yuku-codegen 0.5.18 → 0.5.20
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/README.md +2 -2
- package/encode.js +16 -23
- package/index.d.ts +3 -3
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ interface CodegenResult {
|
|
|
50
50
|
const out = print(program, {
|
|
51
51
|
format: "pretty",
|
|
52
52
|
indent: 2,
|
|
53
|
-
quotes: "
|
|
53
|
+
quotes: "preserve",
|
|
54
54
|
comments: "some",
|
|
55
55
|
sourceMaps: { lineStarts },
|
|
56
56
|
});
|
|
@@ -60,7 +60,7 @@ const out = print(program, {
|
|
|
60
60
|
| ------------ | ---------------------------------------- | ---------- | ---------------------------------------------------------------------------- |
|
|
61
61
|
| `format` | `"pretty" \| "compact"` | `"pretty"` | Whitespace mode. `"compact"` emits only the separators the grammar requires. |
|
|
62
62
|
| `indent` | `number` | `2` | Spaces per indentation level. Applies in pretty mode only. |
|
|
63
|
-
| `quotes` | `"double" \| "single"`
|
|
63
|
+
| `quotes` | `"preserve" \| "double" \| "single"` | `"preserve"` | Quote style for string literals. `"preserve"` keeps each literal's source quote style (re-escaping the content); `"double"` / `"single"` force one. |
|
|
64
64
|
| `comments` | `boolean \| "some" \| "line" \| "block"` | `"some"` | Comment passthrough filter. See [Comments](#comments). |
|
|
65
65
|
| `sourceMaps` | `SourceMapOptions` | `undefined` | Pass an object to emit a Source Map V3. Its `lineStarts` is required, the rest of the metadata is optional. See [Source maps](#source-maps). |
|
|
66
66
|
|
package/encode.js
CHANGED
|
@@ -162,7 +162,7 @@ function encode(program, lineStarts) {
|
|
|
162
162
|
if (n == null) return NULL;
|
|
163
163
|
return enc_label_identifier(n);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function encName(n) {
|
|
166
166
|
if (n == null) return NULL;
|
|
167
167
|
if (n.type === "Identifier") return enc_identifier_name(n);
|
|
168
168
|
return encNode(n);
|
|
@@ -372,7 +372,7 @@ function encode(program, lineStarts) {
|
|
|
372
372
|
function enc_object_property(n) {
|
|
373
373
|
const k = n.key == null
|
|
374
374
|
? NULL
|
|
375
|
-
: (n.computed ? encNode(n.key) :
|
|
375
|
+
: (n.computed ? encNode(n.key) : encName(n.key));
|
|
376
376
|
const v = n.value == null ? NULL : encNode(n.value);
|
|
377
377
|
const idx = alloc();
|
|
378
378
|
tagAt(idx, 17);
|
|
@@ -390,7 +390,7 @@ function encode(program, lineStarts) {
|
|
|
390
390
|
const o = n.object == null ? NULL : encNode(n.object);
|
|
391
391
|
const p = n.property == null
|
|
392
392
|
? NULL
|
|
393
|
-
: (n.computed ? encNode(n.property) :
|
|
393
|
+
: (n.computed ? encNode(n.property) : encName(n.property));
|
|
394
394
|
const idx = alloc();
|
|
395
395
|
tagAt(idx, 18);
|
|
396
396
|
slotAt(idx, 0, o); slotAt(idx, 1, p);
|
|
@@ -525,7 +525,7 @@ function encode(program, lineStarts) {
|
|
|
525
525
|
}
|
|
526
526
|
function enc_method_definition(n, abstract) {
|
|
527
527
|
const decs = encArr(n.decorators, encNode);
|
|
528
|
-
const k = n.computed ? encNode(n.key) :
|
|
528
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
529
529
|
const v = encNode(n.value);
|
|
530
530
|
const idx = alloc();
|
|
531
531
|
tagAt(idx, 29);
|
|
@@ -547,7 +547,7 @@ function encode(program, lineStarts) {
|
|
|
547
547
|
}
|
|
548
548
|
function enc_property_definition(n, accessor, abstract) {
|
|
549
549
|
const decs = encArr(n.decorators, encNode);
|
|
550
|
-
const k = n.computed ? encNode(n.key) :
|
|
550
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
551
551
|
const v = n.value == null ? NULL : encNode(n.value);
|
|
552
552
|
const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
|
|
553
553
|
const idx = alloc();
|
|
@@ -1066,7 +1066,7 @@ function encode(program, lineStarts) {
|
|
|
1066
1066
|
function enc_binding_property(p) {
|
|
1067
1067
|
const k = p.key == null
|
|
1068
1068
|
? NULL
|
|
1069
|
-
: (p.computed ? encNode(p.key) :
|
|
1069
|
+
: (p.computed ? encNode(p.key) : encName(p.key));
|
|
1070
1070
|
const v = p.value == null ? NULL : encBindingTarget(p.value);
|
|
1071
1071
|
const idx = alloc();
|
|
1072
1072
|
tagAt(idx, 73);
|
|
@@ -1119,7 +1119,7 @@ function encode(program, lineStarts) {
|
|
|
1119
1119
|
return idx;
|
|
1120
1120
|
}
|
|
1121
1121
|
function enc_import_specifier(n) {
|
|
1122
|
-
const c_imported = n.imported == null ? NULL :
|
|
1122
|
+
const c_imported = n.imported == null ? NULL : encName(n.imported);
|
|
1123
1123
|
const c_local = n.local == null ? NULL : encBindingTarget(n.local);
|
|
1124
1124
|
const idx = alloc();
|
|
1125
1125
|
tagAt(idx, 77);
|
|
@@ -1149,7 +1149,7 @@ function encode(program, lineStarts) {
|
|
|
1149
1149
|
return idx;
|
|
1150
1150
|
}
|
|
1151
1151
|
function enc_import_attribute(n) {
|
|
1152
|
-
const c_key = n.key == null ? NULL :
|
|
1152
|
+
const c_key = n.key == null ? NULL : encName(n.key);
|
|
1153
1153
|
const c_value = n.value == null ? NULL : encNode(n.value);
|
|
1154
1154
|
const idx = alloc();
|
|
1155
1155
|
tagAt(idx, 80);
|
|
@@ -1187,7 +1187,7 @@ function encode(program, lineStarts) {
|
|
|
1187
1187
|
return idx;
|
|
1188
1188
|
}
|
|
1189
1189
|
function enc_export_all_declaration(n) {
|
|
1190
|
-
const c_exported = n.exported == null ? NULL :
|
|
1190
|
+
const c_exported = n.exported == null ? NULL : encName(n.exported);
|
|
1191
1191
|
const c_source = n.source == null ? NULL : encNode(n.source);
|
|
1192
1192
|
const c_attributes = encArr(n.attributes, encNode);
|
|
1193
1193
|
const idx = alloc();
|
|
@@ -1203,7 +1203,7 @@ function encode(program, lineStarts) {
|
|
|
1203
1203
|
}
|
|
1204
1204
|
function enc_export_specifier(n) {
|
|
1205
1205
|
const c_local = n.local == null ? NULL : encNode(n.local);
|
|
1206
|
-
const c_exported = n.exported == null ? NULL :
|
|
1206
|
+
const c_exported = n.exported == null ? NULL : encName(n.exported);
|
|
1207
1207
|
const idx = alloc();
|
|
1208
1208
|
tagAt(idx, 84);
|
|
1209
1209
|
slotAt(idx, 0, c_local);
|
|
@@ -1333,7 +1333,7 @@ function encode(program, lineStarts) {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
function enc_ts_qualified_name(n) {
|
|
1335
1335
|
const c_left = n.left == null ? NULL : encNode(n.left);
|
|
1336
|
-
const c_right = n.right == null ? NULL :
|
|
1336
|
+
const c_right = n.right == null ? NULL : encName(n.right);
|
|
1337
1337
|
const idx = alloc();
|
|
1338
1338
|
tagAt(idx, 101);
|
|
1339
1339
|
slotAt(idx, 0, c_left);
|
|
@@ -1356,7 +1356,7 @@ function encode(program, lineStarts) {
|
|
|
1356
1356
|
function enc_ts_import_type(n) {
|
|
1357
1357
|
const c_source = n.source == null ? NULL : encNode(n.source);
|
|
1358
1358
|
const c_options = n.options == null ? NULL : encNode(n.options);
|
|
1359
|
-
const c_qualifier = n.qualifier == null ? NULL :
|
|
1359
|
+
const c_qualifier = n.qualifier == null ? NULL : encName(n.qualifier);
|
|
1360
1360
|
const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
|
|
1361
1361
|
const idx = alloc();
|
|
1362
1362
|
tagAt(idx, 103);
|
|
@@ -1635,7 +1635,7 @@ function encode(program, lineStarts) {
|
|
|
1635
1635
|
return idx;
|
|
1636
1636
|
}
|
|
1637
1637
|
function enc_ts_property_signature(n) {
|
|
1638
|
-
const k = n.computed ? encNode(n.key) :
|
|
1638
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
1639
1639
|
const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
|
|
1640
1640
|
const idx = alloc();
|
|
1641
1641
|
tagAt(idx, 129);
|
|
@@ -1649,7 +1649,7 @@ function encode(program, lineStarts) {
|
|
|
1649
1649
|
return idx;
|
|
1650
1650
|
}
|
|
1651
1651
|
function enc_ts_method_signature(n) {
|
|
1652
|
-
const k = n.computed ? encNode(n.key) :
|
|
1652
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
1653
1653
|
const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
|
|
1654
1654
|
const params = encFormalParameters(n.params);
|
|
1655
1655
|
const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
|
|
@@ -1788,7 +1788,7 @@ function encode(program, lineStarts) {
|
|
|
1788
1788
|
return idx;
|
|
1789
1789
|
}
|
|
1790
1790
|
function enc_ts_enum_member(n) {
|
|
1791
|
-
const id = n.computed ? encNode(n.id) :
|
|
1791
|
+
const id = n.computed ? encNode(n.id) : encName(n.id);
|
|
1792
1792
|
const init = n.initializer == null ? NULL : encNode(n.initializer);
|
|
1793
1793
|
const idx = alloc();
|
|
1794
1794
|
tagAt(idx, 141);
|
|
@@ -2103,14 +2103,7 @@ function encode(program, lineStarts) {
|
|
|
2103
2103
|
function encNode(n) {
|
|
2104
2104
|
if (n == null) return NULL;
|
|
2105
2105
|
switch (n.type) {
|
|
2106
|
-
case "Identifier":
|
|
2107
|
-
switch (n.kind) {
|
|
2108
|
-
case "binding": return enc_binding_identifier(n);
|
|
2109
|
-
case "name": return enc_identifier_name(n);
|
|
2110
|
-
case "label": return enc_label_identifier(n);
|
|
2111
|
-
default: return enc_identifier_reference(n);
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2106
|
+
case "Identifier": return enc_identifier_reference(n);
|
|
2114
2107
|
case "PrivateIdentifier": return enc_private_identifier(n);
|
|
2115
2108
|
case "Literal": {
|
|
2116
2109
|
if (n.regex) return enc_regexp_literal(n);
|
package/index.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ export type Format = "pretty" | "compact";
|
|
|
6
6
|
/**
|
|
7
7
|
* Quote style for emitted string literals.
|
|
8
8
|
*
|
|
9
|
-
* - `"preserve"`:
|
|
10
|
-
*
|
|
11
|
-
* - `"double"` / `"single"`:
|
|
9
|
+
* - `"preserve"`: keep each literal's original quote style (single vs double);
|
|
10
|
+
* synthetic nodes default to double.
|
|
11
|
+
* - `"double"` / `"single"`: force that quote.
|
|
12
12
|
*/
|
|
13
13
|
export type Quotes = "preserve" | "double" | "single";
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-codegen",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.20",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript code generator written in Zig",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"encode.js"
|
|
18
18
|
],
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@yuku-codegen/binding-linux-x64-gnu": "0.5.
|
|
21
|
-
"@yuku-codegen/binding-linux-arm64-gnu": "0.5.
|
|
22
|
-
"@yuku-codegen/binding-linux-arm-gnu": "0.5.
|
|
23
|
-
"@yuku-codegen/binding-linux-x64-musl": "0.5.
|
|
24
|
-
"@yuku-codegen/binding-linux-arm64-musl": "0.5.
|
|
25
|
-
"@yuku-codegen/binding-linux-arm-musl": "0.5.
|
|
26
|
-
"@yuku-codegen/binding-darwin-x64": "0.5.
|
|
27
|
-
"@yuku-codegen/binding-darwin-arm64": "0.5.
|
|
28
|
-
"@yuku-codegen/binding-win32-x64": "0.5.
|
|
29
|
-
"@yuku-codegen/binding-win32-arm64": "0.5.
|
|
30
|
-
"@yuku-codegen/binding-freebsd-x64": "0.5.
|
|
20
|
+
"@yuku-codegen/binding-linux-x64-gnu": "0.5.20",
|
|
21
|
+
"@yuku-codegen/binding-linux-arm64-gnu": "0.5.20",
|
|
22
|
+
"@yuku-codegen/binding-linux-arm-gnu": "0.5.20",
|
|
23
|
+
"@yuku-codegen/binding-linux-x64-musl": "0.5.20",
|
|
24
|
+
"@yuku-codegen/binding-linux-arm64-musl": "0.5.20",
|
|
25
|
+
"@yuku-codegen/binding-linux-arm-musl": "0.5.20",
|
|
26
|
+
"@yuku-codegen/binding-darwin-x64": "0.5.20",
|
|
27
|
+
"@yuku-codegen/binding-darwin-arm64": "0.5.20",
|
|
28
|
+
"@yuku-codegen/binding-win32-x64": "0.5.20",
|
|
29
|
+
"@yuku-codegen/binding-win32-arm64": "0.5.20",
|
|
30
|
+
"@yuku-codegen/binding-freebsd-x64": "0.5.20"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"ast",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typescript"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"yuku-parser": "0.5.
|
|
43
|
+
"yuku-parser": "0.5.19"
|
|
44
44
|
}
|
|
45
45
|
}
|