@fictjs/compiler 0.16.0 → 0.17.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.
package/dist/index.cjs CHANGED
@@ -18938,6 +18938,22 @@ function structurizeBlockUntilJoin(ctx, blockId, joinBlock) {
18938
18938
  if (branchNode) nodes.push(branchNode);
18939
18939
  break;
18940
18940
  }
18941
+ case "Switch": {
18942
+ nodes.push(structurizeSwitch(ctx, block, term));
18943
+ break;
18944
+ }
18945
+ case "ForOf": {
18946
+ nodes.push(structurizeForOf(ctx, block, term));
18947
+ break;
18948
+ }
18949
+ case "ForIn": {
18950
+ nodes.push(structurizeForIn(ctx, block, term));
18951
+ break;
18952
+ }
18953
+ case "Try": {
18954
+ nodes.push(structurizeTry(ctx, block, term));
18955
+ break;
18956
+ }
18941
18957
  case "Break":
18942
18958
  nodes.push({ kind: "break", label: term.label });
18943
18959
  break;
@@ -19072,7 +19088,9 @@ function isSwitchCaseTerminated(node) {
19072
19088
  }
19073
19089
  }
19074
19090
  function structurizeForOf(ctx, block, term) {
19091
+ ctx.reservedBlocks.add(term.exit);
19075
19092
  const body = structurizeBlock(ctx, term.body);
19093
+ ctx.reservedBlocks.delete(term.exit);
19076
19094
  const exit = !ctx.emitted.has(term.exit) ? structurizeBlock(ctx, term.exit) : null;
19077
19095
  const forOfNode = {
19078
19096
  kind: "forOf",
@@ -19088,7 +19106,9 @@ function structurizeForOf(ctx, block, term) {
19088
19106
  return forOfNode;
19089
19107
  }
19090
19108
  function structurizeForIn(ctx, block, term) {
19109
+ ctx.reservedBlocks.add(term.exit);
19091
19110
  const body = structurizeBlock(ctx, term.body);
19111
+ ctx.reservedBlocks.delete(term.exit);
19092
19112
  const exit = !ctx.emitted.has(term.exit) ? structurizeBlock(ctx, term.exit) : null;
19093
19113
  const forInNode = {
19094
19114
  kind: "forIn",
@@ -25761,6 +25781,10 @@ function registerResumableComponent(componentName, ctx) {
25761
25781
  const hostParam = t4.identifier("host");
25762
25782
  const snapshotId = t4.identifier("snapshot");
25763
25783
  const ctxId = t4.identifier("ctx");
25784
+ const runtimeModuleUrlExpr = t4.memberExpression(
25785
+ t4.metaProperty(t4.identifier("import"), t4.identifier("meta")),
25786
+ t4.identifier("url")
25787
+ );
25764
25788
  ctx.helpersUsed.add("getSSRScope");
25765
25789
  ctx.helpersUsed.add("ensureScope");
25766
25790
  ctx.helpersUsed.add("prepareContext");
@@ -25834,7 +25858,10 @@ function registerResumableComponent(componentName, ctx) {
25834
25858
  ctx.helpersUsed.add("registerResume");
25835
25859
  const registerCall = t4.expressionStatement(
25836
25860
  t4.callExpression(t4.identifier(RUNTIME_ALIASES.registerResume), [
25837
- t4.stringLiteral(resumeExport),
25861
+ t4.callExpression(t4.identifier(RUNTIME_ALIASES.qrl), [
25862
+ runtimeModuleUrlExpr,
25863
+ t4.stringLiteral(resumeExport)
25864
+ ]),
25838
25865
  resumeFnId
25839
25866
  ])
25840
25867
  );
@@ -27624,18 +27651,8 @@ function lowerExpressionImpl(expr, ctx, valueUsed = true) {
27624
27651
  blocks,
27625
27652
  meta: { fromExpression: true }
27626
27653
  };
27627
- const cfg = analyzeCFG(fn.blocks);
27628
- const hasLoop = cfg.loopHeaders.size > 0 || cfg.backEdges.size > 0;
27629
27654
  const { node, diagnostics } = structurizeCFGWithDiagnostics(fn);
27630
- const structured = node.kind === "stateMachine" || hasLoop ? node.kind === "stateMachine" ? node : {
27631
- kind: "stateMachine",
27632
- blocks: fn.blocks.map((block) => ({
27633
- blockId: block.id,
27634
- instructions: block.instructions,
27635
- terminator: block.terminator
27636
- })),
27637
- entryBlock: fn.blocks[0]?.id ?? 0
27638
- } : diagnostics.isComplete ? node : {
27655
+ const structured = node.kind === "stateMachine" ? node : diagnostics.isComplete ? node : {
27639
27656
  kind: "stateMachine",
27640
27657
  blocks: fn.blocks.map((block) => ({
27641
27658
  blockId: block.id,
package/dist/index.js CHANGED
@@ -18921,6 +18921,22 @@ function structurizeBlockUntilJoin(ctx, blockId, joinBlock) {
18921
18921
  if (branchNode) nodes.push(branchNode);
18922
18922
  break;
18923
18923
  }
18924
+ case "Switch": {
18925
+ nodes.push(structurizeSwitch(ctx, block, term));
18926
+ break;
18927
+ }
18928
+ case "ForOf": {
18929
+ nodes.push(structurizeForOf(ctx, block, term));
18930
+ break;
18931
+ }
18932
+ case "ForIn": {
18933
+ nodes.push(structurizeForIn(ctx, block, term));
18934
+ break;
18935
+ }
18936
+ case "Try": {
18937
+ nodes.push(structurizeTry(ctx, block, term));
18938
+ break;
18939
+ }
18924
18940
  case "Break":
18925
18941
  nodes.push({ kind: "break", label: term.label });
18926
18942
  break;
@@ -19055,7 +19071,9 @@ function isSwitchCaseTerminated(node) {
19055
19071
  }
19056
19072
  }
19057
19073
  function structurizeForOf(ctx, block, term) {
19074
+ ctx.reservedBlocks.add(term.exit);
19058
19075
  const body = structurizeBlock(ctx, term.body);
19076
+ ctx.reservedBlocks.delete(term.exit);
19059
19077
  const exit = !ctx.emitted.has(term.exit) ? structurizeBlock(ctx, term.exit) : null;
19060
19078
  const forOfNode = {
19061
19079
  kind: "forOf",
@@ -19071,7 +19089,9 @@ function structurizeForOf(ctx, block, term) {
19071
19089
  return forOfNode;
19072
19090
  }
19073
19091
  function structurizeForIn(ctx, block, term) {
19092
+ ctx.reservedBlocks.add(term.exit);
19074
19093
  const body = structurizeBlock(ctx, term.body);
19094
+ ctx.reservedBlocks.delete(term.exit);
19075
19095
  const exit = !ctx.emitted.has(term.exit) ? structurizeBlock(ctx, term.exit) : null;
19076
19096
  const forInNode = {
19077
19097
  kind: "forIn",
@@ -25744,6 +25764,10 @@ function registerResumableComponent(componentName, ctx) {
25744
25764
  const hostParam = t4.identifier("host");
25745
25765
  const snapshotId = t4.identifier("snapshot");
25746
25766
  const ctxId = t4.identifier("ctx");
25767
+ const runtimeModuleUrlExpr = t4.memberExpression(
25768
+ t4.metaProperty(t4.identifier("import"), t4.identifier("meta")),
25769
+ t4.identifier("url")
25770
+ );
25747
25771
  ctx.helpersUsed.add("getSSRScope");
25748
25772
  ctx.helpersUsed.add("ensureScope");
25749
25773
  ctx.helpersUsed.add("prepareContext");
@@ -25817,7 +25841,10 @@ function registerResumableComponent(componentName, ctx) {
25817
25841
  ctx.helpersUsed.add("registerResume");
25818
25842
  const registerCall = t4.expressionStatement(
25819
25843
  t4.callExpression(t4.identifier(RUNTIME_ALIASES.registerResume), [
25820
- t4.stringLiteral(resumeExport),
25844
+ t4.callExpression(t4.identifier(RUNTIME_ALIASES.qrl), [
25845
+ runtimeModuleUrlExpr,
25846
+ t4.stringLiteral(resumeExport)
25847
+ ]),
25821
25848
  resumeFnId
25822
25849
  ])
25823
25850
  );
@@ -27607,18 +27634,8 @@ function lowerExpressionImpl(expr, ctx, valueUsed = true) {
27607
27634
  blocks,
27608
27635
  meta: { fromExpression: true }
27609
27636
  };
27610
- const cfg = analyzeCFG(fn.blocks);
27611
- const hasLoop = cfg.loopHeaders.size > 0 || cfg.backEdges.size > 0;
27612
27637
  const { node, diagnostics } = structurizeCFGWithDiagnostics(fn);
27613
- const structured = node.kind === "stateMachine" || hasLoop ? node.kind === "stateMachine" ? node : {
27614
- kind: "stateMachine",
27615
- blocks: fn.blocks.map((block) => ({
27616
- blockId: block.id,
27617
- instructions: block.instructions,
27618
- terminator: block.terminator
27619
- })),
27620
- entryBlock: fn.blocks[0]?.id ?? 0
27621
- } : diagnostics.isComplete ? node : {
27638
+ const structured = node.kind === "stateMachine" ? node : diagnostics.isComplete ? node : {
27622
27639
  kind: "stateMachine",
27623
27640
  blocks: fn.blocks.map((block) => ({
27624
27641
  blockId: block.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fictjs/compiler",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Babel plugin for Fict Compiler",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -48,7 +48,7 @@
48
48
  "@types/babel__helper-plugin-utils": "^7.10.3",
49
49
  "@types/babel__traverse": "^7.28.0",
50
50
  "tsup": "^8.5.1",
51
- "@fictjs/runtime": "0.16.0"
51
+ "@fictjs/runtime": "0.17.0"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsup src/index.ts --format cjs,esm --dts",