@vue-jsx-vapor/compiler 2.6.1 → 2.6.3

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/index.cjs CHANGED
@@ -1412,12 +1412,13 @@ function genTemplates(templates, rootIndex, { helper }) {
1412
1412
  }
1413
1413
  function genSelf(dynamic, context) {
1414
1414
  const [frag, push] = buildCodeFragment();
1415
- const { id, template, operation } = dynamic;
1415
+ const { id, template, operation, hasDynamicChild } = dynamic;
1416
1416
  if (id !== void 0 && template !== void 0) {
1417
1417
  push(NEWLINE, `const n${id} = t${template}()`);
1418
1418
  push(...genDirectivesForElement(id, context));
1419
1419
  }
1420
1420
  if (operation) push(...genOperationWithInsertionState(operation, context));
1421
+ if (hasDynamicChild) push(...genChildren(dynamic, context, push, `n${id}`));
1421
1422
  return frag;
1422
1423
  }
1423
1424
  function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
@@ -1426,7 +1427,6 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
1426
1427
  const { children } = dynamic;
1427
1428
  let offset = 0;
1428
1429
  let prev;
1429
- const childrenToGen = [];
1430
1430
  for (const [index, child] of children.entries()) {
1431
1431
  if (child.flags & DynamicFlag.NON_TEMPLATE) offset--;
1432
1432
  const id = child.flags & DynamicFlag.REFERENCED ? child.flags & DynamicFlag.INSERT ? child.anchor : child.id : void 0;
@@ -1446,12 +1446,11 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
1446
1446
  else if (elementIndex > 1) init = genCall(helper("nthChild"), from, String(elementIndex));
1447
1447
  pushBlock(...init);
1448
1448
  }
1449
- if (id === child.anchor) push(...genSelf(child, context));
1449
+ if (id === child.anchor && !child.hasDynamicChild) push(...genSelf(child, context));
1450
1450
  if (id !== void 0) push(...genDirectivesForElement(id, context));
1451
1451
  prev = [variable, elementIndex];
1452
- childrenToGen.push([child, variable]);
1452
+ push(...genChildren(child, context, pushBlock, variable));
1453
1453
  }
1454
- if (childrenToGen.length) for (const [child, from$1] of childrenToGen) push(...genChildren(child, context, pushBlock, from$1));
1455
1454
  return frag;
1456
1455
  }
1457
1456
 
@@ -1483,7 +1482,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
1483
1482
  genResolveAssets("directive", "resolveDirective");
1484
1483
  }
1485
1484
  for (const child of dynamic.children) push(...genSelf(child, context));
