babel-plugin-react-compiler 0.0.0-experimental-3452ff1-20250321 → 0.0.0-experimental-3cea1f4-20250324
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.d.ts +39 -18
- package/dist/index.js +1376 -882
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -7408,7 +7408,7 @@ var require_expressions = __commonJS({
|
|
7408
7408
|
exports2.MemberExpression = MemberExpression;
|
7409
7409
|
exports2.MetaProperty = MetaProperty;
|
7410
7410
|
exports2.ModuleExpression = ModuleExpression;
|
7411
|
-
exports2.NewExpression =
|
7411
|
+
exports2.NewExpression = NewExpression2;
|
7412
7412
|
exports2.OptionalCallExpression = OptionalCallExpression;
|
7413
7413
|
exports2.OptionalMemberExpression = OptionalMemberExpression;
|
7414
7414
|
exports2.ParenthesizedExpression = ParenthesizedExpression;
|
@@ -7478,7 +7478,7 @@ var require_expressions = __commonJS({
|
|
7478
7478
|
this.space();
|
7479
7479
|
this.print(node.alternate);
|
7480
7480
|
}
|
7481
|
-
function
|
7481
|
+
function NewExpression2(node, parent) {
|
7482
7482
|
this.word("new");
|
7483
7483
|
this.space();
|
7484
7484
|
this.print(node.callee);
|
@@ -12152,7 +12152,7 @@ var require_inferers = __commonJS({
|
|
12152
12152
|
}
|
12153
12153
|
});
|
12154
12154
|
exports2.LogicalExpression = LogicalExpression;
|
12155
|
-
exports2.NewExpression =
|
12155
|
+
exports2.NewExpression = NewExpression2;
|
12156
12156
|
exports2.NullLiteral = NullLiteral;
|
12157
12157
|
exports2.NumericLiteral = NumericLiteral;
|
12158
12158
|
exports2.ObjectExpression = ObjectExpression;
|
@@ -12207,7 +12207,7 @@ var require_inferers = __commonJS({
|
|
12207
12207
|
function TSNonNullExpression() {
|
12208
12208
|
return this.get("expression").getTypeAnnotation();
|
12209
12209
|
}
|
12210
|
-
function
|
12210
|
+
function NewExpression2(node) {
|
12211
12211
|
if (node.callee.type === "Identifier") {
|
12212
12212
|
return genericTypeAnnotation(node.callee);
|
12213
12213
|
}
|
@@ -53254,7 +53254,7 @@ var require_expressions2 = __commonJS({
|
|
53254
53254
|
exports2.MemberExpression = MemberExpression;
|
53255
53255
|
exports2.MetaProperty = MetaProperty;
|
53256
53256
|
exports2.ModuleExpression = ModuleExpression;
|
53257
|
-
exports2.NewExpression =
|
53257
|
+
exports2.NewExpression = NewExpression2;
|
53258
53258
|
exports2.OptionalCallExpression = OptionalCallExpression;
|
53259
53259
|
exports2.OptionalMemberExpression = OptionalMemberExpression;
|
53260
53260
|
exports2.ParenthesizedExpression = ParenthesizedExpression;
|
@@ -53324,7 +53324,7 @@ var require_expressions2 = __commonJS({
|
|
53324
53324
|
this.space();
|
53325
53325
|
this.print(node.alternate);
|
53326
53326
|
}
|
53327
|
-
function
|
53327
|
+
function NewExpression2(node, parent) {
|
53328
53328
|
this.word("new");
|
53329
53329
|
this.space();
|
53330
53330
|
this.print(node.callee);
|
@@ -58020,7 +58020,7 @@ var require_inferers2 = __commonJS({
|
|
58020
58020
|
});
|
58021
58021
|
exports2.VariableDeclarator = VariableDeclarator;
|
58022
58022
|
exports2.TypeCastExpression = TypeCastExpression;
|
58023
|
-
exports2.NewExpression =
|
58023
|
+
exports2.NewExpression = NewExpression2;
|
58024
58024
|
exports2.TemplateLiteral = TemplateLiteral;
|
58025
58025
|
exports2.UnaryExpression = UnaryExpression;
|
58026
58026
|
exports2.BinaryExpression = BinaryExpression;
|
@@ -58107,7 +58107,7 @@ var require_inferers2 = __commonJS({
|
|
58107
58107
|
return node.typeAnnotation;
|
58108
58108
|
}
|
58109
58109
|
TypeCastExpression.validParent = true;
|
58110
|
-
function
|
58110
|
+
function NewExpression2(node) {
|
58111
58111
|
if (this.get("callee").isIdentifier()) {
|
58112
58112
|
return t5.genericTypeAnnotation(node.callee);
|
58113
58113
|
}
|
@@ -97512,7 +97512,7 @@ var require_parentheses3 = __commonJS({
|
|
97512
97512
|
exports2.ConditionalExpression = ConditionalExpression;
|
97513
97513
|
exports2.OptionalMemberExpression = OptionalMemberExpression;
|
97514
97514
|
exports2.AssignmentExpression = AssignmentExpression;
|
97515
|
-
exports2.NewExpression =
|
97515
|
+
exports2.NewExpression = NewExpression2;
|
97516
97516
|
function t5() {
|
97517
97517
|
const data = _interopRequireWildcard(require("@babel/types"));
|
97518
97518
|
t5 = function() {
|
@@ -97675,7 +97675,7 @@ var require_parentheses3 = __commonJS({
|
|
97675
97675
|
return ConditionalExpression(...arguments);
|
97676
97676
|
}
|
97677
97677
|
}
|
97678
|
-
function
|
97678
|
+
function NewExpression2(node, parent) {
|
97679
97679
|
return isClassExtendsClause(node, parent);
|
97680
97680
|
}
|
97681
97681
|
function isFirstInStatement(printStack, {
|
@@ -97879,7 +97879,7 @@ var require_expressions3 = __commonJS({
|
|
97879
97879
|
exports2.ParenthesizedExpression = ParenthesizedExpression;
|
97880
97880
|
exports2.UpdateExpression = UpdateExpression;
|
97881
97881
|
exports2.ConditionalExpression = ConditionalExpression;
|
97882
|
-
exports2.NewExpression =
|
97882
|
+
exports2.NewExpression = NewExpression2;
|
97883
97883
|
exports2.SequenceExpression = SequenceExpression;
|
97884
97884
|
exports2.ThisExpression = ThisExpression;
|
97885
97885
|
exports2.Super = Super;
|
@@ -97967,7 +97967,7 @@ var require_expressions3 = __commonJS({
|
|
97967
97967
|
this.space();
|
97968
97968
|
this.print(node.alternate, node);
|
97969
97969
|
}
|
97970
|
-
function
|
97970
|
+
function NewExpression2(node, parent) {
|
97971
97971
|
this.word("new");
|
97972
97972
|
this.space();
|
97973
97973
|
this.print(node.callee, node);
|
@@ -110425,6 +110425,7 @@ __export(index_exports, {
|
|
110425
110425
|
ErrorSeverity: () => ErrorSeverity,
|
110426
110426
|
OPT_IN_DIRECTIVES: () => OPT_IN_DIRECTIVES,
|
110427
110427
|
OPT_OUT_DIRECTIVES: () => OPT_OUT_DIRECTIVES,
|
110428
|
+
ProgramContext: () => ProgramContext2,
|
110428
110429
|
ValueKind: () => ValueKind,
|
110429
110430
|
compile: () => compileFn,
|
110430
110431
|
compileProgram: () => compileProgram,
|
@@ -110829,7 +110830,7 @@ var CompilerError = class _CompilerError extends Error {
|
|
110829
110830
|
};
|
110830
110831
|
|
110831
110832
|
// src/Entrypoint/Gating.ts
|
110832
|
-
function insertAdditionalFunctionDeclaration(fnPath, compiled,
|
110833
|
+
function insertAdditionalFunctionDeclaration(fnPath, compiled, programContext, gatingFunctionIdentifierName) {
|
110833
110834
|
var _a, _b;
|
110834
110835
|
const originalFnName = fnPath.node.id;
|
110835
110836
|
const originalFnParams = fnPath.node.params;
|
@@ -110842,14 +110843,14 @@ function insertAdditionalFunctionDeclaration(fnPath, compiled, gating) {
|
|
110842
110843
|
reason: "Expected React Compiler optimized function declarations to have the same number of parameters as source",
|
110843
110844
|
loc: (_b = fnPath.node.loc) != null ? _b : null
|
110844
110845
|
});
|
110845
|
-
const gatingCondition =
|
110846
|
-
`${
|
110846
|
+
const gatingCondition = t.identifier(
|
110847
|
+
programContext.newUid(`${gatingFunctionIdentifierName}_result`)
|
110847
110848
|
);
|
110848
|
-
const unoptimizedFnName =
|
110849
|
-
`${originalFnName.name}_unoptimized`
|
110849
|
+
const unoptimizedFnName = t.identifier(
|
110850
|
+
programContext.newUid(`${originalFnName.name}_unoptimized`)
|
110850
110851
|
);
|
110851
|
-
const optimizedFnName =
|
110852
|
-
`${originalFnName.name}_optimized`
|
110852
|
+
const optimizedFnName = t.identifier(
|
110853
|
+
programContext.newUid(`${originalFnName.name}_optimized`)
|
110853
110854
|
);
|
110854
110855
|
compiled.id.name = optimizedFnName.name;
|
110855
110856
|
fnPath.get("id").replaceInline(unoptimizedFnName);
|
@@ -110892,24 +110893,30 @@ function insertAdditionalFunctionDeclaration(fnPath, compiled, gating) {
|
|
110892
110893
|
t.variableDeclaration("const", [
|
110893
110894
|
t.variableDeclarator(
|
110894
110895
|
gatingCondition,
|
110895
|
-
t.callExpression(t.identifier(
|
110896
|
+
t.callExpression(t.identifier(gatingFunctionIdentifierName), [])
|
110896
110897
|
)
|
110897
110898
|
])
|
110898
110899
|
);
|
110899
110900
|
fnPath.insertBefore(compiled);
|
110900
110901
|
}
|
110901
|
-
function insertGatedFunctionDeclaration(fnPath, compiled, gating, referencedBeforeDeclaration) {
|
110902
|
+
function insertGatedFunctionDeclaration(fnPath, compiled, programContext, gating, referencedBeforeDeclaration) {
|
110902
110903
|
var _a;
|
110904
|
+
const gatingImportedName = programContext.addImportSpecifier(gating).name;
|
110903
110905
|
if (referencedBeforeDeclaration && fnPath.isFunctionDeclaration()) {
|
110904
110906
|
CompilerError.invariant(compiled.type === "FunctionDeclaration", {
|
110905
110907
|
reason: "Expected compiled node type to match input type",
|
110906
110908
|
description: `Got ${compiled.type} but expected FunctionDeclaration`,
|
110907
110909
|
loc: (_a = fnPath.node.loc) != null ? _a : null
|
110908
110910
|
});
|
110909
|
-
insertAdditionalFunctionDeclaration(
|
110911
|
+
insertAdditionalFunctionDeclaration(
|
110912
|
+
fnPath,
|
110913
|
+
compiled,
|
110914
|
+
programContext,
|
110915
|
+
gatingImportedName
|
110916
|
+
);
|
110910
110917
|
} else {
|
110911
110918
|
const gatingExpression = t.conditionalExpression(
|
110912
|
-
t.callExpression(t.identifier(
|
110919
|
+
t.callExpression(t.identifier(gatingImportedName), []),
|
110913
110920
|
buildFunctionExpression(compiled),
|
110914
110921
|
buildFunctionExpression(fnPath.node)
|
110915
110922
|
);
|
@@ -110955,7 +110962,7 @@ function buildFunctionExpression(node) {
|
|
110955
110962
|
}
|
110956
110963
|
|
110957
110964
|
// src/Entrypoint/Imports.ts
|
110958
|
-
var
|
110965
|
+
var t4 = __toESM(require("@babel/types"));
|
110959
110966
|
|
110960
110967
|
// src/HIR/HIR.ts
|
110961
110968
|
var t2 = __toESM(require("@babel/types"));
|
@@ -114763,6 +114770,7 @@ var Effect = /* @__PURE__ */ ((Effect2) => {
|
|
114763
114770
|
Effect2["Freeze"] = "freeze";
|
114764
114771
|
Effect2["Read"] = "read";
|
114765
114772
|
Effect2["Capture"] = "capture";
|
114773
|
+
Effect2["ConditionallyMutateIterator"] = "mutate-iterator?";
|
114766
114774
|
Effect2["ConditionallyMutate"] = "mutate?";
|
114767
114775
|
Effect2["Mutate"] = "mutate";
|
114768
114776
|
Effect2["Store"] = "store";
|
@@ -114772,6 +114780,7 @@ var EffectSchema = z.enum([
|
|
114772
114780
|
"read" /* Read */,
|
114773
114781
|
"mutate" /* Mutate */,
|
114774
114782
|
"mutate?" /* ConditionallyMutate */,
|
114783
|
+
"mutate-iterator?" /* ConditionallyMutateIterator */,
|
114775
114784
|
"capture" /* Capture */,
|
114776
114785
|
"store" /* Store */,
|
114777
114786
|
"freeze" /* Freeze */
|
@@ -114781,6 +114790,7 @@ function isMutableEffect(effect, location) {
|
|
114781
114790
|
case "capture" /* Capture */:
|
114782
114791
|
case "store" /* Store */:
|
114783
114792
|
case "mutate?" /* ConditionallyMutate */:
|
114793
|
+
case "mutate-iterator?" /* ConditionallyMutateIterator */:
|
114784
114794
|
case "mutate" /* Mutate */: {
|
114785
114795
|
return true;
|
114786
114796
|
}
|
@@ -114882,6 +114892,12 @@ function isPrimitiveType(id) {
|
|
114882
114892
|
function isArrayType(id) {
|
114883
114893
|
return id.type.kind === "Object" && id.type.shapeId === "BuiltInArray";
|
114884
114894
|
}
|
114895
|
+
function isMapType(id) {
|
114896
|
+
return id.type.kind === "Object" && id.type.shapeId === "BuiltInMap";
|
114897
|
+
}
|
114898
|
+
function isSetType(id) {
|
114899
|
+
return id.type.kind === "Object" && id.type.shapeId === "BuiltInSet";
|
114900
|
+
}
|
114885
114901
|
function isPropsType(id) {
|
114886
114902
|
return id.type.kind === "Object" && id.type.shapeId === "BuiltInProps";
|
114887
114903
|
}
|
@@ -117561,6 +117577,7 @@ var HIRBuilder = class {
|
|
117561
117577
|
type: makeType(),
|
117562
117578
|
loc: (_b = node.loc) != null ? _b : GeneratedSource
|
117563
117579
|
};
|
117580
|
+
__privateGet(this, _env).programContext.addNewReference(name);
|
117564
117581
|
__privateGet(this, _bindings).set(name, { node, identifier: identifier4 });
|
117565
117582
|
return identifier4;
|
117566
117583
|
} else if (mapping.node === node) {
|
@@ -117994,7 +118011,7 @@ var nextAnonId = 0;
|
|
117994
118011
|
function createAnonId() {
|
117995
118012
|
return `<generated_${nextAnonId++}>`;
|
117996
118013
|
}
|
117997
|
-
function addFunction(registry, properties, fn, id = null) {
|
118014
|
+
function addFunction(registry, properties, fn, id = null, isConstructor = false) {
|
117998
118015
|
const shapeId = id != null ? id : createAnonId();
|
117999
118016
|
addShape(registry, shapeId, properties, __spreadProps(__spreadValues({}, fn), {
|
118000
118017
|
hookKind: null
|
@@ -118002,7 +118019,8 @@ function addFunction(registry, properties, fn, id = null) {
|
|
118002
118019
|
return {
|
118003
118020
|
kind: "Function",
|
118004
118021
|
return: fn.returnType,
|
118005
|
-
shapeId
|
118022
|
+
shapeId,
|
118023
|
+
isConstructor
|
118006
118024
|
};
|
118007
118025
|
}
|
118008
118026
|
function addHook(registry, fn, id = null) {
|
@@ -118011,7 +118029,8 @@ function addHook(registry, fn, id = null) {
|
|
118011
118029
|
return {
|
118012
118030
|
kind: "Function",
|
118013
118031
|
return: fn.returnType,
|
118014
|
-
shapeId
|
118032
|
+
shapeId,
|
118033
|
+
isConstructor: false
|
118015
118034
|
};
|
118016
118035
|
}
|
118017
118036
|
function addObject(registry, id, properties) {
|
@@ -118038,6 +118057,8 @@ function addShape(registry, id, properties, functionType2) {
|
|
118038
118057
|
}
|
118039
118058
|
var BuiltInPropsId = "BuiltInProps";
|
118040
118059
|
var BuiltInArrayId = "BuiltInArray";
|
118060
|
+
var BuiltInSetId = "BuiltInSet";
|
118061
|
+
var BuiltInMapId = "BuiltInMap";
|
118041
118062
|
var BuiltInFunctionId = "BuiltInFunction";
|
118042
118063
|
var BuiltInJsxId = "BuiltInJsx";
|
118043
118064
|
var BuiltInObjectId = "BuiltInObject";
|
@@ -118282,6 +118303,311 @@ addObject(BUILTIN_SHAPES, BuiltInObjectId, [
|
|
118282
118303
|
* hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, valueOf
|
118283
118304
|
*/
|
118284
118305
|
]);
|
118306
|
+
addObject(BUILTIN_SHAPES, BuiltInSetId, [
|
118307
|
+
[
|
118308
|
+
/**
|
118309
|
+
* add(value)
|
118310
|
+
* Parameters
|
118311
|
+
* value: the value of the element to add to the Set object.
|
118312
|
+
* Returns the Set object with added value.
|
118313
|
+
*/
|
118314
|
+
"add",
|
118315
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118316
|
+
positionalParams: ["capture" /* Capture */],
|
118317
|
+
restParam: null,
|
118318
|
+
returnType: { kind: "Object", shapeId: BuiltInSetId },
|
118319
|
+
calleeEffect: "store" /* Store */,
|
118320
|
+
// returnValueKind is technically dependent on the ValueKind of the set itself
|
118321
|
+
returnValueKind: "mutable" /* Mutable */
|
118322
|
+
})
|
118323
|
+
],
|
118324
|
+
[
|
118325
|
+
/**
|
118326
|
+
* clear()
|
118327
|
+
* Parameters none
|
118328
|
+
* Returns undefined
|
118329
|
+
*/
|
118330
|
+
"clear",
|
118331
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118332
|
+
positionalParams: [],
|
118333
|
+
restParam: null,
|
118334
|
+
returnType: PRIMITIVE_TYPE,
|
118335
|
+
calleeEffect: "store" /* Store */,
|
118336
|
+
returnValueKind: "primitive" /* Primitive */
|
118337
|
+
})
|
118338
|
+
],
|
118339
|
+
[
|
118340
|
+
/**
|
118341
|
+
* setInstance.delete(value)
|
118342
|
+
* Returns true if value was already in Set; otherwise false.
|
118343
|
+
*/
|
118344
|
+
"delete",
|
118345
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118346
|
+
positionalParams: ["read" /* Read */],
|
118347
|
+
restParam: null,
|
118348
|
+
returnType: PRIMITIVE_TYPE,
|
118349
|
+
calleeEffect: "store" /* Store */,
|
118350
|
+
returnValueKind: "primitive" /* Primitive */
|
118351
|
+
})
|
118352
|
+
],
|
118353
|
+
[
|
118354
|
+
"has",
|
118355
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118356
|
+
positionalParams: ["read" /* Read */],
|
118357
|
+
restParam: null,
|
118358
|
+
returnType: PRIMITIVE_TYPE,
|
118359
|
+
calleeEffect: "read" /* Read */,
|
118360
|
+
returnValueKind: "primitive" /* Primitive */
|
118361
|
+
})
|
118362
|
+
],
|
118363
|
+
["size", PRIMITIVE_TYPE],
|
118364
|
+
[
|
118365
|
+
/**
|
118366
|
+
* difference(other)
|
118367
|
+
* Parameters
|
118368
|
+
* other: A Set object, or set-like object.
|
118369
|
+
* Returns a new Set object containing elements in this set but not in the other set.
|
118370
|
+
*/
|
118371
|
+
"difference",
|
118372
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118373
|
+
positionalParams: ["capture" /* Capture */],
|
118374
|
+
restParam: null,
|
118375
|
+
returnType: { kind: "Object", shapeId: BuiltInSetId },
|
118376
|
+
calleeEffect: "capture" /* Capture */,
|
118377
|
+
returnValueKind: "mutable" /* Mutable */
|
118378
|
+
})
|
118379
|
+
],
|
118380
|
+
[
|
118381
|
+
/**
|
118382
|
+
* union(other)
|
118383
|
+
* Parameters
|
118384
|
+
* other: A Set object, or set-like object.
|
118385
|
+
* Returns a new Set object containing elements in either this set or the other set.
|
118386
|
+
*/
|
118387
|
+
"union",
|
118388
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118389
|
+
positionalParams: ["capture" /* Capture */],
|
118390
|
+
restParam: null,
|
118391
|
+
returnType: { kind: "Object", shapeId: BuiltInSetId },
|
118392
|
+
calleeEffect: "capture" /* Capture */,
|
118393
|
+
returnValueKind: "mutable" /* Mutable */
|
118394
|
+
})
|
118395
|
+
],
|
118396
|
+
[
|
118397
|
+
/**
|
118398
|
+
* symmetricalDifference(other)
|
118399
|
+
* Parameters
|
118400
|
+
* other: A Set object, or set-like object.
|
118401
|
+
* A new Set object containing elements which are in either this set or the other set, but not in both.
|
118402
|
+
*/
|
118403
|
+
"symmetricalDifference",
|
118404
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118405
|
+
positionalParams: ["capture" /* Capture */],
|
118406
|
+
restParam: null,
|
118407
|
+
returnType: { kind: "Object", shapeId: BuiltInSetId },
|
118408
|
+
calleeEffect: "capture" /* Capture */,
|
118409
|
+
returnValueKind: "mutable" /* Mutable */
|
118410
|
+
})
|
118411
|
+
],
|
118412
|
+
[
|
118413
|
+
/**
|
118414
|
+
* isSubsetOf(other)
|
118415
|
+
* Parameters
|
118416
|
+
* other: A Set object, or set-like object.
|
118417
|
+
* Returns true if all elements in this set are also in the other set, and false otherwise.
|
118418
|
+
*/
|
118419
|
+
"isSubsetOf",
|
118420
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118421
|
+
positionalParams: ["read" /* Read */],
|
118422
|
+
restParam: null,
|
118423
|
+
returnType: PRIMITIVE_TYPE,
|
118424
|
+
calleeEffect: "read" /* Read */,
|
118425
|
+
returnValueKind: "primitive" /* Primitive */
|
118426
|
+
})
|
118427
|
+
],
|
118428
|
+
[
|
118429
|
+
/**
|
118430
|
+
* isSupersetOf(other)
|
118431
|
+
* Parameters
|
118432
|
+
* other: A Set object, or set-like object.
|
118433
|
+
* Returns true if all elements in the other set are also in this set, and false otherwise.
|
118434
|
+
*/
|
118435
|
+
"isSupersetOf",
|
118436
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118437
|
+
positionalParams: ["read" /* Read */],
|
118438
|
+
restParam: null,
|
118439
|
+
returnType: PRIMITIVE_TYPE,
|
118440
|
+
calleeEffect: "read" /* Read */,
|
118441
|
+
returnValueKind: "primitive" /* Primitive */
|
118442
|
+
})
|
118443
|
+
],
|
118444
|
+
[
|
118445
|
+
/**
|
118446
|
+
* forEach(callbackFn)
|
118447
|
+
* forEach(callbackFn, thisArg)
|
118448
|
+
*/
|
118449
|
+
"forEach",
|
118450
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118451
|
+
/**
|
118452
|
+
* see Array.map explanation for why arguments are marked `ConditionallyMutate`
|
118453
|
+
*/
|
118454
|
+
positionalParams: [],
|
118455
|
+
restParam: "mutate?" /* ConditionallyMutate */,
|
118456
|
+
returnType: PRIMITIVE_TYPE,
|
118457
|
+
calleeEffect: "mutate?" /* ConditionallyMutate */,
|
118458
|
+
returnValueKind: "primitive" /* Primitive */,
|
118459
|
+
noAlias: true,
|
118460
|
+
mutableOnlyIfOperandsAreMutable: true
|
118461
|
+
})
|
118462
|
+
],
|
118463
|
+
/**
|
118464
|
+
* Iterators
|
118465
|
+
*/
|
118466
|
+
[
|
118467
|
+
"entries",
|
118468
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118469
|
+
positionalParams: [],
|
118470
|
+
restParam: null,
|
118471
|
+
returnType: { kind: "Poly" },
|
118472
|
+
calleeEffect: "capture" /* Capture */,
|
118473
|
+
returnValueKind: "mutable" /* Mutable */
|
118474
|
+
})
|
118475
|
+
],
|
118476
|
+
[
|
118477
|
+
"keys",
|
118478
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118479
|
+
positionalParams: [],
|
118480
|
+
restParam: null,
|
118481
|
+
returnType: { kind: "Poly" },
|
118482
|
+
calleeEffect: "capture" /* Capture */,
|
118483
|
+
returnValueKind: "mutable" /* Mutable */
|
118484
|
+
})
|
118485
|
+
],
|
118486
|
+
[
|
118487
|
+
"values",
|
118488
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118489
|
+
positionalParams: [],
|
118490
|
+
restParam: null,
|
118491
|
+
returnType: { kind: "Poly" },
|
118492
|
+
calleeEffect: "capture" /* Capture */,
|
118493
|
+
returnValueKind: "mutable" /* Mutable */
|
118494
|
+
})
|
118495
|
+
]
|
118496
|
+
]);
|
118497
|
+
addObject(BUILTIN_SHAPES, BuiltInMapId, [
|
118498
|
+
[
|
118499
|
+
/**
|
118500
|
+
* clear()
|
118501
|
+
* Parameters none
|
118502
|
+
* Returns undefined
|
118503
|
+
*/
|
118504
|
+
"clear",
|
118505
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118506
|
+
positionalParams: [],
|
118507
|
+
restParam: null,
|
118508
|
+
returnType: PRIMITIVE_TYPE,
|
118509
|
+
calleeEffect: "store" /* Store */,
|
118510
|
+
returnValueKind: "primitive" /* Primitive */
|
118511
|
+
})
|
118512
|
+
],
|
118513
|
+
[
|
118514
|
+
"delete",
|
118515
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118516
|
+
positionalParams: ["read" /* Read */],
|
118517
|
+
restParam: null,
|
118518
|
+
returnType: PRIMITIVE_TYPE,
|
118519
|
+
calleeEffect: "store" /* Store */,
|
118520
|
+
returnValueKind: "primitive" /* Primitive */
|
118521
|
+
})
|
118522
|
+
],
|
118523
|
+
[
|
118524
|
+
"get",
|
118525
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118526
|
+
positionalParams: ["read" /* Read */],
|
118527
|
+
restParam: null,
|
118528
|
+
returnType: { kind: "Poly" },
|
118529
|
+
calleeEffect: "capture" /* Capture */,
|
118530
|
+
returnValueKind: "mutable" /* Mutable */
|
118531
|
+
})
|
118532
|
+
],
|
118533
|
+
[
|
118534
|
+
"has",
|
118535
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118536
|
+
positionalParams: ["read" /* Read */],
|
118537
|
+
restParam: null,
|
118538
|
+
returnType: PRIMITIVE_TYPE,
|
118539
|
+
calleeEffect: "read" /* Read */,
|
118540
|
+
returnValueKind: "primitive" /* Primitive */
|
118541
|
+
})
|
118542
|
+
],
|
118543
|
+
[
|
118544
|
+
/**
|
118545
|
+
* Params
|
118546
|
+
* key: the key of the element to add to the Map object. The key may be
|
118547
|
+
* any JavaScript type (any primitive value or any type of JavaScript
|
118548
|
+
* object).
|
118549
|
+
* value: the value of the element to add to the Map object.
|
118550
|
+
* Returns the Map object.
|
118551
|
+
*/
|
118552
|
+
"set",
|
118553
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118554
|
+
positionalParams: ["capture" /* Capture */, "capture" /* Capture */],
|
118555
|
+
restParam: null,
|
118556
|
+
returnType: { kind: "Object", shapeId: BuiltInMapId },
|
118557
|
+
calleeEffect: "store" /* Store */,
|
118558
|
+
returnValueKind: "mutable" /* Mutable */
|
118559
|
+
})
|
118560
|
+
],
|
118561
|
+
["size", PRIMITIVE_TYPE],
|
118562
|
+
[
|
118563
|
+
"forEach",
|
118564
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118565
|
+
/**
|
118566
|
+
* see Array.map explanation for why arguments are marked `ConditionallyMutate`
|
118567
|
+
*/
|
118568
|
+
positionalParams: [],
|
118569
|
+
restParam: "mutate?" /* ConditionallyMutate */,
|
118570
|
+
returnType: PRIMITIVE_TYPE,
|
118571
|
+
calleeEffect: "mutate?" /* ConditionallyMutate */,
|
118572
|
+
returnValueKind: "primitive" /* Primitive */,
|
118573
|
+
noAlias: true,
|
118574
|
+
mutableOnlyIfOperandsAreMutable: true
|
118575
|
+
})
|
118576
|
+
],
|
118577
|
+
/**
|
118578
|
+
* Iterators
|
118579
|
+
*/
|
118580
|
+
[
|
118581
|
+
"entries",
|
118582
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118583
|
+
positionalParams: [],
|
118584
|
+
restParam: null,
|
118585
|
+
returnType: { kind: "Poly" },
|
118586
|
+
calleeEffect: "capture" /* Capture */,
|
118587
|
+
returnValueKind: "mutable" /* Mutable */
|
118588
|
+
})
|
118589
|
+
],
|
118590
|
+
[
|
118591
|
+
"keys",
|
118592
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118593
|
+
positionalParams: [],
|
118594
|
+
restParam: null,
|
118595
|
+
returnType: { kind: "Poly" },
|
118596
|
+
calleeEffect: "capture" /* Capture */,
|
118597
|
+
returnValueKind: "mutable" /* Mutable */
|
118598
|
+
})
|
118599
|
+
],
|
118600
|
+
[
|
118601
|
+
"values",
|
118602
|
+
addFunction(BUILTIN_SHAPES, [], {
|
118603
|
+
positionalParams: [],
|
118604
|
+
restParam: null,
|
118605
|
+
returnType: { kind: "Poly" },
|
118606
|
+
calleeEffect: "capture" /* Capture */,
|
118607
|
+
returnValueKind: "mutable" /* Mutable */
|
118608
|
+
})
|
118609
|
+
]
|
118610
|
+
]);
|
118285
118611
|
addObject(BUILTIN_SHAPES, BuiltInUseStateId, [
|
118286
118612
|
["0", { kind: "Poly" }],
|
118287
118613
|
[
|
@@ -122561,29 +122887,23 @@ function fromZodError(zodError, options = {}) {
|
|
122561
122887
|
// src/HIR/Globals.ts
|
122562
122888
|
var DEFAULT_SHAPES = new Map(BUILTIN_SHAPES);
|
122563
122889
|
var UNTYPED_GLOBALS = /* @__PURE__ */ new Set([
|
122564
|
-
"String",
|
122565
122890
|
"Object",
|
122566
122891
|
"Function",
|
122567
|
-
"Number",
|
122568
122892
|
"RegExp",
|
122569
122893
|
"Date",
|
122570
122894
|
"Error",
|
122571
|
-
"Function",
|
122572
122895
|
"TypeError",
|
122573
122896
|
"RangeError",
|
122574
122897
|
"ReferenceError",
|
122575
122898
|
"SyntaxError",
|
122576
122899
|
"URIError",
|
122577
122900
|
"EvalError",
|
122578
|
-
"Boolean",
|
122579
122901
|
"DataView",
|
122580
122902
|
"Float32Array",
|
122581
122903
|
"Float64Array",
|
122582
122904
|
"Int8Array",
|
122583
122905
|
"Int16Array",
|
122584
122906
|
"Int32Array",
|
122585
|
-
"Map",
|
122586
|
-
"Set",
|
122587
122907
|
"WeakMap",
|
122588
122908
|
"Uint8Array",
|
122589
122909
|
"Uint8ClampedArray",
|
@@ -122591,16 +122911,8 @@ var UNTYPED_GLOBALS = /* @__PURE__ */ new Set([
|
|
122591
122911
|
"Uint32Array",
|
122592
122912
|
"ArrayBuffer",
|
122593
122913
|
"JSON",
|
122594
|
-
"parseFloat",
|
122595
|
-
"parseInt",
|
122596
122914
|
"console",
|
122597
|
-
"
|
122598
|
-
"eval",
|
122599
|
-
"isFinite",
|
122600
|
-
"encodeURI",
|
122601
|
-
"decodeURI",
|
122602
|
-
"encodeURIComponent",
|
122603
|
-
"decodeURIComponent"
|
122915
|
+
"eval"
|
122604
122916
|
]);
|
122605
122917
|
var TYPED_GLOBALS = [
|
122606
122918
|
[
|
@@ -122615,6 +122927,23 @@ var TYPED_GLOBALS = [
|
|
122615
122927
|
calleeEffect: "read" /* Read */,
|
122616
122928
|
returnValueKind: "mutable" /* Mutable */
|
122617
122929
|
})
|
122930
|
+
],
|
122931
|
+
[
|
122932
|
+
/**
|
122933
|
+
* Object.fromEntries(iterable)
|
122934
|
+
* iterable: An iterable, such as an Array or Map, containing a list of
|
122935
|
+
* objects. Each object should have two properties.
|
122936
|
+
* Returns a new object whose properties are given by the entries of the
|
122937
|
+
* iterable.
|
122938
|
+
*/
|
122939
|
+
"fromEntries",
|
122940
|
+
addFunction(DEFAULT_SHAPES, [], {
|
122941
|
+
positionalParams: ["mutate?" /* ConditionallyMutate */],
|
122942
|
+
restParam: null,
|
122943
|
+
returnType: { kind: "Object", shapeId: BuiltInObjectId },
|
122944
|
+
calleeEffect: "read" /* Read */,
|
122945
|
+
returnValueKind: "mutable" /* Mutable */
|
122946
|
+
})
|
122618
122947
|
]
|
122619
122948
|
])
|
122620
122949
|
],
|
@@ -122647,7 +122976,7 @@ var TYPED_GLOBALS = [
|
|
122647
122976
|
"from",
|
122648
122977
|
addFunction(DEFAULT_SHAPES, [], {
|
122649
122978
|
positionalParams: [
|
122650
|
-
"mutate?" /*
|
122979
|
+
"mutate-iterator?" /* ConditionallyMutateIterator */,
|
122651
122980
|
"mutate?" /* ConditionallyMutate */,
|
122652
122981
|
"mutate?" /* ConditionallyMutate */
|
122653
122982
|
],
|
@@ -122892,6 +123221,118 @@ var TYPED_GLOBALS = [
|
|
122892
123221
|
calleeEffect: "read" /* Read */,
|
122893
123222
|
returnValueKind: "primitive" /* Primitive */
|
122894
123223
|
})
|
123224
|
+
],
|
123225
|
+
[
|
123226
|
+
"parseInt",
|
123227
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123228
|
+
positionalParams: [],
|
123229
|
+
restParam: "read" /* Read */,
|
123230
|
+
returnType: { kind: "Primitive" },
|
123231
|
+
calleeEffect: "read" /* Read */,
|
123232
|
+
returnValueKind: "primitive" /* Primitive */
|
123233
|
+
})
|
123234
|
+
],
|
123235
|
+
[
|
123236
|
+
"parseFloat",
|
123237
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123238
|
+
positionalParams: [],
|
123239
|
+
restParam: "read" /* Read */,
|
123240
|
+
returnType: { kind: "Primitive" },
|
123241
|
+
calleeEffect: "read" /* Read */,
|
123242
|
+
returnValueKind: "primitive" /* Primitive */
|
123243
|
+
})
|
123244
|
+
],
|
123245
|
+
[
|
123246
|
+
"isNaN",
|
123247
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123248
|
+
positionalParams: [],
|
123249
|
+
restParam: "read" /* Read */,
|
123250
|
+
returnType: { kind: "Primitive" },
|
123251
|
+
calleeEffect: "read" /* Read */,
|
123252
|
+
returnValueKind: "primitive" /* Primitive */
|
123253
|
+
})
|
123254
|
+
],
|
123255
|
+
[
|
123256
|
+
"isFinite",
|
123257
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123258
|
+
positionalParams: [],
|
123259
|
+
restParam: "read" /* Read */,
|
123260
|
+
returnType: { kind: "Primitive" },
|
123261
|
+
calleeEffect: "read" /* Read */,
|
123262
|
+
returnValueKind: "primitive" /* Primitive */
|
123263
|
+
})
|
123264
|
+
],
|
123265
|
+
[
|
123266
|
+
"encodeURI",
|
123267
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123268
|
+
positionalParams: [],
|
123269
|
+
restParam: "read" /* Read */,
|
123270
|
+
returnType: { kind: "Primitive" },
|
123271
|
+
calleeEffect: "read" /* Read */,
|
123272
|
+
returnValueKind: "primitive" /* Primitive */
|
123273
|
+
})
|
123274
|
+
],
|
123275
|
+
[
|
123276
|
+
"encodeURIComponent",
|
123277
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123278
|
+
positionalParams: [],
|
123279
|
+
restParam: "read" /* Read */,
|
123280
|
+
returnType: { kind: "Primitive" },
|
123281
|
+
calleeEffect: "read" /* Read */,
|
123282
|
+
returnValueKind: "primitive" /* Primitive */
|
123283
|
+
})
|
123284
|
+
],
|
123285
|
+
[
|
123286
|
+
"decodeURI",
|
123287
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123288
|
+
positionalParams: [],
|
123289
|
+
restParam: "read" /* Read */,
|
123290
|
+
returnType: { kind: "Primitive" },
|
123291
|
+
calleeEffect: "read" /* Read */,
|
123292
|
+
returnValueKind: "primitive" /* Primitive */
|
123293
|
+
})
|
123294
|
+
],
|
123295
|
+
[
|
123296
|
+
"decodeURIComponent",
|
123297
|
+
addFunction(DEFAULT_SHAPES, [], {
|
123298
|
+
positionalParams: [],
|
123299
|
+
restParam: "read" /* Read */,
|
123300
|
+
returnType: { kind: "Primitive" },
|
123301
|
+
calleeEffect: "read" /* Read */,
|
123302
|
+
returnValueKind: "primitive" /* Primitive */
|
123303
|
+
})
|
123304
|
+
],
|
123305
|
+
[
|
123306
|
+
"Map",
|
123307
|
+
addFunction(
|
123308
|
+
DEFAULT_SHAPES,
|
123309
|
+
[],
|
123310
|
+
{
|
123311
|
+
positionalParams: ["mutate-iterator?" /* ConditionallyMutateIterator */],
|
123312
|
+
restParam: null,
|
123313
|
+
returnType: { kind: "Object", shapeId: BuiltInMapId },
|
123314
|
+
calleeEffect: "read" /* Read */,
|
123315
|
+
returnValueKind: "mutable" /* Mutable */
|
123316
|
+
},
|
123317
|
+
null,
|
123318
|
+
true
|
123319
|
+
)
|
123320
|
+
],
|
123321
|
+
[
|
123322
|
+
"Set",
|
123323
|
+
addFunction(
|
123324
|
+
DEFAULT_SHAPES,
|
123325
|
+
[],
|
123326
|
+
{
|
123327
|
+
positionalParams: ["mutate-iterator?" /* ConditionallyMutateIterator */],
|
123328
|
+
restParam: null,
|
123329
|
+
returnType: { kind: "Object", shapeId: BuiltInSetId },
|
123330
|
+
calleeEffect: "read" /* Read */,
|
123331
|
+
returnValueKind: "mutable" /* Mutable */
|
123332
|
+
},
|
123333
|
+
null,
|
123334
|
+
true
|
123335
|
+
)
|
122895
123336
|
]
|
122896
123337
|
// TODO: rest of Global objects
|
122897
123338
|
];
|
@@ -123385,6 +123826,8 @@ var InstrumentationSchema = z.object({
|
|
123385
123826
|
(opts) => opts.gating != null || opts.globalGating != null,
|
123386
123827
|
"Expected at least one of gating or globalGating"
|
123387
123828
|
);
|
123829
|
+
var USE_FIRE_FUNCTION_NAME = "useFire";
|
123830
|
+
var EMIT_FREEZE_GLOBAL_GATING = "__DEV__";
|
123388
123831
|
var MacroMethodSchema = z.union([
|
123389
123832
|
z.object({ type: z.literal("wildcard") }),
|
123390
123833
|
z.object({ type: z.literal("name"), name: z.string() })
|
@@ -124009,7 +124452,7 @@ function parseConfigPragmaForTests(pragma, defaults) {
|
|
124009
124452
|
}
|
124010
124453
|
var _globals, _shapes, _moduleTypes, _nextIdentifer, _nextBlock, _nextScope, _scope, _outlinedFunctions, _contextIdentifiers, _hoistedIdentifiers, _Environment_instances, resolveModuleType_fn, isKnownReactModule_fn, getCustomHookType_fn;
|
124011
124454
|
var Environment = class {
|
124012
|
-
constructor(scope, fnType, compilerMode, config, contextIdentifiers, logger, filename, code,
|
124455
|
+
constructor(scope, fnType, compilerMode, config, contextIdentifiers, logger, filename, code, programContext) {
|
124013
124456
|
__privateAdd(this, _Environment_instances);
|
124014
124457
|
__privateAdd(this, _globals);
|
124015
124458
|
__privateAdd(this, _shapes);
|
@@ -124028,11 +124471,11 @@ var Environment = class {
|
|
124028
124471
|
this.filename = filename;
|
124029
124472
|
this.code = code;
|
124030
124473
|
this.logger = logger;
|
124031
|
-
this.
|
124474
|
+
this.programContext = programContext;
|
124032
124475
|
__privateSet(this, _shapes, new Map(DEFAULT_SHAPES));
|
124033
124476
|
__privateSet(this, _globals, new Map(DEFAULT_GLOBALS));
|
124034
|
-
this.hasLoweredContextAccess = false;
|
124035
124477
|
this.hasFireRewrite = false;
|
124478
|
+
this.hasInferredEffect = false;
|
124036
124479
|
if (config.disableMemoizationForDebugging && config.enableChangeDetectionForDebugging != null) {
|
124037
124480
|
CompilerError.throwInvalidConfig({
|
124038
124481
|
reason: `Invalid environment config: the 'disableMemoizationForDebugging' and 'enableChangeDetectionForDebugging' options cannot be used together`,
|
@@ -124080,6 +124523,9 @@ var Environment = class {
|
|
124080
124523
|
get nextScopeId() {
|
124081
124524
|
return makeScopeId(__privateWrapper(this, _nextScope)._++);
|
124082
124525
|
}
|
124526
|
+
get scope() {
|
124527
|
+
return __privateGet(this, _scope);
|
124528
|
+
}
|
124083
124529
|
logErrors(errors) {
|
124084
124530
|
if (errors.isOk() || this.logger == null) {
|
124085
124531
|
return;
|
@@ -124630,7 +125076,7 @@ function isMutable2(instr, place) {
|
|
124630
125076
|
function inRange({ id }, range) {
|
124631
125077
|
return id >= range.start && id < range.end;
|
124632
125078
|
}
|
124633
|
-
function mayAllocate(
|
125079
|
+
function mayAllocate(_env4, instruction) {
|
124634
125080
|
const { value } = instruction;
|
124635
125081
|
switch (value.kind) {
|
124636
125082
|
case "Destructure": {
|
@@ -124968,260 +125414,14 @@ function pruneUnusedLabelsHIR(fn) {
|
|
124968
125414
|
}
|
124969
125415
|
}
|
124970
125416
|
|
124971
|
-
// src/
|
124972
|
-
function
|
124973
|
-
|
124974
|
-
return null;
|
124975
|
-
}
|
124976
|
-
const error = new CompilerError();
|
124977
|
-
const restrictedImports = new Set(validateBlocklistedImports);
|
124978
|
-
path.traverse({
|
124979
|
-
ImportDeclaration(importDeclPath) {
|
124980
|
-
var _a;
|
124981
|
-
if (restrictedImports.has(importDeclPath.node.source.value)) {
|
124982
|
-
error.push({
|
124983
|
-
severity: "Todo" /* Todo */,
|
124984
|
-
reason: "Bailing out due to blocklisted import",
|
124985
|
-
description: `Import from module ${importDeclPath.node.source.value}`,
|
124986
|
-
loc: (_a = importDeclPath.node.loc) != null ? _a : null
|
124987
|
-
});
|
124988
|
-
}
|
124989
|
-
}
|
124990
|
-
});
|
124991
|
-
if (error.hasErrors()) {
|
124992
|
-
return error;
|
124993
|
-
} else {
|
124994
|
-
return null;
|
124995
|
-
}
|
124996
|
-
}
|
124997
|
-
function addImportsToProgram(path, importList) {
|
124998
|
-
const identifiers = /* @__PURE__ */ new Set();
|
124999
|
-
const sortedImports = /* @__PURE__ */ new Map();
|
125000
|
-
for (const { importSpecifierName, source: source2 } of importList) {
|
125001
|
-
CompilerError.invariant(identifiers.has(importSpecifierName) === false, {
|
125002
|
-
reason: `Encountered conflicting import specifier for ${importSpecifierName} in Forget config.`,
|
125003
|
-
description: null,
|
125004
|
-
loc: GeneratedSource,
|
125005
|
-
suggestions: null
|
125006
|
-
});
|
125007
|
-
CompilerError.invariant(
|
125008
|
-
path.scope.hasBinding(importSpecifierName) === false,
|
125009
|
-
{
|
125010
|
-
reason: `Encountered conflicting import specifiers for ${importSpecifierName} in generated program.`,
|
125011
|
-
description: null,
|
125012
|
-
loc: GeneratedSource,
|
125013
|
-
suggestions: null
|
125014
|
-
}
|
125015
|
-
);
|
125016
|
-
identifiers.add(importSpecifierName);
|
125017
|
-
const importSpecifierNameList = getOrInsertDefault(
|
125018
|
-
sortedImports,
|
125019
|
-
source2,
|
125020
|
-
[]
|
125021
|
-
);
|
125022
|
-
importSpecifierNameList.push(importSpecifierName);
|
125023
|
-
}
|
125024
|
-
const stmts = [];
|
125025
|
-
for (const [source2, importSpecifierNameList] of sortedImports) {
|
125026
|
-
const importSpecifiers = importSpecifierNameList.map((name) => {
|
125027
|
-
const id = t3.identifier(name);
|
125028
|
-
return t3.importSpecifier(id, id);
|
125029
|
-
});
|
125030
|
-
stmts.push(t3.importDeclaration(importSpecifiers, t3.stringLiteral(source2)));
|
125031
|
-
}
|
125032
|
-
path.unshiftContainer("body", stmts);
|
125033
|
-
}
|
125034
|
-
function isNonNamespacedImport(importDeclPath, moduleName) {
|
125035
|
-
return importDeclPath.get("source").node.value === moduleName && importDeclPath.get("specifiers").every((specifier) => specifier.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
125036
|
-
}
|
125037
|
-
function hasExistingNonNamespacedImportOfModule(program, moduleName) {
|
125038
|
-
let hasExistingImport = false;
|
125039
|
-
program.traverse({
|
125040
|
-
ImportDeclaration(importDeclPath) {
|
125041
|
-
if (isNonNamespacedImport(importDeclPath, moduleName)) {
|
125042
|
-
hasExistingImport = true;
|
125043
|
-
}
|
125044
|
-
}
|
125045
|
-
});
|
125046
|
-
return hasExistingImport;
|
125047
|
-
}
|
125048
|
-
function addMemoCacheFunctionSpecifierToExistingImport(program, moduleName, identifierName) {
|
125049
|
-
let didInsertUseMemoCache = false;
|
125050
|
-
program.traverse({
|
125051
|
-
ImportDeclaration(importDeclPath) {
|
125052
|
-
if (!didInsertUseMemoCache && isNonNamespacedImport(importDeclPath, moduleName)) {
|
125053
|
-
importDeclPath.pushContainer(
|
125054
|
-
"specifiers",
|
125055
|
-
t3.importSpecifier(t3.identifier(identifierName), t3.identifier("c"))
|
125056
|
-
);
|
125057
|
-
didInsertUseMemoCache = true;
|
125058
|
-
}
|
125059
|
-
}
|
125060
|
-
});
|
125061
|
-
return didInsertUseMemoCache;
|
125062
|
-
}
|
125063
|
-
function updateMemoCacheFunctionImport(program, moduleName, useMemoCacheIdentifier) {
|
125064
|
-
const hasExistingImport = hasExistingNonNamespacedImportOfModule(
|
125065
|
-
program,
|
125066
|
-
moduleName
|
125067
|
-
);
|
125068
|
-
if (hasExistingImport) {
|
125069
|
-
const didUpdateImport = addMemoCacheFunctionSpecifierToExistingImport(
|
125070
|
-
program,
|
125071
|
-
moduleName,
|
125072
|
-
useMemoCacheIdentifier
|
125073
|
-
);
|
125074
|
-
if (!didUpdateImport) {
|
125075
|
-
throw new Error(
|
125076
|
-
`Expected an ImportDeclaration of \`${moduleName}\` in order to update ImportSpecifiers with useMemoCache`
|
125077
|
-
);
|
125078
|
-
}
|
125079
|
-
} else {
|
125080
|
-
addMemoCacheFunctionImportDeclaration(
|
125081
|
-
program,
|
125082
|
-
moduleName,
|
125083
|
-
useMemoCacheIdentifier
|
125084
|
-
);
|
125085
|
-
}
|
125086
|
-
}
|
125087
|
-
function addMemoCacheFunctionImportDeclaration(program, moduleName, localName) {
|
125088
|
-
program.unshiftContainer(
|
125089
|
-
"body",
|
125090
|
-
t3.importDeclaration(
|
125091
|
-
[t3.importSpecifier(t3.identifier(localName), t3.identifier("c"))],
|
125092
|
-
t3.stringLiteral(moduleName)
|
125093
|
-
)
|
125094
|
-
);
|
125417
|
+
// src/Utils/ComponentDeclaration.ts
|
125418
|
+
function isComponentDeclaration(node) {
|
125419
|
+
return Object.prototype.hasOwnProperty.call(node, "__componentDeclaration");
|
125095
125420
|
}
|
125096
125421
|
|
125097
|
-
// src/
|
125098
|
-
|
125099
|
-
|
125100
|
-
* Any errors will panic the compiler by throwing an exception, which will
|
125101
|
-
* bubble up to the nearest exception handler above the Forget transform.
|
125102
|
-
* If Forget is invoked through `BabelPluginReactCompiler`, this will at the least
|
125103
|
-
* skip Forget compilation for the rest of current file.
|
125104
|
-
*/
|
125105
|
-
"all_errors",
|
125106
|
-
/*
|
125107
|
-
* Panic by throwing an exception only on critical or unrecognized errors.
|
125108
|
-
* For all other errors, skip the erroring function without inserting
|
125109
|
-
* a Forget-compiled version (i.e. same behavior as noEmit).
|
125110
|
-
*/
|
125111
|
-
"critical_errors",
|
125112
|
-
// Never panic by throwing an exception.
|
125113
|
-
"none"
|
125114
|
-
]);
|
125115
|
-
var CompilerReactTargetSchema = z.union([
|
125116
|
-
z.literal("17"),
|
125117
|
-
z.literal("18"),
|
125118
|
-
z.literal("19"),
|
125119
|
-
/**
|
125120
|
-
* Used exclusively for Meta apps which are guaranteed to have compatible
|
125121
|
-
* react runtime and compiler versions. Note that only the FB-internal bundles
|
125122
|
-
* re-export useMemoCache (see
|
125123
|
-
* https://github.com/facebook/react/blob/5b0ef217ef32333a8e56f39be04327c89efa346f/packages/react/index.fb.js#L68-L70),
|
125124
|
-
* so this option is invalid / creates runtime errors for open-source users.
|
125125
|
-
*/
|
125126
|
-
z.object({
|
125127
|
-
kind: z.literal("donotuse_meta_internal"),
|
125128
|
-
runtimeModule: z.string().default("react")
|
125129
|
-
})
|
125130
|
-
]);
|
125131
|
-
var CompilationModeSchema = z.enum([
|
125132
|
-
/*
|
125133
|
-
* Compiles functions annotated with "use forget" or component/hook-like functions.
|
125134
|
-
* This latter includes:
|
125135
|
-
* * Components declared with component syntax.
|
125136
|
-
* * Functions which can be inferred to be a component or hook:
|
125137
|
-
* - Be named like a hook or component. This logic matches the ESLint rule.
|
125138
|
-
* - *and* create JSX and/or call a hook. This is an additional check to help prevent
|
125139
|
-
* false positives, since compilation has a greater impact than linting.
|
125140
|
-
* This is the default mode
|
125141
|
-
*/
|
125142
|
-
"infer",
|
125143
|
-
// Compile only components using Flow component syntax and hooks using hook syntax.
|
125144
|
-
"syntax",
|
125145
|
-
// Compile only functions which are explicitly annotated with "use forget"
|
125146
|
-
"annotation",
|
125147
|
-
// Compile all top-level functions
|
125148
|
-
"all"
|
125149
|
-
]);
|
125150
|
-
var defaultOptions = {
|
125151
|
-
compilationMode: "infer",
|
125152
|
-
panicThreshold: "none",
|
125153
|
-
environment: parseEnvironmentConfig({}).unwrap(),
|
125154
|
-
logger: null,
|
125155
|
-
gating: null,
|
125156
|
-
noEmit: false,
|
125157
|
-
eslintSuppressionRules: null,
|
125158
|
-
flowSuppressions: true,
|
125159
|
-
ignoreUseNoForget: false,
|
125160
|
-
sources: (filename) => {
|
125161
|
-
return filename.indexOf("node_modules") === -1;
|
125162
|
-
},
|
125163
|
-
enableReanimatedCheck: true,
|
125164
|
-
target: "19"
|
125165
|
-
};
|
125166
|
-
function parsePluginOptions(obj) {
|
125167
|
-
if (obj == null || typeof obj !== "object") {
|
125168
|
-
return defaultOptions;
|
125169
|
-
}
|
125170
|
-
const parsedOptions = /* @__PURE__ */ Object.create(null);
|
125171
|
-
for (let [key2, value] of Object.entries(obj)) {
|
125172
|
-
if (typeof value === "string") {
|
125173
|
-
value = value.toLowerCase();
|
125174
|
-
}
|
125175
|
-
if (isCompilerFlag(key2)) {
|
125176
|
-
switch (key2) {
|
125177
|
-
case "environment": {
|
125178
|
-
const environmentResult = parseEnvironmentConfig(value);
|
125179
|
-
if (environmentResult.isErr()) {
|
125180
|
-
CompilerError.throwInvalidConfig({
|
125181
|
-
reason: "Error in validating environment config. This is an advanced setting and not meant to be used directly",
|
125182
|
-
description: environmentResult.unwrapErr().toString(),
|
125183
|
-
suggestions: null,
|
125184
|
-
loc: null
|
125185
|
-
});
|
125186
|
-
}
|
125187
|
-
parsedOptions[key2] = environmentResult.unwrap();
|
125188
|
-
break;
|
125189
|
-
}
|
125190
|
-
case "target": {
|
125191
|
-
parsedOptions[key2] = parseTargetConfig(value);
|
125192
|
-
break;
|
125193
|
-
}
|
125194
|
-
case "gating": {
|
125195
|
-
if (value == null) {
|
125196
|
-
parsedOptions[key2] = null;
|
125197
|
-
} else {
|
125198
|
-
parsedOptions[key2] = tryParseExternalFunction(value);
|
125199
|
-
}
|
125200
|
-
break;
|
125201
|
-
}
|
125202
|
-
default: {
|
125203
|
-
parsedOptions[key2] = value;
|
125204
|
-
}
|
125205
|
-
}
|
125206
|
-
}
|
125207
|
-
}
|
125208
|
-
return __spreadValues(__spreadValues({}, defaultOptions), parsedOptions);
|
125209
|
-
}
|
125210
|
-
function parseTargetConfig(value) {
|
125211
|
-
const parsed = CompilerReactTargetSchema.safeParse(value);
|
125212
|
-
if (parsed.success) {
|
125213
|
-
return parsed.data;
|
125214
|
-
} else {
|
125215
|
-
CompilerError.throwInvalidConfig({
|
125216
|
-
reason: "Not a valid target",
|
125217
|
-
description: `${fromZodError(parsed.error)}`,
|
125218
|
-
suggestions: null,
|
125219
|
-
loc: null
|
125220
|
-
});
|
125221
|
-
}
|
125222
|
-
}
|
125223
|
-
function isCompilerFlag(s) {
|
125224
|
-
return hasOwnProperty2(defaultOptions, s);
|
125422
|
+
// src/Utils/HookDeclaration.ts
|
125423
|
+
function isHookDeclaration(node) {
|
125424
|
+
return Object.prototype.hasOwnProperty.call(node, "__hookDeclaration");
|
125225
125425
|
}
|
125226
125426
|
|
125227
125427
|
// src/Entrypoint/Pipeline.ts
|
@@ -129030,7 +129230,7 @@ _catchHandlers = new WeakMap();
|
|
129030
129230
|
_controlFlowStack = new WeakMap();
|
129031
129231
|
|
129032
129232
|
// src/ReactiveScopes/CodegenReactiveFunction.ts
|
129033
|
-
var
|
129233
|
+
var t3 = __toESM(require("@babel/types"));
|
129034
129234
|
var import_crypto = require("crypto");
|
129035
129235
|
|
129036
129236
|
// src/ReactiveScopes/MemoizeFbtAndMacroOperandsInSameScope.ts
|
@@ -129196,9 +129396,10 @@ function codegenFunction(fn, {
|
|
129196
129396
|
const compiled = compileResult.unwrap();
|
129197
129397
|
const hookGuard = fn.env.config.enableEmitHookGuards;
|
129198
129398
|
if (hookGuard != null && fn.env.isInferredMemoEnabled) {
|
129199
|
-
compiled.body =
|
129399
|
+
compiled.body = t3.blockStatement([
|
129200
129400
|
createHookGuard(
|
129201
129401
|
hookGuard,
|
129402
|
+
fn.env.programContext,
|
129202
129403
|
compiled.body.body,
|
129203
129404
|
0 /* PushHookGuard */,
|
129204
129405
|
1 /* PopHookGuard */
|
@@ -129208,12 +129409,13 @@ function codegenFunction(fn, {
|
|
129208
129409
|
const cacheCount = compiled.memoSlotsUsed;
|
129209
129410
|
if (cacheCount !== 0) {
|
129210
129411
|
const preface = [];
|
129412
|
+
const useMemoCacheIdentifier = fn.env.programContext.addMemoCacheImport().name;
|
129211
129413
|
preface.push(
|
129212
|
-
|
129213
|
-
|
129214
|
-
|
129215
|
-
|
129216
|
-
|
129414
|
+
t3.variableDeclaration("const", [
|
129415
|
+
t3.variableDeclarator(
|
129416
|
+
t3.identifier(cx.synthesizeName("$")),
|
129417
|
+
t3.callExpression(t3.identifier(useMemoCacheIdentifier), [
|
129418
|
+
t3.numericLiteral(cacheCount)
|
129217
129419
|
])
|
129218
129420
|
)
|
129219
129421
|
])
|
@@ -129221,60 +129423,60 @@ function codegenFunction(fn, {
|
|
129221
129423
|
if (fastRefreshState !== null) {
|
129222
129424
|
const index = cx.synthesizeName("$i");
|
129223
129425
|
preface.push(
|
129224
|
-
|
129225
|
-
|
129426
|
+
t3.ifStatement(
|
129427
|
+
t3.binaryExpression(
|
129226
129428
|
"!==",
|
129227
|
-
|
129228
|
-
|
129229
|
-
|
129429
|
+
t3.memberExpression(
|
129430
|
+
t3.identifier(cx.synthesizeName("$")),
|
129431
|
+
t3.numericLiteral(fastRefreshState.cacheIndex),
|
129230
129432
|
true
|
129231
129433
|
),
|
129232
|
-
|
129434
|
+
t3.stringLiteral(fastRefreshState.hash)
|
129233
129435
|
),
|
129234
|
-
|
129235
|
-
|
129236
|
-
|
129237
|
-
|
129436
|
+
t3.blockStatement([
|
129437
|
+
t3.forStatement(
|
129438
|
+
t3.variableDeclaration("let", [
|
129439
|
+
t3.variableDeclarator(t3.identifier(index), t3.numericLiteral(0))
|
129238
129440
|
]),
|
129239
|
-
|
129441
|
+
t3.binaryExpression(
|
129240
129442
|
"<",
|
129241
|
-
|
129242
|
-
|
129443
|
+
t3.identifier(index),
|
129444
|
+
t3.numericLiteral(cacheCount)
|
129243
129445
|
),
|
129244
|
-
|
129446
|
+
t3.assignmentExpression(
|
129245
129447
|
"+=",
|
129246
|
-
|
129247
|
-
|
129448
|
+
t3.identifier(index),
|
129449
|
+
t3.numericLiteral(1)
|
129248
129450
|
),
|
129249
|
-
|
129250
|
-
|
129251
|
-
|
129451
|
+
t3.blockStatement([
|
129452
|
+
t3.expressionStatement(
|
129453
|
+
t3.assignmentExpression(
|
129252
129454
|
"=",
|
129253
|
-
|
129254
|
-
|
129255
|
-
|
129455
|
+
t3.memberExpression(
|
129456
|
+
t3.identifier(cx.synthesizeName("$")),
|
129457
|
+
t3.identifier(index),
|
129256
129458
|
true
|
129257
129459
|
),
|
129258
|
-
|
129259
|
-
|
129260
|
-
|
129261
|
-
|
129460
|
+
t3.callExpression(
|
129461
|
+
t3.memberExpression(
|
129462
|
+
t3.identifier("Symbol"),
|
129463
|
+
t3.identifier("for")
|
129262
129464
|
),
|
129263
|
-
[
|
129465
|
+
[t3.stringLiteral(MEMO_CACHE_SENTINEL)]
|
129264
129466
|
)
|
129265
129467
|
)
|
129266
129468
|
)
|
129267
129469
|
])
|
129268
129470
|
),
|
129269
|
-
|
129270
|
-
|
129471
|
+
t3.expressionStatement(
|
129472
|
+
t3.assignmentExpression(
|
129271
129473
|
"=",
|
129272
|
-
|
129273
|
-
|
129274
|
-
|
129474
|
+
t3.memberExpression(
|
129475
|
+
t3.identifier(cx.synthesizeName("$")),
|
129476
|
+
t3.numericLiteral(fastRefreshState.cacheIndex),
|
129275
129477
|
true
|
129276
129478
|
),
|
129277
|
-
|
129479
|
+
t3.stringLiteral(fastRefreshState.hash)
|
129278
129480
|
)
|
129279
129481
|
)
|
129280
129482
|
])
|
@@ -129285,30 +129487,43 @@ function codegenFunction(fn, {
|
|
129285
129487
|
}
|
129286
129488
|
const emitInstrumentForget = fn.env.config.enableEmitInstrumentForget;
|
129287
129489
|
if (emitInstrumentForget != null && fn.id != null && fn.env.isInferredMemoEnabled) {
|
129288
|
-
|
129289
|
-
|
129290
|
-
|
129291
|
-
|
129292
|
-
|
129293
|
-
|
129490
|
+
const gating = emitInstrumentForget.gating != null ? t3.identifier(
|
129491
|
+
fn.env.programContext.addImportSpecifier(
|
129492
|
+
emitInstrumentForget.gating
|
129493
|
+
).name
|
129494
|
+
) : null;
|
129495
|
+
const globalGating = emitInstrumentForget.globalGating != null ? t3.identifier(emitInstrumentForget.globalGating) : null;
|
129496
|
+
if (emitInstrumentForget.globalGating != null) {
|
129497
|
+
const assertResult = fn.env.programContext.assertGlobalBinding(
|
129498
|
+
emitInstrumentForget.globalGating
|
129294
129499
|
);
|
129295
|
-
|
129296
|
-
|
129500
|
+
if (assertResult.isErr()) {
|
129501
|
+
return assertResult;
|
129502
|
+
}
|
129503
|
+
}
|
129504
|
+
let ifTest;
|
129505
|
+
if (gating != null && globalGating != null) {
|
129506
|
+
ifTest = t3.logicalExpression("&&", globalGating, gating);
|
129507
|
+
} else if (gating != null) {
|
129508
|
+
ifTest = gating;
|
129297
129509
|
} else {
|
129298
|
-
CompilerError.invariant(
|
129510
|
+
CompilerError.invariant(globalGating != null, {
|
129299
129511
|
reason: "Bad config not caught! Expected at least one of gating or globalGating",
|
129300
129512
|
loc: null,
|
129301
129513
|
suggestions: null
|
129302
129514
|
});
|
129303
|
-
|
129304
|
-
}
|
129305
|
-
const
|
129306
|
-
|
129307
|
-
|
129308
|
-
|
129309
|
-
|
129310
|
-
|
129311
|
-
)
|
129515
|
+
ifTest = globalGating;
|
129516
|
+
}
|
129517
|
+
const instrumentFnIdentifier = fn.env.programContext.addImportSpecifier(
|
129518
|
+
emitInstrumentForget.fn
|
129519
|
+
).name;
|
129520
|
+
const test = t3.ifStatement(
|
129521
|
+
ifTest,
|
129522
|
+
t3.expressionStatement(
|
129523
|
+
t3.callExpression(t3.identifier(instrumentFnIdentifier), [
|
129524
|
+
t3.stringLiteral(fn.id),
|
129525
|
+
t3.stringLiteral((_b = fn.env.filename) != null ? _b : "")
|
129526
|
+
])
|
129312
129527
|
)
|
129313
129528
|
);
|
129314
129529
|
compiled.body.body.unshift(test);
|
@@ -129347,7 +129562,7 @@ function codegenReactiveFunction(cx, fn) {
|
|
129347
129562
|
}
|
129348
129563
|
const params = fn.params.map((param) => convertParameter(param));
|
129349
129564
|
const body = codegenBlock(cx, fn.body);
|
129350
|
-
body.directives = fn.directives.map((d) =>
|
129565
|
+
body.directives = fn.directives.map((d) => t3.directive(t3.directiveLiteral(d)));
|
129351
129566
|
const statements = body.body;
|
129352
129567
|
if (statements.length !== 0) {
|
129353
129568
|
const last = statements[statements.length - 1];
|
@@ -129363,7 +129578,7 @@ function codegenReactiveFunction(cx, fn) {
|
|
129363
129578
|
return Ok({
|
129364
129579
|
type: "CodegenFunction",
|
129365
129580
|
loc: fn.loc,
|
129366
|
-
id: fn.id !== null ?
|
129581
|
+
id: fn.id !== null ? t3.identifier(fn.id) : null,
|
129367
129582
|
params,
|
129368
129583
|
body,
|
129369
129584
|
generator: fn.generator,
|
@@ -129374,8 +129589,8 @@ function codegenReactiveFunction(cx, fn) {
|
|
129374
129589
|
prunedMemoBlocks: countMemoBlockVisitor.prunedMemoBlocks,
|
129375
129590
|
prunedMemoValues: countMemoBlockVisitor.prunedMemoValues,
|
129376
129591
|
outlined: [],
|
129377
|
-
|
129378
|
-
|
129592
|
+
hasFireRewrite: fn.env.hasFireRewrite,
|
129593
|
+
hasInferredEffect: fn.env.hasInferredEffect
|
129379
129594
|
});
|
129380
129595
|
}
|
129381
129596
|
var CountMemoBlockVisitor = class extends ReactiveFunctionVisitor {
|
@@ -129402,7 +129617,7 @@ function convertParameter(param) {
|
|
129402
129617
|
if (param.kind === "Identifier") {
|
129403
129618
|
return convertIdentifier(param.identifier);
|
129404
129619
|
} else {
|
129405
|
-
return
|
129620
|
+
return t3.restElement(convertIdentifier(param.place.identifier));
|
129406
129621
|
}
|
129407
129622
|
}
|
129408
129623
|
var _nextCacheIndex, _declarations;
|
@@ -129496,8 +129711,8 @@ function codegenBlockNoReset(cx, block) {
|
|
129496
129711
|
if (item.label !== null && !item.label.implicit) {
|
129497
129712
|
const block2 = statement.type === "BlockStatement" && statement.body.length === 1 ? statement.body[0] : statement;
|
129498
129713
|
statements.push(
|
129499
|
-
|
129500
|
-
|
129714
|
+
t3.labeledStatement(
|
129715
|
+
t3.identifier(codegenLabel(item.label.id)),
|
129501
129716
|
block2
|
129502
129717
|
)
|
129503
129718
|
);
|
@@ -129516,16 +129731,20 @@ function codegenBlockNoReset(cx, block) {
|
|
129516
129731
|
}
|
129517
129732
|
}
|
129518
129733
|
}
|
129519
|
-
return
|
129734
|
+
return t3.blockStatement(statements);
|
129520
129735
|
}
|
129521
129736
|
function wrapCacheDep(cx, value) {
|
129522
129737
|
if (cx.env.config.enableEmitFreeze != null && cx.env.isInferredMemoEnabled) {
|
129523
|
-
|
129524
|
-
|
129525
|
-
|
129526
|
-
|
129527
|
-
|
129528
|
-
),
|
129738
|
+
const emitFreezeIdentifier = cx.env.programContext.addImportSpecifier(
|
129739
|
+
cx.env.config.enableEmitFreeze
|
129740
|
+
).name;
|
129741
|
+
cx.env.programContext.assertGlobalBinding(EMIT_FREEZE_GLOBAL_GATING, cx.env.scope).unwrap();
|
129742
|
+
return t3.conditionalExpression(
|
129743
|
+
t3.identifier(EMIT_FREEZE_GLOBAL_GATING),
|
129744
|
+
t3.callExpression(t3.identifier(emitFreezeIdentifier), [
|
129745
|
+
value,
|
129746
|
+
t3.stringLiteral(cx.fnName)
|
129747
|
+
]),
|
129529
129748
|
value
|
129530
129749
|
);
|
129531
129750
|
} else {
|
@@ -129542,20 +129761,20 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129542
129761
|
for (const dep of [...scope.dependencies].sort(compareScopeDependency)) {
|
129543
129762
|
const index = cx.nextCacheIndex;
|
129544
129763
|
changeExpressionComments.push(printDependencyComment(dep));
|
129545
|
-
const comparison =
|
129764
|
+
const comparison = t3.binaryExpression(
|
129546
129765
|
"!==",
|
129547
|
-
|
129548
|
-
|
129549
|
-
|
129766
|
+
t3.memberExpression(
|
129767
|
+
t3.identifier(cx.synthesizeName("$")),
|
129768
|
+
t3.numericLiteral(index),
|
129550
129769
|
true
|
129551
129770
|
),
|
129552
129771
|
codegenDependency(cx, dep)
|
129553
129772
|
);
|
129554
129773
|
if (cx.env.config.enableChangeVariableCodegen) {
|
129555
|
-
const changeIdentifier =
|
129774
|
+
const changeIdentifier = t3.identifier(cx.synthesizeName(`c_${index}`));
|
129556
129775
|
statements.push(
|
129557
|
-
|
129558
|
-
|
129776
|
+
t3.variableDeclaration("const", [
|
129777
|
+
t3.variableDeclarator(changeIdentifier, comparison)
|
129559
129778
|
])
|
129560
129779
|
);
|
129561
129780
|
changeExpressions.push(changeIdentifier);
|
@@ -129563,12 +129782,12 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129563
129782
|
changeExpressions.push(comparison);
|
129564
129783
|
}
|
129565
129784
|
cacheStoreStatements.push(
|
129566
|
-
|
129567
|
-
|
129785
|
+
t3.expressionStatement(
|
129786
|
+
t3.assignmentExpression(
|
129568
129787
|
"=",
|
129569
|
-
|
129570
|
-
|
129571
|
-
|
129788
|
+
t3.memberExpression(
|
129789
|
+
t3.identifier(cx.synthesizeName("$")),
|
129790
|
+
t3.numericLiteral(index),
|
129572
129791
|
true
|
129573
129792
|
),
|
129574
129793
|
codegenDependency(cx, dep)
|
@@ -129596,7 +129815,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129596
129815
|
outputComments.push(name.name);
|
129597
129816
|
if (!cx.hasDeclared(identifier4)) {
|
129598
129817
|
statements.push(
|
129599
|
-
|
129818
|
+
t3.variableDeclaration("let", [t3.variableDeclarator(name)])
|
129600
129819
|
);
|
129601
129820
|
}
|
129602
129821
|
cacheLoads.push({ name, index, value: wrapCacheDep(cx, name) });
|
@@ -129616,7 +129835,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129616
129835
|
if (acc == null) {
|
129617
129836
|
return ident;
|
129618
129837
|
}
|
129619
|
-
return
|
129838
|
+
return t3.logicalExpression("||", acc, ident);
|
129620
129839
|
},
|
129621
129840
|
null
|
129622
129841
|
);
|
@@ -129627,16 +129846,16 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129627
129846
|
loc: null,
|
129628
129847
|
suggestions: null
|
129629
129848
|
});
|
129630
|
-
testCondition =
|
129849
|
+
testCondition = t3.binaryExpression(
|
129631
129850
|
"===",
|
129632
|
-
|
129633
|
-
|
129634
|
-
|
129851
|
+
t3.memberExpression(
|
129852
|
+
t3.identifier(cx.synthesizeName("$")),
|
129853
|
+
t3.numericLiteral(firstOutputIndex),
|
129635
129854
|
true
|
129636
129855
|
),
|
129637
|
-
|
129638
|
-
|
129639
|
-
[
|
129856
|
+
t3.callExpression(
|
129857
|
+
t3.memberExpression(t3.identifier("Symbol"), t3.identifier("for")),
|
129858
|
+
[t3.stringLiteral(MEMO_CACHE_SENTINEL)]
|
129640
129859
|
)
|
129641
129860
|
);
|
129642
129861
|
}
|
@@ -129649,81 +129868,82 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129649
129868
|
loc: null
|
129650
129869
|
}
|
129651
129870
|
);
|
129652
|
-
testCondition =
|
129871
|
+
testCondition = t3.logicalExpression(
|
129653
129872
|
"||",
|
129654
129873
|
testCondition,
|
129655
|
-
|
129874
|
+
t3.booleanLiteral(true)
|
129656
129875
|
);
|
129657
129876
|
}
|
129658
129877
|
let computationBlock = codegenBlock(cx, block);
|
129659
129878
|
let memoStatement;
|
129660
|
-
|
129879
|
+
const detectionFunction = cx.env.config.enableChangeDetectionForDebugging;
|
129880
|
+
if (detectionFunction != null && changeExpressions.length > 0) {
|
129661
129881
|
const loc = typeof scope.loc === "symbol" ? "unknown location" : `(${scope.loc.start.line}:${scope.loc.end.line})`;
|
129662
|
-
const
|
129882
|
+
const importedDetectionFunctionIdentifier = cx.env.programContext.addImportSpecifier(detectionFunction).name;
|
129663
129883
|
const cacheLoadOldValueStatements = [];
|
129664
129884
|
const changeDetectionStatements = [];
|
129665
129885
|
const idempotenceDetectionStatements = [];
|
129666
129886
|
for (const { name, index, value } of cacheLoads) {
|
129667
129887
|
const loadName = cx.synthesizeName(`old$${name.name}`);
|
129668
|
-
const slot =
|
129669
|
-
|
129670
|
-
|
129888
|
+
const slot = t3.memberExpression(
|
129889
|
+
t3.identifier(cx.synthesizeName("$")),
|
129890
|
+
t3.numericLiteral(index),
|
129671
129891
|
true
|
129672
129892
|
);
|
129673
129893
|
cacheStoreStatements.push(
|
129674
|
-
|
129894
|
+
t3.expressionStatement(t3.assignmentExpression("=", slot, value))
|
129675
129895
|
);
|
129676
129896
|
cacheLoadOldValueStatements.push(
|
129677
|
-
|
129678
|
-
|
129897
|
+
t3.variableDeclaration("let", [
|
129898
|
+
t3.variableDeclarator(t3.identifier(loadName), slot)
|
129679
129899
|
])
|
129680
129900
|
);
|
129681
129901
|
changeDetectionStatements.push(
|
129682
|
-
|
129683
|
-
|
129684
|
-
|
129685
|
-
|
129686
|
-
|
129687
|
-
|
129688
|
-
|
129689
|
-
|
129902
|
+
t3.expressionStatement(
|
129903
|
+
t3.callExpression(t3.identifier(importedDetectionFunctionIdentifier), [
|
129904
|
+
t3.identifier(loadName),
|
129905
|
+
t3.cloneNode(name, true),
|
129906
|
+
t3.stringLiteral(name.name),
|
129907
|
+
t3.stringLiteral(cx.fnName),
|
129908
|
+
t3.stringLiteral("cached"),
|
129909
|
+
t3.stringLiteral(loc)
|
129690
129910
|
])
|
129691
129911
|
)
|
129692
129912
|
);
|
129693
129913
|
idempotenceDetectionStatements.push(
|
129694
|
-
|
129695
|
-
|
129696
|
-
|
129697
|
-
|
129698
|
-
|
129699
|
-
|
129700
|
-
|
129701
|
-
|
129914
|
+
t3.expressionStatement(
|
129915
|
+
t3.callExpression(t3.identifier(importedDetectionFunctionIdentifier), [
|
129916
|
+
t3.cloneNode(slot, true),
|
129917
|
+
t3.cloneNode(name, true),
|
129918
|
+
t3.stringLiteral(name.name),
|
129919
|
+
t3.stringLiteral(cx.fnName),
|
129920
|
+
t3.stringLiteral("recomputed"),
|
129921
|
+
t3.stringLiteral(loc)
|
129702
129922
|
])
|
129703
129923
|
)
|
129704
129924
|
);
|
129705
129925
|
idempotenceDetectionStatements.push(
|
129706
|
-
|
129926
|
+
t3.expressionStatement(t3.assignmentExpression("=", name, slot))
|
129707
129927
|
);
|
129708
129928
|
}
|
129709
129929
|
const condition = cx.synthesizeName("condition");
|
129710
|
-
const recomputationBlock =
|
129711
|
-
memoStatement =
|
129930
|
+
const recomputationBlock = t3.cloneNode(computationBlock, true);
|
129931
|
+
memoStatement = t3.blockStatement([
|
129712
129932
|
...computationBlock.body,
|
129713
|
-
|
129714
|
-
|
129933
|
+
t3.variableDeclaration("let", [
|
129934
|
+
t3.variableDeclarator(t3.identifier(condition), testCondition)
|
129715
129935
|
]),
|
129716
|
-
|
129717
|
-
|
129718
|
-
|
129936
|
+
t3.ifStatement(
|
129937
|
+
t3.unaryExpression("!", t3.identifier(condition)),
|
129938
|
+
t3.blockStatement([
|
129719
129939
|
...cacheLoadOldValueStatements,
|
129720
129940
|
...changeDetectionStatements
|
129721
129941
|
])
|
129722
129942
|
),
|
129723
129943
|
...cacheStoreStatements,
|
129724
|
-
|
129725
|
-
|
129726
|
-
|
129944
|
+
t3.ifStatement(
|
129945
|
+
t3.identifier(condition),
|
129946
|
+
t3.blockStatement([
|
129727
129947
|
...recomputationBlock.body,
|
129728
129948
|
...idempotenceDetectionStatements
|
129729
129949
|
])
|
@@ -129732,12 +129952,12 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129732
129952
|
} else {
|
129733
129953
|
for (const { name, index, value } of cacheLoads) {
|
129734
129954
|
cacheStoreStatements.push(
|
129735
|
-
|
129736
|
-
|
129955
|
+
t3.expressionStatement(
|
129956
|
+
t3.assignmentExpression(
|
129737
129957
|
"=",
|
129738
|
-
|
129739
|
-
|
129740
|
-
|
129958
|
+
t3.memberExpression(
|
129959
|
+
t3.identifier(cx.synthesizeName("$")),
|
129960
|
+
t3.numericLiteral(index),
|
129741
129961
|
true
|
129742
129962
|
),
|
129743
129963
|
value
|
@@ -129745,13 +129965,13 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129745
129965
|
)
|
129746
129966
|
);
|
129747
129967
|
cacheLoadStatements.push(
|
129748
|
-
|
129749
|
-
|
129968
|
+
t3.expressionStatement(
|
129969
|
+
t3.assignmentExpression(
|
129750
129970
|
"=",
|
129751
129971
|
name,
|
129752
|
-
|
129753
|
-
|
129754
|
-
|
129972
|
+
t3.memberExpression(
|
129973
|
+
t3.identifier(cx.synthesizeName("$")),
|
129974
|
+
t3.numericLiteral(index),
|
129755
129975
|
true
|
129756
129976
|
)
|
129757
129977
|
)
|
@@ -129759,15 +129979,15 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129759
129979
|
);
|
129760
129980
|
}
|
129761
129981
|
computationBlock.body.push(...cacheStoreStatements);
|
129762
|
-
memoStatement =
|
129982
|
+
memoStatement = t3.ifStatement(
|
129763
129983
|
testCondition,
|
129764
129984
|
computationBlock,
|
129765
|
-
|
129985
|
+
t3.blockStatement(cacheLoadStatements)
|
129766
129986
|
);
|
129767
129987
|
}
|
129768
129988
|
if (cx.env.config.enableMemoizationComments) {
|
129769
129989
|
if (changeExpressionComments.length) {
|
129770
|
-
|
129990
|
+
t3.addComment(
|
129771
129991
|
memoStatement,
|
129772
129992
|
"leading",
|
129773
129993
|
` check if ${printDelimitedCommentList(
|
@@ -129776,20 +129996,20 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129776
129996
|
)} changed`,
|
129777
129997
|
true
|
129778
129998
|
);
|
129779
|
-
|
129999
|
+
t3.addComment(
|
129780
130000
|
memoStatement,
|
129781
130001
|
"leading",
|
129782
130002
|
` "useMemo" for ${printDelimitedCommentList(outputComments, "and")}:`,
|
129783
130003
|
true
|
129784
130004
|
);
|
129785
130005
|
} else {
|
129786
|
-
|
130006
|
+
t3.addComment(
|
129787
130007
|
memoStatement,
|
129788
130008
|
"leading",
|
129789
130009
|
" cache value with no dependencies",
|
129790
130010
|
true
|
129791
130011
|
);
|
129792
|
-
|
130012
|
+
t3.addComment(
|
129793
130013
|
memoStatement,
|
129794
130014
|
"leading",
|
129795
130015
|
` "useMemo" for ${printDelimitedCommentList(outputComments, "and")}:`,
|
@@ -129797,7 +130017,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129797
130017
|
);
|
129798
130018
|
}
|
129799
130019
|
if (computationBlock.body.length > 0) {
|
129800
|
-
|
130020
|
+
t3.addComment(
|
129801
130021
|
computationBlock.body[0],
|
129802
130022
|
"leading",
|
129803
130023
|
` Inputs changed, recompute`,
|
@@ -129805,7 +130025,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129805
130025
|
);
|
129806
130026
|
}
|
129807
130027
|
if (cacheLoadStatements.length > 0) {
|
129808
|
-
|
130028
|
+
t3.addComment(
|
129809
130029
|
cacheLoadStatements[0],
|
129810
130030
|
"leading",
|
129811
130031
|
` Inputs did not change, use cached value`,
|
@@ -129827,16 +130047,16 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129827
130047
|
);
|
129828
130048
|
const name = earlyReturnValue.value.name.value;
|
129829
130049
|
statements.push(
|
129830
|
-
|
129831
|
-
|
130050
|
+
t3.ifStatement(
|
130051
|
+
t3.binaryExpression(
|
129832
130052
|
"!==",
|
129833
|
-
|
129834
|
-
|
129835
|
-
|
129836
|
-
[
|
130053
|
+
t3.identifier(name),
|
130054
|
+
t3.callExpression(
|
130055
|
+
t3.memberExpression(t3.identifier("Symbol"), t3.identifier("for")),
|
130056
|
+
[t3.stringLiteral(EARLY_RETURN_SENTINEL)]
|
129837
130057
|
)
|
129838
130058
|
),
|
129839
|
-
|
130059
|
+
t3.blockStatement([t3.returnStatement(t3.identifier(name))])
|
129840
130060
|
)
|
129841
130061
|
);
|
129842
130062
|
}
|
@@ -129847,20 +130067,20 @@ function codegenTerminal(cx, terminal) {
|
|
129847
130067
|
if (terminal.targetKind === "implicit") {
|
129848
130068
|
return null;
|
129849
130069
|
}
|
129850
|
-
return
|
129851
|
-
terminal.targetKind === "labeled" ?
|
130070
|
+
return t3.breakStatement(
|
130071
|
+
terminal.targetKind === "labeled" ? t3.identifier(codegenLabel(terminal.target)) : null
|
129852
130072
|
);
|
129853
130073
|
}
|
129854
130074
|
case "continue": {
|
129855
130075
|
if (terminal.targetKind === "implicit") {
|
129856
130076
|
return null;
|
129857
130077
|
}
|
129858
|
-
return
|
129859
|
-
terminal.targetKind === "labeled" ?
|
130078
|
+
return t3.continueStatement(
|
130079
|
+
terminal.targetKind === "labeled" ? t3.identifier(codegenLabel(terminal.target)) : null
|
129860
130080
|
);
|
129861
130081
|
}
|
129862
130082
|
case "for": {
|
129863
|
-
return
|
130083
|
+
return t3.forStatement(
|
129864
130084
|
codegenForInit(cx, terminal.init),
|
129865
130085
|
codegenInstructionValueToExpression(cx, terminal.test),
|
129866
130086
|
terminal.update !== null ? codegenInstructionValueToExpression(cx, terminal.update) : null,
|
@@ -129934,13 +130154,13 @@ function codegenTerminal(cx, terminal) {
|
|
129934
130154
|
`Unhandled lvalue kind: ${iterableItem.value.lvalue.kind}`
|
129935
130155
|
);
|
129936
130156
|
}
|
129937
|
-
return
|
130157
|
+
return t3.forInStatement(
|
129938
130158
|
/*
|
129939
130159
|
* Special handling here since we only want the VariableDeclarators without any inits
|
129940
130160
|
* This needs to be updated when we handle non-trivial ForOf inits
|
129941
130161
|
*/
|
129942
130162
|
createVariableDeclaration(iterableItem.value.loc, varDeclKind, [
|
129943
|
-
|
130163
|
+
t3.variableDeclarator(lval, null)
|
129944
130164
|
]),
|
129945
130165
|
codegenInstructionValueToExpression(cx, iterableCollection.value),
|
129946
130166
|
codegenBlock(cx, terminal.loop)
|
@@ -130016,13 +130236,13 @@ function codegenTerminal(cx, terminal) {
|
|
130016
130236
|
`Unhandled lvalue kind: ${iterableItem.value.lvalue.kind}`
|
130017
130237
|
);
|
130018
130238
|
}
|
130019
|
-
return
|
130239
|
+
return t3.forOfStatement(
|
130020
130240
|
/*
|
130021
130241
|
* Special handling here since we only want the VariableDeclarators without any inits
|
130022
130242
|
* This needs to be updated when we handle non-trivial ForOf inits
|
130023
130243
|
*/
|
130024
130244
|
createVariableDeclaration(iterableItem.value.loc, varDeclKind, [
|
130025
|
-
|
130245
|
+
t3.variableDeclarator(lval, null)
|
130026
130246
|
]),
|
130027
130247
|
codegenInstructionValueToExpression(cx, iterableCollection),
|
130028
130248
|
codegenBlock(cx, terminal.loop)
|
@@ -130038,35 +130258,35 @@ function codegenTerminal(cx, terminal) {
|
|
130038
130258
|
alternate = block;
|
130039
130259
|
}
|
130040
130260
|
}
|
130041
|
-
return
|
130261
|
+
return t3.ifStatement(test, consequent, alternate);
|
130042
130262
|
}
|
130043
130263
|
case "return": {
|
130044
130264
|
const value = codegenPlaceToExpression(cx, terminal.value);
|
130045
130265
|
if (value.type === "Identifier" && value.name === "undefined") {
|
130046
|
-
return
|
130266
|
+
return t3.returnStatement();
|
130047
130267
|
}
|
130048
|
-
return
|
130268
|
+
return t3.returnStatement(value);
|
130049
130269
|
}
|
130050
130270
|
case "switch": {
|
130051
|
-
return
|
130271
|
+
return t3.switchStatement(
|
130052
130272
|
codegenPlaceToExpression(cx, terminal.test),
|
130053
130273
|
terminal.cases.map((case_) => {
|
130054
130274
|
const test = case_.test !== null ? codegenPlaceToExpression(cx, case_.test) : null;
|
130055
130275
|
const block = codegenBlock(cx, case_.block);
|
130056
|
-
return
|
130276
|
+
return t3.switchCase(test, [block]);
|
130057
130277
|
})
|
130058
130278
|
);
|
130059
130279
|
}
|
130060
130280
|
case "throw": {
|
130061
|
-
return
|
130281
|
+
return t3.throwStatement(codegenPlaceToExpression(cx, terminal.value));
|
130062
130282
|
}
|
130063
130283
|
case "do-while": {
|
130064
130284
|
const test = codegenInstructionValueToExpression(cx, terminal.test);
|
130065
|
-
return
|
130285
|
+
return t3.doWhileStatement(test, codegenBlock(cx, terminal.loop));
|
130066
130286
|
}
|
130067
130287
|
case "while": {
|
130068
130288
|
const test = codegenInstructionValueToExpression(cx, terminal.test);
|
130069
|
-
return
|
130289
|
+
return t3.whileStatement(test, codegenBlock(cx, terminal.loop));
|
130070
130290
|
}
|
130071
130291
|
case "label": {
|
130072
130292
|
return codegenBlock(cx, terminal.block);
|
@@ -130077,9 +130297,9 @@ function codegenTerminal(cx, terminal) {
|
|
130077
130297
|
catchParam = convertIdentifier(terminal.handlerBinding.identifier);
|
130078
130298
|
cx.temp.set(terminal.handlerBinding.identifier.declarationId, null);
|
130079
130299
|
}
|
130080
|
-
return
|
130300
|
+
return t3.tryStatement(
|
130081
130301
|
codegenBlock(cx, terminal.block),
|
130082
|
-
|
130302
|
+
t3.catchClause(catchParam, codegenBlock(cx, terminal.handler))
|
130083
130303
|
);
|
130084
130304
|
}
|
130085
130305
|
default: {
|
@@ -130142,7 +130362,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130142
130362
|
suggestions: null
|
130143
130363
|
});
|
130144
130364
|
return createVariableDeclaration(instr.loc, "const", [
|
130145
|
-
|
130365
|
+
t3.variableDeclarator(codegenLValue(cx, lvalue), value)
|
130146
130366
|
]);
|
130147
130367
|
}
|
130148
130368
|
case "Function" /* Function */: {
|
@@ -130182,7 +130402,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130182
130402
|
suggestions: null
|
130183
130403
|
});
|
130184
130404
|
return createVariableDeclaration(instr.loc, "let", [
|
130185
|
-
|
130405
|
+
t3.variableDeclarator(codegenLValue(cx, lvalue), value)
|
130186
130406
|
]);
|
130187
130407
|
}
|
130188
130408
|
case "Reassign" /* Reassign */: {
|
@@ -130192,7 +130412,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130192
130412
|
loc: instr.value.loc,
|
130193
130413
|
suggestions: null
|
130194
130414
|
});
|
130195
|
-
const expr =
|
130415
|
+
const expr = t3.assignmentExpression(
|
130196
130416
|
"=",
|
130197
130417
|
codegenLValue(cx, lvalue),
|
130198
130418
|
value
|
@@ -130213,7 +130433,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130213
130433
|
}
|
130214
130434
|
}
|
130215
130435
|
case "Catch" /* Catch */: {
|
130216
|
-
return
|
130436
|
+
return t3.emptyStatement();
|
130217
130437
|
}
|
130218
130438
|
case "HoistedLet" /* HoistedLet */:
|
130219
130439
|
case "HoistedConst" /* HoistedConst */:
|
@@ -130232,7 +130452,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130232
130452
|
} else if (instr.value.kind === "StartMemoize" || instr.value.kind === "FinishMemoize") {
|
130233
130453
|
return null;
|
130234
130454
|
} else if (instr.value.kind === "Debugger") {
|
130235
|
-
return
|
130455
|
+
return t3.debuggerStatement();
|
130236
130456
|
} else if (instr.value.kind === "ObjectMethod") {
|
130237
130457
|
CompilerError.invariant(instr.lvalue, {
|
130238
130458
|
reason: "Expected object methods to have a temp lvalue",
|
@@ -130288,7 +130508,7 @@ function codegenForInit(cx, init) {
|
|
130288
130508
|
description: null,
|
130289
130509
|
suggestions: null
|
130290
130510
|
});
|
130291
|
-
return
|
130511
|
+
return t3.variableDeclaration(kind, declarators);
|
130292
130512
|
} else {
|
130293
130513
|
return codegenInstructionValueToExpression(cx, init);
|
130294
130514
|
}
|
@@ -130327,17 +130547,17 @@ function codegenDependency(cx, dependency) {
|
|
130327
130547
|
if (dependency.path.length !== 0) {
|
130328
130548
|
const hasOptional = dependency.path.some((path) => path.optional);
|
130329
130549
|
for (const path of dependency.path) {
|
130330
|
-
const property = typeof path.property === "string" ?
|
130550
|
+
const property = typeof path.property === "string" ? t3.identifier(path.property) : t3.numericLiteral(path.property);
|
130331
130551
|
const isComputed = typeof path.property !== "string";
|
130332
130552
|
if (hasOptional) {
|
130333
|
-
object =
|
130553
|
+
object = t3.optionalMemberExpression(
|
130334
130554
|
object,
|
130335
130555
|
property,
|
130336
130556
|
isComputed,
|
130337
130557
|
path.optional
|
130338
130558
|
);
|
130339
130559
|
} else {
|
130340
|
-
object =
|
130560
|
+
object = t3.memberExpression(object, property, isComputed);
|
130341
130561
|
}
|
130342
130562
|
}
|
130343
130563
|
}
|
@@ -130352,60 +130572,60 @@ function withLoc(fn) {
|
|
130352
130572
|
return node;
|
130353
130573
|
};
|
130354
130574
|
}
|
130355
|
-
var createBinaryExpression = withLoc(
|
130356
|
-
var createExpressionStatement = withLoc(
|
130357
|
-
var _createLabelledStatement = withLoc(
|
130358
|
-
var createVariableDeclaration = withLoc(
|
130359
|
-
var createFunctionDeclaration = withLoc(
|
130360
|
-
var _createWhileStatement = withLoc(
|
130361
|
-
var createTaggedTemplateExpression = withLoc(
|
130362
|
-
var createLogicalExpression = withLoc(
|
130363
|
-
var createSequenceExpression = withLoc(
|
130364
|
-
var createConditionalExpression = withLoc(
|
130365
|
-
var createTemplateLiteral = withLoc(
|
130366
|
-
var createJsxNamespacedName = withLoc(
|
130367
|
-
var createJsxElement = withLoc(
|
130368
|
-
var createJsxAttribute = withLoc(
|
130369
|
-
var createJsxIdentifier = withLoc(
|
130370
|
-
var createJsxExpressionContainer = withLoc(
|
130371
|
-
var createJsxText = withLoc(
|
130372
|
-
var createJsxClosingElement = withLoc(
|
130373
|
-
var createJsxOpeningElement = withLoc(
|
130374
|
-
var createStringLiteral = withLoc(
|
130375
|
-
function createHookGuard(guard, stmts, before, after) {
|
130575
|
+
var createBinaryExpression = withLoc(t3.binaryExpression);
|
130576
|
+
var createExpressionStatement = withLoc(t3.expressionStatement);
|
130577
|
+
var _createLabelledStatement = withLoc(t3.labeledStatement);
|
130578
|
+
var createVariableDeclaration = withLoc(t3.variableDeclaration);
|
130579
|
+
var createFunctionDeclaration = withLoc(t3.functionDeclaration);
|
130580
|
+
var _createWhileStatement = withLoc(t3.whileStatement);
|
130581
|
+
var createTaggedTemplateExpression = withLoc(t3.taggedTemplateExpression);
|
130582
|
+
var createLogicalExpression = withLoc(t3.logicalExpression);
|
130583
|
+
var createSequenceExpression = withLoc(t3.sequenceExpression);
|
130584
|
+
var createConditionalExpression = withLoc(t3.conditionalExpression);
|
130585
|
+
var createTemplateLiteral = withLoc(t3.templateLiteral);
|
130586
|
+
var createJsxNamespacedName = withLoc(t3.jsxNamespacedName);
|
130587
|
+
var createJsxElement = withLoc(t3.jsxElement);
|
130588
|
+
var createJsxAttribute = withLoc(t3.jsxAttribute);
|
130589
|
+
var createJsxIdentifier = withLoc(t3.jsxIdentifier);
|
130590
|
+
var createJsxExpressionContainer = withLoc(t3.jsxExpressionContainer);
|
130591
|
+
var createJsxText = withLoc(t3.jsxText);
|
130592
|
+
var createJsxClosingElement = withLoc(t3.jsxClosingElement);
|
130593
|
+
var createJsxOpeningElement = withLoc(t3.jsxOpeningElement);
|
130594
|
+
var createStringLiteral = withLoc(t3.stringLiteral);
|
130595
|
+
function createHookGuard(guard, context, stmts, before, after) {
|
130596
|
+
const guardFnName = context.addImportSpecifier(guard).name;
|
130376
130597
|
function createHookGuardImpl(kind) {
|
130377
|
-
return
|
130378
|
-
|
130379
|
-
t4.numericLiteral(kind)
|
130380
|
-
])
|
130598
|
+
return t3.expressionStatement(
|
130599
|
+
t3.callExpression(t3.identifier(guardFnName), [t3.numericLiteral(kind)])
|
130381
130600
|
);
|
130382
130601
|
}
|
130383
|
-
return
|
130384
|
-
|
130602
|
+
return t3.tryStatement(
|
130603
|
+
t3.blockStatement([createHookGuardImpl(before), ...stmts]),
|
130385
130604
|
null,
|
130386
|
-
|
130605
|
+
t3.blockStatement([createHookGuardImpl(after)])
|
130387
130606
|
);
|
130388
130607
|
}
|
130389
130608
|
function createCallExpression(env, callee, args, loc, isHook2) {
|
130390
|
-
const callExpr =
|
130609
|
+
const callExpr = t3.callExpression(callee, args);
|
130391
130610
|
if (loc != null && loc != GeneratedSource) {
|
130392
130611
|
callExpr.loc = loc;
|
130393
130612
|
}
|
130394
130613
|
const hookGuard = env.config.enableEmitHookGuards;
|
130395
130614
|
if (hookGuard != null && isHook2 && env.isInferredMemoEnabled) {
|
130396
|
-
const iife =
|
130615
|
+
const iife = t3.functionExpression(
|
130397
130616
|
null,
|
130398
130617
|
[],
|
130399
|
-
|
130618
|
+
t3.blockStatement([
|
130400
130619
|
createHookGuard(
|
130401
130620
|
hookGuard,
|
130402
|
-
|
130621
|
+
env.programContext,
|
130622
|
+
[t3.returnStatement(callExpr)],
|
130403
130623
|
2 /* AllowHook */,
|
130404
130624
|
3 /* DisallowHook */
|
130405
130625
|
)
|
130406
130626
|
])
|
130407
130627
|
);
|
130408
|
-
return
|
130628
|
+
return t3.callExpression(iife, []);
|
130409
130629
|
} else {
|
130410
130630
|
return callExpr;
|
130411
130631
|
}
|
@@ -130414,21 +130634,21 @@ function codegenLabel(id) {
|
|
130414
130634
|
return `bb${id}`;
|
130415
130635
|
}
|
130416
130636
|
function codegenInstruction(cx, instr, value) {
|
130417
|
-
if (
|
130637
|
+
if (t3.isStatement(value)) {
|
130418
130638
|
return value;
|
130419
130639
|
}
|
130420
130640
|
if (instr.lvalue === null) {
|
130421
|
-
return
|
130641
|
+
return t3.expressionStatement(convertValueToExpression(value));
|
130422
130642
|
}
|
130423
130643
|
if (instr.lvalue.identifier.name === null) {
|
130424
130644
|
cx.temp.set(instr.lvalue.identifier.declarationId, value);
|
130425
|
-
return
|
130645
|
+
return t3.emptyStatement();
|
130426
130646
|
} else {
|
130427
130647
|
const expressionValue = convertValueToExpression(value);
|
130428
130648
|
if (cx.hasDeclared(instr.lvalue.identifier)) {
|
130429
130649
|
return createExpressionStatement(
|
130430
130650
|
instr.loc,
|
130431
|
-
|
130651
|
+
t3.assignmentExpression(
|
130432
130652
|
"=",
|
130433
130653
|
convertIdentifier(instr.lvalue.identifier),
|
130434
130654
|
expressionValue
|
@@ -130436,7 +130656,7 @@ function codegenInstruction(cx, instr, value) {
|
|
130436
130656
|
);
|
130437
130657
|
} else {
|
130438
130658
|
return createVariableDeclaration(instr.loc, "const", [
|
130439
|
-
|
130659
|
+
t3.variableDeclarator(
|
130440
130660
|
convertIdentifier(instr.lvalue.identifier),
|
130441
130661
|
expressionValue
|
130442
130662
|
)
|
@@ -130463,12 +130683,12 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130463
130683
|
if (element.kind === "Identifier") {
|
130464
130684
|
return codegenPlaceToExpression(cx, element);
|
130465
130685
|
} else if (element.kind === "Spread") {
|
130466
|
-
return
|
130686
|
+
return t3.spreadElement(codegenPlaceToExpression(cx, element.place));
|
130467
130687
|
} else {
|
130468
130688
|
return null;
|
130469
130689
|
}
|
130470
130690
|
});
|
130471
|
-
value =
|
130691
|
+
value = t3.arrayExpression(elements);
|
130472
130692
|
break;
|
130473
130693
|
}
|
130474
130694
|
case "BinaryExpression": {
|
@@ -130483,7 +130703,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130483
130703
|
break;
|
130484
130704
|
}
|
130485
130705
|
case "UnaryExpression": {
|
130486
|
-
value =
|
130706
|
+
value = t3.unaryExpression(
|
130487
130707
|
instrValue.operator,
|
130488
130708
|
// todo
|
130489
130709
|
codegenPlaceToExpression(cx, instrValue.value)
|
@@ -130498,9 +130718,9 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130498
130718
|
if (cx.env.config.enableForest) {
|
130499
130719
|
const callee2 = codegenPlaceToExpression(cx, instrValue.callee);
|
130500
130720
|
const args2 = instrValue.args.map((arg) => codegenArgument(cx, arg));
|
130501
|
-
value =
|
130721
|
+
value = t3.callExpression(callee2, args2);
|
130502
130722
|
if (instrValue.typeArguments != null) {
|
130503
|
-
value.typeArguments =
|
130723
|
+
value.typeArguments = t3.typeParameterInstantiation(
|
130504
130724
|
instrValue.typeArguments
|
130505
130725
|
);
|
130506
130726
|
}
|
@@ -130526,13 +130746,13 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130526
130746
|
switch (optionalValue.type) {
|
130527
130747
|
case "OptionalCallExpression":
|
130528
130748
|
case "CallExpression": {
|
130529
|
-
CompilerError.invariant(
|
130749
|
+
CompilerError.invariant(t3.isExpression(optionalValue.callee), {
|
130530
130750
|
reason: "v8 intrinsics are validated during lowering",
|
130531
130751
|
description: null,
|
130532
130752
|
loc: (_a = optionalValue.callee.loc) != null ? _a : null,
|
130533
130753
|
suggestions: null
|
130534
130754
|
});
|
130535
|
-
value =
|
130755
|
+
value = t3.optionalCallExpression(
|
130536
130756
|
optionalValue.callee,
|
130537
130757
|
optionalValue.arguments,
|
130538
130758
|
instrValue.optional
|
@@ -130542,13 +130762,13 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130542
130762
|
case "OptionalMemberExpression":
|
130543
130763
|
case "MemberExpression": {
|
130544
130764
|
const property = optionalValue.property;
|
130545
|
-
CompilerError.invariant(
|
130765
|
+
CompilerError.invariant(t3.isExpression(property), {
|
130546
130766
|
reason: "Private names are validated during lowering",
|
130547
130767
|
description: null,
|
130548
130768
|
loc: (_b = property.loc) != null ? _b : null,
|
130549
130769
|
suggestions: null
|
130550
130770
|
});
|
130551
|
-
value =
|
130771
|
+
value = t3.optionalMemberExpression(
|
130552
130772
|
optionalValue.object,
|
130553
130773
|
property,
|
130554
130774
|
optionalValue.computed,
|
@@ -130571,7 +130791,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130571
130791
|
const isHook2 = getHookKind(cx.env, instrValue.property.identifier) != null;
|
130572
130792
|
const memberExpr = codegenPlaceToExpression(cx, instrValue.property);
|
130573
130793
|
CompilerError.invariant(
|
130574
|
-
|
130794
|
+
t3.isMemberExpression(memberExpr) || t3.isOptionalMemberExpression(memberExpr),
|
130575
130795
|
{
|
130576
130796
|
reason: `[Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a \`${memberExpr.type}\``,
|
130577
130797
|
description: null,
|
@@ -130580,7 +130800,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130580
130800
|
}
|
130581
130801
|
);
|
130582
130802
|
CompilerError.invariant(
|
130583
|
-
|
130803
|
+
t3.isNodesEquivalent(
|
130584
130804
|
memberExpr.object,
|
130585
130805
|
codegenPlaceToExpression(cx, instrValue.receiver)
|
130586
130806
|
),
|
@@ -130604,7 +130824,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130604
130824
|
case "NewExpression": {
|
130605
130825
|
const callee = codegenPlaceToExpression(cx, instrValue.callee);
|
130606
130826
|
const args = instrValue.args.map((arg) => codegenArgument(cx, arg));
|
130607
|
-
value =
|
130827
|
+
value = t3.newExpression(callee, args);
|
130608
130828
|
break;
|
130609
130829
|
}
|
130610
130830
|
case "ObjectExpression": {
|
@@ -130616,7 +130836,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130616
130836
|
case "property": {
|
130617
130837
|
const value2 = codegenPlaceToExpression(cx, property.place);
|
130618
130838
|
properties.push(
|
130619
|
-
|
130839
|
+
t3.objectProperty(
|
130620
130840
|
key2,
|
130621
130841
|
value2,
|
130622
130842
|
property.key.kind === "computed",
|
@@ -130646,7 +130866,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130646
130866
|
),
|
130647
130867
|
reactiveFunction
|
130648
130868
|
).unwrap();
|
130649
|
-
const babelNode =
|
130869
|
+
const babelNode = t3.objectMethod(
|
130650
130870
|
"method",
|
130651
130871
|
key2,
|
130652
130872
|
fn.params,
|
@@ -130666,11 +130886,11 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130666
130886
|
}
|
130667
130887
|
} else {
|
130668
130888
|
properties.push(
|
130669
|
-
|
130889
|
+
t3.spreadElement(codegenPlaceToExpression(cx, property.place))
|
130670
130890
|
);
|
130671
130891
|
}
|
130672
130892
|
}
|
130673
|
-
value =
|
130893
|
+
value = t3.objectExpression(properties);
|
130674
130894
|
break;
|
130675
130895
|
}
|
130676
130896
|
case "JSXText": {
|
@@ -130682,7 +130902,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130682
130902
|
for (const attribute of instrValue.props) {
|
130683
130903
|
attributes.push(codegenJsxAttribute(cx, attribute));
|
130684
130904
|
}
|
130685
|
-
let tagValue = instrValue.tag.kind === "Identifier" ? codegenPlaceToExpression(cx, instrValue.tag) :
|
130905
|
+
let tagValue = instrValue.tag.kind === "Identifier" ? codegenPlaceToExpression(cx, instrValue.tag) : t3.stringLiteral(instrValue.tag.name);
|
130686
130906
|
let tag;
|
130687
130907
|
if (tagValue.type === "Identifier") {
|
130688
130908
|
tag = createJsxIdentifier(instrValue.tag.loc, tagValue.name);
|
@@ -130735,16 +130955,16 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130735
130955
|
break;
|
130736
130956
|
}
|
130737
130957
|
case "JsxFragment": {
|
130738
|
-
value =
|
130739
|
-
|
130740
|
-
|
130958
|
+
value = t3.jsxFragment(
|
130959
|
+
t3.jsxOpeningFragment(),
|
130960
|
+
t3.jsxClosingFragment(),
|
130741
130961
|
instrValue.children.map((child) => codegenJsxElement(cx, child))
|
130742
130962
|
);
|
130743
130963
|
break;
|
130744
130964
|
}
|
130745
130965
|
case "UnsupportedNode": {
|
130746
130966
|
const node = instrValue.node;
|
130747
|
-
if (!
|
130967
|
+
if (!t3.isExpression(node)) {
|
130748
130968
|
return node;
|
130749
130969
|
}
|
130750
130970
|
value = node;
|
@@ -130755,19 +130975,19 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130755
130975
|
case "PropertyDelete": {
|
130756
130976
|
let memberExpr;
|
130757
130977
|
if (typeof instrValue.property === "string") {
|
130758
|
-
memberExpr =
|
130978
|
+
memberExpr = t3.memberExpression(
|
130759
130979
|
codegenPlaceToExpression(cx, instrValue.object),
|
130760
|
-
|
130980
|
+
t3.identifier(instrValue.property)
|
130761
130981
|
);
|
130762
130982
|
} else {
|
130763
|
-
memberExpr =
|
130983
|
+
memberExpr = t3.memberExpression(
|
130764
130984
|
codegenPlaceToExpression(cx, instrValue.object),
|
130765
|
-
|
130985
|
+
t3.numericLiteral(instrValue.property),
|
130766
130986
|
true
|
130767
130987
|
);
|
130768
130988
|
}
|
130769
130989
|
if (instrValue.kind === "PropertyStore") {
|
130770
|
-
value =
|
130990
|
+
value = t3.assignmentExpression(
|
130771
130991
|
"=",
|
130772
130992
|
memberExpr,
|
130773
130993
|
codegenPlaceToExpression(cx, instrValue.value)
|
@@ -130775,14 +130995,14 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130775
130995
|
} else if (instrValue.kind === "PropertyLoad") {
|
130776
130996
|
value = memberExpr;
|
130777
130997
|
} else {
|
130778
|
-
value =
|
130998
|
+
value = t3.unaryExpression("delete", memberExpr);
|
130779
130999
|
}
|
130780
131000
|
break;
|
130781
131001
|
}
|
130782
131002
|
case "ComputedStore": {
|
130783
|
-
value =
|
131003
|
+
value = t3.assignmentExpression(
|
130784
131004
|
"=",
|
130785
|
-
|
131005
|
+
t3.memberExpression(
|
130786
131006
|
codegenPlaceToExpression(cx, instrValue.object),
|
130787
131007
|
codegenPlaceToExpression(cx, instrValue.property),
|
130788
131008
|
true
|
@@ -130794,13 +131014,13 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130794
131014
|
case "ComputedLoad": {
|
130795
131015
|
const object = codegenPlaceToExpression(cx, instrValue.object);
|
130796
131016
|
const property = codegenPlaceToExpression(cx, instrValue.property);
|
130797
|
-
value =
|
131017
|
+
value = t3.memberExpression(object, property, true);
|
130798
131018
|
break;
|
130799
131019
|
}
|
130800
131020
|
case "ComputedDelete": {
|
130801
|
-
value =
|
131021
|
+
value = t3.unaryExpression(
|
130802
131022
|
"delete",
|
130803
|
-
|
131023
|
+
t3.memberExpression(
|
130804
131024
|
codegenPlaceToExpression(cx, instrValue.object),
|
130805
131025
|
codegenPlaceToExpression(cx, instrValue.property),
|
130806
131026
|
true
|
@@ -130837,10 +131057,10 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130837
131057
|
body = stmt.argument;
|
130838
131058
|
}
|
130839
131059
|
}
|
130840
|
-
value =
|
131060
|
+
value = t3.arrowFunctionExpression(fn.params, body, fn.async);
|
130841
131061
|
} else {
|
130842
|
-
value =
|
130843
|
-
(_h = fn.id) != null ? _h : instrValue.name != null ?
|
131062
|
+
value = t3.functionExpression(
|
131063
|
+
(_h = fn.id) != null ? _h : instrValue.name != null ? t3.identifier(instrValue.name) : null,
|
130844
131064
|
fn.params,
|
130845
131065
|
fn.body,
|
130846
131066
|
fn.generator,
|
@@ -130853,20 +131073,20 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130853
131073
|
value = createTaggedTemplateExpression(
|
130854
131074
|
instrValue.loc,
|
130855
131075
|
codegenPlaceToExpression(cx, instrValue.tag),
|
130856
|
-
|
131076
|
+
t3.templateLiteral([t3.templateElement(instrValue.value)], [])
|
130857
131077
|
);
|
130858
131078
|
break;
|
130859
131079
|
}
|
130860
131080
|
case "TypeCastExpression": {
|
130861
|
-
if (
|
130862
|
-
value =
|
131081
|
+
if (t3.isTSType(instrValue.typeAnnotation)) {
|
131082
|
+
value = t3.tsAsExpression(
|
130863
131083
|
codegenPlaceToExpression(cx, instrValue.value),
|
130864
131084
|
instrValue.typeAnnotation
|
130865
131085
|
);
|
130866
131086
|
} else {
|
130867
|
-
value =
|
131087
|
+
value = t3.typeCastExpression(
|
130868
131088
|
codegenPlaceToExpression(cx, instrValue.value),
|
130869
|
-
|
131089
|
+
t3.typeAnnotation(instrValue.typeAnnotation)
|
130870
131090
|
);
|
130871
131091
|
}
|
130872
131092
|
break;
|
@@ -130902,7 +131122,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130902
131122
|
if (stmt.type === "ExpressionStatement") {
|
130903
131123
|
return stmt.expression;
|
130904
131124
|
} else {
|
130905
|
-
if (
|
131125
|
+
if (t3.isVariableDeclaration(stmt)) {
|
130906
131126
|
const declarator = stmt.declarations[0];
|
130907
131127
|
cx.errors.push({
|
130908
131128
|
reason: `(CodegenReactiveFunction::codegenInstructionValue) Cannot declare variables in a value block, tried to declare '${declarator.id.name}'`,
|
@@ -130910,7 +131130,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130910
131130
|
loc: (_a2 = declarator.loc) != null ? _a2 : null,
|
130911
131131
|
suggestions: null
|
130912
131132
|
});
|
130913
|
-
return
|
131133
|
+
return t3.stringLiteral(`TODO handle ${declarator.id}`);
|
130914
131134
|
} else {
|
130915
131135
|
cx.errors.push({
|
130916
131136
|
reason: `(CodegenReactiveFunction::codegenInstructionValue) Handle conversion of ${stmt.type} to expression`,
|
@@ -130918,7 +131138,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130918
131138
|
loc: (_b2 = stmt.loc) != null ? _b2 : null,
|
130919
131139
|
suggestions: null
|
130920
131140
|
});
|
130921
|
-
return
|
131141
|
+
return t3.stringLiteral(`TODO handle ${stmt.type}`);
|
130922
131142
|
}
|
130923
131143
|
}
|
130924
131144
|
});
|
@@ -130935,28 +131155,28 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130935
131155
|
case "TemplateLiteral": {
|
130936
131156
|
value = createTemplateLiteral(
|
130937
131157
|
instrValue.loc,
|
130938
|
-
instrValue.quasis.map((q) =>
|
131158
|
+
instrValue.quasis.map((q) => t3.templateElement(q)),
|
130939
131159
|
instrValue.subexprs.map((p) => codegenPlaceToExpression(cx, p))
|
130940
131160
|
);
|
130941
131161
|
break;
|
130942
131162
|
}
|
130943
131163
|
case "LoadGlobal": {
|
130944
|
-
value =
|
131164
|
+
value = t3.identifier(instrValue.binding.name);
|
130945
131165
|
break;
|
130946
131166
|
}
|
130947
131167
|
case "RegExpLiteral": {
|
130948
|
-
value =
|
131168
|
+
value = t3.regExpLiteral(instrValue.pattern, instrValue.flags);
|
130949
131169
|
break;
|
130950
131170
|
}
|
130951
131171
|
case "MetaProperty": {
|
130952
|
-
value =
|
130953
|
-
|
130954
|
-
|
131172
|
+
value = t3.metaProperty(
|
131173
|
+
t3.identifier(instrValue.meta),
|
131174
|
+
t3.identifier(instrValue.property)
|
130955
131175
|
);
|
130956
131176
|
break;
|
130957
131177
|
}
|
130958
131178
|
case "Await": {
|
130959
|
-
value =
|
131179
|
+
value = t3.awaitExpression(codegenPlaceToExpression(cx, instrValue.value));
|
130960
131180
|
break;
|
130961
131181
|
}
|
130962
131182
|
case "GetIterator": {
|
@@ -130972,7 +131192,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130972
131192
|
break;
|
130973
131193
|
}
|
130974
131194
|
case "PostfixUpdate": {
|
130975
|
-
value =
|
131195
|
+
value = t3.updateExpression(
|
130976
131196
|
instrValue.operation,
|
130977
131197
|
codegenPlaceToExpression(cx, instrValue.lvalue),
|
130978
131198
|
false
|
@@ -130980,7 +131200,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130980
131200
|
break;
|
130981
131201
|
}
|
130982
131202
|
case "PrefixUpdate": {
|
130983
|
-
value =
|
131203
|
+
value = t3.updateExpression(
|
130984
131204
|
instrValue.operation,
|
130985
131205
|
codegenPlaceToExpression(cx, instrValue.lvalue),
|
130986
131206
|
true
|
@@ -130997,7 +131217,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130997
131217
|
suggestions: null
|
130998
131218
|
}
|
130999
131219
|
);
|
131000
|
-
value =
|
131220
|
+
value = t3.assignmentExpression(
|
131001
131221
|
"=",
|
131002
131222
|
codegenLValue(cx, instrValue.lvalue.place),
|
131003
131223
|
codegenPlaceToExpression(cx, instrValue.value)
|
@@ -131005,9 +131225,9 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131005
131225
|
break;
|
131006
131226
|
}
|
131007
131227
|
case "StoreGlobal": {
|
131008
|
-
value =
|
131228
|
+
value = t3.assignmentExpression(
|
131009
131229
|
"=",
|
131010
|
-
|
131230
|
+
t3.identifier(instrValue.name),
|
131011
131231
|
codegenPlaceToExpression(cx, instrValue.value)
|
131012
131232
|
);
|
131013
131233
|
break;
|
@@ -131069,7 +131289,7 @@ function codegenJsxAttribute(cx, attribute) {
|
|
131069
131289
|
return createJsxAttribute(attribute.place.loc, propName, value);
|
131070
131290
|
}
|
131071
131291
|
case "JsxSpreadAttribute": {
|
131072
|
-
return
|
131292
|
+
return t3.jsxSpreadAttribute(
|
131073
131293
|
codegenPlaceToExpression(cx, attribute.argument)
|
131074
131294
|
);
|
131075
131295
|
}
|
@@ -131124,9 +131344,9 @@ function convertMemberExpressionToJsx(expr) {
|
|
131124
131344
|
loc: (_a = expr.loc) != null ? _a : null,
|
131125
131345
|
suggestions: null
|
131126
131346
|
});
|
131127
|
-
const property =
|
131347
|
+
const property = t3.jsxIdentifier(expr.property.name);
|
131128
131348
|
if (expr.object.type === "Identifier") {
|
131129
|
-
return
|
131349
|
+
return t3.jsxMemberExpression(t3.jsxIdentifier(expr.object.name), property);
|
131130
131350
|
} else {
|
131131
131351
|
CompilerError.invariant(expr.object.type === "MemberExpression", {
|
131132
131352
|
reason: "Expected JSX member expression to be an identifier or nested member expression",
|
@@ -131135,20 +131355,20 @@ function convertMemberExpressionToJsx(expr) {
|
|
131135
131355
|
suggestions: null
|
131136
131356
|
});
|
131137
131357
|
const object = convertMemberExpressionToJsx(expr.object);
|
131138
|
-
return
|
131358
|
+
return t3.jsxMemberExpression(object, property);
|
131139
131359
|
}
|
131140
131360
|
}
|
131141
131361
|
function codegenObjectPropertyKey(cx, key2) {
|
131142
131362
|
switch (key2.kind) {
|
131143
131363
|
case "string": {
|
131144
|
-
return
|
131364
|
+
return t3.stringLiteral(key2.name);
|
131145
131365
|
}
|
131146
131366
|
case "identifier": {
|
131147
|
-
return
|
131367
|
+
return t3.identifier(key2.name);
|
131148
131368
|
}
|
131149
131369
|
case "computed": {
|
131150
131370
|
const expr = codegenPlace(cx, key2.name);
|
131151
|
-
CompilerError.invariant(
|
131371
|
+
CompilerError.invariant(t3.isExpression(expr), {
|
131152
131372
|
reason: "Expected object property key to be an expression",
|
131153
131373
|
description: null,
|
131154
131374
|
loc: key2.name.loc,
|
@@ -131157,14 +131377,14 @@ function codegenObjectPropertyKey(cx, key2) {
|
|
131157
131377
|
return expr;
|
131158
131378
|
}
|
131159
131379
|
case "number": {
|
131160
|
-
return
|
131380
|
+
return t3.numericLiteral(key2.name);
|
131161
131381
|
}
|
131162
131382
|
}
|
131163
131383
|
}
|
131164
131384
|
function codegenArrayPattern(cx, pattern) {
|
131165
131385
|
const hasHoles = !pattern.items.every((e) => e.kind !== "Hole");
|
131166
131386
|
if (hasHoles) {
|
131167
|
-
const result =
|
131387
|
+
const result = t3.arrayPattern([]);
|
131168
131388
|
for (const item of pattern.items) {
|
131169
131389
|
if (item.kind === "Hole") {
|
131170
131390
|
result.elements.push(null);
|
@@ -131174,7 +131394,7 @@ function codegenArrayPattern(cx, pattern) {
|
|
131174
131394
|
}
|
131175
131395
|
return result;
|
131176
131396
|
} else {
|
131177
|
-
return
|
131397
|
+
return t3.arrayPattern(
|
131178
131398
|
pattern.items.map((item) => {
|
131179
131399
|
if (item.kind === "Hole") {
|
131180
131400
|
return null;
|
@@ -131190,25 +131410,25 @@ function codegenLValue(cx, pattern) {
|
|
131190
131410
|
return codegenArrayPattern(cx, pattern);
|
131191
131411
|
}
|
131192
131412
|
case "ObjectPattern": {
|
131193
|
-
return
|
131413
|
+
return t3.objectPattern(
|
131194
131414
|
pattern.properties.map((property) => {
|
131195
131415
|
if (property.kind === "ObjectProperty") {
|
131196
131416
|
const key2 = codegenObjectPropertyKey(cx, property.key);
|
131197
131417
|
const value = codegenLValue(cx, property.place);
|
131198
|
-
return
|
131418
|
+
return t3.objectProperty(
|
131199
131419
|
key2,
|
131200
131420
|
value,
|
131201
131421
|
property.key.kind === "computed",
|
131202
131422
|
key2.type === "Identifier" && value.type === "Identifier" && value.name === key2.name
|
131203
131423
|
);
|
131204
131424
|
} else {
|
131205
|
-
return
|
131425
|
+
return t3.restElement(codegenLValue(cx, property.place));
|
131206
131426
|
}
|
131207
131427
|
})
|
131208
131428
|
);
|
131209
131429
|
}
|
131210
131430
|
case "Spread": {
|
131211
|
-
return
|
131431
|
+
return t3.restElement(codegenLValue(cx, pattern.place));
|
131212
131432
|
}
|
131213
131433
|
case "Identifier": {
|
131214
131434
|
return convertIdentifier(pattern.identifier);
|
@@ -131223,15 +131443,15 @@ function codegenLValue(cx, pattern) {
|
|
131223
131443
|
}
|
131224
131444
|
function codegenValue(cx, loc, value) {
|
131225
131445
|
if (typeof value === "number") {
|
131226
|
-
return
|
131446
|
+
return t3.numericLiteral(value);
|
131227
131447
|
} else if (typeof value === "boolean") {
|
131228
|
-
return
|
131448
|
+
return t3.booleanLiteral(value);
|
131229
131449
|
} else if (typeof value === "string") {
|
131230
131450
|
return createStringLiteral(loc, value);
|
131231
131451
|
} else if (value === null) {
|
131232
|
-
return
|
131452
|
+
return t3.nullLiteral();
|
131233
131453
|
} else if (value === void 0) {
|
131234
|
-
return
|
131454
|
+
return t3.identifier("undefined");
|
131235
131455
|
} else {
|
131236
131456
|
assertExhaustive(value, "Unexpected primitive value kind");
|
131237
131457
|
}
|
@@ -131240,7 +131460,7 @@ function codegenArgument(cx, arg) {
|
|
131240
131460
|
if (arg.kind === "Identifier") {
|
131241
131461
|
return codegenPlaceToExpression(cx, arg);
|
131242
131462
|
} else {
|
131243
|
-
return
|
131463
|
+
return t3.spreadElement(codegenPlaceToExpression(cx, arg.place));
|
131244
131464
|
}
|
131245
131465
|
}
|
131246
131466
|
function codegenPlaceToExpression(cx, place) {
|
@@ -131274,7 +131494,7 @@ function convertIdentifier(identifier4) {
|
|
131274
131494
|
suggestions: null
|
131275
131495
|
}
|
131276
131496
|
);
|
131277
|
-
return
|
131497
|
+
return t3.identifier(identifier4.name.value);
|
131278
131498
|
}
|
131279
131499
|
function compareScopeDependency(a, b) {
|
131280
131500
|
var _a, _b;
|
@@ -132618,10 +132838,9 @@ function inferReferenceEffects(fn, options = { isFunctionExpression: false }) {
|
|
132618
132838
|
return transformFunctionEffectErrors(functionEffects);
|
132619
132839
|
}
|
132620
132840
|
}
|
132621
|
-
var
|
132841
|
+
var _values, _variables;
|
132622
132842
|
var _InferenceState = class _InferenceState {
|
132623
132843
|
constructor(env, values, variables) {
|
132624
|
-
__privateAdd(this, _env3);
|
132625
132844
|
// The kind of each value, based on its allocation site
|
132626
132845
|
__privateAdd(this, _values);
|
132627
132846
|
/*
|
@@ -132630,7 +132849,7 @@ var _InferenceState = class _InferenceState {
|
|
132630
132849
|
* values from different control flow paths).
|
132631
132850
|
*/
|
132632
132851
|
__privateAdd(this, _variables);
|
132633
|
-
|
132852
|
+
this.env = env;
|
132634
132853
|
__privateSet(this, _values, values);
|
132635
132854
|
__privateSet(this, _variables, variables);
|
132636
132855
|
}
|
@@ -132742,7 +132961,7 @@ var _InferenceState = class _InferenceState {
|
|
132742
132961
|
reason,
|
132743
132962
|
context: /* @__PURE__ */ new Set()
|
132744
132963
|
});
|
132745
|
-
if (value.kind === "FunctionExpression" && (
|
132964
|
+
if (value.kind === "FunctionExpression" && (this.env.config.enablePreserveExistingMemoizationGuarantees || this.env.config.enableTransitivelyFreezeFunctionExpressions)) {
|
132746
132965
|
for (const operand of value.loweredFunc.func.context) {
|
132747
132966
|
const operandValues = __privateGet(this, _variables).get(operand.identifier.id);
|
132748
132967
|
if (operandValues !== void 0) {
|
@@ -132787,6 +133006,18 @@ var _InferenceState = class _InferenceState {
|
|
132787
133006
|
}
|
132788
133007
|
break;
|
132789
133008
|
}
|
133009
|
+
case "mutate-iterator?" /* ConditionallyMutateIterator */: {
|
133010
|
+
if (valueKind.kind === "mutable" /* Mutable */ || valueKind.kind === "context" /* Context */) {
|
133011
|
+
if (isArrayType(place.identifier) || isSetType(place.identifier) || isMapType(place.identifier)) {
|
133012
|
+
effect = "capture" /* Capture */;
|
133013
|
+
} else {
|
133014
|
+
effect = "mutate?" /* ConditionallyMutate */;
|
133015
|
+
}
|
133016
|
+
} else {
|
133017
|
+
effect = "read" /* Read */;
|
133018
|
+
}
|
133019
|
+
break;
|
133020
|
+
}
|
132790
133021
|
case "mutate" /* Mutate */: {
|
132791
133022
|
effect = "mutate" /* Mutate */;
|
132792
133023
|
break;
|
@@ -132890,7 +133121,7 @@ var _InferenceState = class _InferenceState {
|
|
132890
133121
|
return null;
|
132891
133122
|
} else {
|
132892
133123
|
return new _InferenceState(
|
132893
|
-
|
133124
|
+
this.env,
|
132894
133125
|
nextValues != null ? nextValues : new Map(__privateGet(this, _values)),
|
132895
133126
|
nextVariables != null ? nextVariables : new Map(__privateGet(this, _variables))
|
132896
133127
|
);
|
@@ -132903,7 +133134,7 @@ var _InferenceState = class _InferenceState {
|
|
132903
133134
|
*/
|
132904
133135
|
clone() {
|
132905
133136
|
return new _InferenceState(
|
132906
|
-
|
133137
|
+
this.env,
|
132907
133138
|
new Map(__privateGet(this, _values)),
|
132908
133139
|
new Map(__privateGet(this, _variables))
|
132909
133140
|
);
|
@@ -132946,7 +133177,6 @@ var _InferenceState = class _InferenceState {
|
|
132946
133177
|
}
|
132947
133178
|
}
|
132948
133179
|
};
|
132949
|
-
_env3 = new WeakMap();
|
132950
133180
|
_values = new WeakMap();
|
132951
133181
|
_variables = new WeakMap();
|
132952
133182
|
var InferenceState = _InferenceState;
|
@@ -133030,7 +133260,7 @@ function mergeAbstractValues(a, b) {
|
|
133030
133260
|
return { kind, reason, context };
|
133031
133261
|
}
|
133032
133262
|
function inferBlock(env, state, block, functionEffects) {
|
133033
|
-
var _a, _b, _c
|
133263
|
+
var _a, _b, _c;
|
133034
133264
|
for (const phi of block.phis) {
|
133035
133265
|
state.inferPhi(phi);
|
133036
133266
|
}
|
@@ -133071,7 +133301,7 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133071
133301
|
state.referenceAndRecordEffects(
|
133072
133302
|
freezeActions,
|
133073
133303
|
element.place,
|
133074
|
-
|
133304
|
+
"mutate-iterator?" /* ConditionallyMutateIterator */,
|
133075
133305
|
"other" /* Other */
|
133076
133306
|
);
|
133077
133307
|
} else if (element.kind === "Identifier") {
|
@@ -133094,28 +133324,12 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133094
133324
|
break;
|
133095
133325
|
}
|
133096
133326
|
case "NewExpression": {
|
133097
|
-
|
133098
|
-
|
133099
|
-
|
133100
|
-
context: /* @__PURE__ */ new Set()
|
133101
|
-
};
|
133102
|
-
state.referenceAndRecordEffects(
|
133327
|
+
inferCallEffects(
|
133328
|
+
state,
|
133329
|
+
instr,
|
133103
133330
|
freezeActions,
|
133104
|
-
instrValue.callee
|
133105
|
-
"read" /* Read */,
|
133106
|
-
"other" /* Other */
|
133331
|
+
getFunctionCallSignature(env, instrValue.callee.identifier.type)
|
133107
133332
|
);
|
133108
|
-
for (const operand of eachCallArgument(instrValue.args)) {
|
133109
|
-
state.referenceAndRecordEffects(
|
133110
|
-
freezeActions,
|
133111
|
-
operand,
|
133112
|
-
"mutate?" /* ConditionallyMutate */,
|
133113
|
-
"other" /* Other */
|
133114
|
-
);
|
133115
|
-
}
|
133116
|
-
state.initialize(instrValue, valueKind);
|
133117
|
-
state.define(instr.lvalue, instrValue);
|
133118
|
-
instr.lvalue.effect = "mutate?" /* ConditionallyMutate */;
|
133119
133333
|
continuation = { kind: "funeffects" };
|
133120
133334
|
break;
|
133121
133335
|
}
|
@@ -133388,53 +133602,12 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133388
133602
|
break;
|
133389
133603
|
}
|
133390
133604
|
case "CallExpression": {
|
133391
|
-
|
133392
|
-
|
133393
|
-
|
133605
|
+
inferCallEffects(
|
133606
|
+
state,
|
133607
|
+
instr,
|
133608
|
+
freezeActions,
|
133609
|
+
getFunctionCallSignature(env, instrValue.callee.identifier.type)
|
133394
133610
|
);
|
133395
|
-
const effects = signature !== null ? getFunctionEffects(instrValue, signature) : null;
|
133396
|
-
const returnValueKind = signature !== null ? {
|
133397
|
-
kind: signature.returnValueKind,
|
133398
|
-
reason: /* @__PURE__ */ new Set([
|
133399
|
-
(_c = signature.returnValueReason) != null ? _c : "known-return-signature" /* KnownReturnSignature */
|
133400
|
-
]),
|
133401
|
-
context: /* @__PURE__ */ new Set()
|
133402
|
-
} : {
|
133403
|
-
kind: "mutable" /* Mutable */,
|
133404
|
-
reason: /* @__PURE__ */ new Set(["other" /* Other */]),
|
133405
|
-
context: /* @__PURE__ */ new Set()
|
133406
|
-
};
|
133407
|
-
let hasCaptureArgument = false;
|
133408
|
-
for (let i = 0; i < instrValue.args.length; i++) {
|
133409
|
-
const arg = instrValue.args[i];
|
133410
|
-
const place = arg.kind === "Identifier" ? arg : arg.place;
|
133411
|
-
state.referenceAndRecordEffects(
|
133412
|
-
freezeActions,
|
133413
|
-
place,
|
133414
|
-
getArgumentEffect(effects != null ? effects[i] : null, arg),
|
133415
|
-
"other" /* Other */
|
133416
|
-
);
|
133417
|
-
hasCaptureArgument || (hasCaptureArgument = place.effect === "capture" /* Capture */);
|
133418
|
-
}
|
133419
|
-
if (signature !== null) {
|
133420
|
-
state.referenceAndRecordEffects(
|
133421
|
-
freezeActions,
|
133422
|
-
instrValue.callee,
|
133423
|
-
signature.calleeEffect,
|
133424
|
-
"other" /* Other */
|
133425
|
-
);
|
133426
|
-
} else {
|
133427
|
-
state.referenceAndRecordEffects(
|
133428
|
-
freezeActions,
|
133429
|
-
instrValue.callee,
|
133430
|
-
"mutate?" /* ConditionallyMutate */,
|
133431
|
-
"other" /* Other */
|
133432
|
-
);
|
133433
|
-
}
|
133434
|
-
hasCaptureArgument || (hasCaptureArgument = instrValue.callee.effect === "capture" /* Capture */);
|
133435
|
-
state.initialize(instrValue, returnValueKind);
|
133436
|
-
state.define(instr.lvalue, instrValue);
|
133437
|
-
instr.lvalue.effect = hasCaptureArgument ? "store" /* Store */ : "mutate?" /* ConditionallyMutate */;
|
133438
133611
|
continuation = { kind: "funeffects" };
|
133439
133612
|
break;
|
133440
133613
|
}
|
@@ -133451,75 +133624,12 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133451
133624
|
"read" /* Read */,
|
133452
133625
|
"other" /* Other */
|
133453
133626
|
);
|
133454
|
-
|
133455
|
-
|
133456
|
-
|
133627
|
+
inferCallEffects(
|
133628
|
+
state,
|
133629
|
+
instr,
|
133630
|
+
freezeActions,
|
133631
|
+
getFunctionCallSignature(env, instrValue.property.identifier.type)
|
133457
133632
|
);
|
133458
|
-
const returnValueKind = signature !== null ? {
|
133459
|
-
kind: signature.returnValueKind,
|
133460
|
-
reason: /* @__PURE__ */ new Set([
|
133461
|
-
(_d = signature.returnValueReason) != null ? _d : "known-return-signature" /* KnownReturnSignature */
|
133462
|
-
]),
|
133463
|
-
context: /* @__PURE__ */ new Set()
|
133464
|
-
} : {
|
133465
|
-
kind: "mutable" /* Mutable */,
|
133466
|
-
reason: /* @__PURE__ */ new Set(["other" /* Other */]),
|
133467
|
-
context: /* @__PURE__ */ new Set()
|
133468
|
-
};
|
133469
|
-
if (signature !== null && signature.mutableOnlyIfOperandsAreMutable && areArgumentsImmutableAndNonMutating(state, instrValue.args)) {
|
133470
|
-
for (const arg of instrValue.args) {
|
133471
|
-
const place = arg.kind === "Identifier" ? arg : arg.place;
|
133472
|
-
state.referenceAndRecordEffects(
|
133473
|
-
freezeActions,
|
133474
|
-
place,
|
133475
|
-
"read" /* Read */,
|
133476
|
-
"other" /* Other */
|
133477
|
-
);
|
133478
|
-
}
|
133479
|
-
state.referenceAndRecordEffects(
|
133480
|
-
freezeActions,
|
133481
|
-
instrValue.receiver,
|
133482
|
-
"capture" /* Capture */,
|
133483
|
-
"other" /* Other */
|
133484
|
-
);
|
133485
|
-
state.initialize(instrValue, returnValueKind);
|
133486
|
-
state.define(instr.lvalue, instrValue);
|
133487
|
-
instr.lvalue.effect = instrValue.receiver.effect === "capture" /* Capture */ ? "store" /* Store */ : "mutate?" /* ConditionallyMutate */;
|
133488
|
-
continuation = { kind: "funeffects" };
|
133489
|
-
break;
|
133490
|
-
}
|
133491
|
-
const effects = signature !== null ? getFunctionEffects(instrValue, signature) : null;
|
133492
|
-
let hasCaptureArgument = false;
|
133493
|
-
for (let i = 0; i < instrValue.args.length; i++) {
|
133494
|
-
const arg = instrValue.args[i];
|
133495
|
-
const place = arg.kind === "Identifier" ? arg : arg.place;
|
133496
|
-
state.referenceAndRecordEffects(
|
133497
|
-
freezeActions,
|
133498
|
-
place,
|
133499
|
-
getArgumentEffect(effects != null ? effects[i] : null, arg),
|
133500
|
-
"other" /* Other */
|
133501
|
-
);
|
133502
|
-
hasCaptureArgument || (hasCaptureArgument = place.effect === "capture" /* Capture */);
|
133503
|
-
}
|
133504
|
-
if (signature !== null) {
|
133505
|
-
state.referenceAndRecordEffects(
|
133506
|
-
freezeActions,
|
133507
|
-
instrValue.receiver,
|
133508
|
-
signature.calleeEffect,
|
133509
|
-
"other" /* Other */
|
133510
|
-
);
|
133511
|
-
} else {
|
133512
|
-
state.referenceAndRecordEffects(
|
133513
|
-
freezeActions,
|
133514
|
-
instrValue.receiver,
|
133515
|
-
"mutate?" /* ConditionallyMutate */,
|
133516
|
-
"other" /* Other */
|
133517
|
-
);
|
133518
|
-
}
|
133519
|
-
hasCaptureArgument || (hasCaptureArgument = instrValue.receiver.effect === "capture" /* Capture */);
|
133520
|
-
state.initialize(instrValue, returnValueKind);
|
133521
|
-
state.define(instr.lvalue, instrValue);
|
133522
|
-
instr.lvalue.effect = hasCaptureArgument ? "store" /* Store */ : "mutate?" /* ConditionallyMutate */;
|
133523
133633
|
continuation = { kind: "funeffects" };
|
133524
133634
|
break;
|
133525
133635
|
}
|
@@ -133846,7 +133956,8 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133846
133956
|
const isMutable3 = kind === "mutable" /* Mutable */ || kind === "context" /* Context */;
|
133847
133957
|
let effect;
|
133848
133958
|
let valueKind;
|
133849
|
-
|
133959
|
+
const iterator = instrValue.collection.identifier;
|
133960
|
+
if (!isMutable3 || isArrayType(iterator) || isMapType(iterator) || isSetType(iterator)) {
|
133850
133961
|
effect = {
|
133851
133962
|
kind: "read" /* Read */,
|
133852
133963
|
reason: "other" /* Other */
|
@@ -133875,7 +133986,7 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133875
133986
|
state.referenceAndRecordEffects(
|
133876
133987
|
freezeActions,
|
133877
133988
|
instrValue.iterator,
|
133878
|
-
"mutate?" /*
|
133989
|
+
"mutate-iterator?" /* ConditionallyMutateIterator */,
|
133879
133990
|
"other" /* Other */
|
133880
133991
|
);
|
133881
133992
|
state.referenceAndRecordEffects(
|
@@ -133924,7 +134035,7 @@ function inferBlock(env, state, block, functionEffects) {
|
|
133924
134035
|
}
|
133925
134036
|
state.initialize(instrValue, continuation.valueKind);
|
133926
134037
|
state.define(instr.lvalue, instrValue);
|
133927
|
-
instr.lvalue.effect = (
|
134038
|
+
instr.lvalue.effect = (_c = continuation.lvalueEffect) != null ? _c : defaultLvalueEffect;
|
133928
134039
|
}
|
133929
134040
|
functionEffects.push(...inferInstructionFunctionEffects(env, state, instr));
|
133930
134041
|
freezeActions.forEach(
|
@@ -133988,12 +134099,43 @@ function getFunctionEffects(fn, sig) {
|
|
133988
134099
|
}
|
133989
134100
|
return results;
|
133990
134101
|
}
|
134102
|
+
function isKnownMutableEffect(effect) {
|
134103
|
+
switch (effect) {
|
134104
|
+
case "store" /* Store */:
|
134105
|
+
case "mutate?" /* ConditionallyMutate */:
|
134106
|
+
case "mutate-iterator?" /* ConditionallyMutateIterator */:
|
134107
|
+
case "mutate" /* Mutate */: {
|
134108
|
+
return true;
|
134109
|
+
}
|
134110
|
+
case "<unknown>" /* Unknown */: {
|
134111
|
+
CompilerError.invariant(false, {
|
134112
|
+
reason: "Unexpected unknown effect",
|
134113
|
+
description: null,
|
134114
|
+
loc: GeneratedSource,
|
134115
|
+
suggestions: null
|
134116
|
+
});
|
134117
|
+
}
|
134118
|
+
case "read" /* Read */:
|
134119
|
+
case "capture" /* Capture */:
|
134120
|
+
case "freeze" /* Freeze */: {
|
134121
|
+
return false;
|
134122
|
+
}
|
134123
|
+
default: {
|
134124
|
+
assertExhaustive(effect, `Unexpected effect \`${effect}\``);
|
134125
|
+
}
|
134126
|
+
}
|
134127
|
+
}
|
133991
134128
|
function areArgumentsImmutableAndNonMutating(state, args) {
|
133992
134129
|
for (const arg of args) {
|
134130
|
+
if (arg.kind === "Identifier" && arg.identifier.type.kind === "Function") {
|
134131
|
+
const fnShape = state.env.getFunctionSignature(arg.identifier.type);
|
134132
|
+
if (fnShape != null) {
|
134133
|
+
return !fnShape.positionalParams.some(isKnownMutableEffect) && (fnShape.restParam == null || !isKnownMutableEffect(fnShape.restParam));
|
134134
|
+
}
|
134135
|
+
}
|
133993
134136
|
const place = arg.kind === "Identifier" ? arg : arg.place;
|
133994
134137
|
const kind = state.kind(place).kind;
|
133995
134138
|
switch (kind) {
|
133996
|
-
case "global" /* Global */:
|
133997
134139
|
case "primitive" /* Primitive */:
|
133998
134140
|
case "frozen" /* Frozen */: {
|
133999
134141
|
break;
|
@@ -134028,12 +134170,81 @@ function getArgumentEffect(signatureEffect, arg) {
|
|
134028
134170
|
loc: arg.place.loc
|
134029
134171
|
});
|
134030
134172
|
}
|
134031
|
-
return "mutate?" /*
|
134173
|
+
return "mutate-iterator?" /* ConditionallyMutateIterator */;
|
134032
134174
|
}
|
134033
134175
|
} else {
|
134034
134176
|
return "mutate?" /* ConditionallyMutate */;
|
134035
134177
|
}
|
134036
134178
|
}
|
134179
|
+
function inferCallEffects(state, instr, freezeActions, signature) {
|
134180
|
+
var _a;
|
134181
|
+
const instrValue = instr.value;
|
134182
|
+
const returnValueKind = signature !== null ? {
|
134183
|
+
kind: signature.returnValueKind,
|
134184
|
+
reason: /* @__PURE__ */ new Set([
|
134185
|
+
(_a = signature.returnValueReason) != null ? _a : "known-return-signature" /* KnownReturnSignature */
|
134186
|
+
]),
|
134187
|
+
context: /* @__PURE__ */ new Set()
|
134188
|
+
} : {
|
134189
|
+
kind: "mutable" /* Mutable */,
|
134190
|
+
reason: /* @__PURE__ */ new Set(["other" /* Other */]),
|
134191
|
+
context: /* @__PURE__ */ new Set()
|
134192
|
+
};
|
134193
|
+
if (instrValue.kind === "MethodCall" && signature !== null && signature.mutableOnlyIfOperandsAreMutable && areArgumentsImmutableAndNonMutating(state, instrValue.args)) {
|
134194
|
+
for (const arg of instrValue.args) {
|
134195
|
+
const place = arg.kind === "Identifier" ? arg : arg.place;
|
134196
|
+
state.referenceAndRecordEffects(
|
134197
|
+
freezeActions,
|
134198
|
+
place,
|
134199
|
+
"read" /* Read */,
|
134200
|
+
"other" /* Other */
|
134201
|
+
);
|
134202
|
+
}
|
134203
|
+
state.referenceAndRecordEffects(
|
134204
|
+
freezeActions,
|
134205
|
+
instrValue.receiver,
|
134206
|
+
"capture" /* Capture */,
|
134207
|
+
"other" /* Other */
|
134208
|
+
);
|
134209
|
+
state.initialize(instrValue, returnValueKind);
|
134210
|
+
state.define(instr.lvalue, instrValue);
|
134211
|
+
instr.lvalue.effect = instrValue.receiver.effect === "capture" /* Capture */ ? "store" /* Store */ : "mutate?" /* ConditionallyMutate */;
|
134212
|
+
return;
|
134213
|
+
}
|
134214
|
+
const effects = signature !== null ? getFunctionEffects(instrValue, signature) : null;
|
134215
|
+
let hasCaptureArgument = false;
|
134216
|
+
for (let i = 0; i < instrValue.args.length; i++) {
|
134217
|
+
const arg = instrValue.args[i];
|
134218
|
+
const place = arg.kind === "Identifier" ? arg : arg.place;
|
134219
|
+
state.referenceAndRecordEffects(
|
134220
|
+
freezeActions,
|
134221
|
+
place,
|
134222
|
+
getArgumentEffect(effects != null ? effects[i] : null, arg),
|
134223
|
+
"other" /* Other */
|
134224
|
+
);
|
134225
|
+
hasCaptureArgument || (hasCaptureArgument = place.effect === "capture" /* Capture */);
|
134226
|
+
}
|
134227
|
+
const callee = instrValue.kind === "MethodCall" ? instrValue.receiver : instrValue.callee;
|
134228
|
+
if (signature !== null) {
|
134229
|
+
state.referenceAndRecordEffects(
|
134230
|
+
freezeActions,
|
134231
|
+
callee,
|
134232
|
+
signature.calleeEffect,
|
134233
|
+
"other" /* Other */
|
134234
|
+
);
|
134235
|
+
} else {
|
134236
|
+
state.referenceAndRecordEffects(
|
134237
|
+
freezeActions,
|
134238
|
+
callee,
|
134239
|
+
instrValue.kind === "NewExpression" ? "read" /* Read */ : "mutate?" /* ConditionallyMutate */,
|
134240
|
+
"other" /* Other */
|
134241
|
+
);
|
134242
|
+
}
|
134243
|
+
hasCaptureArgument || (hasCaptureArgument = callee.effect === "capture" /* Capture */);
|
134244
|
+
state.initialize(instrValue, returnValueKind);
|
134245
|
+
state.define(instr.lvalue, instrValue);
|
134246
|
+
instr.lvalue.effect = hasCaptureArgument ? "store" /* Store */ : "mutate?" /* ConditionallyMutate */;
|
134247
|
+
}
|
134037
134248
|
|
134038
134249
|
// src/ReactiveScopes/PruneNonEscapingScopes.ts
|
134039
134250
|
function pruneNonEscapingScopes(fn) {
|
@@ -134929,7 +135140,7 @@ var Visitor7 = class extends ReactiveFunctionVisitor {
|
|
134929
135140
|
// src/ReactiveScopes/RenameVariables.ts
|
134930
135141
|
function renameVariables(fn) {
|
134931
135142
|
const globals = collectReferencedGlobals(fn);
|
134932
|
-
const scopes = new Scopes(globals);
|
135143
|
+
const scopes = new Scopes(globals, fn.env.programContext);
|
134933
135144
|
renameVariablesImpl(fn, new Visitor8(), scopes);
|
134934
135145
|
return /* @__PURE__ */ new Set([...scopes.names, ...globals]);
|
134935
135146
|
}
|
@@ -134979,15 +135190,17 @@ var Visitor8 = class extends ReactiveFunctionVisitor {
|
|
134979
135190
|
renameVariablesImpl(_fn, this, _state);
|
134980
135191
|
}
|
134981
135192
|
};
|
134982
|
-
var _seen, _stack, _globals3, _Scopes_instances, lookup_fn;
|
135193
|
+
var _seen, _stack, _globals3, _programContext, _Scopes_instances, lookup_fn;
|
134983
135194
|
var Scopes = class {
|
134984
|
-
constructor(globals) {
|
135195
|
+
constructor(globals, programContext) {
|
134985
135196
|
__privateAdd(this, _Scopes_instances);
|
134986
135197
|
__privateAdd(this, _seen, /* @__PURE__ */ new Map());
|
134987
135198
|
__privateAdd(this, _stack, [/* @__PURE__ */ new Map()]);
|
134988
135199
|
__privateAdd(this, _globals3);
|
135200
|
+
__privateAdd(this, _programContext);
|
134989
135201
|
this.names = /* @__PURE__ */ new Set();
|
134990
135202
|
__privateSet(this, _globals3, globals);
|
135203
|
+
__privateSet(this, _programContext, programContext);
|
134991
135204
|
}
|
134992
135205
|
visit(identifier4) {
|
134993
135206
|
const originalName = identifier4.name;
|
@@ -135015,6 +135228,7 @@ var Scopes = class {
|
|
135015
135228
|
name = `${originalName.value}$${id++}`;
|
135016
135229
|
}
|
135017
135230
|
}
|
135231
|
+
__privateGet(this, _programContext).addNewReference(name);
|
135018
135232
|
const identifierName = makeIdentifierName(name);
|
135019
135233
|
identifier4.name = identifierName;
|
135020
135234
|
__privateGet(this, _seen).set(identifier4.declarationId, identifierName);
|
@@ -135037,6 +135251,7 @@ var Scopes = class {
|
|
135037
135251
|
_seen = new WeakMap();
|
135038
135252
|
_stack = new WeakMap();
|
135039
135253
|
_globals3 = new WeakMap();
|
135254
|
+
_programContext = new WeakMap();
|
135040
135255
|
_Scopes_instances = new WeakSet();
|
135041
135256
|
lookup_fn = function(name) {
|
135042
135257
|
for (let i = __privateGet(this, _stack).length - 1; i >= 0; i--) {
|
@@ -135220,6 +135435,13 @@ function inferPlace(place, instrId, inferMutableRangeForStores) {
|
|
135220
135435
|
infer(place, instrId);
|
135221
135436
|
}
|
135222
135437
|
return;
|
135438
|
+
case "mutate-iterator?" /* ConditionallyMutateIterator */: {
|
135439
|
+
const identifier4 = place.identifier;
|
135440
|
+
if (!isArrayType(identifier4) && !isSetType(identifier4) && !isMapType(identifier4)) {
|
135441
|
+
infer(place, instrId);
|
135442
|
+
}
|
135443
|
+
return;
|
135444
|
+
}
|
135223
135445
|
case "mutate?" /* ConditionallyMutate */:
|
135224
135446
|
case "mutate" /* Mutate */: {
|
135225
135447
|
infer(place, instrId);
|
@@ -135855,6 +136077,7 @@ function inferReactivePlaces(fn) {
|
|
135855
136077
|
case "capture" /* Capture */:
|
135856
136078
|
case "store" /* Store */:
|
135857
136079
|
case "mutate?" /* ConditionallyMutate */:
|
136080
|
+
case "mutate-iterator?" /* ConditionallyMutateIterator */:
|
135858
136081
|
case "mutate" /* Mutate */: {
|
135859
136082
|
if (isMutable2(instruction, operand)) {
|
135860
136083
|
reactiveIdentifiers.markReactive(operand);
|
@@ -136222,6 +136445,7 @@ function inferEffectDependencies(fn) {
|
|
136222
136445
|
if (hasRewrite) {
|
136223
136446
|
markInstructionIds(fn.body);
|
136224
136447
|
fixScopeAndIdentifierRanges(fn.body);
|
136448
|
+
fn.env.hasInferredEffect = true;
|
136225
136449
|
}
|
136226
136450
|
}
|
136227
136451
|
function writeDependencyToInstructions(dep, reactive, env, loc) {
|
@@ -137310,7 +137534,8 @@ function* generateInstructionTypes(env, names, instr) {
|
|
137310
137534
|
yield equation(value.callee.identifier.type, {
|
137311
137535
|
kind: "Function",
|
137312
137536
|
shapeId: null,
|
137313
|
-
return: returnType
|
137537
|
+
return: returnType,
|
137538
|
+
isConstructor: false
|
137314
137539
|
});
|
137315
137540
|
yield equation(left, returnType);
|
137316
137541
|
break;
|
@@ -137320,7 +137545,8 @@ function* generateInstructionTypes(env, names, instr) {
|
|
137320
137545
|
yield equation(value.tag.identifier.type, {
|
137321
137546
|
kind: "Function",
|
137322
137547
|
shapeId: null,
|
137323
|
-
return: returnType
|
137548
|
+
return: returnType,
|
137549
|
+
isConstructor: false
|
137324
137550
|
});
|
137325
137551
|
yield equation(left, returnType);
|
137326
137552
|
break;
|
@@ -137369,7 +137595,8 @@ function* generateInstructionTypes(env, names, instr) {
|
|
137369
137595
|
yield equation(value.property.identifier.type, {
|
137370
137596
|
kind: "Function",
|
137371
137597
|
return: returnType,
|
137372
|
-
shapeId: null
|
137598
|
+
shapeId: null,
|
137599
|
+
isConstructor: false
|
137373
137600
|
});
|
137374
137601
|
yield equation(left, returnType);
|
137375
137602
|
break;
|
@@ -137432,7 +137659,8 @@ function* generateInstructionTypes(env, names, instr) {
|
|
137432
137659
|
yield equation(left, {
|
137433
137660
|
kind: "Function",
|
137434
137661
|
shapeId: BuiltInFunctionId,
|
137435
|
-
return: value.loweredFunc.func.returnType
|
137662
|
+
return: value.loweredFunc.func.returnType,
|
137663
|
+
isConstructor: false
|
137436
137664
|
});
|
137437
137665
|
break;
|
137438
137666
|
}
|
@@ -137450,9 +137678,19 @@ function* generateInstructionTypes(env, names, instr) {
|
|
137450
137678
|
yield equation(left, { kind: "Object", shapeId: BuiltInJsxId });
|
137451
137679
|
break;
|
137452
137680
|
}
|
137681
|
+
case "NewExpression": {
|
137682
|
+
const returnType = makeType();
|
137683
|
+
yield equation(value.callee.identifier.type, {
|
137684
|
+
kind: "Function",
|
137685
|
+
return: returnType,
|
137686
|
+
shapeId: null,
|
137687
|
+
isConstructor: true
|
137688
|
+
});
|
137689
|
+
yield equation(left, returnType);
|
137690
|
+
break;
|
137691
|
+
}
|
137453
137692
|
case "PropertyStore":
|
137454
137693
|
case "DeclareLocal":
|
137455
|
-
case "NewExpression":
|
137456
137694
|
case "RegExpLiteral":
|
137457
137695
|
case "MetaProperty":
|
137458
137696
|
case "ComputedStore":
|
@@ -137511,7 +137749,7 @@ var Unifier = class {
|
|
137511
137749
|
this.bindVariableTo(tB, tA);
|
137512
137750
|
return;
|
137513
137751
|
}
|
137514
|
-
if (tB.kind === "Function" && tA.kind === "Function") {
|
137752
|
+
if (tB.kind === "Function" && tA.kind === "Function" && tA.isConstructor === tB.isConstructor) {
|
137515
137753
|
this.unify(tA.return, tB.return);
|
137516
137754
|
return;
|
137517
137755
|
}
|
@@ -137612,7 +137850,8 @@ var Unifier = class {
|
|
137612
137850
|
return {
|
137613
137851
|
kind: "Function",
|
137614
137852
|
return: returnType,
|
137615
|
-
shapeId: type.shapeId
|
137853
|
+
shapeId: type.shapeId,
|
137854
|
+
isConstructor: type.isConstructor
|
137616
137855
|
};
|
137617
137856
|
}
|
137618
137857
|
case "ObjectMethod":
|
@@ -139414,7 +139653,7 @@ function propagatePhiTypes(fn) {
|
|
139414
139653
|
}
|
139415
139654
|
|
139416
139655
|
// src/Optimization/LowerContextAccess.ts
|
139417
|
-
function lowerContextAccess(fn,
|
139656
|
+
function lowerContextAccess(fn, loweredContextCalleeConfig) {
|
139418
139657
|
const contextAccess = /* @__PURE__ */ new Map();
|
139419
139658
|
const contextKeys = /* @__PURE__ */ new Map();
|
139420
139659
|
for (const [, block] of fn.body.blocks) {
|
@@ -139442,6 +139681,7 @@ function lowerContextAccess(fn, loweredContextCallee) {
|
|
139442
139681
|
}
|
139443
139682
|
}
|
139444
139683
|
}
|
139684
|
+
let importLoweredContextCallee = null;
|
139445
139685
|
if (contextAccess.size > 0 && contextKeys.size > 0) {
|
139446
139686
|
for (const [, block] of fn.body.blocks) {
|
139447
139687
|
let nextInstructions = null;
|
@@ -139449,9 +139689,12 @@ function lowerContextAccess(fn, loweredContextCallee) {
|
|
139449
139689
|
const instr = block.instructions[i];
|
139450
139690
|
const { lvalue, value } = instr;
|
139451
139691
|
if (value.kind === "CallExpression" && isUseContextHookType(value.callee.identifier) && contextKeys.has(lvalue.identifier.id)) {
|
139692
|
+
importLoweredContextCallee != null ? importLoweredContextCallee : importLoweredContextCallee = fn.env.programContext.addImportSpecifier(
|
139693
|
+
loweredContextCalleeConfig
|
139694
|
+
);
|
139452
139695
|
const loweredContextCalleeInstr = emitLoadLoweredContextCallee(
|
139453
139696
|
fn.env,
|
139454
|
-
|
139697
|
+
importLoweredContextCallee
|
139455
139698
|
);
|
139456
139699
|
if (nextInstructions === null) {
|
139457
139700
|
nextInstructions = block.instructions.slice(0, i);
|
@@ -139475,17 +139718,12 @@ function lowerContextAccess(fn, loweredContextCallee) {
|
|
139475
139718
|
}
|
139476
139719
|
markInstructionIds(fn.body);
|
139477
139720
|
inferTypes(fn);
|
139478
|
-
fn.env.hasLoweredContextAccess = true;
|
139479
139721
|
}
|
139480
139722
|
}
|
139481
|
-
function emitLoadLoweredContextCallee(env,
|
139723
|
+
function emitLoadLoweredContextCallee(env, importedLowerContextCallee) {
|
139482
139724
|
const loadGlobal = {
|
139483
139725
|
kind: "LoadGlobal",
|
139484
|
-
binding: {
|
139485
|
-
kind: "ImportNamespace",
|
139486
|
-
module: loweredContextCallee.source,
|
139487
|
-
name: loweredContextCallee.importSpecifierName
|
139488
|
-
},
|
139726
|
+
binding: __spreadValues({}, importedLowerContextCallee),
|
139489
139727
|
loc: GeneratedSource
|
139490
139728
|
};
|
139491
139729
|
return {
|
@@ -141192,7 +141430,7 @@ function process2(fn, jsx, globals) {
|
|
141192
141430
|
if (fn.fnType === "Component") {
|
141193
141431
|
return null;
|
141194
141432
|
}
|
141195
|
-
const props = collectProps(jsx);
|
141433
|
+
const props = collectProps(fn.env, jsx);
|
141196
141434
|
if (!props) return null;
|
141197
141435
|
const outlinedTag = fn.env.generateGloballyUniqueIdentifierName(null).value;
|
141198
141436
|
const newInstrs = emitOutlinedJsx(fn.env, jsx, props, outlinedTag);
|
@@ -141202,7 +141440,7 @@ function process2(fn, jsx, globals) {
|
|
141202
141440
|
outlinedFn.id = outlinedTag;
|
141203
141441
|
return { instrs: newInstrs, fn: outlinedFn };
|
141204
141442
|
}
|
141205
|
-
function collectProps(instructions) {
|
141443
|
+
function collectProps(env, instructions) {
|
141206
141444
|
let id = 1;
|
141207
141445
|
function generateName(oldName) {
|
141208
141446
|
let newName = oldName;
|
@@ -141210,6 +141448,7 @@ function collectProps(instructions) {
|
|
141210
141448
|
newName = `${oldName}${id++}`;
|
141211
141449
|
}
|
141212
141450
|
seen.add(newName);
|
141451
|
+
env.programContext.addNewReference(newName);
|
141213
141452
|
return newName;
|
141214
141453
|
}
|
141215
141454
|
const attributes = [];
|
@@ -141472,6 +141711,7 @@ function transformFire(fn) {
|
|
141472
141711
|
context.throwIfErrorsFound();
|
141473
141712
|
}
|
141474
141713
|
function replaceFireFunctions(fn, context) {
|
141714
|
+
let importedUseFire = null;
|
141475
141715
|
let hasRewrite = false;
|
141476
141716
|
for (const [, block] of fn.body.blocks) {
|
141477
141717
|
const rewriteInstrs = /* @__PURE__ */ new Map();
|
@@ -141495,7 +141735,14 @@ function replaceFireFunctions(fn, context) {
|
|
141495
141735
|
] of capturedCallees.entries()) {
|
141496
141736
|
if (!context.hasCalleeWithInsertedFire(fireCalleePlace)) {
|
141497
141737
|
context.addCalleeWithInsertedFire(fireCalleePlace);
|
141498
|
-
|
141738
|
+
importedUseFire != null ? importedUseFire : importedUseFire = fn.env.programContext.addImportSpecifier({
|
141739
|
+
source: fn.env.programContext.reactRuntimeModule,
|
141740
|
+
importSpecifierName: USE_FIRE_FUNCTION_NAME
|
141741
|
+
});
|
141742
|
+
const loadUseFireInstr = makeLoadUseFireInstruction(
|
141743
|
+
fn.env,
|
141744
|
+
importedUseFire
|
141745
|
+
);
|
141499
141746
|
const loadFireCalleeInstr = makeLoadFireCalleeInstruction(
|
141500
141747
|
fn.env,
|
141501
141748
|
fireCalleeInfo.capturedCalleeIdentifier
|
@@ -141715,18 +141962,13 @@ function ensureNoMoreFireUses(fn, context) {
|
|
141715
141962
|
}
|
141716
141963
|
}
|
141717
141964
|
}
|
141718
|
-
function makeLoadUseFireInstruction(env) {
|
141965
|
+
function makeLoadUseFireInstruction(env, importedLoadUseFire) {
|
141719
141966
|
const useFirePlace = createTemporaryPlace(env, GeneratedSource);
|
141720
141967
|
useFirePlace.effect = "read" /* Read */;
|
141721
141968
|
useFirePlace.identifier.type = DefaultNonmutatingHook;
|
141722
141969
|
const instrValue = {
|
141723
141970
|
kind: "LoadGlobal",
|
141724
|
-
binding: {
|
141725
|
-
kind: "ImportSpecifier",
|
141726
|
-
name: "useFire",
|
141727
|
-
module: "react",
|
141728
|
-
imported: "useFire"
|
141729
|
-
},
|
141971
|
+
binding: __spreadValues({}, importedLoadUseFire),
|
141730
141972
|
loc: GeneratedSource
|
141731
141973
|
};
|
141732
141974
|
return {
|
@@ -141794,10 +142036,10 @@ function makeStoreUseFireInstruction(env, useFireCallResultPlace, fireFunctionBi
|
|
141794
142036
|
loc: GeneratedSource
|
141795
142037
|
};
|
141796
142038
|
}
|
141797
|
-
var
|
142039
|
+
var _env3, _errors, _callExpressions, _functionExpressions, _loadLocals, _fireCalleesToFireFunctions, _calleesWithInsertedFire, _capturedCalleeIdentifierIds, _inUseEffectLambda, _loadGlobalInstructionIds, _arrayExpressions;
|
141798
142040
|
var Context4 = class {
|
141799
142041
|
constructor(env) {
|
141800
|
-
__privateAdd(this,
|
142042
|
+
__privateAdd(this, _env3);
|
141801
142043
|
__privateAdd(this, _errors, new CompilerError());
|
141802
142044
|
/*
|
141803
142045
|
* Used to look up the call expression passed to a `fire(callExpr())`. Gives back
|
@@ -141846,7 +142088,7 @@ var Context4 = class {
|
|
141846
142088
|
* to use the fire functions
|
141847
142089
|
*/
|
141848
142090
|
__privateAdd(this, _arrayExpressions, /* @__PURE__ */ new Map());
|
141849
|
-
__privateSet(this,
|
142091
|
+
__privateSet(this, _env3, env);
|
141850
142092
|
}
|
141851
142093
|
pushError(error) {
|
141852
142094
|
__privateGet(this, _errors).push(error);
|
@@ -141881,7 +142123,7 @@ var Context4 = class {
|
|
141881
142123
|
const fireFunctionBinding = getOrInsertWith(
|
141882
142124
|
__privateGet(this, _fireCalleesToFireFunctions),
|
141883
142125
|
callee.identifier.id,
|
141884
|
-
() => createTemporaryPlace(__privateGet(this,
|
142126
|
+
() => createTemporaryPlace(__privateGet(this, _env3), GeneratedSource)
|
141885
142127
|
);
|
141886
142128
|
__privateGet(this, _capturedCalleeIdentifierIds).set(callee.identifier.id, {
|
141887
142129
|
fireFunctionBinding,
|
@@ -141929,7 +142171,7 @@ var Context4 = class {
|
|
141929
142171
|
if (this.hasErrors()) throw __privateGet(this, _errors);
|
141930
142172
|
}
|
141931
142173
|
};
|
141932
|
-
|
142174
|
+
_env3 = new WeakMap();
|
141933
142175
|
_errors = new WeakMap();
|
141934
142176
|
_callExpressions = new WeakMap();
|
141935
142177
|
_functionExpressions = new WeakMap();
|
@@ -142059,7 +142301,7 @@ function validateStaticComponents(fn) {
|
|
142059
142301
|
}
|
142060
142302
|
|
142061
142303
|
// src/Entrypoint/Pipeline.ts
|
142062
|
-
function run(func, config, fnType, mode,
|
142304
|
+
function run(func, config, fnType, mode, programContext, logger, filename, code) {
|
142063
142305
|
var _a, _b;
|
142064
142306
|
const contextIdentifiers = findContextIdentifiers(func);
|
142065
142307
|
const env = new Environment(
|
@@ -142071,7 +142313,7 @@ function run(func, config, fnType, mode, useMemoCacheIdentifier, logger, filenam
|
|
142071
142313
|
logger,
|
142072
142314
|
filename,
|
142073
142315
|
code,
|
142074
|
-
|
142316
|
+
programContext
|
142075
142317
|
);
|
142076
142318
|
(_b = (_a = env.logger) == null ? void 0 : _a.debugLogIRs) == null ? void 0 : _b.call(_a, {
|
142077
142319
|
kind: "debug",
|
@@ -142387,29 +142629,19 @@ function runWithEnvironment(func, env) {
|
|
142387
142629
|
}
|
142388
142630
|
return ast;
|
142389
142631
|
}
|
142390
|
-
function compileFn(func, config, fnType, mode,
|
142632
|
+
function compileFn(func, config, fnType, mode, programContext, logger, filename, code) {
|
142391
142633
|
return run(
|
142392
142634
|
func,
|
142393
142635
|
config,
|
142394
142636
|
fnType,
|
142395
142637
|
mode,
|
142396
|
-
|
142638
|
+
programContext,
|
142397
142639
|
logger,
|
142398
142640
|
filename,
|
142399
142641
|
code
|
142400
142642
|
);
|
142401
142643
|
}
|
142402
142644
|
|
142403
|
-
// src/Utils/ComponentDeclaration.ts
|
142404
|
-
function isComponentDeclaration(node) {
|
142405
|
-
return Object.prototype.hasOwnProperty.call(node, "__componentDeclaration");
|
142406
|
-
}
|
142407
|
-
|
142408
|
-
// src/Utils/HookDeclaration.ts
|
142409
|
-
function isHookDeclaration(node) {
|
142410
|
-
return Object.prototype.hasOwnProperty.call(node, "__hookDeclaration");
|
142411
|
-
}
|
142412
|
-
|
142413
142645
|
// src/Entrypoint/Suppression.ts
|
142414
142646
|
function filterSuppressionsThatAffectFunction(suppressionRanges, fn) {
|
142415
142647
|
const suppressionsInScope = [];
|
@@ -142712,7 +142944,11 @@ function compileProgram(program, pass) {
|
|
142712
142944
|
handleError(restrictedImportsErr, pass, null);
|
142713
142945
|
return null;
|
142714
142946
|
}
|
142715
|
-
const
|
142947
|
+
const programContext = new ProgramContext2(
|
142948
|
+
program,
|
142949
|
+
pass.opts.target,
|
142950
|
+
environment.hookPattern
|
142951
|
+
);
|
142716
142952
|
const suppressions = findProgramSuppressions(
|
142717
142953
|
pass.comments,
|
142718
142954
|
(_a = pass.opts.eslintSuppressionRules) != null ? _a : DEFAULT_ESLINT_SUPPRESSIONS,
|
@@ -142780,7 +143016,7 @@ function compileProgram(program, pass) {
|
|
142780
143016
|
environment,
|
142781
143017
|
fnType,
|
142782
143018
|
"all_features",
|
142783
|
-
|
143019
|
+
programContext,
|
142784
143020
|
pass.opts.logger,
|
142785
143021
|
pass.filename,
|
142786
143022
|
pass.code
|
@@ -142807,13 +143043,13 @@ function compileProgram(program, pass) {
|
|
142807
143043
|
environment,
|
142808
143044
|
fnType,
|
142809
143045
|
"no_inferred_memo",
|
142810
|
-
|
143046
|
+
programContext,
|
142811
143047
|
pass.opts.logger,
|
142812
143048
|
pass.filename,
|
142813
143049
|
pass.code
|
142814
143050
|
)
|
142815
143051
|
};
|
142816
|
-
if (!compileResult.compiledFn.hasFireRewrite && !compileResult.compiledFn.
|
143052
|
+
if (!compileResult.compiledFn.hasFireRewrite && !compileResult.compiledFn.hasInferredEffect) {
|
142817
143053
|
return null;
|
142818
143054
|
}
|
142819
143055
|
} catch (err) {
|
@@ -142892,82 +143128,28 @@ function compileProgram(program, pass) {
|
|
142892
143128
|
if (moduleScopeOptOutDirectives.length > 0) {
|
142893
143129
|
return null;
|
142894
143130
|
}
|
142895
|
-
|
142896
|
-
if (pass.opts.gating != null) {
|
142897
|
-
gating = {
|
142898
|
-
gatingFn: pass.opts.gating,
|
142899
|
-
referencedBeforeDeclared: getFunctionReferencedBeforeDeclarationAtTopLevel(program, compiledFns)
|
142900
|
-
};
|
142901
|
-
}
|
142902
|
-
const hasLoweredContextAccess = compiledFns.some(
|
142903
|
-
(c2) => c2.compiledFn.hasLoweredContextAccess
|
142904
|
-
);
|
142905
|
-
const externalFunctions = [];
|
142906
|
-
try {
|
142907
|
-
if (gating != null) {
|
142908
|
-
externalFunctions.push(gating.gatingFn);
|
142909
|
-
}
|
142910
|
-
const lowerContextAccess2 = environment.lowerContextAccess;
|
142911
|
-
if (lowerContextAccess2 && hasLoweredContextAccess) {
|
142912
|
-
externalFunctions.push(lowerContextAccess2);
|
142913
|
-
}
|
142914
|
-
const enableEmitInstrumentForget = environment.enableEmitInstrumentForget;
|
142915
|
-
if (enableEmitInstrumentForget != null) {
|
142916
|
-
externalFunctions.push(enableEmitInstrumentForget.fn);
|
142917
|
-
if (enableEmitInstrumentForget.gating != null) {
|
142918
|
-
externalFunctions.push(enableEmitInstrumentForget.gating);
|
142919
|
-
}
|
142920
|
-
}
|
142921
|
-
if (environment.enableEmitFreeze != null) {
|
142922
|
-
externalFunctions.push(environment.enableEmitFreeze);
|
142923
|
-
}
|
142924
|
-
if (environment.enableEmitHookGuards != null) {
|
142925
|
-
externalFunctions.push(environment.enableEmitHookGuards);
|
142926
|
-
}
|
142927
|
-
if (environment.enableChangeDetectionForDebugging != null) {
|
142928
|
-
externalFunctions.push(environment.enableChangeDetectionForDebugging);
|
142929
|
-
}
|
142930
|
-
const hasFireRewrite = compiledFns.some((c2) => c2.compiledFn.hasFireRewrite);
|
142931
|
-
if (environment.enableFire && hasFireRewrite) {
|
142932
|
-
externalFunctions.push({
|
142933
|
-
source: getReactCompilerRuntimeModule(pass.opts),
|
142934
|
-
importSpecifierName: "useFire"
|
142935
|
-
});
|
142936
|
-
}
|
142937
|
-
} catch (err) {
|
142938
|
-
handleError(err, pass, null);
|
142939
|
-
return null;
|
142940
|
-
}
|
143131
|
+
const referencedBeforeDeclared = pass.opts.gating != null ? getFunctionReferencedBeforeDeclarationAtTopLevel(program, compiledFns) : null;
|
142941
143132
|
for (const result of compiledFns) {
|
142942
143133
|
const { kind, originalFn, compiledFn } = result;
|
142943
143134
|
const transformedFn = createNewFunctionNode(originalFn, compiledFn);
|
142944
|
-
if (
|
143135
|
+
if (referencedBeforeDeclared != null && kind === "original") {
|
143136
|
+
CompilerError.invariant(pass.opts.gating != null, {
|
143137
|
+
reason: "Expected 'gating' import to be present",
|
143138
|
+
loc: null
|
143139
|
+
});
|
142945
143140
|
insertGatedFunctionDeclaration(
|
142946
143141
|
originalFn,
|
142947
143142
|
transformedFn,
|
142948
|
-
|
142949
|
-
|
143143
|
+
programContext,
|
143144
|
+
pass.opts.gating,
|
143145
|
+
referencedBeforeDeclared.has(result)
|
142950
143146
|
);
|
142951
143147
|
} else {
|
142952
143148
|
originalFn.replaceWith(transformedFn);
|
142953
143149
|
}
|
142954
143150
|
}
|
142955
143151
|
if (compiledFns.length > 0) {
|
142956
|
-
|
142957
|
-
for (const fn of compiledFns) {
|
142958
|
-
if (fn.compiledFn.memoSlotsUsed > 0) {
|
142959
|
-
needsMemoCacheFunctionImport = true;
|
142960
|
-
break;
|
142961
|
-
}
|
142962
|
-
}
|
142963
|
-
if (needsMemoCacheFunctionImport) {
|
142964
|
-
updateMemoCacheFunctionImport(
|
142965
|
-
program,
|
142966
|
-
getReactCompilerRuntimeModule(pass.opts),
|
142967
|
-
useMemoCacheIdentifier.name
|
142968
|
-
);
|
142969
|
-
}
|
142970
|
-
addImportsToProgram(program, externalFunctions);
|
143152
|
+
addImportsToProgram(program, programContext);
|
142971
143153
|
}
|
142972
143154
|
return { retryErrors };
|
142973
143155
|
}
|
@@ -142992,7 +143174,7 @@ function shouldSkipCompilation(program, pass) {
|
|
142992
143174
|
}
|
142993
143175
|
if (hasMemoCacheFunctionImport(
|
142994
143176
|
program,
|
142995
|
-
getReactCompilerRuntimeModule(pass.opts)
|
143177
|
+
getReactCompilerRuntimeModule(pass.opts.target)
|
142996
143178
|
)) {
|
142997
143179
|
return true;
|
142998
143180
|
}
|
@@ -143186,26 +143368,32 @@ function callsHooksOrCreatesJsx(node, hookPattern) {
|
|
143186
143368
|
});
|
143187
143369
|
return invokesHooks || createsJsx;
|
143188
143370
|
}
|
143371
|
+
function isNonNode(node) {
|
143372
|
+
if (!node) {
|
143373
|
+
return true;
|
143374
|
+
}
|
143375
|
+
switch (node.type) {
|
143376
|
+
case "ObjectExpression":
|
143377
|
+
case "ArrowFunctionExpression":
|
143378
|
+
case "FunctionExpression":
|
143379
|
+
case "BigIntLiteral":
|
143380
|
+
case "ClassExpression":
|
143381
|
+
case "NewExpression":
|
143382
|
+
return true;
|
143383
|
+
}
|
143384
|
+
return false;
|
143385
|
+
}
|
143189
143386
|
function returnsNonNode(node) {
|
143190
|
-
let hasReturn = false;
|
143191
143387
|
let returnsNonNode2 = false;
|
143388
|
+
if (
|
143389
|
+
// node.traverse#ArrowFunctionExpression isn't called for the root node
|
143390
|
+
node.type === "ArrowFunctionExpression" && node.node.body.type !== "BlockStatement"
|
143391
|
+
) {
|
143392
|
+
returnsNonNode2 = isNonNode(node.node.body);
|
143393
|
+
}
|
143192
143394
|
node.traverse({
|
143193
143395
|
ReturnStatement(ret) {
|
143194
|
-
|
143195
|
-
const argument = ret.node.argument;
|
143196
|
-
if (argument == null) {
|
143197
|
-
returnsNonNode2 = true;
|
143198
|
-
} else {
|
143199
|
-
switch (argument.type) {
|
143200
|
-
case "ObjectExpression":
|
143201
|
-
case "ArrowFunctionExpression":
|
143202
|
-
case "FunctionExpression":
|
143203
|
-
case "BigIntLiteral":
|
143204
|
-
case "ClassExpression":
|
143205
|
-
case "NewExpression":
|
143206
|
-
returnsNonNode2 = true;
|
143207
|
-
}
|
143208
|
-
}
|
143396
|
+
returnsNonNode2 = isNonNode(ret.node.argument);
|
143209
143397
|
},
|
143210
143398
|
// Skip traversing all nested functions and their return statements
|
143211
143399
|
ArrowFunctionExpression: skipNestedFunctions(node),
|
@@ -143213,7 +143401,7 @@ function returnsNonNode(node) {
|
|
143213
143401
|
FunctionDeclaration: skipNestedFunctions(node),
|
143214
143402
|
ObjectMethod: (node2) => node2.skip()
|
143215
143403
|
});
|
143216
|
-
return
|
143404
|
+
return returnsNonNode2;
|
143217
143405
|
}
|
143218
143406
|
function getFunctionName2(path) {
|
143219
143407
|
if (path.isFunctionDeclaration()) {
|
@@ -143280,14 +143468,14 @@ function getFunctionReferencedBeforeDeclarationAtTopLevel(program, fns) {
|
|
143280
143468
|
});
|
143281
143469
|
return referencedBeforeDeclaration;
|
143282
143470
|
}
|
143283
|
-
function getReactCompilerRuntimeModule(
|
143284
|
-
if (
|
143471
|
+
function getReactCompilerRuntimeModule(target) {
|
143472
|
+
if (target === "19") {
|
143285
143473
|
return "react/compiler-runtime";
|
143286
|
-
} else if (
|
143474
|
+
} else if (target === "17" || target === "18") {
|
143287
143475
|
return "react-compiler-runtime";
|
143288
143476
|
} else {
|
143289
143477
|
CompilerError.invariant(
|
143290
|
-
|
143478
|
+
target != null && target.kind === "donotuse_meta_internal" && typeof target.runtimeModule === "string",
|
143291
143479
|
{
|
143292
143480
|
reason: "Expected target to already be validated",
|
143293
143481
|
description: null,
|
@@ -143295,8 +143483,313 @@ function getReactCompilerRuntimeModule(opts) {
|
|
143295
143483
|
suggestions: null
|
143296
143484
|
}
|
143297
143485
|
);
|
143298
|
-
return
|
143486
|
+
return target.runtimeModule;
|
143487
|
+
}
|
143488
|
+
}
|
143489
|
+
|
143490
|
+
// src/Entrypoint/Imports.ts
|
143491
|
+
function validateRestrictedImports(path, { validateBlocklistedImports }) {
|
143492
|
+
if (validateBlocklistedImports == null || validateBlocklistedImports.length === 0) {
|
143493
|
+
return null;
|
143299
143494
|
}
|
143495
|
+
const error = new CompilerError();
|
143496
|
+
const restrictedImports = new Set(validateBlocklistedImports);
|
143497
|
+
path.traverse({
|
143498
|
+
ImportDeclaration(importDeclPath) {
|
143499
|
+
var _a;
|
143500
|
+
if (restrictedImports.has(importDeclPath.node.source.value)) {
|
143501
|
+
error.push({
|
143502
|
+
severity: "Todo" /* Todo */,
|
143503
|
+
reason: "Bailing out due to blocklisted import",
|
143504
|
+
description: `Import from module ${importDeclPath.node.source.value}`,
|
143505
|
+
loc: (_a = importDeclPath.node.loc) != null ? _a : null
|
143506
|
+
});
|
143507
|
+
}
|
143508
|
+
}
|
143509
|
+
});
|
143510
|
+
if (error.hasErrors()) {
|
143511
|
+
return error;
|
143512
|
+
} else {
|
143513
|
+
return null;
|
143514
|
+
}
|
143515
|
+
}
|
143516
|
+
var ProgramContext2 = class {
|
143517
|
+
constructor(program, reactRuntimeModule, hookPattern) {
|
143518
|
+
// known generated or referenced identifiers in the program
|
143519
|
+
this.knownReferencedNames = /* @__PURE__ */ new Set();
|
143520
|
+
// generated imports
|
143521
|
+
this.imports = /* @__PURE__ */ new Map();
|
143522
|
+
this.hookPattern = hookPattern;
|
143523
|
+
this.scope = program.scope;
|
143524
|
+
this.reactRuntimeModule = getReactCompilerRuntimeModule(reactRuntimeModule);
|
143525
|
+
}
|
143526
|
+
isHookName(name) {
|
143527
|
+
if (this.hookPattern == null) {
|
143528
|
+
return isHookName(name);
|
143529
|
+
} else {
|
143530
|
+
const match = new RegExp(this.hookPattern).exec(name);
|
143531
|
+
return match != null && typeof match[1] === "string" && isHookName(match[1]);
|
143532
|
+
}
|
143533
|
+
}
|
143534
|
+
hasReference(name) {
|
143535
|
+
return this.knownReferencedNames.has(name) || this.scope.hasBinding(name) || this.scope.hasGlobal(name) || this.scope.hasReference(name);
|
143536
|
+
}
|
143537
|
+
newUid(name) {
|
143538
|
+
let uid;
|
143539
|
+
if (this.isHookName(name)) {
|
143540
|
+
uid = name;
|
143541
|
+
let i = 0;
|
143542
|
+
while (this.hasReference(uid)) {
|
143543
|
+
this.knownReferencedNames.add(uid);
|
143544
|
+
uid = `${name}_${i++}`;
|
143545
|
+
}
|
143546
|
+
} else if (!this.hasReference(name)) {
|
143547
|
+
uid = name;
|
143548
|
+
} else {
|
143549
|
+
uid = this.scope.generateUid(name);
|
143550
|
+
}
|
143551
|
+
this.knownReferencedNames.add(uid);
|
143552
|
+
return uid;
|
143553
|
+
}
|
143554
|
+
addMemoCacheImport() {
|
143555
|
+
return this.addImportSpecifier(
|
143556
|
+
{
|
143557
|
+
source: this.reactRuntimeModule,
|
143558
|
+
importSpecifierName: "c"
|
143559
|
+
},
|
143560
|
+
"_c"
|
143561
|
+
);
|
143562
|
+
}
|
143563
|
+
/**
|
143564
|
+
*
|
143565
|
+
* @param externalFunction
|
143566
|
+
* @param nameHint if defined, will be used as the name of the import specifier
|
143567
|
+
* @returns
|
143568
|
+
*/
|
143569
|
+
addImportSpecifier({ source: module2, importSpecifierName: specifier }, nameHint) {
|
143570
|
+
var _a;
|
143571
|
+
const maybeBinding = (_a = this.imports.get(module2)) == null ? void 0 : _a.get(specifier);
|
143572
|
+
if (maybeBinding != null) {
|
143573
|
+
return __spreadValues({}, maybeBinding);
|
143574
|
+
}
|
143575
|
+
const binding = {
|
143576
|
+
kind: "ImportSpecifier",
|
143577
|
+
name: this.newUid(nameHint != null ? nameHint : specifier),
|
143578
|
+
module: module2,
|
143579
|
+
imported: specifier
|
143580
|
+
};
|
143581
|
+
getOrInsertWith(this.imports, module2, () => /* @__PURE__ */ new Map()).set(specifier, __spreadValues({}, binding));
|
143582
|
+
return binding;
|
143583
|
+
}
|
143584
|
+
addNewReference(name) {
|
143585
|
+
this.knownReferencedNames.add(name);
|
143586
|
+
}
|
143587
|
+
assertGlobalBinding(name, localScope) {
|
143588
|
+
var _a, _b;
|
143589
|
+
const scope = localScope != null ? localScope : this.scope;
|
143590
|
+
if (!scope.hasReference(name) && !scope.hasBinding(name)) {
|
143591
|
+
return Ok(void 0);
|
143592
|
+
}
|
143593
|
+
const error = new CompilerError();
|
143594
|
+
error.push({
|
143595
|
+
severity: "Todo" /* Todo */,
|
143596
|
+
reason: "Encountered conflicting global in generated program",
|
143597
|
+
description: `Conflict from local binding ${name}`,
|
143598
|
+
loc: (_b = (_a = scope.getBinding(name)) == null ? void 0 : _a.path.node.loc) != null ? _b : null,
|
143599
|
+
suggestions: null
|
143600
|
+
});
|
143601
|
+
return Err(error);
|
143602
|
+
}
|
143603
|
+
};
|
143604
|
+
function getExistingImports(program) {
|
143605
|
+
const existingImports = /* @__PURE__ */ new Map();
|
143606
|
+
program.traverse({
|
143607
|
+
ImportDeclaration(path) {
|
143608
|
+
if (isNonNamespacedImport(path)) {
|
143609
|
+
existingImports.set(path.node.source.value, path);
|
143610
|
+
}
|
143611
|
+
}
|
143612
|
+
});
|
143613
|
+
return existingImports;
|
143614
|
+
}
|
143615
|
+
function addImportsToProgram(path, programContext) {
|
143616
|
+
const existingImports = getExistingImports(path);
|
143617
|
+
const stmts = [];
|
143618
|
+
const sortedModules = [...programContext.imports.entries()].sort(
|
143619
|
+
([a], [b]) => a.localeCompare(b)
|
143620
|
+
);
|
143621
|
+
for (const [moduleName, importsMap] of sortedModules) {
|
143622
|
+
for (const [specifierName, loweredImport] of importsMap) {
|
143623
|
+
CompilerError.invariant(
|
143624
|
+
path.scope.getBinding(loweredImport.name) == null,
|
143625
|
+
{
|
143626
|
+
reason: "Encountered conflicting import specifiers in generated program",
|
143627
|
+
description: `Conflict from import ${loweredImport.module}:(${loweredImport.imported} as ${loweredImport.name}).`,
|
143628
|
+
loc: GeneratedSource,
|
143629
|
+
suggestions: null
|
143630
|
+
}
|
143631
|
+
);
|
143632
|
+
CompilerError.invariant(
|
143633
|
+
loweredImport.module === moduleName && loweredImport.imported === specifierName,
|
143634
|
+
{
|
143635
|
+
reason: "Found inconsistent import specifier. This is an internal bug.",
|
143636
|
+
description: `Expected import ${moduleName}:${specifierName} but found ${loweredImport.module}:${loweredImport.imported}`,
|
143637
|
+
loc: GeneratedSource
|
143638
|
+
}
|
143639
|
+
);
|
143640
|
+
}
|
143641
|
+
const sortedImport = [
|
143642
|
+
...importsMap.values()
|
143643
|
+
].sort(({ imported: a }, { imported: b }) => a.localeCompare(b));
|
143644
|
+
const importSpecifiers = sortedImport.map((specifier) => {
|
143645
|
+
return t4.importSpecifier(
|
143646
|
+
t4.identifier(specifier.name),
|
143647
|
+
t4.identifier(specifier.imported)
|
143648
|
+
);
|
143649
|
+
});
|
143650
|
+
const maybeExistingImports = existingImports.get(moduleName);
|
143651
|
+
if (maybeExistingImports != null) {
|
143652
|
+
maybeExistingImports.pushContainer("specifiers", importSpecifiers);
|
143653
|
+
} else {
|
143654
|
+
stmts.push(
|
143655
|
+
t4.importDeclaration(importSpecifiers, t4.stringLiteral(moduleName))
|
143656
|
+
);
|
143657
|
+
}
|
143658
|
+
}
|
143659
|
+
path.unshiftContainer("body", stmts);
|
143660
|
+
}
|
143661
|
+
function isNonNamespacedImport(importDeclPath) {
|
143662
|
+
return importDeclPath.get("specifiers").every((specifier) => specifier.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
143663
|
+
}
|
143664
|
+
|
143665
|
+
// src/Entrypoint/Options.ts
|
143666
|
+
var PanicThresholdOptionsSchema = z.enum([
|
143667
|
+
/*
|
143668
|
+
* Any errors will panic the compiler by throwing an exception, which will
|
143669
|
+
* bubble up to the nearest exception handler above the Forget transform.
|
143670
|
+
* If Forget is invoked through `BabelPluginReactCompiler`, this will at the least
|
143671
|
+
* skip Forget compilation for the rest of current file.
|
143672
|
+
*/
|
143673
|
+
"all_errors",
|
143674
|
+
/*
|
143675
|
+
* Panic by throwing an exception only on critical or unrecognized errors.
|
143676
|
+
* For all other errors, skip the erroring function without inserting
|
143677
|
+
* a Forget-compiled version (i.e. same behavior as noEmit).
|
143678
|
+
*/
|
143679
|
+
"critical_errors",
|
143680
|
+
// Never panic by throwing an exception.
|
143681
|
+
"none"
|
143682
|
+
]);
|
143683
|
+
var CompilerReactTargetSchema = z.union([
|
143684
|
+
z.literal("17"),
|
143685
|
+
z.literal("18"),
|
143686
|
+
z.literal("19"),
|
143687
|
+
/**
|
143688
|
+
* Used exclusively for Meta apps which are guaranteed to have compatible
|
143689
|
+
* react runtime and compiler versions. Note that only the FB-internal bundles
|
143690
|
+
* re-export useMemoCache (see
|
143691
|
+
* https://github.com/facebook/react/blob/5b0ef217ef32333a8e56f39be04327c89efa346f/packages/react/index.fb.js#L68-L70),
|
143692
|
+
* so this option is invalid / creates runtime errors for open-source users.
|
143693
|
+
*/
|
143694
|
+
z.object({
|
143695
|
+
kind: z.literal("donotuse_meta_internal"),
|
143696
|
+
runtimeModule: z.string().default("react")
|
143697
|
+
})
|
143698
|
+
]);
|
143699
|
+
var CompilationModeSchema = z.enum([
|
143700
|
+
/*
|
143701
|
+
* Compiles functions annotated with "use forget" or component/hook-like functions.
|
143702
|
+
* This latter includes:
|
143703
|
+
* * Components declared with component syntax.
|
143704
|
+
* * Functions which can be inferred to be a component or hook:
|
143705
|
+
* - Be named like a hook or component. This logic matches the ESLint rule.
|
143706
|
+
* - *and* create JSX and/or call a hook. This is an additional check to help prevent
|
143707
|
+
* false positives, since compilation has a greater impact than linting.
|
143708
|
+
* This is the default mode
|
143709
|
+
*/
|
143710
|
+
"infer",
|
143711
|
+
// Compile only components using Flow component syntax and hooks using hook syntax.
|
143712
|
+
"syntax",
|
143713
|
+
// Compile only functions which are explicitly annotated with "use forget"
|
143714
|
+
"annotation",
|
143715
|
+
// Compile all top-level functions
|
143716
|
+
"all"
|
143717
|
+
]);
|
143718
|
+
var defaultOptions = {
|
143719
|
+
compilationMode: "infer",
|
143720
|
+
panicThreshold: "none",
|
143721
|
+
environment: parseEnvironmentConfig({}).unwrap(),
|
143722
|
+
logger: null,
|
143723
|
+
gating: null,
|
143724
|
+
noEmit: false,
|
143725
|
+
eslintSuppressionRules: null,
|
143726
|
+
flowSuppressions: true,
|
143727
|
+
ignoreUseNoForget: false,
|
143728
|
+
sources: (filename) => {
|
143729
|
+
return filename.indexOf("node_modules") === -1;
|
143730
|
+
},
|
143731
|
+
enableReanimatedCheck: true,
|
143732
|
+
target: "19"
|
143733
|
+
};
|
143734
|
+
function parsePluginOptions(obj) {
|
143735
|
+
if (obj == null || typeof obj !== "object") {
|
143736
|
+
return defaultOptions;
|
143737
|
+
}
|
143738
|
+
const parsedOptions = /* @__PURE__ */ Object.create(null);
|
143739
|
+
for (let [key2, value] of Object.entries(obj)) {
|
143740
|
+
if (typeof value === "string") {
|
143741
|
+
value = value.toLowerCase();
|
143742
|
+
}
|
143743
|
+
if (isCompilerFlag(key2)) {
|
143744
|
+
switch (key2) {
|
143745
|
+
case "environment": {
|
143746
|
+
const environmentResult = parseEnvironmentConfig(value);
|
143747
|
+
if (environmentResult.isErr()) {
|
143748
|
+
CompilerError.throwInvalidConfig({
|
143749
|
+
reason: "Error in validating environment config. This is an advanced setting and not meant to be used directly",
|
143750
|
+
description: environmentResult.unwrapErr().toString(),
|
143751
|
+
suggestions: null,
|
143752
|
+
loc: null
|
143753
|
+
});
|
143754
|
+
}
|
143755
|
+
parsedOptions[key2] = environmentResult.unwrap();
|
143756
|
+
break;
|
143757
|
+
}
|
143758
|
+
case "target": {
|
143759
|
+
parsedOptions[key2] = parseTargetConfig(value);
|
143760
|
+
break;
|
143761
|
+
}
|
143762
|
+
case "gating": {
|
143763
|
+
if (value == null) {
|
143764
|
+
parsedOptions[key2] = null;
|
143765
|
+
} else {
|
143766
|
+
parsedOptions[key2] = tryParseExternalFunction(value);
|
143767
|
+
}
|
143768
|
+
break;
|
143769
|
+
}
|
143770
|
+
default: {
|
143771
|
+
parsedOptions[key2] = value;
|
143772
|
+
}
|
143773
|
+
}
|
143774
|
+
}
|
143775
|
+
}
|
143776
|
+
return __spreadValues(__spreadValues({}, defaultOptions), parsedOptions);
|
143777
|
+
}
|
143778
|
+
function parseTargetConfig(value) {
|
143779
|
+
const parsed = CompilerReactTargetSchema.safeParse(value);
|
143780
|
+
if (parsed.success) {
|
143781
|
+
return parsed.data;
|
143782
|
+
} else {
|
143783
|
+
CompilerError.throwInvalidConfig({
|
143784
|
+
reason: "Not a valid target",
|
143785
|
+
description: `${fromZodError(parsed.error)}`,
|
143786
|
+
suggestions: null,
|
143787
|
+
loc: null
|
143788
|
+
});
|
143789
|
+
}
|
143790
|
+
}
|
143791
|
+
function isCompilerFlag(s) {
|
143792
|
+
return hasOwnProperty2(defaultOptions, s);
|
143300
143793
|
}
|
143301
143794
|
|
143302
143795
|
// src/Entrypoint/Reanimated.ts
|
@@ -143622,6 +144115,7 @@ var index_default = BabelPluginReactCompiler;
|
|
143622
144115
|
ErrorSeverity,
|
143623
144116
|
OPT_IN_DIRECTIVES,
|
143624
144117
|
OPT_OUT_DIRECTIVES,
|
144118
|
+
ProgramContext,
|
143625
144119
|
ValueKind,
|
143626
144120
|
compile,
|
143627
144121
|
compileProgram,
|