Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24.x"
cache: "npm"
Expand All @@ -83,7 +83,7 @@ jobs:

- name: Upload test results
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: browser-test-results-${{ matrix.browser }}
path: test-results/browser
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js 24
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.x
cache: "npm"
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Upload report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: conformance-report
path: |
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
Expand All @@ -51,7 +51,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "26.x"
cache: "npm"
Expand All @@ -76,7 +76,7 @@ jobs:
fi

- name: Upload build artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "26.x"
registry-url: "https://registry.npmjs.org"
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "26.x"
cache: "npm"
Expand All @@ -213,7 +213,7 @@ jobs:
run: node scripts/binaries/smoke.mjs "$BINARY"

- name: Upload the binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: binary-${{ matrix.target }}
path: dist-bin/${{ matrix.binary }}
Expand All @@ -235,12 +235,12 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "26.x"

- name: Download the binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: binary-*
path: dist-bin
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
# Pinned ssg release and the SHA-256 of its linux-amd64 archive, taken from
# the release's checksums.sha256. Update both together.
SSG_VERSION: "1.8.64"
SSG_SHA256: "dfc0a414b53d31984462533a95097ed1eb5815a4b024384cb418ff4acfa2f689"
SSG_VERSION: "1.9.7"
SSG_SHA256: "1999ac5c976f4dab9512044dbd12a2c6b30dd73f521b42c18008fe119d4e5e33"
# Wrangler release used for the deployment; keep in sync with the Makefile.
WRANGLER_VERSION: "4.144.0"

Expand All @@ -69,7 +69,7 @@ jobs:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.x
cache: "npm"
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
run: ./node_modules/.bin/playwright test -c tests/browser/playwright.config.mjs --project=chromium tests/browser/check.spec.mjs

- name: Upload site
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: site
path: site/public
Expand All @@ -140,7 +140,7 @@ jobs:
persist-credentials: false

- name: Download site
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: site
path: site/public
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js 24.x
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.x
cache: "npm"
Expand All @@ -114,7 +114,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js 24.x
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.x
cache: "npm"
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js 26.x
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26.x
cache: "npm"
Expand All @@ -175,7 +175,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js 26.x
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26.x
cache: "npm"
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.5] - 2026-11-13

### Fixed