1486
- for (const child of dynamic.children) push(...genChildren(child, context, push, `n${child.id}`));
1485
+ for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`));
1487
1486
  push(...genOperations(operation, context));
1488
1487
  push(...genEffects(effect, context, genEffectsExtraFrag));
1489
1488
  push(NEWLINE, `return `);
@@ -1573,6 +1572,7 @@ function generate(ir, options = {}) {
1573
1572
  //#endregion
1574
1573
  //#region src/transform.ts
1575
1574
  const defaultOptions = {
1575
+ source: "",
1576
1576
  filename: "",
1577
1577
  hoistStatic: false,
1578
1578
  hmr: false,
@@ -1590,6 +1590,7 @@ const defaultOptions = {
1590
1590
  inSSR: false,
1591
1591
  ssrCssVars: ``,
1592
1592
  isTS: false,
1593
+ withFallback: false,
1593
1594
  onError: __vue_compiler_dom.defaultOnError,
1594
1595
  onWarn: __vue_compiler_dom.defaultOnWarn
1595
1596
  };
@@ -1807,20 +1808,13 @@ const transformElement = (node, context) => {
1807
1808
  };
1808
1809
  };
1809
1810
  function transformComponentElement(tag, propsResult, singleRoot, context) {
1810
- let asset = true;
1811
- const fromSetup = tag;
1812
- if (fromSetup) {
1813
- tag = fromSetup;
1814
- asset = false;
1815
- }
1811
+ let asset = context.options.withFallback;
1816
1812
  const dotIndex = tag.indexOf(".");
1817
1813
  if (dotIndex > 0) {
1818
1814
  const ns = tag.slice(0, dotIndex);
1819
- if (ns) {
1820
- tag = ns + tag.slice(dotIndex);
1821
- asset = false;
1822
- }
1815
+ if (ns) tag = ns + tag.slice(dotIndex);
1823
1816
  }
1817
+ if (tag.includes("-")) asset = true;
1824
1818
  if (asset) context.component.add(tag);
1825
1819
  context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT;
1826
1820
  context.dynamic.operation = {
package/dist/index.d.cts CHANGED
@@ -17,7 +17,13 @@ interface DirectiveTransformResult {
17
17
  }
18
18
  type StructuralDirectiveTransform = (node: JSXElement, dir: JSXAttribute, context: TransformContext) => void | (() => void);
19
19
  type TransformOptions = HackOptions<TransformOptions$1> & {
20
+ source?: string;
20
21
  templates?: string[];
22
+ /**
23
+ * Compile JSX Component to createComponentWithFallback.
24
+ * @default false
25
+ */
26
+ withFallback?: boolean;
21
27
  };
22
28
  declare class TransformContext<T extends BlockIRNode['node'] = BlockIRNode['node']> {
23
29
  ir: RootIRNode;
@@ -370,10 +376,7 @@ declare function generate(ir: RootIRNode, options?: CodegenOptions): VaporCodege
370
376
  //#endregion
371
377
  //#region src/compile.d.ts
372
378
  declare function compile(source: JSXElement | JSXFragment | string, options?: CompilerOptions): VaporCodegenResult;
373
- type CompilerOptions = HackOptions<CompilerOptions$1> & {
374
- source?: string;
375
- templates?: string[];
376
- };
379
+ type CompilerOptions = HackOptions<CompilerOptions$1> & TransformOptions;
377
380
  type TransformPreset = [NodeTransform[], Record<string, DirectiveTransform>];
378
381
  //#endregion
379
382
  //#region src/transforms/transformText.d.ts
package/dist/index.d.ts CHANGED
@@ -17,7 +17,13 @@ interface DirectiveTransformResult {
17
17
  }
18
18
  type StructuralDirectiveTransform = (node: JSXElement, dir: JSXAttribute, context: TransformContext) => void | (() => void);
19
19
  type TransformOptions = HackOptions<TransformOptions$1> & {
20
+ source?: string;
20
21
  templates?: string[];
22
+ /**
23
+ * Compile JSX Component to createComponentWithFallback.
24
+ * @default false
25
+ */
26
+ withFallback?: boolean;
21
27
  };
22
28
  declare class TransformContext<T extends BlockIRNode['node'] = BlockIRNode['node']> {
23
29
  ir: RootIRNode;
@@ -370,10 +376,7 @@ declare function generate(ir: RootIRNode, options?: CodegenOptions): VaporCodege
370
376
  //#endregion
371
377
  //#region src/compile.d.ts
372
378
  declare function compile(source: JSXElement | JSXFragment | string, options?: CompilerOptions): VaporCodegenResult;
373
- type CompilerOptions = HackOptions<CompilerOptions$1> & {
374
- source?: string;
375
- templates?: string[];
376
- };
379
+ type CompilerOptions = HackOptions<CompilerOptions$1> & TransformOptions;
377
380
  type TransformPreset = [NodeTransform[], Record<string, DirectiveTransform>];
378
381
  //#endregion
379
382
  //#region src/transforms/transformText.d.ts
package/dist/index.js CHANGED
@@ -1389,12 +1389,13 @@ function genTemplates(templates, rootIndex, { helper }) {
1389
1389
  }
1390
1390
  function genSelf(dynamic, context) {
1391
1391
  const [frag, push] = buildCodeFragment();
1392
- const { id, template, operation } = dynamic;
1392
+ const { id, template, operation, hasDynamicChild } = dynamic;
1393
1393
  if (id !== void 0 && template !== void 0) {
1394
1394
  push(NEWLINE, `const n${id} = t${template}()`);
1395
1395
  push(...genDirectivesForElement(id, context));
1396
1396
  }
1397
1397
  if (operation) push(...genOperationWithInsertionState(operation, context));
1398
+ if (hasDynamicChild) push(...genChildren(dynamic, context, push, `n${id}`));
1398
1399
  return frag;
1399
1400
  }
1400
1401
  function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
@@ -1403,7 +1404,6 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
1403
1404
  const { children } = dynamic;
1404
1405
  let offset = 0;
1405
1406
  let prev;
1406
- const childrenToGen = [];
1407
1407
  for (const [index, child] of children.entries()) {
1408
1408
  if (child.flags & DynamicFlag.NON_TEMPLATE) offset--;
1409
1409
  const id = child.flags & DynamicFlag.REFERENCED ? child.flags & DynamicFlag.INSERT ? child.anchor : child.id : void 0;
@@ -1423,12 +1423,11 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
1423
1423
  else if (elementIndex > 1) init = genCall(helper("nthChild"), from, String(elementIndex));
1424
1424
  pushBlock(...init);
1425
1425
  }
1426
- if (id === child.anchor) push(...genSelf(child, context));
1426
+ if (id === child.anchor && !child.hasDynamicChild) push(...genSelf(child, context));
1427
1427
  if (id !== void 0) push(...genDirectivesForElement(id, context));
1428
1428
  prev = [variable, elementIndex];
1429
- childrenToGen.push([child, variable]);
1429
+ push(...genChildren(child, context, pushBlock, variable));
1430
1430
  }
1431
- if (childrenToGen.length) for (const [child, from$1] of childrenToGen) push(...genChildren(child, context, pushBlock, from$1));
1432
1431
  return frag;
1433
1432
  }
1434
1433
 
@@ -1460,7 +1459,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
1460
1459
  genResolveAssets("directive", "resolveDirective");
1461
1460
  }
1462
1461
  for (const child of dynamic.children) push(...genSelf(child, context));
1463
- for (const child of dynamic.children) push(...genChildren(child, context, push, `n${child.id}`));
1462
+ for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`));
1464
1463
  push(...genOperations(operation, context));
