@zeus-js/compiler 0.1.0-beta.0 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler.cjs.js +13 -7
- package/dist/compiler.cjs.prod.js +13 -7
- package/dist/compiler.esm-browser.js +141 -150
- package/dist/compiler.esm-browser.prod.js +5 -5
- package/dist/compiler.esm-bundler.js +13 -6
- package/dist/compiler.global.js +143 -150
- package/dist/compiler.global.prod.js +5 -5
- package/package.json +4 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* compiler v0.1.0-beta.
|
|
2
|
+
* compiler v0.1.0-beta.2
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
}) : target, mod));
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region node_modules/.pnpm/@babel+helper-plugin-utils@7.29.7/node_modules/@babel/helper-plugin-utils/lib/index.js
|
|
30
|
-
var require_lib$
|
|
30
|
+
var require_lib$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.declare = declare;
|
|
33
33
|
exports.declarePreset = void 0;
|
|
@@ -80,22 +80,6 @@ var require_lib$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
}));
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region node_modules/.pnpm/@babel+plugin-syntax-jsx@7.28.6_@babel+core@7.29.0/node_modules/@babel/plugin-syntax-jsx/lib/index.js
|
|
85
|
-
var require_lib$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
86
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
|
-
exports.default = void 0;
|
|
88
|
-
exports.default = (0, require_lib$4().declare)((api) => {
|
|
89
|
-
api.assertVersion("^7.0.0-0 || ^8.0.0-0");
|
|
90
|
-
return {
|
|
91
|
-
name: "syntax-jsx",
|
|
92
|
-
manipulateOptions(opts, parserOpts) {
|
|
93
|
-
if (parserOpts.plugins.some((p) => (Array.isArray(p) ? p[0] : p) === "typescript")) return;
|
|
94
|
-
parserOpts.plugins.push("jsx");
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
}));
|
|
99
83
|
Object.freeze({});
|
|
100
84
|
Object.freeze([]);
|
|
101
85
|
const extend = Object.assign;
|
|
@@ -14158,9 +14142,8 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14158
14142
|
}));
|
|
14159
14143
|
//#endregion
|
|
14160
14144
|
//#region packages/core/compiler/src/codegen/support/imports.ts
|
|
14161
|
-
var import_lib = require_lib$
|
|
14162
|
-
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib
|
|
14163
|
-
var import_lib$2 = /* @__PURE__ */ __toESM(require_lib());
|
|
14145
|
+
var import_lib = require_lib$3();
|
|
14146
|
+
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib());
|
|
14164
14147
|
const DEFAULT_RENDERER_MODULE = "@zeus-js/runtime-dom";
|
|
14165
14148
|
function getImportKey(moduleName, imported) {
|
|
14166
14149
|
return `${moduleName}:${imported}`;
|
|
@@ -14178,14 +14161,14 @@ function registerImportMethod(path, imported, moduleName = getRendererConfig(pat
|
|
|
14178
14161
|
const importMethods = data.importMethods || (data.importMethods = /* @__PURE__ */ new Map());
|
|
14179
14162
|
const key = getImportKey(moduleName, imported);
|
|
14180
14163
|
const cached = importMethods.get(key);
|
|
14181
|
-
if (cached) return import_lib$
|
|
14164
|
+
if (cached) return import_lib$1.cloneNode(cached.local);
|
|
14182
14165
|
const local = getProgramPath(path).scope.generateUidIdentifier(imported);
|
|
14183
14166
|
importMethods.set(key, {
|
|
14184
14167
|
imported,
|
|
14185
14168
|
local,
|
|
14186
14169
|
moduleName
|
|
14187
14170
|
});
|
|
14188
|
-
return import_lib$
|
|
14171
|
+
return import_lib$1.cloneNode(local);
|
|
14189
14172
|
}
|
|
14190
14173
|
/**
|
|
14191
14174
|
* Generates import declarations for all collected runtime helpers and
|
|
@@ -14201,7 +14184,7 @@ function appendImportMethods(path) {
|
|
|
14201
14184
|
else grouped.set(record.moduleName, [record]);
|
|
14202
14185
|
}
|
|
14203
14186
|
const declarations = [];
|
|
14204
|
-
for (const [moduleName, records] of grouped) declarations.push(import_lib$
|
|
14187
|
+
for (const [moduleName, records] of grouped) declarations.push(import_lib$1.importDeclaration(records.map((record) => import_lib$1.importSpecifier(import_lib$1.cloneNode(record.local), import_lib$1.identifier(record.imported))), import_lib$1.stringLiteral(moduleName)));
|
|
14205
14188
|
path.unshiftContainer("body", declarations);
|
|
14206
14189
|
}
|
|
14207
14190
|
function getProgramScopeData(path) {
|
|
@@ -14248,11 +14231,11 @@ function appendTemplates(path) {
|
|
|
14248
14231
|
};
|
|
14249
14232
|
const shouldUseImportNode = Boolean(template.isCE || template.isImportNode);
|
|
14250
14233
|
const isMathML = isMathMLTemplate(html);
|
|
14251
|
-
const args = [import_lib$
|
|
14252
|
-
if (template.isSVG || shouldUseImportNode || isMathML) args.push(import_lib$
|
|
14253
|
-
return import_lib$
|
|
14234
|
+
const args = [import_lib$1.templateLiteral([import_lib$1.templateElement(tmpl, true)], [])];
|
|
14235
|
+
if (template.isSVG || shouldUseImportNode || isMathML) args.push(import_lib$1.booleanLiteral(shouldUseImportNode), import_lib$1.booleanLiteral(Boolean(template.isSVG)), import_lib$1.booleanLiteral(isMathML));
|
|
14236
|
+
return import_lib$1.variableDeclarator(import_lib$1.cloneNode(template.id), import_lib$1.addComment(import_lib$1.callExpression(import_lib$1.cloneNode(templateMethod), args), "leading", "#__PURE__"));
|
|
14254
14237
|
});
|
|
14255
|
-
path.node.body.unshift(import_lib$
|
|
14238
|
+
path.node.body.unshift(import_lib$1.variableDeclaration("var", declarators));
|
|
14256
14239
|
}
|
|
14257
14240
|
//#endregion
|
|
14258
14241
|
//#region packages/core/compiler/src/codegen/support/events.ts
|
|
@@ -14282,7 +14265,7 @@ function registerEvent(path, eventName) {
|
|
|
14282
14265
|
function appendEvents(path) {
|
|
14283
14266
|
const events = path.scope.data.events;
|
|
14284
14267
|
if (!(events === null || events === void 0 ? void 0 : events.size)) return;
|
|
14285
|
-
path.node.body.push(import_lib$
|
|
14268
|
+
path.node.body.push(import_lib$1.expressionStatement(import_lib$1.callExpression(registerImportMethod(path, "delegateEvents", getRendererConfig(path, "dom").moduleName), [import_lib$1.arrayExpression(Array.from(events).map((eventName) => import_lib$1.stringLiteral(eventName)))])));
|
|
14286
14269
|
}
|
|
14287
14270
|
//#endregion
|
|
14288
14271
|
//#region packages/core/compiler/src/config/index.ts
|
|
@@ -14403,7 +14386,7 @@ function emitBindings(node, context) {
|
|
|
14403
14386
|
return statements;
|
|
14404
14387
|
}
|
|
14405
14388
|
function emitRawTextBinding(node, context) {
|
|
14406
|
-
return import_lib$
|
|
14389
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindTextContent"), [import_lib$1.identifier(node.ref.name), import_lib$1.arrowFunctionExpression([], emitRawTextValue(node.children))]));
|
|
14407
14390
|
}
|
|
14408
14391
|
function hasRuntimeRawText$1(children) {
|
|
14409
14392
|
return children.some((child) => {
|
|
@@ -14415,15 +14398,15 @@ function hasRuntimeRawText$1(children) {
|
|
|
14415
14398
|
function emitRawTextValue(children) {
|
|
14416
14399
|
const values = children.flatMap((child) => {
|
|
14417
14400
|
switch (child.kind) {
|
|
14418
|
-
case "Text": return [import_lib$
|
|
14401
|
+
case "Text": return [import_lib$1.stringLiteral(child.value)];
|
|
14419
14402
|
case "DynamicText": return [child.expr];
|
|
14420
14403
|
case "Fragment": return [emitRawTextValue(child.children)];
|
|
14421
14404
|
default: return [];
|
|
14422
14405
|
}
|
|
14423
14406
|
});
|
|
14424
|
-
if (values.length === 0) return import_lib$
|
|
14407
|
+
if (values.length === 0) return import_lib$1.stringLiteral("");
|
|
14425
14408
|
if (values.length === 1) return values[0];
|
|
14426
|
-
return import_lib$
|
|
14409
|
+
return import_lib$1.arrayExpression(values);
|
|
14427
14410
|
}
|
|
14428
14411
|
function emitChildBinding(node, context) {
|
|
14429
14412
|
switch (node.kind) {
|
|
@@ -14439,12 +14422,12 @@ function emitChildBinding(node, context) {
|
|
|
14439
14422
|
}
|
|
14440
14423
|
function emitAttrBinding(target, binding, context) {
|
|
14441
14424
|
const name = normalizeAttrName(binding.name);
|
|
14442
|
-
if (name === "class") return import_lib$
|
|
14443
|
-
if (name === "style") return import_lib$
|
|
14444
|
-
return import_lib$
|
|
14445
|
-
import_lib$
|
|
14446
|
-
import_lib$
|
|
14447
|
-
import_lib$
|
|
14425
|
+
if (name === "class") return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindClass"), [import_lib$1.identifier(target.ref.name), import_lib$1.arrowFunctionExpression([], binding.expr)]));
|
|
14426
|
+
if (name === "style") return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindStyle"), [import_lib$1.identifier(target.ref.name), import_lib$1.arrowFunctionExpression([], binding.expr)]));
|
|
14427
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindAttr"), [
|
|
14428
|
+
import_lib$1.identifier(target.ref.name),
|
|
14429
|
+
import_lib$1.stringLiteral(name),
|
|
14430
|
+
import_lib$1.arrowFunctionExpression([], binding.expr)
|
|
14448
14431
|
]));
|
|
14449
14432
|
}
|
|
14450
14433
|
function normalizeAttrName(name) {
|
|
@@ -14452,45 +14435,45 @@ function normalizeAttrName(name) {
|
|
|
14452
14435
|
}
|
|
14453
14436
|
function emitEventBinding(target, binding, context) {
|
|
14454
14437
|
registerEvent(context.programPath, binding.eventName);
|
|
14455
|
-
return import_lib$
|
|
14456
|
-
import_lib$
|
|
14457
|
-
import_lib$
|
|
14438
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindEvent"), [
|
|
14439
|
+
import_lib$1.identifier(target.ref.name),
|
|
14440
|
+
import_lib$1.stringLiteral(binding.eventName),
|
|
14458
14441
|
normalizeEventHandler(binding.handler, context)
|
|
14459
14442
|
]));
|
|
14460
14443
|
}
|
|
14461
14444
|
function normalizeEventHandler(handler, context) {
|
|
14462
|
-
if (import_lib$
|
|
14445
|
+
if (import_lib$1.isMemberExpression(handler) || import_lib$1.isOptionalMemberExpression(handler)) {
|
|
14463
14446
|
const event = context.uid("event$");
|
|
14464
|
-
return import_lib$
|
|
14447
|
+
return import_lib$1.arrowFunctionExpression([import_lib$1.identifier(event.name)], import_lib$1.optionalCallExpression(import_lib$1.cloneNode(handler), [import_lib$1.identifier(event.name)], true));
|
|
14465
14448
|
}
|
|
14466
14449
|
return handler;
|
|
14467
14450
|
}
|
|
14468
14451
|
function emitPropBinding(target, binding, context) {
|
|
14469
|
-
return import_lib$
|
|
14470
|
-
import_lib$
|
|
14471
|
-
import_lib$
|
|
14472
|
-
import_lib$
|
|
14452
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindProp"), [
|
|
14453
|
+
import_lib$1.identifier(target.ref.name),
|
|
14454
|
+
import_lib$1.stringLiteral(binding.name),
|
|
14455
|
+
import_lib$1.arrowFunctionExpression([], binding.expr)
|
|
14473
14456
|
]));
|
|
14474
14457
|
}
|
|
14475
14458
|
function emitRefBinding(target, binding, context) {
|
|
14476
|
-
return import_lib$
|
|
14459
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindRef"), [import_lib$1.identifier(target.ref.name), binding.expr]));
|
|
14477
14460
|
}
|
|
14478
14461
|
function emitDynamicText(node, context) {
|
|
14479
14462
|
if (!node.domPath || node.domPath.kind !== "Marker") return [];
|
|
14480
14463
|
const textRef = context.uid("text$");
|
|
14481
|
-
if (node.once) return [import_lib$
|
|
14482
|
-
import_lib$
|
|
14464
|
+
if (node.once) return [import_lib$1.variableDeclaration("const", [import_lib$1.variableDeclarator(textRef, import_lib$1.callExpression(import_lib$1.memberExpression(import_lib$1.identifier("document"), import_lib$1.identifier("createTextNode")), [import_lib$1.callExpression(import_lib$1.identifier("String"), [node.expr])]))]), import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("insert"), [
|
|
14465
|
+
import_lib$1.identifier(node.domPath.parent.name),
|
|
14483
14466
|
textRef,
|
|
14484
|
-
import_lib$
|
|
14467
|
+
import_lib$1.identifier(node.ref.name)
|
|
14485
14468
|
]))];
|
|
14486
14469
|
return [
|
|
14487
|
-
import_lib$
|
|
14488
|
-
import_lib$
|
|
14489
|
-
import_lib$
|
|
14470
|
+
import_lib$1.variableDeclaration("const", [import_lib$1.variableDeclarator(textRef, import_lib$1.callExpression(import_lib$1.memberExpression(import_lib$1.identifier("document"), import_lib$1.identifier("createTextNode")), [import_lib$1.stringLiteral("")]))]),
|
|
14471
|
+
import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("insert"), [
|
|
14472
|
+
import_lib$1.identifier(node.domPath.parent.name),
|
|
14490
14473
|
textRef,
|
|
14491
|
-
import_lib$
|
|
14474
|
+
import_lib$1.identifier(node.ref.name)
|
|
14492
14475
|
])),
|
|
14493
|
-
import_lib$
|
|
14476
|
+
import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindText"), [textRef, import_lib$1.arrowFunctionExpression([], node.expr)]))
|
|
14494
14477
|
];
|
|
14495
14478
|
}
|
|
14496
14479
|
function emitComponentInsert(node, context) {
|
|
@@ -14498,24 +14481,24 @@ function emitComponentInsert(node, context) {
|
|
|
14498
14481
|
}
|
|
14499
14482
|
function emitMarkerInsert(node, context, value) {
|
|
14500
14483
|
if (!node.domPath || node.domPath.kind !== "Marker") return [];
|
|
14501
|
-
return [import_lib$
|
|
14502
|
-
import_lib$
|
|
14484
|
+
return [import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("insert"), [
|
|
14485
|
+
import_lib$1.identifier(node.domPath.parent.name),
|
|
14503
14486
|
value,
|
|
14504
|
-
import_lib$
|
|
14487
|
+
import_lib$1.identifier(node.ref.name)
|
|
14505
14488
|
]))];
|
|
14506
14489
|
}
|
|
14507
14490
|
function emitMarkerMount(node, context, mountCall) {
|
|
14508
14491
|
if (!node.domPath || node.domPath.kind !== "Marker") return [];
|
|
14509
|
-
return [import_lib$
|
|
14492
|
+
return [import_lib$1.expressionStatement(mountCall)];
|
|
14510
14493
|
}
|
|
14511
14494
|
//#endregion
|
|
14512
14495
|
//#region packages/core/compiler/src/codegen/dom/emitDomPath.ts
|
|
14513
14496
|
function emitPhysicalDomPath(path) {
|
|
14514
14497
|
switch (path.kind) {
|
|
14515
14498
|
case "Root": throw new Error("Root path is emitted from template clone directly");
|
|
14516
|
-
case "FirstChild": return import_lib$
|
|
14517
|
-
case "NextSibling": return import_lib$
|
|
14518
|
-
case "ChildNode": return import_lib$
|
|
14499
|
+
case "FirstChild": return import_lib$1.memberExpression(import_lib$1.identifier(path.parent.name), import_lib$1.identifier("firstChild"));
|
|
14500
|
+
case "NextSibling": return import_lib$1.memberExpression(import_lib$1.identifier(path.previous.name), import_lib$1.identifier("nextSibling"));
|
|
14501
|
+
case "ChildNode": return import_lib$1.memberExpression(import_lib$1.memberExpression(import_lib$1.identifier(path.parent.name), import_lib$1.identifier("childNodes")), import_lib$1.numericLiteral(path.index), true);
|
|
14519
14502
|
}
|
|
14520
14503
|
}
|
|
14521
14504
|
//#endregion
|
|
@@ -14572,20 +14555,20 @@ function escapeAttr(value) {
|
|
|
14572
14555
|
function emitTemplateClone(node, context) {
|
|
14573
14556
|
const html = renderTemplateHTML(node);
|
|
14574
14557
|
const template = context.registerTemplate(html, node.flags.isSVG);
|
|
14575
|
-
const templateCall = import_lib$
|
|
14576
|
-
return import_lib$
|
|
14558
|
+
const templateCall = import_lib$1.callExpression(import_lib$1.cloneNode(template.id), []);
|
|
14559
|
+
return import_lib$1.memberExpression(templateCall, import_lib$1.identifier("firstChild"));
|
|
14577
14560
|
}
|
|
14578
14561
|
//#endregion
|
|
14579
14562
|
//#region packages/core/compiler/src/codegen/dom/emitElement.ts
|
|
14580
14563
|
function emitElement(node, context) {
|
|
14581
14564
|
if (!hasRuntimeWork(node)) return emitTemplateClone(node, context);
|
|
14582
14565
|
const statements = [
|
|
14583
|
-
import_lib$
|
|
14566
|
+
import_lib$1.variableDeclaration("const", [import_lib$1.variableDeclarator(import_lib$1.identifier(node.ref.name), emitTemplateClone(node, context))]),
|
|
14584
14567
|
...emitDomRefDeclarations(node.children, context),
|
|
14585
14568
|
...emitBindings(node, context),
|
|
14586
|
-
import_lib$
|
|
14569
|
+
import_lib$1.returnStatement(import_lib$1.identifier(node.ref.name))
|
|
14587
14570
|
];
|
|
14588
|
-
return import_lib$
|
|
14571
|
+
return import_lib$1.callExpression(import_lib$1.arrowFunctionExpression([], import_lib$1.blockStatement(statements)), []);
|
|
14589
14572
|
}
|
|
14590
14573
|
function emitDomRefDeclarations(children, context) {
|
|
14591
14574
|
const statements = [];
|
|
@@ -14671,7 +14654,7 @@ function emitRefDependency(ref, statements, context, refNodeMap, declared) {
|
|
|
14671
14654
|
}
|
|
14672
14655
|
function createDomRefDeclaration(node, _context) {
|
|
14673
14656
|
if (!node.physicalDomPath) throw new Error(`${node.kind} physical DOM path is not assigned`);
|
|
14674
|
-
return import_lib$
|
|
14657
|
+
return import_lib$1.variableDeclaration("const", [import_lib$1.variableDeclarator(import_lib$1.identifier(node.ref.name), emitPhysicalDomPath(node.physicalDomPath))]);
|
|
14675
14658
|
}
|
|
14676
14659
|
function needsDomRefDeclaration(node) {
|
|
14677
14660
|
if (!node.physicalDomPath) return false;
|
|
@@ -14716,13 +14699,13 @@ function hasChildRuntimeWork(node) {
|
|
|
14716
14699
|
//#endregion
|
|
14717
14700
|
//#region packages/core/compiler/src/codegen/dom/emitFragment.ts
|
|
14718
14701
|
function emitFragment(node, context) {
|
|
14719
|
-
return import_lib$
|
|
14702
|
+
return import_lib$1.arrayExpression(node.children.map((child) => emitDOM(child, context)));
|
|
14720
14703
|
}
|
|
14721
14704
|
//#endregion
|
|
14722
14705
|
//#region packages/core/compiler/src/codegen/dom/emitNodeExpression.ts
|
|
14723
14706
|
function emitNodeExpression(node, context) {
|
|
14724
14707
|
switch (node.kind) {
|
|
14725
|
-
case "Text": return import_lib$
|
|
14708
|
+
case "Text": return import_lib$1.stringLiteral(node.value);
|
|
14726
14709
|
case "DynamicText": return node.expr;
|
|
14727
14710
|
case "Element": return emitElement(node, context);
|
|
14728
14711
|
case "Component": return emitComponent(node, context);
|
|
@@ -14731,101 +14714,102 @@ function emitNodeExpression(node, context) {
|
|
|
14731
14714
|
case "For": return emitFor(node, context);
|
|
14732
14715
|
case "Host": return emitHost(node, context);
|
|
14733
14716
|
case "Slot": return emitSlot(node, context);
|
|
14734
|
-
default: return import_lib$
|
|
14717
|
+
default: return import_lib$1.nullLiteral();
|
|
14735
14718
|
}
|
|
14736
14719
|
}
|
|
14737
14720
|
//#endregion
|
|
14738
14721
|
//#region packages/core/compiler/src/codegen/dom/emitComponent.ts
|
|
14739
14722
|
function emitComponent(node, context) {
|
|
14740
|
-
const props = import_lib$
|
|
14741
|
-
return import_lib$
|
|
14723
|
+
const props = import_lib$1.objectExpression(node.props.map((prop) => emitComponentProp(prop, context)));
|
|
14724
|
+
return import_lib$1.callExpression(context.importRuntime("createComponent"), [node.callee, props]);
|
|
14742
14725
|
}
|
|
14743
14726
|
function emitComponentProp(prop, context) {
|
|
14744
14727
|
const key = createObjectKey$1(prop.name);
|
|
14745
|
-
if (Array.isArray(prop.value)) return import_lib$
|
|
14746
|
-
if (isStaticPropValue(prop.value)) return import_lib$
|
|
14747
|
-
return import_lib$
|
|
14728
|
+
if (Array.isArray(prop.value)) return import_lib$1.objectMethod("get", key, [], import_lib$1.blockStatement([import_lib$1.returnStatement(emitChildrenProp(prop.value, context))]));
|
|
14729
|
+
if (isStaticPropValue(prop.value)) return import_lib$1.objectProperty(key, prop.value);
|
|
14730
|
+
return import_lib$1.objectMethod("get", key, [], import_lib$1.blockStatement([import_lib$1.returnStatement(prop.value)]));
|
|
14748
14731
|
}
|
|
14749
14732
|
function emitChildrenProp(children, context) {
|
|
14750
14733
|
const nodes = children.map((child) => emitNodeExpression(child, context));
|
|
14751
14734
|
if (nodes.length === 1) return nodes[0];
|
|
14752
|
-
return import_lib$
|
|
14735
|
+
return import_lib$1.arrayExpression(nodes);
|
|
14753
14736
|
}
|
|
14754
14737
|
function isStaticPropValue(value) {
|
|
14755
|
-
return import_lib$
|
|
14738
|
+
return import_lib$1.isStringLiteral(value) || import_lib$1.isNumericLiteral(value) || import_lib$1.isBooleanLiteral(value) || import_lib$1.isNullLiteral(value);
|
|
14756
14739
|
}
|
|
14757
14740
|
function createObjectKey$1(key) {
|
|
14758
|
-
return import_lib$
|
|
14741
|
+
return import_lib$1.isValidIdentifier(key) ? import_lib$1.identifier(key) : import_lib$1.stringLiteral(key);
|
|
14759
14742
|
}
|
|
14760
14743
|
//#endregion
|
|
14761
14744
|
//#region packages/core/compiler/src/codegen/dom/emitBuiltin.ts
|
|
14762
14745
|
function emitShow(node, context) {
|
|
14763
|
-
const props = [import_lib$
|
|
14764
|
-
if (node.fallback) props.push(import_lib$
|
|
14765
|
-
return import_lib$
|
|
14746
|
+
const props = [import_lib$1.objectProperty(import_lib$1.identifier("when"), node.when), import_lib$1.objectProperty(import_lib$1.identifier("children"), import_lib$1.arrowFunctionExpression([], emitChildrenProp(node.children, context)))];
|
|
14747
|
+
if (node.fallback) props.push(import_lib$1.objectProperty(import_lib$1.identifier("fallback"), Array.isArray(node.fallback) ? import_lib$1.arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : node.fallback));
|
|
14748
|
+
return import_lib$1.callExpression(context.importRuntime("createComponent"), [context.importRuntime("Show"), import_lib$1.objectExpression(props)]);
|
|
14766
14749
|
}
|
|
14767
14750
|
function emitMountShow(node, context) {
|
|
14768
14751
|
const path = node.domPath;
|
|
14769
14752
|
if (!path || path.kind !== "Marker") throw new Error("Show DOM path is not assigned");
|
|
14770
|
-
return import_lib$
|
|
14771
|
-
import_lib$
|
|
14753
|
+
return import_lib$1.callExpression(context.importRuntime("mountShow"), [
|
|
14754
|
+
import_lib$1.identifier(path.parent.name),
|
|
14772
14755
|
emitMarkerIdentifier(node),
|
|
14773
|
-
import_lib$
|
|
14774
|
-
import_lib$
|
|
14775
|
-
node.fallback ? Array.isArray(node.fallback) ? import_lib$
|
|
14756
|
+
import_lib$1.arrowFunctionExpression([], node.when),
|
|
14757
|
+
import_lib$1.arrowFunctionExpression([], emitChildrenProp(node.children, context)),
|
|
14758
|
+
node.fallback ? Array.isArray(node.fallback) ? import_lib$1.arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : import_lib$1.arrowFunctionExpression([], node.fallback) : import_lib$1.identifier("undefined")
|
|
14776
14759
|
]);
|
|
14777
14760
|
}
|
|
14778
14761
|
function emitFor(node, context) {
|
|
14779
14762
|
const params = [node.item];
|
|
14780
14763
|
if (node.index) params.push(node.index);
|
|
14781
|
-
const props = [import_lib$
|
|
14782
|
-
if (node.by) props.push(import_lib$
|
|
14783
|
-
return import_lib$
|
|
14764
|
+
const props = [import_lib$1.objectProperty(import_lib$1.identifier("each"), node.each), import_lib$1.objectProperty(import_lib$1.identifier("children"), import_lib$1.arrowFunctionExpression(params, emitChildrenProp(node.body, context)))];
|
|
14765
|
+
if (node.by) props.push(import_lib$1.objectProperty(import_lib$1.identifier("by"), node.by));
|
|
14766
|
+
return import_lib$1.callExpression(context.importRuntime("createComponent"), [context.importRuntime("For"), import_lib$1.objectExpression(props)]);
|
|
14784
14767
|
}
|
|
14785
14768
|
function emitMountFor(node, context) {
|
|
14786
14769
|
var _node$by;
|
|
14787
14770
|
const params = [node.item];
|
|
14788
|
-
const path = node.domPath;
|
|
14789
14771
|
if (node.index) params.push(node.index);
|
|
14772
|
+
const path = node.domPath;
|
|
14790
14773
|
if (!path || path.kind !== "Marker") throw new Error("For DOM path is not assigned");
|
|
14791
|
-
return import_lib$
|
|
14792
|
-
import_lib$
|
|
14774
|
+
return import_lib$1.callExpression(context.importRuntime("mountFor"), [
|
|
14775
|
+
import_lib$1.identifier(path.parent.name),
|
|
14793
14776
|
emitMarkerIdentifier(node),
|
|
14794
|
-
import_lib$
|
|
14795
|
-
(_node$by = node.by) !== null && _node$by !== void 0 ? _node$by : import_lib$
|
|
14796
|
-
import_lib$
|
|
14777
|
+
import_lib$1.arrowFunctionExpression([], node.each),
|
|
14778
|
+
(_node$by = node.by) !== null && _node$by !== void 0 ? _node$by : import_lib$1.identifier("undefined"),
|
|
14779
|
+
import_lib$1.arrowFunctionExpression(params, emitChildrenProp(node.body, context))
|
|
14797
14780
|
]);
|
|
14798
14781
|
}
|
|
14799
14782
|
function emitHost(node, context) {
|
|
14800
14783
|
const props = buildHostProps(node, context);
|
|
14801
|
-
const
|
|
14802
|
-
if (!node.child) return
|
|
14784
|
+
const hostIdent = context.importRuntime("Host");
|
|
14785
|
+
if (!node.child) return import_lib$1.callExpression(hostIdent, [import_lib$1.objectExpression(props)]);
|
|
14803
14786
|
const childExpr = emitNodeExpression(node.child, context);
|
|
14804
|
-
|
|
14787
|
+
const hostCall = import_lib$1.callExpression(hostIdent, [import_lib$1.objectExpression(props)]);
|
|
14788
|
+
return import_lib$1.callExpression(import_lib$1.arrowFunctionExpression([], import_lib$1.blockStatement([import_lib$1.expressionStatement(hostCall), import_lib$1.returnStatement(childExpr)])), []);
|
|
14805
14789
|
}
|
|
14806
14790
|
function buildHostProps(node, context) {
|
|
14807
14791
|
const props = [];
|
|
14808
14792
|
for (const attr of node.attrs) {
|
|
14809
14793
|
const key = createObjectKey(attr.name);
|
|
14810
|
-
if (isStaticValue(attr.expr) || isGetterExpression(attr.expr)) props.push(import_lib$
|
|
14811
|
-
else props.push(import_lib$
|
|
14794
|
+
if (isStaticValue(attr.expr) || isGetterExpression(attr.expr)) props.push(import_lib$1.objectProperty(key, attr.expr));
|
|
14795
|
+
else props.push(import_lib$1.objectProperty(key, import_lib$1.arrowFunctionExpression([], attr.expr)));
|
|
14812
14796
|
}
|
|
14813
14797
|
return props;
|
|
14814
14798
|
}
|
|
14815
14799
|
function isStaticValue(expr) {
|
|
14816
|
-
return import_lib$
|
|
14800
|
+
return import_lib$1.isStringLiteral(expr) || import_lib$1.isNumericLiteral(expr) || import_lib$1.isBooleanLiteral(expr) || import_lib$1.isNullLiteral(expr);
|
|
14817
14801
|
}
|
|
14818
14802
|
function isGetterExpression(expr) {
|
|
14819
|
-
return import_lib$
|
|
14803
|
+
return import_lib$1.isArrowFunctionExpression(expr) || import_lib$1.isFunctionExpression(expr);
|
|
14820
14804
|
}
|
|
14821
14805
|
function createObjectKey(name) {
|
|
14822
|
-
return import_lib$
|
|
14806
|
+
return import_lib$1.isValidIdentifier(name) ? import_lib$1.identifier(name) : import_lib$1.stringLiteral(name);
|
|
14823
14807
|
}
|
|
14824
14808
|
function emitSlot(node, context) {
|
|
14825
|
-
return import_lib$
|
|
14809
|
+
return import_lib$1.callExpression(context.importRuntime("createSlot"), [node.name ? import_lib$1.stringLiteral(node.name) : import_lib$1.identifier("undefined"), node.fallback.length > 0 ? import_lib$1.arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : import_lib$1.identifier("undefined")]);
|
|
14826
14810
|
}
|
|
14827
14811
|
function emitMarkerIdentifier(node) {
|
|
14828
|
-
return import_lib$
|
|
14812
|
+
return import_lib$1.identifier(node.ref.name);
|
|
14829
14813
|
}
|
|
14830
14814
|
//#endregion
|
|
14831
14815
|
//#region packages/core/compiler/src/codegen/dom/index.ts
|
|
@@ -14838,7 +14822,7 @@ function emitDOM(node, context) {
|
|
|
14838
14822
|
case "For": return emitFor(node, context);
|
|
14839
14823
|
case "Host": return emitHost(node, context);
|
|
14840
14824
|
case "Slot": return emitSlot(node, context);
|
|
14841
|
-
case "DynamicText": return import_lib$
|
|
14825
|
+
case "DynamicText": return import_lib$1.arrowFunctionExpression([], node.expr);
|
|
14842
14826
|
default: throw new Error(`Unsupported root IR node: ${node.kind}`);
|
|
14843
14827
|
}
|
|
14844
14828
|
}
|
|
@@ -14862,14 +14846,14 @@ var CompilerContext = class {
|
|
|
14862
14846
|
const importMethods = scopeData.importMethods || (scopeData.importMethods = /* @__PURE__ */ new Map());
|
|
14863
14847
|
const key = `${moduleName}:${imported}`;
|
|
14864
14848
|
const cached = importMethods.get(key);
|
|
14865
|
-
if (cached) return import_lib$
|
|
14849
|
+
if (cached) return import_lib$1.cloneNode(cached.local);
|
|
14866
14850
|
const local = this.uid(imported);
|
|
14867
14851
|
importMethods.set(key, {
|
|
14868
14852
|
moduleName,
|
|
14869
14853
|
imported,
|
|
14870
14854
|
local
|
|
14871
14855
|
});
|
|
14872
|
-
return import_lib$
|
|
14856
|
+
return import_lib$1.cloneNode(local);
|
|
14873
14857
|
}
|
|
14874
14858
|
registerTemplate(html, isSVG = false) {
|
|
14875
14859
|
const scopeData = this.programPath.scope.data;
|
|
@@ -14877,7 +14861,7 @@ var CompilerContext = class {
|
|
|
14877
14861
|
const templates = scopeData.templates || (scopeData.templates = []);
|
|
14878
14862
|
const cached = templateMap.get(html);
|
|
14879
14863
|
if (cached) return {
|
|
14880
|
-
id: import_lib$
|
|
14864
|
+
id: import_lib$1.cloneNode(cached.id),
|
|
14881
14865
|
html,
|
|
14882
14866
|
isSVG: Boolean(cached.isSVG)
|
|
14883
14867
|
};
|
|
@@ -14893,7 +14877,7 @@ var CompilerContext = class {
|
|
|
14893
14877
|
});
|
|
14894
14878
|
templates.push(templateMap.get(html));
|
|
14895
14879
|
return {
|
|
14896
|
-
id: import_lib$
|
|
14880
|
+
id: import_lib$1.cloneNode(id),
|
|
14897
14881
|
html,
|
|
14898
14882
|
isSVG
|
|
14899
14883
|
};
|
|
@@ -15140,15 +15124,15 @@ function slotIR(input) {
|
|
|
15140
15124
|
* These do NOT produce IR or Babel AST; they only read the JSX tree.
|
|
15141
15125
|
*/
|
|
15142
15126
|
function jsxElementNameToString(node) {
|
|
15143
|
-
if (import_lib$
|
|
15144
|
-
if (import_lib$
|
|
15127
|
+
if (import_lib$1.isJSXMemberExpression(node)) return `${jsxElementNameToString(node.object)}.${node.property.name}`;
|
|
15128
|
+
if (import_lib$1.isJSXIdentifier(node) || import_lib$1.isIdentifier(node)) return node.name;
|
|
15145
15129
|
return `${node.namespace.name}:${node.name.name}`;
|
|
15146
15130
|
}
|
|
15147
15131
|
function getTagName(node) {
|
|
15148
15132
|
return jsxElementNameToString(node.openingElement.name);
|
|
15149
15133
|
}
|
|
15150
15134
|
function getJSXAttrName(name) {
|
|
15151
|
-
if (import_lib$
|
|
15135
|
+
if (import_lib$1.isJSXNamespacedName(name)) return `${name.namespace.name}:${name.name.name}`;
|
|
15152
15136
|
return name.name;
|
|
15153
15137
|
}
|
|
15154
15138
|
function isComponentTag(tagName) {
|
|
@@ -15160,7 +15144,7 @@ function toEventName(name) {
|
|
|
15160
15144
|
//#endregion
|
|
15161
15145
|
//#region packages/core/compiler/src/lower/lowerAttribute.ts
|
|
15162
15146
|
function lowerAttribute(path, _context) {
|
|
15163
|
-
if (path.isJSXSpreadAttribute() || import_lib$
|
|
15147
|
+
if (path.isJSXSpreadAttribute() || import_lib$1.isJSXSpreadAttribute(path.node)) throw new CompilerError({
|
|
15164
15148
|
code: CompilerErrorCode.UNSUPPORTED_SPREAD_ATTRIBUTE,
|
|
15165
15149
|
message: "Spread attributes are not supported in Zeus MVP.",
|
|
15166
15150
|
path,
|
|
@@ -15178,7 +15162,7 @@ function lowerAttribute(path, _context) {
|
|
|
15178
15162
|
});
|
|
15179
15163
|
return staticAttrIR(name, true);
|
|
15180
15164
|
}
|
|
15181
|
-
if (import_lib$
|
|
15165
|
+
if (import_lib$1.isStringLiteral(value)) {
|
|
15182
15166
|
if (name === "ref") throw new CompilerError({
|
|
15183
15167
|
code: CompilerErrorCode.INVALID_REF_USAGE,
|
|
15184
15168
|
message: "String refs are not supported in Zeus.",
|
|
@@ -15187,9 +15171,9 @@ function lowerAttribute(path, _context) {
|
|
|
15187
15171
|
});
|
|
15188
15172
|
return staticAttrIR(name, value.value);
|
|
15189
15173
|
}
|
|
15190
|
-
if (import_lib$
|
|
15174
|
+
if (import_lib$1.isJSXExpressionContainer(value)) {
|
|
15191
15175
|
const expr = value.expression;
|
|
15192
|
-
if (import_lib$
|
|
15176
|
+
if (import_lib$1.isJSXEmptyExpression(expr)) throw new CompilerError({
|
|
15193
15177
|
code: CompilerErrorCode.EMPTY_EXPRESSION,
|
|
15194
15178
|
message: `Attribute "${name}" expression cannot be empty.`,
|
|
15195
15179
|
path
|
|
@@ -15213,8 +15197,8 @@ function lowerChildren(children, context) {
|
|
|
15213
15197
|
}
|
|
15214
15198
|
if (child.isJSXExpressionContainer()) {
|
|
15215
15199
|
const expr = child.node.expression;
|
|
15216
|
-
if (import_lib$
|
|
15217
|
-
if (import_lib$
|
|
15200
|
+
if (import_lib$1.isJSXEmptyExpression(expr)) continue;
|
|
15201
|
+
if (import_lib$1.isExpression(expr)) result.push(dynamicTextIR(expr, ref(context.uid("anchor$").name)));
|
|
15218
15202
|
continue;
|
|
15219
15203
|
}
|
|
15220
15204
|
if (child.isJSXElement() || child.isJSXFragment()) {
|
|
@@ -15236,7 +15220,7 @@ function isBuiltinTag(tagName) {
|
|
|
15236
15220
|
}
|
|
15237
15221
|
function lowerBuiltin(path, context) {
|
|
15238
15222
|
const tagName = path.node.openingElement.name;
|
|
15239
|
-
if (!import_lib$
|
|
15223
|
+
if (!import_lib$1.isJSXIdentifier(tagName)) throw new CompilerError({
|
|
15240
15224
|
code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
|
|
15241
15225
|
message: "Built-in JSX nodes do not support member expressions.",
|
|
15242
15226
|
path
|
|
@@ -15270,7 +15254,7 @@ function optionalShowFallbackAttr(path, context) {
|
|
|
15270
15254
|
});
|
|
15271
15255
|
if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
|
|
15272
15256
|
const value = attr.get("value");
|
|
15273
|
-
if (!value.node) return import_lib$
|
|
15257
|
+
if (!value.node) return import_lib$1.booleanLiteral(true);
|
|
15274
15258
|
if (value.isStringLiteral()) return value.node;
|
|
15275
15259
|
if (!value.isJSXExpressionContainer()) return void 0;
|
|
15276
15260
|
const expression = value.get("expression");
|
|
@@ -15283,7 +15267,7 @@ function lowerFor(path, context) {
|
|
|
15283
15267
|
const each = requiredExpressionAttr(path, "each");
|
|
15284
15268
|
const by = optionalExpressionAttr(path, "by");
|
|
15285
15269
|
const render = getOnlyRenderFunction(path);
|
|
15286
|
-
const item = (_getParamIdentifier = getParamIdentifier(render, 0)) !== null && _getParamIdentifier !== void 0 ? _getParamIdentifier : import_lib$
|
|
15270
|
+
const item = (_getParamIdentifier = getParamIdentifier(render, 0)) !== null && _getParamIdentifier !== void 0 ? _getParamIdentifier : import_lib$1.identifier("item");
|
|
15287
15271
|
const index = getParamIdentifier(render, 1);
|
|
15288
15272
|
const bodyPath = render.get("body");
|
|
15289
15273
|
const body = [];
|
|
@@ -15322,9 +15306,9 @@ function optionalExpressionAttr(path, name) {
|
|
|
15322
15306
|
});
|
|
15323
15307
|
if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
|
|
15324
15308
|
const value = attr.node.value;
|
|
15325
|
-
if (!value) return import_lib$
|
|
15326
|
-
if (import_lib$
|
|
15327
|
-
if (import_lib$
|
|
15309
|
+
if (!value) return import_lib$1.booleanLiteral(true);
|
|
15310
|
+
if (import_lib$1.isStringLiteral(value)) return value;
|
|
15311
|
+
if (import_lib$1.isJSXExpressionContainer(value) && !import_lib$1.isJSXEmptyExpression(value.expression)) return value.expression;
|
|
15328
15312
|
}
|
|
15329
15313
|
function optionalStringAttr(path, name) {
|
|
15330
15314
|
const attr = path.get("openingElement").get("attributes").find((attrPath) => {
|
|
@@ -15334,7 +15318,7 @@ function optionalStringAttr(path, name) {
|
|
|
15334
15318
|
if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
|
|
15335
15319
|
const value = attr.node.value;
|
|
15336
15320
|
if (!value) return "";
|
|
15337
|
-
if (import_lib$
|
|
15321
|
+
if (import_lib$1.isStringLiteral(value)) return value.value;
|
|
15338
15322
|
}
|
|
15339
15323
|
function getOnlyRenderFunction(path) {
|
|
15340
15324
|
const expressions = path.get("children").filter((child) => child.isJSXExpressionContainer()).map((child) => child.get("expression")).filter((expression) => expression.isArrowFunctionExpression() || expression.isFunctionExpression());
|
|
@@ -15347,12 +15331,12 @@ function getOnlyRenderFunction(path) {
|
|
|
15347
15331
|
}
|
|
15348
15332
|
function getParamIdentifier(path, index, fallback) {
|
|
15349
15333
|
const param = path.node.params[index];
|
|
15350
|
-
if (import_lib$
|
|
15351
|
-
if (fallback) return import_lib$
|
|
15334
|
+
if (import_lib$1.isIdentifier(param)) return param;
|
|
15335
|
+
if (fallback) return import_lib$1.identifier(fallback);
|
|
15352
15336
|
}
|
|
15353
15337
|
function getBuiltinName(path) {
|
|
15354
15338
|
const name = path.node.openingElement.name;
|
|
15355
|
-
return import_lib$
|
|
15339
|
+
return import_lib$1.isJSXIdentifier(name) ? name.name : "Builtin";
|
|
15356
15340
|
}
|
|
15357
15341
|
function isEventLikeProp(key) {
|
|
15358
15342
|
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
@@ -15371,7 +15355,7 @@ function lowerHost(path, context) {
|
|
|
15371
15355
|
const rawChildren = lowerChildren(path.get("children"), context);
|
|
15372
15356
|
for (const attrPath of path.get("openingElement").get("attributes")) {
|
|
15373
15357
|
const node = attrPath.node;
|
|
15374
|
-
if (import_lib$
|
|
15358
|
+
if (import_lib$1.isJSXSpreadAttribute(node)) throw new CompilerError({
|
|
15375
15359
|
code: CompilerErrorCode.UNSUPPORTED_COMPONENT_PROP,
|
|
15376
15360
|
message: "Spread props are not supported on Host in Phase 1.",
|
|
15377
15361
|
path: attrPath
|
|
@@ -15399,15 +15383,15 @@ function lowerHost(path, context) {
|
|
|
15399
15383
|
id: id(),
|
|
15400
15384
|
kind: "HostAttr",
|
|
15401
15385
|
name: normalizeHostAttrName(name),
|
|
15402
|
-
expr: import_lib$
|
|
15386
|
+
expr: import_lib$1.booleanLiteral(true)
|
|
15403
15387
|
});
|
|
15404
|
-
else if (import_lib$
|
|
15388
|
+
else if (import_lib$1.isStringLiteral(value)) attrs.push({
|
|
15405
15389
|
id: id(),
|
|
15406
15390
|
kind: "HostAttr",
|
|
15407
15391
|
name: normalizeHostAttrName(name),
|
|
15408
|
-
expr: import_lib$
|
|
15392
|
+
expr: import_lib$1.stringLiteral(value.value)
|
|
15409
15393
|
});
|
|
15410
|
-
else if (import_lib$
|
|
15394
|
+
else if (import_lib$1.isJSXExpressionContainer(value) && !import_lib$1.isJSXEmptyExpression(value.expression)) attrs.push({
|
|
15411
15395
|
id: id(),
|
|
15412
15396
|
kind: "HostAttr",
|
|
15413
15397
|
name: normalizeHostAttrName(name),
|
|
@@ -15426,7 +15410,7 @@ function lowerComponent(path, context) {
|
|
|
15426
15410
|
const props = [];
|
|
15427
15411
|
for (const attr of path.get("openingElement").get("attributes")) {
|
|
15428
15412
|
const node = attr.node;
|
|
15429
|
-
if (import_lib$
|
|
15413
|
+
if (import_lib$1.isJSXSpreadAttribute(node)) throw new CompilerError({
|
|
15430
15414
|
code: CompilerErrorCode.UNSUPPORTED_COMPONENT_PROP,
|
|
15431
15415
|
message: "Spread props are not supported in Zeus MVP.",
|
|
15432
15416
|
path: attr
|
|
@@ -15435,19 +15419,19 @@ function lowerComponent(path, context) {
|
|
|
15435
15419
|
if (!node.value) {
|
|
15436
15420
|
props.push({
|
|
15437
15421
|
name,
|
|
15438
|
-
value: import_lib$
|
|
15422
|
+
value: import_lib$1.booleanLiteral(true)
|
|
15439
15423
|
});
|
|
15440
15424
|
continue;
|
|
15441
15425
|
}
|
|
15442
|
-
if (import_lib$
|
|
15426
|
+
if (import_lib$1.isStringLiteral(node.value)) {
|
|
15443
15427
|
props.push({
|
|
15444
15428
|
name,
|
|
15445
15429
|
value: node.value
|
|
15446
15430
|
});
|
|
15447
15431
|
continue;
|
|
15448
15432
|
}
|
|
15449
|
-
if (import_lib$
|
|
15450
|
-
if (import_lib$
|
|
15433
|
+
if (import_lib$1.isJSXExpressionContainer(node.value)) {
|
|
15434
|
+
if (import_lib$1.isJSXEmptyExpression(node.value.expression)) throw new CompilerError({
|
|
15451
15435
|
code: CompilerErrorCode.EMPTY_EXPRESSION,
|
|
15452
15436
|
message: `Component prop "${name}" expression cannot be empty.`,
|
|
15453
15437
|
path: attr
|
|
@@ -15470,17 +15454,17 @@ function lowerComponent(path, context) {
|
|
|
15470
15454
|
});
|
|
15471
15455
|
}
|
|
15472
15456
|
function convertComponentIdentifier(node) {
|
|
15473
|
-
if (import_lib$
|
|
15474
|
-
if (node.name === "this") return import_lib$
|
|
15475
|
-
if (import_lib$
|
|
15476
|
-
return import_lib$
|
|
15457
|
+
if (import_lib$1.isJSXIdentifier(node)) {
|
|
15458
|
+
if (node.name === "this") return import_lib$1.thisExpression();
|
|
15459
|
+
if (import_lib$1.isValidIdentifier(node.name)) return import_lib$1.identifier(node.name);
|
|
15460
|
+
return import_lib$1.stringLiteral(node.name);
|
|
15477
15461
|
}
|
|
15478
|
-
if (import_lib$
|
|
15462
|
+
if (import_lib$1.isJSXMemberExpression(node)) {
|
|
15479
15463
|
const object = convertComponentIdentifier(node.object);
|
|
15480
15464
|
const property = convertComponentIdentifier(node.property);
|
|
15481
|
-
return import_lib$
|
|
15465
|
+
return import_lib$1.memberExpression(object, property, import_lib$1.isStringLiteral(property));
|
|
15482
15466
|
}
|
|
15483
|
-
if (import_lib$
|
|
15467
|
+
if (import_lib$1.isJSXNamespacedName(node)) return import_lib$1.stringLiteral(`${node.namespace.name}:${node.name.name}`);
|
|
15484
15468
|
return node;
|
|
15485
15469
|
}
|
|
15486
15470
|
//#endregion
|
|
@@ -15889,11 +15873,18 @@ function createVisitor(config) {
|
|
|
15889
15873
|
}
|
|
15890
15874
|
//#endregion
|
|
15891
15875
|
//#region packages/core/compiler/src/index.ts
|
|
15876
|
+
function hasParserPlugin(plugins, name) {
|
|
15877
|
+
return plugins.some((plugin) => (Array.isArray(plugin) ? plugin[0] : plugin) === name);
|
|
15878
|
+
}
|
|
15892
15879
|
var src_default = (0, import_lib.declare)((api, options) => {
|
|
15893
15880
|
api.assertVersion(7);
|
|
15894
15881
|
return {
|
|
15895
15882
|
name: "babel-plugin-zeus-compiler",
|
|
15896
|
-
|
|
15883
|
+
manipulateOptions(_opts, parserOpts) {
|
|
15884
|
+
var _parserOpts$plugins;
|
|
15885
|
+
(_parserOpts$plugins = parserOpts.plugins) !== null && _parserOpts$plugins !== void 0 || (parserOpts.plugins = []);
|
|
15886
|
+
if (!hasParserPlugin(parserOpts.plugins, "jsx")) parserOpts.plugins.push("jsx");
|
|
15887
|
+
},
|
|
15897
15888
|
visitor: createVisitor(resolveConfig(options))
|
|
15898
15889
|
};
|
|
15899
15890
|
});
|