@fictjs/compiler 0.11.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 +24 -3
- package/dist/index.js +24 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -34096,6 +34096,15 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34096
34096
|
"catch",
|
|
34097
34097
|
"finally"
|
|
34098
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
|
+
]);
|
|
34099
34108
|
const capturedClosureByBinding = /* @__PURE__ */ new Map();
|
|
34100
34109
|
const shouldIgnoreIdentifierReference = (idPath) => {
|
|
34101
34110
|
if (idPath.parentPath.isMemberExpression({ property: idPath.node }) && !idPath.parent.computed) {
|
|
@@ -34163,7 +34172,19 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34163
34172
|
const captured = capturedClosureByBinding.get(binding.identifier);
|
|
34164
34173
|
return captured && captured.size > 0 ? captured : null;
|
|
34165
34174
|
};
|
|
34166
|
-
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
|
+
}
|
|
34167
34188
|
const member = t4.isMemberExpression(callee) || t4.isOptionalMemberExpression(callee) ? callee : null;
|
|
34168
34189
|
if (!member || member.computed || !t4.isIdentifier(member.property)) return false;
|
|
34169
34190
|
return NON_ESCAPING_CALLBACK_METHODS.has(member.property.name);
|
|
@@ -34334,7 +34355,8 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34334
34355
|
const isSafe = calleeName && SAFE_FUNCTIONS.has(calleeName);
|
|
34335
34356
|
if (isSafe) return;
|
|
34336
34357
|
const argPaths = path2.get("arguments");
|
|
34337
|
-
const nonEscapingCallbackHost = isNonEscapingCallbackHost(callee);
|
|
34358
|
+
const nonEscapingCallbackHost = isNonEscapingCallbackHost(path2, callee);
|
|
34359
|
+
if (nonEscapingCallbackHost) return;
|
|
34338
34360
|
for (const argPath of argPaths) {
|
|
34339
34361
|
if (argPath.isIdentifier() && hasTrackedBinding(argPath, argPath.node.name, stateBindingIds)) {
|
|
34340
34362
|
continue;
|
|
@@ -34350,7 +34372,6 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34350
34372
|
break;
|
|
34351
34373
|
}
|
|
34352
34374
|
}
|
|
34353
|
-
if (nonEscapingCallbackHost) return;
|
|
34354
34375
|
for (const argPath of argPaths) {
|
|
34355
34376
|
const captured = collectCapturedForArgument(argPath);
|
|
34356
34377
|
if (!captured) continue;
|
package/dist/index.js
CHANGED
|
@@ -34081,6 +34081,15 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34081
34081
|
"catch",
|
|
34082
34082
|
"finally"
|
|
34083
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
|
+
]);
|
|
34084
34093
|
const capturedClosureByBinding = /* @__PURE__ */ new Map();
|
|
34085
34094
|
const shouldIgnoreIdentifierReference = (idPath) => {
|
|
34086
34095
|
if (idPath.parentPath.isMemberExpression({ property: idPath.node }) && !idPath.parent.computed) {
|
|
@@ -34148,7 +34157,19 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34148
34157
|
const captured = capturedClosureByBinding.get(binding.identifier);
|
|
34149
34158
|
return captured && captured.size > 0 ? captured : null;
|
|
34150
34159
|
};
|
|
34151
|
-
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
|
+
}
|
|
34152
34173
|
const member = t4.isMemberExpression(callee) || t4.isOptionalMemberExpression(callee) ? callee : null;
|
|
34153
34174
|
if (!member || member.computed || !t4.isIdentifier(member.property)) return false;
|
|
34154
34175
|
return NON_ESCAPING_CALLBACK_METHODS.has(member.property.name);
|
|
@@ -34319,7 +34340,8 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34319
34340
|
const isSafe = calleeName && SAFE_FUNCTIONS.has(calleeName);
|
|
34320
34341
|
if (isSafe) return;
|
|
34321
34342
|
const argPaths = path2.get("arguments");
|
|
34322
|
-
const nonEscapingCallbackHost = isNonEscapingCallbackHost(callee);
|
|
34343
|
+
const nonEscapingCallbackHost = isNonEscapingCallbackHost(path2, callee);
|
|
34344
|
+
if (nonEscapingCallbackHost) return;
|
|
34323
34345
|
for (const argPath of argPaths) {
|
|
34324
34346
|
if (argPath.isIdentifier() && hasTrackedBinding(argPath, argPath.node.name, stateBindingIds)) {
|
|
34325
34347
|
continue;
|
|
@@ -34335,7 +34357,6 @@ function runWarningPass(programPath, stateBindingIds, stateRootBindingIds, react
|
|
|
34335
34357
|
break;
|
|
34336
34358
|
}
|
|
34337
34359
|
}
|
|
34338
|
-
if (nonEscapingCallbackHost) return;
|
|
34339
34360
|
for (const argPath of argPaths) {
|
|
34340
34361
|
const captured = collectCapturedForArgument(argPath);
|
|
34341
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",
|