@fictjs/compiler 0.10.0 → 0.12.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 +41 -9
- package/dist/index.js +41 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -16719,10 +16719,12 @@ function convertJSXMemberExpr(node) {
|
|
|
16719
16719
|
};
|
|
16720
16720
|
}
|
|
16721
16721
|
|
|
16722
|
-
// src/
|
|
16722
|
+
// src/ir/dependency-key.ts
|
|
16723
16723
|
function normalizeDependencyKey(name) {
|
|
16724
|
-
return name.split(".").map((part) => part
|
|
16724
|
+
return name.split(".").map((part) => getSSABaseName(part)).join(".");
|
|
16725
16725
|
}
|
|
16726
|
+
|
|
16727
|
+
// src/fine-grained-dom.ts
|
|
16726
16728
|
function applyRegionMetadata(state, options) {
|
|
16727
16729
|
if (!options.region) return;
|
|
16728
16730
|
const region = options.region;
|
|
@@ -24215,7 +24217,7 @@ function extractKeyFromMapCallback(callback) {
|
|
|
24215
24217
|
|
|
24216
24218
|
// src/ir/codegen-overrides.ts
|
|
24217
24219
|
function normalizeDependencyKey2(name) {
|
|
24218
|
-
return name
|
|
24220
|
+
return normalizeDependencyKey(name);
|
|
24219
24221
|
}
|
|
24220
24222
|
function getDependencyPathFromNode(node, t4) {
|
|
24221
24223
|
if (t4.isIdentifier(node)) {
|
|
@@ -33839,9 +33841,18 @@ function isInsideLoop(path2) {
|
|
|
33839
33841
|
);
|
|
33840
33842
|
}
|
|
33841
33843
|
function isInsideConditional(path2) {
|
|
33842
|
-
|
|
33843
|
-
|
|
33844
|
-
|
|
33844
|
+
let current = path2;
|
|
33845
|
+
while (current?.parentPath) {
|
|
33846
|
+
const parent = current.parentPath;
|
|
33847
|
+
if (parent.isIfStatement?.() || parent.isConditionalExpression?.() || parent.isSwitchCase?.()) {
|
|
33848
|
+
return true;
|
|
33849
|
+
}
|
|
33850
|
+
if (parent.isLogicalExpression?.() && current.key === "right") {
|
|
33851
|
+
return true;
|
|
33852
|
+
}
|
|
33853
|
+
current = parent;
|
|
33854
|
+
}
|
|
33855
|
+
return false;
|
|
33845
33856
|
}
|
|
33846
33857
|
function isInsideJSX(path2) {
|
|
33847
33858
|
return !!path2.findParent((p) => p.isJSXElement?.() || p.isJSXFragment?.());
|
|
@@ -34085,6 +34096,15 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34085
34096
|
"catch",
|
|
34086
34097
|
"finally"
|
|
34087
34098
|
]);
|
|
34099
|
+
const NON_ESCAPING_CALLBACK_FUNCTION_IMPORTS = /* @__PURE__ */ new Set([
|
|
34100
|
+
"untrack",
|
|
34101
|
+
"batch",
|
|
34102
|
+
"startTransition",
|
|
34103
|
+
"createEffect",
|
|
34104
|
+
"createMemo",
|
|
34105
|
+
"createRenderEffect",
|
|
34106
|
+
"runInScope"
|
|
34107
|
+
]);
|
|
34088
34108
|
const capturedClosureByBinding = /* @__PURE__ */ new Map();
|
|
34089
34109
|
const shouldIgnoreIdentifierReference = (idPath) => {
|
|
34090
34110
|
if (idPath.parentPath.isMemberExpression({ property: idPath.node }) && !idPath.parent.computed) {
|
|
@@ -34152,7 +34172,19 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34152
34172
|
const captured = capturedClosureByBinding.get(binding.identifier);
|
|
34153
34173
|
return captured && captured.size > 0 ? captured : null;
|
|
34154
34174
|
};
|
|
34155
|
-
const isNonEscapingCallbackHost = (callee) => {
|
|
34175
|
+
const isNonEscapingCallbackHost = (callPath, callee) => {
|
|
34176
|
+
if (t4.isIdentifier(callee)) {
|
|
34177
|
+
const binding = callPath.scope.getBinding(callee.name);
|
|
34178
|
+
const bindingPath = binding?.path;
|
|
34179
|
+
if (bindingPath?.isImportSpecifier()) {
|
|
34180
|
+
const imported = bindingPath.node.imported;
|
|
34181
|
+
const importedName = t4.isIdentifier(imported) ? imported.name : imported.value;
|
|
34182
|
+
const source = bindingPath.parentPath.node;
|
|
34183
|
+
if (source.type === "ImportDeclaration" && (source.source.value === "fict" || source.source.value === "fict/advanced" || source.source.value === "@fictjs/runtime" || source.source.value === "@fictjs/runtime/advanced") && NON_ESCAPING_CALLBACK_FUNCTION_IMPORTS.has(importedName)) {
|
|
34184
|
+
return true;
|
|
34185
|
+
}
|
|
34186
|
+
}
|
|
34187
|
+
}
|
|
34156
34188
|
const member = t4.isMemberExpression(callee) || t4.isOptionalMemberExpression(callee) ? callee : null;
|
|
34157
34189
|
if (!member || member.computed || !t4.isIdentifier(member.property)) return false;
|
|
34158
34190
|
return NON_ESCAPING_CALLBACK_METHODS.has(member.property.name);
|
|
@@ -34323,7 +34355,8 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34323
34355
|
const isSafe = calleeName && SAFE_FUNCTIONS.has(calleeName);
|
|
34324
34356
|
if (isSafe) return;
|
|
34325
34357
|
const argPaths = path2.get("arguments");
|
|
34326
|
-
const nonEscapingCallbackHost = isNonEscapingCallbackHost(callee);
|
|
34358
|
+
const nonEscapingCallbackHost = isNonEscapingCallbackHost(path2, callee);
|
|
34359
|
+
if (nonEscapingCallbackHost) return;
|
|
34327
34360
|
for (const argPath of argPaths) {
|
|
34328
34361
|
if (argPath.isIdentifier() && hasTrackedBinding(argPath, argPath.node.name, stateBindingIds)) {
|
|
34329
34362
|
continue;
|
|
@@ -34339,7 +34372,6 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34339
34372
|
break;
|
|
34340
34373
|
}
|
|
34341
34374
|
}
|
|
34342
|
-
if (nonEscapingCallbackHost) return;
|
|
34343
34375
|
for (const argPath of argPaths) {
|
|
34344
34376
|
const captured = collectCapturedForArgument(argPath);
|
|
34345
34377
|
if (!captured) continue;
|
package/dist/index.js
CHANGED
|
@@ -16704,10 +16704,12 @@ function convertJSXMemberExpr(node) {
|
|
|
16704
16704
|
};
|
|
16705
16705
|
}
|
|
16706
16706
|
|
|
16707
|
-
// src/
|
|
16707
|
+
// src/ir/dependency-key.ts
|
|
16708
16708
|
function normalizeDependencyKey(name) {
|
|
16709
|
-
return name.split(".").map((part) => part
|
|
16709
|
+
return name.split(".").map((part) => getSSABaseName(part)).join(".");
|
|
16710
16710
|
}
|
|
16711
|
+
|
|
16712
|
+
// src/fine-grained-dom.ts
|
|
16711
16713
|
function applyRegionMetadata(state, options) {
|
|
16712
16714
|
if (!options.region) return;
|
|
16713
16715
|
const region = options.region;
|
|
@@ -24200,7 +24202,7 @@ function extractKeyFromMapCallback(callback) {
|
|
|
24200
24202
|
|
|
24201
24203
|
// src/ir/codegen-overrides.ts
|
|
24202
24204
|
function normalizeDependencyKey2(name) {
|
|
24203
|
-
return name
|
|
24205
|
+
return normalizeDependencyKey(name);
|
|
24204
24206
|
}
|
|
24205
24207
|
function getDependencyPathFromNode(node, t4) {
|
|
24206
24208
|
if (t4.isIdentifier(node)) {
|
|
@@ -33824,9 +33826,18 @@ function isInsideLoop(path2) {
|
|
|
33824
33826
|
);
|
|
33825
33827
|
}
|
|
33826
33828
|
function isInsideConditional(path2) {
|
|
33827
|
-
|
|
33828
|
-
|
|
33829
|
-
|
|
33829
|
+
let current = path2;
|
|
33830
|
+
while (current?.parentPath) {
|
|
33831
|
+
const parent = current.parentPath;
|
|
33832
|
+
if (parent.isIfStatement?.() || parent.isConditionalExpression?.() || parent.isSwitchCase?.()) {
|
|
33833
|
+
return true;
|
|
33834
|
+
}
|
|
33835
|
+
if (parent.isLogicalExpression?.() && current.key === "right") {
|
|
33836
|
+
return true;
|
|
33837
|
+
}
|
|
33838
|
+
current = parent;
|
|
33839
|
+
}
|
|
33840
|
+
return false;
|
|
33830
33841
|
}
|
|
33831
33842
|
function isInsideJSX(path2) {
|
|
33832
33843
|
return !!path2.findParent((p) => p.isJSXElement?.() || p.isJSXFragment?.());
|
|
@@ -34070,6 +34081,15 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34070
34081
|
"catch",
|
|
34071
34082
|
"finally"
|
|
34072
34083
|
]);
|
|
34084
|
+
const NON_ESCAPING_CALLBACK_FUNCTION_IMPORTS = /* @__PURE__ */ new Set([
|
|
34085
|
+
"untrack",
|
|
34086
|
+
"batch",
|
|
34087
|
+
"startTransition",
|
|
34088
|
+
"createEffect",
|
|
34089
|
+
"createMemo",
|
|
34090
|
+
"createRenderEffect",
|
|
34091
|
+
"runInScope"
|
|
34092
|
+
]);
|
|
34073
34093
|
const capturedClosureByBinding = /* @__PURE__ */ new Map();
|
|
34074
34094
|
const shouldIgnoreIdentifierReference = (idPath) => {
|
|
34075
34095
|
if (idPath.parentPath.isMemberExpression({ property: idPath.node }) && !idPath.parent.computed) {
|
|
@@ -34137,7 +34157,19 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34137
34157
|
const captured = capturedClosureByBinding.get(binding.identifier);
|
|
34138
34158
|
return captured && captured.size > 0 ? captured : null;
|
|
34139
34159
|
};
|
|
34140
|
-
const isNonEscapingCallbackHost = (callee) => {
|
|
34160
|
+
const isNonEscapingCallbackHost = (callPath, callee) => {
|
|
34161
|
+
if (t4.isIdentifier(callee)) {
|
|
34162
|
+
const binding = callPath.scope.getBinding(callee.name);
|
|
34163
|
+
const bindingPath = binding?.path;
|
|
34164
|
+
if (bindingPath?.isImportSpecifier()) {
|
|
34165
|
+
const imported = bindingPath.node.imported;
|
|
34166
|
+
const importedName = t4.isIdentifier(imported) ? imported.name : imported.value;
|
|
34167
|
+
const source = bindingPath.parentPath.node;
|
|
34168
|
+
if (source.type === "ImportDeclaration" && (source.source.value === "fict" || source.source.value === "fict/advanced" || source.source.value === "@fictjs/runtime" || source.source.value === "@fictjs/runtime/advanced") && NON_ESCAPING_CALLBACK_FUNCTION_IMPORTS.has(importedName)) {
|
|
34169
|
+
return true;
|
|
34170
|
+
}
|
|
34171
|
+
}
|
|
34172
|
+
}
|
|
34141
34173
|
const member = t4.isMemberExpression(callee) || t4.isOptionalMemberExpression(callee) ? callee : null;
|
|
34142
34174
|
if (!member || member.computed || !t4.isIdentifier(member.property)) return false;
|
|
34143
34175
|
return NON_ESCAPING_CALLBACK_METHODS.has(member.property.name);
|
|
@@ -34308,7 +34340,8 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34308
34340
|
const isSafe = calleeName && SAFE_FUNCTIONS.has(calleeName);
|
|
34309
34341
|
if (isSafe) return;
|
|
34310
34342
|
const argPaths = path2.get("arguments");
|
|
34311
|
-
const nonEscapingCallbackHost = isNonEscapingCallbackHost(callee);
|
|
34343
|
+
const nonEscapingCallbackHost = isNonEscapingCallbackHost(path2, callee);
|
|
34344
|
+
if (nonEscapingCallbackHost) return;
|
|
34312
34345
|
for (const argPath of argPaths) {
|
|
34313
34346
|
if (argPath.isIdentifier() && hasTrackedBinding(argPath, argPath.node.name, stateBindingIds)) {
|
|
34314
34347
|
continue;
|
|
@@ -34324,7 +34357,6 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34324
34357
|
break;
|
|
34325
34358
|
}
|
|
34326
34359
|
}
|
|
34327
|
-
if (nonEscapingCallbackHost) return;
|
|
34328
34360
|
for (const argPath of argPaths) {
|
|
34329
34361
|
const captured = collectCapturedForArgument(argPath);
|
|
34330
34362
|
if (!captured) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fictjs/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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.
|
|
51
|
+
"@fictjs/runtime": "0.12.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|