@vobs/compiler 1.2.1 → 1.2.2

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/dist/index.cjs CHANGED
@@ -1,14 +1,47 @@
1
- 'use strict';
2
-
3
- var ts = require('typescript');
4
- var error = require('@vobs/runtime/error');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var ts__default = /*#__PURE__*/_interopDefault(ts);
9
-
1
+ var __VOBS_CJS_FILE_URL = require("url").pathToFileURL(__filename).href;
2
+ "use strict";
3
+ var __create = Object.create;
10
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
9
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // packages/compiler/src/index.ts
33
+ var src_exports = {};
34
+ __export(src_exports, {
35
+ compile: () => compile,
36
+ compileWithSourceMap: () => compileWithSourceMap,
37
+ createCompiler: () => createCompiler,
38
+ createI18nExtractor: () => createI18nExtractor
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+
42
+ // packages/compiler/src/compile.ts
43
+ var import_typescript = __toESM(require("typescript"), 1);
44
+ var import_error = require("@vobs/runtime/error");
12
45
  function createCompiler(options = {}) {
13
46
  const basePlugins = options.plugins ?? [];
14
47
  return {
@@ -31,7 +64,7 @@ function compile(code, options = {}) {
31
64
  const result = compileWithSourceMap(code, options);
32
65
  const firstError = result.diagnostics.find((diagnostic) => diagnostic.severity === "error");
33
66
  if (firstError) {
34
- throw new error.VobsError({
67
+ throw new import_error.VobsError({
35
68
  code: firstError.code,
36
69
  layer: "compiler",
37
70
  message: firstError.message,
@@ -45,12 +78,12 @@ function compile(code, options = {}) {
45
78
  __name(compile, "compile");
46
79
  function compileWithSourceMap(code, options = {}) {
47
80
  const filename = options.filename ?? "component.tsx";
48
- let sourceFile = ts__default.default.createSourceFile(
81
+ let sourceFile = import_typescript.default.createSourceFile(
49
82
  filename,
50
83
  code,
51
- ts__default.default.ScriptTarget.Latest,
84
+ import_typescript.default.ScriptTarget.Latest,
52
85
  true,
53
- ts__default.default.ScriptKind.TSX
86
+ import_typescript.default.ScriptKind.TSX
54
87
  );
55
88
  const state = {
56
89
  generatedId: 0,
@@ -66,18 +99,18 @@ function compileWithSourceMap(code, options = {}) {
66
99
  diagnostics: []
67
100
  };
68
101
  const cleanFilename = filename.split(/[?#]/u, 1)[0] || filename;
69
- const diagnostics = ts__default.default.transpileModule(code, {
102
+ const diagnostics = import_typescript.default.transpileModule(code, {
70
103
  // Vite appends query strings (for example `?direct`) to module IDs;
71
104
  // strip them so TypeScript still recognizes TSX syntax for diagnostics.
72
105
  fileName: cleanFilename,
73
106
  reportDiagnostics: true,
74
- compilerOptions: { jsx: ts__default.default.JsxEmit.Preserve, target: ts__default.default.ScriptTarget.Latest }
107
+ compilerOptions: { jsx: import_typescript.default.JsxEmit.Preserve, target: import_typescript.default.ScriptTarget.Latest }
75
108
  }).diagnostics?.map((diagnostic) => toCompilerDiagnostic(diagnostic, sourceFile, cleanFilename)) ?? [];
76
109
  const plugins = options.plugins ?? [];
77
110
  validatePlugins(plugins);
78
111
  const context = {
79
112
  filename,
80
- factory: ts__default.default.factory,
113
+ factory: import_typescript.default.factory,
81
114
  addRuntimeImport(name) {
82
115
  resolveHelperName(state, name);
83
116
  },
@@ -89,15 +122,15 @@ function compileWithSourceMap(code, options = {}) {
89
122
  }
90
123
  for (const plugin of plugins) sourceFile = transformPluginNodes(sourceFile, plugin, context);
91
124
  const statements = sourceFile.statements.map(
92
- (statement) => ts__default.default.isImportDeclaration(statement) ? rebuildImport(state, statement) : transformStatement(state, statement)
125
+ (statement) => import_typescript.default.isImportDeclaration(statement) ? rebuildImport(state, statement) : transformStatement(state, statement)
93
126
  );
94
127
  const templateDeclarations = createTemplateDeclarations(state);
95
- const resultFile = ts__default.default.factory.updateSourceFile(sourceFile, [
128
+ const resultFile = import_typescript.default.factory.updateSourceFile(sourceFile, [
96
129
  ...createRuntimeImports(state),
97
130
  ...templateDeclarations,
98
131
  ...statements
99
132
  ]);
100
- const generated = ts__default.default.createPrinter().printFile(resultFile);
133
+ const generated = import_typescript.default.createPrinter().printFile(resultFile);
101
134
  return {
102
135
  code: generated,
103
136
  map: buildSourceMap(state, filename, code, generated, resultFile),
@@ -108,11 +141,11 @@ __name(compileWithSourceMap, "compileWithSourceMap");
108
141
  function toCompilerDiagnostic(diagnostic, sourceFile, filename) {
109
142
  const start = diagnostic.start ?? 0;
110
143
  const length = diagnostic.length ?? 1;
111
- const message = ts__default.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
144
+ const message = import_typescript.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
112
145
  const { line, column, codeFrame } = buildCodeFrame(sourceFile, start, length);
113
146
  return {
114
147
  code: `VOBS_C${String(diagnostic.code).padStart(3, "0")}`,
115
- severity: diagnostic.category === ts__default.default.DiagnosticCategory.Warning ? "warning" : "error",
148
+ severity: diagnostic.category === import_typescript.default.DiagnosticCategory.Warning ? "warning" : "error",
116
149
  message,
117
150
  location: { file: filename, line, column },
118
151
  codeFrame
@@ -135,7 +168,7 @@ function reportUnsupportedTag(state, tagName) {
135
168
  const sourceFile = tagName.getSourceFile() ?? state.sourceFile;
136
169
  if (!sourceFile) return;
137
170
  const label = tagName.getText();
138
- const kindNote = tagName.kind === ts__default.default.SyntaxKind.JsxNamespacedName ? "\uFF08JSX \u547D\u540D\u7A7A\u95F4\u6807\u7B7E\uFF09" : "";
171
+ const kindNote = tagName.kind === import_typescript.default.SyntaxKind.JsxNamespacedName ? "\uFF08JSX \u547D\u540D\u7A7A\u95F4\u6807\u7B7E\uFF09" : "";
139
172
  const { line, column, codeFrame } = buildCodeFrame(sourceFile, tagName.getStart(sourceFile), tagName.getWidth(sourceFile));
140
173
  state.diagnostics.push({
141
174
  code: "VOBS_C101",
@@ -148,7 +181,7 @@ function reportUnsupportedTag(state, tagName) {
148
181
  }
149
182
  __name(reportUnsupportedTag, "reportUnsupportedTag");
150
183
  function buildSourceMap(state, filename, source, generated, resultFile) {
151
- const reparsed = ts__default.default.createSourceFile(filename, generated, ts__default.default.ScriptTarget.Latest, true, ts__default.default.ScriptKind.TSX);
184
+ const reparsed = import_typescript.default.createSourceFile(filename, generated, import_typescript.default.ScriptTarget.Latest, true, import_typescript.default.ScriptKind.TSX);
152
185
  const segments = [];
153
186
  walkPairedTrees(state, resultFile, reparsed, reparsed, segments);
154
187
  segments.sort((a, b) => a.genLine - b.genLine || a.genCol - b.genCol);
@@ -163,8 +196,8 @@ function buildSourceMap(state, filename, source, generated, resultFile) {
163
196
  }
164
197
  __name(buildSourceMap, "buildSourceMap");
165
198
  function statementLists(node) {
166
- if (ts__default.default.isSourceFile(node) || ts__default.default.isBlock(node) || ts__default.default.isModuleBlock(node)) return node.statements;
167
- if (ts__default.default.isCaseClause(node) || ts__default.default.isDefaultClause(node)) return node.statements;
199
+ if (import_typescript.default.isSourceFile(node) || import_typescript.default.isBlock(node) || import_typescript.default.isModuleBlock(node)) return node.statements;
200
+ if (import_typescript.default.isCaseClause(node) || import_typescript.default.isDefaultClause(node)) return node.statements;
168
201
  return null;
169
202
  }
170
203
  __name(statementLists, "statementLists");
@@ -183,10 +216,10 @@ function walkPairedTrees(state, original, generated, reparsed, segments) {
183
216
  }
184
217
  const originalChildren = [];
185
218
  const generatedChildren = [];
186
- ts__default.default.forEachChild(original, (node) => {
219
+ import_typescript.default.forEachChild(original, (node) => {
187
220
  originalChildren.push(node);
188
221
  });
189
- ts__default.default.forEachChild(generated, (node) => {
222
+ import_typescript.default.forEachChild(generated, (node) => {
190
223
  generatedChildren.push(node);
191
224
  });
192
225
  if (originalChildren.length !== generatedChildren.length) return;
@@ -256,8 +289,8 @@ __name(encodeVlq, "encodeVlq");
256
289
  function validatePlugins(plugins) {
257
290
  const names = /* @__PURE__ */ new Set();
258
291
  for (const plugin of plugins) {
259
- if (!plugin.name) throw new error.VobsError({ code: "VOBS_C007", layer: "compiler", message: "\u7F16\u8BD1\u5668\u63D2\u4EF6\u5FC5\u987B\u63D0\u4F9B name", fix: "\u4E3A\u63D2\u4EF6\u6DFB\u52A0\u7A33\u5B9A\u4E14\u552F\u4E00\u7684 name\u3002" });
260
- if (names.has(plugin.name)) throw new error.VobsError({ code: "VOBS_C007", layer: "compiler", message: `\u68C0\u6D4B\u5230\u91CD\u590D\u63D2\u4EF6: ${plugin.name}`, fix: "\u4E3A\u6BCF\u4E2A\u7F16\u8BD1\u5668\u63D2\u4EF6\u4F7F\u7528\u552F\u4E00\u7684 name\u3002" });
292
+ if (!plugin.name) throw new import_error.VobsError({ code: "VOBS_C007", layer: "compiler", message: "\u7F16\u8BD1\u5668\u63D2\u4EF6\u5FC5\u987B\u63D0\u4F9B name", fix: "\u4E3A\u63D2\u4EF6\u6DFB\u52A0\u7A33\u5B9A\u4E14\u552F\u4E00\u7684 name\u3002" });
293
+ if (names.has(plugin.name)) throw new import_error.VobsError({ code: "VOBS_C007", layer: "compiler", message: `\u68C0\u6D4B\u5230\u91CD\u590D\u63D2\u4EF6: ${plugin.name}`, fix: "\u4E3A\u6BCF\u4E2A\u7F16\u8BD1\u5668\u63D2\u4EF6\u4F7F\u7528\u552F\u4E00\u7684 name\u3002" });
261
294
  names.add(plugin.name);
262
295
  }
263
296
  }
@@ -269,11 +302,11 @@ function transformPluginNodes(sourceFile, plugin, context) {
269
302
  const visit = /* @__PURE__ */ __name((node) => {
270
303
  const replacement = transformNode(node, context);
271
304
  if (replacement === null) return void 0;
272
- return ts__default.default.visitEachChild(replacement ?? node, visit, transformContext);
305
+ return import_typescript.default.visitEachChild(replacement ?? node, visit, transformContext);
273
306
  }, "visit");
274
- return ts__default.default.visitNode(root, visit);
307
+ return import_typescript.default.visitNode(root, visit);
275
308
  }, "transformer");
276
- const result = ts__default.default.transform(sourceFile, [transformer]);
309
+ const result = import_typescript.default.transform(sourceFile, [transformer]);
277
310
  try {
278
311
  return result.transformed[0];
279
312
  } finally {
@@ -284,8 +317,8 @@ __name(transformPluginNodes, "transformPluginNodes");
284
317
  function collectDeclaredNames(sourceFile) {
285
318
  const names = /* @__PURE__ */ new Set();
286
319
  const visit = /* @__PURE__ */ __name((node) => {
287
- if (ts__default.default.isIdentifier(node) && isBindingName(node)) names.add(node.text);
288
- ts__default.default.forEachChild(node, visit);
320
+ if (import_typescript.default.isIdentifier(node) && isBindingName(node)) names.add(node.text);
321
+ import_typescript.default.forEachChild(node, visit);
289
322
  }, "visit");
290
323
  visit(sourceFile);
291
324
  return names;
@@ -294,11 +327,11 @@ __name(collectDeclaredNames, "collectDeclaredNames");
294
327
  function collectStateAliases(sourceFile) {
295
328
  const aliases = /* @__PURE__ */ new Set();
296
329
  for (const statement of sourceFile.statements) {
297
- if (!ts__default.default.isImportDeclaration(statement) || !ts__default.default.isStringLiteral(statement.moduleSpecifier)) continue;
298
- const module = statement.moduleSpecifier.text;
299
- if (module !== "@vobs/reactivity" && module !== "@vobs/vobs") continue;
330
+ if (!import_typescript.default.isImportDeclaration(statement) || !import_typescript.default.isStringLiteral(statement.moduleSpecifier)) continue;
331
+ const module2 = statement.moduleSpecifier.text;
332
+ if (module2 !== "@vobs/reactivity" && module2 !== "@vobs/vobs") continue;
300
333
  const clause = statement.importClause;
301
- if (!clause?.namedBindings || !ts__default.default.isNamedImports(clause.namedBindings)) continue;
334
+ if (!clause?.namedBindings || !import_typescript.default.isNamedImports(clause.namedBindings)) continue;
302
335
  for (const element of clause.namedBindings.elements) {
303
336
  if (element.propertyName ? element.propertyName.text === "state" : element.name.text === "state") {
304
337
  aliases.add(element.name.text);
@@ -311,9 +344,9 @@ __name(collectStateAliases, "collectStateAliases");
311
344
  function collectLocallyDeclaredNames(sourceFile) {
312
345
  const names = /* @__PURE__ */ new Set();
313
346
  const visit = /* @__PURE__ */ __name((node) => {
314
- if (ts__default.default.isImportDeclaration(node)) return;
315
- if (ts__default.default.isIdentifier(node) && isBindingName(node)) names.add(node.text);
316
- ts__default.default.forEachChild(node, visit);
347
+ if (import_typescript.default.isImportDeclaration(node)) return;
348
+ if (import_typescript.default.isIdentifier(node) && isBindingName(node)) names.add(node.text);
349
+ import_typescript.default.forEachChild(node, visit);
317
350
  }, "visit");
318
351
  visit(sourceFile);
319
352
  return names;
@@ -322,9 +355,9 @@ __name(collectLocallyDeclaredNames, "collectLocallyDeclaredNames");
322
355
  function isBindingName(node) {
323
356
  const parent = node.parent;
324
357
  if (!parent) return false;
325
- if (ts__default.default.isPropertyAccessExpression(parent) && parent.name === node) return false;
326
- if (ts__default.default.isQualifiedName(parent) && parent.right === node) return false;
327
- if (ts__default.default.isJsxAttribute(parent)) return false;
358
+ if (import_typescript.default.isPropertyAccessExpression(parent) && parent.name === node) return false;
359
+ if (import_typescript.default.isQualifiedName(parent) && parent.right === node) return false;
360
+ if (import_typescript.default.isJsxAttribute(parent)) return false;
328
361
  return parent.name === node;
329
362
  }
330
363
  __name(isBindingName, "isBindingName");
@@ -342,45 +375,45 @@ function resolveHelperName(state, name) {
342
375
  }
343
376
  __name(resolveHelperName, "resolveHelperName");
344
377
  function helperRef(state, name) {
345
- return ts__default.default.factory.createIdentifier(resolveHelperName(state, name));
378
+ return import_typescript.default.factory.createIdentifier(resolveHelperName(state, name));
346
379
  }
347
380
  __name(helperRef, "helperRef");
348
381
  function createRuntimeImports(state) {
349
382
  const modules = /* @__PURE__ */ new Map();
350
383
  for (const [name, alias] of state.helperAliases) {
351
- const module = name === "insertResourceBoundary" ? "@vobs/resource" : "@vobs/vobs";
352
- const imported = modules.get(module) ?? [];
353
- imported.push(ts__default.default.factory.createImportSpecifier(
384
+ const module2 = name === "insertResourceBoundary" ? "@vobs/resource" : "@vobs/vobs";
385
+ const imported = modules.get(module2) ?? [];
386
+ imported.push(import_typescript.default.factory.createImportSpecifier(
354
387
  false,
355
- alias === name ? void 0 : ts__default.default.factory.createIdentifier(name),
356
- ts__default.default.factory.createIdentifier(alias)
388
+ alias === name ? void 0 : import_typescript.default.factory.createIdentifier(name),
389
+ import_typescript.default.factory.createIdentifier(alias)
357
390
  ));
358
- modules.set(module, imported);
391
+ modules.set(module2, imported);
359
392
  }
360
- return [...modules.entries()].map(([module, imported]) => ts__default.default.factory.createImportDeclaration(
393
+ return [...modules.entries()].map(([module2, imported]) => import_typescript.default.factory.createImportDeclaration(
361
394
  void 0,
362
- ts__default.default.factory.createImportClause(
395
+ import_typescript.default.factory.createImportClause(
363
396
  false,
364
397
  void 0,
365
- ts__default.default.factory.createNamedImports(imported)
398
+ import_typescript.default.factory.createNamedImports(imported)
366
399
  ),
367
- ts__default.default.factory.createStringLiteral(module)
400
+ import_typescript.default.factory.createStringLiteral(module2)
368
401
  ));
369
402
  }
370
403
  __name(createRuntimeImports, "createRuntimeImports");
371
404
  function rebuildImport(state, node) {
372
- if (!ts__default.default.isStringLiteral(node.moduleSpecifier)) return node;
373
- return tagStatement(state, ts__default.default.factory.createImportDeclaration(
405
+ if (!import_typescript.default.isStringLiteral(node.moduleSpecifier)) return node;
406
+ return tagStatement(state, import_typescript.default.factory.createImportDeclaration(
374
407
  node.modifiers,
375
408
  node.importClause,
376
- ts__default.default.factory.createStringLiteral(node.moduleSpecifier.text),
409
+ import_typescript.default.factory.createStringLiteral(node.moduleSpecifier.text),
377
410
  node.attributes
378
411
  ), node);
379
412
  }
380
413
  __name(rebuildImport, "rebuildImport");
381
414
  function transformStatement(state, node) {
382
- if (ts__default.default.isFunctionDeclaration(node) && node.body) {
383
- return tagStatement(state, ts__default.default.factory.updateFunctionDeclaration(
415
+ if (import_typescript.default.isFunctionDeclaration(node) && node.body) {
416
+ return tagStatement(state, import_typescript.default.factory.updateFunctionDeclaration(
384
417
  node,
385
418
  node.modifiers,
386
419
  node.asteriskToken,
@@ -391,15 +424,15 @@ function transformStatement(state, node) {
391
424
  transformBlock(state, node.body)
392
425
  ), node);
393
426
  }
394
- if (ts__default.default.isVariableStatement(node)) return transformVariableStatement(state, node);
395
- if (ts__default.default.isExportAssignment(node) && containsJsx(node.expression)) {
396
- return tagStatement(state, ts__default.default.factory.updateExportAssignment(node, node.modifiers, transformEmbeddedExpression(state, node.expression)), node);
427
+ if (import_typescript.default.isVariableStatement(node)) return transformVariableStatement(state, node);
428
+ if (import_typescript.default.isExportAssignment(node) && containsJsx(node.expression)) {
429
+ return tagStatement(state, import_typescript.default.factory.updateExportAssignment(node, node.modifiers, transformEmbeddedExpression(state, node.expression)), node);
397
430
  }
398
- if (ts__default.default.isExpressionStatement(node) && containsJsx(node.expression)) {
399
- return tagStatement(state, ts__default.default.factory.updateExpressionStatement(node, transformEmbeddedExpression(state, node.expression)), node);
431
+ if (import_typescript.default.isExpressionStatement(node) && containsJsx(node.expression)) {
432
+ return tagStatement(state, import_typescript.default.factory.updateExpressionStatement(node, transformEmbeddedExpression(state, node.expression)), node);
400
433
  }
401
- if (ts__default.default.isReturnStatement(node) && node.expression && containsJsx(node.expression)) {
402
- return tagStatement(state, ts__default.default.factory.updateReturnStatement(node, transformEmbeddedExpression(state, node.expression)), node);
434
+ if (import_typescript.default.isReturnStatement(node) && node.expression && containsJsx(node.expression)) {
435
+ return tagStatement(state, import_typescript.default.factory.updateReturnStatement(node, transformEmbeddedExpression(state, node.expression)), node);
403
436
  }
404
437
  return node;
405
438
  }
@@ -415,7 +448,7 @@ function transformVariableStatement(state, node) {
415
448
  }
416
449
  if (nextInitializer === initializer) return declaration;
417
450
  changed = true;
418
- return ts__default.default.factory.updateVariableDeclaration(
451
+ return import_typescript.default.factory.updateVariableDeclaration(
419
452
  declaration,
420
453
  declaration.name,
421
454
  declaration.exclamationToken,
@@ -424,28 +457,28 @@ function transformVariableStatement(state, node) {
424
457
  );
425
458
  });
426
459
  if (!changed) return node;
427
- return tagStatement(state, ts__default.default.factory.updateVariableStatement(
460
+ return tagStatement(state, import_typescript.default.factory.updateVariableStatement(
428
461
  node,
429
462
  node.modifiers,
430
- ts__default.default.factory.updateVariableDeclarationList(node.declarationList, declarations)
463
+ import_typescript.default.factory.updateVariableDeclarationList(node.declarationList, declarations)
431
464
  ), node);
432
465
  }
433
466
  __name(transformVariableStatement, "transformVariableStatement");
434
467
  function inferStateDebugName(state, declaration, initializer) {
435
468
  if (state.stateAliases.size === 0) return void 0;
436
- if (!ts__default.default.isIdentifier(declaration.name)) return void 0;
469
+ if (!import_typescript.default.isIdentifier(declaration.name)) return void 0;
437
470
  let call = initializer;
438
- while (ts__default.default.isParenthesizedExpression(call) || ts__default.default.isAsExpression(call) || ts__default.default.isTypeAssertionExpression(call) || ts__default.default.isSatisfiesExpression(call)) {
471
+ while (import_typescript.default.isParenthesizedExpression(call) || import_typescript.default.isAsExpression(call) || import_typescript.default.isTypeAssertionExpression(call) || import_typescript.default.isSatisfiesExpression(call)) {
439
472
  call = call.expression;
440
473
  }
441
- if (!ts__default.default.isCallExpression(call)) return void 0;
474
+ if (!import_typescript.default.isCallExpression(call)) return void 0;
442
475
  const callee = call.expression;
443
- if (!ts__default.default.isIdentifier(callee) || !state.stateAliases.has(callee.text)) return void 0;
476
+ if (!import_typescript.default.isIdentifier(callee) || !state.stateAliases.has(callee.text)) return void 0;
444
477
  if (state.localBindings.has(callee.text)) return void 0;
445
478
  if (call.arguments.length !== 1) return void 0;
446
- return ts__default.default.factory.createCallExpression(callee, call.typeArguments, [
479
+ return import_typescript.default.factory.createCallExpression(callee, call.typeArguments, [
447
480
  ...call.arguments,
448
- ts__default.default.factory.createStringLiteral(declaration.name.text)
481
+ import_typescript.default.factory.createStringLiteral(declaration.name.text)
449
482
  ]);
450
483
  }
451
484
  __name(inferStateDebugName, "inferStateDebugName");
@@ -456,7 +489,7 @@ function containsJsx(expression) {
456
489
  found = true;
457
490
  return;
458
491
  }
459
- ts__default.default.forEachChild(node, visit);
492
+ import_typescript.default.forEachChild(node, visit);
460
493
  }, "visit");
461
494
  visit(expression);
462
495
  return found;
@@ -464,20 +497,20 @@ function containsJsx(expression) {
464
497
  __name(containsJsx, "containsJsx");
465
498
  function transformBlock(state, block) {
466
499
  const statements = block.statements.map((statement) => {
467
- if (!ts__default.default.isReturnStatement(statement) || !statement.expression) return transformStatement(state, statement);
468
- const expression = ts__default.default.isParenthesizedExpression(statement.expression) ? statement.expression.expression : statement.expression;
469
- return isJsxExpression(expression) ? tagStatement(state, ts__default.default.factory.updateReturnStatement(statement, transformJsxExpression(state, expression)), statement) : statement;
500
+ if (!import_typescript.default.isReturnStatement(statement) || !statement.expression) return transformStatement(state, statement);
501
+ const expression = import_typescript.default.isParenthesizedExpression(statement.expression) ? statement.expression.expression : statement.expression;
502
+ return isJsxExpression(expression) ? tagStatement(state, import_typescript.default.factory.updateReturnStatement(statement, transformJsxExpression(state, expression)), statement) : statement;
470
503
  });
471
- return ts__default.default.factory.updateBlock(block, statements);
504
+ return import_typescript.default.factory.updateBlock(block, statements);
472
505
  }
473
506
  __name(transformBlock, "transformBlock");
474
507
  function isJsxExpression(node) {
475
- return ts__default.default.isJsxElement(node) || ts__default.default.isJsxSelfClosingElement(node) || ts__default.default.isJsxFragment(node);
508
+ return import_typescript.default.isJsxElement(node) || import_typescript.default.isJsxSelfClosingElement(node) || import_typescript.default.isJsxFragment(node);
476
509
  }
477
510
  __name(isJsxExpression, "isJsxExpression");
478
511
  function transformJsxExpression(state, node) {
479
- if (ts__default.default.isJsxFragment(node)) return transformFragment(state, node.children);
480
- if (ts__default.default.isJsxElement(node)) {
512
+ if (import_typescript.default.isJsxFragment(node)) return transformFragment(state, node.children);
513
+ if (import_typescript.default.isJsxElement(node)) {
481
514
  return transformElement(state, node, node.openingElement.tagName, node.openingElement.attributes, node.children);
482
515
  }
483
516
  return transformElement(state, node, node.tagName, node.attributes, []);
@@ -485,35 +518,35 @@ function transformJsxExpression(state, node) {
485
518
  __name(transformJsxExpression, "transformJsxExpression");
486
519
  function transformElement(state, node, tagName, attributes, children) {
487
520
  if (isFragmentTag(tagName)) return transformFragment(state, children);
488
- if (!ts__default.default.isIdentifier(tagName)) {
521
+ if (!import_typescript.default.isIdentifier(tagName)) {
489
522
  reportUnsupportedTag(state, tagName);
490
523
  }
491
- if (ts__default.default.isIdentifier(tagName) && tagName.text === "ResourceBoundary") {
524
+ if (import_typescript.default.isIdentifier(tagName) && tagName.text === "ResourceBoundary") {
492
525
  return transformResourceBoundary(state, node, attributes, children);
493
526
  }
494
- if (ts__default.default.isIdentifier(tagName) && tagName.text === "AsyncBoundary") {
527
+ if (import_typescript.default.isIdentifier(tagName) && tagName.text === "AsyncBoundary") {
495
528
  return transformAsyncBoundary(state, node, attributes, children);
496
529
  }
497
- if (ts__default.default.isIdentifier(tagName) && tagName.text === "ErrorBoundary") {
530
+ if (import_typescript.default.isIdentifier(tagName) && tagName.text === "ErrorBoundary") {
498
531
  return transformErrorBoundary(state, node, attributes, children);
499
532
  }
500
- if (ts__default.default.isIdentifier(tagName) && tagName.text === "Profiler") {
533
+ if (import_typescript.default.isIdentifier(tagName) && tagName.text === "Profiler") {
501
534
  return transformProfiler(state, node, attributes, children);
502
535
  }
503
- if (ts__default.default.isIdentifier(tagName) && /^[A-Z]/.test(tagName.text)) {
536
+ if (import_typescript.default.isIdentifier(tagName) && /^[A-Z]/.test(tagName.text)) {
504
537
  const args = [
505
- ts__default.default.factory.createCallExpression(helperRef(state, "resolveComponent"), void 0, [
538
+ import_typescript.default.factory.createCallExpression(helperRef(state, "resolveComponent"), void 0, [
506
539
  tagName,
507
- ts__default.default.factory.createStringLiteral(state.filename),
508
- ts__default.default.factory.createStringLiteral(tagName.text)
540
+ import_typescript.default.factory.createStringLiteral(state.filename),
541
+ import_typescript.default.factory.createStringLiteral(tagName.text)
509
542
  ]),
510
543
  createComponentProps(state, attributes, children)
511
544
  ];
512
545
  if (state.sourceLocation) args.push(createSourceLocation(tagName));
513
- return ts__default.default.factory.createCallExpression(helperRef(state, "createComponent"), void 0, args);
546
+ return import_typescript.default.factory.createCallExpression(helperRef(state, "createComponent"), void 0, args);
514
547
  }
515
548
  if (isStaticElement(tagName, attributes, children)) {
516
- return ts__default.default.factory.createCallExpression(
549
+ return import_typescript.default.factory.createCallExpression(
517
550
  helperRef(state, "cloneTemplate"),
518
551
  void 0,
519
552
  [registerTemplate(state, serializeStaticHtml(node))]
@@ -525,25 +558,25 @@ function transformElement(state, node, tagName, attributes, children) {
525
558
  createConstStatement(
526
559
  state,
527
560
  elementId,
528
- ts__default.default.factory.createCallExpression(
561
+ import_typescript.default.factory.createCallExpression(
529
562
  helperRef(state, "createElement"),
530
563
  void 0,
531
- [ts__default.default.factory.createStringLiteral(elementName)]
564
+ [import_typescript.default.factory.createStringLiteral(elementName)]
532
565
  ),
533
566
  node
534
567
  )
535
568
  ];
536
569
  appendAttributes(state, statements, elementId, attributes);
537
570
  appendChildren(state, statements, elementId, children);
538
- statements.push(tagStatement(state, ts__default.default.factory.createReturnStatement(elementId), node));
539
- return ts__default.default.factory.createCallExpression(
540
- ts__default.default.factory.createArrowFunction(
571
+ statements.push(tagStatement(state, import_typescript.default.factory.createReturnStatement(elementId), node));
572
+ return import_typescript.default.factory.createCallExpression(
573
+ import_typescript.default.factory.createArrowFunction(
541
574
  void 0,
542
575
  void 0,
543
576
  [],
544
577
  void 0,
545
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken),
546
- ts__default.default.factory.createBlock(statements, true)
578
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken),
579
+ import_typescript.default.factory.createBlock(statements, true)
547
580
  ),
548
581
  void 0,
549
582
  []
@@ -559,29 +592,29 @@ function transformFragment(state, children) {
559
592
  const anchor = nextIdentifier(state, "_fragmentAnchor");
560
593
  const statements = [];
561
594
  appendChildren(state, statements, parent, children, anchor);
562
- return ts__default.default.factory.createCallExpression(
595
+ return import_typescript.default.factory.createCallExpression(
563
596
  helperRef(state, "createFragment"),
564
597
  void 0,
565
- [ts__default.default.factory.createArrowFunction(
598
+ [import_typescript.default.factory.createArrowFunction(
566
599
  void 0,
567
600
  void 0,
568
601
  [
569
- ts__default.default.factory.createParameterDeclaration(void 0, void 0, parent),
570
- ts__default.default.factory.createParameterDeclaration(void 0, void 0, anchor)
602
+ import_typescript.default.factory.createParameterDeclaration(void 0, void 0, parent),
603
+ import_typescript.default.factory.createParameterDeclaration(void 0, void 0, anchor)
571
604
  ],
572
605
  void 0,
573
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken),
574
- ts__default.default.factory.createBlock(statements, true)
606
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken),
607
+ import_typescript.default.factory.createBlock(statements, true)
575
608
  )]
576
609
  );
577
610
  }
578
611
  __name(transformFragment, "transformFragment");
579
612
  function transformResourceBoundary(state, node, attributes, children) {
580
613
  const resource = getAttributeExpression(attributes, "resource");
581
- if (!resource) throw new error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "ResourceBoundary \u5FC5\u987B\u63D0\u4F9B resource \u5C5E\u6027", fix: "\u4E3A ResourceBoundary \u6DFB\u52A0 resource={resource}\u3002" });
614
+ if (!resource) throw new import_error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "ResourceBoundary \u5FC5\u987B\u63D0\u4F9B resource \u5C5E\u6027", fix: "\u4E3A ResourceBoundary \u6DFB\u52A0 resource={resource}\u3002" });
582
615
  const options = [
583
- ts__default.default.factory.createPropertyAssignment("resource", transformEmbeddedExpression(state, resource)),
584
- ts__default.default.factory.createPropertyAssignment("children", createBoundaryFactory(state, children))
616
+ import_typescript.default.factory.createPropertyAssignment("resource", transformEmbeddedExpression(state, resource)),
617
+ import_typescript.default.factory.createPropertyAssignment("children", createBoundaryFactory(state, children))
585
618
  ];
586
619
  appendBoundaryOptionalProperty(state, options, attributes, "loading");
587
620
  appendBoundaryOptionalProperty(state, options, attributes, "empty");
@@ -591,34 +624,34 @@ function transformResourceBoundary(state, node, attributes, children) {
591
624
  __name(transformResourceBoundary, "transformResourceBoundary");
592
625
  function transformErrorBoundary(state, node, attributes, children) {
593
626
  const fallback = getAttributeExpression(attributes, "fallback");
594
- if (!fallback) throw new error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "ErrorBoundary \u5FC5\u987B\u63D0\u4F9B fallback \u5C5E\u6027", fix: "\u4E3A ErrorBoundary \u6DFB\u52A0 fallback={(error, retry) => ...}\u3002" });
627
+ if (!fallback) throw new import_error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "ErrorBoundary \u5FC5\u987B\u63D0\u4F9B fallback \u5C5E\u6027", fix: "\u4E3A ErrorBoundary \u6DFB\u52A0 fallback={(error, retry) => ...}\u3002" });
595
628
  return createBoundaryFragment(state, node, "insertErrorBoundary", [
596
- ts__default.default.factory.createPropertyAssignment("children", createBoundaryFactory(state, children)),
597
- ts__default.default.factory.createPropertyAssignment("fallback", transformEmbeddedExpression(state, fallback))
629
+ import_typescript.default.factory.createPropertyAssignment("children", createBoundaryFactory(state, children)),
630
+ import_typescript.default.factory.createPropertyAssignment("fallback", transformEmbeddedExpression(state, fallback))
598
631
  ]);
599
632
  }
600
633
  __name(transformErrorBoundary, "transformErrorBoundary");
601
634
  function transformAsyncBoundary(state, node, attributes, children) {
602
635
  const promise = getAttributeExpression(attributes, "promise");
603
- if (!promise) throw new error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "AsyncBoundary \u5FC5\u987B\u63D0\u4F9B promise \u5C5E\u6027", fix: "\u4E3A AsyncBoundary \u6DFB\u52A0 promise={promise}\u3002" });
636
+ if (!promise) throw new import_error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "AsyncBoundary \u5FC5\u987B\u63D0\u4F9B promise \u5C5E\u6027", fix: "\u4E3A AsyncBoundary \u6DFB\u52A0 promise={promise}\u3002" });
604
637
  const options = [
605
- ts__default.default.factory.createPropertyAssignment("promise", transformEmbeddedExpression(state, promise)),
606
- ts__default.default.factory.createPropertyAssignment("children", createAsyncFactory(state, children))
638
+ import_typescript.default.factory.createPropertyAssignment("promise", transformEmbeddedExpression(state, promise)),
639
+ import_typescript.default.factory.createPropertyAssignment("children", createAsyncFactory(state, children))
607
640
  ];
608
641
  appendBoundaryOptionalProperty(state, options, attributes, "loading");
609
642
  appendBoundaryOptionalProperty(state, options, attributes, "fallback");
610
643
  const resetKey = getAttributeExpression(attributes, "resetKey");
611
- if (resetKey) options.push(ts__default.default.factory.createPropertyAssignment("resetKey", createGetter(resetKey)));
644
+ if (resetKey) options.push(import_typescript.default.factory.createPropertyAssignment("resetKey", createGetter(resetKey)));
612
645
  return createBoundaryFragment(state, node, "insertAsyncBoundary", options);
613
646
  }
614
647
  __name(transformAsyncBoundary, "transformAsyncBoundary");
615
648
  function transformProfiler(state, node, attributes, children) {
616
- const idAttribute = attributes.properties.find((attribute) => ts__default.default.isJsxAttribute(attribute) && attribute.name.getText() === "id");
617
- const id = idAttribute && ts__default.default.isJsxAttribute(idAttribute) && idAttribute.initializer && ts__default.default.isStringLiteral(idAttribute.initializer) ? ts__default.default.factory.createStringLiteral(idAttribute.initializer.text) : idAttribute && ts__default.default.isJsxAttribute(idAttribute) && idAttribute.initializer && ts__default.default.isJsxExpression(idAttribute.initializer) ? idAttribute.initializer.expression : null;
618
- if (!id) throw new error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "Profiler \u5FC5\u987B\u63D0\u4F9B id \u5C5E\u6027", fix: '\u4E3A Profiler \u6DFB\u52A0 id="ComponentName"\u3002' });
649
+ const idAttribute = attributes.properties.find((attribute) => import_typescript.default.isJsxAttribute(attribute) && attribute.name.getText() === "id");
650
+ const id = idAttribute && import_typescript.default.isJsxAttribute(idAttribute) && idAttribute.initializer && import_typescript.default.isStringLiteral(idAttribute.initializer) ? import_typescript.default.factory.createStringLiteral(idAttribute.initializer.text) : idAttribute && import_typescript.default.isJsxAttribute(idAttribute) && idAttribute.initializer && import_typescript.default.isJsxExpression(idAttribute.initializer) ? idAttribute.initializer.expression : null;
651
+ if (!id) throw new import_error.VobsError({ code: "VOBS_C002", layer: "compiler", message: "Profiler \u5FC5\u987B\u63D0\u4F9B id \u5C5E\u6027", fix: '\u4E3A Profiler \u6DFB\u52A0 id="ComponentName"\u3002' });
619
652
  const options = [
620
- ts__default.default.factory.createPropertyAssignment("id", transformEmbeddedExpression(state, id)),
621
- ts__default.default.factory.createPropertyAssignment("children", createBoundaryFactory(state, children))
653
+ import_typescript.default.factory.createPropertyAssignment("id", transformEmbeddedExpression(state, id)),
654
+ import_typescript.default.factory.createPropertyAssignment("children", createBoundaryFactory(state, children))
622
655
  ];
623
656
  appendBoundaryOptionalProperty(state, options, attributes, "onRender");
624
657
  return createBoundaryFragment(state, node, "insertProfiler", options);
@@ -627,22 +660,22 @@ __name(transformProfiler, "transformProfiler");
627
660
  function createBoundaryFragment(state, node, helper, options) {
628
661
  const parent = nextIdentifier(state, "_boundaryParent");
629
662
  const anchor = nextIdentifier(state, "_boundaryAnchor");
630
- return ts__default.default.factory.createCallExpression(
663
+ return import_typescript.default.factory.createCallExpression(
631
664
  helperRef(state, "createFragment"),
632
665
  void 0,
633
- [ts__default.default.factory.createArrowFunction(
666
+ [import_typescript.default.factory.createArrowFunction(
634
667
  void 0,
635
668
  void 0,
636
669
  [
637
- ts__default.default.factory.createParameterDeclaration(void 0, void 0, parent),
638
- ts__default.default.factory.createParameterDeclaration(void 0, void 0, anchor)
670
+ import_typescript.default.factory.createParameterDeclaration(void 0, void 0, parent),
671
+ import_typescript.default.factory.createParameterDeclaration(void 0, void 0, anchor)
639
672
  ],
640
673
  void 0,
641
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken),
642
- ts__default.default.factory.createBlock([callStatement(state, helper, [
674
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken),
675
+ import_typescript.default.factory.createBlock([callStatement(state, helper, [
643
676
  parent,
644
677
  anchor,
645
- ts__default.default.factory.createObjectLiteralExpression(options, true)
678
+ import_typescript.default.factory.createObjectLiteralExpression(options, true)
646
679
  ], node)], true)
647
680
  )]
648
681
  );
@@ -650,27 +683,27 @@ function createBoundaryFragment(state, node, helper, options) {
650
683
  __name(createBoundaryFragment, "createBoundaryFragment");
651
684
  function createBoundaryFactory(state, children) {
652
685
  const content = transformFragment(state, children);
653
- return ts__default.default.factory.createArrowFunction(
686
+ return import_typescript.default.factory.createArrowFunction(
654
687
  void 0,
655
688
  void 0,
656
689
  [],
657
690
  void 0,
658
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken),
691
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken),
659
692
  content
660
693
  );
661
694
  }
662
695
  __name(createBoundaryFactory, "createBoundaryFactory");
663
696
  function createAsyncFactory(state, children) {
664
- const value = ts__default.default.factory.createIdentifier("value");
665
- const expressionChild = children.length === 1 && children[0].kind === ts__default.default.SyntaxKind.JsxExpression ? children[0].expression : void 0;
666
- if (expressionChild && ts__default.default.isArrowFunction(expressionChild)) {
697
+ const value = import_typescript.default.factory.createIdentifier("value");
698
+ const expressionChild = children.length === 1 && children[0].kind === import_typescript.default.SyntaxKind.JsxExpression ? children[0].expression : void 0;
699
+ if (expressionChild && import_typescript.default.isArrowFunction(expressionChild)) {
667
700
  const transformed = transformEmbeddedExpression(state, expressionChild);
668
701
  return transformed;
669
702
  }
670
703
  const content = transformFragment(state, children);
671
- return ts__default.default.factory.createArrowFunction(void 0, void 0, [
672
- ts__default.default.factory.createParameterDeclaration(void 0, void 0, value)
673
- ], void 0, ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken), content);
704
+ return import_typescript.default.factory.createArrowFunction(void 0, void 0, [
705
+ import_typescript.default.factory.createParameterDeclaration(void 0, void 0, value)
706
+ ], void 0, import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken), content);
674
707
  }
675
708
  __name(createAsyncFactory, "createAsyncFactory");
676
709
  function appendBoundaryOptionalProperty(state, properties, attributes, name) {
@@ -678,14 +711,14 @@ function appendBoundaryOptionalProperty(state, properties, attributes, name) {
678
711
  if (expression) {
679
712
  const transformed = transformEmbeddedExpression(state, expression);
680
713
  const value = isJsxExpression(unwrapExpression(expression)) ? createGetter(transformed) : transformed;
681
- properties.push(ts__default.default.factory.createPropertyAssignment(name, value));
714
+ properties.push(import_typescript.default.factory.createPropertyAssignment(name, value));
682
715
  }
683
716
  }
684
717
  __name(appendBoundaryOptionalProperty, "appendBoundaryOptionalProperty");
685
718
  function getAttributeExpression(attributes, name) {
686
719
  for (const attribute of attributes.properties) {
687
- if (!ts__default.default.isJsxAttribute(attribute) || attribute.name.getText() !== name) continue;
688
- if (attribute.initializer && ts__default.default.isJsxExpression(attribute.initializer)) {
720
+ if (!import_typescript.default.isJsxAttribute(attribute) || attribute.name.getText() !== name) continue;
721
+ if (attribute.initializer && import_typescript.default.isJsxExpression(attribute.initializer)) {
689
722
  return attribute.initializer.expression ?? null;
690
723
  }
691
724
  }
@@ -693,14 +726,14 @@ function getAttributeExpression(attributes, name) {
693
726
  }
694
727
  __name(getAttributeExpression, "getAttributeExpression");
695
728
  function transformEmbeddedExpression(state, expression) {
696
- const result = ts__default.default.transform(expression, [(context) => (root) => {
729
+ const result = import_typescript.default.transform(expression, [(context) => (root) => {
697
730
  const visit = /* @__PURE__ */ __name((node) => {
698
- if (ts__default.default.isJsxElement(node) || ts__default.default.isJsxSelfClosingElement(node) || ts__default.default.isJsxFragment(node)) {
731
+ if (import_typescript.default.isJsxElement(node) || import_typescript.default.isJsxSelfClosingElement(node) || import_typescript.default.isJsxFragment(node)) {
699
732
  return transformJsxExpression(state, node);
700
733
  }
701
- return ts__default.default.visitEachChild(node, visit, context);
734
+ return import_typescript.default.visitEachChild(node, visit, context);
702
735
  }, "visit");
703
- return ts__default.default.visitNode(root, visit);
736
+ return import_typescript.default.visitNode(root, visit);
704
737
  }]);
705
738
  try {
706
739
  return result.transformed[0];
@@ -710,20 +743,20 @@ function transformEmbeddedExpression(state, expression) {
710
743
  }
711
744
  __name(transformEmbeddedExpression, "transformEmbeddedExpression");
712
745
  function isStaticElement(tagName, attributes, children) {
713
- if (!ts__default.default.isIdentifier(tagName) || !/^[a-z]/.test(tagName.text)) return false;
746
+ if (!import_typescript.default.isIdentifier(tagName) || !/^[a-z]/.test(tagName.text)) return false;
714
747
  for (const attribute of attributes.properties) {
715
- if (ts__default.default.isJsxSpreadAttribute(attribute)) return false;
716
- if (!ts__default.default.isJsxAttribute(attribute)) return false;
748
+ if (import_typescript.default.isJsxSpreadAttribute(attribute)) return false;
749
+ if (!import_typescript.default.isJsxAttribute(attribute)) return false;
717
750
  const name = attribute.name.getText();
718
751
  if (name === "key" || name === "ref" || name.startsWith("on")) return false;
719
752
  if (isPropertyAttribute(name)) return false;
720
753
  const initializer = attribute.initializer;
721
- if (initializer && !ts__default.default.isStringLiteral(initializer)) return false;
754
+ if (initializer && !import_typescript.default.isStringLiteral(initializer)) return false;
722
755
  }
723
756
  for (const child of children) {
724
- if (ts__default.default.isJsxText(child)) continue;
725
- if (ts__default.default.isJsxElement(child) || ts__default.default.isJsxSelfClosingElement(child)) {
726
- const nested = ts__default.default.isJsxElement(child) ? { tagName: child.openingElement.tagName, attributes: child.openingElement.attributes, children: child.children } : { tagName: child.tagName, attributes: child.attributes, children: [] };
757
+ if (import_typescript.default.isJsxText(child)) continue;
758
+ if (import_typescript.default.isJsxElement(child) || import_typescript.default.isJsxSelfClosingElement(child)) {
759
+ const nested = import_typescript.default.isJsxElement(child) ? { tagName: child.openingElement.tagName, attributes: child.openingElement.attributes, children: child.children } : { tagName: child.tagName, attributes: child.attributes, children: [] };
727
760
  if (!isStaticElement(nested.tagName, nested.attributes, nested.children)) return false;
728
761
  continue;
729
762
  }
@@ -733,7 +766,7 @@ function isStaticElement(tagName, attributes, children) {
733
766
  }
734
767
  __name(isStaticElement, "isStaticElement");
735
768
  function serializeStaticHtml(node) {
736
- const { tagName, attributes, children } = ts__default.default.isJsxElement(node) ? { tagName: node.openingElement.tagName, attributes: node.openingElement.attributes, children: node.children } : { tagName: node.tagName, attributes: node.attributes, children: [] };
769
+ const { tagName, attributes, children } = import_typescript.default.isJsxElement(node) ? { tagName: node.openingElement.tagName, attributes: node.openingElement.attributes, children: node.children } : { tagName: node.tagName, attributes: node.attributes, children: [] };
737
770
  return serializeStaticElement(tagName, attributes, children);
738
771
  }
739
772
  __name(serializeStaticHtml, "serializeStaticHtml");
@@ -741,25 +774,25 @@ function serializeStaticElement(tagName, attributes, children) {
741
774
  const name = tagName.getText();
742
775
  let html = `<${name}`;
743
776
  for (const attribute of attributes.properties) {
744
- if (!ts__default.default.isJsxAttribute(attribute)) continue;
777
+ if (!import_typescript.default.isJsxAttribute(attribute)) continue;
745
778
  const attributeName = attribute.name.getText() === "className" ? "class" : attribute.name.getText();
746
779
  const initializer = attribute.initializer;
747
780
  if (!initializer) {
748
781
  html += ` ${attributeName}=""`;
749
782
  continue;
750
783
  }
751
- if (ts__default.default.isStringLiteral(initializer)) {
784
+ if (import_typescript.default.isStringLiteral(initializer)) {
752
785
  html += ` ${attributeName}="${escapeHtmlAttribute(initializer.text)}"`;
753
786
  }
754
787
  }
755
788
  html += ">";
756
789
  for (const child of children) {
757
- if (ts__default.default.isJsxText(child)) {
790
+ if (import_typescript.default.isJsxText(child)) {
758
791
  const text = child.text.replace(/\s+/g, " ").trimStart();
759
792
  if (text.trim()) html += escapeHtmlText(text);
760
793
  continue;
761
794
  }
762
- if (ts__default.default.isJsxElement(child)) {
795
+ if (import_typescript.default.isJsxElement(child)) {
763
796
  html += serializeStaticElement(
764
797
  child.openingElement.tagName,
765
798
  child.openingElement.attributes,
@@ -767,7 +800,7 @@ function serializeStaticElement(tagName, attributes, children) {
767
800
  );
768
801
  continue;
769
802
  }
770
- if (ts__default.default.isJsxSelfClosingElement(child)) {
803
+ if (import_typescript.default.isJsxSelfClosingElement(child)) {
771
804
  html += serializeStaticElement(child.tagName, child.attributes, []);
772
805
  }
773
806
  }
@@ -793,103 +826,103 @@ function registerTemplate(state, html) {
793
826
  __name(registerTemplate, "registerTemplate");
794
827
  function createTemplateDeclarations(state) {
795
828
  return [...state.templates.entries()].map(
796
- ([html, identifier]) => ts__default.default.factory.createVariableStatement(void 0, ts__default.default.factory.createVariableDeclarationList([
797
- ts__default.default.factory.createVariableDeclaration(identifier, void 0, void 0, ts__default.default.factory.createCallExpression(
829
+ ([html, identifier]) => import_typescript.default.factory.createVariableStatement(void 0, import_typescript.default.factory.createVariableDeclarationList([
830
+ import_typescript.default.factory.createVariableDeclaration(identifier, void 0, void 0, import_typescript.default.factory.createCallExpression(
798
831
  helperRef(state, "createTemplate"),
799
832
  void 0,
800
- [ts__default.default.factory.createStringLiteral(html)]
833
+ [import_typescript.default.factory.createStringLiteral(html)]
801
834
  ))
802
- ], ts__default.default.NodeFlags.Const))
835
+ ], import_typescript.default.NodeFlags.Const))
803
836
  );
804
837
  }
805
838
  __name(createTemplateDeclarations, "createTemplateDeclarations");
806
839
  function appendAttributes(state, statements, element, attributes) {
807
840
  const staticProps = [];
808
- const hasSpread = attributes.properties.some((attribute) => ts__default.default.isJsxSpreadAttribute(attribute));
841
+ const hasSpread = attributes.properties.some((attribute) => import_typescript.default.isJsxSpreadAttribute(attribute));
809
842
  for (const attribute of attributes.properties) {
810
- if (ts__default.default.isJsxSpreadAttribute(attribute)) {
843
+ if (import_typescript.default.isJsxSpreadAttribute(attribute)) {
811
844
  statements.push(callStatement(state, "spreadProps", [element, transformEmbeddedExpression(state, attribute.expression)], attribute));
812
845
  continue;
813
846
  }
814
- if (!ts__default.default.isJsxAttribute(attribute)) continue;
847
+ if (!import_typescript.default.isJsxAttribute(attribute)) continue;
815
848
  const name = attribute.name.getText();
816
849
  if (name === "key") continue;
817
850
  if (name === "ref") {
818
851
  const initializer2 = attribute.initializer;
819
- if (initializer2 && ts__default.default.isJsxExpression(initializer2) && initializer2.expression) {
852
+ if (initializer2 && import_typescript.default.isJsxExpression(initializer2) && initializer2.expression) {
820
853
  statements.push(callStatement(state, "setRef", [element, transformEmbeddedExpression(state, initializer2.expression)], attribute));
821
854
  }
822
855
  continue;
823
856
  }
824
857
  const initializer = attribute.initializer;
825
- if (name.startsWith("on") && initializer && ts__default.default.isJsxExpression(initializer) && initializer.expression) {
858
+ if (name.startsWith("on") && initializer && import_typescript.default.isJsxExpression(initializer) && initializer.expression) {
826
859
  statements.push(callStatement(state, "addEventListener", [
827
860
  element,
828
- ts__default.default.factory.createStringLiteral(name.slice(2).toLowerCase()),
861
+ import_typescript.default.factory.createStringLiteral(name.slice(2).toLowerCase()),
829
862
  initializer.expression
830
863
  ], attribute));
831
864
  continue;
832
865
  }
833
866
  if (!initializer) {
834
867
  if (hasSpread) {
835
- statements.push(callStatement(state, isPropertyAttribute(name) ? "setProperty" : "setAttribute", [element, ts__default.default.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === "className" ? "class" : name), isPropertyAttribute(name) ? ts__default.default.factory.createTrue() : ts__default.default.factory.createStringLiteral("")], attribute));
868
+ statements.push(callStatement(state, isPropertyAttribute(name) ? "setProperty" : "setAttribute", [element, import_typescript.default.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === "className" ? "class" : name), isPropertyAttribute(name) ? import_typescript.default.factory.createTrue() : import_typescript.default.factory.createStringLiteral("")], attribute));
836
869
  continue;
837
870
  }
838
- if (isPropertyAttribute(name)) staticProps.push(createStaticProperty(name, ts__default.default.factory.createTrue()));
839
- else staticProps.push(createStaticProperty(name === "className" ? "class" : name, ts__default.default.factory.createStringLiteral("")));
871
+ if (isPropertyAttribute(name)) staticProps.push(createStaticProperty(name, import_typescript.default.factory.createTrue()));
872
+ else staticProps.push(createStaticProperty(name === "className" ? "class" : name, import_typescript.default.factory.createStringLiteral("")));
840
873
  continue;
841
874
  }
842
- if (ts__default.default.isStringLiteral(initializer)) {
875
+ if (import_typescript.default.isStringLiteral(initializer)) {
843
876
  if (hasSpread) {
844
- statements.push(callStatement(state, isPropertyAttribute(name) ? "setProperty" : "setAttribute", [element, ts__default.default.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === "className" ? "class" : name), ts__default.default.factory.createStringLiteral(initializer.text)], attribute));
877
+ statements.push(callStatement(state, isPropertyAttribute(name) ? "setProperty" : "setAttribute", [element, import_typescript.default.factory.createStringLiteral(isPropertyAttribute(name) ? name : name === "className" ? "class" : name), import_typescript.default.factory.createStringLiteral(initializer.text)], attribute));
845
878
  continue;
846
879
  }
847
880
  staticProps.push(createStaticProperty(
848
881
  isPropertyAttribute(name) ? name : name === "className" ? "class" : name,
849
- ts__default.default.factory.createStringLiteral(initializer.text)
882
+ import_typescript.default.factory.createStringLiteral(initializer.text)
850
883
  ));
851
884
  continue;
852
885
  }
853
886
  const attributeName = name === "className" ? "class" : name;
854
887
  const propertyAttribute = isPropertyAttribute(name);
855
- if (ts__default.default.isJsxExpression(initializer) && initializer.expression) {
888
+ if (import_typescript.default.isJsxExpression(initializer) && initializer.expression) {
856
889
  statements.push(callStatement(state, propertyAttribute ? "bindProperty" : "bindAttribute", [
857
890
  element,
858
- ts__default.default.factory.createStringLiteral(propertyAttribute ? name : attributeName),
891
+ import_typescript.default.factory.createStringLiteral(propertyAttribute ? name : attributeName),
859
892
  createGetter(initializer.expression)
860
893
  ], attribute));
861
894
  }
862
895
  }
863
896
  if (staticProps.length) statements.splice(1, 0, callStatement(state, "setStaticProps", [
864
897
  element,
865
- ts__default.default.factory.createObjectLiteralExpression(staticProps, true)
898
+ import_typescript.default.factory.createObjectLiteralExpression(staticProps, true)
866
899
  ], attributes));
867
900
  }
868
901
  __name(appendAttributes, "appendAttributes");
869
902
  function createStaticProperty(name, value) {
870
- return ts__default.default.factory.createPropertyAssignment(ts__default.default.factory.createStringLiteral(name), value);
903
+ return import_typescript.default.factory.createPropertyAssignment(import_typescript.default.factory.createStringLiteral(name), value);
871
904
  }
872
905
  __name(createStaticProperty, "createStaticProperty");
873
906
  function isPropertyAttribute(name) {
874
907
  return name === "value" || name === "checked" || name === "selected" || name === "disabled" || name === "multiple" || name === "readOnly" || name === "required" || name === "autofocus" || name === "hidden" || name === "tabIndex";
875
908
  }
876
909
  __name(isPropertyAttribute, "isPropertyAttribute");
877
- function appendChildren(state, statements, element, children, anchor = ts__default.default.factory.createNull()) {
910
+ function appendChildren(state, statements, element, children, anchor = import_typescript.default.factory.createNull()) {
878
911
  for (const child of children) {
879
- if (ts__default.default.isJsxText(child)) {
912
+ if (import_typescript.default.isJsxText(child)) {
880
913
  const text = child.text.replace(/\s+/g, " ").trimStart();
881
914
  if (text.trim()) {
882
915
  statements.push(callStatement(state, "insertBefore", [
883
916
  element,
884
- ts__default.default.factory.createCallExpression(helperRef(state, "createText"), void 0, [
885
- ts__default.default.factory.createStringLiteral(text)
917
+ import_typescript.default.factory.createCallExpression(helperRef(state, "createText"), void 0, [
918
+ import_typescript.default.factory.createStringLiteral(text)
886
919
  ]),
887
920
  anchor
888
921
  ], child));
889
922
  }
890
923
  continue;
891
924
  }
892
- if (ts__default.default.isJsxElement(child) || ts__default.default.isJsxSelfClosingElement(child) || ts__default.default.isJsxFragment(child)) {
925
+ if (import_typescript.default.isJsxElement(child) || import_typescript.default.isJsxSelfClosingElement(child) || import_typescript.default.isJsxFragment(child)) {
893
926
  statements.push(callStatement(state, "insertBefore", [
894
927
  element,
895
928
  transformJsxExpression(state, child),
@@ -897,7 +930,7 @@ function appendChildren(state, statements, element, children, anchor = ts__defau
897
930
  ], child));
898
931
  continue;
899
932
  }
900
- if (child.kind === ts__default.default.SyntaxKind.JsxExpression) {
933
+ if (child.kind === import_typescript.default.SyntaxKind.JsxExpression) {
901
934
  const expression = child.expression;
902
935
  if (!expression) continue;
903
936
  const list = transformListExpression(state, element, expression, anchor);
@@ -910,9 +943,9 @@ function appendChildren(state, statements, element, children, anchor = ts__defau
910
943
  statements.push(callStatement(state, "insertDynamic", [element, anchor, dynamic], child));
911
944
  continue;
912
945
  }
913
- if (!containsJsx(expression) && !ts__default.default.isIdentifier(expression)) {
946
+ if (!containsJsx(expression) && !import_typescript.default.isIdentifier(expression)) {
914
947
  const textId = nextIdentifier(state, "_text");
915
- statements.push(createConstStatement(state, textId, ts__default.default.factory.createCallExpression(helperRef(state, "createText"), void 0, [ts__default.default.factory.createStringLiteral("")]), child));
948
+ statements.push(createConstStatement(state, textId, import_typescript.default.factory.createCallExpression(helperRef(state, "createText"), void 0, [import_typescript.default.factory.createStringLiteral("")]), child));
916
949
  statements.push(callStatement(state, "insertBefore", [element, textId, anchor], child));
917
950
  statements.push(callStatement(state, "bindText", [textId, createGetter(expression)], child));
918
951
  continue;
@@ -926,18 +959,18 @@ __name(appendChildren, "appendChildren");
926
959
  function createComponentProps(state, attributes, children) {
927
960
  const properties = [];
928
961
  for (const attribute of attributes.properties) {
929
- if (ts__default.default.isJsxSpreadAttribute(attribute)) {
930
- properties.push(ts__default.default.factory.createSpreadAssignment(attribute.expression));
962
+ if (import_typescript.default.isJsxSpreadAttribute(attribute)) {
963
+ properties.push(import_typescript.default.factory.createSpreadAssignment(attribute.expression));
931
964
  continue;
932
965
  }
933
966
  const name = propertyName(attribute.name.getText());
934
967
  if (attribute.name.getText() === "key") continue;
935
968
  const initializer = attribute.initializer;
936
969
  if (!initializer) {
937
- properties.push(ts__default.default.factory.createPropertyAssignment(name, ts__default.default.factory.createTrue()));
938
- } else if (ts__default.default.isStringLiteral(initializer)) {
939
- properties.push(ts__default.default.factory.createPropertyAssignment(name, ts__default.default.factory.createStringLiteral(initializer.text)));
940
- } else if (ts__default.default.isJsxExpression(initializer) && initializer.expression) {
970
+ properties.push(import_typescript.default.factory.createPropertyAssignment(name, import_typescript.default.factory.createTrue()));
971
+ } else if (import_typescript.default.isStringLiteral(initializer)) {
972
+ properties.push(import_typescript.default.factory.createPropertyAssignment(name, import_typescript.default.factory.createStringLiteral(initializer.text)));
973
+ } else if (import_typescript.default.isJsxExpression(initializer) && initializer.expression) {
941
974
  properties.push(createGetterProperty(name, transformEmbeddedExpression(state, initializer.expression)));
942
975
  }
943
976
  }
@@ -945,43 +978,43 @@ function createComponentProps(state, attributes, children) {
945
978
  if (childExpressions.length === 1) {
946
979
  properties.push(createGetterProperty("children", childExpressions[0]));
947
980
  } else if (childExpressions.length > 1) {
948
- properties.push(createGetterProperty("children", ts__default.default.factory.createArrayLiteralExpression(childExpressions)));
981
+ properties.push(createGetterProperty("children", import_typescript.default.factory.createArrayLiteralExpression(childExpressions)));
949
982
  }
950
- return ts__default.default.factory.createObjectLiteralExpression(properties, true);
983
+ return import_typescript.default.factory.createObjectLiteralExpression(properties, true);
951
984
  }
952
985
  __name(createComponentProps, "createComponentProps");
953
986
  function createSourceLocation(node) {
954
987
  const sourceFile = node.getSourceFile();
955
988
  const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
956
- return ts__default.default.factory.createObjectLiteralExpression([
957
- ts__default.default.factory.createPropertyAssignment("file", ts__default.default.factory.createStringLiteral(sourceFile.fileName)),
958
- ts__default.default.factory.createPropertyAssignment("line", ts__default.default.factory.createNumericLiteral(position.line + 1)),
959
- ts__default.default.factory.createPropertyAssignment("column", ts__default.default.factory.createNumericLiteral(position.character + 1))
989
+ return import_typescript.default.factory.createObjectLiteralExpression([
990
+ import_typescript.default.factory.createPropertyAssignment("file", import_typescript.default.factory.createStringLiteral(sourceFile.fileName)),
991
+ import_typescript.default.factory.createPropertyAssignment("line", import_typescript.default.factory.createNumericLiteral(position.line + 1)),
992
+ import_typescript.default.factory.createPropertyAssignment("column", import_typescript.default.factory.createNumericLiteral(position.character + 1))
960
993
  ], true);
961
994
  }
962
995
  __name(createSourceLocation, "createSourceLocation");
963
996
  function transformDynamicExpression(state, expression) {
964
- if (ts__default.default.isBinaryExpression(expression) && expression.operatorToken.kind === ts__default.default.SyntaxKind.AmpersandAmpersandToken) {
997
+ if (import_typescript.default.isBinaryExpression(expression) && expression.operatorToken.kind === import_typescript.default.SyntaxKind.AmpersandAmpersandToken) {
965
998
  const right = unwrapExpression(expression.right);
966
999
  if (!isJsxExpression(right)) return null;
967
- return createGetter(ts__default.default.factory.createConditionalExpression(
1000
+ return createGetter(import_typescript.default.factory.createConditionalExpression(
968
1001
  expression.left,
969
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.QuestionToken),
1002
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.QuestionToken),
970
1003
  transformJsxExpression(state, right),
971
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.ColonToken),
972
- ts__default.default.factory.createNull()
1004
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.ColonToken),
1005
+ import_typescript.default.factory.createNull()
973
1006
  ));
974
1007
  }
975
- if (ts__default.default.isConditionalExpression(expression)) {
1008
+ if (import_typescript.default.isConditionalExpression(expression)) {
976
1009
  const whenTrue = transformDynamicBranch(state, expression.whenTrue);
977
1010
  const whenFalse = transformDynamicBranch(state, expression.whenFalse);
978
1011
  if (!whenTrue && !whenFalse) return null;
979
- return createGetter(ts__default.default.factory.createConditionalExpression(
1012
+ return createGetter(import_typescript.default.factory.createConditionalExpression(
980
1013
  expression.condition,
981
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.QuestionToken),
982
- whenTrue ?? ts__default.default.factory.createNull(),
983
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.ColonToken),
984
- whenFalse ?? ts__default.default.factory.createNull()
1014
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.QuestionToken),
1015
+ whenTrue ?? import_typescript.default.factory.createNull(),
1016
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.ColonToken),
1017
+ whenFalse ?? import_typescript.default.factory.createNull()
985
1018
  ));
986
1019
  }
987
1020
  return null;
@@ -990,17 +1023,17 @@ __name(transformDynamicExpression, "transformDynamicExpression");
990
1023
  function transformDynamicBranch(state, expression) {
991
1024
  const branch = unwrapExpression(expression);
992
1025
  if (isJsxExpression(branch)) return transformJsxExpression(state, branch);
993
- if (branch.kind === ts__default.default.SyntaxKind.NullKeyword || branch.kind === ts__default.default.SyntaxKind.FalseKeyword) return branch;
1026
+ if (branch.kind === import_typescript.default.SyntaxKind.NullKeyword || branch.kind === import_typescript.default.SyntaxKind.FalseKeyword) return branch;
994
1027
  return null;
995
1028
  }
996
1029
  __name(transformDynamicBranch, "transformDynamicBranch");
997
1030
  function transformListExpression(state, parent, expression, anchor) {
998
- if (!ts__default.default.isCallExpression(expression) || expression.arguments.length !== 1) return null;
999
- if (!ts__default.default.isPropertyAccessExpression(expression.expression) || expression.expression.name.text !== "map") return null;
1031
+ if (!import_typescript.default.isCallExpression(expression) || expression.arguments.length !== 1) return null;
1032
+ if (!import_typescript.default.isPropertyAccessExpression(expression.expression) || expression.expression.name.text !== "map") return null;
1000
1033
  const callback = expression.arguments[0];
1001
- if (!ts__default.default.isArrowFunction(callback) && !ts__default.default.isFunctionExpression(callback)) return null;
1034
+ if (!import_typescript.default.isArrowFunction(callback) && !import_typescript.default.isFunctionExpression(callback)) return null;
1002
1035
  const body = unwrapExpression(callback.body);
1003
- if (!isJsxExpression(body) || ts__default.default.isJsxFragment(body)) return null;
1036
+ if (!isJsxExpression(body) || import_typescript.default.isJsxFragment(body)) return null;
1004
1037
  const key = findKeyExpression(body);
1005
1038
  const renderItem = transformListCallback(callback, transformJsxExpression(state, body));
1006
1039
  const args = [
@@ -1014,8 +1047,8 @@ function transformListExpression(state, parent, expression, anchor) {
1014
1047
  }
1015
1048
  __name(transformListExpression, "transformListExpression");
1016
1049
  function transformListCallback(callback, body) {
1017
- if (ts__default.default.isArrowFunction(callback)) {
1018
- return ts__default.default.factory.updateArrowFunction(
1050
+ if (import_typescript.default.isArrowFunction(callback)) {
1051
+ return import_typescript.default.factory.updateArrowFunction(
1019
1052
  callback,
1020
1053
  callback.modifiers,
1021
1054
  callback.typeParameters,
@@ -1025,7 +1058,7 @@ function transformListCallback(callback, body) {
1025
1058
  body
1026
1059
  );
1027
1060
  }
1028
- return ts__default.default.factory.updateFunctionExpression(
1061
+ return import_typescript.default.factory.updateFunctionExpression(
1029
1062
  callback,
1030
1063
  callback.modifiers,
1031
1064
  callback.asteriskToken,
@@ -1033,26 +1066,26 @@ function transformListCallback(callback, body) {
1033
1066
  callback.typeParameters,
1034
1067
  callback.parameters,
1035
1068
  callback.type,
1036
- ts__default.default.factory.createBlock([ts__default.default.factory.createReturnStatement(body)], true)
1069
+ import_typescript.default.factory.createBlock([import_typescript.default.factory.createReturnStatement(body)], true)
1037
1070
  );
1038
1071
  }
1039
1072
  __name(transformListCallback, "transformListCallback");
1040
1073
  function createKeyCallback(callback, key) {
1041
- return ts__default.default.factory.createArrowFunction(
1074
+ return import_typescript.default.factory.createArrowFunction(
1042
1075
  void 0,
1043
1076
  void 0,
1044
1077
  callback.parameters,
1045
1078
  void 0,
1046
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken),
1079
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken),
1047
1080
  key
1048
1081
  );
1049
1082
  }
1050
1083
  __name(createKeyCallback, "createKeyCallback");
1051
1084
  function findKeyExpression(node) {
1052
- const attributes = ts__default.default.isJsxElement(node) ? node.openingElement.attributes : node.attributes;
1085
+ const attributes = import_typescript.default.isJsxElement(node) ? node.openingElement.attributes : node.attributes;
1053
1086
  for (const attribute of attributes.properties) {
1054
- if (!ts__default.default.isJsxAttribute(attribute) || attribute.name.getText() !== "key") continue;
1055
- if (attribute.initializer && ts__default.default.isJsxExpression(attribute.initializer)) {
1087
+ if (!import_typescript.default.isJsxAttribute(attribute) || attribute.name.getText() !== "key") continue;
1088
+ if (attribute.initializer && import_typescript.default.isJsxExpression(attribute.initializer)) {
1056
1089
  return attribute.initializer.expression ?? null;
1057
1090
  }
1058
1091
  }
@@ -1060,18 +1093,18 @@ function findKeyExpression(node) {
1060
1093
  }
1061
1094
  __name(findKeyExpression, "findKeyExpression");
1062
1095
  function unwrapExpression(node) {
1063
- return ts__default.default.isParenthesizedExpression(node) ? node.expression : node;
1096
+ return import_typescript.default.isParenthesizedExpression(node) ? node.expression : node;
1064
1097
  }
1065
1098
  __name(unwrapExpression, "unwrapExpression");
1066
1099
  function childToComponentExpression(state, child) {
1067
- if (ts__default.default.isJsxText(child)) {
1100
+ if (import_typescript.default.isJsxText(child)) {
1068
1101
  const text = child.text.replace(/\s+/g, " ").trim();
1069
- return text ? [ts__default.default.factory.createStringLiteral(text)] : [];
1102
+ return text ? [import_typescript.default.factory.createStringLiteral(text)] : [];
1070
1103
  }
1071
- if (ts__default.default.isJsxElement(child) || ts__default.default.isJsxSelfClosingElement(child) || ts__default.default.isJsxFragment(child)) {
1104
+ if (import_typescript.default.isJsxElement(child) || import_typescript.default.isJsxSelfClosingElement(child) || import_typescript.default.isJsxFragment(child)) {
1072
1105
  return [transformJsxExpression(state, child)];
1073
1106
  }
1074
- if (child.kind === ts__default.default.SyntaxKind.JsxExpression) {
1107
+ if (child.kind === import_typescript.default.SyntaxKind.JsxExpression) {
1075
1108
  const expression = child.expression;
1076
1109
  return expression ? [transformEmbeddedExpression(state, expression)] : [];
1077
1110
  }
@@ -1079,43 +1112,43 @@ function childToComponentExpression(state, child) {
1079
1112
  }
1080
1113
  __name(childToComponentExpression, "childToComponentExpression");
1081
1114
  function propertyName(name) {
1082
- return /^[$A-Z_a-z][$\w]*$/u.test(name) ? ts__default.default.factory.createIdentifier(name) : ts__default.default.factory.createStringLiteral(name);
1115
+ return /^[$A-Z_a-z][$\w]*$/u.test(name) ? import_typescript.default.factory.createIdentifier(name) : import_typescript.default.factory.createStringLiteral(name);
1083
1116
  }
1084
1117
  __name(propertyName, "propertyName");
1085
1118
  function createGetter(expression) {
1086
- return ts__default.default.factory.createArrowFunction(
1119
+ return import_typescript.default.factory.createArrowFunction(
1087
1120
  void 0,
1088
1121
  void 0,
1089
1122
  [],
1090
1123
  void 0,
1091
- ts__default.default.factory.createToken(ts__default.default.SyntaxKind.EqualsGreaterThanToken),
1124
+ import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken),
1092
1125
  expression
1093
1126
  );
1094
1127
  }
1095
1128
  __name(createGetter, "createGetter");
1096
1129
  function createGetterProperty(name, expression) {
1097
- return ts__default.default.factory.createGetAccessorDeclaration(
1130
+ return import_typescript.default.factory.createGetAccessorDeclaration(
1098
1131
  void 0,
1099
1132
  typeof name === "string" ? propertyName(name) : name,
1100
1133
  [],
1101
1134
  void 0,
1102
- ts__default.default.factory.createBlock([ts__default.default.factory.createReturnStatement(expression)], true)
1135
+ import_typescript.default.factory.createBlock([import_typescript.default.factory.createReturnStatement(expression)], true)
1103
1136
  );
1104
1137
  }
1105
1138
  __name(createGetterProperty, "createGetterProperty");
1106
1139
  function callStatement(state, name, args, source) {
1107
- const statement = ts__default.default.factory.createExpressionStatement(
1108
- ts__default.default.factory.createCallExpression(helperRef(state, name), void 0, args)
1140
+ const statement = import_typescript.default.factory.createExpressionStatement(
1141
+ import_typescript.default.factory.createCallExpression(helperRef(state, name), void 0, args)
1109
1142
  );
1110
1143
  return source ? tagStatement(state, statement, source) : statement;
1111
1144
  }
1112
1145
  __name(callStatement, "callStatement");
1113
1146
  function createConstStatement(state, name, initializer, source) {
1114
- const statement = ts__default.default.factory.createVariableStatement(
1147
+ const statement = import_typescript.default.factory.createVariableStatement(
1115
1148
  void 0,
1116
- ts__default.default.factory.createVariableDeclarationList([
1117
- ts__default.default.factory.createVariableDeclaration(name, void 0, void 0, initializer)
1118
- ], ts__default.default.NodeFlags.Const)
1149
+ import_typescript.default.factory.createVariableDeclarationList([
1150
+ import_typescript.default.factory.createVariableDeclaration(name, void 0, void 0, initializer)
1151
+ ], import_typescript.default.NodeFlags.Const)
1119
1152
  );
1120
1153
  return source ? tagStatement(state, statement, source) : statement;
1121
1154
  }
@@ -1138,9 +1171,12 @@ function nextIdentifier(state, prefix) {
1138
1171
  do {
1139
1172
  name = `${prefix}${state.generatedId++}`;
1140
1173
  } while (state.takenNames.has(name));
1141
- return ts__default.default.factory.createIdentifier(name);
1174
+ return import_typescript.default.factory.createIdentifier(name);
1142
1175
  }
1143
1176
  __name(nextIdentifier, "nextIdentifier");
1177
+
1178
+ // packages/compiler/src/i18n-extractor.ts
1179
+ var import_typescript2 = __toESM(require("typescript"), 1);
1144
1180
  function createI18nExtractor(options = {}) {
1145
1181
  const names = new Set(options.functions ?? ["t"]);
1146
1182
  const keys = /* @__PURE__ */ new Set();
@@ -1148,14 +1184,14 @@ function createI18nExtractor(options = {}) {
1148
1184
  name: "i18n-extractor",
1149
1185
  analyze(program, context) {
1150
1186
  const visit = /* @__PURE__ */ __name((node) => {
1151
- if (ts__default.default.isCallExpression(node) && isTranslationCall(node.expression, names)) {
1187
+ if (import_typescript2.default.isCallExpression(node) && isTranslationCall(node.expression, names)) {
1152
1188
  const key = readStaticKey(node.arguments[0]);
1153
1189
  if (key) {
1154
1190
  keys.add(key);
1155
1191
  options.onKey?.(key, context.filename);
1156
1192
  }
1157
1193
  }
1158
- ts__default.default.forEachChild(node, visit);
1194
+ import_typescript2.default.forEachChild(node, visit);
1159
1195
  }, "visit");
1160
1196
  visit(program);
1161
1197
  }
@@ -1168,20 +1204,21 @@ function createI18nExtractor(options = {}) {
1168
1204
  }
1169
1205
  __name(createI18nExtractor, "createI18nExtractor");
1170
1206
  function isTranslationCall(expression, names) {
1171
- if (ts__default.default.isIdentifier(expression)) return names.has(expression.text);
1172
- return ts__default.default.isPropertyAccessExpression(expression) && names.has(expression.name.text);
1207
+ if (import_typescript2.default.isIdentifier(expression)) return names.has(expression.text);
1208
+ return import_typescript2.default.isPropertyAccessExpression(expression) && names.has(expression.name.text);
1173
1209
  }
1174
1210
  __name(isTranslationCall, "isTranslationCall");
1175
1211
  function readStaticKey(argument) {
1176
1212
  if (!argument) return void 0;
1177
- if (ts__default.default.isStringLiteral(argument) || ts__default.default.isNoSubstitutionTemplateLiteral(argument)) return argument.text;
1213
+ if (import_typescript2.default.isStringLiteral(argument) || import_typescript2.default.isNoSubstitutionTemplateLiteral(argument)) return argument.text;
1178
1214
  return void 0;
1179
1215
  }
1180
1216
  __name(readStaticKey, "readStaticKey");
1181
-
1182
- exports.compile = compile;
1183
- exports.compileWithSourceMap = compileWithSourceMap;
1184
- exports.createCompiler = createCompiler;
1185
- exports.createI18nExtractor = createI18nExtractor;
1186
- //# sourceMappingURL=index.cjs.map
1217
+ // Annotate the CommonJS export names for ESM import in node:
1218
+ 0 && (module.exports = {
1219
+ compile,
1220
+ compileWithSourceMap,
1221
+ createCompiler,
1222
+ createI18nExtractor
1223
+ });
1187
1224
  //# sourceMappingURL=index.cjs.map