@rsvelte/vite-plugin-svelte-native 0.2.7 → 0.2.8
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/package.json +6 -6
- package/parse-envelope.js +54 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsvelte/vite-plugin-svelte-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "NAPI bindings to the rsvelte compiler — used by the @rsvelte vite-plugin-svelte shim",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"index.d.ts"
|
|
30
30
|
],
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.2.
|
|
33
|
-
"@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.2.
|
|
34
|
-
"@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.2.
|
|
35
|
-
"@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.2.
|
|
36
|
-
"@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.2.
|
|
32
|
+
"@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.2.8",
|
|
33
|
+
"@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.2.8",
|
|
34
|
+
"@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.2.8",
|
|
35
|
+
"@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.2.8",
|
|
36
|
+
"@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.2.8"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
package/parse-envelope.js
CHANGED
|
@@ -155,6 +155,11 @@ const JS_NULL = 0xca;
|
|
|
155
155
|
// 0xcb was the former whole-node JS_RAW_JSON escape (removed — TS type
|
|
156
156
|
// annotations now ride a per-node trailer; see readOptTypeAnnotation).
|
|
157
157
|
const JS_TS_PARAMETER_PROPERTY = 0xcc;
|
|
158
|
+
const JS_TS_AS_EXPRESSION = 0xcd;
|
|
159
|
+
const JS_TS_SATISFIES_EXPRESSION = 0xce;
|
|
160
|
+
const JS_TS_NON_NULL_EXPRESSION = 0xcf;
|
|
161
|
+
const JS_TS_TYPE_ASSERTION = 0xd0;
|
|
162
|
+
const JS_TS_INSTANTIATION_EXPRESSION = 0xd1;
|
|
158
163
|
|
|
159
164
|
// LiteralValue inner tag (within a JS_LITERAL payload).
|
|
160
165
|
const LV_NULL = 0;
|
|
@@ -581,6 +586,16 @@ function readNodeBody(ctx, tag, start, end) {
|
|
|
581
586
|
return readJsBareExpr(ctx, 'TSParameterProperty', start, end);
|
|
582
587
|
case JS_TS_MODULE_DECLARATION:
|
|
583
588
|
return readJsTSModuleDeclaration(ctx, start, end);
|
|
589
|
+
case JS_TS_AS_EXPRESSION:
|
|
590
|
+
return readJsTSAssertion(ctx, 'TSAsExpression', start, end, true);
|
|
591
|
+
case JS_TS_SATISFIES_EXPRESSION:
|
|
592
|
+
return readJsTSAssertion(ctx, 'TSSatisfiesExpression', start, end, true);
|
|
593
|
+
case JS_TS_NON_NULL_EXPRESSION:
|
|
594
|
+
return readJsTSAssertion(ctx, 'TSNonNullExpression', start, end, false);
|
|
595
|
+
case JS_TS_TYPE_ASSERTION:
|
|
596
|
+
return readJsTSTypeAssertion(ctx, start, end);
|
|
597
|
+
case JS_TS_INSTANTIATION_EXPRESSION:
|
|
598
|
+
return readJsTSInstantiationExpression(ctx, start, end);
|
|
584
599
|
case JS_COMMENT:
|
|
585
600
|
return readJsComment_(ctx, start, end);
|
|
586
601
|
|
|
@@ -975,6 +990,45 @@ function readJsChainExpression(ctx, start, end) {
|
|
|
975
990
|
return node;
|
|
976
991
|
}
|
|
977
992
|
|
|
993
|
+
// TS assertion wrappers (`x as T` / `x satisfies T` / `x!`). As/Satisfies carry
|
|
994
|
+
// a `typeAnnotation` trailer; NonNull does not (`hasTypeAnnotation` is false).
|
|
995
|
+
function readJsTSAssertion(ctx, typeName, start, end, hasTypeAnnotation) {
|
|
996
|
+
const loc = readTypedLoc(ctx);
|
|
997
|
+
const expression = readNode(ctx);
|
|
998
|
+
const node = { type: typeName, start, end };
|
|
999
|
+
if (loc !== null) node.loc = loc;
|
|
1000
|
+
node.expression = expression;
|
|
1001
|
+
if (hasTypeAnnotation) {
|
|
1002
|
+
const typeAnnotation = readOptTypeAnnotation(ctx);
|
|
1003
|
+
if (typeAnnotation !== null) node.typeAnnotation = typeAnnotation;
|
|
1004
|
+
}
|
|
1005
|
+
return node;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
function readJsTSTypeAssertion(ctx, start, end) {
|
|
1009
|
+
// Wire order: loc, expression, typeAnnotation — but svelte/compiler emits
|
|
1010
|
+
// `typeAnnotation` before `expression`, so build the object in that order.
|
|
1011
|
+
const loc = readTypedLoc(ctx);
|
|
1012
|
+
const expression = readNode(ctx);
|
|
1013
|
+
const typeAnnotation = readOptTypeAnnotation(ctx);
|
|
1014
|
+
const node = { type: 'TSTypeAssertion', start, end };
|
|
1015
|
+
if (loc !== null) node.loc = loc;
|
|
1016
|
+
if (typeAnnotation !== null) node.typeAnnotation = typeAnnotation;
|
|
1017
|
+
node.expression = expression;
|
|
1018
|
+
return node;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function readJsTSInstantiationExpression(ctx, start, end) {
|
|
1022
|
+
const loc = readTypedLoc(ctx);
|
|
1023
|
+
const expression = readNode(ctx);
|
|
1024
|
+
const typeArguments = readOptTypeAnnotation(ctx);
|
|
1025
|
+
const node = { type: 'TSInstantiationExpression', start, end };
|
|
1026
|
+
if (loc !== null) node.loc = loc;
|
|
1027
|
+
node.expression = expression;
|
|
1028
|
+
if (typeArguments !== null) node.typeArguments = typeArguments;
|
|
1029
|
+
return node;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
978
1032
|
function readJsMetaProperty(ctx, start, end) {
|
|
979
1033
|
const loc = readTypedLoc(ctx);
|
|
980
1034
|
const meta = readNode(ctx);
|