@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
package/dist/compiler.global.js
CHANGED
|
@@ -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
|
**/
|
|
@@ -32,7 +32,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
32
32
|
}) : target, mod));
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region node_modules/.pnpm/@babel+helper-plugin-utils@7.29.7/node_modules/@babel/helper-plugin-utils/lib/index.js
|
|
35
|
-
var require_lib$
|
|
35
|
+
var require_lib$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.declare = declare;
|
|
38
38
|
exports.declarePreset = void 0;
|
|
@@ -85,22 +85,6 @@ var ZeusCompiler = (function(exports) {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
}));
|
|
88
|
-
//#endregion
|
|
89
|
-
//#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
|
|
90
|
-
var require_lib$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
91
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
-
exports.default = void 0;
|
|
93
|
-
exports.default = (0, require_lib$4().declare)((api) => {
|
|
94
|
-
api.assertVersion("^7.0.0-0 || ^8.0.0-0");
|
|
95
|
-
return {
|
|
96
|
-
name: "syntax-jsx",
|
|
97
|
-
manipulateOptions(opts, parserOpts) {
|
|
98
|
-
if (parserOpts.plugins.some((p) => (Array.isArray(p) ? p[0] : p) === "typescript")) return;
|
|
99
|
-
parserOpts.plugins.push("jsx");
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
}));
|
|
104
88
|
Object.freeze({});
|
|
105
89
|
Object.freeze([]);
|
|
106
90
|
const extend = Object.assign;
|
|
@@ -14163,9 +14147,8 @@ var ZeusCompiler = (function(exports) {
|
|
|
14163
14147
|
}));
|
|
14164
14148
|
//#endregion
|
|
14165
14149
|
//#region packages/core/compiler/src/codegen/support/imports.ts
|
|
14166
|
-
var import_lib = require_lib$
|
|
14167
|
-
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib
|
|
14168
|
-
var import_lib$2 = /* @__PURE__ */ __toESM(require_lib());
|
|
14150
|
+
var import_lib = require_lib$3();
|
|
14151
|
+
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib());
|
|
14169
14152
|
const DEFAULT_RENDERER_MODULE = "@zeus-js/runtime-dom";
|
|
14170
14153
|
function getImportKey(moduleName, imported) {
|
|
14171
14154
|
return `${moduleName}:${imported}`;
|
|
@@ -14183,14 +14166,14 @@ var ZeusCompiler = (function(exports) {
|
|
|
14183
14166
|
const importMethods = data.importMethods || (data.importMethods = /* @__PURE__ */ new Map());
|
|
14184
14167
|
const key = getImportKey(moduleName, imported);
|
|
14185
14168
|
const cached = importMethods.get(key);
|
|
14186
|
-
if (cached) return import_lib$
|
|
14169
|
+
if (cached) return import_lib$1.cloneNode(cached.local);
|
|
14187
14170
|
const local = getProgramPath(path).scope.generateUidIdentifier(imported);
|
|
14188
14171
|
importMethods.set(key, {
|
|
14189
14172
|
imported,
|
|
14190
14173
|
local,
|
|
14191
14174
|
moduleName
|
|
14192
14175
|
});
|
|
14193
|
-
return import_lib$
|
|
14176
|
+
return import_lib$1.cloneNode(local);
|
|
14194
14177
|
}
|
|
14195
14178
|
/**
|
|
14196
14179
|
* Generates import declarations for all collected runtime helpers and
|
|
@@ -14206,7 +14189,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14206
14189
|
else grouped.set(record.moduleName, [record]);
|
|
14207
14190
|
}
|
|
14208
14191
|
const declarations = [];
|
|
14209
|
-
for (const [moduleName, records] of grouped) declarations.push(import_lib$
|
|
14192
|
+
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)));
|
|
14210
14193
|
path.unshiftContainer("body", declarations);
|
|
14211
14194
|
}
|
|
14212
14195
|
function getProgramScopeData(path) {
|
|
@@ -14253,11 +14236,11 @@ var ZeusCompiler = (function(exports) {
|
|
|
14253
14236
|
};
|
|
14254
14237
|
const shouldUseImportNode = Boolean(template.isCE || template.isImportNode);
|
|
14255
14238
|
const isMathML = isMathMLTemplate(html);
|
|
14256
|
-
const args = [import_lib$
|
|
14257
|
-
if (template.isSVG || shouldUseImportNode || isMathML) args.push(import_lib$
|
|
14258
|
-
return import_lib$
|
|
14239
|
+
const args = [import_lib$1.templateLiteral([import_lib$1.templateElement(tmpl, true)], [])];
|
|
14240
|
+
if (template.isSVG || shouldUseImportNode || isMathML) args.push(import_lib$1.booleanLiteral(shouldUseImportNode), import_lib$1.booleanLiteral(Boolean(template.isSVG)), import_lib$1.booleanLiteral(isMathML));
|
|
14241
|
+
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__"));
|
|
14259
14242
|
});
|
|
14260
|
-
path.node.body.unshift(import_lib$
|
|
14243
|
+
path.node.body.unshift(import_lib$1.variableDeclaration("var", declarators));
|
|
14261
14244
|
}
|
|
14262
14245
|
//#endregion
|
|
14263
14246
|
//#region packages/core/compiler/src/codegen/support/events.ts
|
|
@@ -14287,7 +14270,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14287
14270
|
function appendEvents(path) {
|
|
14288
14271
|
const events = path.scope.data.events;
|
|
14289
14272
|
if (!(events === null || events === void 0 ? void 0 : events.size)) return;
|
|
14290
|
-
path.node.body.push(import_lib$
|
|
14273
|
+
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)))])));
|
|
14291
14274
|
}
|
|
14292
14275
|
//#endregion
|
|
14293
14276
|
//#region packages/core/compiler/src/config/index.ts
|
|
@@ -14408,7 +14391,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14408
14391
|
return statements;
|
|
14409
14392
|
}
|
|
14410
14393
|
function emitRawTextBinding(node, context) {
|
|
14411
|
-
return import_lib$
|
|
14394
|
+
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))]));
|
|
14412
14395
|
}
|
|
14413
14396
|
function hasRuntimeRawText$1(children) {
|
|
14414
14397
|
return children.some((child) => {
|
|
@@ -14420,15 +14403,15 @@ var ZeusCompiler = (function(exports) {
|
|
|
14420
14403
|
function emitRawTextValue(children) {
|
|
14421
14404
|
const values = children.flatMap((child) => {
|
|
14422
14405
|
switch (child.kind) {
|
|
14423
|
-
case "Text": return [import_lib$
|
|
14406
|
+
case "Text": return [import_lib$1.stringLiteral(child.value)];
|
|
14424
14407
|
case "DynamicText": return [child.expr];
|
|
14425
14408
|
case "Fragment": return [emitRawTextValue(child.children)];
|
|
14426
14409
|
default: return [];
|
|
14427
14410
|
}
|
|
14428
14411
|
});
|
|
14429
|
-
if (values.length === 0) return import_lib$
|
|
14412
|
+
if (values.length === 0) return import_lib$1.stringLiteral("");
|
|
14430
14413
|
if (values.length === 1) return values[0];
|
|
14431
|
-
return import_lib$
|
|
14414
|
+
return import_lib$1.arrayExpression(values);
|
|
14432
14415
|
}
|
|
14433
14416
|
function emitChildBinding(node, context) {
|
|
14434
14417
|
switch (node.kind) {
|
|
@@ -14444,12 +14427,12 @@ var ZeusCompiler = (function(exports) {
|
|
|
14444
14427
|
}
|
|
14445
14428
|
function emitAttrBinding(target, binding, context) {
|
|
14446
14429
|
const name = normalizeAttrName(binding.name);
|
|
14447
|
-
if (name === "class") return import_lib$
|
|
14448
|
-
if (name === "style") return import_lib$
|
|
14449
|
-
return import_lib$
|
|
14450
|
-
import_lib$
|
|
14451
|
-
import_lib$
|
|
14452
|
-
import_lib$
|
|
14430
|
+
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)]));
|
|
14431
|
+
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)]));
|
|
14432
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindAttr"), [
|
|
14433
|
+
import_lib$1.identifier(target.ref.name),
|
|
14434
|
+
import_lib$1.stringLiteral(name),
|
|
14435
|
+
import_lib$1.arrowFunctionExpression([], binding.expr)
|
|
14453
14436
|
]));
|
|
14454
14437
|
}
|
|
14455
14438
|
function normalizeAttrName(name) {
|
|
@@ -14457,45 +14440,45 @@ var ZeusCompiler = (function(exports) {
|
|
|
14457
14440
|
}
|
|
14458
14441
|
function emitEventBinding(target, binding, context) {
|
|
14459
14442
|
registerEvent(context.programPath, binding.eventName);
|
|
14460
|
-
return import_lib$
|
|
14461
|
-
import_lib$
|
|
14462
|
-
import_lib$
|
|
14443
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindEvent"), [
|
|
14444
|
+
import_lib$1.identifier(target.ref.name),
|
|
14445
|
+
import_lib$1.stringLiteral(binding.eventName),
|
|
14463
14446
|
normalizeEventHandler(binding.handler, context)
|
|
14464
14447
|
]));
|
|
14465
14448
|
}
|
|
14466
14449
|
function normalizeEventHandler(handler, context) {
|
|
14467
|
-
if (import_lib$
|
|
14450
|
+
if (import_lib$1.isMemberExpression(handler) || import_lib$1.isOptionalMemberExpression(handler)) {
|
|
14468
14451
|
const event = context.uid("event$");
|
|
14469
|
-
return import_lib$
|
|
14452
|
+
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));
|
|
14470
14453
|
}
|
|
14471
14454
|
return handler;
|
|
14472
14455
|
}
|
|
14473
14456
|
function emitPropBinding(target, binding, context) {
|
|
14474
|
-
return import_lib$
|
|
14475
|
-
import_lib$
|
|
14476
|
-
import_lib$
|
|
14477
|
-
import_lib$
|
|
14457
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindProp"), [
|
|
14458
|
+
import_lib$1.identifier(target.ref.name),
|
|
14459
|
+
import_lib$1.stringLiteral(binding.name),
|
|
14460
|
+
import_lib$1.arrowFunctionExpression([], binding.expr)
|
|
14478
14461
|
]));
|
|
14479
14462
|
}
|
|
14480
14463
|
function emitRefBinding(target, binding, context) {
|
|
14481
|
-
return import_lib$
|
|
14464
|
+
return import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindRef"), [import_lib$1.identifier(target.ref.name), binding.expr]));
|
|
14482
14465
|
}
|
|
14483
14466
|
function emitDynamicText(node, context) {
|
|
14484
14467
|
if (!node.domPath || node.domPath.kind !== "Marker") return [];
|
|
14485
14468
|
const textRef = context.uid("text$");
|
|
14486
|
-
if (node.once) return [import_lib$
|
|
14487
|
-
import_lib$
|
|
14469
|
+
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"), [
|
|
14470
|
+
import_lib$1.identifier(node.domPath.parent.name),
|
|
14488
14471
|
textRef,
|
|
14489
|
-
import_lib$
|
|
14472
|
+
import_lib$1.identifier(node.ref.name)
|
|
14490
14473
|
]))];
|
|
14491
14474
|
return [
|
|
14492
|
-
import_lib$
|
|
14493
|
-
import_lib$
|
|
14494
|
-
import_lib$
|
|
14475
|
+
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("")]))]),
|
|
14476
|
+
import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("insert"), [
|
|
14477
|
+
import_lib$1.identifier(node.domPath.parent.name),
|
|
14495
14478
|
textRef,
|
|
14496
|
-
import_lib$
|
|
14479
|
+
import_lib$1.identifier(node.ref.name)
|
|
14497
14480
|
])),
|
|
14498
|
-
import_lib$
|
|
14481
|
+
import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("bindText"), [textRef, import_lib$1.arrowFunctionExpression([], node.expr)]))
|
|
14499
14482
|
];
|
|
14500
14483
|
}
|
|
14501
14484
|
function emitComponentInsert(node, context) {
|
|
@@ -14503,24 +14486,24 @@ var ZeusCompiler = (function(exports) {
|
|
|
14503
14486
|
}
|
|
14504
14487
|
function emitMarkerInsert(node, context, value) {
|
|
14505
14488
|
if (!node.domPath || node.domPath.kind !== "Marker") return [];
|
|
14506
|
-
return [import_lib$
|
|
14507
|
-
import_lib$
|
|
14489
|
+
return [import_lib$1.expressionStatement(import_lib$1.callExpression(context.importRuntime("insert"), [
|
|
14490
|
+
import_lib$1.identifier(node.domPath.parent.name),
|
|
14508
14491
|
value,
|
|
14509
|
-
import_lib$
|
|
14492
|
+
import_lib$1.identifier(node.ref.name)
|
|
14510
14493
|
]))];
|
|
14511
14494
|
}
|
|
14512
14495
|
function emitMarkerMount(node, context, mountCall) {
|
|
14513
14496
|
if (!node.domPath || node.domPath.kind !== "Marker") return [];
|
|
14514
|
-
return [import_lib$
|
|
14497
|
+
return [import_lib$1.expressionStatement(mountCall)];
|
|
14515
14498
|
}
|
|
14516
14499
|
//#endregion
|
|
14517
14500
|
//#region packages/core/compiler/src/codegen/dom/emitDomPath.ts
|
|
14518
14501
|
function emitPhysicalDomPath(path) {
|
|
14519
14502
|
switch (path.kind) {
|
|
14520
14503
|
case "Root": throw new Error("Root path is emitted from template clone directly");
|
|
14521
|
-
case "FirstChild": return import_lib$
|
|
14522
|
-
case "NextSibling": return import_lib$
|
|
14523
|
-
case "ChildNode": return import_lib$
|
|
14504
|
+
case "FirstChild": return import_lib$1.memberExpression(import_lib$1.identifier(path.parent.name), import_lib$1.identifier("firstChild"));
|
|
14505
|
+
case "NextSibling": return import_lib$1.memberExpression(import_lib$1.identifier(path.previous.name), import_lib$1.identifier("nextSibling"));
|
|
14506
|
+
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);
|
|
14524
14507
|
}
|
|
14525
14508
|
}
|
|
14526
14509
|
//#endregion
|
|
@@ -14577,20 +14560,20 @@ var ZeusCompiler = (function(exports) {
|
|
|
14577
14560
|
function emitTemplateClone(node, context) {
|
|
14578
14561
|
const html = renderTemplateHTML(node);
|
|
14579
14562
|
const template = context.registerTemplate(html, node.flags.isSVG);
|
|
14580
|
-
const templateCall = import_lib$
|
|
14581
|
-
return import_lib$
|
|
14563
|
+
const templateCall = import_lib$1.callExpression(import_lib$1.cloneNode(template.id), []);
|
|
14564
|
+
return import_lib$1.memberExpression(templateCall, import_lib$1.identifier("firstChild"));
|
|
14582
14565
|
}
|
|
14583
14566
|
//#endregion
|
|
14584
14567
|
//#region packages/core/compiler/src/codegen/dom/emitElement.ts
|
|
14585
14568
|
function emitElement(node, context) {
|
|
14586
14569
|
if (!hasRuntimeWork(node)) return emitTemplateClone(node, context);
|
|
14587
14570
|
const statements = [
|
|
14588
|
-
import_lib$
|
|
14571
|
+
import_lib$1.variableDeclaration("const", [import_lib$1.variableDeclarator(import_lib$1.identifier(node.ref.name), emitTemplateClone(node, context))]),
|
|
14589
14572
|
...emitDomRefDeclarations(node.children, context),
|
|
14590
14573
|
...emitBindings(node, context),
|
|
14591
|
-
import_lib$
|
|
14574
|
+
import_lib$1.returnStatement(import_lib$1.identifier(node.ref.name))
|
|
14592
14575
|
];
|
|
14593
|
-
return import_lib$
|
|
14576
|
+
return import_lib$1.callExpression(import_lib$1.arrowFunctionExpression([], import_lib$1.blockStatement(statements)), []);
|
|
14594
14577
|
}
|
|
14595
14578
|
function emitDomRefDeclarations(children, context) {
|
|
14596
14579
|
const statements = [];
|
|
@@ -14676,7 +14659,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14676
14659
|
}
|
|
14677
14660
|
function createDomRefDeclaration(node, _context) {
|
|
14678
14661
|
if (!node.physicalDomPath) throw new Error(`${node.kind} physical DOM path is not assigned`);
|
|
14679
|
-
return import_lib$
|
|
14662
|
+
return import_lib$1.variableDeclaration("const", [import_lib$1.variableDeclarator(import_lib$1.identifier(node.ref.name), emitPhysicalDomPath(node.physicalDomPath))]);
|
|
14680
14663
|
}
|
|
14681
14664
|
function needsDomRefDeclaration(node) {
|
|
14682
14665
|
if (!node.physicalDomPath) return false;
|
|
@@ -14721,13 +14704,13 @@ var ZeusCompiler = (function(exports) {
|
|
|
14721
14704
|
//#endregion
|
|
14722
14705
|
//#region packages/core/compiler/src/codegen/dom/emitFragment.ts
|
|
14723
14706
|
function emitFragment(node, context) {
|
|
14724
|
-
return import_lib$
|
|
14707
|
+
return import_lib$1.arrayExpression(node.children.map((child) => emitDOM(child, context)));
|
|
14725
14708
|
}
|
|
14726
14709
|
//#endregion
|
|
14727
14710
|
//#region packages/core/compiler/src/codegen/dom/emitNodeExpression.ts
|
|
14728
14711
|
function emitNodeExpression(node, context) {
|
|
14729
14712
|
switch (node.kind) {
|
|
14730
|
-
case "Text": return import_lib$
|
|
14713
|
+
case "Text": return import_lib$1.stringLiteral(node.value);
|
|
14731
14714
|
case "DynamicText": return node.expr;
|
|
14732
14715
|
case "Element": return emitElement(node, context);
|
|
14733
14716
|
case "Component": return emitComponent(node, context);
|
|
@@ -14736,101 +14719,102 @@ var ZeusCompiler = (function(exports) {
|
|
|
14736
14719
|
case "For": return emitFor(node, context);
|
|
14737
14720
|
case "Host": return emitHost(node, context);
|
|
14738
14721
|
case "Slot": return emitSlot(node, context);
|
|
14739
|
-
default: return import_lib$
|
|
14722
|
+
default: return import_lib$1.nullLiteral();
|
|
14740
14723
|
}
|
|
14741
14724
|
}
|
|
14742
14725
|
//#endregion
|
|
14743
14726
|
//#region packages/core/compiler/src/codegen/dom/emitComponent.ts
|
|
14744
14727
|
function emitComponent(node, context) {
|
|
14745
|
-
const props = import_lib$
|
|
14746
|
-
return import_lib$
|
|
14728
|
+
const props = import_lib$1.objectExpression(node.props.map((prop) => emitComponentProp(prop, context)));
|
|
14729
|
+
return import_lib$1.callExpression(context.importRuntime("createComponent"), [node.callee, props]);
|
|
14747
14730
|
}
|
|
14748
14731
|
function emitComponentProp(prop, context) {
|
|
14749
14732
|
const key = createObjectKey$1(prop.name);
|
|
14750
|
-
if (Array.isArray(prop.value)) return import_lib$
|
|
14751
|
-
if (isStaticPropValue(prop.value)) return import_lib$
|
|
14752
|
-
return import_lib$
|
|
14733
|
+
if (Array.isArray(prop.value)) return import_lib$1.objectMethod("get", key, [], import_lib$1.blockStatement([import_lib$1.returnStatement(emitChildrenProp(prop.value, context))]));
|
|
14734
|
+
if (isStaticPropValue(prop.value)) return import_lib$1.objectProperty(key, prop.value);
|
|
14735
|
+
return import_lib$1.objectMethod("get", key, [], import_lib$1.blockStatement([import_lib$1.returnStatement(prop.value)]));
|
|
14753
14736
|
}
|
|
14754
14737
|
function emitChildrenProp(children, context) {
|
|
14755
14738
|
const nodes = children.map((child) => emitNodeExpression(child, context));
|
|
14756
14739
|
if (nodes.length === 1) return nodes[0];
|
|
14757
|
-
return import_lib$
|
|
14740
|
+
return import_lib$1.arrayExpression(nodes);
|
|
14758
14741
|
}
|
|
14759
14742
|
function isStaticPropValue(value) {
|
|
14760
|
-
return import_lib$
|
|
14743
|
+
return import_lib$1.isStringLiteral(value) || import_lib$1.isNumericLiteral(value) || import_lib$1.isBooleanLiteral(value) || import_lib$1.isNullLiteral(value);
|
|
14761
14744
|
}
|
|
14762
14745
|
function createObjectKey$1(key) {
|
|
14763
|
-
return import_lib$
|
|
14746
|
+
return import_lib$1.isValidIdentifier(key) ? import_lib$1.identifier(key) : import_lib$1.stringLiteral(key);
|
|
14764
14747
|
}
|
|
14765
14748
|
//#endregion
|
|
14766
14749
|
//#region packages/core/compiler/src/codegen/dom/emitBuiltin.ts
|
|
14767
14750
|
function emitShow(node, context) {
|
|
14768
|
-
const props = [import_lib$
|
|
14769
|
-
if (node.fallback) props.push(import_lib$
|
|
14770
|
-
return import_lib$
|
|
14751
|
+
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)))];
|
|
14752
|
+
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));
|
|
14753
|
+
return import_lib$1.callExpression(context.importRuntime("createComponent"), [context.importRuntime("Show"), import_lib$1.objectExpression(props)]);
|
|
14771
14754
|
}
|
|
14772
14755
|
function emitMountShow(node, context) {
|
|
14773
14756
|
const path = node.domPath;
|
|
14774
14757
|
if (!path || path.kind !== "Marker") throw new Error("Show DOM path is not assigned");
|
|
14775
|
-
return import_lib$
|
|
14776
|
-
import_lib$
|
|
14758
|
+
return import_lib$1.callExpression(context.importRuntime("mountShow"), [
|
|
14759
|
+
import_lib$1.identifier(path.parent.name),
|
|
14777
14760
|
emitMarkerIdentifier(node),
|
|
14778
|
-
import_lib$
|
|
14779
|
-
import_lib$
|
|
14780
|
-
node.fallback ? Array.isArray(node.fallback) ? import_lib$
|
|
14761
|
+
import_lib$1.arrowFunctionExpression([], node.when),
|
|
14762
|
+
import_lib$1.arrowFunctionExpression([], emitChildrenProp(node.children, context)),
|
|
14763
|
+
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")
|
|
14781
14764
|
]);
|
|
14782
14765
|
}
|
|
14783
14766
|
function emitFor(node, context) {
|
|
14784
14767
|
const params = [node.item];
|
|
14785
14768
|
if (node.index) params.push(node.index);
|
|
14786
|
-
const props = [import_lib$
|
|
14787
|
-
if (node.by) props.push(import_lib$
|
|
14788
|
-
return import_lib$
|
|
14769
|
+
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)))];
|
|
14770
|
+
if (node.by) props.push(import_lib$1.objectProperty(import_lib$1.identifier("by"), node.by));
|
|
14771
|
+
return import_lib$1.callExpression(context.importRuntime("createComponent"), [context.importRuntime("For"), import_lib$1.objectExpression(props)]);
|
|
14789
14772
|
}
|
|
14790
14773
|
function emitMountFor(node, context) {
|
|
14791
14774
|
var _node$by;
|
|
14792
14775
|
const params = [node.item];
|
|
14793
|
-
const path = node.domPath;
|
|
14794
14776
|
if (node.index) params.push(node.index);
|
|
14777
|
+
const path = node.domPath;
|
|
14795
14778
|
if (!path || path.kind !== "Marker") throw new Error("For DOM path is not assigned");
|
|
14796
|
-
return import_lib$
|
|
14797
|
-
import_lib$
|
|
14779
|
+
return import_lib$1.callExpression(context.importRuntime("mountFor"), [
|
|
14780
|
+
import_lib$1.identifier(path.parent.name),
|
|
14798
14781
|
emitMarkerIdentifier(node),
|
|
14799
|
-
import_lib$
|
|
14800
|
-
(_node$by = node.by) !== null && _node$by !== void 0 ? _node$by : import_lib$
|
|
14801
|
-
import_lib$
|
|
14782
|
+
import_lib$1.arrowFunctionExpression([], node.each),
|
|
14783
|
+
(_node$by = node.by) !== null && _node$by !== void 0 ? _node$by : import_lib$1.identifier("undefined"),
|
|
14784
|
+
import_lib$1.arrowFunctionExpression(params, emitChildrenProp(node.body, context))
|
|
14802
14785
|
]);
|
|
14803
14786
|
}
|
|
14804
14787
|
function emitHost(node, context) {
|
|
14805
14788
|
const props = buildHostProps(node, context);
|
|
14806
|
-
const
|
|
14807
|
-
if (!node.child) return
|
|
14789
|
+
const hostIdent = context.importRuntime("Host");
|
|
14790
|
+
if (!node.child) return import_lib$1.callExpression(hostIdent, [import_lib$1.objectExpression(props)]);
|
|
14808
14791
|
const childExpr = emitNodeExpression(node.child, context);
|
|
14809
|
-
|
|
14792
|
+
const hostCall = import_lib$1.callExpression(hostIdent, [import_lib$1.objectExpression(props)]);
|
|
14793
|
+
return import_lib$1.callExpression(import_lib$1.arrowFunctionExpression([], import_lib$1.blockStatement([import_lib$1.expressionStatement(hostCall), import_lib$1.returnStatement(childExpr)])), []);
|
|
14810
14794
|
}
|
|
14811
14795
|
function buildHostProps(node, context) {
|
|
14812
14796
|
const props = [];
|
|
14813
14797
|
for (const attr of node.attrs) {
|
|
14814
14798
|
const key = createObjectKey(attr.name);
|
|
14815
|
-
if (isStaticValue(attr.expr) || isGetterExpression(attr.expr)) props.push(import_lib$
|
|
14816
|
-
else props.push(import_lib$
|
|
14799
|
+
if (isStaticValue(attr.expr) || isGetterExpression(attr.expr)) props.push(import_lib$1.objectProperty(key, attr.expr));
|
|
14800
|
+
else props.push(import_lib$1.objectProperty(key, import_lib$1.arrowFunctionExpression([], attr.expr)));
|
|
14817
14801
|
}
|
|
14818
14802
|
return props;
|
|
14819
14803
|
}
|
|
14820
14804
|
function isStaticValue(expr) {
|
|
14821
|
-
return import_lib$
|
|
14805
|
+
return import_lib$1.isStringLiteral(expr) || import_lib$1.isNumericLiteral(expr) || import_lib$1.isBooleanLiteral(expr) || import_lib$1.isNullLiteral(expr);
|
|
14822
14806
|
}
|
|
14823
14807
|
function isGetterExpression(expr) {
|
|
14824
|
-
return import_lib$
|
|
14808
|
+
return import_lib$1.isArrowFunctionExpression(expr) || import_lib$1.isFunctionExpression(expr);
|
|
14825
14809
|
}
|
|
14826
14810
|
function createObjectKey(name) {
|
|
14827
|
-
return import_lib$
|
|
14811
|
+
return import_lib$1.isValidIdentifier(name) ? import_lib$1.identifier(name) : import_lib$1.stringLiteral(name);
|
|
14828
14812
|
}
|
|
14829
14813
|
function emitSlot(node, context) {
|
|
14830
|
-
return import_lib$
|
|
14814
|
+
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")]);
|
|
14831
14815
|
}
|
|
14832
14816
|
function emitMarkerIdentifier(node) {
|
|
14833
|
-
return import_lib$
|
|
14817
|
+
return import_lib$1.identifier(node.ref.name);
|
|
14834
14818
|
}
|
|
14835
14819
|
//#endregion
|
|
14836
14820
|
//#region packages/core/compiler/src/codegen/dom/index.ts
|
|
@@ -14843,7 +14827,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14843
14827
|
case "For": return emitFor(node, context);
|
|
14844
14828
|
case "Host": return emitHost(node, context);
|
|
14845
14829
|
case "Slot": return emitSlot(node, context);
|
|
14846
|
-
case "DynamicText": return import_lib$
|
|
14830
|
+
case "DynamicText": return import_lib$1.arrowFunctionExpression([], node.expr);
|
|
14847
14831
|
default: throw new Error(`Unsupported root IR node: ${node.kind}`);
|
|
14848
14832
|
}
|
|
14849
14833
|
}
|
|
@@ -14867,14 +14851,14 @@ var ZeusCompiler = (function(exports) {
|
|
|
14867
14851
|
const importMethods = scopeData.importMethods || (scopeData.importMethods = /* @__PURE__ */ new Map());
|
|
14868
14852
|
const key = `${moduleName}:${imported}`;
|
|
14869
14853
|
const cached = importMethods.get(key);
|
|
14870
|
-
if (cached) return import_lib$
|
|
14854
|
+
if (cached) return import_lib$1.cloneNode(cached.local);
|
|
14871
14855
|
const local = this.uid(imported);
|
|
14872
14856
|
importMethods.set(key, {
|
|
14873
14857
|
moduleName,
|
|
14874
14858
|
imported,
|
|
14875
14859
|
local
|
|
14876
14860
|
});
|
|
14877
|
-
return import_lib$
|
|
14861
|
+
return import_lib$1.cloneNode(local);
|
|
14878
14862
|
}
|
|
14879
14863
|
registerTemplate(html, isSVG = false) {
|
|
14880
14864
|
const scopeData = this.programPath.scope.data;
|
|
@@ -14882,7 +14866,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14882
14866
|
const templates = scopeData.templates || (scopeData.templates = []);
|
|
14883
14867
|
const cached = templateMap.get(html);
|
|
14884
14868
|
if (cached) return {
|
|
14885
|
-
id: import_lib$
|
|
14869
|
+
id: import_lib$1.cloneNode(cached.id),
|
|
14886
14870
|
html,
|
|
14887
14871
|
isSVG: Boolean(cached.isSVG)
|
|
14888
14872
|
};
|
|
@@ -14898,7 +14882,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
14898
14882
|
});
|
|
14899
14883
|
templates.push(templateMap.get(html));
|
|
14900
14884
|
return {
|
|
14901
|
-
id: import_lib$
|
|
14885
|
+
id: import_lib$1.cloneNode(id),
|
|
14902
14886
|
html,
|
|
14903
14887
|
isSVG
|
|
14904
14888
|
};
|
|
@@ -15145,15 +15129,15 @@ var ZeusCompiler = (function(exports) {
|
|
|
15145
15129
|
* These do NOT produce IR or Babel AST; they only read the JSX tree.
|
|
15146
15130
|
*/
|
|
15147
15131
|
function jsxElementNameToString(node) {
|
|
15148
|
-
if (import_lib$
|
|
15149
|
-
if (import_lib$
|
|
15132
|
+
if (import_lib$1.isJSXMemberExpression(node)) return `${jsxElementNameToString(node.object)}.${node.property.name}`;
|
|
15133
|
+
if (import_lib$1.isJSXIdentifier(node) || import_lib$1.isIdentifier(node)) return node.name;
|
|
15150
15134
|
return `${node.namespace.name}:${node.name.name}`;
|
|
15151
15135
|
}
|
|
15152
15136
|
function getTagName(node) {
|
|
15153
15137
|
return jsxElementNameToString(node.openingElement.name);
|
|
15154
15138
|
}
|
|
15155
15139
|
function getJSXAttrName(name) {
|
|
15156
|
-
if (import_lib$
|
|
15140
|
+
if (import_lib$1.isJSXNamespacedName(name)) return `${name.namespace.name}:${name.name.name}`;
|
|
15157
15141
|
return name.name;
|
|
15158
15142
|
}
|
|
15159
15143
|
function isComponentTag(tagName) {
|
|
@@ -15165,7 +15149,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15165
15149
|
//#endregion
|
|
15166
15150
|
//#region packages/core/compiler/src/lower/lowerAttribute.ts
|
|
15167
15151
|
function lowerAttribute(path, _context) {
|
|
15168
|
-
if (path.isJSXSpreadAttribute() || import_lib$
|
|
15152
|
+
if (path.isJSXSpreadAttribute() || import_lib$1.isJSXSpreadAttribute(path.node)) throw new CompilerError({
|
|
15169
15153
|
code: CompilerErrorCode.UNSUPPORTED_SPREAD_ATTRIBUTE,
|
|
15170
15154
|
message: "Spread attributes are not supported in Zeus MVP.",
|
|
15171
15155
|
path,
|
|
@@ -15183,7 +15167,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15183
15167
|
});
|
|
15184
15168
|
return staticAttrIR(name, true);
|
|
15185
15169
|
}
|
|
15186
|
-
if (import_lib$
|
|
15170
|
+
if (import_lib$1.isStringLiteral(value)) {
|
|
15187
15171
|
if (name === "ref") throw new CompilerError({
|
|
15188
15172
|
code: CompilerErrorCode.INVALID_REF_USAGE,
|
|
15189
15173
|
message: "String refs are not supported in Zeus.",
|
|
@@ -15192,9 +15176,9 @@ var ZeusCompiler = (function(exports) {
|
|
|
15192
15176
|
});
|
|
15193
15177
|
return staticAttrIR(name, value.value);
|
|
15194
15178
|
}
|
|
15195
|
-
if (import_lib$
|
|
15179
|
+
if (import_lib$1.isJSXExpressionContainer(value)) {
|
|
15196
15180
|
const expr = value.expression;
|
|
15197
|
-
if (import_lib$
|
|
15181
|
+
if (import_lib$1.isJSXEmptyExpression(expr)) throw new CompilerError({
|
|
15198
15182
|
code: CompilerErrorCode.EMPTY_EXPRESSION,
|
|
15199
15183
|
message: `Attribute "${name}" expression cannot be empty.`,
|
|
15200
15184
|
path
|
|
@@ -15218,8 +15202,8 @@ var ZeusCompiler = (function(exports) {
|
|
|
15218
15202
|
}
|
|
15219
15203
|
if (child.isJSXExpressionContainer()) {
|
|
15220
15204
|
const expr = child.node.expression;
|
|
15221
|
-
if (import_lib$
|
|
15222
|
-
if (import_lib$
|
|
15205
|
+
if (import_lib$1.isJSXEmptyExpression(expr)) continue;
|
|
15206
|
+
if (import_lib$1.isExpression(expr)) result.push(dynamicTextIR(expr, ref(context.uid("anchor$").name)));
|
|
15223
15207
|
continue;
|
|
15224
15208
|
}
|
|
15225
15209
|
if (child.isJSXElement() || child.isJSXFragment()) {
|
|
@@ -15241,7 +15225,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15241
15225
|
}
|
|
15242
15226
|
function lowerBuiltin(path, context) {
|
|
15243
15227
|
const tagName = path.node.openingElement.name;
|
|
15244
|
-
if (!import_lib$
|
|
15228
|
+
if (!import_lib$1.isJSXIdentifier(tagName)) throw new CompilerError({
|
|
15245
15229
|
code: CompilerErrorCode.INVALID_BUILTIN_USAGE,
|
|
15246
15230
|
message: "Built-in JSX nodes do not support member expressions.",
|
|
15247
15231
|
path
|
|
@@ -15275,7 +15259,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15275
15259
|
});
|
|
15276
15260
|
if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
|
|
15277
15261
|
const value = attr.get("value");
|
|
15278
|
-
if (!value.node) return import_lib$
|
|
15262
|
+
if (!value.node) return import_lib$1.booleanLiteral(true);
|
|
15279
15263
|
if (value.isStringLiteral()) return value.node;
|
|
15280
15264
|
if (!value.isJSXExpressionContainer()) return void 0;
|
|
15281
15265
|
const expression = value.get("expression");
|
|
@@ -15288,7 +15272,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15288
15272
|
const each = requiredExpressionAttr(path, "each");
|
|
15289
15273
|
const by = optionalExpressionAttr(path, "by");
|
|
15290
15274
|
const render = getOnlyRenderFunction(path);
|
|
15291
|
-
const item = (_getParamIdentifier = getParamIdentifier(render, 0)) !== null && _getParamIdentifier !== void 0 ? _getParamIdentifier : import_lib$
|
|
15275
|
+
const item = (_getParamIdentifier = getParamIdentifier(render, 0)) !== null && _getParamIdentifier !== void 0 ? _getParamIdentifier : import_lib$1.identifier("item");
|
|
15292
15276
|
const index = getParamIdentifier(render, 1);
|
|
15293
15277
|
const bodyPath = render.get("body");
|
|
15294
15278
|
const body = [];
|
|
@@ -15327,9 +15311,9 @@ var ZeusCompiler = (function(exports) {
|
|
|
15327
15311
|
});
|
|
15328
15312
|
if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
|
|
15329
15313
|
const value = attr.node.value;
|
|
15330
|
-
if (!value) return import_lib$
|
|
15331
|
-
if (import_lib$
|
|
15332
|
-
if (import_lib$
|
|
15314
|
+
if (!value) return import_lib$1.booleanLiteral(true);
|
|
15315
|
+
if (import_lib$1.isStringLiteral(value)) return value;
|
|
15316
|
+
if (import_lib$1.isJSXExpressionContainer(value) && !import_lib$1.isJSXEmptyExpression(value.expression)) return value.expression;
|
|
15333
15317
|
}
|
|
15334
15318
|
function optionalStringAttr(path, name) {
|
|
15335
15319
|
const attr = path.get("openingElement").get("attributes").find((attrPath) => {
|
|
@@ -15339,7 +15323,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15339
15323
|
if (!(attr === null || attr === void 0 ? void 0 : attr.isJSXAttribute())) return void 0;
|
|
15340
15324
|
const value = attr.node.value;
|
|
15341
15325
|
if (!value) return "";
|
|
15342
|
-
if (import_lib$
|
|
15326
|
+
if (import_lib$1.isStringLiteral(value)) return value.value;
|
|
15343
15327
|
}
|
|
15344
15328
|
function getOnlyRenderFunction(path) {
|
|
15345
15329
|
const expressions = path.get("children").filter((child) => child.isJSXExpressionContainer()).map((child) => child.get("expression")).filter((expression) => expression.isArrowFunctionExpression() || expression.isFunctionExpression());
|
|
@@ -15352,12 +15336,12 @@ var ZeusCompiler = (function(exports) {
|
|
|
15352
15336
|
}
|
|
15353
15337
|
function getParamIdentifier(path, index, fallback) {
|
|
15354
15338
|
const param = path.node.params[index];
|
|
15355
|
-
if (import_lib$
|
|
15356
|
-
if (fallback) return import_lib$
|
|
15339
|
+
if (import_lib$1.isIdentifier(param)) return param;
|
|
15340
|
+
if (fallback) return import_lib$1.identifier(fallback);
|
|
15357
15341
|
}
|
|
15358
15342
|
function getBuiltinName(path) {
|
|
15359
15343
|
const name = path.node.openingElement.name;
|
|
15360
|
-
return import_lib$
|
|
15344
|
+
return import_lib$1.isJSXIdentifier(name) ? name.name : "Builtin";
|
|
15361
15345
|
}
|
|
15362
15346
|
function isEventLikeProp(key) {
|
|
15363
15347
|
return /^on[A-Z]/.test(key) || key.startsWith("on:");
|
|
@@ -15376,7 +15360,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15376
15360
|
const rawChildren = lowerChildren(path.get("children"), context);
|
|
15377
15361
|
for (const attrPath of path.get("openingElement").get("attributes")) {
|
|
15378
15362
|
const node = attrPath.node;
|
|
15379
|
-
if (import_lib$
|
|
15363
|
+
if (import_lib$1.isJSXSpreadAttribute(node)) throw new CompilerError({
|
|
15380
15364
|
code: CompilerErrorCode.UNSUPPORTED_COMPONENT_PROP,
|
|
15381
15365
|
message: "Spread props are not supported on Host in Phase 1.",
|
|
15382
15366
|
path: attrPath
|
|
@@ -15404,15 +15388,15 @@ var ZeusCompiler = (function(exports) {
|
|
|
15404
15388
|
id: id(),
|
|
15405
15389
|
kind: "HostAttr",
|
|
15406
15390
|
name: normalizeHostAttrName(name),
|
|
15407
|
-
expr: import_lib$
|
|
15391
|
+
expr: import_lib$1.booleanLiteral(true)
|
|
15408
15392
|
});
|
|
15409
|
-
else if (import_lib$
|
|
15393
|
+
else if (import_lib$1.isStringLiteral(value)) attrs.push({
|
|
15410
15394
|
id: id(),
|
|
15411
15395
|
kind: "HostAttr",
|
|
15412
15396
|
name: normalizeHostAttrName(name),
|
|
15413
|
-
expr: import_lib$
|
|
15397
|
+
expr: import_lib$1.stringLiteral(value.value)
|
|
15414
15398
|
});
|
|
15415
|
-
else if (import_lib$
|
|
15399
|
+
else if (import_lib$1.isJSXExpressionContainer(value) && !import_lib$1.isJSXEmptyExpression(value.expression)) attrs.push({
|
|
15416
15400
|
id: id(),
|
|
15417
15401
|
kind: "HostAttr",
|
|
15418
15402
|
name: normalizeHostAttrName(name),
|
|
@@ -15431,7 +15415,7 @@ var ZeusCompiler = (function(exports) {
|
|
|
15431
15415
|
const props = [];
|
|
15432
15416
|
for (const attr of path.get("openingElement").get("attributes")) {
|
|
15433
15417
|
const node = attr.node;
|
|
15434
|
-
if (import_lib$
|
|
15418
|
+
if (import_lib$1.isJSXSpreadAttribute(node)) throw new CompilerError({
|
|
15435
15419
|
code: CompilerErrorCode.UNSUPPORTED_COMPONENT_PROP,
|
|
15436
15420
|
message: "Spread props are not supported in Zeus MVP.",
|
|
15437
15421
|
path: attr
|
|
@@ -15440,19 +15424,19 @@ var ZeusCompiler = (function(exports) {
|
|
|
15440
15424
|
if (!node.value) {
|
|
15441
15425
|
props.push({
|
|
15442
15426
|
name,
|
|
15443
|
-
value: import_lib$
|
|
15427
|
+
value: import_lib$1.booleanLiteral(true)
|
|
15444
15428
|
});
|
|
15445
15429
|
continue;
|
|
15446
15430
|
}
|
|
15447
|
-
if (import_lib$
|
|
15431
|
+
if (import_lib$1.isStringLiteral(node.value)) {
|
|
15448
15432
|
props.push({
|
|
15449
15433
|
name,
|
|
15450
15434
|
value: node.value
|
|
15451
15435
|
});
|
|
15452
15436
|
continue;
|
|
15453
15437
|
}
|
|
15454
|
-
if (import_lib$
|
|
15455
|
-
if (import_lib$
|
|
15438
|
+
if (import_lib$1.isJSXExpressionContainer(node.value)) {
|
|
15439
|
+
if (import_lib$1.isJSXEmptyExpression(node.value.expression)) throw new CompilerError({
|
|
15456
15440
|
code: CompilerErrorCode.EMPTY_EXPRESSION,
|
|
15457
15441
|
message: `Component prop "${name}" expression cannot be empty.`,
|
|
15458
15442
|
path: attr
|
|
@@ -15475,17 +15459,17 @@ var ZeusCompiler = (function(exports) {
|
|
|
15475
15459
|
});
|
|
15476
15460
|
}
|
|
15477
15461
|
function convertComponentIdentifier(node) {
|
|
15478
|
-
if (import_lib$
|
|
15479
|
-
if (node.name === "this") return import_lib$
|
|
15480
|
-
if (import_lib$
|
|
15481
|
-
return import_lib$
|
|
15462
|
+
if (import_lib$1.isJSXIdentifier(node)) {
|
|
15463
|
+
if (node.name === "this") return import_lib$1.thisExpression();
|
|
15464
|
+
if (import_lib$1.isValidIdentifier(node.name)) return import_lib$1.identifier(node.name);
|
|
15465
|
+
return import_lib$1.stringLiteral(node.name);
|
|
15482
15466
|
}
|
|
15483
|
-
if (import_lib$
|
|
15467
|
+
if (import_lib$1.isJSXMemberExpression(node)) {
|
|
15484
15468
|
const object = convertComponentIdentifier(node.object);
|
|
15485
15469
|
const property = convertComponentIdentifier(node.property);
|
|
15486
|
-
return import_lib$
|
|
15470
|
+
return import_lib$1.memberExpression(object, property, import_lib$1.isStringLiteral(property));
|
|
15487
15471
|
}
|
|
15488
|
-
if (import_lib$
|
|
15472
|
+
if (import_lib$1.isJSXNamespacedName(node)) return import_lib$1.stringLiteral(`${node.namespace.name}:${node.name.name}`);
|
|
15489
15473
|
return node;
|
|
15490
15474
|
}
|
|
15491
15475
|
//#endregion
|
|
@@ -15893,11 +15877,20 @@ var ZeusCompiler = (function(exports) {
|
|
|
15893
15877
|
};
|
|
15894
15878
|
}
|
|
15895
15879
|
//#endregion
|
|
15880
|
+
//#region packages/core/compiler/src/index.ts
|
|
15881
|
+
function hasParserPlugin(plugins, name) {
|
|
15882
|
+
return plugins.some((plugin) => (Array.isArray(plugin) ? plugin[0] : plugin) === name);
|
|
15883
|
+
}
|
|
15884
|
+
//#endregion
|
|
15896
15885
|
exports.default = (0, import_lib.declare)((api, options) => {
|
|
15897
15886
|
api.assertVersion(7);
|
|
15898
15887
|
return {
|
|
15899
15888
|
name: "babel-plugin-zeus-compiler",
|
|
15900
|
-
|
|
15889
|
+
manipulateOptions(_opts, parserOpts) {
|
|
15890
|
+
var _parserOpts$plugins;
|
|
15891
|
+
(_parserOpts$plugins = parserOpts.plugins) !== null && _parserOpts$plugins !== void 0 || (parserOpts.plugins = []);
|
|
15892
|
+
if (!hasParserPlugin(parserOpts.plugins, "jsx")) parserOpts.plugins.push("jsx");
|
|
15893
|
+
},
|
|
15901
15894
|
visitor: createVisitor(resolveConfig(options))
|
|
15902
15895
|
};
|
|
15903
15896
|
});
|