Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Refactor transform to be isomorphic (Node/web compatibility) #171

Merged
merged 24 commits into from
Mar 15, 2023

Commits on Feb 18, 2023

  1. Convert transform to async/await

    Includes tests around API stability, as these expectations were all broken in a previous naive attempt at the same change
    eyelidlessness committed Feb 18, 2023
    Configuration menu
    Copy the full SHA
    e02efa9 View commit details
    Browse the repository at this point in the history

Commits on Feb 19, 2023

  1. Initial Node/DOM compatibility

    1. Introduces an abstract subset of DOM APIs corresponding to previous usage of semantically equivalent `libxmljs` APIs. It would have been nicer to import these types and export the subset we care about, but this is inconsistent with how TypeScript `lib` works (it always augments the global scope).
    
    2. Provides a Node implementation of those DOM APIs by extending `libxmljs` prototypes. This kind of extension isn't ideal, but it's the most reasonable way to achieve such a compatibility layer without sacrificing performance. An ealirer alternative approach used `WeakMap`s to cross reference the DOM/`libxmljs` interfaces, but this had a significant impact on perf. This implementation is type checked by default.
    
    3. Provides a web implementation by... just exporting the relevant globals. This implementation is type checked by `tsc` using the `tsconfig.web.json` project file. This ensures that the abstract DOM interfaces are actully consistent with the built in DOM `lib` types.
    
    4. Refactors transformer.ts to use the abstract DOM APIs. This uses the Node DOM compatibility implementation by default, and the native web DOM implementation when the environment variable `ENV` is set to "web".
    
    5. Also when `ENV` is web, tests and benchmarks call `transform` in the specified `BROWSER` environment variable (defaulting to "fiefox") via a simple `playwright` bridge. In CI, all tests and benchmarks are run in: Node 14, Node 16, Firefox, Chromium, Webkit.
    
    6. Build is updated to produce both Node and web targets. The build config itself is fairly complex, but it's been consolidated in `vite.config.ts`. This also includes a corresponding change to build `app.ts` rather than the previous, much more complex `app.js` using a Vite dev server (and roughly restores its implementation to what it had been prior to the initial TypeScript migration).
    
    7. There are several known issues at the point of this commit. These either correspond to XSLT extensions not supported by browser targets, or to differences in behavior between DOM/`libxmljs`, all of which will be addressed in separate commits discussing each in greater detail.
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    6242fbe View commit details
    Browse the repository at this point in the history
  2. Fix: consistent URL escaping in web environments

    This addresses a slight difference between Node's and browsers' respective implementations of `URL`, namely that browsers do not implicitly escape special path characters for unknown schemes (i.e. `jr`). This change is a workaround, temporarily substituting the `jr` scheme to consistently take advantage of built-in escaping behavior, then restoring it for the final return value.
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    916e2e3 View commit details
    Browse the repository at this point in the history
  3. Fix: HTML document/"fragment" hierarchy

    This addresses:
    
    - an inconsistency between how `libxslt` and the native DOM `XSLTProcessor` handle XSLT transforms to HTML.`libxslt` (correctly, IMO) treats the XSLT document's expressed root element as the resulting document element, whereas browsers produce a document with an implicit `html > body > root` structure.
    
    - a slight change in `renderMarkdown` which parses to a document rather than a fragment, for the purpose of a simpler DOM compatibiity API in this case. (That call to `correctHTMLDocHierarchy` was mistakenly included in an earlier commit, but I'm hoping this subsequent commit will be clear enough and we'll likely squash these commits anyhow.)
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    a0238fe View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cda915a View commit details
    Browse the repository at this point in the history
  5. Remove fatal errors from XSL from unsupported extensions

    The functionality depending on them will be reimplemented with DOM APIs
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    b46e7b5 View commit details
    Browse the repository at this point in the history
  6. Fix: Firefox does not apply templates to attributes

    It's possible there are other attribute cases I haven't identified, but these are the ones I was able to find in test failures, snapshot mismatches, and the spec.
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    29a733f View commit details
    Browse the repository at this point in the history
  7. Fix: dynamic itemset itext translations

    These dynamic template calls are now injected into the XSL, allowing us to eliminate the use of `str:replace` and `dyn:evaluate` extensions.
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    4227fe4 View commit details
    Browse the repository at this point in the history
  8. Fix: transform appearance classes in transformer.ts

    This eliminates the need to use `str:tokenize` extension
    eyelidlessness committed Feb 19, 2023
    Configuration menu
    Copy the full SHA
    3d93e1b View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2023

  1. Add web demo

    eyelidlessness committed Feb 21, 2023
    Configuration menu
    Copy the full SHA
    538bcfe View commit details
    Browse the repository at this point in the history
  2. Web test/benchmark setup refinements

    Faster Firefox startup, improved logging
    eyelidlessness committed Feb 21, 2023
    Configuration menu
    Copy the full SHA
    d9ae798 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    97c1513 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9a4a1a1 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5c6f898 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    fdb904c View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2023

  1. Attempt to report summaries to PR

    Also bumps actions versions which have been warning about Node 12 for no apparent reason
    eyelidlessness committed Feb 22, 2023
    Configuration menu
    Copy the full SHA
    77eb952 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    51595b4 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2023

  1. Configuration menu
    Copy the full SHA
    69109d0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    50d2f76 View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2023

  1. Address initial review feedback

    - Update README
    - Clarify change to URL escaping implementation per initial review feedback
    eyelidlessness committed Mar 2, 2023
    Configuration menu
    Copy the full SHA
    13b1e9c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    885eac7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e480bfe View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    671d5c6 View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2023

  1. Demo tweaks

    - Add demo dev mode (very useful for manual testing during dev)
    - Actually display errors
    - Don't show Invalid state on errors
    eyelidlessness committed Mar 3, 2023
    Configuration menu
    Copy the full SHA
    6efd980 View commit details
    Browse the repository at this point in the history