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

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/package.json +6 -6
  2. package/parse-envelope.js +51 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsvelte/vite-plugin-svelte-native",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
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-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"
33
+ "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.3.10",
34
+ "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.3.10",
35
+ "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.3.10",
36
+ "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.3.10",
37
+ "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.3.10"
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 = 5;
22
+ const VERSION = 8;
23
23
  const HEADER_LEN = 24;
24
24
 
25
25
  // Tags — must mirror napi_raw_parse.rs.
@@ -80,7 +80,7 @@ const TAG_AWAIT_BLOCK = 0x72;
80
80
  const TAG_KEY_BLOCK = 0x73;
81
81
  const TAG_SNIPPET_BLOCK = 0x74;
82
82
 
83
- // JsNode (estree) tags — 0x80..0xCC. Mirrors `napi_raw_parse.rs`.
83
+ // JsNode (estree) tags — 0x80..0xD1. Mirrors `napi_raw_parse.rs`.
84
84
  const JS_IDENTIFIER = 0x80;
85
85
  const JS_PRIVATE_IDENTIFIER = 0x81;
86
86
  const JS_LITERAL = 0x82;
@@ -140,6 +140,8 @@ const JS_CONTINUE_STATEMENT = 0xb7;
140
140
  const JS_EMPTY_STATEMENT = 0xb8;
141
141
  const JS_DEBUGGER_STATEMENT = 0xb9;
142
142
  const JS_IMPORT_DECLARATION = 0xba;
143
+ const JS_IMPORT_ATTRIBUTE = 0xd2;
144
+ const JS_EXPORT_ALL_DECLARATION = 0xd3;
143
145
  const JS_IMPORT_SPECIFIER = 0xbb;
144
146
  const JS_IMPORT_DEFAULT_SPECIFIER = 0xbc;
145
147
  const JS_IMPORT_NAMESPACE_SPECIFIER = 0xbd;
@@ -152,7 +154,6 @@ const JS_PROPERTY_DEFINITION = 0xc3;
152
154
  const JS_STATIC_BLOCK = 0xc4;
153
155
  const JS_DECORATOR = 0xc5;
154
156
  const JS_TS_TYPE_ANNOTATION = 0xc6;
155
- const JS_TS_ENUM_DECLARATION = 0xc7;
156
157
  const JS_TS_MODULE_DECLARATION = 0xc8;
157
158
  const JS_COMMENT = 0xc9;
158
159
  const JS_NULL = 0xca;
