@fictjs/compiler 0.4.0 → 0.5.1
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/README.md +3 -0
- package/dist/index.cjs +765 -86
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +765 -86
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -14150,6 +14150,9 @@ var RUNTIME_HELPERS = {
|
|
|
14150
14150
|
conditional: "createConditional",
|
|
14151
14151
|
keyedList: "createKeyedList",
|
|
14152
14152
|
insert: "insert",
|
|
14153
|
+
insertBetween: "insertBetween",
|
|
14154
|
+
resolvePath: "resolvePath",
|
|
14155
|
+
getSlotEnd: "getSlotEnd",
|
|
14153
14156
|
onDestroy: "onDestroy",
|
|
14154
14157
|
bindText: "bindText",
|
|
14155
14158
|
bindAttribute: "bindAttribute",
|
|
@@ -14161,7 +14164,18 @@ var RUNTIME_HELPERS = {
|
|
|
14161
14164
|
bindRef: "bindRef",
|
|
14162
14165
|
toNodeArray: "toNodeArray",
|
|
14163
14166
|
template: "template",
|
|
14164
|
-
delegateEvents: "delegateEvents"
|
|
14167
|
+
delegateEvents: "delegateEvents",
|
|
14168
|
+
useLexicalScope: "__fictUseLexicalScope",
|
|
14169
|
+
getScopeProps: "__fictGetScopeProps",
|
|
14170
|
+
qrl: "__fictQrl",
|
|
14171
|
+
getSSRScope: "__fictGetSSRScope",
|
|
14172
|
+
ensureScope: "__fictEnsureScope",
|
|
14173
|
+
prepareContext: "__fictPrepareContext",
|
|
14174
|
+
enterHydration: "__fictEnterHydration",
|
|
14175
|
+
exitHydration: "__fictExitHydration",
|
|
14176
|
+
domRender: "render",
|
|
14177
|
+
hydrateComponent: "hydrateComponent",
|
|
14178
|
+
registerResume: "__fictRegisterResume"
|
|
14165
14179
|
};
|
|
14166
14180
|
var RUNTIME_ALIASES = {
|
|
14167
14181
|
signal: "createSignal",
|
|
@@ -14186,6 +14200,9 @@ var RUNTIME_ALIASES = {
|
|
|
14186
14200
|
conditional: "createConditional",
|
|
14187
14201
|
keyedList: "createKeyedList",
|
|
14188
14202
|
insert: "insert",
|
|
14203
|
+
insertBetween: "insertBetween",
|
|
14204
|
+
resolvePath: "resolvePath",
|
|
14205
|
+
getSlotEnd: "getSlotEnd",
|
|
14189
14206
|
onDestroy: "onDestroy",
|
|
14190
14207
|
bindText: "bindText",
|
|
14191
14208
|
bindAttribute: "bindAttribute",
|
|
@@ -14197,7 +14214,18 @@ var RUNTIME_ALIASES = {
|
|
|
14197
14214
|
bindRef: "bindRef",
|
|
14198
14215
|
toNodeArray: "toNodeArray",
|
|
14199
14216
|
template: "template",
|
|
14200
|
-
delegateEvents: "delegateEvents"
|
|
14217
|
+
delegateEvents: "delegateEvents",
|
|
14218
|
+
useLexicalScope: "__fictUseLexicalScope",
|
|
14219
|
+
getScopeProps: "__fictGetScopeProps",
|
|
14220
|
+
qrl: "__fictQrl",
|
|
14221
|
+
getSSRScope: "__fictGetSSRScope",
|
|
14222
|
+
ensureScope: "__fictEnsureScope",
|
|
14223
|
+
prepareContext: "__fictPrepareContext",
|
|
14224
|
+
enterHydration: "__fictEnterHydration",
|
|
14225
|
+
exitHydration: "__fictExitHydration",
|
|
14226
|
+
domRender: "render",
|
|
14227
|
+
hydrateComponent: "hydrateComponent",
|
|
14228
|
+
registerResume: "__fictRegisterResume"
|
|
14201
14229
|
};
|
|
14202
14230
|
var DelegatedEvents = /* @__PURE__ */ new Set([...DelegatedEventNames]);
|
|
14203
14231
|
var SAFE_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
@@ -14548,6 +14576,9 @@ function parseFictReturnAnnotation(node) {
|
|
|
14548
14576
|
if (content === "'memo'" || content === '"memo"') {
|
|
14549
14577
|
return { directAccessor: "memo" };
|
|
14550
14578
|
}
|
|
14579
|
+
if (/^\{\s*\}$/.test(content)) {
|
|
14580
|
+
return { objectProps: /* @__PURE__ */ new Map() };
|
|
14581
|
+
}
|
|
14551
14582
|
const objectMatch = content.match(/^\{([^}]+)\}$/);
|
|
14552
14583
|
if (objectMatch) {
|
|
14553
14584
|
const objectProps = /* @__PURE__ */ new Map();
|
|
@@ -16107,6 +16138,7 @@ function convertExpression(node, options) {
|
|
|
16107
16138
|
const arrow = {
|
|
16108
16139
|
kind: "ArrowFunction",
|
|
16109
16140
|
params: nested.params,
|
|
16141
|
+
rawParams: nested.rawParams ?? node.params,
|
|
16110
16142
|
body: nested.blocks,
|
|
16111
16143
|
isExpression: false,
|
|
16112
16144
|
isAsync: node.async,
|
|
@@ -16120,6 +16152,7 @@ function convertExpression(node, options) {
|
|
|
16120
16152
|
params: node.params.map(
|
|
16121
16153
|
(p) => t.isPattern(p) ? extractIdentifiersFromPattern(p) : t.isIdentifier(p) ? [{ kind: "Identifier", name: p.name }] : []
|
|
16122
16154
|
).flat(),
|
|
16155
|
+
rawParams: node.params,
|
|
16123
16156
|
body: convertExpression(node.body),
|
|
16124
16157
|
isExpression: true,
|
|
16125
16158
|
isAsync: node.async,
|
|
@@ -16141,6 +16174,7 @@ function convertExpression(node, options) {
|
|
|
16141
16174
|
kind: "FunctionExpression",
|
|
16142
16175
|
name: node.id?.name ?? "",
|
|
16143
16176
|
params: nested.params,
|
|
16177
|
+
rawParams: nested.rawParams ?? node.params,
|
|
16144
16178
|
body: nested.blocks,
|
|
16145
16179
|
isAsync: node.async,
|
|
16146
16180
|
reactiveScope: options?.reactiveScope,
|
|
@@ -16377,6 +16411,9 @@ function convertJSXMemberExpr(node) {
|
|
|
16377
16411
|
};
|
|
16378
16412
|
}
|
|
16379
16413
|
|
|
16414
|
+
// src/ir/codegen.ts
|
|
16415
|
+
var import_node_url2 = require("url");
|
|
16416
|
+
|
|
16380
16417
|
// src/fine-grained-dom.ts
|
|
16381
16418
|
function normalizeDependencyKey(name) {
|
|
16382
16419
|
return name.split(".").map((part) => part.replace(/_\d+$/, "")).join(".");
|
|
@@ -21176,9 +21213,14 @@ function instructionToStatement(instr, t4, declaredVars, ctx, _buildMemoCall) {
|
|
|
21176
21213
|
declaredVars.add(baseName2);
|
|
21177
21214
|
if (treatAsTracked && !isDestructuringTemp) {
|
|
21178
21215
|
if (isStateCall2) {
|
|
21179
|
-
|
|
21180
|
-
|
|
21181
|
-
|
|
21216
|
+
ctx.currentAssignmentName = baseName2;
|
|
21217
|
+
try {
|
|
21218
|
+
return t4.variableDeclaration(normalizedDecl, [
|
|
21219
|
+
t4.variableDeclarator(t4.identifier(baseName2), lowerAssignedValue(true))
|
|
21220
|
+
]);
|
|
21221
|
+
} finally {
|
|
21222
|
+
ctx.currentAssignmentName = void 0;
|
|
21223
|
+
}
|
|
21182
21224
|
}
|
|
21183
21225
|
if (dependsOnTracked) {
|
|
21184
21226
|
if (instr.value.kind === "Identifier" && ctx.trackedVars.has(deSSAVarName(instr.value.name)) && !isDestructuringTemp) {
|
|
@@ -22101,7 +22143,17 @@ function createCodegenContext(t4) {
|
|
|
22101
22143
|
hookReturnInfo: /* @__PURE__ */ new Map(),
|
|
22102
22144
|
hoistedTemplates: /* @__PURE__ */ new Map(),
|
|
22103
22145
|
hoistedTemplateStatements: [],
|
|
22104
|
-
|
|
22146
|
+
hoistedResumableStatements: [],
|
|
22147
|
+
resumableHandlerCounter: 0,
|
|
22148
|
+
resumableComponentCounter: 0,
|
|
22149
|
+
resumableComponents: /* @__PURE__ */ new Map(),
|
|
22150
|
+
resumableEnabled: false,
|
|
22151
|
+
autoExtractEnabled: false,
|
|
22152
|
+
autoExtractThreshold: 3,
|
|
22153
|
+
delegatedEventsUsed: /* @__PURE__ */ new Set(),
|
|
22154
|
+
componentFunctionDefs: /* @__PURE__ */ new Map(),
|
|
22155
|
+
hoistedFunctionDepCounter: 0,
|
|
22156
|
+
hoistedFunctionDepNames: /* @__PURE__ */ new Map()
|
|
22105
22157
|
};
|
|
22106
22158
|
}
|
|
22107
22159
|
function withGetterCache(ctx, fn) {
|
|
@@ -23007,6 +23059,51 @@ function computeReactiveAccessors(fn, ctx) {
|
|
|
23007
23059
|
function genTemp(ctx, prefix = "tmp") {
|
|
23008
23060
|
return ctx.t.identifier(`__${prefix}_${ctx.tempCounter++}`);
|
|
23009
23061
|
}
|
|
23062
|
+
function renameIdentifiersInExpr(expr, renames, _t) {
|
|
23063
|
+
const cloned = JSON.parse(JSON.stringify(expr));
|
|
23064
|
+
function visit(node) {
|
|
23065
|
+
if (!node || typeof node !== "object") return;
|
|
23066
|
+
const n = node;
|
|
23067
|
+
if (n.type === "Identifier" && typeof n.name === "string") {
|
|
23068
|
+
const newName = renames.get(n.name);
|
|
23069
|
+
if (newName) {
|
|
23070
|
+
n.name = newName;
|
|
23071
|
+
}
|
|
23072
|
+
}
|
|
23073
|
+
for (const key of Object.keys(n)) {
|
|
23074
|
+
if (key === "loc" || key === "start" || key === "end" || key === "extra" || key === "comments" || key === "leadingComments" || key === "trailingComments") {
|
|
23075
|
+
continue;
|
|
23076
|
+
}
|
|
23077
|
+
const value = n[key];
|
|
23078
|
+
if (Array.isArray(value)) {
|
|
23079
|
+
for (const item of value) {
|
|
23080
|
+
visit(item);
|
|
23081
|
+
}
|
|
23082
|
+
} else if (value && typeof value === "object") {
|
|
23083
|
+
visit(value);
|
|
23084
|
+
}
|
|
23085
|
+
}
|
|
23086
|
+
}
|
|
23087
|
+
visit(cloned);
|
|
23088
|
+
return cloned;
|
|
23089
|
+
}
|
|
23090
|
+
function genModuleUrlExpr(ctx) {
|
|
23091
|
+
const { t: t4 } = ctx;
|
|
23092
|
+
const filename = ctx.options?.filename;
|
|
23093
|
+
if (filename) {
|
|
23094
|
+
let fileUrl;
|
|
23095
|
+
if (filename.startsWith("file://")) {
|
|
23096
|
+
fileUrl = filename;
|
|
23097
|
+
} else {
|
|
23098
|
+
fileUrl = (0, import_node_url2.pathToFileURL)(filename).href;
|
|
23099
|
+
}
|
|
23100
|
+
return t4.stringLiteral(fileUrl);
|
|
23101
|
+
}
|
|
23102
|
+
return t4.memberExpression(
|
|
23103
|
+
t4.metaProperty(t4.identifier("import"), t4.identifier("meta")),
|
|
23104
|
+
t4.identifier("url")
|
|
23105
|
+
);
|
|
23106
|
+
}
|
|
23010
23107
|
function extractKeyFromAttributes(attributes) {
|
|
23011
23108
|
for (const attr of attributes) {
|
|
23012
23109
|
if (attr.name === "key" && attr.value) {
|
|
@@ -23130,6 +23227,26 @@ function lowerInstruction(instr, ctx) {
|
|
|
23130
23227
|
ctx.memoVars?.add(baseName2);
|
|
23131
23228
|
}
|
|
23132
23229
|
}
|
|
23230
|
+
if (declKind) {
|
|
23231
|
+
const initKind = getReactiveCallKind(instr.value, ctx);
|
|
23232
|
+
if (initKind === "signal") {
|
|
23233
|
+
ctx.signalVars?.add(baseName2);
|
|
23234
|
+
ctx.trackedVars.add(baseName2);
|
|
23235
|
+
ctx.currentAssignmentName = baseName2;
|
|
23236
|
+
const loweredValue = (() => {
|
|
23237
|
+
try {
|
|
23238
|
+
return lowerTrackedExpression(instr.value, ctx);
|
|
23239
|
+
} finally {
|
|
23240
|
+
ctx.currentAssignmentName = void 0;
|
|
23241
|
+
}
|
|
23242
|
+
})();
|
|
23243
|
+
return applyLoc(
|
|
23244
|
+
t4.variableDeclaration(declKind, [
|
|
23245
|
+
t4.variableDeclarator(t4.identifier(baseName2), loweredValue)
|
|
23246
|
+
])
|
|
23247
|
+
);
|
|
23248
|
+
}
|
|
23249
|
+
}
|
|
23133
23250
|
if (ctx.signalVars?.has(baseName2)) {
|
|
23134
23251
|
ctx.currentAssignmentName = baseName2;
|
|
23135
23252
|
const loweredValue = (() => {
|
|
@@ -23791,7 +23908,13 @@ function lowerExpressionImpl(expr, ctx, _isAssigned = false) {
|
|
|
23791
23908
|
})),
|
|
23792
23909
|
entryBlock: fn.blocks[0]?.id ?? 0
|
|
23793
23910
|
};
|
|
23794
|
-
const declared = new Set(
|
|
23911
|
+
const declared = /* @__PURE__ */ new Set();
|
|
23912
|
+
for (const p of paramIds) {
|
|
23913
|
+
const ids = t4.getBindingIdentifiers(p);
|
|
23914
|
+
for (const name of Object.keys(ids)) {
|
|
23915
|
+
declared.add(name);
|
|
23916
|
+
}
|
|
23917
|
+
}
|
|
23795
23918
|
return lowerStructuredNodeWithoutRegions(structured, t4, ctx, declared);
|
|
23796
23919
|
} catch {
|
|
23797
23920
|
return lowerBlocksToStatements(blocks);
|
|
@@ -23855,23 +23978,23 @@ function lowerExpressionImpl(expr, ctx, _isAssigned = false) {
|
|
|
23855
23978
|
case "MetaProperty":
|
|
23856
23979
|
return t4.metaProperty(t4.identifier(expr.meta.name), t4.identifier(expr.property.name));
|
|
23857
23980
|
case "CallExpression": {
|
|
23858
|
-
|
|
23981
|
+
const stateCalleeNameRaw = expr.callee.kind === "Identifier" ? expr.callee.name : null;
|
|
23982
|
+
const stateCalleeName = stateCalleeNameRaw ? deSSAVarName(stateCalleeNameRaw) : null;
|
|
23983
|
+
if (stateCalleeName && ctx.stateMacroNames?.has(stateCalleeName)) {
|
|
23859
23984
|
const args = lowerCallArguments(expr.arguments);
|
|
23860
23985
|
const includeDevtools = ctx.options?.dev !== false;
|
|
23861
|
-
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
args.push(t4.objectExpression(options));
|
|
23874
|
-
}
|
|
23986
|
+
const options = [];
|
|
23987
|
+
if (ctx.currentAssignmentName) {
|
|
23988
|
+
options.push(
|
|
23989
|
+
t4.objectProperty(t4.identifier("name"), t4.stringLiteral(ctx.currentAssignmentName))
|
|
23990
|
+
);
|
|
23991
|
+
}
|
|
23992
|
+
if (includeDevtools && expr.loc) {
|
|
23993
|
+
const source = `${ctx.options?.filename ?? ""}:${expr.loc.start.line}:${expr.loc.start.column}`;
|
|
23994
|
+
options.push(t4.objectProperty(t4.identifier("devToolsSource"), t4.stringLiteral(source)));
|
|
23995
|
+
}
|
|
23996
|
+
if (options.length > 0) {
|
|
23997
|
+
args.push(t4.objectExpression(options));
|
|
23875
23998
|
}
|
|
23876
23999
|
if (ctx.inModule) {
|
|
23877
24000
|
ctx.helpersUsed.add("signal");
|
|
@@ -24092,7 +24215,12 @@ function lowerExpressionImpl(expr, ctx, _isAssigned = false) {
|
|
|
24092
24215
|
case "ArrowFunction": {
|
|
24093
24216
|
const reactiveLowered = lowerReactiveScopeExpression(expr);
|
|
24094
24217
|
if (reactiveLowered) return reactiveLowered;
|
|
24095
|
-
const
|
|
24218
|
+
const useRawParams = expr.rawParams && expr.rawParams.length > 0 && expr.rawParams.every(
|
|
24219
|
+
(param) => t4.isIdentifier(param) || t4.isRestElement(param) && t4.isIdentifier(param.argument)
|
|
24220
|
+
);
|
|
24221
|
+
const paramIds = useRawParams ? expr.rawParams.map(
|
|
24222
|
+
(param) => t4.cloneNode(param, true)
|
|
24223
|
+
) : mapParams(expr.params);
|
|
24096
24224
|
const shadowed = new Set(expr.params.map((p) => deSSAVarName(p.name)));
|
|
24097
24225
|
const localDeclared = collectLocalDeclaredNames(
|
|
24098
24226
|
expr.params,
|
|
@@ -24140,7 +24268,12 @@ function lowerExpressionImpl(expr, ctx, _isAssigned = false) {
|
|
|
24140
24268
|
case "FunctionExpression": {
|
|
24141
24269
|
const reactiveLowered = lowerReactiveScopeExpression(expr);
|
|
24142
24270
|
if (reactiveLowered) return reactiveLowered;
|
|
24143
|
-
const
|
|
24271
|
+
const useRawParams = expr.rawParams && expr.rawParams.length > 0 && expr.rawParams.every(
|
|
24272
|
+
(param) => t4.isIdentifier(param) || t4.isRestElement(param) && t4.isIdentifier(param.argument)
|
|
24273
|
+
);
|
|
24274
|
+
const paramIds = useRawParams ? expr.rawParams.map(
|
|
24275
|
+
(param) => t4.cloneNode(param, true)
|
|
24276
|
+
) : mapParams(expr.params);
|
|
24144
24277
|
const shadowed = new Set(expr.params.map((p) => deSSAVarName(p.name)));
|
|
24145
24278
|
const localDeclared = collectLocalDeclaredNames(expr.params, expr.body, t4);
|
|
24146
24279
|
return withNonReactiveScope(
|
|
@@ -25025,17 +25158,280 @@ function resolveNamespaceContext(tagName, parentNamespace) {
|
|
|
25025
25158
|
if (tagName === "foreignObject" && parentNamespace === "svg") return null;
|
|
25026
25159
|
return parentNamespace;
|
|
25027
25160
|
}
|
|
25161
|
+
function countExpressionNodes(expr) {
|
|
25162
|
+
if (!expr) return 0;
|
|
25163
|
+
let count = 1;
|
|
25164
|
+
switch (expr.kind) {
|
|
25165
|
+
case "Literal":
|
|
25166
|
+
return 1;
|
|
25167
|
+
case "Identifier":
|
|
25168
|
+
return 1;
|
|
25169
|
+
case "BinaryExpression":
|
|
25170
|
+
case "LogicalExpression":
|
|
25171
|
+
count += countExpressionNodes(expr.left);
|
|
25172
|
+
count += countExpressionNodes(expr.right);
|
|
25173
|
+
return count;
|
|
25174
|
+
case "UnaryExpression":
|
|
25175
|
+
count += countExpressionNodes(expr.argument);
|
|
25176
|
+
return count;
|
|
25177
|
+
case "ConditionalExpression":
|
|
25178
|
+
count += countExpressionNodes(expr.test);
|
|
25179
|
+
count += countExpressionNodes(expr.consequent);
|
|
25180
|
+
count += countExpressionNodes(expr.alternate);
|
|
25181
|
+
return count;
|
|
25182
|
+
case "CallExpression":
|
|
25183
|
+
count += countExpressionNodes(expr.callee);
|
|
25184
|
+
for (const arg of expr.arguments) {
|
|
25185
|
+
count += countExpressionNodes(arg);
|
|
25186
|
+
}
|
|
25187
|
+
return count;
|
|
25188
|
+
case "MemberExpression":
|
|
25189
|
+
count += countExpressionNodes(expr.object);
|
|
25190
|
+
if (expr.computed && expr.property) {
|
|
25191
|
+
count += countExpressionNodes(expr.property);
|
|
25192
|
+
}
|
|
25193
|
+
return count;
|
|
25194
|
+
case "ArrayExpression":
|
|
25195
|
+
for (const elem of expr.elements) {
|
|
25196
|
+
if (elem) count += countExpressionNodes(elem);
|
|
25197
|
+
}
|
|
25198
|
+
return count;
|
|
25199
|
+
case "ObjectExpression":
|
|
25200
|
+
for (const prop of expr.properties) {
|
|
25201
|
+
if (prop.kind === "Property") {
|
|
25202
|
+
count += countExpressionNodes(prop.value);
|
|
25203
|
+
} else if (prop.kind === "SpreadElement") {
|
|
25204
|
+
count += countExpressionNodes(prop.argument);
|
|
25205
|
+
}
|
|
25206
|
+
}
|
|
25207
|
+
return count;
|
|
25208
|
+
case "ArrowFunction":
|
|
25209
|
+
if (expr.isExpression && expr.body && !Array.isArray(expr.body)) {
|
|
25210
|
+
count += countExpressionNodes(expr.body);
|
|
25211
|
+
} else if (Array.isArray(expr.body)) {
|
|
25212
|
+
for (const block of expr.body) {
|
|
25213
|
+
count += countBlockNodes(block);
|
|
25214
|
+
}
|
|
25215
|
+
}
|
|
25216
|
+
return count;
|
|
25217
|
+
case "FunctionExpression":
|
|
25218
|
+
if (expr.body) {
|
|
25219
|
+
for (const block of expr.body) {
|
|
25220
|
+
count += countBlockNodes(block);
|
|
25221
|
+
}
|
|
25222
|
+
}
|
|
25223
|
+
return count;
|
|
25224
|
+
case "AssignmentExpression":
|
|
25225
|
+
count += countExpressionNodes(expr.left);
|
|
25226
|
+
count += countExpressionNodes(expr.right);
|
|
25227
|
+
return count;
|
|
25228
|
+
case "UpdateExpression":
|
|
25229
|
+
count += countExpressionNodes(expr.argument);
|
|
25230
|
+
return count;
|
|
25231
|
+
case "SequenceExpression":
|
|
25232
|
+
for (const e of expr.expressions) {
|
|
25233
|
+
count += countExpressionNodes(e);
|
|
25234
|
+
}
|
|
25235
|
+
return count;
|
|
25236
|
+
case "AwaitExpression":
|
|
25237
|
+
count += countExpressionNodes(expr.argument);
|
|
25238
|
+
return count + 2;
|
|
25239
|
+
// Async adds complexity
|
|
25240
|
+
case "NewExpression":
|
|
25241
|
+
count += countExpressionNodes(expr.callee);
|
|
25242
|
+
for (const arg of expr.arguments) {
|
|
25243
|
+
count += countExpressionNodes(arg);
|
|
25244
|
+
}
|
|
25245
|
+
return count;
|
|
25246
|
+
case "TemplateLiteral":
|
|
25247
|
+
for (const e of expr.expressions) {
|
|
25248
|
+
count += countExpressionNodes(e);
|
|
25249
|
+
}
|
|
25250
|
+
return count;
|
|
25251
|
+
default:
|
|
25252
|
+
return count;
|
|
25253
|
+
}
|
|
25254
|
+
}
|
|
25255
|
+
function countBlockNodes(block) {
|
|
25256
|
+
let count = 1;
|
|
25257
|
+
for (const instr of block.instructions) {
|
|
25258
|
+
count += countInstructionNodes(instr);
|
|
25259
|
+
}
|
|
25260
|
+
return count;
|
|
25261
|
+
}
|
|
25262
|
+
function countInstructionNodes(instr) {
|
|
25263
|
+
switch (instr.kind) {
|
|
25264
|
+
case "Expression":
|
|
25265
|
+
return 1 + countExpressionNodes(instr.value);
|
|
25266
|
+
case "Assign":
|
|
25267
|
+
return 1 + countExpressionNodes(instr.value);
|
|
25268
|
+
case "Phi":
|
|
25269
|
+
return 1;
|
|
25270
|
+
default:
|
|
25271
|
+
return 1;
|
|
25272
|
+
}
|
|
25273
|
+
}
|
|
25274
|
+
function hasExternalCalls(expr) {
|
|
25275
|
+
if (!expr) return false;
|
|
25276
|
+
switch (expr.kind) {
|
|
25277
|
+
case "CallExpression": {
|
|
25278
|
+
if (expr.callee.kind === "Identifier") {
|
|
25279
|
+
const name = expr.callee.name;
|
|
25280
|
+
if (!["console", "Math", "JSON", "Object", "Array"].includes(name)) {
|
|
25281
|
+
return true;
|
|
25282
|
+
}
|
|
25283
|
+
}
|
|
25284
|
+
if (expr.callee.kind === "MemberExpression") {
|
|
25285
|
+
return true;
|
|
25286
|
+
}
|
|
25287
|
+
for (const arg of expr.arguments) {
|
|
25288
|
+
if (hasExternalCalls(arg)) return true;
|
|
25289
|
+
}
|
|
25290
|
+
return false;
|
|
25291
|
+
}
|
|
25292
|
+
case "ArrowFunction":
|
|
25293
|
+
if (expr.isExpression && expr.body && !Array.isArray(expr.body)) {
|
|
25294
|
+
return hasExternalCalls(expr.body);
|
|
25295
|
+
} else if (Array.isArray(expr.body)) {
|
|
25296
|
+
for (const block of expr.body) {
|
|
25297
|
+
if (blockHasExternalCalls(block)) return true;
|
|
25298
|
+
}
|
|
25299
|
+
}
|
|
25300
|
+
return false;
|
|
25301
|
+
case "FunctionExpression":
|
|
25302
|
+
if (expr.body) {
|
|
25303
|
+
for (const block of expr.body) {
|
|
25304
|
+
if (blockHasExternalCalls(block)) return true;
|
|
25305
|
+
}
|
|
25306
|
+
}
|
|
25307
|
+
return false;
|
|
25308
|
+
case "BinaryExpression":
|
|
25309
|
+
case "LogicalExpression":
|
|
25310
|
+
return hasExternalCalls(expr.left) || hasExternalCalls(expr.right);
|
|
25311
|
+
case "UnaryExpression":
|
|
25312
|
+
return hasExternalCalls(expr.argument);
|
|
25313
|
+
case "ConditionalExpression":
|
|
25314
|
+
return hasExternalCalls(expr.test) || hasExternalCalls(expr.consequent) || hasExternalCalls(expr.alternate);
|
|
25315
|
+
case "MemberExpression":
|
|
25316
|
+
return hasExternalCalls(expr.object);
|
|
25317
|
+
case "AssignmentExpression":
|
|
25318
|
+
return hasExternalCalls(expr.right);
|
|
25319
|
+
case "SequenceExpression":
|
|
25320
|
+
return expr.expressions.some((e) => hasExternalCalls(e));
|
|
25321
|
+
case "AwaitExpression":
|
|
25322
|
+
return true;
|
|
25323
|
+
// Await implies async external operation
|
|
25324
|
+
case "NewExpression":
|
|
25325
|
+
return true;
|
|
25326
|
+
// Constructor calls are external
|
|
25327
|
+
default:
|
|
25328
|
+
return false;
|
|
25329
|
+
}
|
|
25330
|
+
}
|
|
25331
|
+
function blockHasExternalCalls(block) {
|
|
25332
|
+
for (const instr of block.instructions) {
|
|
25333
|
+
if (instructionHasExternalCalls(instr)) return true;
|
|
25334
|
+
}
|
|
25335
|
+
return false;
|
|
25336
|
+
}
|
|
25337
|
+
function instructionHasExternalCalls(instr) {
|
|
25338
|
+
switch (instr.kind) {
|
|
25339
|
+
case "Expression":
|
|
25340
|
+
return hasExternalCalls(instr.value);
|
|
25341
|
+
case "Assign":
|
|
25342
|
+
return hasExternalCalls(instr.value);
|
|
25343
|
+
default:
|
|
25344
|
+
return false;
|
|
25345
|
+
}
|
|
25346
|
+
}
|
|
25347
|
+
function hasAsyncAwait(expr) {
|
|
25348
|
+
if (!expr) return false;
|
|
25349
|
+
switch (expr.kind) {
|
|
25350
|
+
case "AwaitExpression":
|
|
25351
|
+
return true;
|
|
25352
|
+
case "ArrowFunction":
|
|
25353
|
+
if (expr.isAsync) return true;
|
|
25354
|
+
if (expr.isExpression && expr.body && !Array.isArray(expr.body)) {
|
|
25355
|
+
return hasAsyncAwait(expr.body);
|
|
25356
|
+
} else if (Array.isArray(expr.body)) {
|
|
25357
|
+
for (const block of expr.body) {
|
|
25358
|
+
if (blockHasAsyncAwait(block)) return true;
|
|
25359
|
+
}
|
|
25360
|
+
}
|
|
25361
|
+
return false;
|
|
25362
|
+
case "FunctionExpression":
|
|
25363
|
+
if (expr.isAsync) return true;
|
|
25364
|
+
if (expr.body) {
|
|
25365
|
+
for (const block of expr.body) {
|
|
25366
|
+
if (blockHasAsyncAwait(block)) return true;
|
|
25367
|
+
}
|
|
25368
|
+
}
|
|
25369
|
+
return false;
|
|
25370
|
+
case "CallExpression":
|
|
25371
|
+
if (hasAsyncAwait(expr.callee)) return true;
|
|
25372
|
+
return expr.arguments.some((arg) => hasAsyncAwait(arg));
|
|
25373
|
+
case "BinaryExpression":
|
|
25374
|
+
case "LogicalExpression":
|
|
25375
|
+
return hasAsyncAwait(expr.left) || hasAsyncAwait(expr.right);
|
|
25376
|
+
case "ConditionalExpression":
|
|
25377
|
+
return hasAsyncAwait(expr.test) || hasAsyncAwait(expr.consequent) || hasAsyncAwait(expr.alternate);
|
|
25378
|
+
case "SequenceExpression":
|
|
25379
|
+
return expr.expressions.some((e) => hasAsyncAwait(e));
|
|
25380
|
+
default:
|
|
25381
|
+
return false;
|
|
25382
|
+
}
|
|
25383
|
+
}
|
|
25384
|
+
function blockHasAsyncAwait(block) {
|
|
25385
|
+
for (const instr of block.instructions) {
|
|
25386
|
+
if (instructionHasAsyncAwait(instr)) return true;
|
|
25387
|
+
}
|
|
25388
|
+
return false;
|
|
25389
|
+
}
|
|
25390
|
+
function instructionHasAsyncAwait(instr) {
|
|
25391
|
+
switch (instr.kind) {
|
|
25392
|
+
case "Expression":
|
|
25393
|
+
return hasAsyncAwait(instr.value);
|
|
25394
|
+
case "Assign":
|
|
25395
|
+
return hasAsyncAwait(instr.value);
|
|
25396
|
+
default:
|
|
25397
|
+
return false;
|
|
25398
|
+
}
|
|
25399
|
+
}
|
|
25400
|
+
function shouldAutoExtract(expr, ctx) {
|
|
25401
|
+
if (!expr) return false;
|
|
25402
|
+
if (!ctx.autoExtractEnabled) return false;
|
|
25403
|
+
const threshold = ctx.autoExtractThreshold ?? 3;
|
|
25404
|
+
if (expr.kind === "Identifier") {
|
|
25405
|
+
return true;
|
|
25406
|
+
}
|
|
25407
|
+
if (expr.kind === "ArrowFunction" || expr.kind === "FunctionExpression") {
|
|
25408
|
+
if (expr.kind === "ArrowFunction" && expr.isAsync || expr.kind === "FunctionExpression" && expr.isAsync || hasAsyncAwait(expr)) {
|
|
25409
|
+
return true;
|
|
25410
|
+
}
|
|
25411
|
+
if (hasExternalCalls(expr)) {
|
|
25412
|
+
return true;
|
|
25413
|
+
}
|
|
25414
|
+
const nodeCount2 = countExpressionNodes(expr);
|
|
25415
|
+
if (nodeCount2 >= threshold) {
|
|
25416
|
+
return true;
|
|
25417
|
+
}
|
|
25418
|
+
return false;
|
|
25419
|
+
}
|
|
25420
|
+
const nodeCount = countExpressionNodes(expr);
|
|
25421
|
+
return nodeCount >= threshold;
|
|
25422
|
+
}
|
|
25028
25423
|
function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
25029
25424
|
if (jsx.isComponent || typeof jsx.tagName !== "string") {
|
|
25030
25425
|
return {
|
|
25031
|
-
html: "
|
|
25426
|
+
html: "<!--fict:slot:start--><!--fict:slot:end-->",
|
|
25032
25427
|
bindings: [
|
|
25033
25428
|
{
|
|
25034
25429
|
type: "child",
|
|
25035
25430
|
path: [...parentPath],
|
|
25036
25431
|
expr: jsx
|
|
25037
25432
|
}
|
|
25038
|
-
]
|
|
25433
|
+
],
|
|
25434
|
+
nodeCount: 1
|
|
25039
25435
|
};
|
|
25040
25436
|
}
|
|
25041
25437
|
const tagName = jsx.tagName;
|
|
@@ -25046,7 +25442,11 @@ function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
|
25046
25442
|
if (attr.isSpread) {
|
|
25047
25443
|
continue;
|
|
25048
25444
|
}
|
|
25049
|
-
|
|
25445
|
+
let name = normalizeHIRAttrName(attr.name);
|
|
25446
|
+
const isResumableEvent = name.endsWith("$");
|
|
25447
|
+
if (isResumableEvent) {
|
|
25448
|
+
name = name.slice(0, -1);
|
|
25449
|
+
}
|
|
25050
25450
|
if (name === "key") {
|
|
25051
25451
|
if (attr.value && !isStaticValue(attr.value)) {
|
|
25052
25452
|
bindings.push({
|
|
@@ -25081,12 +25481,14 @@ function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
|
25081
25481
|
changed = true;
|
|
25082
25482
|
}
|
|
25083
25483
|
}
|
|
25484
|
+
const shouldBeResumable = isResumableEvent && ctx.resumableEnabled || !isResumableEvent && ctx.resumableEnabled && shouldAutoExtract(attr.value ?? void 0, ctx);
|
|
25084
25485
|
bindings.push({
|
|
25085
25486
|
type: "event",
|
|
25086
25487
|
path: [...parentPath],
|
|
25087
25488
|
name: eventName.toLowerCase(),
|
|
25088
25489
|
expr: attr.value ?? void 0,
|
|
25089
|
-
eventOptions: { capture, passive, once }
|
|
25490
|
+
eventOptions: { capture, passive, once },
|
|
25491
|
+
resumable: shouldBeResumable
|
|
25090
25492
|
});
|
|
25091
25493
|
continue;
|
|
25092
25494
|
}
|
|
@@ -25142,7 +25544,7 @@ function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
|
25142
25544
|
const childResult = extractHIRStaticHtml(child.value, ctx, childPath, resolvedNamespace);
|
|
25143
25545
|
html += childResult.html;
|
|
25144
25546
|
bindings.push(...childResult.bindings);
|
|
25145
|
-
childIndex
|
|
25547
|
+
childIndex += childResult.nodeCount;
|
|
25146
25548
|
} else if (child.kind === "expression") {
|
|
25147
25549
|
const inline = hasAdjacentInline(i);
|
|
25148
25550
|
if (!inline && isLikelyTextExpression(child.value, ctx)) {
|
|
@@ -25155,7 +25557,7 @@ function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
|
25155
25557
|
namespace: resolvedNamespace
|
|
25156
25558
|
});
|
|
25157
25559
|
} else {
|
|
25158
|
-
html += "
|
|
25560
|
+
html += "<!--fict:slot:start--><!--fict:slot:end-->";
|
|
25159
25561
|
bindings.push({
|
|
25160
25562
|
type: "child",
|
|
25161
25563
|
path: [...parentPath, childIndex],
|
|
@@ -25163,6 +25565,8 @@ function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
|
25163
25565
|
// Track namespace for dynamic child bindings
|
|
25164
25566
|
namespace: resolvedNamespace
|
|
25165
25567
|
});
|
|
25568
|
+
childIndex++;
|
|
25569
|
+
continue;
|
|
25166
25570
|
}
|
|
25167
25571
|
childIndex++;
|
|
25168
25572
|
}
|
|
@@ -25173,6 +25577,7 @@ function extractHIRStaticHtml(jsx, ctx, parentPath = [], namespace = null) {
|
|
|
25173
25577
|
return {
|
|
25174
25578
|
html,
|
|
25175
25579
|
bindings,
|
|
25580
|
+
nodeCount: 1,
|
|
25176
25581
|
isSVG: needsSVG || void 0,
|
|
25177
25582
|
isMathML: needsMathML || void 0
|
|
25178
25583
|
};
|
|
@@ -25264,6 +25669,17 @@ function lowerIntrinsicElement(jsx, ctx) {
|
|
|
25264
25669
|
const eventName = binding.name;
|
|
25265
25670
|
const hasEventOptions = binding.eventOptions && (binding.eventOptions.capture || binding.eventOptions.passive || binding.eventOptions.once);
|
|
25266
25671
|
const isDelegated = DelegatedEvents.has(eventName) && !hasEventOptions;
|
|
25672
|
+
if (binding.resumable && !hasEventOptions) {
|
|
25673
|
+
emitResumableEventBinding(
|
|
25674
|
+
targetId,
|
|
25675
|
+
eventName,
|
|
25676
|
+
binding.expr,
|
|
25677
|
+
statements,
|
|
25678
|
+
ctx,
|
|
25679
|
+
containingRegion
|
|
25680
|
+
);
|
|
25681
|
+
continue;
|
|
25682
|
+
}
|
|
25267
25683
|
const hirDataBinding = isDelegated && binding.expr ? extractDelegatedEventDataFromHIR(binding.expr, ctx) : null;
|
|
25268
25684
|
if (hirDataBinding) {
|
|
25269
25685
|
ctx.delegatedEventsUsed?.add(eventName);
|
|
@@ -25560,13 +25976,16 @@ function resolveHIRBindingPath(path2, cache, statements, ctx) {
|
|
|
25560
25976
|
ancestorId = cache.get("");
|
|
25561
25977
|
relativePath = path2;
|
|
25562
25978
|
}
|
|
25563
|
-
|
|
25564
|
-
|
|
25565
|
-
|
|
25566
|
-
for (let i = 0; i < index; i++) {
|
|
25567
|
-
currentExpr = t4.memberExpression(currentExpr, t4.identifier("nextSibling"));
|
|
25568
|
-
}
|
|
25979
|
+
if (relativePath.length === 0) {
|
|
25980
|
+
cache.set(key, ancestorId);
|
|
25981
|
+
return ancestorId;
|
|
25569
25982
|
}
|
|
25983
|
+
ctx.helpersUsed.add("resolvePath");
|
|
25984
|
+
const pathExpr = t4.arrayExpression(relativePath.map((index) => t4.numericLiteral(index)));
|
|
25985
|
+
const currentExpr = t4.callExpression(t4.identifier(RUNTIME_ALIASES.resolvePath), [
|
|
25986
|
+
ancestorId,
|
|
25987
|
+
pathExpr
|
|
25988
|
+
]);
|
|
25570
25989
|
const varId = genTemp(ctx, "el");
|
|
25571
25990
|
statements.push(t4.variableDeclaration("const", [t4.variableDeclarator(varId, currentExpr)]));
|
|
25572
25991
|
cache.set(key, varId);
|
|
@@ -25574,7 +25993,16 @@ function resolveHIRBindingPath(path2, cache, statements, ctx) {
|
|
|
25574
25993
|
}
|
|
25575
25994
|
function emitHIRChildBinding(markerId, expr, statements, ctx, containingRegion, namespace) {
|
|
25576
25995
|
const { t: t4 } = ctx;
|
|
25577
|
-
|
|
25996
|
+
ctx.helpersUsed.add("getSlotEnd");
|
|
25997
|
+
const endMarkerId = genTemp(ctx, "end");
|
|
25998
|
+
statements.push(
|
|
25999
|
+
t4.variableDeclaration("const", [
|
|
26000
|
+
t4.variableDeclarator(
|
|
26001
|
+
endMarkerId,
|
|
26002
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.getSlotEnd), [markerId])
|
|
26003
|
+
)
|
|
26004
|
+
])
|
|
26005
|
+
);
|
|
25578
26006
|
if (namespace !== void 0) {
|
|
25579
26007
|
ctx.namespaceContext = namespace;
|
|
25580
26008
|
}
|
|
@@ -25593,26 +26021,26 @@ function emitHIRChildBinding(markerId, expr, statements, ctx, containingRegion,
|
|
|
25593
26021
|
return;
|
|
25594
26022
|
}
|
|
25595
26023
|
if (expr.kind === "ConditionalExpression" || expr.kind === "LogicalExpression" && expr.operator === "&&") {
|
|
25596
|
-
emitConditionalChild(
|
|
26024
|
+
emitConditionalChild(markerId, endMarkerId, expr, statements, ctx);
|
|
25597
26025
|
return;
|
|
25598
26026
|
}
|
|
25599
26027
|
if (expr.kind === "CallExpression" || expr.kind === "OptionalCallExpression") {
|
|
25600
26028
|
const callee = expr.callee;
|
|
25601
26029
|
if ((callee.kind === "MemberExpression" || callee.kind === "OptionalMemberExpression") && callee.property.kind === "Identifier" && callee.property.name === "map") {
|
|
25602
|
-
emitListChild(
|
|
26030
|
+
emitListChild(markerId, endMarkerId, expr, statements, ctx);
|
|
25603
26031
|
return;
|
|
25604
26032
|
}
|
|
25605
26033
|
}
|
|
25606
26034
|
if (expr.kind === "JSXElement") {
|
|
25607
26035
|
const childExpr = lowerJSXElement(expr, ctx);
|
|
25608
|
-
ctx.helpersUsed.add("
|
|
26036
|
+
ctx.helpersUsed.add("insertBetween");
|
|
25609
26037
|
ctx.helpersUsed.add("createElement");
|
|
25610
26038
|
statements.push(
|
|
25611
26039
|
t4.expressionStatement(
|
|
25612
|
-
t4.callExpression(t4.identifier(RUNTIME_ALIASES.
|
|
25613
|
-
parentId,
|
|
25614
|
-
t4.arrowFunctionExpression([], childExpr),
|
|
26040
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.insertBetween), [
|
|
25615
26041
|
markerId,
|
|
26042
|
+
endMarkerId,
|
|
26043
|
+
t4.arrowFunctionExpression([], childExpr),
|
|
25616
26044
|
t4.identifier(RUNTIME_ALIASES.createElement)
|
|
25617
26045
|
])
|
|
25618
26046
|
)
|
|
@@ -25620,20 +26048,280 @@ function emitHIRChildBinding(markerId, expr, statements, ctx, containingRegion,
|
|
|
25620
26048
|
return;
|
|
25621
26049
|
}
|
|
25622
26050
|
const valueExpr = lowerDomExpression(expr, ctx, containingRegion);
|
|
25623
|
-
ctx.helpersUsed.add("
|
|
26051
|
+
ctx.helpersUsed.add("insertBetween");
|
|
25624
26052
|
ctx.helpersUsed.add("createElement");
|
|
25625
26053
|
statements.push(
|
|
25626
26054
|
t4.expressionStatement(
|
|
25627
|
-
t4.callExpression(t4.identifier(RUNTIME_ALIASES.
|
|
25628
|
-
parentId,
|
|
25629
|
-
t4.arrowFunctionExpression([], valueExpr),
|
|
26055
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.insertBetween), [
|
|
25630
26056
|
markerId,
|
|
26057
|
+
endMarkerId,
|
|
26058
|
+
t4.arrowFunctionExpression([], valueExpr),
|
|
25631
26059
|
t4.identifier(RUNTIME_ALIASES.createElement)
|
|
25632
26060
|
])
|
|
25633
26061
|
)
|
|
25634
26062
|
);
|
|
25635
26063
|
}
|
|
25636
|
-
function
|
|
26064
|
+
function emitResumableEventBinding(targetId, eventName, expr, statements, ctx, containingRegion) {
|
|
26065
|
+
const { t: t4 } = ctx;
|
|
26066
|
+
if (!ctx.resumableEnabled) {
|
|
26067
|
+
return;
|
|
26068
|
+
}
|
|
26069
|
+
const prevWrapTracked = ctx.wrapTrackedExpressions;
|
|
26070
|
+
ctx.wrapTrackedExpressions = false;
|
|
26071
|
+
const valueExpr = lowerDomExpression(expr, ctx, containingRegion, {
|
|
26072
|
+
skipHookAccessors: true,
|
|
26073
|
+
skipRegionRootOverride: true
|
|
26074
|
+
});
|
|
26075
|
+
ctx.wrapTrackedExpressions = prevWrapTracked;
|
|
26076
|
+
const eventParam = t4.identifier("event");
|
|
26077
|
+
const elParam = t4.identifier("el");
|
|
26078
|
+
const scopeParam = t4.identifier("scopeId");
|
|
26079
|
+
const ensureHandlerParam = (fn) => {
|
|
26080
|
+
if (t4.isArrowFunctionExpression(fn)) {
|
|
26081
|
+
if (fn.params.length > 0) return fn;
|
|
26082
|
+
return t4.arrowFunctionExpression([eventParam], fn.body, fn.async);
|
|
26083
|
+
}
|
|
26084
|
+
if (t4.isFunctionExpression(fn)) {
|
|
26085
|
+
if (fn.params.length > 0) return fn;
|
|
26086
|
+
return t4.functionExpression(fn.id, [eventParam], fn.body, fn.generator, fn.async);
|
|
26087
|
+
}
|
|
26088
|
+
if (t4.isIdentifier(fn) || t4.isMemberExpression(fn)) {
|
|
26089
|
+
return fn;
|
|
26090
|
+
}
|
|
26091
|
+
if (t4.isCallExpression(fn) && fn.arguments.length === 0 && (t4.isIdentifier(fn.callee) || t4.isMemberExpression(fn.callee))) {
|
|
26092
|
+
return fn.callee;
|
|
26093
|
+
}
|
|
26094
|
+
return t4.functionExpression(
|
|
26095
|
+
null,
|
|
26096
|
+
[eventParam],
|
|
26097
|
+
t4.blockStatement([
|
|
26098
|
+
t4.returnStatement(
|
|
26099
|
+
t4.callExpression(
|
|
26100
|
+
t4.memberExpression(fn, t4.identifier("call")),
|
|
26101
|
+
[t4.thisExpression(), eventParam]
|
|
26102
|
+
)
|
|
26103
|
+
)
|
|
26104
|
+
])
|
|
26105
|
+
);
|
|
26106
|
+
};
|
|
26107
|
+
const handlerExpr = ensureHandlerParam(valueExpr);
|
|
26108
|
+
const handlerId = t4.identifier(`__fict_e${ctx.resumableHandlerCounter ?? 0}`);
|
|
26109
|
+
ctx.resumableHandlerCounter = (ctx.resumableHandlerCounter ?? 0) + 1;
|
|
26110
|
+
const captured = /* @__PURE__ */ new Set();
|
|
26111
|
+
collectExpressionIdentifiersDeep(expr, captured);
|
|
26112
|
+
const lexicalNames = Array.from(captured).filter((name) => ctx.signalVars?.has(name));
|
|
26113
|
+
const propsName = ctx.propsParamName && captured.has(ctx.propsParamName) ? ctx.propsParamName : null;
|
|
26114
|
+
const functionDeps = [];
|
|
26115
|
+
const functionDepRenames = /* @__PURE__ */ new Map();
|
|
26116
|
+
for (const name of captured) {
|
|
26117
|
+
if (ctx.functionVars?.has(name) && !ctx.signalVars?.has(name)) {
|
|
26118
|
+
const hirDef = ctx.componentFunctionDefs?.get(name);
|
|
26119
|
+
if (hirDef) {
|
|
26120
|
+
functionDeps.push(name);
|
|
26121
|
+
let hoistedName = ctx.hoistedFunctionDepNames?.get(name);
|
|
26122
|
+
if (!hoistedName) {
|
|
26123
|
+
hoistedName = `__fict_fn_${name}_${ctx.hoistedFunctionDepCounter ?? 0}`;
|
|
26124
|
+
ctx.hoistedFunctionDepCounter = (ctx.hoistedFunctionDepCounter ?? 0) + 1;
|
|
26125
|
+
ctx.hoistedFunctionDepNames?.set(name, hoistedName);
|
|
26126
|
+
const loweredFn = lowerDomExpression(hirDef, ctx, null, {
|
|
26127
|
+
skipHookAccessors: true,
|
|
26128
|
+
skipRegionRootOverride: true
|
|
26129
|
+
});
|
|
26130
|
+
const hoistedDecl = t4.variableDeclaration("const", [
|
|
26131
|
+
t4.variableDeclarator(t4.identifier(hoistedName), loweredFn)
|
|
26132
|
+
]);
|
|
26133
|
+
const hoistedExport = t4.exportNamedDeclaration(hoistedDecl, []);
|
|
26134
|
+
ctx.hoistedResumableStatements?.push(hoistedExport);
|
|
26135
|
+
}
|
|
26136
|
+
functionDepRenames.set(name, hoistedName);
|
|
26137
|
+
}
|
|
26138
|
+
}
|
|
26139
|
+
}
|
|
26140
|
+
let finalHandlerExpr = handlerExpr;
|
|
26141
|
+
if (functionDepRenames.size > 0) {
|
|
26142
|
+
finalHandlerExpr = renameIdentifiersInExpr(handlerExpr, functionDepRenames, t4);
|
|
26143
|
+
}
|
|
26144
|
+
const bodyStatements = [];
|
|
26145
|
+
if (lexicalNames.length > 0) {
|
|
26146
|
+
ctx.helpersUsed.add("useLexicalScope");
|
|
26147
|
+
bodyStatements.push(
|
|
26148
|
+
t4.variableDeclaration("const", [
|
|
26149
|
+
t4.variableDeclarator(
|
|
26150
|
+
t4.arrayPattern(lexicalNames.map((name) => t4.identifier(name))),
|
|
26151
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.useLexicalScope), [
|
|
26152
|
+
scopeParam,
|
|
26153
|
+
t4.arrayExpression(lexicalNames.map((name) => t4.stringLiteral(name)))
|
|
26154
|
+
])
|
|
26155
|
+
)
|
|
26156
|
+
])
|
|
26157
|
+
);
|
|
26158
|
+
}
|
|
26159
|
+
if (propsName) {
|
|
26160
|
+
ctx.helpersUsed.add("getScopeProps");
|
|
26161
|
+
bodyStatements.push(
|
|
26162
|
+
t4.variableDeclaration("const", [
|
|
26163
|
+
t4.variableDeclarator(
|
|
26164
|
+
t4.identifier(propsName),
|
|
26165
|
+
t4.logicalExpression(
|
|
26166
|
+
"||",
|
|
26167
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.getScopeProps), [scopeParam]),
|
|
26168
|
+
t4.objectExpression([])
|
|
26169
|
+
)
|
|
26170
|
+
)
|
|
26171
|
+
])
|
|
26172
|
+
);
|
|
26173
|
+
}
|
|
26174
|
+
const handlerVar = t4.identifier("__handler");
|
|
26175
|
+
bodyStatements.push(
|
|
26176
|
+
t4.variableDeclaration("const", [t4.variableDeclarator(handlerVar, finalHandlerExpr)])
|
|
26177
|
+
);
|
|
26178
|
+
bodyStatements.push(
|
|
26179
|
+
t4.returnStatement(
|
|
26180
|
+
t4.callExpression(t4.memberExpression(handlerVar, t4.identifier("call")), [elParam, eventParam])
|
|
26181
|
+
)
|
|
26182
|
+
);
|
|
26183
|
+
const exportedHandler = t4.exportNamedDeclaration(
|
|
26184
|
+
t4.variableDeclaration("const", [
|
|
26185
|
+
t4.variableDeclarator(
|
|
26186
|
+
handlerId,
|
|
26187
|
+
t4.arrowFunctionExpression(
|
|
26188
|
+
[scopeParam, eventParam, elParam],
|
|
26189
|
+
t4.blockStatement(bodyStatements)
|
|
26190
|
+
)
|
|
26191
|
+
)
|
|
26192
|
+
]),
|
|
26193
|
+
[]
|
|
26194
|
+
);
|
|
26195
|
+
ctx.hoistedResumableStatements?.push(exportedHandler);
|
|
26196
|
+
ctx.helpersUsed.add("qrl");
|
|
26197
|
+
const qrlExpr = t4.callExpression(t4.identifier(RUNTIME_ALIASES.qrl), [
|
|
26198
|
+
genModuleUrlExpr(ctx),
|
|
26199
|
+
t4.stringLiteral(handlerId.name)
|
|
26200
|
+
]);
|
|
26201
|
+
statements.push(
|
|
26202
|
+
t4.expressionStatement(
|
|
26203
|
+
t4.callExpression(t4.memberExpression(targetId, t4.identifier("setAttribute")), [
|
|
26204
|
+
t4.stringLiteral(`on:${eventName}`),
|
|
26205
|
+
qrlExpr
|
|
26206
|
+
])
|
|
26207
|
+
)
|
|
26208
|
+
);
|
|
26209
|
+
}
|
|
26210
|
+
function registerResumableComponent(componentName, ctx) {
|
|
26211
|
+
if (!ctx.resumableEnabled) return;
|
|
26212
|
+
if (!ctx.hoistedResumableStatements || !ctx.resumableComponents) return;
|
|
26213
|
+
if (ctx.resumableComponents.has(componentName)) return;
|
|
26214
|
+
const { t: t4 } = ctx;
|
|
26215
|
+
const resumeExport = `__fict_r${ctx.resumableComponentCounter ?? 0}`;
|
|
26216
|
+
ctx.resumableComponentCounter = (ctx.resumableComponentCounter ?? 0) + 1;
|
|
26217
|
+
const scopeParam = t4.identifier("scopeId");
|
|
26218
|
+
const hostParam = t4.identifier("host");
|
|
26219
|
+
const snapshotId = t4.identifier("snapshot");
|
|
26220
|
+
const ctxId = t4.identifier("ctx");
|
|
26221
|
+
ctx.helpersUsed.add("getSSRScope");
|
|
26222
|
+
ctx.helpersUsed.add("ensureScope");
|
|
26223
|
+
ctx.helpersUsed.add("prepareContext");
|
|
26224
|
+
ctx.helpersUsed.add("pushContext");
|
|
26225
|
+
ctx.helpersUsed.add("popContext");
|
|
26226
|
+
ctx.helpersUsed.add("hydrateComponent");
|
|
26227
|
+
ctx.helpersUsed.add("qrl");
|
|
26228
|
+
const snapshotDecl = t4.variableDeclaration("const", [
|
|
26229
|
+
t4.variableDeclarator(
|
|
26230
|
+
snapshotId,
|
|
26231
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.getSSRScope), [scopeParam])
|
|
26232
|
+
)
|
|
26233
|
+
]);
|
|
26234
|
+
const earlyReturn = t4.ifStatement(t4.unaryExpression("!", snapshotId), t4.returnStatement());
|
|
26235
|
+
const ensureCtxDecl = t4.variableDeclaration("const", [
|
|
26236
|
+
t4.variableDeclarator(
|
|
26237
|
+
ctxId,
|
|
26238
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.ensureScope), [
|
|
26239
|
+
scopeParam,
|
|
26240
|
+
hostParam,
|
|
26241
|
+
snapshotId
|
|
26242
|
+
])
|
|
26243
|
+
)
|
|
26244
|
+
]);
|
|
26245
|
+
const prepareCtx = t4.expressionStatement(
|
|
26246
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.prepareContext), [ctxId])
|
|
26247
|
+
);
|
|
26248
|
+
const pushCtx = t4.expressionStatement(
|
|
26249
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.pushContext), [])
|
|
26250
|
+
);
|
|
26251
|
+
const hydrateCall = t4.expressionStatement(
|
|
26252
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.hydrateComponent), [
|
|
26253
|
+
t4.arrowFunctionExpression(
|
|
26254
|
+
[],
|
|
26255
|
+
t4.callExpression(t4.identifier(componentName), [
|
|
26256
|
+
t4.logicalExpression(
|
|
26257
|
+
"||",
|
|
26258
|
+
t4.memberExpression(snapshotId, t4.identifier("props")),
|
|
26259
|
+
t4.objectExpression([])
|
|
26260
|
+
)
|
|
26261
|
+
])
|
|
26262
|
+
),
|
|
26263
|
+
hostParam
|
|
26264
|
+
])
|
|
26265
|
+
);
|
|
26266
|
+
const popCtx = t4.expressionStatement(
|
|
26267
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.popContext), [])
|
|
26268
|
+
);
|
|
26269
|
+
const resumeFnId = t4.identifier(resumeExport);
|
|
26270
|
+
const resumeFn = t4.exportNamedDeclaration(
|
|
26271
|
+
t4.variableDeclaration("const", [
|
|
26272
|
+
t4.variableDeclarator(
|
|
26273
|
+
resumeFnId,
|
|
26274
|
+
t4.arrowFunctionExpression(
|
|
26275
|
+
[scopeParam, hostParam],
|
|
26276
|
+
t4.blockStatement([
|
|
26277
|
+
snapshotDecl,
|
|
26278
|
+
earlyReturn,
|
|
26279
|
+
ensureCtxDecl,
|
|
26280
|
+
t4.tryStatement(
|
|
26281
|
+
t4.blockStatement([prepareCtx, pushCtx, hydrateCall]),
|
|
26282
|
+
null,
|
|
26283
|
+
t4.blockStatement([popCtx])
|
|
26284
|
+
)
|
|
26285
|
+
])
|
|
26286
|
+
)
|
|
26287
|
+
)
|
|
26288
|
+
]),
|
|
26289
|
+
[]
|
|
26290
|
+
);
|
|
26291
|
+
ctx.helpersUsed.add("registerResume");
|
|
26292
|
+
const registerCall = t4.expressionStatement(
|
|
26293
|
+
t4.callExpression(t4.identifier(RUNTIME_ALIASES.registerResume), [
|
|
26294
|
+
t4.stringLiteral(resumeExport),
|
|
26295
|
+
resumeFnId
|
|
26296
|
+
])
|
|
26297
|
+
);
|
|
26298
|
+
const metaId = t4.identifier(`__fict_meta_${componentName}`);
|
|
26299
|
+
const moduleUrlExpr = genModuleUrlExpr(ctx);
|
|
26300
|
+
const typeKeyExpr = t4.binaryExpression("+", t4.stringLiteral(`${componentName}@`), moduleUrlExpr);
|
|
26301
|
+
const resumeQrlExpr = t4.callExpression(t4.identifier(RUNTIME_ALIASES.qrl), [
|
|
26302
|
+
genModuleUrlExpr(ctx),
|
|
26303
|
+
t4.stringLiteral(resumeExport)
|
|
26304
|
+
]);
|
|
26305
|
+
const metaDecl = t4.variableDeclaration("const", [
|
|
26306
|
+
t4.variableDeclarator(
|
|
26307
|
+
metaId,
|
|
26308
|
+
t4.objectExpression([
|
|
26309
|
+
t4.objectProperty(t4.identifier("id"), typeKeyExpr),
|
|
26310
|
+
t4.objectProperty(t4.identifier("resume"), resumeQrlExpr)
|
|
26311
|
+
])
|
|
26312
|
+
)
|
|
26313
|
+
]);
|
|
26314
|
+
const assignMeta = t4.expressionStatement(
|
|
26315
|
+
t4.assignmentExpression(
|
|
26316
|
+
"=",
|
|
26317
|
+
t4.memberExpression(t4.identifier(componentName), t4.identifier("__fictMeta")),
|
|
26318
|
+
metaId
|
|
26319
|
+
)
|
|
26320
|
+
);
|
|
26321
|
+
ctx.hoistedResumableStatements.push(resumeFn, registerCall, metaDecl, assignMeta);
|
|
26322
|
+
ctx.resumableComponents.set(componentName, { resumeExport, typeKey: componentName });
|
|
26323
|
+
}
|
|
26324
|
+
function emitConditionalChild(startMarkerId, endMarkerId, expr, statements, ctx) {
|
|
25637
26325
|
const { t: t4 } = ctx;
|
|
25638
26326
|
ctx.helpersUsed.add("conditional");
|
|
25639
26327
|
ctx.helpersUsed.add("createElement");
|
|
@@ -25674,7 +26362,10 @@ function emitConditionalChild(parentId, markerId, expr, statements, ctx) {
|
|
|
25674
26362
|
];
|
|
25675
26363
|
if (alternate) {
|
|
25676
26364
|
args.push(t4.arrowFunctionExpression([], alternate));
|
|
26365
|
+
} else {
|
|
26366
|
+
args.push(t4.identifier("undefined"));
|
|
25677
26367
|
}
|
|
26368
|
+
args.push(startMarkerId, endMarkerId);
|
|
25678
26369
|
statements.push(
|
|
25679
26370
|
t4.variableDeclaration("const", [
|
|
25680
26371
|
t4.variableDeclarator(
|
|
@@ -25683,14 +26374,6 @@ function emitConditionalChild(parentId, markerId, expr, statements, ctx) {
|
|
|
25683
26374
|
)
|
|
25684
26375
|
])
|
|
25685
26376
|
);
|
|
25686
|
-
statements.push(
|
|
25687
|
-
t4.expressionStatement(
|
|
25688
|
-
t4.callExpression(t4.memberExpression(parentId, t4.identifier("insertBefore")), [
|
|
25689
|
-
t4.memberExpression(bindingId, t4.identifier("marker")),
|
|
25690
|
-
markerId
|
|
25691
|
-
])
|
|
25692
|
-
)
|
|
25693
|
-
);
|
|
25694
26377
|
statements.push(
|
|
25695
26378
|
t4.expressionStatement(
|
|
25696
26379
|
t4.optionalCallExpression(
|
|
@@ -26155,6 +26838,8 @@ function buildListCallExpression(expr, statements, ctx) {
|
|
|
26155
26838
|
}
|
|
26156
26839
|
const keyExpr = extractKeyFromMapCallback(mapCallback);
|
|
26157
26840
|
const isKeyed = !!keyExpr;
|
|
26841
|
+
const hasRestParam = (mapCallback.kind === "ArrowFunction" || mapCallback.kind === "FunctionExpression") && Array.isArray(mapCallback.rawParams) && mapCallback.rawParams.some((param) => t4.isRestElement(param));
|
|
26842
|
+
const canConstifyKey = isKeyed && keyExpr && !hasRestParam;
|
|
26158
26843
|
if (isKeyed) {
|
|
26159
26844
|
ctx.helpersUsed.add("keyedList");
|
|
26160
26845
|
} else {
|
|
@@ -26168,7 +26853,7 @@ function buildListCallExpression(expr, statements, ctx) {
|
|
|
26168
26853
|
const prevListKeyExpr = ctx.listKeyExpr;
|
|
26169
26854
|
const prevListItemParamName = ctx.listItemParamName;
|
|
26170
26855
|
const prevListKeyParamName = ctx.listKeyParamName;
|
|
26171
|
-
if (
|
|
26856
|
+
if (canConstifyKey && keyExpr) {
|
|
26172
26857
|
ctx.listKeyExpr = keyExpr;
|
|
26173
26858
|
ctx.listKeyParamName = "__key";
|
|
26174
26859
|
if (mapCallback.kind === "ArrowFunction" || mapCallback.kind === "FunctionExpression") {
|
|
@@ -26254,7 +26939,7 @@ function buildListCallExpression(expr, statements, ctx) {
|
|
|
26254
26939
|
keyExprAst
|
|
26255
26940
|
);
|
|
26256
26941
|
const hasIndexParam = (t4.isArrowFunctionExpression(callbackExpr) || t4.isFunctionExpression(callbackExpr)) && callbackExpr.params.length >= 2;
|
|
26257
|
-
if (t4.isArrowFunctionExpression(callbackExpr) || t4.isFunctionExpression(callbackExpr)) {
|
|
26942
|
+
if (canConstifyKey && (t4.isArrowFunctionExpression(callbackExpr) || t4.isFunctionExpression(callbackExpr))) {
|
|
26258
26943
|
const newParams = [...callbackExpr.params];
|
|
26259
26944
|
while (newParams.length < 2) {
|
|
26260
26945
|
newParams.push(t4.identifier(newParams.length === 0 ? "__item" : "__index"));
|
|
@@ -26297,40 +26982,16 @@ function buildListCallExpression(expr, statements, ctx) {
|
|
|
26297
26982
|
}
|
|
26298
26983
|
return listCall;
|
|
26299
26984
|
}
|
|
26300
|
-
function emitListChild(
|
|
26985
|
+
function emitListChild(startMarkerId, endMarkerId, expr, statements, ctx) {
|
|
26301
26986
|
const { t: t4 } = ctx;
|
|
26302
26987
|
const listCall = buildListCallExpression(expr, statements, ctx);
|
|
26303
26988
|
if (!listCall) return;
|
|
26989
|
+
if (t4.isCallExpression(listCall)) {
|
|
26990
|
+
listCall.arguments.push(startMarkerId, endMarkerId);
|
|
26991
|
+
}
|
|
26304
26992
|
ctx.helpersUsed.add("onDestroy");
|
|
26305
|
-
ctx.helpersUsed.add("toNodeArray");
|
|
26306
26993
|
const listId = genTemp(ctx, "list");
|
|
26307
26994
|
statements.push(t4.variableDeclaration("const", [t4.variableDeclarator(listId, listCall)]));
|
|
26308
|
-
const markersId = genTemp(ctx, "markers");
|
|
26309
|
-
statements.push(
|
|
26310
|
-
t4.variableDeclaration("const", [
|
|
26311
|
-
t4.variableDeclarator(
|
|
26312
|
-
markersId,
|
|
26313
|
-
t4.callExpression(t4.identifier(RUNTIME_ALIASES.toNodeArray), [
|
|
26314
|
-
t4.memberExpression(listId, t4.identifier("marker"))
|
|
26315
|
-
])
|
|
26316
|
-
)
|
|
26317
|
-
])
|
|
26318
|
-
);
|
|
26319
|
-
const mId = genTemp(ctx, "m");
|
|
26320
|
-
statements.push(
|
|
26321
|
-
t4.forOfStatement(
|
|
26322
|
-
t4.variableDeclaration("const", [t4.variableDeclarator(mId)]),
|
|
26323
|
-
markersId,
|
|
26324
|
-
t4.blockStatement([
|
|
26325
|
-
t4.expressionStatement(
|
|
26326
|
-
t4.callExpression(t4.memberExpression(parentId, t4.identifier("insertBefore")), [
|
|
26327
|
-
mId,
|
|
26328
|
-
markerId
|
|
26329
|
-
])
|
|
26330
|
-
)
|
|
26331
|
-
])
|
|
26332
|
-
)
|
|
26333
|
-
);
|
|
26334
26995
|
statements.push(
|
|
26335
26996
|
t4.expressionStatement(
|
|
26336
26997
|
t4.optionalCallExpression(
|
|
@@ -26367,6 +27028,9 @@ function lowerHIRWithRegions(program, t4, options, macroAliases) {
|
|
|
26367
27028
|
program.functions.filter((fn) => !!fn.name).map((fn) => [fn.name, fn])
|
|
26368
27029
|
);
|
|
26369
27030
|
ctx.options = options;
|
|
27031
|
+
ctx.resumableEnabled = options?.resumable === true;
|
|
27032
|
+
ctx.autoExtractEnabled = options?.autoExtractHandlers ?? options?.resumable === true;
|
|
27033
|
+
ctx.autoExtractThreshold = options?.autoExtractThreshold ?? 3;
|
|
26370
27034
|
const body = [];
|
|
26371
27035
|
const topLevelAliases = /* @__PURE__ */ new Set();
|
|
26372
27036
|
let topLevelCtxInjected = false;
|
|
@@ -26613,6 +27277,9 @@ function lowerHIRWithRegions(program, t4, options, macroAliases) {
|
|
|
26613
27277
|
lowerableBuffer.push(stmt);
|
|
26614
27278
|
}
|
|
26615
27279
|
flushLowerableBuffer();
|
|
27280
|
+
if (ctx.resumableEnabled && ctx.hoistedResumableStatements && ctx.hoistedResumableStatements.length > 0) {
|
|
27281
|
+
body.push(...ctx.hoistedResumableStatements);
|
|
27282
|
+
}
|
|
26616
27283
|
for (const func of generatedFunctions.values()) {
|
|
26617
27284
|
body.push(func.stmt);
|
|
26618
27285
|
if (func.stmt.id?.name) emittedFunctionNames.add(func.stmt.id.name);
|
|
@@ -26653,12 +27320,15 @@ function lowerTopLevelStatementBlock(statements, ctx, t4, name = "__module_segme
|
|
|
26653
27320
|
ctx.storeVars = storeVars;
|
|
26654
27321
|
ctx.memoVars = memoVars;
|
|
26655
27322
|
ctx.mutatedVars = mutatedVars;
|
|
27323
|
+
const componentFunctionDefs = ctx.componentFunctionDefs ?? /* @__PURE__ */ new Map();
|
|
27324
|
+
ctx.componentFunctionDefs = componentFunctionDefs;
|
|
26656
27325
|
for (const block of fn.blocks) {
|
|
26657
27326
|
for (const instr of block.instructions) {
|
|
26658
27327
|
if (instr.kind === "Assign") {
|
|
26659
27328
|
const target = deSSAVarName(instr.target.name);
|
|
26660
27329
|
if (instr.value.kind === "ArrowFunction" || instr.value.kind === "FunctionExpression") {
|
|
26661
27330
|
functionVars.add(target);
|
|
27331
|
+
componentFunctionDefs.set(target, instr.value);
|
|
26662
27332
|
}
|
|
26663
27333
|
if (instr.value.kind === "CallExpression" || instr.value.kind === "OptionalCallExpression") {
|
|
26664
27334
|
const callKind = getReactiveCallKind(instr.value, ctx);
|
|
@@ -26826,6 +27496,8 @@ function lowerFunctionWithRegions(fn, ctx, options) {
|
|
|
26826
27496
|
ctx.mutatedVars = /* @__PURE__ */ new Set();
|
|
26827
27497
|
ctx.noMemo = !!(prevNoMemo || fn.meta?.noMemo);
|
|
26828
27498
|
ctx.hookResultVarMap = /* @__PURE__ */ new Map();
|
|
27499
|
+
const prevComponentFunctionDefs = ctx.componentFunctionDefs;
|
|
27500
|
+
ctx.componentFunctionDefs = /* @__PURE__ */ new Map();
|
|
26829
27501
|
const hookResultVars = /* @__PURE__ */ new Set();
|
|
26830
27502
|
const hookAccessorAliases = /* @__PURE__ */ new Set();
|
|
26831
27503
|
const prevPropsParam = ctx.propsParamName;
|
|
@@ -26842,6 +27514,7 @@ function lowerFunctionWithRegions(fn, ctx, options) {
|
|
|
26842
27514
|
const target = deSSAVarName(instr.target.name);
|
|
26843
27515
|
if (instr.value.kind === "ArrowFunction" || instr.value.kind === "FunctionExpression") {
|
|
26844
27516
|
ctx.functionVars?.add(target);
|
|
27517
|
+
ctx.componentFunctionDefs?.set(target, instr.value);
|
|
26845
27518
|
}
|
|
26846
27519
|
if (instr.value.kind === "CallExpression" || instr.value.kind === "OptionalCallExpression") {
|
|
26847
27520
|
const callKind = getReactiveCallKind(instr.value, ctx);
|
|
@@ -27137,6 +27810,7 @@ function lowerFunctionWithRegions(fn, ctx, options) {
|
|
|
27137
27810
|
ctx.externalTracked = prevExternalTracked;
|
|
27138
27811
|
ctx.signalVars = prevSignalVars;
|
|
27139
27812
|
ctx.functionVars = prevFunctionVars;
|
|
27813
|
+
ctx.componentFunctionDefs = prevComponentFunctionDefs;
|
|
27140
27814
|
ctx.memoVars = prevMemoVars;
|
|
27141
27815
|
ctx.storeVars = prevStoreVars;
|
|
27142
27816
|
ctx.mutatedVars = prevMutatedVars;
|
|
@@ -27154,6 +27828,7 @@ function lowerFunctionWithRegions(fn, ctx, options) {
|
|
|
27154
27828
|
ctx.externalTracked = prevExternalTracked;
|
|
27155
27829
|
ctx.signalVars = prevSignalVars;
|
|
27156
27830
|
ctx.functionVars = prevFunctionVars;
|
|
27831
|
+
ctx.componentFunctionDefs = prevComponentFunctionDefs;
|
|
27157
27832
|
ctx.memoVars = prevMemoVars;
|
|
27158
27833
|
ctx.storeVars = prevStoreVars;
|
|
27159
27834
|
ctx.mutatedVars = prevMutatedVars;
|
|
@@ -27250,6 +27925,9 @@ function lowerFunctionWithRegions(fn, ctx, options) {
|
|
|
27250
27925
|
fn.loc
|
|
27251
27926
|
);
|
|
27252
27927
|
funcDecl.async = isAsync;
|
|
27928
|
+
if (isComponent && fn.name) {
|
|
27929
|
+
registerResumableComponent(fn.name, ctx);
|
|
27930
|
+
}
|
|
27253
27931
|
ctx.needsCtx = prevNeedsCtx;
|
|
27254
27932
|
ctx.shadowedNames = prevShadowed;
|
|
27255
27933
|
ctx.localDeclaredNames = prevLocalDeclared;
|
|
@@ -27257,6 +27935,7 @@ function lowerFunctionWithRegions(fn, ctx, options) {
|
|
|
27257
27935
|
ctx.externalTracked = prevExternalTracked;
|
|
27258
27936
|
ctx.signalVars = prevSignalVars;
|
|
27259
27937
|
ctx.functionVars = prevFunctionVars;
|
|
27938
|
+
ctx.componentFunctionDefs = prevComponentFunctionDefs;
|
|
27260
27939
|
ctx.memoVars = prevMemoVars;
|
|
27261
27940
|
ctx.storeVars = prevStoreVars;
|
|
27262
27941
|
ctx.mutatedVars = prevMutatedVars;
|