@rsvelte/vite-plugin-svelte-native 0.1.4 → 0.2.1

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.
Files changed (2) hide show
  1. package/index.d.ts +50 -0
  2. package/package.json +8 -8
package/index.d.ts CHANGED
@@ -281,6 +281,56 @@ export function compileModuleLegacy(
281
281
  options?: ModuleCompileOptions,
282
282
  ): CompileResult;
283
283
 
284
+ // ---------------------------------------------------------------------------
285
+ // parse
286
+ // ---------------------------------------------------------------------------
287
+
288
+ export interface ParseOptions {
289
+ /**
290
+ * Skip emitting nested `loc: { start, end }` blocks on every embedded
291
+ * JavaScript expression. Top-level `start` / `end` byte offsets are
292
+ * still emitted. Callers that re-parse expression ranges with their
293
+ * own parser (e.g. `svelte-eslint-parser`) get a smaller AST and a
294
+ * meaningfully faster `JSON.parse` (with the JSON path) or a tighter
295
+ * binary buffer (with `parseEnvelope`).
296
+ */
297
+ skipExpressionLoc?: boolean;
298
+ /**
299
+ * Skip emitting the full CSS `StyleSheet` AST. The decoded `css`
300
+ * field becomes a minimal stub
301
+ * (`{ type: "StyleSheet", start, end, attributes: [], children: [], content: { start, end, styles: "", comment: null } }`).
302
+ * Use when the downstream pipeline re-parses `<style>` blocks with
303
+ * its own CSS parser (e.g. `svelte-eslint-parser` uses postcss).
304
+ * Saves ~5–10 KB of buffer per component and skips the matching
305
+ * JSON-parse step.
306
+ */
307
+ skipCssAst?: boolean;
308
+ }
309
+
310
+ /**
311
+ * Parse a Svelte component and return the AST as a JSON string. The
312
+ * caller is responsible for `JSON.parse` on the returned value.
313
+ *
314
+ * For the fastest path skip JSON entirely: use {@link parseEnvelope}
315
+ * with `decodeParseEnvelope` from
316
+ * `@rsvelte/vite-plugin-svelte-native/parse-envelope.js`.
317
+ */
318
+ export function parse(source: string, options?: ParseOptions): string;
319
+
320
+ /**
321
+ * Parse a Svelte component and return a raw-transfer envelope `Buffer`.
322
+ *
323
+ * The buffer is a compact binary encoding of the AST (all 26 template
324
+ * node types and all 74 estree node types are tagged; only a small
325
+ * number of leaf sub-trees — CSS, `SvelteOptions`, directive metadata —
326
+ * fall back to inline JSON behind `TAG_JSON`). Pair with
327
+ * `decodeParseEnvelope` exported from
328
+ * `@rsvelte/vite-plugin-svelte-native/parse-envelope.js` to get the
329
+ * same plain-object AST that `JSON.parse(parse(source))` produces, but
330
+ * without the per-byte `JSON.parse` tokenisation cost.
331
+ */
332
+ export function parseEnvelope(source: string, options?: ParseOptions): Buffer;
333
+
284
334
  // ---------------------------------------------------------------------------
285
335
  // svelte2tsx
286
336
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@rsvelte/vite-plugin-svelte-native",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "NAPI bindings to the rsvelte compiler — used by the @rsvelte vite-plugin-svelte shim",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/baseballyama/rsvelte.git",
9
- "directory": "npm/vite-plugin-svelte-native"
9
+ "directory": "apps/apps/npm/vite-plugin-svelte-native"
10
10
  },
11
- "homepage": "https://github.com/baseballyama/rsvelte/tree/main/npm/vite-plugin-svelte-native#readme",
11
+ "homepage": "https://github.com/baseballyama/rsvelte/tree/main/apps/npm/vite-plugin-svelte-native#readme",
12
12
  "bugs": {
13
13
  "url": "https://github.com/baseballyama/rsvelte/issues"
14
14
  },
@@ -27,11 +27,11 @@
27
27
  "index.d.ts"
28
28
  ],
29
29
  "optionalDependencies": {
30
- "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.1.4",
31
- "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.1.4",
32
- "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.1.4",
33
- "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.1.4",
34
- "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.1.4"
30
+ "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.2.1",
31
+ "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.2.1",
32
+ "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.2.1",
33
+ "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.2.1",
34
+ "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.2.1"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"