@@ -561,6 +562,8 @@ function readNodeBody(ctx, tag, start, end) {
561
562
  return readJsBareExpr(ctx, 'DebuggerStatement', start, end);
562
563
  case JS_IMPORT_DECLARATION:
563
564
  return readJsImportDeclaration(ctx, start, end);
565
+ case JS_IMPORT_ATTRIBUTE:
566
+ return readJsImportAttribute(ctx, start, end);
564
567
  case JS_IMPORT_SPECIFIER:
565
568
  return readJsImportSpecifier(ctx, start, end);
566
569
  case JS_IMPORT_DEFAULT_SPECIFIER:
@@ -571,6 +574,8 @@ function readNodeBody(ctx, tag, start, end) {
571
574
  return readJsExportNamedDeclaration(ctx, start, end);
572
575
  case JS_EXPORT_DEFAULT_DECLARATION:
573
576
  return readJsExportDefaultDeclaration(ctx, start, end);
577
+ case JS_EXPORT_ALL_DECLARATION:
578
+ return readJsExportAllDeclaration(ctx, start, end);
574
579
  case JS_EXPORT_SPECIFIER:
575
580
  return readJsExportSpecifier(ctx, start, end);
576
581
  case JS_CLASS_BODY:
@@ -585,8 +590,6 @@ function readNodeBody(ctx, tag, start, end) {
585
590
  return readJsBareExpr(ctx, 'Decorator', start, end);
586
591
  case JS_TS_TYPE_ANNOTATION:
587
592
  return readJsTSTypeAnnotation(ctx, start, end);
588
- case JS_TS_ENUM_DECLARATION:
589
- return readJsBareExpr(ctx, 'TSEnumDeclaration', start, end);
590
593
  case JS_TS_PARAMETER_PROPERTY:
591
594
  return readJsBareExpr(ctx, 'TSParameterProperty', start, end);
592
595
  case JS_TS_MODULE_DECLARATION:
@@ -978,11 +981,18 @@ function readJsBareExpr(ctx, typeName, start, end) {
978
981
  function readJsImportExpression(ctx, start, end) {
979
982
  const loc = readTypedLoc(ctx);
980
983
  const source = readNode(ctx);
984
+ const options = readChildArray(ctx);
985
+ const ts = readBool(ctx);
981
986
  const node = { type: 'ImportExpression', start, end };
982
987
  if (loc !== null) node.loc = loc;
983
988
  node.source = source;
984
- // The upstream serializer also adds `options: null`. Match that.
985
- node.options = null;
989
+ // acorn-typescript spells the second argument as an `arguments` list and
990
+ // omits the key when there is none; acorn always writes `options`.
991
+ if (ts) {
992
+ if (options.length > 0) node.arguments = options;
993
+ } else {
994
+ node.options = options.length > 0 ? options[0] : null;
995
+ }
986
996
  return node;
987
997
  }
988
998
 
@@ -1416,7 +1426,19 @@ function readJsImportDeclaration(ctx, start, end) {
1416
1426
  node.specifiers = specifiers;
1417
1427
  node.source = source;
1418
1428
  if (importKind !== null) node.importKind = importKind;
1419
- node.attributes = attributes;
1429
+ // See `readJsExportNamedDeclaration`.
1430
+ if (importKind === null || attributes.length > 0) node.attributes = attributes;
1431
+ return node;
1432
+ }
1433
+
1434
+ function readJsImportAttribute(ctx, start, end) {
1435
+ const loc = readTypedLoc(ctx);
1436
+ const key = readNode(ctx);
1437
+ const value = readNode(ctx);
1438
+ const node = { type: 'ImportAttribute', start, end };
1439
+ if (loc !== null) node.loc = loc;
1440
+ node.key = key;
1441
+ node.value = value;
1420
1442
  return node;
1421
1443
  }
1422
1444
 
@@ -1464,15 +1486,35 @@ function readJsExportNamedDeclaration(ctx, start, end) {
1464
1486
  node.specifiers = specifiers;
1465
1487
  node.source = source;
1466
1488
  if (exportKind !== null) node.exportKind = exportKind;
1467
- node.attributes = attributes;
1489
+ // acorn always writes `attributes`; acorn-typescript writes it only where the
1490
+ // source had a `with` clause, and `exportKind` is set for TypeScript alone.
1491
+ if (exportKind === null || attributes.length > 0) node.attributes = attributes;
1492
+ return node;
1493
+ }
1494
+
1495
+ function readJsExportAllDeclaration(ctx, start, end) {
1496
+ const loc = readTypedLoc(ctx);
1497
+ const exported = readOptNode(ctx);
1498
+ const source = readNode(ctx);
1499
+ const exportKind = readOptStr(ctx);
1500
+ const attributes = readChildArray(ctx);
1501
+ const node = { type: 'ExportAllDeclaration', start, end };
1502
+ if (loc !== null) node.loc = loc;
1503
+ if (exportKind !== null) node.exportKind = exportKind;
1504
+ node.exported = exported;
1505
+ node.source = source;
1506
+ // See `readJsExportNamedDeclaration`.
1507
+ if (exportKind === null || attributes.length > 0) node.attributes = attributes;
1468
1508
  return node;
1469
1509
  }
1470
1510
 
1471
1511
  function readJsExportDefaultDeclaration(ctx, start, end) {
1472
1512
  const loc = readTypedLoc(ctx);
1473
1513
  const declaration = readNode(ctx);
1514
+ const exportKind = readOptStr(ctx);
1474
1515
  const node = { type: 'ExportDefaultDeclaration', start, end };
1475
1516
  if (loc !== null) node.loc = loc;
1517
+ if (exportKind !== null) node.exportKind = exportKind;
1476
1518
  node.declaration = declaration;
1477
1519
  return node;
1478
1520
  }