@zeus-js/compiler 0.1.0 → 0.1.1-beta.0

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * compiler v0.1.0
2
+ * compiler v0.1.1-beta.0
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -5743,6 +5743,7 @@ var ZeusCompiler = (function(exports) {
5743
5743
  }
5744
5744
  //#endregion
5745
5745
  //#region packages/core/compiler/src/config/index.ts
5746
+ const DEFAULT_SSR_RENDERER_MODULE = "@zeus-js/runtime-ssr";
5746
5747
  const DEFAULT_OPTIONS = {
5747
5748
  moduleName: DEFAULT_RENDERER_MODULE,
5748
5749
  generate: "dom",
@@ -5767,7 +5768,9 @@ var ZeusCompiler = (function(exports) {
5767
5768
  * @returns The resolved compiler options.
5768
5769
  */
5769
5770
  function resolveConfig(options) {
5770
- return extend(DEFAULT_OPTIONS, options);
5771
+ const config = extend({}, DEFAULT_OPTIONS, options);
5772
+ if (config.generate === "ssr" && (options === null || options === void 0 ? void 0 : options.moduleName) === void 0) config.moduleName = DEFAULT_SSR_RENDERER_MODULE;
5773
+ return config;
5771
5774
  }
5772
5775
  //#endregion
5773
5776
  //#region packages/core/compiler/src/context/CompilerContext.ts
@@ -5962,8 +5965,10 @@ var ZeusCompiler = (function(exports) {
5962
5965
  }
5963
5966
  function exitProgram(config, path, state) {
5964
5967
  if (state.get("skip")) return;
5965
- appendTemplates(path);
5966
- appendEvents(path);
5968
+ if (config.generate === "dom") {
5969
+ appendTemplates(path);
5970
+ if (config.delegateEvents) appendEvents(path);
5971
+ }
5967
5972
  appendImportMethods(path);
5968
5973
  }
5969
5974
  function createProgramVisitor(config) {
@@ -18324,19 +18329,18 @@ var ZeusCompiler = (function(exports) {
18324
18329
  }
18325
18330
  function elementIR(input) {
18326
18331
  var _input$attrs, _input$children;
18327
- return {
18332
+ return _objectSpread2(_objectSpread2({
18328
18333
  id: id(),
18329
18334
  kind: "Element",
18330
18335
  ref: input.ref,
18331
18336
  tagName: input.tagName,
18332
18337
  attrs: (_input$attrs = input.attrs) !== null && _input$attrs !== void 0 ? _input$attrs : [],
18333
- children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : [],
18334
- flags: _objectSpread2({
18335
- isSVG: false,
18336
- isVoid: false,
18337
- isCustomElement: input.tagName.includes("-")
18338
- }, input.flags)
18339
- };
18338
+ children: (_input$children = input.children) !== null && _input$children !== void 0 ? _input$children : []
18339
+ }, input.span === void 0 ? {} : { span: input.span }), {}, { flags: _objectSpread2({
18340
+ isSVG: false,
18341
+ isVoid: false,
18342
+ isCustomElement: input.tagName.includes("-")
18343
+ }, input.flags) });
18340
18344
  }
18341
18345
  function textIR(value) {
18342
18346
  return {
@@ -18401,13 +18405,13 @@ var ZeusCompiler = (function(exports) {
18401
18405
  };
18402
18406
  }
18403
18407
  function componentIR(input) {
18404
- return {
18408
+ return _objectSpread2({
18405
18409
  id: id(),
18406
18410
  kind: "Component",
18407
18411
  ref: input.ref,
18408
18412
  callee: input.callee,
18409
18413
  props: input.props
18410
- };
18414
+ }, input.span === void 0 ? {} : { span: input.span });
18411
18415
  }
18412
18416
  function showIR(input) {
18413
18417
  return {
@@ -18636,7 +18640,7 @@ var ZeusCompiler = (function(exports) {
18636
18640
  ];
18637
18641
  }
18638
18642
  function emitComponentInsert(node, context) {
18639
- return emitMarkerInsert(node, context, emitComponent(node, context));
18643
+ return emitMarkerInsert(node, context, emitComponent$1(node, context));
18640
18644
  }
18641
18645
  function emitMarkerInsert(node, context, value) {
18642
18646
  if (!node.domPath || node.domPath.kind !== "Marker") return [];
@@ -18717,7 +18721,7 @@ var ZeusCompiler = (function(exports) {
18717
18721
  }
18718
18722
  //#endregion
18719
18723
  //#region packages/core/compiler/src/codegen/dom/emitElement.ts
18720
- function emitElement(node, context) {
18724
+ function emitElement$1(node, context) {
18721
18725
  if (!hasRuntimeWork(node)) return emitTemplateClone(node, context);
18722
18726
  return callExpression(arrowFunctionExpression([], blockStatement([
18723
18727
  variableDeclaration("const", [variableDeclarator(identifier(node.ref.name), emitTemplateClone(node, context))]),
@@ -18863,11 +18867,11 @@ var ZeusCompiler = (function(exports) {
18863
18867
  switch (node.kind) {
18864
18868
  case "Text": return stringLiteral(node.value);
18865
18869
  case "DynamicText": return parseExpressionIR(node.expr);
18866
- case "Element": return emitElement(node, context);
18867
- case "Component": return emitComponent(node, context);
18870
+ case "Element": return emitElement$1(node, context);
18871
+ case "Component": return emitComponent$1(node, context);
18868
18872
  case "Fragment": return emitFragment(node, context);
18869
- case "Show": return emitShow(node, context);
18870
- case "For": return emitFor(node, context);
18873
+ case "Show": return emitShow$1(node, context);
18874
+ case "For": return emitFor$1(node, context);
18871
18875
  case "Host": return emitHost(node, context);
18872
18876
  case "Slot": return emitSlot(node, context);
18873
18877
  default: return nullLiteral();
@@ -18875,15 +18879,15 @@ var ZeusCompiler = (function(exports) {
18875
18879
  }
18876
18880
  //#endregion
18877
18881
  //#region packages/core/compiler/src/codegen/dom/emitComponent.ts
18878
- function emitComponent(node, context) {
18879
- const props = objectExpression(node.props.map((prop) => emitComponentProp(prop, context)));
18882
+ function emitComponent$1(node, context) {
18883
+ const props = objectExpression(node.props.map((prop) => emitComponentProp$1(prop, context)));
18880
18884
  return callExpression(context.importRuntime("createComponent"), [parseExpressionIR(node.callee), props]);
18881
18885
  }
18882
- function emitComponentProp(prop, context) {
18883
- const key = createObjectKey$1(prop.name);
18886
+ function emitComponentProp$1(prop, context) {
18887
+ const key = createObjectKey$2(prop.name);
18884
18888
  if (Array.isArray(prop.value)) return objectMethod("get", key, [], blockStatement([returnStatement(emitChildrenProp(prop.value, context))]));
18885
18889
  const value = parseExpressionIR(prop.value);
18886
- if (isStaticPropValue(value)) return objectProperty(key, value);
18890
+ if (isStaticPropValue$1(value)) return objectProperty(key, value);
18887
18891
  return objectMethod("get", key, [], blockStatement([returnStatement(value)]));
18888
18892
  }
18889
18893
  function emitChildrenProp(children, context) {
@@ -18891,15 +18895,15 @@ var ZeusCompiler = (function(exports) {
18891
18895
  if (nodes.length === 1) return nodes[0];
18892
18896
  return arrayExpression(nodes);
18893
18897
  }
18894
- function isStaticPropValue(value) {
18898
+ function isStaticPropValue$1(value) {
18895
18899
  return isStringLiteral(value) || isNumericLiteral(value) || isBooleanLiteral(value) || isNullLiteral(value);
18896
18900
  }
18897
- function createObjectKey$1(key) {
18901
+ function createObjectKey$2(key) {
18898
18902
  return isValidIdentifier(key) ? identifier(key) : stringLiteral(key);
18899
18903
  }
18900
18904
  //#endregion
18901
18905
  //#region packages/core/compiler/src/codegen/dom/emitBuiltin.ts
18902
- function emitShow(node, context) {
18906
+ function emitShow$1(node, context) {
18903
18907
  const props = [objectProperty(identifier("when"), parseExpressionIR(node.when)), objectProperty(identifier("children"), arrowFunctionExpression([], emitChildrenProp(node.children, context)))];
18904
18908
  if (node.fallback) props.push(objectProperty(identifier("fallback"), Array.isArray(node.fallback) ? arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : parseExpressionIR(node.fallback)));
18905
18909
  return callExpression(context.importRuntime("createComponent"), [context.importRuntime("Show"), objectExpression(props)]);
@@ -18915,7 +18919,7 @@ var ZeusCompiler = (function(exports) {
18915
18919
  node.fallback ? Array.isArray(node.fallback) ? arrowFunctionExpression([], emitChildrenProp(node.fallback, context)) : arrowFunctionExpression([], parseExpressionIR(node.fallback)) : identifier("undefined")
18916
18920
  ]);
18917
18921
  }
18918
- function emitFor(node, context) {
18922
+ function emitFor$1(node, context) {
18919
18923
  const params = [identifier(node.item.name)];
18920
18924
  if (node.index) params.push(identifier(node.index.name));
18921
18925
  const props = [objectProperty(identifier("each"), parseExpressionIR(node.each)), objectProperty(identifier("children"), arrowFunctionExpression(params, emitChildrenProp(node.body, context)))];
@@ -18945,7 +18949,7 @@ var ZeusCompiler = (function(exports) {
18945
18949
  function buildHostProps(node, context) {
18946
18950
  const props = [];
18947
18951
  for (const attr of node.attrs) {
18948
- const key = createObjectKey(attr.name);
18952
+ const key = createObjectKey$1(attr.name);
18949
18953
  const expression = parseExpressionIR(attr.expr);
18950
18954
  if (isStaticValue(expression) || isGetterExpression(expression)) props.push(objectProperty(key, expression));
18951
18955
  else props.push(objectProperty(key, arrowFunctionExpression([], expression)));
@@ -18958,7 +18962,7 @@ var ZeusCompiler = (function(exports) {
18958
18962
  function isGetterExpression(expr) {
18959
18963
  return isArrowFunctionExpression(expr) || isFunctionExpression(expr);
18960
18964
  }
18961
- function createObjectKey(name) {
18965
+ function createObjectKey$1(name) {
18962
18966
  return isValidIdentifier(name) ? identifier(name) : stringLiteral(name);
18963
18967
  }
18964
18968
  function emitSlot(node, context) {
@@ -18971,11 +18975,11 @@ var ZeusCompiler = (function(exports) {
18971
18975
  //#region packages/core/compiler/src/codegen/dom/index.ts
18972
18976
  function emitDOM(node, context) {
18973
18977
  switch (node.kind) {
18974
- case "Element": return emitElement(node, context);
18978
+ case "Element": return emitElement$1(node, context);
18975
18979
  case "Fragment": return emitFragment(node, context);
18976
- case "Component": return emitComponent(node, context);
18977
- case "Show": return emitShow(node, context);
18978
- case "For": return emitFor(node, context);
18980
+ case "Component": return emitComponent$1(node, context);
18981
+ case "Show": return emitShow$1(node, context);
18982
+ case "For": return emitFor$1(node, context);
18979
18983
  case "Host": return emitHost(node, context);
18980
18984
  case "Slot": return emitSlot(node, context);
18981
18985
  case "DynamicText": return arrowFunctionExpression([], parseExpressionIR(node.expr));
@@ -18983,6 +18987,43 @@ var ZeusCompiler = (function(exports) {
18983
18987
  }
18984
18988
  }
18985
18989
  //#endregion
18990
+ //#region packages/core/compiler/src/codegen/ssr/rawText.ts
18991
+ function getSSRRawTextTag(tagName) {
18992
+ const normalized = tagName.toLowerCase();
18993
+ return normalized === "script" || normalized === "style" ? normalized : void 0;
18994
+ }
18995
+ //#endregion
18996
+ //#region packages/core/compiler/src/codegen/ssr/property.ts
18997
+ const BOOLEAN_PROPERTY_ELEMENTS = {
18998
+ checked: /* @__PURE__ */ new Set(["input"]),
18999
+ disabled: /* @__PURE__ */ new Set([
19000
+ "button",
19001
+ "fieldset",
19002
+ "input",
19003
+ "optgroup",
19004
+ "option",
19005
+ "select",
19006
+ "textarea"
19007
+ ]),
19008
+ multiple: /* @__PURE__ */ new Set(["input", "select"]),
19009
+ readOnly: /* @__PURE__ */ new Set(["input", "textarea"]),
19010
+ selected: /* @__PURE__ */ new Set(["option"])
19011
+ };
19012
+ const VALUE_PROPERTY_ELEMENTS = /* @__PURE__ */ new Set([
19013
+ "button",
19014
+ "input",
19015
+ "option",
19016
+ "textarea"
19017
+ ]);
19018
+ function isSSRPropertySupported(tag, name) {
19019
+ var _BOOLEAN_PROPERTY_ELE;
19020
+ const normalizedTag = tag.toLowerCase();
19021
+ if (name === "tabIndex") return true;
19022
+ if (name === "htmlFor") return normalizedTag === "label";
19023
+ if (name === "value") return VALUE_PROPERTY_ELEMENTS.has(normalizedTag);
19024
+ return Boolean((_BOOLEAN_PROPERTY_ELE = BOOLEAN_PROPERTY_ELEMENTS[name]) === null || _BOOLEAN_PROPERTY_ELE === void 0 ? void 0 : _BOOLEAN_PROPERTY_ELE.has(normalizedTag));
19025
+ }
19026
+ //#endregion
18986
19027
  //#region packages/core/compiler/src/diagnostics/codes.ts
18987
19028
  const CompilerErrorCode = {
18988
19029
  UNSUPPORTED_SPREAD_ATTRIBUTE: "ZEUS_UNSUPPORTED_SPREAD_ATTRIBUTE",
@@ -18994,6 +19035,9 @@ var ZeusCompiler = (function(exports) {
18994
19035
  INVALID_TRANSFORM_RESULT: "ZEUS_INVALID_TRANSFORM_RESULT",
18995
19036
  UNSUPPORTED_NODE: "ZEUS_UNSUPPORTED_NODE",
18996
19037
  INVALID_BUILTIN_USAGE: "ZEUS_INVALID_BUILTIN_USAGE",
19038
+ UNSUPPORTED_SSR_BUILTIN: "ZEUS_UNSUPPORTED_SSR_BUILTIN",
19039
+ UNSUPPORTED_SSR_PROPERTY: "ZEUS_UNSUPPORTED_SSR_PROPERTY",
19040
+ UNSUPPORTED_SSR_RAW_TEXT_CHILD: "ZEUS_UNSUPPORTED_SSR_RAW_TEXT_CHILD",
18997
19041
  INVALID_REF_USAGE: "ZEUS_INVALID_REF_USAGE"
18998
19042
  };
18999
19043
  //#endregion
@@ -19030,6 +19074,169 @@ var ZeusCompiler = (function(exports) {
19030
19074
  }
19031
19075
  };
19032
19076
  //#endregion
19077
+ //#region packages/core/compiler/src/codegen/ssr/validate.ts
19078
+ function assertSSRSupported(node, filename, rawTextTag) {
19079
+ if (rawTextTag && (node.kind === "Element" || node.kind === "Component")) throwUnsupportedSSRRawTextChild(node, rawTextTag, filename);
19080
+ switch (node.kind) {
19081
+ case "Host":
19082
+ case "Slot": throwUnsupportedSSRBuiltin(node, filename);
19083
+ case "Element":
19084
+ for (const attribute of node.attrs) if (attribute.kind === "PropBinding" && !isSSRPropertySupported(node.tagName, attribute.name)) throwUnsupportedSSRProperty(node, attribute, filename);
19085
+ const childRawTextTag = getSSRRawTextTag(node.tagName);
19086
+ for (const child of node.children) assertSSRSupported(child, filename, childRawTextTag);
19087
+ return;
19088
+ case "Fragment":
19089
+ for (const child of node.children) assertSSRSupported(child, filename, rawTextTag);
19090
+ return;
19091
+ case "Component":
19092
+ for (const prop of node.props) {
19093
+ if (!Array.isArray(prop.value)) continue;
19094
+ for (const child of prop.value) assertSSRSupported(child, filename);
19095
+ }
19096
+ return;
19097
+ case "Show":
19098
+ for (const child of node.children) assertSSRSupported(child, filename, rawTextTag);
19099
+ if (Array.isArray(node.fallback)) for (const child of node.fallback) assertSSRSupported(child, filename, rawTextTag);
19100
+ return;
19101
+ case "For":
19102
+ for (const child of node.body) assertSSRSupported(child, filename, rawTextTag);
19103
+ return;
19104
+ case "Text":
19105
+ case "DynamicText": return;
19106
+ }
19107
+ }
19108
+ function throwUnsupportedSSRRawTextChild(node, tag, filename) {
19109
+ throw new CompilerError({
19110
+ code: CompilerErrorCode.UNSUPPORTED_SSR_RAW_TEXT_CHILD,
19111
+ message: `${node.kind} children are not supported inside <${tag}> SSR raw text.`,
19112
+ hint: "Use text expressions, Fragment, Show, or For directly inside the raw-text element.",
19113
+ filename,
19114
+ span: node.span
19115
+ });
19116
+ }
19117
+ function throwUnsupportedSSRProperty(element, property, filename) {
19118
+ var _ref, _property$span;
19119
+ throw new CompilerError({
19120
+ code: CompilerErrorCode.UNSUPPORTED_SSR_PROPERTY,
19121
+ message: `Property "${property.name}" on <${element.tagName}> cannot be serialized by SSR codegen.`,
19122
+ hint: "Use an equivalent HTML attribute binding or move this DOM-only property update to client code.",
19123
+ filename,
19124
+ span: (_ref = (_property$span = property.span) !== null && _property$span !== void 0 ? _property$span : property.expr.span) !== null && _ref !== void 0 ? _ref : element.span
19125
+ });
19126
+ }
19127
+ function throwUnsupportedSSRBuiltin(node, filename) {
19128
+ throw new CompilerError({
19129
+ code: CompilerErrorCode.UNSUPPORTED_SSR_BUILTIN,
19130
+ message: `<${node.kind}> is not supported by SSR codegen.`,
19131
+ hint: "Render Web Components on the client; the SSR baseline supports DOM components only.",
19132
+ filename,
19133
+ span: node.span
19134
+ });
19135
+ }
19136
+ //#endregion
19137
+ //#region packages/core/compiler/src/codegen/ssr/index.ts
19138
+ function emitSSR(node, context, rawTextTag) {
19139
+ switch (node.kind) {
19140
+ case "Element": return emitElement(node, context);
19141
+ case "Fragment": return emitChildren(node.children, context, rawTextTag);
19142
+ case "Text":
19143
+ if (rawTextTag) return stringLiteral(decodeCompilerEscapedText(node.value));
19144
+ return callExpression(context.importRuntime("ssrStatic"), [stringLiteral(node.value)]);
19145
+ case "DynamicText":
19146
+ if (rawTextTag) return parseExpressionIR(node.expr);
19147
+ return callExpression(context.importRuntime("ssrText"), [parseExpressionIR(node.expr)]);
19148
+ case "Component": return emitComponent(node, context);
19149
+ case "Show": return emitShow(node, context, rawTextTag);
19150
+ case "For": return emitFor(node, context, rawTextTag);
19151
+ case "Host":
19152
+ case "Slot": return throwUnsupportedSSRBuiltin(node);
19153
+ default: return throwUnsupportedSSRNode(node);
19154
+ }
19155
+ }
19156
+ function emitShow(node, context, rawTextTag) {
19157
+ const args = [arrowFunctionExpression([], parseExpressionIR(node.when)), arrowFunctionExpression([], emitChildrenValue(node.children, context, rawTextTag))];
19158
+ if (node.fallback) {
19159
+ const fallback = Array.isArray(node.fallback) ? emitChildrenValue(node.fallback, context, rawTextTag) : parseExpressionIR(node.fallback);
19160
+ args.push(arrowFunctionExpression([], fallback));
19161
+ }
19162
+ return callExpression(context.importRuntime("ssrShow"), args);
19163
+ }
19164
+ function emitFor(node, context, rawTextTag) {
19165
+ const params = [identifier(node.item.name)];
19166
+ if (node.index) params.push(identifier(node.index.name));
19167
+ return callExpression(context.importRuntime("ssrFor"), [arrowFunctionExpression([], parseExpressionIR(node.each)), arrowFunctionExpression(params, emitChildrenValue(node.body, context, rawTextTag))]);
19168
+ }
19169
+ function emitComponent(node, context) {
19170
+ return callExpression(context.importRuntime("ssrComponent"), [parseExpressionIR(node.callee), objectExpression(node.props.map((prop) => emitComponentProp(prop, context)))]);
19171
+ }
19172
+ function emitComponentProp(prop, context) {
19173
+ const key = createObjectKey(prop.name);
19174
+ if (Array.isArray(prop.value)) return objectMethod("get", key, [], blockStatement([returnStatement(emitChildrenValue(prop.value, context))]));
19175
+ const value = parseExpressionIR(prop.value);
19176
+ if (isStaticPropValue(value)) return objectProperty(key, value);
19177
+ return objectMethod("get", key, [], blockStatement([returnStatement(value)]));
19178
+ }
19179
+ function emitElement(node, context) {
19180
+ const rawTextTag = getSSRRawTextTag(node.tagName);
19181
+ const args = [stringLiteral(node.tagName), arrayExpression(node.attrs.flatMap((attr) => {
19182
+ switch (attr.kind) {
19183
+ case "StaticAttribute":
19184
+ if (isEventAttributeName$1(attr.name)) return [];
19185
+ return [emitStaticAttribute(attr, context)];
19186
+ case "AttrBinding": return [emitAttributeBinding(attr, context)];
19187
+ case "PropBinding": return [emitPropertyBinding(attr, context)];
19188
+ default: return [];
19189
+ }
19190
+ }))];
19191
+ if (node.children.length > 0) args.push(emitChildren(node.children, context, rawTextTag));
19192
+ if (node.flags.isVoid) {
19193
+ if (node.children.length === 0) args.push(identifier("undefined"));
19194
+ args.push(booleanLiteral(true));
19195
+ }
19196
+ return callExpression(context.importRuntime("ssrElement"), args);
19197
+ }
19198
+ function emitAttributeBinding(attr, context) {
19199
+ const name = normalizeAttributeName(attr.name);
19200
+ return callExpression(context.importRuntime("ssrAttr"), [stringLiteral(name), emitBindingValue(attr.expr)]);
19201
+ }
19202
+ function emitPropertyBinding(attr, context) {
19203
+ return callExpression(context.importRuntime("ssrProp"), [stringLiteral(attr.name), emitBindingValue(attr.expr)]);
19204
+ }
19205
+ function emitBindingValue(expression) {
19206
+ const value = parseExpressionIR(expression);
19207
+ if (isArrowFunctionExpression(value) || isFunctionExpression(value)) return callExpression(value, []);
19208
+ return value;
19209
+ }
19210
+ function emitStaticAttribute(attr, context) {
19211
+ return callExpression(context.importRuntime("ssrAttr"), [stringLiteral(normalizeAttributeName(attr.name)), attr.value === true ? booleanLiteral(true) : stringLiteral(attr.value)]);
19212
+ }
19213
+ function emitChildren(children, context, rawTextTag) {
19214
+ return arrayExpression(children.map((child) => emitSSR(child, context, rawTextTag)));
19215
+ }
19216
+ function emitChildrenValue(children, context, rawTextTag) {
19217
+ if (children.length === 1) return emitSSR(children[0], context, rawTextTag);
19218
+ return emitChildren(children, context, rawTextTag);
19219
+ }
19220
+ function decodeCompilerEscapedText(value) {
19221
+ return value.replace(/&lt;/g, "<").replace(/&amp;/g, "&");
19222
+ }
19223
+ function isStaticPropValue(value) {
19224
+ return isStringLiteral(value) || isNumericLiteral(value) || isBooleanLiteral(value) || isNullLiteral(value);
19225
+ }
19226
+ function createObjectKey(name) {
19227
+ return isValidIdentifier(name) ? identifier(name) : stringLiteral(name);
19228
+ }
19229
+ function normalizeAttributeName(name) {
19230
+ return name === "className" ? "class" : name;
19231
+ }
19232
+ function isEventAttributeName$1(name) {
19233
+ return name.length > 2 && name.slice(0, 2).toLowerCase() === "on";
19234
+ }
19235
+ function throwUnsupportedSSRNode(node) {
19236
+ const kind = node.kind;
19237
+ throw new Error(`Unsupported SSR IR node: ${kind}`);
19238
+ }
19239
+ //#endregion
19033
19240
  //#region packages/core/compiler/src/adapters/babel/diagnostic.ts
19034
19241
  function createBabelCompilerError(path, options) {
19035
19242
  var _hub$file;
@@ -19102,12 +19309,15 @@ var ZeusCompiler = (function(exports) {
19102
19309
  if (!expression.isExpression()) return null;
19103
19310
  const expr = lowerExpressionIR(expression);
19104
19311
  if (name === "ref") return refBindingIR(expr);
19105
- if (name.startsWith("on") && name.length > 2) return eventBindingIR(toEventName(name), expr);
19312
+ if (isEventAttributeName(name)) return eventBindingIR(toEventName(name), expr);
19106
19313
  if (name.startsWith("prop:")) return propBindingIR(name.slice(5), expr);
19107
19314
  return attrBindingIR(name, expr);
19108
19315
  }
19109
19316
  return null;
19110
19317
  }
19318
+ function isEventAttributeName(name) {
19319
+ return name.length > 2 && name.slice(0, 2).toLowerCase() === "on";
19320
+ }
19111
19321
  //#endregion
19112
19322
  //#region packages/core/compiler/src/lower/lowerChildren.ts
19113
19323
  function lowerChildren(children, context) {
@@ -19374,7 +19584,8 @@ var ZeusCompiler = (function(exports) {
19374
19584
  return componentIR({
19375
19585
  ref: ref(context.uid("cmp$").name),
19376
19586
  callee: tag,
19377
- props
19587
+ props,
19588
+ span: sourceSpanFromBabelNode(path.node)
19378
19589
  });
19379
19590
  }
19380
19591
  function convertComponentIdentifier(node) {
@@ -19405,6 +19616,7 @@ var ZeusCompiler = (function(exports) {
19405
19616
  tagName,
19406
19617
  attrs,
19407
19618
  children: VoidElements.includes(tagName) ? [] : lowerChildren(path.get("children"), context),
19619
+ span: sourceSpanFromBabelNode(path.node),
19408
19620
  flags: {
19409
19621
  isVoid: VoidElements.includes(tagName),
19410
19622
  isCustomElement: tagName.includes("-")
@@ -19786,13 +19998,18 @@ var ZeusCompiler = (function(exports) {
19786
19998
  const context = getCompilerContext(path, config);
19787
19999
  const ir = lowerJSX(path, context);
19788
20000
  normalizeChildren(ir);
20001
+ if (config.generate === "ssr") assertSSRSupported(ir, state.filename);
19789
20002
  validateBuiltins(ir, {
19790
20003
  isDefineElementRenderRoot: isDefineElementRenderRoot(path),
19791
20004
  filename: state.filename
19792
20005
  });
20006
+ analyzeBindings(ir);
20007
+ if (config.generate === "ssr") {
20008
+ path.replaceWith(emitSSR(ir, context));
20009
+ return;
20010
+ }
19793
20011
  assignDomPaths(ir);
19794
20012
  assignPhysicalDomPaths(ir);
19795
- analyzeBindings(ir);
19796
20013
  collectTemplates(ir, context);
19797
20014
  path.replaceWith(emitDOM(ir, context));
19798
20015
  }