1465
1464
  push(...genEffects(effect, context, genEffectsExtraFrag));
1466
1465
  push(NEWLINE, `return `);
@@ -1550,6 +1549,7 @@ function generate(ir, options = {}) {
1550
1549
  //#endregion
1551
1550
  //#region src/transform.ts
1552
1551
  const defaultOptions = {
1552
+ source: "",
1553
1553
  filename: "",
1554
1554
  hoistStatic: false,
1555
1555
  hmr: false,
@@ -1567,6 +1567,7 @@ const defaultOptions = {
1567
1567
  inSSR: false,
1568
1568
  ssrCssVars: ``,
1569
1569
  isTS: false,
1570
+ withFallback: false,
1570
1571
  onError: defaultOnError,
1571
1572
  onWarn: defaultOnWarn
1572
1573
  };
@@ -1784,20 +1785,13 @@ const transformElement = (node, context) => {
1784
1785
  };
1785
1786
  };
1786
1787
  function transformComponentElement(tag, propsResult, singleRoot, context) {
1787
- let asset = true;
1788
- const fromSetup = tag;
1789
- if (fromSetup) {
1790
- tag = fromSetup;
1791
- asset = false;
1792
- }
1788
+ let asset = context.options.withFallback;
1793
1789
  const dotIndex = tag.indexOf(".");
1794
1790
  if (dotIndex > 0) {
1795
1791
  const ns = tag.slice(0, dotIndex);
1796
- if (ns) {
1797
- tag = ns + tag.slice(dotIndex);
1798
- asset = false;
1799
- }
1792
+ if (ns) tag = ns + tag.slice(dotIndex);
1800
1793
  }
1794
+ if (tag.includes("-")) asset = true;
1801
1795
  if (asset) context.component.add(tag);
1802
1796
  context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT;
1803
1797
  context.dynamic.operation = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Vue JSX Vapor Compiler",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -34,11 +34,11 @@
34
34
  "./*": "./*"
35
35
  },
36
36
  "dependencies": {
37
- "@babel/parser": "^7.28.0",
38
- "@babel/types": "^7.28.0",
37
+ "@babel/parser": "^7.28.4",
38
+ "@babel/types": "^7.28.4",
39
39
  "@vue/compiler-dom": "3.6.0-alpha.2",
40
40
  "@vue/shared": "3.6.0-alpha.2",
41
- "ast-kit": "^2.1.1",
41
+ "ast-kit": "^2.1.2",
42
42
  "source-map-js": "^1.2.1"
43
43
  },
44
44
  "scripts": {