@zeus-js/compiler 0.0.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.
@@ -0,0 +1,1651 @@
1
+ /**
2
+ * compiler v0.0.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { declare } from "@babel/helper-plugin-utils";
7
+ import syntaxJsx from "@babel/plugin-syntax-jsx";
8
+ import { extend } from "@zeus-js/shared";
9
+ import * as t from "@babel/types";
10
+ //#region packages/compiler/src/codegen/support/imports.ts
11
+ /**
12
+ * Runtime helpers registration and program injection.
13
+ *
14
+ * Manages the collection of runtime helper imports (template, insert, setAttr,
15
+ * createComponent, delegateEvents, etc.) and generates the necessary import
16
+ * declarations at the top of the program.
17
+ */
18
+ const DEFAULT_RENDERER_MODULE = "@zeus-js/runtime-dom";
19
+ function getImportKey(moduleName, imported) {
20
+ return `${moduleName}:${imported}`;
21
+ }
22
+ function getRendererConfig(path, renderer = "dom") {
23
+ var _hub$file;
24
+ const hub = path.hub;
25
+ return {
26
+ renderer,
27
+ moduleName: (hub === null || hub === void 0 || (_hub$file = hub.file) === null || _hub$file === void 0 || (_hub$file = _hub$file.metadata) === null || _hub$file === void 0 || (_hub$file = _hub$file.zeus) === null || _hub$file === void 0 || (_hub$file = _hub$file.config) === null || _hub$file === void 0 ? void 0 : _hub$file.moduleName) || "@zeus-js/runtime-dom"
28
+ };
29
+ }
30
+ function registerImportMethod(path, imported, moduleName = getRendererConfig(path, "dom").moduleName) {
31
+ const data = getProgramScopeData(path);
32
+ const importMethods = data.importMethods || (data.importMethods = /* @__PURE__ */ new Map());
33
+ const key = getImportKey(moduleName, imported);
34
+ const cached = importMethods.get(key);
35
+ if (cached) return t.cloneNode(cached.local);
36
+ const local = getProgramPath(path).scope.generateUidIdentifier(imported);
37
+ importMethods.set(key, {
38
+ imported,
39
+ local,
40
+ moduleName
41
+ });
42
+ return t.cloneNode(local);
43
+ }
44
+ /**
45
+ * Generates import declarations for all collected runtime helpers and
46
+ * prepends them to the program body.
47
+ */
48
+ function appendImportMethods(path) {
49
+ const importMethods = path.scope.data.importMethods;
50
+ if (!(importMethods === null || importMethods === void 0 ? void 0 : importMethods.size)) return;
51
+ const grouped = /* @__PURE__ */ new Map();
52
+ for (const record of importMethods.values()) {
53
+ const records = grouped.get(record.moduleName);
54
+ if (records) records.push(record);
55
+ else grouped.set(record.moduleName, [record]);
56
+ }
57
+ const declarations = [];
58
+ for (const [moduleName, records] of grouped) declarations.push(t.importDeclaration(records.map((record) => t.importSpecifier(t.cloneNode(record.local), t.identifier(record.imported))), t.stringLiteral(moduleName)));
59
+ path.unshiftContainer("body", declarations);
60
+ }
61
+ function getProgramScopeData(path) {
62
+ return path.scope.getProgramParent().path.scope.data;
63
+ }
64
+ function getProgramPath(path) {
65
+ return path.scope.getProgramParent().path;
66
+ }
67
+ //#endregion
68
+ //#region packages/compiler/src/codegen/support/templates.ts
69
+ /**
70
+ * Template registration, scope data management, and program injection.
71
+ *
72
+ * Tracks all compiled templates across the program scope, registers template
73
+ * variable declarations (tmpl$0, tmpl$1, ...), and generates the template
74
+ * registration calls at the top of the program.
75
+ */
76
+ /**
77
+ * Retrieves all registered templates for a given renderer.
78
+ */
79
+ function getTemplates(path, renderer = "dom") {
80
+ var _scopeData$templates$, _scopeData$templates;
81
+ return (_scopeData$templates$ = (_scopeData$templates = path.scope.data.templates) === null || _scopeData$templates === void 0 ? void 0 : _scopeData$templates.filter((t) => t.renderer === renderer)) !== null && _scopeData$templates$ !== void 0 ? _scopeData$templates$ : [];
82
+ }
83
+ function escapeStringForTemplate(value) {
84
+ return value.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
85
+ }
86
+ function isMathMLTemplate(template) {
87
+ return /^<(math|annotation|annotation-xml|maction|merror|mfrac|mi|mmultiscripts|mn|mo|mover|mpadded|mphantom|mprescripts|mroot|mrow|ms|mspace|msqrt|mstyle|msub|msubsup|msup|mtable|mtd|mtext|mtr|munder|munderover|semantics|menclose|mfenced)(\s|>)/.test(template);
88
+ }
89
+ /**
90
+ * Generates `var tmpl$0 = template(...), tmpl$1 = template(...)` declarations
91
+ * and unshifts them to the top of the program.
92
+ */
93
+ function appendTemplates(path) {
94
+ const templates = getTemplates(path, "dom");
95
+ if (!templates.length) return;
96
+ const templateMethod = registerImportMethod(path, "template", getRendererConfig(path, "dom").moduleName);
97
+ const declarators = templates.map((template) => {
98
+ const html = template.templateWithClosingTags || template.template;
99
+ const tmpl = {
100
+ cooked: html,
101
+ raw: escapeStringForTemplate(html)
102
+ };
103
+ const shouldUseImportNode = Boolean(template.isCE || template.isImportNode);
104
+ const isMathML = isMathMLTemplate(html);
105
+ const args = [t.templateLiteral([t.templateElement(tmpl, true)], [])];
106
+ if (template.isSVG || shouldUseImportNode || isMathML) args.push(t.booleanLiteral(shouldUseImportNode), t.booleanLiteral(Boolean(template.isSVG)), t.booleanLiteral(isMathML));
107
+ return t.variableDeclarator(t.cloneNode(template.id), t.addComment(t.callExpression(t.cloneNode(templateMethod), args), "leading", "#__PURE__"));
108
+ });
109
+ path.node.body.unshift(t.variableDeclaration("var", declarators));
110
+ }
111
+ //#endregion
112
+ //#region packages/compiler/src/codegen/support/events.ts
113
+ /**
114
+ * Event registration and delegation.
115
+ *
116
+ * Tracks all event handlers encountered during JSX transform and generates
117
+ * a single delegateEvents call at the end of the program (if any events
118
+ * were found).
119
+ */
120
+ /**
121
+ * Registers an event name in the program scope.
122
+ * Events are deduplicated — registering the same event name multiple times
123
+ * only keeps it once.
124
+ */
125
+ function registerEvent(path, eventName) {
126
+ const scopeData = path.scope.getProgramParent().path.scope.data;
127
+ (scopeData.events || (scopeData.events = /* @__PURE__ */ new Set())).add(eventName);
128
+ }
129
+ /**
130
+ * Generates a delegateEvents(...) call at the end of the program body.
131
+ *
132
+ * This implements the event delegation pattern: instead of attaching individual
133
+ * addEventListener calls, we register event names with the runtime so it can
134
+ * attach a single delegated listener at the root.
135
+ */
136
+ function appendEvents(path) {
137
+ const events = path.scope.data.events;
138
+ if (!(events === null || events === void 0 ? void 0 : events.size)) return;
139
+ path.node.body.push(t.expressionStatement(t.callExpression(registerImportMethod(path, "delegateEvents", getRendererConfig(path, "dom").moduleName), [t.arrayExpression(Array.from(events).map((eventName) => t.stringLiteral(eventName)))])));
140
+ }
141
+ //#endregion
142
+ //#region packages/compiler/src/config/index.ts
143
+ const DEFAULT_OPTIONS = {
144
+ moduleName: DEFAULT_RENDERER_MODULE,
145
+ generate: "dom",
146
+ hydratable: false,
147
+ delegateEvents: true,
148
+ delegatedEvents: [],
149
+ builtIns: [],
150
+ wrapConditionals: true,
151
+ omitNestedClosingTags: false,
152
+ omitLastClosingTag: true,
153
+ omitQuotes: true,
154
+ contextToCustomElements: false,
155
+ staticMarker: "@once",
156
+ effectWrapper: "effect",
157
+ memoWrapper: "memo",
158
+ validate: true,
159
+ inlineStyles: true
160
+ };
161
+ /**
162
+ * Resolve the compiler options by merging the default options with the provided options.
163
+ * @param options - The compiler options to resolve.
164
+ * @returns The resolved compiler options.
165
+ */
166
+ function resolveConfig(options) {
167
+ return extend(DEFAULT_OPTIONS, options);
168
+ }
169
+ //#endregion
170
+ //#region packages/compiler/src/utils/constant.ts
171
+ const VoidElements = [
172
+ "area",
173
+ "base",
174
+ "br",
175
+ "col",
176
+ "embed",
177
+ "hr",
178
+ "img",
179
+ "input",
180
+ "keygen",
181
+ "link",
182
+ "menuitem",
183
+ "meta",
184
+ "param",
185
+ "source",
186
+ "track",
187
+ "wbr"
188
+ ];
189
+ //#endregion
190
+ //#region packages/compiler/src/utils/html.ts
191
+ function escapeHTML(value, attr = false) {
192
+ let result = value.replace(/&/g, "&amp;");
193
+ if (attr) return result.replace(/"/g, "&quot;").replace(/>/g, "&gt;");
194
+ return result.replace(/</g, "&lt;");
195
+ }
196
+ function trimJSXText(value) {
197
+ return value.replace(/\r\n?/g, "\n").split("\n").map((line) => line.trim()).filter(Boolean).join(" ");
198
+ }
199
+ const rawTextElements = new Set([
200
+ "script",
201
+ "style",
202
+ "textarea",
203
+ "title"
204
+ ]);
205
+ function isRawTextElement(tagName) {
206
+ return rawTextElements.has(tagName);
207
+ }
208
+ //#endregion
209
+ //#region packages/compiler/src/utils/metadata.ts
210
+ function setZeusMetadata(state, config) {
211
+ const metadata = state.file.metadata;
212
+ metadata.zeus = extend({}, metadata.zeus, { config });
213
+ return metadata.zeus;
214
+ }
215
+ //#endregion
216
+ //#region packages/compiler/src/program.ts
217
+ /**
218
+ * Program visitor — entry and exit point for the entire transform pass.
219
+ *
220
+ * - Program.enter: initializes file metadata
221
+ * - Program.exit: injects all collected codegen artifacts (templates, events, imports)
222
+ */
223
+ function enterProgram(config, path, state) {
224
+ setZeusMetadata(state, config);
225
+ }
226
+ function exitProgram(config, path, state) {
227
+ if (state.get("skip")) return;
228
+ appendTemplates(path);
229
+ appendEvents(path);
230
+ appendImportMethods(path);
231
+ }
232
+ function createProgramVisitor(config) {
233
+ return {
234
+ enter(path, state) {
235
+ enterProgram(config, path, state);
236
+ },
237
+ exit(path, state) {
238
+ exitProgram(config, path, state);
239
+ }
240
+ };
241
+ }
242
+ //#endregion
243
+ //#region packages/compiler/src/codegen/dom/emitBinding.ts
244
+ function emitBindings(node, context) {
245
+ const statements = [];
246
+ for (const attr of node.attrs) {
247
+ if (attr.kind === "AttrBinding") statements.push(emitAttrBinding(node, attr, context));
248
+ if (attr.kind === "EventBinding") statements.push(emitEventBinding(node, attr, context));
249
+ if (attr.kind === "PropBinding") statements.push(emitPropBinding(node, attr, context));
250
+ if (attr.kind === "RefBinding") statements.push(emitRefBinding(node, attr, context));
251
+ }
252
+ if (isRawTextElement(node.tagName) && hasRuntimeRawText$1(node.children)) {
253
+ statements.push(emitRawTextBinding(node, context));
254
+ return statements;
255
+ }
256
+ for (const child of node.children) statements.push(...emitChildBinding(child, context));
257
+ return statements;
258
+ }
259
+ function emitRawTextBinding(node, context) {
260
+ return t.expressionStatement(t.callExpression(context.importRuntime("bindTextContent"), [t.identifier(node.ref.name), t.arrowFunctionExpression([], emitRawTextValue(node.children))]));
261
+ }
262
+ function hasRuntimeRawText$1(children) {
263
+ return children.some((child) => {
264
+ if (child.kind === "Text") return false;
265
+ if (child.kind === "Fragment") return hasRuntimeRawText$1(child.children);
266
+ return true;
267
+ });
268
+ }
269
+ function emitRawTextValue(children) {
270
+ const values = children.flatMap((child) => {
271
+ switch (child.kind) {
272
+ case "Text": return [t.stringLiteral(child.value)];
273
+ case "DynamicText": return [child.expr];
274
+ case "Fragment": return [emitRawTextValue(child.children)];
275
+ default: return [];
276
+ }
277
+ });
278
+ if (values.length === 0) return t.stringLiteral("");
279
+ if (values.length === 1) return values[0];
280
+ return t.arrayExpression(values);
281
+ }
282
+ function emitChildBinding(node, context) {
283
+ switch (node.kind) {
284
+ case "DynamicText": return emitDynamicText(node, context);
285
+ case "Component": return emitComponentInsert(node, context);
286
+ case "Show": return emitMarkerMount(node, context, emitMountShow(node, context));
287
+ case "For": return emitMarkerMount(node, context, emitMountFor(node, context));
288
+ case "Slot": return emitMarkerInsert(node, context, emitSlot(node, context));
289
+ case "Element": return emitBindings(node, context);
290
+ case "Fragment": return node.children.flatMap((child) => emitChildBinding(child, context));
291
+ default: return [];
292
+ }
293
+ }
294
+ function emitAttrBinding(target, binding, context) {
295
+ const name = normalizeAttrName(binding.name);
296
+ if (name === "class") return t.expressionStatement(t.callExpression(context.importRuntime("bindClass"), [t.identifier(target.ref.name), t.arrowFunctionExpression([], binding.expr)]));
297
+ if (name === "style") return t.expressionStatement(t.callExpression(context.importRuntime("bindStyle"), [t.identifier(target.ref.name), t.arrowFunctionExpression([], binding.expr)]));
298
+ return t.expressionStatement(t.callExpression(context.importRuntime("bindAttr"), [
299
+ t.identifier(target.ref.name),
300
+ t.stringLiteral(name),
301
+ t.arrowFunctionExpression([], binding.expr)
302
+ ]));
303
+ }
304
+ function normalizeAttrName(name) {
305
+ return name === "className" ? "class" : name;
306
+ }
307
+ function emitEventBinding(target, binding, context) {
308
+ registerEvent(context.programPath, binding.eventName);
309
+ return t.expressionStatement(t.callExpression(context.importRuntime("bindEvent"), [
310
+ t.identifier(target.ref.name),
311
+ t.stringLiteral(binding.eventName),
312
+ normalizeEventHandler(binding.handler, context)
313
+ ]));
314
+ }
315
+ function normalizeEventHandler(handler, context) {
316
+ if (t.isMemberExpression(handler) || t.isOptionalMemberExpression(handler)) {
317
+ const event = context.uid("event$");
318
+ return t.arrowFunctionExpression([t.identifier(event.name)], t.optionalCallExpression(t.cloneNode(handler), [t.identifier(event.name)], true));
319
+ }
320
+ return handler;
321
+ }
322
+ function emitPropBinding(target, binding, context) {
323
+ return t.expressionStatement(t.callExpression(context.importRuntime("bindProp"), [
324
+ t.identifier(target.ref.name),
325
+ t.stringLiteral(binding.name),
326
+ t.arrowFunctionExpression([], binding.expr)
327
+ ]));
328
+ }
329
+ function emitRefBinding(target, binding, context) {
330
+ return t.expressionStatement(t.callExpression(context.importRuntime("bindRef"), [t.identifier(target.ref.name), binding.expr]));
331
+ }
332
+ function emitDynamicText(node, context) {
333
+ if (!node.domPath || node.domPath.kind !== "Marker") return [];
334
+ const textRef = context.uid("text$");
335
+ if (node.once) return [t.variableDeclaration("const", [t.variableDeclarator(textRef, t.callExpression(t.memberExpression(t.identifier("document"), t.identifier("createTextNode")), [t.callExpression(t.identifier("String"), [node.expr])]))]), t.expressionStatement(t.callExpression(context.importRuntime("insert"), [
336
+ t.identifier(node.domPath.parent.name),
337
+ textRef,
338
+ t.identifier(node.ref.name)
339
+ ]))];
340
+ return [
341
+ t.variableDeclaration("const", [t.variableDeclarator(textRef, t.callExpression(t.memberExpression(t.identifier("document"), t.identifier("createTextNode")), [t.stringLiteral("")]))]),
342
+ t.expressionStatement(t.callExpression(context.importRuntime("insert"), [
343
+ t.identifier(node.domPath.parent.name),
344
+ textRef,
345
+ t.identifier(node.ref.name)
346
+ ])),
347
+ t.expressionStatement(t.callExpression(context.importRuntime("bindText"), [textRef, t.arrowFunctionExpression([], node.expr)]))
348
+ ];
349
+ }
350
+ function emitComponentInsert(node, context) {
351
+ return emitMarkerInsert(node, context, emitComponent(node, context));
352
+ }
353
+ function emitMarkerInsert(node, context, value) {
354
+ if (!node.domPath || node.domPath.kind !== "Marker") return [];
355
+ return [t.expressionStatement(t.callExpression(context.importRuntime("insert"), [
356
+ t.identifier(node.domPath.parent.name),
357
+ value,
358
+ t.identifier(node.ref.name)
359
+ ]))];
360
+ }
361
+ function emitMarkerMount(node, context, mountCall) {
362
+ if (!node.domPath || node.domPath.kind !== "Marker") return [];
363
+ return [t.expressionStatement(mountCall)];
364
+ }
365
+ //#endregion
366
+ //#region packages/compiler/src/codegen/dom/emitDomPath.ts
367
+ function emitPhysicalDomPath(path) {
368
+ switch (path.kind) {
369
+ case "Root": throw new Error("Root path is emitted from template clone directly");
370
+ case "FirstChild": return t.memberExpression(t.identifier(path.parent.name), t.identifier("firstChild"));
371
+ case "NextSibling": return t.memberExpression(t.identifier(path.previous.name), t.identifier("nextSibling"));
372
+ case "ChildNode": return t.memberExpression(t.memberExpression(t.identifier(path.parent.name), t.identifier("childNodes")), t.numericLiteral(path.index), true);
373
+ }
374
+ }
375
+ //#endregion
376
+ //#region packages/compiler/src/passes/collectTemplates.ts
377
+ function collectTemplates(node, context) {
378
+ if (node.kind === "Element") {
379
+ context.registerTemplate(renderTemplateHTML(node), node.flags.isSVG);
380
+ return;
381
+ }
382
+ if (node.kind === "Fragment") for (const child of node.children) {
383
+ if (child.kind !== "Element") continue;
384
+ context.registerTemplate(renderTemplateHTML(child), child.flags.isSVG);
385
+ }
386
+ }
387
+ function normalizeStaticAttrName(name) {
388
+ return name === "className" ? "class" : name;
389
+ }
390
+ function renderTemplateHTML(node) {
391
+ const attrs = node.attrs.filter((attr) => attr.kind === "StaticAttribute").map((attr) => {
392
+ if (attr.kind !== "StaticAttribute") return "";
393
+ const name = normalizeStaticAttrName(attr.name);
394
+ if (attr.value === true) return ` ${name}`;
395
+ return ` ${name}="${escapeAttr(attr.value)}"`;
396
+ }).join("");
397
+ if (node.flags.isVoid) return `<${node.tagName}${attrs}>`;
398
+ if (isRawTextElement(node.tagName) && hasRuntimeRawText(node.children)) return `<${node.tagName}${attrs}></${node.tagName}>`;
399
+ return `<${node.tagName}${attrs}>${node.children.map(renderChildTemplate).join("")}</${node.tagName}>`;
400
+ }
401
+ function hasRuntimeRawText(children) {
402
+ return children.some((child) => {
403
+ if (child.kind === "Text") return false;
404
+ if (child.kind === "Fragment") return hasRuntimeRawText(child.children);
405
+ return true;
406
+ });
407
+ }
408
+ function renderChildTemplate(node) {
409
+ switch (node.kind) {
410
+ case "Element": return renderTemplateHTML(node);
411
+ case "Text": return node.value;
412
+ case "DynamicText":
413
+ case "Component":
414
+ case "Show":
415
+ case "For":
416
+ case "Slot": return "<!>";
417
+ case "Host": return node.children.map(renderChildTemplate).join("");
418
+ case "Fragment": return node.children.map(renderChildTemplate).join("");
419
+ }
420
+ }
421
+ function escapeAttr(value) {
422
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
423
+ }
424
+ //#endregion
425
+ //#region packages/compiler/src/codegen/dom/emitTemplate.ts
426
+ function emitTemplateClone(node, context) {
427
+ const html = renderTemplateHTML(node);
428
+ const template = context.registerTemplate(html, node.flags.isSVG);
429
+ const templateCall = t.callExpression(t.cloneNode(template.id), []);
430
+ return t.memberExpression(templateCall, t.identifier("firstChild"));
431
+ }
432
+ //#endregion
433
+ //#region packages/compiler/src/codegen/dom/emitElement.ts
434
+ function emitElement(node, context) {
435
+ if (!hasRuntimeWork(node)) return emitTemplateClone(node, context);
436
+ const statements = [
437
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(node.ref.name), emitTemplateClone(node, context))]),
438
+ ...emitDomRefDeclarations(node.children, context),
439
+ ...emitBindings(node, context),
440
+ t.returnStatement(t.identifier(node.ref.name))
441
+ ];
442
+ return t.callExpression(t.arrowFunctionExpression([], t.blockStatement(statements)), []);
443
+ }
444
+ function emitDomRefDeclarations(children, context) {
445
+ const statements = [];
446
+ const declared = /* @__PURE__ */ new Set();
447
+ const refNodeMap = collectRefNodeMap(children);
448
+ for (const child of children) collectRequiredDomRefDeclaration(child, statements, context, refNodeMap, declared);
449
+ return statements;
450
+ }
451
+ function collectRefNodeMap(children) {
452
+ const map = /* @__PURE__ */ new Map();
453
+ for (const child of children) collectRefNode(child, map);
454
+ return map;
455
+ }
456
+ function collectRefNode(node, map) {
457
+ switch (node.kind) {
458
+ case "Element":
459
+ map.set(node.ref.name, node);
460
+ for (const child of node.children) collectRefNode(child, map);
461
+ return;
462
+ case "DynamicText":
463
+ case "Component":
464
+ case "Show":
465
+ case "For":
466
+ case "Slot":
467
+ map.set(node.ref.name, node);
468
+ return;
469
+ case "Fragment":
470
+ for (const child of node.children) collectRefNode(child, map);
471
+ return;
472
+ case "Host":
473
+ for (const child of node.children) collectRefNode(child, map);
474
+ return;
475
+ default: return;
476
+ }
477
+ }
478
+ function collectRequiredDomRefDeclaration(node, statements, context, refNodeMap, declared) {
479
+ switch (node.kind) {
480
+ case "Element":
481
+ if (needsDomRefDeclaration(node)) emitDomRefDeclarationWithDeps(node, statements, context, refNodeMap, declared);
482
+ for (const child of node.children) collectRequiredDomRefDeclaration(child, statements, context, refNodeMap, declared);
483
+ return;
484
+ case "DynamicText":
485
+ case "Component":
486
+ case "Show":
487
+ case "For":
488
+ case "Slot":
489
+ emitDomRefDeclarationWithDeps(node, statements, context, refNodeMap, declared);
490
+ return;
491
+ case "Fragment":
492
+ for (const child of node.children) collectRequiredDomRefDeclaration(child, statements, context, refNodeMap, declared);
493
+ return;
494
+ case "Host":
495
+ for (const child of node.children) collectRequiredDomRefDeclaration(child, statements, context, refNodeMap, declared);
496
+ return;
497
+ default: return;
498
+ }
499
+ }
500
+ function emitDomRefDeclarationWithDeps(node, statements, context, refNodeMap, declared) {
501
+ if (declared.has(node.ref.name)) return;
502
+ if (!node.physicalDomPath) throw new Error(`${node.kind} physical DOM path is not assigned`);
503
+ emitPhysicalDomPathDependencies(node.physicalDomPath, statements, context, refNodeMap, declared);
504
+ statements.push(createDomRefDeclaration(node, context));
505
+ declared.add(node.ref.name);
506
+ }
507
+ function emitPhysicalDomPathDependencies(path, statements, context, refNodeMap, declared) {
508
+ switch (path.kind) {
509
+ case "Root": return;
510
+ case "FirstChild":
511
+ emitRefDependency(path.parent, statements, context, refNodeMap, declared);
512
+ return;
513
+ case "ChildNode":
514
+ emitRefDependency(path.parent, statements, context, refNodeMap, declared);
515
+ return;
516
+ case "NextSibling":
517
+ emitRefDependency(path.previous, statements, context, refNodeMap, declared);
518
+ return;
519
+ }
520
+ }
521
+ function emitRefDependency(ref, statements, context, refNodeMap, declared) {
522
+ const dep = refNodeMap.get(ref.name);
523
+ if (!dep) return;
524
+ emitDomRefDeclarationWithDeps(dep, statements, context, refNodeMap, declared);
525
+ }
526
+ function createDomRefDeclaration(node, _context) {
527
+ if (!node.physicalDomPath) throw new Error(`${node.kind} physical DOM path is not assigned`);
528
+ return t.variableDeclaration("const", [t.variableDeclarator(t.identifier(node.ref.name), emitPhysicalDomPath(node.physicalDomPath))]);
529
+ }
530
+ function needsDomRefDeclaration(node) {
531
+ if (!node.physicalDomPath) return false;
532
+ if (node.attrs.some((attr) => attr.kind === "AttrBinding" || attr.kind === "PropBinding" || attr.kind === "EventBinding" || attr.kind === "RefBinding")) return true;
533
+ return node.children.some((child) => {
534
+ switch (child.kind) {
535
+ case "DynamicText":
536
+ case "Component":
537
+ case "Show":
538
+ case "For":
539
+ case "Slot": return true;
540
+ case "Element": return needsDomRefDeclaration(child);
541
+ case "Fragment": return child.children.some((inner) => inner.kind === "Element" ? needsDomRefDeclaration(inner) : inner.kind !== "Text");
542
+ case "Host": return child.children.some((inner) => inner.kind === "Element" ? needsDomRefDeclaration(inner) : inner.kind !== "Text");
543
+ default: return false;
544
+ }
545
+ });
546
+ }
547
+ function hasRuntimeWork(node) {
548
+ return node.attrs.some((attr) => attr.kind === "AttrBinding" || attr.kind === "PropBinding" || attr.kind === "EventBinding" || attr.kind === "RefBinding") || node.children.some(hasChildRuntimeWork);
549
+ }
550
+ function hasChildRuntimeWork(node) {
551
+ switch (node.kind) {
552
+ case "DynamicText":
553
+ case "Component":
554
+ case "Show":
555
+ case "For":
556
+ case "Slot": return true;
557
+ case "Element": return hasRuntimeWork(node);
558
+ case "Fragment":
559
+ case "Host": return node.children.some(hasChildRuntimeWork);
560
+ default: return false;
561
+ }
562
+ }
563
+ //#endregion
564
+ //#region packages/compiler/src/codegen/dom/emitFragment.ts
565
+ function emitFragment(node, context) {
566
+ return t.arrayExpression(node.children.map((child) => emitDOM(child, context)));
567
+ }
568
+ //#endregion
569
+ //#region packages/compiler/src/codegen/dom/emitNodeExpression.ts
570
+ function emitNodeExpression(node, context) {
571
+ switch (node.kind) {
572
+ case "Text": return t.stringLiteral(node.value);
573
+ case "DynamicText": return node.expr;
574
+ case "Element": return emitElement(node, context);
575
+ case "Component": return emitComponent(node, context);
576
+ case "Fragment": return emitFragment(node, context);
577
+ case "Show": return emitShow(node, context);
578
+ case "For": return emitFor(node, context);
579
+ case "Host": return emitHost(node, context);
580
+ case "Slot": return emitSlot(node, context);
581
+ default: return t.nullLiteral();
582
+ }
583
+ }
584
+ //#endregion
585
+ //#region packages/compiler/src/codegen/dom/emitComponent.ts
586
+ function emitComponent(node, context) {
587
+ const props = t.objectExpression(node.props.map((prop) => emitComponentProp(prop, context)));
588
+ return t.callExpression(context.importRuntime("createComponent"), [node.callee, props]);
589
+ }
590
+ function emitComponentProp(prop, context) {
591
+ const key = createObjectKey(prop.name);
592
+ if (Array.isArray(prop.value)) return t.objectMethod("get", key, [], t.blockStatement([t.returnStatement(emitChildrenProp(prop.value, context))]));
593
+ if (isStaticPropValue(prop.value)) return t.objectProperty(key, prop.value);
594
+ return t.objectMethod("get", key, [], t.blockStatement([t.returnStatement(prop.value)]));
595
+ }
596
+ function emitChildrenProp(children, context) {
597
+ const nodes = children.map((child) => emitNodeExpression(child, context));
598
+ if (nodes.length === 1) return nodes[0];
599
+ return t.arrayExpression(nodes);
600
+ }
601
+ function isStaticPropValue(value) {
602
+ return t.isStringLiteral(value) || t.isNumericLiteral(value) || t.isBooleanLiteral(value) || t.isNullLiteral(value);
603
+ }
604
+ function createObjectKey(key) {
605
+ return t.isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);
606
+ }
607
+ //#endregion
608
+ //#region packages/compiler/src/codegen/dom/emitBuiltin.ts
609
+ function emitShow(node, context) {
610
+ const props = [t.objectProperty(t.identifier("when"), node.when), t.objectProperty(t.identifier("children"), t.arrowFunctionExpression([], emitChildrenProp(node.children, context)))];
611
+ if (node.fallback) props.push(t.objectProperty(t.identifier("fallback"), Array.isArray(node.fallback) ? t.arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : node.fallback));
612
+ return t.callExpression(context.importRuntime("createComponent"), [context.importRuntime("Show"), t.objectExpression(props)]);
613
+ }
614
+ function emitMountShow(node, context) {
615
+ const path = node.domPath;
616
+ if (!path || path.kind !== "Marker") throw new Error("Show DOM path is not assigned");
617
+ return t.callExpression(context.importRuntime("mountShow"), [
618
+ t.identifier(path.parent.name),
619
+ emitMarkerIdentifier(node),
620
+ t.arrowFunctionExpression([], node.when),
621
+ t.arrowFunctionExpression([], emitChildrenProp(node.children, context)),
622
+ node.fallback ? Array.isArray(node.fallback) ? t.arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : t.arrowFunctionExpression([], node.fallback) : t.identifier("undefined")
623
+ ]);
624
+ }
625
+ function emitFor(node, context) {
626
+ const params = [node.item];
627
+ if (node.index) params.push(node.index);
628
+ const props = [t.objectProperty(t.identifier("each"), node.each), t.objectProperty(t.identifier("children"), t.arrowFunctionExpression(params, emitChildrenProp(node.body, context)))];
629
+ if (node.by) props.push(t.objectProperty(t.identifier("by"), node.by));
630
+ return t.callExpression(context.importRuntime("createComponent"), [context.importRuntime("For"), t.objectExpression(props)]);
631
+ }
632
+ function emitMountFor(node, context) {
633
+ var _node$by;
634
+ const params = [node.item];
635
+ const path = node.domPath;
636
+ if (node.index) params.push(node.index);
637
+ if (!path || path.kind !== "Marker") throw new Error("For DOM path is not assigned");
638
+ return t.callExpression(context.importRuntime("mountFor"), [
639
+ t.identifier(path.parent.name),
640
+ emitMarkerIdentifier(node),
641
+ t.arrowFunctionExpression([], node.each),
642
+ (_node$by = node.by) !== null && _node$by !== void 0 ? _node$by : t.identifier("undefined"),
643
+ t.arrowFunctionExpression(params, emitChildrenProp(node.body, context))
644
+ ]);
645
+ }
646
+ function emitHost(node, context) {
647
+ return emitChildrenProp(node.children, context);
648
+ }
649
+ function emitSlot(node, context) {
650
+ return t.callExpression(context.importRuntime("createSlot"), [node.name ? t.stringLiteral(node.name) : t.identifier("undefined"), node.fallback.length > 0 ? t.arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : t.identifier("undefined")]);
651
+ }
652
+ function emitMarkerIdentifier(node) {
653
+ return t.identifier(node.ref.name);
654
+ }
655
+ //#endregion
656
+ //#region packages/compiler/src/codegen/dom/index.ts
657
+ function emitDOM(node, context) {
658
+ switch (node.kind) {
659
+ case "Element": return emitElement(node, context);
660
+ case "Fragment": return emitFragment(node, context);
661
+ case "Component": return emitComponent(node, context);
662
+ case "Show": return emitShow(node, context);
663
+ case "For": return emitFor(node, context);
664
+ case "Host": return emitHost(node, context);
665
+ case "Slot": return emitSlot(node, context);
666
+ case "DynamicText": return t.arrowFunctionExpression([], node.expr);
667
+ default: throw new Error(`Unsupported root IR node: ${node.kind}`);
668
+ }
669
+ }
670
+ //#endregion
671
+ //#region packages/compiler/src/context/CompilerContext.ts
672
+ var CompilerContext = class {
673
+ constructor(options, programPath) {
674
+ this.options = options;
675
+ this.programPath = programPath;
676
+ this.diagnostics = [];
677
+ }
678
+ runtimeModule() {
679
+ return this.options.moduleName || "@zeus-js/runtime-dom";
680
+ }
681
+ uid(name) {
682
+ return this.programPath.scope.generateUidIdentifier(name);
683
+ }
684
+ importRuntime(imported) {
685
+ const moduleName = this.runtimeModule();
686
+ const scopeData = this.programPath.scope.data;
687
+ const importMethods = scopeData.importMethods || (scopeData.importMethods = /* @__PURE__ */ new Map());
688
+ const key = `${moduleName}:${imported}`;
689
+ const cached = importMethods.get(key);
690
+ if (cached) return t.cloneNode(cached.local);
691
+ const local = this.uid(imported);
692
+ importMethods.set(key, {
693
+ moduleName,
694
+ imported,
695
+ local
696
+ });
697
+ return t.cloneNode(local);
698
+ }
699
+ registerTemplate(html, isSVG = false) {
700
+ const scopeData = this.programPath.scope.data;
701
+ const templateMap = scopeData.templateMap || (scopeData.templateMap = /* @__PURE__ */ new Map());
702
+ const templates = scopeData.templates || (scopeData.templates = []);
703
+ const cached = templateMap.get(html);
704
+ if (cached) return {
705
+ id: t.cloneNode(cached.id),
706
+ html,
707
+ isSVG: Boolean(cached.isSVG)
708
+ };
709
+ const id = this.uid("tmpl$");
710
+ templateMap.set(html, {
711
+ id,
712
+ template: html,
713
+ templateWithClosingTags: html,
714
+ renderer: "dom",
715
+ isSVG,
716
+ isCE: html.includes("-"),
717
+ isImportNode: /^<(img|iframe)(\s|>)/.test(html)
718
+ });
719
+ templates.push(templateMap.get(html));
720
+ return {
721
+ id: t.cloneNode(id),
722
+ html,
723
+ isSVG
724
+ };
725
+ }
726
+ report(diagnostic) {
727
+ this.diagnostics.push(diagnostic);
728
+ }
729
+ };
730
+ function getCompilerContext(path, options) {
731
+ return new CompilerContext(options, path.scope.getProgramParent().path);
732
+ }
733
+ //#endregion
734
+ //#region packages/compiler/src/diagnostics/codes.ts
735
+ const CompilerErrorCode = {
736
+ UNSUPPORTED_SPREAD_ATTRIBUTE: "ZEUS_UNSUPPORTED_SPREAD_ATTRIBUTE",
737
+ UNSUPPORTED_SPREAD_CHILD: "ZEUS_UNSUPPORTED_SPREAD_CHILD",
738
+ UNSUPPORTED_FRAGMENT: "ZEUS_UNSUPPORTED_FRAGMENT",
739
+ UNSUPPORTED_FRAGMENT_CHILD: "ZEUS_UNSUPPORTED_FRAGMENT_CHILD",
740
+ UNSUPPORTED_COMPONENT_PROP: "ZEUS_UNSUPPORTED_COMPONENT_PROP",
741
+ EMPTY_EXPRESSION: "ZEUS_EMPTY_EXPRESSION",
742
+ INVALID_TRANSFORM_RESULT: "ZEUS_INVALID_TRANSFORM_RESULT",
743
+ UNSUPPORTED_NODE: "ZEUS_UNSUPPORTED_NODE",
744
+ INVALID_BUILTIN_USAGE: "ZEUS_INVALID_BUILTIN_USAGE",
745
+ INVALID_REF_USAGE: "ZEUS_INVALID_REF_USAGE"
746
+ };
747
+ //#endregion
748
+ //#region packages/compiler/src/diagnostics/CompilerError.ts
749
+ var CompilerError = class extends Error {
750
+ constructor(options) {
751
+ var _options$path;
752
+ const loc = (_options$path = options.path) === null || _options$path === void 0 || (_options$path = _options$path.node.loc) === null || _options$path === void 0 ? void 0 : _options$path.start;
753
+ const location = loc ? ` (${loc.line}:${loc.column})` : "";
754
+ const hint = options.hint ? `\nHint: ${options.hint}` : "";
755
+ super(`[${options.code}] ${options.message}${location}${hint}`);
756
+ this.name = "ZeusCompilerError";
757
+ this.code = options.code;
758
+ this.hint = options.hint;
759
+ }
760
+ };
761
+ //#endregion
762
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
763
+ function _typeof(o) {
764
+ "@babel/helpers - typeof";
765
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
766
+ return typeof o;
767
+ } : function(o) {
768
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
769
+ }, _typeof(o);
770
+ }
771
+ //#endregion
772
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
773
+ function toPrimitive(t, r) {
774
+ if ("object" != _typeof(t) || !t) return t;
775
+ var e = t[Symbol.toPrimitive];
776
+ if (void 0 !== e) {
777
+ var i = e.call(t, r || "default");
778
+ if ("object" != _typeof(i)) return i;
779
+ throw new TypeError("@@toPrimitive must return a primitive value.");
780
+ }
781
+ return ("string" === r ? String : Number)(t);
782
+ }
783
+ //#endregion
784
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
785
+ function toPropertyKey(t) {
786
+ var i = toPrimitive(t, "string");
787
+ return "symbol" == _typeof(i) ? i : i + "";
788
+ }
789
+ //#endregion
790
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
791
+ function _defineProperty(e, r, t) {
792
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
793
+ value: t,
794
+ enumerable: !0,
795
+ configurable: !0,
796
+ writable: !0
797
+ }) : e[r] = t, e;
798
+ }
799
+ //#endregion
800
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
801
+ function ownKeys(e, r) {
802
+ var t = Object.keys(e);
803
+ if (Object.getOwnPropertySymbols) {
804
+ var o = Object.getOwnPropertySymbols(e);
805
+ r && (o = o.filter(function(r) {
806
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
807
+ })), t.push.apply(t, o);
808
+ }
809
+ return t;
810
+ }
811
+ function _objectSpread2(e) {
812
+ for (var r = 1; r < arguments.length; r++) {
813
+ var t = null != arguments[r] ? arguments[r] : {};
814
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
815
+ _defineProperty(e, r, t[r]);
816
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
817
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
818
+ });
819
+ }
820
+ return e;
821
+ }
822
+ //#endregion
823
+ //#region packages/compiler/src/ir/semanticBuilders.ts
824
+ let nextId = 0;
825
+ function id() {
826
+ return nextId++;
827
+ }
828
+ function ref(name) {
829
+ return { name };
830
+ }
831
+ function elementIR(input) {
832
+ var _input$attrs, _input$children;
833
+ return {
834
+ id: id(),
835
+ kind: "Element",
836
+ ref: input.ref,
837
+ tagName: input.tagName,
838
+ attrs: (_input$attrs = input.attrs) !== null && _input$attrs !== void 0 ? _input$attrs : [],
839
+ children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : [],
840
+ flags: _objectSpread2({
841
+ isSVG: false,
842
+ isVoid: false,
843
+ isCustomElement: input.tagName.includes("-")
844
+ }, input.flags)
845
+ };
846
+ }
847
+ function textIR(value) {
848
+ return {
849
+ id: id(),
850
+ kind: "Text",
851
+ value
852
+ };
853
+ }
854
+ function dynamicTextIR(expr, nodeRef, once = false) {
855
+ return {
856
+ id: id(),
857
+ kind: "DynamicText",
858
+ expr,
859
+ ref: nodeRef,
860
+ once
861
+ };
862
+ }
863
+ function fragmentIR(children) {
864
+ return {
865
+ id: id(),
866
+ kind: "Fragment",
867
+ children
868
+ };
869
+ }
870
+ function staticAttrIR(name, value) {
871
+ return {
872
+ id: id(),
873
+ kind: "StaticAttribute",
874
+ name,
875
+ value
876
+ };
877
+ }
878
+ function attrBindingIR(name, expr) {
879
+ return {
880
+ id: id(),
881
+ kind: "AttrBinding",
882
+ name,
883
+ expr
884
+ };
885
+ }
886
+ function propBindingIR(name, expr) {
887
+ return {
888
+ id: id(),
889
+ kind: "PropBinding",
890
+ name,
891
+ expr
892
+ };
893
+ }
894
+ function eventBindingIR(eventName, handler) {
895
+ return {
896
+ id: id(),
897
+ kind: "EventBinding",
898
+ eventName,
899
+ handler
900
+ };
901
+ }
902
+ function refBindingIR(expr) {
903
+ return {
904
+ id: id(),
905
+ kind: "RefBinding",
906
+ expr
907
+ };
908
+ }
909
+ function componentIR(input) {
910
+ return {
911
+ id: id(),
912
+ kind: "Component",
913
+ ref: input.ref,
914
+ callee: input.callee,
915
+ props: input.props
916
+ };
917
+ }
918
+ function showIR(input) {
919
+ return {
920
+ id: id(),
921
+ kind: "Show",
922
+ ref: input.ref,
923
+ when: input.when,
924
+ children: input.children,
925
+ fallback: input.fallback
926
+ };
927
+ }
928
+ function forIR(input) {
929
+ return {
930
+ id: id(),
931
+ kind: "For",
932
+ ref: input.ref,
933
+ each: input.each,
934
+ by: input.by,
935
+ item: input.item,
936
+ index: input.index,
937
+ body: input.body
938
+ };
939
+ }
940
+ function hostIR(children) {
941
+ return {
942
+ id: id(),
943
+ kind: "Host",
944
+ children
945
+ };
946
+ }
947
+ function slotIR(input) {
948
+ var _input$fallback;
949
+ return {
950
+ id: id(),
951
+ kind: "Slot",
952
+ ref: input.ref,
953
+ name: input.name,
954
+ fallback: (_input$fallback = input.fallback) !== null && _input$fallback !== void 0 ? _input$fallback : []
955
+ };
956
+ }
957
+ //#endregion
958
+ //#region packages/compiler/src/parse/jsx.ts
959
+ /**
960
+ * JSX AST parsing utilities.
961
+ *
962
+ * Low-level helpers for extracting and interpreting information from Babel's
963
+ * JSX AST nodes — tag names, attribute names, and path type guards.
964
+ * These do NOT produce IR or Babel AST; they only read the JSX tree.
965
+ */
966
+ function jsxElementNameToString(node) {
967
+ if (t.isJSXMemberExpression(node)) return `${jsxElementNameToString(node.object)}.${node.property.name}`;
968
+ if (t.isJSXIdentifier(node) || t.isIdentifier(node)) return node.name;
969
+ return `${node.namespace.name}:${node.name.name}`;
970
+ }
971
+ function getTagName(node) {
972
+ return jsxElementNameToString(node.openingElement.name);
973
+ }
974
+ function getJSXAttrName(name) {
975
+ if (t.isJSXNamespacedName(name)) return `${name.namespace.name}:${name.name.name}`;
976
+ return name.name;
977
+ }
978
+ function isComponentTag(tagName) {
979
+ return /^[A-Z]/.test(tagName) || tagName.includes(".");
980
+ }
981
+ function toEventName(name) {
982
+ return name.slice(2).toLowerCase();
983
+ }
984
+ //#endregion
985
+ //#region packages/compiler/src/lower/lowerAttribute.ts
986
+ function lowerAttribute(path, _context) {
987
+ if (path.isJSXSpreadAttribute() || t.isJSXSpreadAttribute(path.node)) throw new CompilerError({
988
+ code: CompilerErrorCode.UNSUPPORTED_SPREAD_ATTRIBUTE,
989
+ message: "Spread attributes are not supported in Zeus MVP.",
990
+ path,
991
+ hint: "Use explicit attributes instead, for example <div id={id} />."
992
+ });
993
+ const node = path.node;
994
+ const name = getJSXAttrName(node.name);
995
+ const value = node.value;
996
+ if (!value) {
997
+ if (name === "ref") throw new CompilerError({
998
+ code: CompilerErrorCode.EMPTY_EXPRESSION,
999
+ message: "ref attribute requires an expression.",
1000
+ path,
1001
+ hint: "Use <div ref={target} /> instead."
1002
+ });
1003
+ return staticAttrIR(name, true);
1004
+ }
1005
+ if (t.isStringLiteral(value)) {
1006
+ if (name === "ref") throw new CompilerError({
1007
+ code: CompilerErrorCode.INVALID_REF_USAGE,
1008
+ message: "String refs are not supported in Zeus.",
1009
+ path,
1010
+ hint: "Use a state holder or callback ref: <div ref={el} />."
1011
+ });
1012
+ return staticAttrIR(name, value.value);
1013
+ }
1014
+ if (t.isJSXExpressionContainer(value)) {
1015
+ const expr = value.expression;
1016
+ if (t.isJSXEmptyExpression(expr)) throw new CompilerError({
1017
+ code: CompilerErrorCode.EMPTY_EXPRESSION,
1018
+ message: `Attribute "${name}" expression cannot be empty.`,
1019
+ path
1020
+ });
1021
+ if (name === "ref") return refBindingIR(expr);
1022
+ if (name.startsWith("on") && name.length > 2) return eventBindingIR(toEventName(name), expr);
1023
+ if (name.startsWith("prop:")) return propBindingIR(name.slice(5), expr);
1024
+ return attrBindingIR(name, expr);
1025
+ }
1026
+ return null;
1027
+ }
1028
+ //#endregion
1029
+ //#region packages/compiler/src/lower/lowerChildren.ts
1030
+ function lowerChildren(children, context) {
1031
+ const result = [];
1032
+ for (const child of children) {
1033
+ if (child.isJSXText()) {
1034
+ const text = trimJSXText(child.node.value);
1035
+ if (text) result.push(textIR(escapeHTML(text)));
1036
+ continue;
1037
+ }
1038
+ if (child.isJSXExpressionContainer()) {
1039
+ const expr = child.node.expression;
1040
+ if (t.isJSXEmptyExpression(expr)) continue;
1041
+ if (t.isExpression(expr)) result.push(dynamicTextIR(expr, ref(context.uid("anchor$").name)));
1042
+ continue;
1043
+ }
1044
+ if (child.isJSXElement() || child.isJSXFragment()) {
1045
+ result.push(lowerJSX(child, context));
1046
+ continue;
1047
+ }
1048
+ }
1049
+ return result;
1050
+ }
1051
+ //#endregion
1052
+ //#region packages/compiler/src/lower/lowerBuiltin.ts
1053
+ function isBuiltinTag(tagName) {
1054
+ return tagName === "Show" || tagName === "For" || tagName === "Host" || tagName === "Slot";
1055
+ }
1056
+ function lowerBuiltin(path, context) {
1057
+ const tagName = path.node.openingElement.name;
1058
+ if (!t.isJSXIdentifier(tagName)) throw new CompilerError({
1059
+ code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
1060
+ message: "Built-in JSX nodes do not support member expressions.",
1061
+ path
1062
+ });
1063
+ switch (tagName.name) {
1064
+ case "Show": return lowerShow(path, context);
1065
+ case "For": return lowerFor(path, context);
1066
+ case "Host": return hostIR(lowerChildren(path.get("children"), context));
1067
+ case "Slot": return lowerSlot(path, context);
1068
+ default: throw new CompilerError({
1069
+ code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
1070
+ message: `Unsupported built-in <${tagName.name}>.`,
1071
+ path
1072
+ });
1073
+ }
1074
+ }
1075
+ function lowerShow(path, context) {
1076
+ const when = requiredExpressionAttr(path, "when");
1077
+ const fallback = optionalShowFallbackAttr(path, context);
1078
+ return showIR({
1079
+ ref: ref(context.uid("show$").name),
1080
+ when,
1081
+ fallback,
1082
+ children: lowerChildren(path.get("children"), context)
1083
+ });
1084
+ }
1085
+ function optionalShowFallbackAttr(path, context) {
1086
+ const attr = path.get("openingElement").get("attributes").find((attrPath) => {
1087
+ if (!attrPath.isJSXAttribute()) return false;
1088
+ return getJSXAttrName(attrPath.node.name) === "fallback";
1089
+ });
1090
+ if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
1091
+ const value = attr.get("value");
1092
+ if (!value.node) return t.booleanLiteral(true);
1093
+ if (value.isStringLiteral()) return value.node;
1094
+ if (!value.isJSXExpressionContainer()) return void 0;
1095
+ const expression = value.get("expression");
1096
+ if (expression.isJSXEmptyExpression()) return void 0;
1097
+ if (expression.isJSXElement() || expression.isJSXFragment()) return [lowerJSX(expression, context)];
1098
+ if (expression.isExpression()) return expression.node;
1099
+ }
1100
+ function lowerFor(path, context) {
1101
+ var _getParamIdentifier;
1102
+ const each = requiredExpressionAttr(path, "each");
1103
+ const by = optionalExpressionAttr(path, "by");
1104
+ const render = getOnlyRenderFunction(path);
1105
+ const item = (_getParamIdentifier = getParamIdentifier(render, 0)) !== null && _getParamIdentifier !== void 0 ? _getParamIdentifier : t.identifier("item");
1106
+ const index = getParamIdentifier(render, 1);
1107
+ const bodyPath = render.get("body");
1108
+ const body = [];
1109
+ if (bodyPath.isJSXElement() || bodyPath.isJSXFragment()) body.push(lowerJSX(bodyPath, context));
1110
+ else if (bodyPath.isExpression()) body.push(dynamicTextIR(bodyPath.node, ref(context.uid("anchor$").name)));
1111
+ return forIR({
1112
+ ref: ref(context.uid("for$").name),
1113
+ each,
1114
+ by,
1115
+ item,
1116
+ index,
1117
+ body
1118
+ });
1119
+ }
1120
+ function lowerSlot(path, context) {
1121
+ const name = optionalStringAttr(path, "name");
1122
+ return slotIR({
1123
+ ref: ref(context.uid("slot$").name),
1124
+ name,
1125
+ fallback: lowerChildren(path.get("children"), context)
1126
+ });
1127
+ }
1128
+ function requiredExpressionAttr(path, name) {
1129
+ const value = optionalExpressionAttr(path, name);
1130
+ if (!value || Array.isArray(value)) throw new CompilerError({
1131
+ code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
1132
+ message: `<${getBuiltinName(path)}> requires "${name}".`,
1133
+ path
1134
+ });
1135
+ return value;
1136
+ }
1137
+ function optionalExpressionAttr(path, name) {
1138
+ const attr = path.get("openingElement").get("attributes").find((attrPath) => {
1139
+ if (!attrPath.isJSXAttribute()) return false;
1140
+ return getJSXAttrName(attrPath.node.name) === name;
1141
+ });
1142
+ if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
1143
+ const value = attr.node.value;
1144
+ if (!value) return t.booleanLiteral(true);
1145
+ if (t.isStringLiteral(value)) return value;
1146
+ if (t.isJSXExpressionContainer(value) && !t.isJSXEmptyExpression(value.expression)) return value.expression;
1147
+ }
1148
+ function optionalStringAttr(path, name) {
1149
+ const attr = path.get("openingElement").get("attributes").find((attrPath) => {
1150
+ if (!attrPath.isJSXAttribute()) return false;
1151
+ return getJSXAttrName(attrPath.node.name) === name;
1152
+ });
1153
+ if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
1154
+ const value = attr.node.value;
1155
+ if (!value) return "";
1156
+ if (t.isStringLiteral(value)) return value.value;
1157
+ }
1158
+ function getOnlyRenderFunction(path) {
1159
+ const expressions = path.get("children").filter((child) => child.isJSXExpressionContainer()).map((child) => child.get("expression")).filter((expression) => expression.isArrowFunctionExpression() || expression.isFunctionExpression());
1160
+ if (expressions.length !== 1) throw new CompilerError({
1161
+ code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
1162
+ message: "<For> requires exactly one render function child.",
1163
+ path
1164
+ });
1165
+ return expressions[0];
1166
+ }
1167
+ function getParamIdentifier(path, index, fallback) {
1168
+ const param = path.node.params[index];
1169
+ if (t.isIdentifier(param)) return param;
1170
+ if (fallback) return t.identifier(fallback);
1171
+ }
1172
+ function getBuiltinName(path) {
1173
+ const name = path.node.openingElement.name;
1174
+ return t.isJSXIdentifier(name) ? name.name : "Builtin";
1175
+ }
1176
+ //#endregion
1177
+ //#region packages/compiler/src/lower/lowerComponent.ts
1178
+ function lowerComponent(path, context) {
1179
+ const tag = convertComponentIdentifier(path.node.openingElement.name);
1180
+ const props = [];
1181
+ for (const attr of path.get("openingElement").get("attributes")) {
1182
+ const node = attr.node;
1183
+ if (t.isJSXSpreadAttribute(node)) throw new CompilerError({
1184
+ code: CompilerErrorCode.UNSUPPORTED_COMPONENT_PROP,
1185
+ message: "Spread props are not supported in Zeus MVP.",
1186
+ path: attr
1187
+ });
1188
+ const name = getJSXAttrName(node.name);
1189
+ if (!node.value) {
1190
+ props.push({
1191
+ name,
1192
+ value: t.booleanLiteral(true)
1193
+ });
1194
+ continue;
1195
+ }
1196
+ if (t.isStringLiteral(node.value)) {
1197
+ props.push({
1198
+ name,
1199
+ value: node.value
1200
+ });
1201
+ continue;
1202
+ }
1203
+ if (t.isJSXExpressionContainer(node.value)) {
1204
+ if (t.isJSXEmptyExpression(node.value.expression)) throw new CompilerError({
1205
+ code: CompilerErrorCode.EMPTY_EXPRESSION,
1206
+ message: `Component prop "${name}" expression cannot be empty.`,
1207
+ path: attr
1208
+ });
1209
+ props.push({
1210
+ name,
1211
+ value: node.value.expression
1212
+ });
1213
+ }
1214
+ }
1215
+ const children = lowerChildren(path.get("children"), context);
1216
+ if (children.length > 0) props.push({
1217
+ name: "children",
1218
+ value: children
1219
+ });
1220
+ return componentIR({
1221
+ ref: ref(context.uid("cmp$").name),
1222
+ callee: tag,
1223
+ props
1224
+ });
1225
+ }
1226
+ function convertComponentIdentifier(node) {
1227
+ if (t.isJSXIdentifier(node)) {
1228
+ if (node.name === "this") return t.thisExpression();
1229
+ if (t.isValidIdentifier(node.name)) return t.identifier(node.name);
1230
+ return t.stringLiteral(node.name);
1231
+ }
1232
+ if (t.isJSXMemberExpression(node)) {
1233
+ const object = convertComponentIdentifier(node.object);
1234
+ const property = convertComponentIdentifier(node.property);
1235
+ return t.memberExpression(object, property, t.isStringLiteral(property));
1236
+ }
1237
+ if (t.isJSXNamespacedName(node)) return t.stringLiteral(`${node.namespace.name}:${node.name.name}`);
1238
+ return node;
1239
+ }
1240
+ //#endregion
1241
+ //#region packages/compiler/src/lower/lowerElement.ts
1242
+ function lowerElement(path, context) {
1243
+ const tagName = getTagName(path.node);
1244
+ if (isBuiltinTag(tagName)) return lowerBuiltin(path, context);
1245
+ if (isComponentTag(tagName)) return lowerComponent(path, context);
1246
+ const attrs = path.get("openingElement").get("attributes").map((attr) => lowerAttribute(attr, context)).filter(Boolean);
1247
+ return elementIR({
1248
+ ref: ref(context.uid("el$").name),
1249
+ tagName,
1250
+ attrs,
1251
+ children: VoidElements.includes(tagName) ? [] : lowerChildren(path.get("children"), context),
1252
+ flags: {
1253
+ isVoid: VoidElements.includes(tagName),
1254
+ isCustomElement: tagName.includes("-")
1255
+ }
1256
+ });
1257
+ }
1258
+ //#endregion
1259
+ //#region packages/compiler/src/lower/lowerFragment.ts
1260
+ function lowerFragment(path, context) {
1261
+ return fragmentIR(lowerChildren(path.get("children"), context));
1262
+ }
1263
+ //#endregion
1264
+ //#region packages/compiler/src/lower/lowerJSX.ts
1265
+ function lowerJSX(path, context) {
1266
+ if (path.isJSXElement()) return lowerElement(path, context);
1267
+ if (path.isJSXFragment()) return lowerFragment(path, context);
1268
+ throw new Error("Unsupported JSX node");
1269
+ }
1270
+ //#endregion
1271
+ //#region packages/compiler/src/passes/normalizeChildren.ts
1272
+ function normalizeChildren(node) {
1273
+ visit$2(node);
1274
+ return node;
1275
+ }
1276
+ function visit$2(node) {
1277
+ switch (node.kind) {
1278
+ case "Element":
1279
+ case "Fragment":
1280
+ case "Host":
1281
+ node.children = node.children.filter((child) => {
1282
+ if (child.kind === "Text") return child.value.length > 0;
1283
+ return true;
1284
+ });
1285
+ for (const child of node.children) visit$2(child);
1286
+ return;
1287
+ case "Component":
1288
+ for (const prop of node.props) {
1289
+ if (!Array.isArray(prop.value)) continue;
1290
+ prop.value = prop.value.filter((child) => {
1291
+ if (child.kind === "Text") return child.value.length > 0;
1292
+ return true;
1293
+ });
1294
+ for (const child of prop.value) visit$2(child);
1295
+ }
1296
+ return;
1297
+ case "Slot":
1298
+ node.fallback = node.fallback.filter((child) => {
1299
+ if (child.kind === "Text") return child.value.length > 0;
1300
+ return true;
1301
+ });
1302
+ for (const child of node.fallback) visit$2(child);
1303
+ return;
1304
+ case "Show":
1305
+ for (const child of node.children) visit$2(child);
1306
+ if (Array.isArray(node.fallback)) {
1307
+ node.fallback = node.fallback.filter((child) => {
1308
+ if (child.kind === "Text") return child.value.length > 0;
1309
+ return true;
1310
+ });
1311
+ for (const child of node.fallback) visit$2(child);
1312
+ }
1313
+ return;
1314
+ case "For":
1315
+ for (const child of node.body) visit$2(child);
1316
+ return;
1317
+ case "Text":
1318
+ case "DynamicText": return;
1319
+ }
1320
+ }
1321
+ //#endregion
1322
+ //#region packages/compiler/src/passes/assignDomPaths.ts
1323
+ function assignDomPaths(node) {
1324
+ visitNode$1(node);
1325
+ return node;
1326
+ }
1327
+ function visitNode$1(node, parent) {
1328
+ switch (node.kind) {
1329
+ case "Element":
1330
+ assignElementPath(node, parent);
1331
+ assignChildPaths(node);
1332
+ return;
1333
+ case "Fragment":
1334
+ for (const child of node.children) visitNode$1(child, parent);
1335
+ return;
1336
+ case "Component":
1337
+ for (const prop of node.props) {
1338
+ if (!Array.isArray(prop.value)) continue;
1339
+ for (const child of prop.value) visitNode$1(child);
1340
+ }
1341
+ return;
1342
+ case "Show":
1343
+ for (const child of node.children) visitNode$1(child);
1344
+ if (Array.isArray(node.fallback)) for (const child of node.fallback) visitNode$1(child);
1345
+ return;
1346
+ case "For":
1347
+ for (const child of node.body) visitNode$1(child);
1348
+ return;
1349
+ case "Host":
1350
+ for (const child of node.children) visitNode$1(child, parent);
1351
+ return;
1352
+ case "Slot":
1353
+ for (const child of node.fallback) visitNode$1(child);
1354
+ return;
1355
+ case "Text":
1356
+ case "DynamicText": return;
1357
+ }
1358
+ }
1359
+ function assignElementPath(node, parent) {
1360
+ if (!parent) {
1361
+ node.domPath = { kind: "Root" };
1362
+ return;
1363
+ }
1364
+ const templateChildren = parent.children.filter(isTemplateChild);
1365
+ const index = templateChildren.indexOf(node);
1366
+ if (index === -1) return;
1367
+ if (index === 0) {
1368
+ node.domPath = {
1369
+ kind: "FirstChild",
1370
+ parent: parent.ref
1371
+ };
1372
+ return;
1373
+ }
1374
+ const previous = templateChildren[index - 1];
1375
+ if (previous.kind === "Element") {
1376
+ node.domPath = {
1377
+ kind: "NextSibling",
1378
+ previous: previous.ref
1379
+ };
1380
+ return;
1381
+ }
1382
+ node.domPath = {
1383
+ kind: "Child",
1384
+ parent: parent.ref,
1385
+ index
1386
+ };
1387
+ }
1388
+ function assignChildPaths(parent) {
1389
+ let markerIndex = 0;
1390
+ for (const child of parent.children) {
1391
+ if (isMarkerTemplateNode(child)) {
1392
+ assignMarkerPath(child, parent.ref, markerIndex++);
1393
+ visitNode$1(child);
1394
+ continue;
1395
+ }
1396
+ visitNode$1(child, parent);
1397
+ }
1398
+ }
1399
+ function assignMarkerPath(node, parent, index) {
1400
+ node.domPath = {
1401
+ kind: "Marker",
1402
+ parent,
1403
+ index
1404
+ };
1405
+ }
1406
+ function isTemplateChild(node) {
1407
+ return node.kind === "Element" || node.kind === "DynamicText" || node.kind === "Component" || node.kind === "Show" || node.kind === "For" || node.kind === "Slot";
1408
+ }
1409
+ function isMarkerTemplateNode(node) {
1410
+ return node.kind === "DynamicText" || node.kind === "Component" || node.kind === "Show" || node.kind === "For" || node.kind === "Slot";
1411
+ }
1412
+ //#endregion
1413
+ //#region packages/compiler/src/passes/assignPhysicalDomPaths.ts
1414
+ function assignPhysicalDomPaths(node) {
1415
+ visitNode(node);
1416
+ return node;
1417
+ }
1418
+ function visitNode(node, parent) {
1419
+ switch (node.kind) {
1420
+ case "Element":
1421
+ assignElementPhysicalPath(node, parent);
1422
+ assignChildrenPhysicalPaths(node);
1423
+ return;
1424
+ case "Fragment":
1425
+ for (const child of node.children) visitNode(child, parent);
1426
+ return;
1427
+ case "Host":
1428
+ for (const child of node.children) visitNode(child, parent);
1429
+ return;
1430
+ case "Show":
1431
+ for (const child of node.children) visitNode(child);
1432
+ if (Array.isArray(node.fallback)) for (const child of node.fallback) visitNode(child);
1433
+ return;
1434
+ case "For":
1435
+ for (const child of node.body) visitNode(child);
1436
+ return;
1437
+ case "Slot":
1438
+ for (const child of node.fallback) visitNode(child);
1439
+ return;
1440
+ case "Component":
1441
+ for (const prop of node.props) {
1442
+ if (!Array.isArray(prop.value)) continue;
1443
+ for (const child of prop.value) visitNode(child);
1444
+ }
1445
+ return;
1446
+ case "Text":
1447
+ case "DynamicText": return;
1448
+ }
1449
+ }
1450
+ function assignElementPhysicalPath(node, parent) {
1451
+ if (!parent) {
1452
+ node.physicalDomPath = { kind: "Root" };
1453
+ return;
1454
+ }
1455
+ const physicalChildren = flattenPhysicalChildren(parent.children);
1456
+ const index = physicalChildren.indexOf(node);
1457
+ if (index < 0) return;
1458
+ node.physicalDomPath = createPhysicalPath(parent.ref, physicalChildren, index);
1459
+ }
1460
+ function assignChildrenPhysicalPaths(parent) {
1461
+ const physicalChildren = flattenPhysicalChildren(parent.children);
1462
+ for (let index = 0; index < physicalChildren.length; index++) {
1463
+ const child = physicalChildren[index];
1464
+ if (child.kind === "TextPlaceholder") continue;
1465
+ child.physicalDomPath = createPhysicalPath(parent.ref, physicalChildren, index);
1466
+ }
1467
+ for (const child of parent.children) visitNode(child, parent);
1468
+ }
1469
+ function createPhysicalPath(parent, children, index) {
1470
+ if (index === 0) return {
1471
+ kind: "FirstChild",
1472
+ parent
1473
+ };
1474
+ const previous = findPreviousRefNode(children, index);
1475
+ if (previous) return {
1476
+ kind: "NextSibling",
1477
+ previous: previous.ref
1478
+ };
1479
+ return {
1480
+ kind: "ChildNode",
1481
+ parent,
1482
+ index
1483
+ };
1484
+ }
1485
+ function findPreviousRefNode(children, index) {
1486
+ for (let i = index - 1; i >= 0; i--) {
1487
+ const node = children[i];
1488
+ if (node.kind === "TextPlaceholder") continue;
1489
+ return node;
1490
+ }
1491
+ }
1492
+ function flattenPhysicalChildren(children) {
1493
+ const result = [];
1494
+ for (const child of children) appendPhysicalChild(result, child);
1495
+ return result;
1496
+ }
1497
+ function appendPhysicalChild(result, node) {
1498
+ switch (node.kind) {
1499
+ case "Text":
1500
+ if (node.value.length > 0) result.push({ kind: "TextPlaceholder" });
1501
+ return;
1502
+ case "Element":
1503
+ case "DynamicText":
1504
+ case "Component":
1505
+ case "Show":
1506
+ case "For":
1507
+ case "Slot":
1508
+ result.push(node);
1509
+ return;
1510
+ case "Fragment":
1511
+ for (const child of node.children) appendPhysicalChild(result, child);
1512
+ return;
1513
+ case "Host":
1514
+ for (const child of node.children) appendPhysicalChild(result, child);
1515
+ return;
1516
+ }
1517
+ }
1518
+ //#endregion
1519
+ //#region packages/compiler/src/passes/validateBuiltins.ts
1520
+ function validateBuiltins(node) {
1521
+ visit$1(node, {
1522
+ insideHost: false,
1523
+ root: true
1524
+ });
1525
+ }
1526
+ function visit$1(node, state) {
1527
+ switch (node.kind) {
1528
+ case "Host":
1529
+ if (!state.root) throw new CompilerError({
1530
+ code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
1531
+ message: "<Host> can only be used as a root host boundary."
1532
+ });
1533
+ for (const child of node.children) visit$1(child, {
1534
+ insideHost: true,
1535
+ root: false
1536
+ });
1537
+ return;
1538
+ case "Slot":
1539
+ if (!state.insideHost) throw new CompilerError({
1540
+ code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
1541
+ message: "<Slot> can only be used inside <Host>."
1542
+ });
1543
+ return;
1544
+ case "Element":
1545
+ case "Fragment":
1546
+ for (const child of node.children) visit$1(child, _objectSpread2(_objectSpread2({}, state), {}, { root: false }));
1547
+ return;
1548
+ case "Component":
1549
+ for (const prop of node.props) {
1550
+ if (!Array.isArray(prop.value)) continue;
1551
+ for (const child of prop.value) visit$1(child, _objectSpread2(_objectSpread2({}, state), {}, { root: false }));
1552
+ }
1553
+ return;
1554
+ case "Show":
1555
+ for (const child of node.children) visit$1(child, _objectSpread2(_objectSpread2({}, state), {}, { root: false }));
1556
+ if (Array.isArray(node.fallback)) for (const child of node.fallback) visit$1(child, _objectSpread2(_objectSpread2({}, state), {}, { root: false }));
1557
+ return;
1558
+ case "For":
1559
+ for (const child of node.body) visit$1(child, _objectSpread2(_objectSpread2({}, state), {}, { root: false }));
1560
+ return;
1561
+ default: return;
1562
+ }
1563
+ }
1564
+ //#endregion
1565
+ //#region packages/compiler/src/passes/analyzeBindings.ts
1566
+ function analyzeBindings(node) {
1567
+ const analysis = {
1568
+ dynamicText: 0,
1569
+ dynamicAttrs: 0,
1570
+ events: 0,
1571
+ components: 0
1572
+ };
1573
+ visit(node, analysis);
1574
+ return analysis;
1575
+ }
1576
+ function visit(node, analysis) {
1577
+ switch (node.kind) {
1578
+ case "Element":
1579
+ for (const attr of node.attrs) {
1580
+ if (attr.kind === "AttrBinding" || attr.kind === "PropBinding") analysis.dynamicAttrs++;
1581
+ if (attr.kind === "EventBinding") analysis.events++;
1582
+ }
1583
+ for (const child of node.children) visit(child, analysis);
1584
+ return;
1585
+ case "DynamicText":
1586
+ analysis.dynamicText++;
1587
+ return;
1588
+ case "Component":
1589
+ analysis.components++;
1590
+ for (const prop of node.props) {
1591
+ if (!Array.isArray(prop.value)) continue;
1592
+ for (const child of prop.value) visit(child, analysis);
1593
+ }
1594
+ return;
1595
+ case "Fragment":
1596
+ case "Host":
1597
+ for (const child of node.children) visit(child, analysis);
1598
+ return;
1599
+ case "Slot":
1600
+ for (const child of node.fallback) visit(child, analysis);
1601
+ return;
1602
+ case "Show":
1603
+ for (const child of node.children) visit(child, analysis);
1604
+ if (Array.isArray(node.fallback)) for (const child of node.fallback) visit(child, analysis);
1605
+ return;
1606
+ case "For":
1607
+ for (const child of node.body) visit(child, analysis);
1608
+ return;
1609
+ case "Text": return;
1610
+ }
1611
+ }
1612
+ //#endregion
1613
+ //#region packages/compiler/src/transform/index.ts
1614
+ function transformJSX(path, state, config) {
1615
+ if (state.get("skip")) return;
1616
+ if (!path.isJSXElement() && !path.isJSXFragment()) return;
1617
+ const context = getCompilerContext(path, config);
1618
+ const ir = lowerJSX(path, context);
1619
+ normalizeChildren(ir);
1620
+ validateBuiltins(ir);
1621
+ assignDomPaths(ir);
1622
+ assignPhysicalDomPaths(ir);
1623
+ analyzeBindings(ir);
1624
+ collectTemplates(ir, context);
1625
+ path.replaceWith(emitDOM(ir, context));
1626
+ }
1627
+ //#endregion
1628
+ //#region packages/compiler/src/visitor.ts
1629
+ function createVisitor(config) {
1630
+ return {
1631
+ JSXElement(path, state) {
1632
+ transformJSX(path, state, config);
1633
+ },
1634
+ JSXFragment(path, state) {
1635
+ transformJSX(path, state, config);
1636
+ },
1637
+ Program: createProgramVisitor(config)
1638
+ };
1639
+ }
1640
+ //#endregion
1641
+ //#region packages/compiler/src/index.ts
1642
+ var src_default = declare((api, options) => {
1643
+ api.assertVersion(7);
1644
+ return {
1645
+ name: "babel-plugin-zeus-compiler",
1646
+ inherits: syntaxJsx,
1647
+ visitor: createVisitor(resolveConfig(options))
1648
+ };
1649
+ });
1650
+ //#endregion
1651
+ export { src_default as default };