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