@rsvelte/vite-plugin-svelte-native 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -254,4 +254,4 @@ module.exports.decodeParseEnvelope = decodeParseEnvelope;
254
254
  // with `submodules/svelte/packages/svelte/package.json` by hand; run
255
255
  // `node scripts/dev/check-vps-version.mjs` (also wired into CI) to
256
256
  // catch drift.
257
- module.exports.VERSION = '5.56.9';
257
+ module.exports.VERSION = '5.56.10';
package/index.d.ts CHANGED
@@ -193,6 +193,13 @@ export function compileModule(
193
193
  * {@link decodeEnvelope} to obtain
194
194
  * the legacy {@link CompileResult} shape; or pass the buffer through
195
195
  * worker `postMessage` (transferable) to avoid a copy.
196
+ *
197
+ * Unlike {@link compile}, this does NOT go through the wrapper that resolves
198
+ * upstream's function-valued options, so a `runes` / `css` / `customElement` /
199
+ * `warningFilter` callback is **rejected** here rather than honoured — evaluate
200
+ * it yourself and pass the plain value. `runes` and `warningFilter` used to be
201
+ * dropped in silence instead, which produced a successful compile with the
202
+ * wrong result; `css` and `customElement` already threw.
196
203
  */
197
204
  export function compileEnvelope(source: string, options?: CompileOptions): Buffer;
198
205
  export function compileModuleEnvelope(
@@ -328,6 +335,13 @@ export function compileModuleBuffers(
328
335
  /**
329
336
  * The legacy JSON-on-the-boundary path. Kept exported for parity tests
330
337
  * and as an escape hatch — production callers should use {@link compile}.
338
+ *
339
+ * Unlike {@link compile}, this does NOT go through the wrapper that resolves
340
+ * upstream's function-valued options, so a `runes` / `css` / `customElement` /
341
+ * `warningFilter` callback is **rejected** here rather than honoured — evaluate
342
+ * it yourself and pass the plain value. `runes` and `warningFilter` used to be
343
+ * dropped in silence instead, which produced a successful compile with the
344
+ * wrong result; `css` and `customElement` already threw.
331
345
  */
332
346
  export function compileLegacy(source: string, options?: CompileOptions): CompileResult;
333
347
  export function compileModuleLegacy(
@@ -359,12 +373,29 @@ export interface ParseOptions {
359
373
  * JSON-parse step.
360
374
  */
361
375
  skipCssAst?: boolean;
376
+ /**
377
+ * `modern` from `svelte/compiler`'s `parse()`. **Defaults to `false`**,
378
+ * which returns the LEGACY AST (`{ html, instance, module, css }`); pass
379
+ * `true` for the modern `Root` shape. The modern AST stays opt-in until
380
+ * Svelte 6, and this binding defaults the same way official does.
381
+ */
382
+ modern?: boolean;
383
+ /**
384
+ * `loose` from `svelte/compiler`'s `parse()`. Recover from a parse error
385
+ * and return an AST anyway — what an editor integration needs to parse a
386
+ * document mid-keystroke. Not blanket recovery: a source official still
387
+ * rejects under `loose` (e.g. a stray `</div>`) throws here too.
388
+ */
389
+ loose?: boolean;
362
390
  }
363
391
 
364
392
  /**
365
393
  * Parse a Svelte component and return the AST as a JSON string. The
366
394
  * caller is responsible for `JSON.parse` on the returned value.
367
395
  *
396
+ * Without `{ modern: true }` this returns the LEGACY AST, matching
397
+ * `svelte/compiler`'s default.
398
+ *
368
399
  * For the fastest path skip JSON entirely: use {@link parseEnvelope}
369
400
  * with `decodeParseEnvelope` from
370
401
  * `@rsvelte/vite-plugin-svelte-native/parse-envelope.js`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsvelte/vite-plugin-svelte-native",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "NAPI bindings to the rsvelte compiler — used by the @rsvelte vite-plugin-svelte shim",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,11 +30,11 @@
30
30
  "index.d.ts"
31
31
  ],
32
32
  "optionalDependencies": {
33
- "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.3.8",
34
- "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.3.8",
35
- "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.3.8",
36
- "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.3.8",
37
- "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.3.8"
33
+ "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.3.9",
34
+ "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.3.9",
35
+ "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.3.9",
36
+ "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.3.9",
37
+ "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.3.9"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
package/parse-envelope.js CHANGED
@@ -19,7 +19,7 @@ const MAGIC = 0x3156_5052; // "RPV1" little-endian
19
19
  // reorder, `typeParameters` on function-like nodes, Identifier `optional`);
20
20
  // v4 adds the object-method `typeParameters`-after-`body` flag byte.
21
21
  // Keep in lockstep with `napi_raw_parse.rs`'s `VERSION`.
22
- const VERSION = 4;
22
+ const VERSION = 5;
23
23
  const HEADER_LEN = 24;
24
24
 
25
25
  // Tags — must mirror napi_raw_parse.rs.
@@ -1652,7 +1652,14 @@ function readJsComment(ctx, start, end) {
1652
1652
  const kindByte = readU8(ctx);
1653
1653
  const kind = kindByte === 1 ? 'Block' : 'Line';
1654
1654
  const value = readStr(ctx);
1655
+ // Only an in-tag comment's `loc` carries `character`; a script comment's
1656
+ // comes from the JS parser, which does not produce one.
1657
+ const hasCharacter = readU8(ctx) === 1;
1655
1658
  const loc = readSourceLocation(ctx);
1659
+ if (!hasCharacter) {
1660
+ delete loc.start.character;
1661
+ delete loc.end.character;
1662
+ }
1656
1663
  return { type: kind, start, end, value, loc };
1657
1664
  }
1658
1665