- **The browser bundle did not load in Safari 15.4 to 16.3** ([#35](https://github.com/spagu/XSLT-Processor/issues/35)): `SyntaxError: Invalid regular expression: invalid group specifier name`. The check for unpaired surrogates of EXSLT `str:encode-uri()`/`str:decode-uri()` used a regex lookbehind, which Safari only parses from 16.4, and a syntax error stops the whole script. It is now a loop over the code units. The build targets the browsers of docs/BROWSER-SUPPORT.md (Chrome/Edge 93, Firefox 92, Safari 15.4) instead of plain ES2022, and `src/browserSupport.test.js` fails on any lookbehind, `v` flag or built-in newer than Safari 15.4 in the sources.
- **@tradik/xslt3 1.0.1 loads in Safari 15.4 to 16.3 as well** (issue #35): title-case number words (`format-integer($n, 'Ww')`) used a regex lookbehind, now a captured word start; the `m` flag's `^` still needs a lookbehind, which is now built at run time after a check of the engine, so Safari before 16.4 gets FORX0002 naming the cause for that one pattern instead of a bundle that does not load. The browser-support test scans `packages/xslt3/src` too.

### Added

- **`fetchOptions` for cross-origin requests** ([#34](https://github.com/spagu/XSLT-Processor/issues/34)): a `RequestInit` for the requests the processor makes itself with `fetch` (the asynchronous API's `xsl:import`, `xsl:include` and `document()` without a loader), e.g. `new XSLTProcessor({ fetchOptions: { credentials: "include" } })` for a server on another origin that needs cookies, the same opt-in as `crossorigin="use-credentials"`. `importStylesheetAsync()` and `transformAsync()` take `fetchOptions` for one call too; the call's `signal` still cancels the request, and a loader of yours is not affected. Documented in docs/LOADERS.md.

### Changed

- **Dependencies and CI**: development dependencies at their latest releases (jsdom 31.0.1, @playwright/test 1.65.0, ESLint 10.14.0, Prettier 3.10.1, linkedom 0.18.15) with minimatch held at 11.0.8 through `overrides` (GHSA-g3hv-75wg-m249 in ESLint's own dependency; `npm audit` is clean); actions/setup-node 7.1.0, actions/upload-artifact 7.0.2, actions/download-artifact 8.0.2; the website is built with ssg 1.9.7, which fixes the fingerprinting of CDN file names we reported (spagu/ssg#316), so the changelog page names the CDN bundle correctly again.

### Security

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The documentation is also published as a website with an interactive playground:
| Guide | Contents |
|-------|----------|
| [API Reference](docs/API.md) | `XSLTProcessor` methods, parameters, `xsl:output` serialization, module exports, `XsltEngine` options, TypeScript |
| [Loaders](docs/LOADERS.md) | `xsl:import`, `xsl:include` and the `document()` function |
| [Loaders](docs/LOADERS.md) | `xsl:import`, `xsl:include` and the `document()` function; `fetchOptions` for cross-origin requests with credentials |
| [Complete Example](docs/EXAMPLES.md) | A product list transformed into an HTML table (browser and CLI) |
| [Command Line Tool](docs/CLI.md) | `xslt` options, base directory, includes, input encodings |
| [Conformance](docs/CONFORMANCE.md) | W3C compliance tables, supported elements and functions, known deviations, test coverage |
Expand Down
5 changes: 3 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ non-W3C options:
| `enableDynamicEvaluate` | Allow EXSLT `dyn:evaluate()` (trusted input only) |
| `clock` | `() => Date` used by EXSLT date functions and `current-dateTime()` |
| `legacyNameTests` | Deprecated: unprefixed name tests also match namespaced nodes, as before 1.2.0 |
| `fetchOptions` | `RequestInit` for the requests the processor makes itself with `fetch` (the asynchronous API's `xsl:import`, `xsl:include` and `document()` when no loader is given), e.g. `{ credentials: "include" }` for a cross-origin server that needs cookies, `{ mode: "cors", headers: {…} }`. A call's `fetchOptions` takes its place for that call; a loader of yours makes its own requests and ignores it. See [Loaders](LOADERS.md#cross-origin-requests-and-credentials) |
| `legacyContentTypeMeta` | html output gets libxslt 1.1.45's `<meta http-equiv="Content-Type" content="text/html; charset=…">`, as up to 1.3.3, instead of Chrome's `<meta charset="…">` (the default since 1.3.4). `serializeResult()` takes the same choice as `contentTypeMeta: "http-equiv"` |
| `legacyXhtmlFragments` | Deprecated: `transformToFragment` turns xml output into XHTML elements of an HTML owner document, as in 1.2.0 to 1.3.0; Chrome and Firefox keep them in no namespace, the default since 1.3.1 |

Expand Down Expand Up @@ -236,8 +237,8 @@ large results incrementally. The synchronous W3C methods are unchanged.

| Method | Description |
|--------|-------------|
| `importStylesheetAsync(style, stylesheetUri?, { loader?, documentLoader?, signal? })` | Loads the `xsl:import`/`xsl:include` tree (in parallel, each URI once) and the literal `document('...')` URIs with `fetch` or a custom loader, then compiles synchronously. `style` may be a Node, a string, bytes, a `ReadableStream` or an async iterable |
| `transformAsync(source, { signal?, stylesheet?, stylesheetUri?, fetchStylesheet?, fetchDocument? })` | Returns a `Promise<string>` with the serialized result; failures reject. Sources may be nodes, strings, bytes, `ReadableStream`s or async iterables, decoded by byte order mark, then the XML declaration's encoding, then UTF-8 |
| `importStylesheetAsync(style, stylesheetUri?, { loader?, documentLoader?, signal?, fetchOptions? })` | Loads the `xsl:import`/`xsl:include` tree (in parallel, each URI once) and the literal `document('...')` URIs with `fetch` or a custom loader, then compiles synchronously. `style` may be a Node, a string, bytes, a `ReadableStream` or an async iterable |
| `transformAsync(source, { signal?, stylesheet?, stylesheetUri?, fetchStylesheet?, fetchDocument?, fetchOptions? })` | Returns a `Promise<string>` with the serialized result; failures reject. Sources may be nodes, strings, bytes, `ReadableStream`s or async iterables, decoded by byte order mark, then the XML declaration's encoding, then UTF-8 |
| `transformToStream(source, { signal?, chunkSize? })` | Returns a `ReadableStream<string>` serialized on demand in chunks of about 16 KiB, with backpressure and cancellation |

```js
Expand Down
13 changes: 11 additions & 2 deletions docs/BROWSER-SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Browser Compatibility

The bundles are built for ES2022 without transpiling and use `Object.hasOwn()`
and `Array.prototype.at()`, which set the minimum browser versions below.
The bundles are built for the browsers below (esbuild targets `chrome93`,
`edge93`, `firefox92`, `safari15.4`), so newer syntax is lowered for them.
What esbuild cannot lower is kept out of the sources of the library and of
`@tradik/xslt3` by a test (`src/browserSupport.test.js`): regular expression lookbehind, the `v` flag,
and built-ins newer than Safari 15.4 such as `isWellFormed()`, `toSorted()` or
`Object.groupBy()`. A lookbehind made the 1.3.4 bundle a `SyntaxError` in
Safari 15.4 to 16.3 (issue #35). The one exception is the `m` flag of
`@tradik/xslt3`'s regular expressions, which builds a lookbehind at run time
only after checking that the engine has it, and otherwise raises FORX0002
naming Safari before 16.4. `Object.hasOwn()` and
`Array.prototype.at()` set the minimum versions.

## Polyfill Support

Expand Down
35 changes: 35 additions & 0 deletions docs/LOADERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ an XML string. See the [API Reference](API.md) for the rest of the API.
- [Advanced: the engine accessor](#advanced-the-engine-accessor)
- [Using the document() function](#using-the-document-function)
- [Import vs Include Behavior](#import-vs-include-behavior)
- [Cross-origin requests and credentials](#cross-origin-requests-and-credentials)

## Using xsl:import and xsl:include

Expand Down Expand Up @@ -169,3 +170,37 @@ const result = processor.transformToDocument(xmlDoc);
</xsl:template>
</xsl:stylesheet>
```

## Cross-origin requests and credentials

Without a loader, the asynchronous API (`importStylesheetAsync`,
`transformAsync`) loads `xsl:import`, `xsl:include` and literal `document()`
URIs with the global `fetch`. Its defaults are `fetch`'s own: CORS for another
origin, cookies only for the same origin. A server on another origin that
needs cookies or HTTP authentication gets them with `fetchOptions`, any
[`RequestInit`](https://developer.mozilla.org/docs/Web/API/RequestInit):

```js
// Every request of this processor sends credentials
const processor = new XSLTProcessor({
fetchOptions: { credentials: "include" },
});
await processor.importStylesheetAsync(
(await fetch(url, { credentials: "include" })).body,
url,
);

// Or for one call: takes the place of the processor's fetchOptions
await processor.importStylesheetAsync(stylesheet, url, {
fetchOptions: { credentials: "include", headers: { "X-Client": "app" } },
});
```

This is the same opt-in as `crossorigin="use-credentials"` on a `<script>`
or `<link>`: the server has to answer with
`Access-Control-Allow-Credentials: true` and a specific
`Access-Control-Allow-Origin` (not `*`), as for any credentialed CORS
request. The call's `signal` still cancels the request. A loader of your own
makes its own requests, so `fetchOptions` does not apply to it; set the
options in its `fetch` call. The stylesheet you pass in is fetched by you,
so give that `fetch` the same options.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ implements the W3C `XSLTProcessor` API for browsers and Node.js and ships an
| Guide | Contents |
|-------|----------|
| [API Reference](API.md) | `XSLTProcessor` methods, parameters, `xsl:output` serialization, module exports, `XsltEngine` options, TypeScript |
| [Loaders](LOADERS.md) | `xsl:import`, `xsl:include` and the `document()` function |
| [Loaders](LOADERS.md) | `xsl:import`, `xsl:include` and the `document()` function; `fetchOptions` for cross-origin requests with credentials |
| [Complete Example](EXAMPLES.md) | A product list transformed into an HTML table (browser and CLI) |
| [Command Line Tool](CLI.md) | `xslt` options, base directory, includes, input encodings |
| [Conformance](CONFORMANCE.md) | W3C compliance tables, supported elements and functions, known deviations, test coverage |
Expand Down
1 change: 1 addition & 0 deletions docs/XSLT3.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typing and XQuery.
| Years | -999,999,999 to 999,999,999 (XSD 1.1: year 0 exists) |
| Implicit timezone | an option, default UTC |
| `xs:anyURI` | lexical form not validated |
| Regex `m` flag with `^` | needs regular expression lookbehind; Safari 15.4 to 16.3 lack it and raise FORX0002 naming the cause (every other pattern works there) |

## Milestones

Expand Down
Loading
Loading