@tsrx/oxc 0.0.0-trusted-publishing-bootstrap → 0.8.0
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/LICENSE +21 -0
- package/README.md +141 -0
- package/THIRD_PARTY_NOTICES.md +49 -0
- package/bin/oxc-tsrx +2 -0
- package/bin/oxc-tsrx-fmt +2 -0
- package/bin/oxc-tsrx-lint +2 -0
- package/bin/oxc-tsrx-lsp +2 -0
- package/bin/oxfmt +2 -0
- package/bin/oxlint +2 -0
- package/dist/bin/oxc-tsrx-fmt.js +13 -0
- package/dist/bin/oxc-tsrx-lint.js +13 -0
- package/dist/bin/oxc-tsrx-lsp.js +13 -0
- package/dist/bin/oxc-tsrx.js +115 -0
- package/dist/bin/oxfmt.js +24 -0
- package/dist/bin/oxlint.js +33 -0
- package/dist/canonical-command.d.ts +50 -0
- package/dist/canonical-command.js +196 -0
- package/dist/compat.d.ts +149 -0
- package/dist/compat.js +1615 -0
- package/dist/editor-resolution.js +508 -0
- package/dist/format-cli.js +276 -0
- package/dist/format-invocation.js +97 -0
- package/dist/format.d.ts +1 -0
- package/dist/format.js +56 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +16 -0
- package/dist/lint-cli.js +487 -0
- package/dist/lint-invocation.js +192 -0
- package/dist/lint-js-plugins.js +819 -0
- package/dist/lint-plugins-dev.d.ts +1 -0
- package/dist/lint-plugins-dev.js +2 -0
- package/dist/lint-prestart.js +16 -0
- package/dist/lint.d.ts +1 -0
- package/dist/lint.js +2 -0
- package/dist/native-targets.js +76 -0
- package/dist/oxlint-lsp-multiplexer.js +622 -0
- package/dist/package-binary.js +29 -0
- package/dist/parser.d.ts +216 -0
- package/dist/parser.js +557 -0
- package/dist/process.js +88 -0
- package/dist/provider-resolve.d.ts +160 -0
- package/dist/provider-resolve.js +471 -0
- package/dist/providers-report.js +49 -0
- package/dist/runtime.js +323 -0
- package/dist/spawn-command.d.ts +20 -0
- package/dist/spawn-command.js +87 -0
- package/dist/tsrx-core-compat/facade.js +1184 -0
- package/dist/tsrx-core-compat/index.d.ts +6 -0
- package/dist/tsrx-core-compat/index.js +9 -0
- package/dist/tsrx-core-compat/style.js +525 -0
- package/dist/tsrx-core-compat/types/estree.d.ts +20 -0
- package/dist/tsrx-core-compat/types/index.d.ts +50 -0
- package/dist/tsrx-transfer.js +352 -0
- package/package.json +144 -5
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
//#region src/tsrx-transfer.ts
|
|
2
|
+
const PROGRAM_TRANSFER_VERSION = 1;
|
|
3
|
+
const PROGRAM_BINARY_TRANSFER_MAGIC = 1112691540;
|
|
4
|
+
const PROGRAM_BINARY_TRANSFER_VERSION = 1;
|
|
5
|
+
const PROGRAM_TRANSFER_MAX_BYTES = 268435456;
|
|
6
|
+
const PROGRAM_BINARY_HEADER_WORDS = 12;
|
|
7
|
+
const SCALAR_TAG = 0;
|
|
8
|
+
const OBJECT_TAG = 1;
|
|
9
|
+
const LIST_TAG = 2;
|
|
10
|
+
const INLINE_U32_TAG = 3;
|
|
11
|
+
const VALUE_INDEX_MASK = 1073741823;
|
|
12
|
+
const UNUSED_RANGE = 4294967295;
|
|
13
|
+
const COMMON_KEY_FLAG = 2147483648;
|
|
14
|
+
const COMMON_KEY_INDEX_MASK = 2147483647;
|
|
15
|
+
const TSRX_CORE_COMPAT_DEFAULTS_STRIPPED = Symbol.for("@oxc-tsrx/parser/tsrx-core-compat-defaults-stripped");
|
|
16
|
+
const COMMON_KEYS = Object.freeze([
|
|
17
|
+
"body",
|
|
18
|
+
"end",
|
|
19
|
+
"hashbang",
|
|
20
|
+
"sourceType",
|
|
21
|
+
"start",
|
|
22
|
+
"type",
|
|
23
|
+
"async",
|
|
24
|
+
"attributes",
|
|
25
|
+
"declaration",
|
|
26
|
+
"expression",
|
|
27
|
+
"generator",
|
|
28
|
+
"id",
|
|
29
|
+
"metadata",
|
|
30
|
+
"name",
|
|
31
|
+
"params",
|
|
32
|
+
"path",
|
|
33
|
+
"render",
|
|
34
|
+
"children",
|
|
35
|
+
"closingElement",
|
|
36
|
+
"openingElement",
|
|
37
|
+
"selfClosing",
|
|
38
|
+
"value",
|
|
39
|
+
"raw",
|
|
40
|
+
"source",
|
|
41
|
+
"specifiers",
|
|
42
|
+
"kind",
|
|
43
|
+
"local",
|
|
44
|
+
"phase",
|
|
45
|
+
"optional",
|
|
46
|
+
"imported",
|
|
47
|
+
"declarations",
|
|
48
|
+
"init",
|
|
49
|
+
"arguments",
|
|
50
|
+
"callee",
|
|
51
|
+
"computed",
|
|
52
|
+
"key",
|
|
53
|
+
"operator",
|
|
54
|
+
"method",
|
|
55
|
+
"properties",
|
|
56
|
+
"shorthand",
|
|
57
|
+
"left",
|
|
58
|
+
"right",
|
|
59
|
+
"object",
|
|
60
|
+
"property",
|
|
61
|
+
"argument",
|
|
62
|
+
"statementType",
|
|
63
|
+
"prefix",
|
|
64
|
+
"consequent",
|
|
65
|
+
"test",
|
|
66
|
+
"alternate",
|
|
67
|
+
"block",
|
|
68
|
+
"finalizer",
|
|
69
|
+
"handler",
|
|
70
|
+
"param",
|
|
71
|
+
"pending",
|
|
72
|
+
"resetParam",
|
|
73
|
+
"await",
|
|
74
|
+
"empty",
|
|
75
|
+
"index",
|
|
76
|
+
"elements",
|
|
77
|
+
"typeAnnotation",
|
|
78
|
+
"accessibility",
|
|
79
|
+
"declare",
|
|
80
|
+
"members"
|
|
81
|
+
]);
|
|
82
|
+
function isTsrxBinaryProgram(payload) {
|
|
83
|
+
return payload !== null && typeof payload === "object" && Object.prototype.toString.call(payload.words) === "[object Uint32Array]";
|
|
84
|
+
}
|
|
85
|
+
function invalid(message) {
|
|
86
|
+
throw new TypeError(`invalid TSRX Program transfer: ${message}`);
|
|
87
|
+
}
|
|
88
|
+
function applyFix(program, path) {
|
|
89
|
+
if (!Array.isArray(path)) invalid("fix path is not an array");
|
|
90
|
+
let node = program;
|
|
91
|
+
for (const key of path) {
|
|
92
|
+
if (!(typeof key === "string" || Number.isSafeInteger(key) && key >= 0) || node === null || typeof node !== "object" || !Object.hasOwn(node, key)) invalid("fix path does not select a Program node");
|
|
93
|
+
node = node[key];
|
|
94
|
+
}
|
|
95
|
+
if (node === null || typeof node !== "object") invalid("fix path does not end at a Program node");
|
|
96
|
+
if (typeof node.bigint === "string") {
|
|
97
|
+
node.value = BigInt(node.bigint);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (node.regex !== null && typeof node.regex === "object" && typeof node.regex.pattern === "string" && typeof node.regex.flags === "string") {
|
|
101
|
+
try {
|
|
102
|
+
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
103
|
+
} catch {}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
invalid("fix path selects no supported special value");
|
|
107
|
+
}
|
|
108
|
+
function parseMetadata(metadata, keyCount, scalarCount, fixCount) {
|
|
109
|
+
let decoded;
|
|
110
|
+
try {
|
|
111
|
+
decoded = JSON.parse(metadata);
|
|
112
|
+
} catch {
|
|
113
|
+
invalid("metadata is not valid JSON");
|
|
114
|
+
}
|
|
115
|
+
if (!Array.isArray(decoded) || decoded.length !== 3) invalid("metadata does not have exactly three tables");
|
|
116
|
+
const [keys, scalars, fixes] = decoded;
|
|
117
|
+
if (!Array.isArray(keys) || keys.length !== keyCount) invalid("key metadata count does not match the graph header");
|
|
118
|
+
for (const key of keys) if (typeof key !== "string") invalid("key metadata contains a non-string");
|
|
119
|
+
if (!Array.isArray(scalars) || scalars.length !== scalarCount) invalid("scalar metadata count does not match the graph header");
|
|
120
|
+
for (const scalar of scalars) if (scalar !== null && typeof scalar !== "string" && typeof scalar !== "number" && typeof scalar !== "boolean") invalid("scalar metadata contains a non-scalar");
|
|
121
|
+
if (!Array.isArray(fixes) || fixes.length !== fixCount) invalid("fix metadata count does not match the graph header");
|
|
122
|
+
for (const path of fixes) if (!Array.isArray(path)) invalid("fix metadata contains a non-path");
|
|
123
|
+
return {
|
|
124
|
+
keys,
|
|
125
|
+
scalars,
|
|
126
|
+
fixes
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function parseBinaryProgram(payload) {
|
|
130
|
+
if (payload === null || typeof payload !== "object" || typeof payload.metadata !== "string" || !isTsrxBinaryProgram(payload)) invalid("binary payload has invalid lanes");
|
|
131
|
+
const { metadata, words } = payload;
|
|
132
|
+
if (words.byteLength > PROGRAM_TRANSFER_MAX_BYTES || Buffer.byteLength(metadata, "utf8") > PROGRAM_TRANSFER_MAX_BYTES - words.byteLength) invalid("binary payload exceeds its bounded capacity");
|
|
133
|
+
if (words.length < PROGRAM_BINARY_HEADER_WORDS) invalid("binary graph header is truncated");
|
|
134
|
+
if (words[0] !== 1112691540) invalid("binary graph magic does not match");
|
|
135
|
+
if (words[1] !== 1) invalid(`unsupported binary version ${String(words[1])}`);
|
|
136
|
+
if (words[11] !== 0) invalid("binary graph reserved word is nonzero");
|
|
137
|
+
const objectCount = words[2];
|
|
138
|
+
const fieldCount = words[3];
|
|
139
|
+
const listCount = words[4];
|
|
140
|
+
const valueCount = words[5];
|
|
141
|
+
const rootTag = words[6];
|
|
142
|
+
const rootIndex = words[7];
|
|
143
|
+
const keyCount = words[8];
|
|
144
|
+
const scalarCount = words[9];
|
|
145
|
+
const fixCount = words[10];
|
|
146
|
+
const objectOffset = PROGRAM_BINARY_HEADER_WORDS;
|
|
147
|
+
const fieldOffset = objectOffset + objectCount * 2;
|
|
148
|
+
const listOffset = fieldOffset + fieldCount * 2;
|
|
149
|
+
const valueOffset = listOffset + listCount * 2;
|
|
150
|
+
const expectedWords = valueOffset + valueCount;
|
|
151
|
+
if (!Number.isSafeInteger(expectedWords) || words.length !== expectedWords) invalid("binary graph table lengths do not match the header");
|
|
152
|
+
if (rootTag !== OBJECT_TAG || rootIndex >= objectCount) invalid("binary graph root is not a valid Program object");
|
|
153
|
+
const { keys, scalars, fixes } = parseMetadata(metadata, keyCount, scalarCount, fixCount);
|
|
154
|
+
const objects = new Array(objectCount);
|
|
155
|
+
const fieldOwners = new Uint8Array(fieldCount);
|
|
156
|
+
for (let index = 0; index < objectCount; index += 1) {
|
|
157
|
+
const offset = objectOffset + index * 2;
|
|
158
|
+
const start = words[offset];
|
|
159
|
+
const count = words[offset + 1];
|
|
160
|
+
if (start === UNUSED_RANGE) {
|
|
161
|
+
if (count !== 0) invalid("unused binary object has fields");
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (start + count > fieldCount) invalid("binary object field range is truncated");
|
|
165
|
+
for (let field = start; field < start + count; field += 1) {
|
|
166
|
+
if (fieldOwners[field] !== 0) invalid("binary object field ranges overlap");
|
|
167
|
+
fieldOwners[field] = 1;
|
|
168
|
+
}
|
|
169
|
+
objects[index] = {};
|
|
170
|
+
}
|
|
171
|
+
for (const owner of fieldOwners) if (owner !== 1) invalid("binary object fields are unowned");
|
|
172
|
+
const lists = new Array(listCount);
|
|
173
|
+
const valueOwners = new Uint8Array(valueCount);
|
|
174
|
+
for (let index = 0; index < listCount; index += 1) {
|
|
175
|
+
const offset = listOffset + index * 2;
|
|
176
|
+
const start = words[offset];
|
|
177
|
+
const count = words[offset + 1];
|
|
178
|
+
if (start === UNUSED_RANGE) {
|
|
179
|
+
if (count !== 0) invalid("unused binary list has values");
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (start + count > valueCount) invalid("binary list value range is truncated");
|
|
183
|
+
for (let value = start; value < start + count; value += 1) {
|
|
184
|
+
if (valueOwners[value] !== 0) invalid("binary list value ranges overlap");
|
|
185
|
+
valueOwners[value] = 1;
|
|
186
|
+
}
|
|
187
|
+
lists[index] = new Array(count);
|
|
188
|
+
}
|
|
189
|
+
for (const owner of valueOwners) if (owner !== 1) invalid("binary list values are unowned");
|
|
190
|
+
if (objects[rootIndex] === void 0) invalid("binary graph root is unused");
|
|
191
|
+
const owners = new Uint8Array(objectCount + listCount);
|
|
192
|
+
owners[rootIndex] = 1;
|
|
193
|
+
for (let objectIndex = 0; objectIndex < objectCount; objectIndex += 1) {
|
|
194
|
+
const object = objects[objectIndex];
|
|
195
|
+
const rangeOffset = objectOffset + objectIndex * 2;
|
|
196
|
+
const start = words[rangeOffset];
|
|
197
|
+
const count = words[rangeOffset + 1];
|
|
198
|
+
for (let fieldIndex = start; fieldIndex < start + count; fieldIndex += 1) {
|
|
199
|
+
const offset = fieldOffset + fieldIndex * 2;
|
|
200
|
+
const encodedKey = words[offset];
|
|
201
|
+
const key = encodedKey & COMMON_KEY_FLAG ? COMMON_KEYS[encodedKey & COMMON_KEY_INDEX_MASK] : keys[encodedKey];
|
|
202
|
+
if (typeof key !== "string" || !(encodedKey & COMMON_KEY_FLAG) && encodedKey >= keyCount) invalid("binary key index is out of range");
|
|
203
|
+
const packed = words[offset + 1];
|
|
204
|
+
const tag = packed >>> 30;
|
|
205
|
+
const index = packed & VALUE_INDEX_MASK;
|
|
206
|
+
let decoded;
|
|
207
|
+
if (tag === SCALAR_TAG) {
|
|
208
|
+
if (index >= scalarCount) invalid("binary scalar index is out of range");
|
|
209
|
+
decoded = scalars[index];
|
|
210
|
+
} else if (tag === OBJECT_TAG) {
|
|
211
|
+
if (index >= objectCount || objects[index] === void 0) invalid("binary object index is out of range or unused");
|
|
212
|
+
if (owners[index] !== 0) invalid("binary graph contains sharing or a cycle");
|
|
213
|
+
owners[index] = 1;
|
|
214
|
+
decoded = objects[index];
|
|
215
|
+
} else if (tag === LIST_TAG) {
|
|
216
|
+
if (index >= listCount || lists[index] === void 0) invalid("binary list index is out of range or unused");
|
|
217
|
+
const owner = objectCount + index;
|
|
218
|
+
if (owners[owner] !== 0) invalid("binary graph contains sharing or a cycle");
|
|
219
|
+
owners[owner] = 1;
|
|
220
|
+
decoded = lists[index];
|
|
221
|
+
} else if (tag === INLINE_U32_TAG) decoded = index;
|
|
222
|
+
else invalid(`binary value tag ${String(tag)} is invalid`);
|
|
223
|
+
if (key === "__proto__") Object.defineProperty(object, key, {
|
|
224
|
+
configurable: true,
|
|
225
|
+
enumerable: true,
|
|
226
|
+
writable: true,
|
|
227
|
+
value: decoded
|
|
228
|
+
});
|
|
229
|
+
else object[key] = decoded;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
for (let listIndex = 0; listIndex < listCount; listIndex += 1) {
|
|
233
|
+
const list = lists[listIndex];
|
|
234
|
+
if (list === void 0) continue;
|
|
235
|
+
const rangeOffset = listOffset + listIndex * 2;
|
|
236
|
+
const start = words[rangeOffset];
|
|
237
|
+
const count = words[rangeOffset + 1];
|
|
238
|
+
for (let index = 0; index < count; index += 1) {
|
|
239
|
+
const packed = words[valueOffset + start + index];
|
|
240
|
+
const tag = packed >>> 30;
|
|
241
|
+
const valueIndex = packed & VALUE_INDEX_MASK;
|
|
242
|
+
if (tag === SCALAR_TAG) {
|
|
243
|
+
if (valueIndex >= scalarCount) invalid("binary scalar index is out of range");
|
|
244
|
+
list[index] = scalars[valueIndex];
|
|
245
|
+
} else if (tag === OBJECT_TAG) {
|
|
246
|
+
if (valueIndex >= objectCount || objects[valueIndex] === void 0) invalid("binary object index is out of range or unused");
|
|
247
|
+
if (owners[valueIndex] !== 0) invalid("binary graph contains sharing or a cycle");
|
|
248
|
+
owners[valueIndex] = 1;
|
|
249
|
+
list[index] = objects[valueIndex];
|
|
250
|
+
} else if (tag === LIST_TAG) {
|
|
251
|
+
if (valueIndex >= listCount || lists[valueIndex] === void 0) invalid("binary list index is out of range or unused");
|
|
252
|
+
const owner = objectCount + valueIndex;
|
|
253
|
+
if (owners[owner] !== 0) invalid("binary graph contains sharing or a cycle");
|
|
254
|
+
owners[owner] = 1;
|
|
255
|
+
list[index] = lists[valueIndex];
|
|
256
|
+
} else if (tag === INLINE_U32_TAG) list[index] = valueIndex;
|
|
257
|
+
else invalid(`binary value tag ${String(tag)} is invalid`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (let index = 0; index < objectCount; index += 1) if (owners[index] !== Number(objects[index] !== void 0)) invalid("binary graph contains an unreachable container");
|
|
261
|
+
for (let index = 0; index < listCount; index += 1) if (owners[objectCount + index] !== Number(lists[index] !== void 0)) invalid("binary graph contains an unreachable container");
|
|
262
|
+
const program = objects[rootIndex];
|
|
263
|
+
for (const path of fixes) applyFix(program, path);
|
|
264
|
+
return program;
|
|
265
|
+
}
|
|
266
|
+
function isEmptyArray(value) {
|
|
267
|
+
return Array.isArray(value) && value.length === 0;
|
|
268
|
+
}
|
|
269
|
+
function omitTsrxCoreCompatDefault(type, key, value) {
|
|
270
|
+
if (isEmptyArray(value) && (key === "decorators" || key === "attributes" && (type === "ExportAllDeclaration" || type === "ExportNamedDeclaration" || type === "ImportDeclaration") || key === "implements" && (type === "ClassDeclaration" || type === "ClassExpression") || key === "extends" && type === "TSInterfaceDeclaration")) return true;
|
|
271
|
+
if (value == null && (key === "accessibility" || key === "directive" || key === "hashbang" || key === "options" || key === "phase" || key === "returnType" || key === "superTypeArguments" || key === "typeAnnotation" || key === "typeArguments" || key === "typeParameters" || type === "RestElement" && key === "value")) return true;
|
|
272
|
+
if (value !== false) return false;
|
|
273
|
+
if (key === "abstract" || key === "const" || key === "declare" || key === "definite" || key === "global" || key === "in" || key === "out" || key === "override" || key === "readonly" || key === "static") return true;
|
|
274
|
+
return key === "optional" && (type === "ArrayPattern" || type === "AssignmentPattern" || type === "Identifier" || type === "MethodDefinition" || type === "ObjectPattern" || type === "Property" || type === "PropertyDefinition" || type === "RestElement" || type === "TSMethodSignature" || type === "TSPropertySignature");
|
|
275
|
+
}
|
|
276
|
+
function parseTrustedBinaryProgram(payload, stripTsrxCoreCompatDefaults = false) {
|
|
277
|
+
const { metadata, words } = payload;
|
|
278
|
+
const objectCount = words[2];
|
|
279
|
+
const fieldCount = words[3];
|
|
280
|
+
const listCount = words[4];
|
|
281
|
+
const objectOffset = PROGRAM_BINARY_HEADER_WORDS;
|
|
282
|
+
const fieldOffset = objectOffset + objectCount * 2;
|
|
283
|
+
const listOffset = fieldOffset + fieldCount * 2;
|
|
284
|
+
const valueOffset = listOffset + listCount * 2;
|
|
285
|
+
const [keys, scalars, fixes] = JSON.parse(metadata);
|
|
286
|
+
const objects = new Array(objectCount);
|
|
287
|
+
const lists = new Array(listCount);
|
|
288
|
+
for (let index = 0; index < objectCount; index += 1) if (words[objectOffset + index * 2] !== UNUSED_RANGE) objects[index] = {};
|
|
289
|
+
for (let index = 0; index < listCount; index += 1) if (words[listOffset + index * 2] !== UNUSED_RANGE) lists[index] = new Array(words[listOffset + index * 2 + 1]);
|
|
290
|
+
for (let listIndex = 0; listIndex < listCount; listIndex += 1) {
|
|
291
|
+
if (lists[listIndex] === void 0) continue;
|
|
292
|
+
const start = words[listOffset + listIndex * 2];
|
|
293
|
+
const count = words[listOffset + listIndex * 2 + 1];
|
|
294
|
+
const list = lists[listIndex];
|
|
295
|
+
for (let index = 0; index < count; index += 1) {
|
|
296
|
+
const packed = words[valueOffset + start + index];
|
|
297
|
+
const tag = packed >>> 30;
|
|
298
|
+
const valueIndex = packed & VALUE_INDEX_MASK;
|
|
299
|
+
list[index] = tag === SCALAR_TAG ? scalars[valueIndex] : tag === OBJECT_TAG ? objects[valueIndex] : tag === LIST_TAG ? lists[valueIndex] : valueIndex;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
for (let objectIndex = 0; objectIndex < objectCount; objectIndex += 1) {
|
|
303
|
+
if (objects[objectIndex] === void 0) continue;
|
|
304
|
+
const start = words[objectOffset + objectIndex * 2];
|
|
305
|
+
const count = words[objectOffset + objectIndex * 2 + 1];
|
|
306
|
+
const object = objects[objectIndex];
|
|
307
|
+
let type;
|
|
308
|
+
if (stripTsrxCoreCompatDefaults) for (let index = 0; index < count; index += 1) {
|
|
309
|
+
const offset = fieldOffset + (start + index) * 2;
|
|
310
|
+
const encodedKey = words[offset];
|
|
311
|
+
if ((encodedKey & COMMON_KEY_FLAG ? COMMON_KEYS[encodedKey & COMMON_KEY_INDEX_MASK] : keys[encodedKey]) !== "type") continue;
|
|
312
|
+
const packed = words[offset + 1];
|
|
313
|
+
if (packed >>> 30 === SCALAR_TAG) type = scalars[packed & VALUE_INDEX_MASK];
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
for (let index = 0; index < count; index += 1) {
|
|
317
|
+
const offset = fieldOffset + (start + index) * 2;
|
|
318
|
+
const packed = words[offset + 1];
|
|
319
|
+
const tag = packed >>> 30;
|
|
320
|
+
const valueIndex = packed & VALUE_INDEX_MASK;
|
|
321
|
+
const decoded = tag === SCALAR_TAG ? scalars[valueIndex] : tag === OBJECT_TAG ? objects[valueIndex] : tag === LIST_TAG ? lists[valueIndex] : valueIndex;
|
|
322
|
+
const encodedKey = words[offset];
|
|
323
|
+
const key = encodedKey & COMMON_KEY_FLAG ? COMMON_KEYS[encodedKey & COMMON_KEY_INDEX_MASK] : keys[encodedKey];
|
|
324
|
+
if (stripTsrxCoreCompatDefaults && omitTsrxCoreCompatDefault(type, key, decoded)) continue;
|
|
325
|
+
object[key] = decoded;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const program = objects[words[7]];
|
|
329
|
+
for (const path of fixes) applyFix(program, path);
|
|
330
|
+
if (stripTsrxCoreCompatDefaults) Object.defineProperty(program, TSRX_CORE_COMPAT_DEFAULTS_STRIPPED, {
|
|
331
|
+
configurable: true,
|
|
332
|
+
value: true
|
|
333
|
+
});
|
|
334
|
+
return program;
|
|
335
|
+
}
|
|
336
|
+
function parseTrustedTsrxProgram(payload, stripTsrxCoreCompatDefaults = false) {
|
|
337
|
+
if (isTsrxBinaryProgram(payload)) return parseTrustedBinaryProgram(payload, stripTsrxCoreCompatDefaults);
|
|
338
|
+
return parseTsrxProgram(payload);
|
|
339
|
+
}
|
|
340
|
+
function parseTsrxProgram(payload) {
|
|
341
|
+
if (payload === null) return null;
|
|
342
|
+
if (typeof payload !== "string") return parseBinaryProgram(payload);
|
|
343
|
+
const envelope = JSON.parse(payload);
|
|
344
|
+
if (envelope === null || typeof envelope !== "object") invalid("envelope is not an object");
|
|
345
|
+
if (envelope.version !== PROGRAM_TRANSFER_VERSION) invalid(`unsupported version ${String(envelope.version)}`);
|
|
346
|
+
if (envelope.node === null || typeof envelope.node !== "object") invalid("Program is not an object");
|
|
347
|
+
if (!Array.isArray(envelope.fixes)) invalid("fixes is not an array");
|
|
348
|
+
for (const path of envelope.fixes) applyFix(envelope.node, path);
|
|
349
|
+
return envelope.node;
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
export { PROGRAM_BINARY_TRANSFER_MAGIC, PROGRAM_BINARY_TRANSFER_VERSION, isTsrxBinaryProgram, parseTrustedTsrxProgram, parseTsrxProgram };
|
package/package.json
CHANGED
|
@@ -1,9 +1,148 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/oxc",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "The official OXC integration for TSRX — Rust-native Oxlint and Oxfmt for .tsrx, JavaScript, TypeScript, and JSX",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"formatter",
|
|
7
|
+
"javascript",
|
|
8
|
+
"linter",
|
|
9
|
+
"oxc",
|
|
10
|
+
"oxfmt",
|
|
11
|
+
"oxlint",
|
|
12
|
+
"parser",
|
|
13
|
+
"tsx",
|
|
14
|
+
"tsrx",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://compiled.run/oxc-tsrx",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/tsrx-org/oxc/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/tsrx-org/oxc.git",
|
|
24
|
+
"directory": "packages/toolchain"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"oxc": {
|
|
30
|
+
"provider": {
|
|
31
|
+
"protocol": 1,
|
|
32
|
+
"id": "tsrx",
|
|
33
|
+
"languages": [
|
|
34
|
+
{
|
|
35
|
+
"id": "tsrx",
|
|
36
|
+
"extensions": [
|
|
37
|
+
".tsrx"
|
|
38
|
+
],
|
|
39
|
+
"capabilities": {
|
|
40
|
+
"parse": {
|
|
41
|
+
"module": "./parser"
|
|
42
|
+
},
|
|
43
|
+
"lint": {
|
|
44
|
+
"bin": "oxc-tsrx-lint"
|
|
45
|
+
},
|
|
46
|
+
"format": {
|
|
47
|
+
"bin": "oxc-tsrx-fmt"
|
|
48
|
+
},
|
|
49
|
+
"lsp": {
|
|
50
|
+
"bin": "oxc-tsrx-lsp"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"bin": {
|
|
58
|
+
"oxc-tsrx": "./bin/oxc-tsrx",
|
|
59
|
+
"oxlint": "./bin/oxlint",
|
|
60
|
+
"oxfmt": "./bin/oxfmt",
|
|
61
|
+
"oxc-tsrx-lint": "./bin/oxc-tsrx-lint",
|
|
62
|
+
"oxc-tsrx-fmt": "./bin/oxc-tsrx-fmt",
|
|
63
|
+
"oxc-tsrx-lsp": "./bin/oxc-tsrx-lsp"
|
|
64
|
+
},
|
|
65
|
+
"exports": {
|
|
66
|
+
".": {
|
|
67
|
+
"types": "./dist/index.d.ts",
|
|
68
|
+
"import": "./dist/index.js",
|
|
69
|
+
"default": "./dist/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./parser": {
|
|
72
|
+
"types": "./dist/parser.d.ts",
|
|
73
|
+
"import": "./dist/parser.js",
|
|
74
|
+
"default": "./dist/parser.js"
|
|
75
|
+
},
|
|
76
|
+
"./lint": {
|
|
77
|
+
"types": "./dist/lint.d.ts",
|
|
78
|
+
"import": "./dist/lint.js",
|
|
79
|
+
"default": "./dist/lint.js"
|
|
80
|
+
},
|
|
81
|
+
"./lint/plugins-dev": {
|
|
82
|
+
"types": "./dist/lint-plugins-dev.d.ts",
|
|
83
|
+
"import": "./dist/lint-plugins-dev.js",
|
|
84
|
+
"default": "./dist/lint-plugins-dev.js"
|
|
85
|
+
},
|
|
86
|
+
"./format": {
|
|
87
|
+
"types": "./dist/format.d.ts",
|
|
88
|
+
"import": "./dist/format.js",
|
|
89
|
+
"default": "./dist/format.js"
|
|
90
|
+
},
|
|
91
|
+
"./compat": {
|
|
92
|
+
"types": "./dist/compat.d.ts",
|
|
93
|
+
"import": "./dist/compat.js",
|
|
94
|
+
"default": "./dist/compat.js"
|
|
95
|
+
},
|
|
96
|
+
"./tsrx-core-compat": {
|
|
97
|
+
"types": "./dist/tsrx-core-compat/index.d.ts",
|
|
98
|
+
"import": "./dist/tsrx-core-compat/index.js",
|
|
99
|
+
"default": "./dist/tsrx-core-compat/index.js"
|
|
100
|
+
},
|
|
101
|
+
"./tsrx-core-compat/types": {
|
|
102
|
+
"types": "./dist/tsrx-core-compat/types/index.d.ts"
|
|
103
|
+
},
|
|
104
|
+
"./tsrx-core-compat/types/estree": {
|
|
105
|
+
"types": "./dist/tsrx-core-compat/types/estree.d.ts"
|
|
106
|
+
},
|
|
107
|
+
"./provider-resolve": {
|
|
108
|
+
"types": "./dist/provider-resolve.d.ts",
|
|
109
|
+
"import": "./dist/provider-resolve.js",
|
|
110
|
+
"default": "./dist/provider-resolve.js"
|
|
111
|
+
},
|
|
112
|
+
"./package.json": "./package.json"
|
|
113
|
+
},
|
|
114
|
+
"files": [
|
|
115
|
+
"bin",
|
|
116
|
+
"dist",
|
|
117
|
+
"LICENSE",
|
|
118
|
+
"README.md",
|
|
119
|
+
"THIRD_PARTY_NOTICES.md"
|
|
120
|
+
],
|
|
121
|
+
"sideEffects": false,
|
|
122
|
+
"dependencies": {
|
|
123
|
+
"@oxc-project/types": "0.140.0",
|
|
124
|
+
"oxfmt-current": "npm:oxfmt@0.59.0",
|
|
125
|
+
"oxlint-current": "npm:oxlint@1.74.0",
|
|
126
|
+
"oxlint-tsgolint": "0.24.0",
|
|
127
|
+
"pathe": "2.0.3",
|
|
128
|
+
"tinyglobby": "0.2.17"
|
|
129
|
+
},
|
|
130
|
+
"optionalDependencies": {
|
|
131
|
+
"@tsrx/oxc-darwin-arm64": "0.8.0",
|
|
132
|
+
"@tsrx/oxc-darwin-x64": "0.8.0",
|
|
133
|
+
"@tsrx/oxc-linux-arm64-gnu": "0.8.0",
|
|
134
|
+
"@tsrx/oxc-linux-arm64-musl": "0.8.0",
|
|
135
|
+
"@tsrx/oxc-linux-x64-gnu": "0.8.0",
|
|
136
|
+
"@tsrx/oxc-linux-x64-musl": "0.8.0",
|
|
137
|
+
"@tsrx/oxc-win32-arm64-msvc": "0.8.0",
|
|
138
|
+
"@tsrx/oxc-win32-x64-msvc": "0.8.0"
|
|
139
|
+
},
|
|
140
|
+
"engines": {
|
|
141
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
142
|
+
},
|
|
6
143
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
144
|
+
"publishConfig": {
|
|
145
|
+
"access": "public",
|
|
146
|
+
"provenance": true
|
|
147
|
+
}
|
|
9
148
|
}
|