babel-plugin-react-compiler 19.0.0-beta-aeaed83-20250323 → 19.0.0-beta-e993439-20250405
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 +43 -15
- package/dist/index.js +844 -700
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -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,
|
@@ -110433,8 +110434,10 @@ __export(index_exports, {
|
|
110433
110434
|
findDirectiveEnablingMemoization: () => findDirectiveEnablingMemoization,
|
110434
110435
|
parseConfigPragmaForTests: () => parseConfigPragmaForTests,
|
110435
110436
|
parsePluginOptions: () => parsePluginOptions,
|
110437
|
+
printFunctionWithOutlined: () => printFunctionWithOutlined,
|
110436
110438
|
printHIR: () => printHIR,
|
110437
110439
|
printReactiveFunction: () => printReactiveFunction,
|
110440
|
+
printReactiveFunctionWithOutlined: () => printReactiveFunctionWithOutlined,
|
110438
110441
|
runBabelPluginReactCompiler: () => runBabelPluginReactCompiler,
|
110439
110442
|
validateEnvironmentConfig: () => validateEnvironmentConfig
|
110440
110443
|
});
|
@@ -110829,7 +110832,7 @@ var CompilerError = class _CompilerError extends Error {
|
|
110829
110832
|
};
|
110830
110833
|
|
110831
110834
|
// src/Entrypoint/Gating.ts
|
110832
|
-
function insertAdditionalFunctionDeclaration(fnPath, compiled,
|
110835
|
+
function insertAdditionalFunctionDeclaration(fnPath, compiled, programContext, gatingFunctionIdentifierName) {
|
110833
110836
|
var _a, _b;
|
110834
110837
|
const originalFnName = fnPath.node.id;
|
110835
110838
|
const originalFnParams = fnPath.node.params;
|
@@ -110842,14 +110845,14 @@ function insertAdditionalFunctionDeclaration(fnPath, compiled, gating) {
|
|
110842
110845
|
reason: "Expected React Compiler optimized function declarations to have the same number of parameters as source",
|
110843
110846
|
loc: (_b = fnPath.node.loc) != null ? _b : null
|
110844
110847
|
});
|
110845
|
-
const gatingCondition =
|
110846
|
-
`${
|
110848
|
+
const gatingCondition = t.identifier(
|
110849
|
+
programContext.newUid(`${gatingFunctionIdentifierName}_result`)
|
110847
110850
|
);
|
110848
|
-
const unoptimizedFnName =
|
110849
|
-
`${originalFnName.name}_unoptimized`
|
110851
|
+
const unoptimizedFnName = t.identifier(
|
110852
|
+
programContext.newUid(`${originalFnName.name}_unoptimized`)
|
110850
110853
|
);
|
110851
|
-
const optimizedFnName =
|
110852
|
-
`${originalFnName.name}_optimized`
|
110854
|
+
const optimizedFnName = t.identifier(
|
110855
|
+
programContext.newUid(`${originalFnName.name}_optimized`)
|
110853
110856
|
);
|
110854
110857
|
compiled.id.name = optimizedFnName.name;
|
110855
110858
|
fnPath.get("id").replaceInline(unoptimizedFnName);
|
@@ -110892,24 +110895,30 @@ function insertAdditionalFunctionDeclaration(fnPath, compiled, gating) {
|
|
110892
110895
|
t.variableDeclaration("const", [
|
110893
110896
|
t.variableDeclarator(
|
110894
110897
|
gatingCondition,
|
110895
|
-
t.callExpression(t.identifier(
|
110898
|
+
t.callExpression(t.identifier(gatingFunctionIdentifierName), [])
|
110896
110899
|
)
|
110897
110900
|
])
|
110898
110901
|
);
|
110899
110902
|
fnPath.insertBefore(compiled);
|
110900
110903
|
}
|
110901
|
-
function insertGatedFunctionDeclaration(fnPath, compiled, gating, referencedBeforeDeclaration) {
|
110904
|
+
function insertGatedFunctionDeclaration(fnPath, compiled, programContext, gating, referencedBeforeDeclaration) {
|
110902
110905
|
var _a;
|
110906
|
+
const gatingImportedName = programContext.addImportSpecifier(gating).name;
|
110903
110907
|
if (referencedBeforeDeclaration && fnPath.isFunctionDeclaration()) {
|
110904
110908
|
CompilerError.invariant(compiled.type === "FunctionDeclaration", {
|
110905
110909
|
reason: "Expected compiled node type to match input type",
|
110906
110910
|
description: `Got ${compiled.type} but expected FunctionDeclaration`,
|
110907
110911
|
loc: (_a = fnPath.node.loc) != null ? _a : null
|
110908
110912
|
});
|
110909
|
-
insertAdditionalFunctionDeclaration(
|
110913
|
+
insertAdditionalFunctionDeclaration(
|
110914
|
+
fnPath,
|
110915
|
+
compiled,
|
110916
|
+
programContext,
|
110917
|
+
gatingImportedName
|
110918
|
+
);
|
110910
110919
|
} else {
|
110911
110920
|
const gatingExpression = t.conditionalExpression(
|
110912
|
-
t.callExpression(t.identifier(
|
110921
|
+
t.callExpression(t.identifier(gatingImportedName), []),
|
110913
110922
|
buildFunctionExpression(compiled),
|
110914
110923
|
buildFunctionExpression(fnPath.node)
|
110915
110924
|
);
|
@@ -110955,7 +110964,7 @@ function buildFunctionExpression(node) {
|
|
110955
110964
|
}
|
110956
110965
|
|
110957
110966
|
// src/Entrypoint/Imports.ts
|
110958
|
-
var
|
110967
|
+
var t4 = __toESM(require("@babel/types"));
|
110959
110968
|
|
110960
110969
|
// src/HIR/HIR.ts
|
110961
110970
|
var t2 = __toESM(require("@babel/types"));
|
@@ -114952,6 +114961,14 @@ function getHookKindForType(env, type) {
|
|
114952
114961
|
var import_generator = __toESM(require_lib26());
|
114953
114962
|
|
114954
114963
|
// src/ReactiveScopes/PrintReactiveFunction.ts
|
114964
|
+
function printReactiveFunctionWithOutlined(fn) {
|
114965
|
+
const writer = new Writer();
|
114966
|
+
writeReactiveFunction(fn, writer);
|
114967
|
+
for (const outlined of fn.env.getOutlinedFunctions()) {
|
114968
|
+
writer.writeLine("\nfunction " + printFunction(outlined.fn));
|
114969
|
+
}
|
114970
|
+
return writer.complete();
|
114971
|
+
}
|
114955
114972
|
function printReactiveFunction(fn) {
|
114956
114973
|
const writer = new Writer();
|
114957
114974
|
writeReactiveFunction(fn, writer);
|
@@ -115319,6 +115336,15 @@ _line = new WeakMap();
|
|
115319
115336
|
_depth = new WeakMap();
|
115320
115337
|
|
115321
115338
|
// src/HIR/PrintHIR.ts
|
115339
|
+
function printFunctionWithOutlined(fn) {
|
115340
|
+
const output = [printFunction(fn)];
|
115341
|
+
for (const outlined of fn.env.getOutlinedFunctions()) {
|
115342
|
+
output.push(`
|
115343
|
+
function ${outlined.fn.id}:
|
115344
|
+
${printHIR(outlined.fn.body)}`);
|
115345
|
+
}
|
115346
|
+
return output.join("\n");
|
115347
|
+
}
|
115322
115348
|
function printFunction(fn) {
|
115323
115349
|
const output = [];
|
115324
115350
|
let definition = "";
|
@@ -117570,6 +117596,7 @@ var HIRBuilder = class {
|
|
117570
117596
|
type: makeType(),
|
117571
117597
|
loc: (_b = node.loc) != null ? _b : GeneratedSource
|
117572
117598
|
};
|
117599
|
+
__privateGet(this, _env).programContext.addNewReference(name);
|
117573
117600
|
__privateGet(this, _bindings).set(name, { node, identifier: identifier4 });
|
117574
117601
|
return identifier4;
|
117575
117602
|
} else if (mapping.node === node) {
|
@@ -120990,6 +121017,19 @@ function lowerExpression(builder, exprPath) {
|
|
120990
121017
|
kind: "TypeCastExpression",
|
120991
121018
|
value: lowerExpressionToTemporary(builder, expr.get("expression")),
|
120992
121019
|
typeAnnotation: typeAnnotation2.node,
|
121020
|
+
typeAnnotationKind: "cast",
|
121021
|
+
type: lowerType(typeAnnotation2.node),
|
121022
|
+
loc: exprLoc
|
121023
|
+
};
|
121024
|
+
}
|
121025
|
+
case "TSSatisfiesExpression": {
|
121026
|
+
let expr = exprPath;
|
121027
|
+
const typeAnnotation2 = expr.get("typeAnnotation");
|
121028
|
+
return {
|
121029
|
+
kind: "TypeCastExpression",
|
121030
|
+
value: lowerExpressionToTemporary(builder, expr.get("expression")),
|
121031
|
+
typeAnnotation: typeAnnotation2.node,
|
121032
|
+
typeAnnotationKind: "satisfies",
|
120993
121033
|
type: lowerType(typeAnnotation2.node),
|
120994
121034
|
loc: exprLoc
|
120995
121035
|
};
|
@@ -121001,6 +121041,7 @@ function lowerExpression(builder, exprPath) {
|
|
121001
121041
|
kind: "TypeCastExpression",
|
121002
121042
|
value: lowerExpressionToTemporary(builder, expr.get("expression")),
|
121003
121043
|
typeAnnotation: typeAnnotation2.node,
|
121044
|
+
typeAnnotationKind: "as",
|
121004
121045
|
type: lowerType(typeAnnotation2.node),
|
121005
121046
|
loc: exprLoc
|
121006
121047
|
};
|
@@ -123818,6 +123859,8 @@ var InstrumentationSchema = z.object({
|
|
123818
123859
|
(opts) => opts.gating != null || opts.globalGating != null,
|
123819
123860
|
"Expected at least one of gating or globalGating"
|
123820
123861
|
);
|
123862
|
+
var USE_FIRE_FUNCTION_NAME = "useFire";
|
123863
|
+
var EMIT_FREEZE_GLOBAL_GATING = "__DEV__";
|
123821
123864
|
var MacroMethodSchema = z.union([
|
123822
123865
|
z.object({ type: z.literal("wildcard") }),
|
123823
123866
|
z.object({ type: z.literal("name"), name: z.string() })
|
@@ -124407,6 +124450,7 @@ function parseConfigPragmaForTests(pragma, defaults) {
|
|
124407
124450
|
const environment = parseConfigPragmaEnvironmentForTest(pragma);
|
124408
124451
|
let compilationMode = defaults.compilationMode;
|
124409
124452
|
let panicThreshold = "all_errors";
|
124453
|
+
let noEmit = defaultOptions.noEmit;
|
124410
124454
|
for (const token2 of pragma.split(" ")) {
|
124411
124455
|
if (!token2.startsWith("@")) {
|
124412
124456
|
continue;
|
@@ -124432,17 +124476,22 @@ function parseConfigPragmaForTests(pragma, defaults) {
|
|
124432
124476
|
panicThreshold = "none";
|
124433
124477
|
break;
|
124434
124478
|
}
|
124479
|
+
case "@noEmit": {
|
124480
|
+
noEmit = true;
|
124481
|
+
break;
|
124482
|
+
}
|
124435
124483
|
}
|
124436
124484
|
}
|
124437
124485
|
return parsePluginOptions({
|
124438
124486
|
environment,
|
124439
124487
|
compilationMode,
|
124440
|
-
panicThreshold
|
124488
|
+
panicThreshold,
|
124489
|
+
noEmit
|
124441
124490
|
});
|
124442
124491
|
}
|
124443
124492
|
var _globals, _shapes, _moduleTypes, _nextIdentifer, _nextBlock, _nextScope, _scope, _outlinedFunctions, _contextIdentifiers, _hoistedIdentifiers, _Environment_instances, resolveModuleType_fn, isKnownReactModule_fn, getCustomHookType_fn;
|
124444
124493
|
var Environment = class {
|
124445
|
-
constructor(scope, fnType, compilerMode, config, contextIdentifiers, logger, filename, code,
|
124494
|
+
constructor(scope, fnType, compilerMode, config, contextIdentifiers, logger, filename, code, programContext) {
|
124446
124495
|
__privateAdd(this, _Environment_instances);
|
124447
124496
|
__privateAdd(this, _globals);
|
124448
124497
|
__privateAdd(this, _shapes);
|
@@ -124452,6 +124501,7 @@ var Environment = class {
|
|
124452
124501
|
__privateAdd(this, _nextScope, 0);
|
124453
124502
|
__privateAdd(this, _scope);
|
124454
124503
|
__privateAdd(this, _outlinedFunctions, []);
|
124504
|
+
this.inferredEffectLocations = /* @__PURE__ */ new Set();
|
124455
124505
|
__privateAdd(this, _contextIdentifiers);
|
124456
124506
|
__privateAdd(this, _hoistedIdentifiers);
|
124457
124507
|
__privateSet(this, _scope, scope);
|
@@ -124461,11 +124511,11 @@ var Environment = class {
|
|
124461
124511
|
this.filename = filename;
|
124462
124512
|
this.code = code;
|
124463
124513
|
this.logger = logger;
|
124464
|
-
this.
|
124514
|
+
this.programContext = programContext;
|
124465
124515
|
__privateSet(this, _shapes, new Map(DEFAULT_SHAPES));
|
124466
124516
|
__privateSet(this, _globals, new Map(DEFAULT_GLOBALS));
|
124467
|
-
this.hasLoweredContextAccess = false;
|
124468
124517
|
this.hasFireRewrite = false;
|
124518
|
+
this.hasInferredEffect = false;
|
124469
124519
|
if (config.disableMemoizationForDebugging && config.enableChangeDetectionForDebugging != null) {
|
124470
124520
|
CompilerError.throwInvalidConfig({
|
124471
124521
|
reason: `Invalid environment config: the 'disableMemoizationForDebugging' and 'enableChangeDetectionForDebugging' options cannot be used together`,
|
@@ -124513,6 +124563,9 @@ var Environment = class {
|
|
124513
124563
|
get nextScopeId() {
|
124514
124564
|
return makeScopeId(__privateWrapper(this, _nextScope)._++);
|
124515
124565
|
}
|
124566
|
+
get scope() {
|
124567
|
+
return __privateGet(this, _scope);
|
124568
|
+
}
|
124516
124569
|
logErrors(errors) {
|
124517
124570
|
if (errors.isOk() || this.logger == null) {
|
124518
124571
|
return;
|
@@ -125401,260 +125454,14 @@ function pruneUnusedLabelsHIR(fn) {
|
|
125401
125454
|
}
|
125402
125455
|
}
|
125403
125456
|
|
125404
|
-
// src/
|
125405
|
-
function
|
125406
|
-
|
125407
|
-
return null;
|
125408
|
-
}
|
125409
|
-
const error = new CompilerError();
|
125410
|
-
const restrictedImports = new Set(validateBlocklistedImports);
|
125411
|
-
path.traverse({
|
125412
|
-
ImportDeclaration(importDeclPath) {
|
125413
|
-
var _a;
|
125414
|
-
if (restrictedImports.has(importDeclPath.node.source.value)) {
|
125415
|
-
error.push({
|
125416
|
-
severity: "Todo" /* Todo */,
|
125417
|
-
reason: "Bailing out due to blocklisted import",
|
125418
|
-
description: `Import from module ${importDeclPath.node.source.value}`,
|
125419
|
-
loc: (_a = importDeclPath.node.loc) != null ? _a : null
|
125420
|
-
});
|
125421
|
-
}
|
125422
|
-
}
|
125423
|
-
});
|
125424
|
-
if (error.hasErrors()) {
|
125425
|
-
return error;
|
125426
|
-
} else {
|
125427
|
-
return null;
|
125428
|
-
}
|
125429
|
-
}
|
125430
|
-
function addImportsToProgram(path, importList) {
|
125431
|
-
const identifiers = /* @__PURE__ */ new Set();
|
125432
|
-
const sortedImports = /* @__PURE__ */ new Map();
|
125433
|
-
for (const { importSpecifierName, source: source2 } of importList) {
|
125434
|
-
CompilerError.invariant(identifiers.has(importSpecifierName) === false, {
|
125435
|
-
reason: `Encountered conflicting import specifier for ${importSpecifierName} in Forget config.`,
|
125436
|
-
description: null,
|
125437
|
-
loc: GeneratedSource,
|
125438
|
-
suggestions: null
|
125439
|
-
});
|
125440
|
-
CompilerError.invariant(
|
125441
|
-
path.scope.hasBinding(importSpecifierName) === false,
|
125442
|
-
{
|
125443
|
-
reason: `Encountered conflicting import specifiers for ${importSpecifierName} in generated program.`,
|
125444
|
-
description: null,
|
125445
|
-
loc: GeneratedSource,
|
125446
|
-
suggestions: null
|
125447
|
-
}
|
125448
|
-
);
|
125449
|
-
identifiers.add(importSpecifierName);
|
125450
|
-
const importSpecifierNameList = getOrInsertDefault(
|
125451
|
-
sortedImports,
|
125452
|
-
source2,
|
125453
|
-
[]
|
125454
|
-
);
|
125455
|
-
importSpecifierNameList.push(importSpecifierName);
|
125456
|
-
}
|
125457
|
-
const stmts = [];
|
125458
|
-
for (const [source2, importSpecifierNameList] of sortedImports) {
|
125459
|
-
const importSpecifiers = importSpecifierNameList.map((name) => {
|
125460
|
-
const id = t3.identifier(name);
|
125461
|
-
return t3.importSpecifier(id, id);
|
125462
|
-
});
|
125463
|
-
stmts.push(t3.importDeclaration(importSpecifiers, t3.stringLiteral(source2)));
|
125464
|
-
}
|
125465
|
-
path.unshiftContainer("body", stmts);
|
125466
|
-
}
|
125467
|
-
function isNonNamespacedImport(importDeclPath, moduleName) {
|
125468
|
-
return importDeclPath.get("source").node.value === moduleName && importDeclPath.get("specifiers").every((specifier) => specifier.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
125469
|
-
}
|
125470
|
-
function hasExistingNonNamespacedImportOfModule(program, moduleName) {
|
125471
|
-
let hasExistingImport = false;
|
125472
|
-
program.traverse({
|
125473
|
-
ImportDeclaration(importDeclPath) {
|
125474
|
-
if (isNonNamespacedImport(importDeclPath, moduleName)) {
|
125475
|
-
hasExistingImport = true;
|
125476
|
-
}
|
125477
|
-
}
|
125478
|
-
});
|
125479
|
-
return hasExistingImport;
|
125480
|
-
}
|
125481
|
-
function addMemoCacheFunctionSpecifierToExistingImport(program, moduleName, identifierName) {
|
125482
|
-
let didInsertUseMemoCache = false;
|
125483
|
-
program.traverse({
|
125484
|
-
ImportDeclaration(importDeclPath) {
|
125485
|
-
if (!didInsertUseMemoCache && isNonNamespacedImport(importDeclPath, moduleName)) {
|
125486
|
-
importDeclPath.pushContainer(
|
125487
|
-
"specifiers",
|
125488
|
-
t3.importSpecifier(t3.identifier(identifierName), t3.identifier("c"))
|
125489
|
-
);
|
125490
|
-
didInsertUseMemoCache = true;
|
125491
|
-
}
|
125492
|
-
}
|
125493
|
-
});
|
125494
|
-
return didInsertUseMemoCache;
|
125495
|
-
}
|
125496
|
-
function updateMemoCacheFunctionImport(program, moduleName, useMemoCacheIdentifier) {
|
125497
|
-
const hasExistingImport = hasExistingNonNamespacedImportOfModule(
|
125498
|
-
program,
|
125499
|
-
moduleName
|
125500
|
-
);
|
125501
|
-
if (hasExistingImport) {
|
125502
|
-
const didUpdateImport = addMemoCacheFunctionSpecifierToExistingImport(
|
125503
|
-
program,
|
125504
|
-
moduleName,
|
125505
|
-
useMemoCacheIdentifier
|
125506
|
-
);
|
125507
|
-
if (!didUpdateImport) {
|
125508
|
-
throw new Error(
|
125509
|
-
`Expected an ImportDeclaration of \`${moduleName}\` in order to update ImportSpecifiers with useMemoCache`
|
125510
|
-
);
|
125511
|
-
}
|
125512
|
-
} else {
|
125513
|
-
addMemoCacheFunctionImportDeclaration(
|
125514
|
-
program,
|
125515
|
-
moduleName,
|
125516
|
-
useMemoCacheIdentifier
|
125517
|
-
);
|
125518
|
-
}
|
125519
|
-
}
|
125520
|
-
function addMemoCacheFunctionImportDeclaration(program, moduleName, localName) {
|
125521
|
-
program.unshiftContainer(
|
125522
|
-
"body",
|
125523
|
-
t3.importDeclaration(
|
125524
|
-
[t3.importSpecifier(t3.identifier(localName), t3.identifier("c"))],
|
125525
|
-
t3.stringLiteral(moduleName)
|
125526
|
-
)
|
125527
|
-
);
|
125457
|
+
// src/Utils/ComponentDeclaration.ts
|
125458
|
+
function isComponentDeclaration(node) {
|
125459
|
+
return Object.prototype.hasOwnProperty.call(node, "__componentDeclaration");
|
125528
125460
|
}
|
125529
125461
|
|
125530
|
-
// src/
|
125531
|
-
|
125532
|
-
|
125533
|
-
* Any errors will panic the compiler by throwing an exception, which will
|
125534
|
-
* bubble up to the nearest exception handler above the Forget transform.
|
125535
|
-
* If Forget is invoked through `BabelPluginReactCompiler`, this will at the least
|
125536
|
-
* skip Forget compilation for the rest of current file.
|
125537
|
-
*/
|
125538
|
-
"all_errors",
|
125539
|
-
/*
|
125540
|
-
* Panic by throwing an exception only on critical or unrecognized errors.
|
125541
|
-
* For all other errors, skip the erroring function without inserting
|
125542
|
-
* a Forget-compiled version (i.e. same behavior as noEmit).
|
125543
|
-
*/
|
125544
|
-
"critical_errors",
|
125545
|
-
// Never panic by throwing an exception.
|
125546
|
-
"none"
|
125547
|
-
]);
|
125548
|
-
var CompilerReactTargetSchema = z.union([
|
125549
|
-
z.literal("17"),
|
125550
|
-
z.literal("18"),
|
125551
|
-
z.literal("19"),
|
125552
|
-
/**
|
125553
|
-
* Used exclusively for Meta apps which are guaranteed to have compatible
|
125554
|
-
* react runtime and compiler versions. Note that only the FB-internal bundles
|
125555
|
-
* re-export useMemoCache (see
|
125556
|
-
* https://github.com/facebook/react/blob/5b0ef217ef32333a8e56f39be04327c89efa346f/packages/react/index.fb.js#L68-L70),
|
125557
|
-
* so this option is invalid / creates runtime errors for open-source users.
|
125558
|
-
*/
|
125559
|
-
z.object({
|
125560
|
-
kind: z.literal("donotuse_meta_internal"),
|
125561
|
-
runtimeModule: z.string().default("react")
|
125562
|
-
})
|
125563
|
-
]);
|
125564
|
-
var CompilationModeSchema = z.enum([
|
125565
|
-
/*
|
125566
|
-
* Compiles functions annotated with "use forget" or component/hook-like functions.
|
125567
|
-
* This latter includes:
|
125568
|
-
* * Components declared with component syntax.
|
125569
|
-
* * Functions which can be inferred to be a component or hook:
|
125570
|
-
* - Be named like a hook or component. This logic matches the ESLint rule.
|
125571
|
-
* - *and* create JSX and/or call a hook. This is an additional check to help prevent
|
125572
|
-
* false positives, since compilation has a greater impact than linting.
|
125573
|
-
* This is the default mode
|
125574
|
-
*/
|
125575
|
-
"infer",
|
125576
|
-
// Compile only components using Flow component syntax and hooks using hook syntax.
|
125577
|
-
"syntax",
|
125578
|
-
// Compile only functions which are explicitly annotated with "use forget"
|
125579
|
-
"annotation",
|
125580
|
-
// Compile all top-level functions
|
125581
|
-
"all"
|
125582
|
-
]);
|
125583
|
-
var defaultOptions = {
|
125584
|
-
compilationMode: "infer",
|
125585
|
-
panicThreshold: "none",
|
125586
|
-
environment: parseEnvironmentConfig({}).unwrap(),
|
125587
|
-
logger: null,
|
125588
|
-
gating: null,
|
125589
|
-
noEmit: false,
|
125590
|
-
eslintSuppressionRules: null,
|
125591
|
-
flowSuppressions: true,
|
125592
|
-
ignoreUseNoForget: false,
|
125593
|
-
sources: (filename) => {
|
125594
|
-
return filename.indexOf("node_modules") === -1;
|
125595
|
-
},
|
125596
|
-
enableReanimatedCheck: true,
|
125597
|
-
target: "19"
|
125598
|
-
};
|
125599
|
-
function parsePluginOptions(obj) {
|
125600
|
-
if (obj == null || typeof obj !== "object") {
|
125601
|
-
return defaultOptions;
|
125602
|
-
}
|
125603
|
-
const parsedOptions = /* @__PURE__ */ Object.create(null);
|
125604
|
-
for (let [key2, value] of Object.entries(obj)) {
|
125605
|
-
if (typeof value === "string") {
|
125606
|
-
value = value.toLowerCase();
|
125607
|
-
}
|
125608
|
-
if (isCompilerFlag(key2)) {
|
125609
|
-
switch (key2) {
|
125610
|
-
case "environment": {
|
125611
|
-
const environmentResult = parseEnvironmentConfig(value);
|
125612
|
-
if (environmentResult.isErr()) {
|
125613
|
-
CompilerError.throwInvalidConfig({
|
125614
|
-
reason: "Error in validating environment config. This is an advanced setting and not meant to be used directly",
|
125615
|
-
description: environmentResult.unwrapErr().toString(),
|
125616
|
-
suggestions: null,
|
125617
|
-
loc: null
|
125618
|
-
});
|
125619
|
-
}
|
125620
|
-
parsedOptions[key2] = environmentResult.unwrap();
|
125621
|
-
break;
|
125622
|
-
}
|
125623
|
-
case "target": {
|
125624
|
-
parsedOptions[key2] = parseTargetConfig(value);
|
125625
|
-
break;
|
125626
|
-
}
|
125627
|
-
case "gating": {
|
125628
|
-
if (value == null) {
|
125629
|
-
parsedOptions[key2] = null;
|
125630
|
-
} else {
|
125631
|
-
parsedOptions[key2] = tryParseExternalFunction(value);
|
125632
|
-
}
|
125633
|
-
break;
|
125634
|
-
}
|
125635
|
-
default: {
|
125636
|
-
parsedOptions[key2] = value;
|
125637
|
-
}
|
125638
|
-
}
|
125639
|
-
}
|
125640
|
-
}
|
125641
|
-
return __spreadValues(__spreadValues({}, defaultOptions), parsedOptions);
|
125642
|
-
}
|
125643
|
-
function parseTargetConfig(value) {
|
125644
|
-
const parsed = CompilerReactTargetSchema.safeParse(value);
|
125645
|
-
if (parsed.success) {
|
125646
|
-
return parsed.data;
|
125647
|
-
} else {
|
125648
|
-
CompilerError.throwInvalidConfig({
|
125649
|
-
reason: "Not a valid target",
|
125650
|
-
description: `${fromZodError(parsed.error)}`,
|
125651
|
-
suggestions: null,
|
125652
|
-
loc: null
|
125653
|
-
});
|
125654
|
-
}
|
125655
|
-
}
|
125656
|
-
function isCompilerFlag(s) {
|
125657
|
-
return hasOwnProperty2(defaultOptions, s);
|
125462
|
+
// src/Utils/HookDeclaration.ts
|
125463
|
+
function isHookDeclaration(node) {
|
125464
|
+
return Object.prototype.hasOwnProperty.call(node, "__hookDeclaration");
|
125658
125465
|
}
|
125659
125466
|
|
125660
125467
|
// src/Entrypoint/Pipeline.ts
|
@@ -129463,7 +129270,7 @@ _catchHandlers = new WeakMap();
|
|
129463
129270
|
_controlFlowStack = new WeakMap();
|
129464
129271
|
|
129465
129272
|
// src/ReactiveScopes/CodegenReactiveFunction.ts
|
129466
|
-
var
|
129273
|
+
var t3 = __toESM(require("@babel/types"));
|
129467
129274
|
var import_crypto = require("crypto");
|
129468
129275
|
|
129469
129276
|
// src/ReactiveScopes/MemoizeFbtAndMacroOperandsInSameScope.ts
|
@@ -129629,9 +129436,10 @@ function codegenFunction(fn, {
|
|
129629
129436
|
const compiled = compileResult.unwrap();
|
129630
129437
|
const hookGuard = fn.env.config.enableEmitHookGuards;
|
129631
129438
|
if (hookGuard != null && fn.env.isInferredMemoEnabled) {
|
129632
|
-
compiled.body =
|
129439
|
+
compiled.body = t3.blockStatement([
|
129633
129440
|
createHookGuard(
|
129634
129441
|
hookGuard,
|
129442
|
+
fn.env.programContext,
|
129635
129443
|
compiled.body.body,
|
129636
129444
|
0 /* PushHookGuard */,
|
129637
129445
|
1 /* PopHookGuard */
|
@@ -129641,12 +129449,13 @@ function codegenFunction(fn, {
|
|
129641
129449
|
const cacheCount = compiled.memoSlotsUsed;
|
129642
129450
|
if (cacheCount !== 0) {
|
129643
129451
|
const preface = [];
|
129452
|
+
const useMemoCacheIdentifier = fn.env.programContext.addMemoCacheImport().name;
|
129644
129453
|
preface.push(
|
129645
|
-
|
129646
|
-
|
129647
|
-
|
129648
|
-
|
129649
|
-
|
129454
|
+
t3.variableDeclaration("const", [
|
129455
|
+
t3.variableDeclarator(
|
129456
|
+
t3.identifier(cx.synthesizeName("$")),
|
129457
|
+
t3.callExpression(t3.identifier(useMemoCacheIdentifier), [
|
129458
|
+
t3.numericLiteral(cacheCount)
|
129650
129459
|
])
|
129651
129460
|
)
|
129652
129461
|
])
|
@@ -129654,60 +129463,60 @@ function codegenFunction(fn, {
|
|
129654
129463
|
if (fastRefreshState !== null) {
|
129655
129464
|
const index = cx.synthesizeName("$i");
|
129656
129465
|
preface.push(
|
129657
|
-
|
129658
|
-
|
129466
|
+
t3.ifStatement(
|
129467
|
+
t3.binaryExpression(
|
129659
129468
|
"!==",
|
129660
|
-
|
129661
|
-
|
129662
|
-
|
129469
|
+
t3.memberExpression(
|
129470
|
+
t3.identifier(cx.synthesizeName("$")),
|
129471
|
+
t3.numericLiteral(fastRefreshState.cacheIndex),
|
129663
129472
|
true
|
129664
129473
|
),
|
129665
|
-
|
129474
|
+
t3.stringLiteral(fastRefreshState.hash)
|
129666
129475
|
),
|
129667
|
-
|
129668
|
-
|
129669
|
-
|
129670
|
-
|
129476
|
+
t3.blockStatement([
|
129477
|
+
t3.forStatement(
|
129478
|
+
t3.variableDeclaration("let", [
|
129479
|
+
t3.variableDeclarator(t3.identifier(index), t3.numericLiteral(0))
|
129671
129480
|
]),
|
129672
|
-
|
129481
|
+
t3.binaryExpression(
|
129673
129482
|
"<",
|
129674
|
-
|
129675
|
-
|
129483
|
+
t3.identifier(index),
|
129484
|
+
t3.numericLiteral(cacheCount)
|
129676
129485
|
),
|
129677
|
-
|
129486
|
+
t3.assignmentExpression(
|
129678
129487
|
"+=",
|
129679
|
-
|
129680
|
-
|
129488
|
+
t3.identifier(index),
|
129489
|
+
t3.numericLiteral(1)
|
129681
129490
|
),
|
129682
|
-
|
129683
|
-
|
129684
|
-
|
129491
|
+
t3.blockStatement([
|
129492
|
+
t3.expressionStatement(
|
129493
|
+
t3.assignmentExpression(
|
129685
129494
|
"=",
|
129686
|
-
|
129687
|
-
|
129688
|
-
|
129495
|
+
t3.memberExpression(
|
129496
|
+
t3.identifier(cx.synthesizeName("$")),
|
129497
|
+
t3.identifier(index),
|
129689
129498
|
true
|
129690
129499
|
),
|
129691
|
-
|
129692
|
-
|
129693
|
-
|
129694
|
-
|
129500
|
+
t3.callExpression(
|
129501
|
+
t3.memberExpression(
|
129502
|
+
t3.identifier("Symbol"),
|
129503
|
+
t3.identifier("for")
|
129695
129504
|
),
|
129696
|
-
[
|
129505
|
+
[t3.stringLiteral(MEMO_CACHE_SENTINEL)]
|
129697
129506
|
)
|
129698
129507
|
)
|
129699
129508
|
)
|
129700
129509
|
])
|
129701
129510
|
),
|
129702
|
-
|
129703
|
-
|
129511
|
+
t3.expressionStatement(
|
129512
|
+
t3.assignmentExpression(
|
129704
129513
|
"=",
|
129705
|
-
|
129706
|
-
|
129707
|
-
|
129514
|
+
t3.memberExpression(
|
129515
|
+
t3.identifier(cx.synthesizeName("$")),
|
129516
|
+
t3.numericLiteral(fastRefreshState.cacheIndex),
|
129708
129517
|
true
|
129709
129518
|
),
|
129710
|
-
|
129519
|
+
t3.stringLiteral(fastRefreshState.hash)
|
129711
129520
|
)
|
129712
129521
|
)
|
129713
129522
|
])
|
@@ -129718,30 +129527,43 @@ function codegenFunction(fn, {
|
|
129718
129527
|
}
|
129719
129528
|
const emitInstrumentForget = fn.env.config.enableEmitInstrumentForget;
|
129720
129529
|
if (emitInstrumentForget != null && fn.id != null && fn.env.isInferredMemoEnabled) {
|
129721
|
-
|
129722
|
-
|
129723
|
-
|
129724
|
-
|
129725
|
-
|
129726
|
-
|
129530
|
+
const gating = emitInstrumentForget.gating != null ? t3.identifier(
|
129531
|
+
fn.env.programContext.addImportSpecifier(
|
129532
|
+
emitInstrumentForget.gating
|
129533
|
+
).name
|
129534
|
+
) : null;
|
129535
|
+
const globalGating = emitInstrumentForget.globalGating != null ? t3.identifier(emitInstrumentForget.globalGating) : null;
|
129536
|
+
if (emitInstrumentForget.globalGating != null) {
|
129537
|
+
const assertResult = fn.env.programContext.assertGlobalBinding(
|
129538
|
+
emitInstrumentForget.globalGating
|
129727
129539
|
);
|
129728
|
-
|
129729
|
-
|
129540
|
+
if (assertResult.isErr()) {
|
129541
|
+
return assertResult;
|
129542
|
+
}
|
129543
|
+
}
|
129544
|
+
let ifTest;
|
129545
|
+
if (gating != null && globalGating != null) {
|
129546
|
+
ifTest = t3.logicalExpression("&&", globalGating, gating);
|
129547
|
+
} else if (gating != null) {
|
129548
|
+
ifTest = gating;
|
129730
129549
|
} else {
|
129731
|
-
CompilerError.invariant(
|
129550
|
+
CompilerError.invariant(globalGating != null, {
|
129732
129551
|
reason: "Bad config not caught! Expected at least one of gating or globalGating",
|
129733
129552
|
loc: null,
|
129734
129553
|
suggestions: null
|
129735
129554
|
});
|
129736
|
-
|
129737
|
-
}
|
129738
|
-
const
|
129739
|
-
|
129740
|
-
|
129741
|
-
|
129742
|
-
|
129743
|
-
|
129744
|
-
)
|
129555
|
+
ifTest = globalGating;
|
129556
|
+
}
|
129557
|
+
const instrumentFnIdentifier = fn.env.programContext.addImportSpecifier(
|
129558
|
+
emitInstrumentForget.fn
|
129559
|
+
).name;
|
129560
|
+
const test = t3.ifStatement(
|
129561
|
+
ifTest,
|
129562
|
+
t3.expressionStatement(
|
129563
|
+
t3.callExpression(t3.identifier(instrumentFnIdentifier), [
|
129564
|
+
t3.stringLiteral(fn.id),
|
129565
|
+
t3.stringLiteral((_b = fn.env.filename) != null ? _b : "")
|
129566
|
+
])
|
129745
129567
|
)
|
129746
129568
|
);
|
129747
129569
|
compiled.body.body.unshift(test);
|
@@ -129780,7 +129602,7 @@ function codegenReactiveFunction(cx, fn) {
|
|
129780
129602
|
}
|
129781
129603
|
const params = fn.params.map((param) => convertParameter(param));
|
129782
129604
|
const body = codegenBlock(cx, fn.body);
|
129783
|
-
body.directives = fn.directives.map((d) =>
|
129605
|
+
body.directives = fn.directives.map((d) => t3.directive(t3.directiveLiteral(d)));
|
129784
129606
|
const statements = body.body;
|
129785
129607
|
if (statements.length !== 0) {
|
129786
129608
|
const last = statements[statements.length - 1];
|
@@ -129796,7 +129618,7 @@ function codegenReactiveFunction(cx, fn) {
|
|
129796
129618
|
return Ok({
|
129797
129619
|
type: "CodegenFunction",
|
129798
129620
|
loc: fn.loc,
|
129799
|
-
id: fn.id !== null ?
|
129621
|
+
id: fn.id !== null ? t3.identifier(fn.id) : null,
|
129800
129622
|
params,
|
129801
129623
|
body,
|
129802
129624
|
generator: fn.generator,
|
@@ -129807,8 +129629,9 @@ function codegenReactiveFunction(cx, fn) {
|
|
129807
129629
|
prunedMemoBlocks: countMemoBlockVisitor.prunedMemoBlocks,
|
129808
129630
|
prunedMemoValues: countMemoBlockVisitor.prunedMemoValues,
|
129809
129631
|
outlined: [],
|
129810
|
-
|
129811
|
-
|
129632
|
+
hasFireRewrite: fn.env.hasFireRewrite,
|
129633
|
+
hasInferredEffect: fn.env.hasInferredEffect,
|
129634
|
+
inferredEffectLocations: fn.env.inferredEffectLocations
|
129812
129635
|
});
|
129813
129636
|
}
|
129814
129637
|
var CountMemoBlockVisitor = class extends ReactiveFunctionVisitor {
|
@@ -129835,7 +129658,7 @@ function convertParameter(param) {
|
|
129835
129658
|
if (param.kind === "Identifier") {
|
129836
129659
|
return convertIdentifier(param.identifier);
|
129837
129660
|
} else {
|
129838
|
-
return
|
129661
|
+
return t3.restElement(convertIdentifier(param.place.identifier));
|
129839
129662
|
}
|
129840
129663
|
}
|
129841
129664
|
var _nextCacheIndex, _declarations;
|
@@ -129929,8 +129752,8 @@ function codegenBlockNoReset(cx, block) {
|
|
129929
129752
|
if (item.label !== null && !item.label.implicit) {
|
129930
129753
|
const block2 = statement.type === "BlockStatement" && statement.body.length === 1 ? statement.body[0] : statement;
|
129931
129754
|
statements.push(
|
129932
|
-
|
129933
|
-
|
129755
|
+
t3.labeledStatement(
|
129756
|
+
t3.identifier(codegenLabel(item.label.id)),
|
129934
129757
|
block2
|
129935
129758
|
)
|
129936
129759
|
);
|
@@ -129949,16 +129772,20 @@ function codegenBlockNoReset(cx, block) {
|
|
129949
129772
|
}
|
129950
129773
|
}
|
129951
129774
|
}
|
129952
|
-
return
|
129775
|
+
return t3.blockStatement(statements);
|
129953
129776
|
}
|
129954
129777
|
function wrapCacheDep(cx, value) {
|
129955
129778
|
if (cx.env.config.enableEmitFreeze != null && cx.env.isInferredMemoEnabled) {
|
129956
|
-
|
129957
|
-
|
129958
|
-
|
129959
|
-
|
129960
|
-
|
129961
|
-
),
|
129779
|
+
const emitFreezeIdentifier = cx.env.programContext.addImportSpecifier(
|
129780
|
+
cx.env.config.enableEmitFreeze
|
129781
|
+
).name;
|
129782
|
+
cx.env.programContext.assertGlobalBinding(EMIT_FREEZE_GLOBAL_GATING, cx.env.scope).unwrap();
|
129783
|
+
return t3.conditionalExpression(
|
129784
|
+
t3.identifier(EMIT_FREEZE_GLOBAL_GATING),
|
129785
|
+
t3.callExpression(t3.identifier(emitFreezeIdentifier), [
|
129786
|
+
value,
|
129787
|
+
t3.stringLiteral(cx.fnName)
|
129788
|
+
]),
|
129962
129789
|
value
|
129963
129790
|
);
|
129964
129791
|
} else {
|
@@ -129975,20 +129802,20 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129975
129802
|
for (const dep of [...scope.dependencies].sort(compareScopeDependency)) {
|
129976
129803
|
const index = cx.nextCacheIndex;
|
129977
129804
|
changeExpressionComments.push(printDependencyComment(dep));
|
129978
|
-
const comparison =
|
129805
|
+
const comparison = t3.binaryExpression(
|
129979
129806
|
"!==",
|
129980
|
-
|
129981
|
-
|
129982
|
-
|
129807
|
+
t3.memberExpression(
|
129808
|
+
t3.identifier(cx.synthesizeName("$")),
|
129809
|
+
t3.numericLiteral(index),
|
129983
129810
|
true
|
129984
129811
|
),
|
129985
129812
|
codegenDependency(cx, dep)
|
129986
129813
|
);
|
129987
129814
|
if (cx.env.config.enableChangeVariableCodegen) {
|
129988
|
-
const changeIdentifier =
|
129815
|
+
const changeIdentifier = t3.identifier(cx.synthesizeName(`c_${index}`));
|
129989
129816
|
statements.push(
|
129990
|
-
|
129991
|
-
|
129817
|
+
t3.variableDeclaration("const", [
|
129818
|
+
t3.variableDeclarator(changeIdentifier, comparison)
|
129992
129819
|
])
|
129993
129820
|
);
|
129994
129821
|
changeExpressions.push(changeIdentifier);
|
@@ -129996,12 +129823,12 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
129996
129823
|
changeExpressions.push(comparison);
|
129997
129824
|
}
|
129998
129825
|
cacheStoreStatements.push(
|
129999
|
-
|
130000
|
-
|
129826
|
+
t3.expressionStatement(
|
129827
|
+
t3.assignmentExpression(
|
130001
129828
|
"=",
|
130002
|
-
|
130003
|
-
|
130004
|
-
|
129829
|
+
t3.memberExpression(
|
129830
|
+
t3.identifier(cx.synthesizeName("$")),
|
129831
|
+
t3.numericLiteral(index),
|
130005
129832
|
true
|
130006
129833
|
),
|
130007
129834
|
codegenDependency(cx, dep)
|
@@ -130029,7 +129856,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130029
129856
|
outputComments.push(name.name);
|
130030
129857
|
if (!cx.hasDeclared(identifier4)) {
|
130031
129858
|
statements.push(
|
130032
|
-
|
129859
|
+
t3.variableDeclaration("let", [t3.variableDeclarator(name)])
|
130033
129860
|
);
|
130034
129861
|
}
|
130035
129862
|
cacheLoads.push({ name, index, value: wrapCacheDep(cx, name) });
|
@@ -130049,7 +129876,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130049
129876
|
if (acc == null) {
|
130050
129877
|
return ident;
|
130051
129878
|
}
|
130052
|
-
return
|
129879
|
+
return t3.logicalExpression("||", acc, ident);
|
130053
129880
|
},
|
130054
129881
|
null
|
130055
129882
|
);
|
@@ -130060,16 +129887,16 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130060
129887
|
loc: null,
|
130061
129888
|
suggestions: null
|
130062
129889
|
});
|
130063
|
-
testCondition =
|
129890
|
+
testCondition = t3.binaryExpression(
|
130064
129891
|
"===",
|
130065
|
-
|
130066
|
-
|
130067
|
-
|
129892
|
+
t3.memberExpression(
|
129893
|
+
t3.identifier(cx.synthesizeName("$")),
|
129894
|
+
t3.numericLiteral(firstOutputIndex),
|
130068
129895
|
true
|
130069
129896
|
),
|
130070
|
-
|
130071
|
-
|
130072
|
-
[
|
129897
|
+
t3.callExpression(
|
129898
|
+
t3.memberExpression(t3.identifier("Symbol"), t3.identifier("for")),
|
129899
|
+
[t3.stringLiteral(MEMO_CACHE_SENTINEL)]
|
130073
129900
|
)
|
130074
129901
|
);
|
130075
129902
|
}
|
@@ -130082,81 +129909,82 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130082
129909
|
loc: null
|
130083
129910
|
}
|
130084
129911
|
);
|
130085
|
-
testCondition =
|
129912
|
+
testCondition = t3.logicalExpression(
|
130086
129913
|
"||",
|
130087
129914
|
testCondition,
|
130088
|
-
|
129915
|
+
t3.booleanLiteral(true)
|
130089
129916
|
);
|
130090
129917
|
}
|
130091
129918
|
let computationBlock = codegenBlock(cx, block);
|
130092
129919
|
let memoStatement;
|
130093
|
-
|
129920
|
+
const detectionFunction = cx.env.config.enableChangeDetectionForDebugging;
|
129921
|
+
if (detectionFunction != null && changeExpressions.length > 0) {
|
130094
129922
|
const loc = typeof scope.loc === "symbol" ? "unknown location" : `(${scope.loc.start.line}:${scope.loc.end.line})`;
|
130095
|
-
const
|
129923
|
+
const importedDetectionFunctionIdentifier = cx.env.programContext.addImportSpecifier(detectionFunction).name;
|
130096
129924
|
const cacheLoadOldValueStatements = [];
|
130097
129925
|
const changeDetectionStatements = [];
|
130098
129926
|
const idempotenceDetectionStatements = [];
|
130099
129927
|
for (const { name, index, value } of cacheLoads) {
|
130100
129928
|
const loadName = cx.synthesizeName(`old$${name.name}`);
|
130101
|
-
const slot =
|
130102
|
-
|
130103
|
-
|
129929
|
+
const slot = t3.memberExpression(
|
129930
|
+
t3.identifier(cx.synthesizeName("$")),
|
129931
|
+
t3.numericLiteral(index),
|
130104
129932
|
true
|
130105
129933
|
);
|
130106
129934
|
cacheStoreStatements.push(
|
130107
|
-
|
129935
|
+
t3.expressionStatement(t3.assignmentExpression("=", slot, value))
|
130108
129936
|
);
|
130109
129937
|
cacheLoadOldValueStatements.push(
|
130110
|
-
|
130111
|
-
|
129938
|
+
t3.variableDeclaration("let", [
|
129939
|
+
t3.variableDeclarator(t3.identifier(loadName), slot)
|
130112
129940
|
])
|
130113
129941
|
);
|
130114
129942
|
changeDetectionStatements.push(
|
130115
|
-
|
130116
|
-
|
130117
|
-
|
130118
|
-
|
130119
|
-
|
130120
|
-
|
130121
|
-
|
130122
|
-
|
129943
|
+
t3.expressionStatement(
|
129944
|
+
t3.callExpression(t3.identifier(importedDetectionFunctionIdentifier), [
|
129945
|
+
t3.identifier(loadName),
|
129946
|
+
t3.cloneNode(name, true),
|
129947
|
+
t3.stringLiteral(name.name),
|
129948
|
+
t3.stringLiteral(cx.fnName),
|
129949
|
+
t3.stringLiteral("cached"),
|
129950
|
+
t3.stringLiteral(loc)
|
130123
129951
|
])
|
130124
129952
|
)
|
130125
129953
|
);
|
130126
129954
|
idempotenceDetectionStatements.push(
|
130127
|
-
|
130128
|
-
|
130129
|
-
|
130130
|
-
|
130131
|
-
|
130132
|
-
|
130133
|
-
|
130134
|
-
|
129955
|
+
t3.expressionStatement(
|
129956
|
+
t3.callExpression(t3.identifier(importedDetectionFunctionIdentifier), [
|
129957
|
+
t3.cloneNode(slot, true),
|
129958
|
+
t3.cloneNode(name, true),
|
129959
|
+
t3.stringLiteral(name.name),
|
129960
|
+
t3.stringLiteral(cx.fnName),
|
129961
|
+
t3.stringLiteral("recomputed"),
|
129962
|
+
t3.stringLiteral(loc)
|
130135
129963
|
])
|
130136
129964
|
)
|
130137
129965
|
);
|
130138
129966
|
idempotenceDetectionStatements.push(
|
130139
|
-
|
129967
|
+
t3.expressionStatement(t3.assignmentExpression("=", name, slot))
|
130140
129968
|
);
|
130141
129969
|
}
|
130142
129970
|
const condition = cx.synthesizeName("condition");
|
130143
|
-
const recomputationBlock =
|
130144
|
-
memoStatement =
|
129971
|
+
const recomputationBlock = t3.cloneNode(computationBlock, true);
|
129972
|
+
memoStatement = t3.blockStatement([
|
130145
129973
|
...computationBlock.body,
|
130146
|
-
|
130147
|
-
|
129974
|
+
t3.variableDeclaration("let", [
|
129975
|
+
t3.variableDeclarator(t3.identifier(condition), testCondition)
|
130148
129976
|
]),
|
130149
|
-
|
130150
|
-
|
130151
|
-
|
129977
|
+
t3.ifStatement(
|
129978
|
+
t3.unaryExpression("!", t3.identifier(condition)),
|
129979
|
+
t3.blockStatement([
|
130152
129980
|
...cacheLoadOldValueStatements,
|
130153
129981
|
...changeDetectionStatements
|
130154
129982
|
])
|
130155
129983
|
),
|
130156
129984
|
...cacheStoreStatements,
|
130157
|
-
|
130158
|
-
|
130159
|
-
|
129985
|
+
t3.ifStatement(
|
129986
|
+
t3.identifier(condition),
|
129987
|
+
t3.blockStatement([
|
130160
129988
|
...recomputationBlock.body,
|
130161
129989
|
...idempotenceDetectionStatements
|
130162
129990
|
])
|
@@ -130165,12 +129993,12 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130165
129993
|
} else {
|
130166
129994
|
for (const { name, index, value } of cacheLoads) {
|
130167
129995
|
cacheStoreStatements.push(
|
130168
|
-
|
130169
|
-
|
129996
|
+
t3.expressionStatement(
|
129997
|
+
t3.assignmentExpression(
|
130170
129998
|
"=",
|
130171
|
-
|
130172
|
-
|
130173
|
-
|
129999
|
+
t3.memberExpression(
|
130000
|
+
t3.identifier(cx.synthesizeName("$")),
|
130001
|
+
t3.numericLiteral(index),
|
130174
130002
|
true
|
130175
130003
|
),
|
130176
130004
|
value
|
@@ -130178,13 +130006,13 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130178
130006
|
)
|
130179
130007
|
);
|
130180
130008
|
cacheLoadStatements.push(
|
130181
|
-
|
130182
|
-
|
130009
|
+
t3.expressionStatement(
|
130010
|
+
t3.assignmentExpression(
|
130183
130011
|
"=",
|
130184
130012
|
name,
|
130185
|
-
|
130186
|
-
|
130187
|
-
|
130013
|
+
t3.memberExpression(
|
130014
|
+
t3.identifier(cx.synthesizeName("$")),
|
130015
|
+
t3.numericLiteral(index),
|
130188
130016
|
true
|
130189
130017
|
)
|
130190
130018
|
)
|
@@ -130192,15 +130020,15 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130192
130020
|
);
|
130193
130021
|
}
|
130194
130022
|
computationBlock.body.push(...cacheStoreStatements);
|
130195
|
-
memoStatement =
|
130023
|
+
memoStatement = t3.ifStatement(
|
130196
130024
|
testCondition,
|
130197
130025
|
computationBlock,
|
130198
|
-
|
130026
|
+
t3.blockStatement(cacheLoadStatements)
|
130199
130027
|
);
|
130200
130028
|
}
|
130201
130029
|
if (cx.env.config.enableMemoizationComments) {
|
130202
130030
|
if (changeExpressionComments.length) {
|
130203
|
-
|
130031
|
+
t3.addComment(
|
130204
130032
|
memoStatement,
|
130205
130033
|
"leading",
|
130206
130034
|
` check if ${printDelimitedCommentList(
|
@@ -130209,20 +130037,20 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130209
130037
|
)} changed`,
|
130210
130038
|
true
|
130211
130039
|
);
|
130212
|
-
|
130040
|
+
t3.addComment(
|
130213
130041
|
memoStatement,
|
130214
130042
|
"leading",
|
130215
130043
|
` "useMemo" for ${printDelimitedCommentList(outputComments, "and")}:`,
|
130216
130044
|
true
|
130217
130045
|
);
|
130218
130046
|
} else {
|
130219
|
-
|
130047
|
+
t3.addComment(
|
130220
130048
|
memoStatement,
|
130221
130049
|
"leading",
|
130222
130050
|
" cache value with no dependencies",
|
130223
130051
|
true
|
130224
130052
|
);
|
130225
|
-
|
130053
|
+
t3.addComment(
|
130226
130054
|
memoStatement,
|
130227
130055
|
"leading",
|
130228
130056
|
` "useMemo" for ${printDelimitedCommentList(outputComments, "and")}:`,
|
@@ -130230,7 +130058,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130230
130058
|
);
|
130231
130059
|
}
|
130232
130060
|
if (computationBlock.body.length > 0) {
|
130233
|
-
|
130061
|
+
t3.addComment(
|
130234
130062
|
computationBlock.body[0],
|
130235
130063
|
"leading",
|
130236
130064
|
` Inputs changed, recompute`,
|
@@ -130238,7 +130066,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130238
130066
|
);
|
130239
130067
|
}
|
130240
130068
|
if (cacheLoadStatements.length > 0) {
|
130241
|
-
|
130069
|
+
t3.addComment(
|
130242
130070
|
cacheLoadStatements[0],
|
130243
130071
|
"leading",
|
130244
130072
|
` Inputs did not change, use cached value`,
|
@@ -130260,16 +130088,16 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
130260
130088
|
);
|
130261
130089
|
const name = earlyReturnValue.value.name.value;
|
130262
130090
|
statements.push(
|
130263
|
-
|
130264
|
-
|
130091
|
+
t3.ifStatement(
|
130092
|
+
t3.binaryExpression(
|
130265
130093
|
"!==",
|
130266
|
-
|
130267
|
-
|
130268
|
-
|
130269
|
-
[
|
130094
|
+
t3.identifier(name),
|
130095
|
+
t3.callExpression(
|
130096
|
+
t3.memberExpression(t3.identifier("Symbol"), t3.identifier("for")),
|
130097
|
+
[t3.stringLiteral(EARLY_RETURN_SENTINEL)]
|
130270
130098
|
)
|
130271
130099
|
),
|
130272
|
-
|
130100
|
+
t3.blockStatement([t3.returnStatement(t3.identifier(name))])
|
130273
130101
|
)
|
130274
130102
|
);
|
130275
130103
|
}
|
@@ -130280,20 +130108,20 @@ function codegenTerminal(cx, terminal) {
|
|
130280
130108
|
if (terminal.targetKind === "implicit") {
|
130281
130109
|
return null;
|
130282
130110
|
}
|
130283
|
-
return
|
130284
|
-
terminal.targetKind === "labeled" ?
|
130111
|
+
return t3.breakStatement(
|
130112
|
+
terminal.targetKind === "labeled" ? t3.identifier(codegenLabel(terminal.target)) : null
|
130285
130113
|
);
|
130286
130114
|
}
|
130287
130115
|
case "continue": {
|
130288
130116
|
if (terminal.targetKind === "implicit") {
|
130289
130117
|
return null;
|
130290
130118
|
}
|
130291
|
-
return
|
130292
|
-
terminal.targetKind === "labeled" ?
|
130119
|
+
return t3.continueStatement(
|
130120
|
+
terminal.targetKind === "labeled" ? t3.identifier(codegenLabel(terminal.target)) : null
|
130293
130121
|
);
|
130294
130122
|
}
|
130295
130123
|
case "for": {
|
130296
|
-
return
|
130124
|
+
return t3.forStatement(
|
130297
130125
|
codegenForInit(cx, terminal.init),
|
130298
130126
|
codegenInstructionValueToExpression(cx, terminal.test),
|
130299
130127
|
terminal.update !== null ? codegenInstructionValueToExpression(cx, terminal.update) : null,
|
@@ -130367,13 +130195,13 @@ function codegenTerminal(cx, terminal) {
|
|
130367
130195
|
`Unhandled lvalue kind: ${iterableItem.value.lvalue.kind}`
|
130368
130196
|
);
|
130369
130197
|
}
|
130370
|
-
return
|
130198
|
+
return t3.forInStatement(
|
130371
130199
|
/*
|
130372
130200
|
* Special handling here since we only want the VariableDeclarators without any inits
|
130373
130201
|
* This needs to be updated when we handle non-trivial ForOf inits
|
130374
130202
|
*/
|
130375
130203
|
createVariableDeclaration(iterableItem.value.loc, varDeclKind, [
|
130376
|
-
|
130204
|
+
t3.variableDeclarator(lval, null)
|
130377
130205
|
]),
|
130378
130206
|
codegenInstructionValueToExpression(cx, iterableCollection.value),
|
130379
130207
|
codegenBlock(cx, terminal.loop)
|
@@ -130449,13 +130277,13 @@ function codegenTerminal(cx, terminal) {
|
|
130449
130277
|
`Unhandled lvalue kind: ${iterableItem.value.lvalue.kind}`
|
130450
130278
|
);
|
130451
130279
|
}
|
130452
|
-
return
|
130280
|
+
return t3.forOfStatement(
|
130453
130281
|
/*
|
130454
130282
|
* Special handling here since we only want the VariableDeclarators without any inits
|
130455
130283
|
* This needs to be updated when we handle non-trivial ForOf inits
|
130456
130284
|
*/
|
130457
130285
|
createVariableDeclaration(iterableItem.value.loc, varDeclKind, [
|
130458
|
-
|
130286
|
+
t3.variableDeclarator(lval, null)
|
130459
130287
|
]),
|
130460
130288
|
codegenInstructionValueToExpression(cx, iterableCollection),
|
130461
130289
|
codegenBlock(cx, terminal.loop)
|
@@ -130471,35 +130299,35 @@ function codegenTerminal(cx, terminal) {
|
|
130471
130299
|
alternate = block;
|
130472
130300
|
}
|
130473
130301
|
}
|
130474
|
-
return
|
130302
|
+
return t3.ifStatement(test, consequent, alternate);
|
130475
130303
|
}
|
130476
130304
|
case "return": {
|
130477
130305
|
const value = codegenPlaceToExpression(cx, terminal.value);
|
130478
130306
|
if (value.type === "Identifier" && value.name === "undefined") {
|
130479
|
-
return
|
130307
|
+
return t3.returnStatement();
|
130480
130308
|
}
|
130481
|
-
return
|
130309
|
+
return t3.returnStatement(value);
|
130482
130310
|
}
|
130483
130311
|
case "switch": {
|
130484
|
-
return
|
130312
|
+
return t3.switchStatement(
|
130485
130313
|
codegenPlaceToExpression(cx, terminal.test),
|
130486
130314
|
terminal.cases.map((case_) => {
|
130487
130315
|
const test = case_.test !== null ? codegenPlaceToExpression(cx, case_.test) : null;
|
130488
130316
|
const block = codegenBlock(cx, case_.block);
|
130489
|
-
return
|
130317
|
+
return t3.switchCase(test, [block]);
|
130490
130318
|
})
|
130491
130319
|
);
|
130492
130320
|
}
|
130493
130321
|
case "throw": {
|
130494
|
-
return
|
130322
|
+
return t3.throwStatement(codegenPlaceToExpression(cx, terminal.value));
|
130495
130323
|
}
|
130496
130324
|
case "do-while": {
|
130497
130325
|
const test = codegenInstructionValueToExpression(cx, terminal.test);
|
130498
|
-
return
|
130326
|
+
return t3.doWhileStatement(test, codegenBlock(cx, terminal.loop));
|
130499
130327
|
}
|
130500
130328
|
case "while": {
|
130501
130329
|
const test = codegenInstructionValueToExpression(cx, terminal.test);
|
130502
|
-
return
|
130330
|
+
return t3.whileStatement(test, codegenBlock(cx, terminal.loop));
|
130503
130331
|
}
|
130504
130332
|
case "label": {
|
130505
130333
|
return codegenBlock(cx, terminal.block);
|
@@ -130510,9 +130338,9 @@ function codegenTerminal(cx, terminal) {
|
|
130510
130338
|
catchParam = convertIdentifier(terminal.handlerBinding.identifier);
|
130511
130339
|
cx.temp.set(terminal.handlerBinding.identifier.declarationId, null);
|
130512
130340
|
}
|
130513
|
-
return
|
130341
|
+
return t3.tryStatement(
|
130514
130342
|
codegenBlock(cx, terminal.block),
|
130515
|
-
|
130343
|
+
t3.catchClause(catchParam, codegenBlock(cx, terminal.handler))
|
130516
130344
|
);
|
130517
130345
|
}
|
130518
130346
|
default: {
|
@@ -130575,7 +130403,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130575
130403
|
suggestions: null
|
130576
130404
|
});
|
130577
130405
|
return createVariableDeclaration(instr.loc, "const", [
|
130578
|
-
|
130406
|
+
t3.variableDeclarator(codegenLValue(cx, lvalue), value)
|
130579
130407
|
]);
|
130580
130408
|
}
|
130581
130409
|
case "Function" /* Function */: {
|
@@ -130615,7 +130443,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130615
130443
|
suggestions: null
|
130616
130444
|
});
|
130617
130445
|
return createVariableDeclaration(instr.loc, "let", [
|
130618
|
-
|
130446
|
+
t3.variableDeclarator(codegenLValue(cx, lvalue), value)
|
130619
130447
|
]);
|
130620
130448
|
}
|
130621
130449
|
case "Reassign" /* Reassign */: {
|
@@ -130625,7 +130453,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130625
130453
|
loc: instr.value.loc,
|
130626
130454
|
suggestions: null
|
130627
130455
|
});
|
130628
|
-
const expr =
|
130456
|
+
const expr = t3.assignmentExpression(
|
130629
130457
|
"=",
|
130630
130458
|
codegenLValue(cx, lvalue),
|
130631
130459
|
value
|
@@ -130646,7 +130474,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130646
130474
|
}
|
130647
130475
|
}
|
130648
130476
|
case "Catch" /* Catch */: {
|
130649
|
-
return
|
130477
|
+
return t3.emptyStatement();
|
130650
130478
|
}
|
130651
130479
|
case "HoistedLet" /* HoistedLet */:
|
130652
130480
|
case "HoistedConst" /* HoistedConst */:
|
@@ -130665,7 +130493,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
130665
130493
|
} else if (instr.value.kind === "StartMemoize" || instr.value.kind === "FinishMemoize") {
|
130666
130494
|
return null;
|
130667
130495
|
} else if (instr.value.kind === "Debugger") {
|
130668
|
-
return
|
130496
|
+
return t3.debuggerStatement();
|
130669
130497
|
} else if (instr.value.kind === "ObjectMethod") {
|
130670
130498
|
CompilerError.invariant(instr.lvalue, {
|
130671
130499
|
reason: "Expected object methods to have a temp lvalue",
|
@@ -130721,7 +130549,7 @@ function codegenForInit(cx, init) {
|
|
130721
130549
|
description: null,
|
130722
130550
|
suggestions: null
|
130723
130551
|
});
|
130724
|
-
return
|
130552
|
+
return t3.variableDeclaration(kind, declarators);
|
130725
130553
|
} else {
|
130726
130554
|
return codegenInstructionValueToExpression(cx, init);
|
130727
130555
|
}
|
@@ -130760,17 +130588,17 @@ function codegenDependency(cx, dependency) {
|
|
130760
130588
|
if (dependency.path.length !== 0) {
|
130761
130589
|
const hasOptional = dependency.path.some((path) => path.optional);
|
130762
130590
|
for (const path of dependency.path) {
|
130763
|
-
const property = typeof path.property === "string" ?
|
130591
|
+
const property = typeof path.property === "string" ? t3.identifier(path.property) : t3.numericLiteral(path.property);
|
130764
130592
|
const isComputed = typeof path.property !== "string";
|
130765
130593
|
if (hasOptional) {
|
130766
|
-
object =
|
130594
|
+
object = t3.optionalMemberExpression(
|
130767
130595
|
object,
|
130768
130596
|
property,
|
130769
130597
|
isComputed,
|
130770
130598
|
path.optional
|
130771
130599
|
);
|
130772
130600
|
} else {
|
130773
|
-
object =
|
130601
|
+
object = t3.memberExpression(object, property, isComputed);
|
130774
130602
|
}
|
130775
130603
|
}
|
130776
130604
|
}
|
@@ -130785,60 +130613,60 @@ function withLoc(fn) {
|
|
130785
130613
|
return node;
|
130786
130614
|
};
|
130787
130615
|
}
|
130788
|
-
var createBinaryExpression = withLoc(
|
130789
|
-
var createExpressionStatement = withLoc(
|
130790
|
-
var _createLabelledStatement = withLoc(
|
130791
|
-
var createVariableDeclaration = withLoc(
|
130792
|
-
var createFunctionDeclaration = withLoc(
|
130793
|
-
var _createWhileStatement = withLoc(
|
130794
|
-
var createTaggedTemplateExpression = withLoc(
|
130795
|
-
var createLogicalExpression = withLoc(
|
130796
|
-
var createSequenceExpression = withLoc(
|
130797
|
-
var createConditionalExpression = withLoc(
|
130798
|
-
var createTemplateLiteral = withLoc(
|
130799
|
-
var createJsxNamespacedName = withLoc(
|
130800
|
-
var createJsxElement = withLoc(
|
130801
|
-
var createJsxAttribute = withLoc(
|
130802
|
-
var createJsxIdentifier = withLoc(
|
130803
|
-
var createJsxExpressionContainer = withLoc(
|
130804
|
-
var createJsxText = withLoc(
|
130805
|
-
var createJsxClosingElement = withLoc(
|
130806
|
-
var createJsxOpeningElement = withLoc(
|
130807
|
-
var createStringLiteral = withLoc(
|
130808
|
-
function createHookGuard(guard, stmts, before, after) {
|
130616
|
+
var createBinaryExpression = withLoc(t3.binaryExpression);
|
130617
|
+
var createExpressionStatement = withLoc(t3.expressionStatement);
|
130618
|
+
var _createLabelledStatement = withLoc(t3.labeledStatement);
|
130619
|
+
var createVariableDeclaration = withLoc(t3.variableDeclaration);
|
130620
|
+
var createFunctionDeclaration = withLoc(t3.functionDeclaration);
|
130621
|
+
var _createWhileStatement = withLoc(t3.whileStatement);
|
130622
|
+
var createTaggedTemplateExpression = withLoc(t3.taggedTemplateExpression);
|
130623
|
+
var createLogicalExpression = withLoc(t3.logicalExpression);
|
130624
|
+
var createSequenceExpression = withLoc(t3.sequenceExpression);
|
130625
|
+
var createConditionalExpression = withLoc(t3.conditionalExpression);
|
130626
|
+
var createTemplateLiteral = withLoc(t3.templateLiteral);
|
130627
|
+
var createJsxNamespacedName = withLoc(t3.jsxNamespacedName);
|
130628
|
+
var createJsxElement = withLoc(t3.jsxElement);
|
130629
|
+
var createJsxAttribute = withLoc(t3.jsxAttribute);
|
130630
|
+
var createJsxIdentifier = withLoc(t3.jsxIdentifier);
|
130631
|
+
var createJsxExpressionContainer = withLoc(t3.jsxExpressionContainer);
|
130632
|
+
var createJsxText = withLoc(t3.jsxText);
|
130633
|
+
var createJsxClosingElement = withLoc(t3.jsxClosingElement);
|
130634
|
+
var createJsxOpeningElement = withLoc(t3.jsxOpeningElement);
|
130635
|
+
var createStringLiteral = withLoc(t3.stringLiteral);
|
130636
|
+
function createHookGuard(guard, context, stmts, before, after) {
|
130637
|
+
const guardFnName = context.addImportSpecifier(guard).name;
|
130809
130638
|
function createHookGuardImpl(kind) {
|
130810
|
-
return
|
130811
|
-
|
130812
|
-
t4.numericLiteral(kind)
|
130813
|
-
])
|
130639
|
+
return t3.expressionStatement(
|
130640
|
+
t3.callExpression(t3.identifier(guardFnName), [t3.numericLiteral(kind)])
|
130814
130641
|
);
|
130815
130642
|
}
|
130816
|
-
return
|
130817
|
-
|
130643
|
+
return t3.tryStatement(
|
130644
|
+
t3.blockStatement([createHookGuardImpl(before), ...stmts]),
|
130818
130645
|
null,
|
130819
|
-
|
130646
|
+
t3.blockStatement([createHookGuardImpl(after)])
|
130820
130647
|
);
|
130821
130648
|
}
|
130822
130649
|
function createCallExpression(env, callee, args, loc, isHook2) {
|
130823
|
-
const callExpr =
|
130650
|
+
const callExpr = t3.callExpression(callee, args);
|
130824
130651
|
if (loc != null && loc != GeneratedSource) {
|
130825
130652
|
callExpr.loc = loc;
|
130826
130653
|
}
|
130827
130654
|
const hookGuard = env.config.enableEmitHookGuards;
|
130828
130655
|
if (hookGuard != null && isHook2 && env.isInferredMemoEnabled) {
|
130829
|
-
const iife =
|
130656
|
+
const iife = t3.functionExpression(
|
130830
130657
|
null,
|
130831
130658
|
[],
|
130832
|
-
|
130659
|
+
t3.blockStatement([
|
130833
130660
|
createHookGuard(
|
130834
130661
|
hookGuard,
|
130835
|
-
|
130662
|
+
env.programContext,
|
130663
|
+
[t3.returnStatement(callExpr)],
|
130836
130664
|
2 /* AllowHook */,
|
130837
130665
|
3 /* DisallowHook */
|
130838
130666
|
)
|
130839
130667
|
])
|
130840
130668
|
);
|
130841
|
-
return
|
130669
|
+
return t3.callExpression(iife, []);
|
130842
130670
|
} else {
|
130843
130671
|
return callExpr;
|
130844
130672
|
}
|
@@ -130847,21 +130675,21 @@ function codegenLabel(id) {
|
|
130847
130675
|
return `bb${id}`;
|
130848
130676
|
}
|
130849
130677
|
function codegenInstruction(cx, instr, value) {
|
130850
|
-
if (
|
130678
|
+
if (t3.isStatement(value)) {
|
130851
130679
|
return value;
|
130852
130680
|
}
|
130853
130681
|
if (instr.lvalue === null) {
|
130854
|
-
return
|
130682
|
+
return t3.expressionStatement(convertValueToExpression(value));
|
130855
130683
|
}
|
130856
130684
|
if (instr.lvalue.identifier.name === null) {
|
130857
130685
|
cx.temp.set(instr.lvalue.identifier.declarationId, value);
|
130858
|
-
return
|
130686
|
+
return t3.emptyStatement();
|
130859
130687
|
} else {
|
130860
130688
|
const expressionValue = convertValueToExpression(value);
|
130861
130689
|
if (cx.hasDeclared(instr.lvalue.identifier)) {
|
130862
130690
|
return createExpressionStatement(
|
130863
130691
|
instr.loc,
|
130864
|
-
|
130692
|
+
t3.assignmentExpression(
|
130865
130693
|
"=",
|
130866
130694
|
convertIdentifier(instr.lvalue.identifier),
|
130867
130695
|
expressionValue
|
@@ -130869,7 +130697,7 @@ function codegenInstruction(cx, instr, value) {
|
|
130869
130697
|
);
|
130870
130698
|
} else {
|
130871
130699
|
return createVariableDeclaration(instr.loc, "const", [
|
130872
|
-
|
130700
|
+
t3.variableDeclarator(
|
130873
130701
|
convertIdentifier(instr.lvalue.identifier),
|
130874
130702
|
expressionValue
|
130875
130703
|
)
|
@@ -130896,12 +130724,12 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130896
130724
|
if (element.kind === "Identifier") {
|
130897
130725
|
return codegenPlaceToExpression(cx, element);
|
130898
130726
|
} else if (element.kind === "Spread") {
|
130899
|
-
return
|
130727
|
+
return t3.spreadElement(codegenPlaceToExpression(cx, element.place));
|
130900
130728
|
} else {
|
130901
130729
|
return null;
|
130902
130730
|
}
|
130903
130731
|
});
|
130904
|
-
value =
|
130732
|
+
value = t3.arrayExpression(elements);
|
130905
130733
|
break;
|
130906
130734
|
}
|
130907
130735
|
case "BinaryExpression": {
|
@@ -130916,7 +130744,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130916
130744
|
break;
|
130917
130745
|
}
|
130918
130746
|
case "UnaryExpression": {
|
130919
|
-
value =
|
130747
|
+
value = t3.unaryExpression(
|
130920
130748
|
instrValue.operator,
|
130921
130749
|
// todo
|
130922
130750
|
codegenPlaceToExpression(cx, instrValue.value)
|
@@ -130931,9 +130759,9 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130931
130759
|
if (cx.env.config.enableForest) {
|
130932
130760
|
const callee2 = codegenPlaceToExpression(cx, instrValue.callee);
|
130933
130761
|
const args2 = instrValue.args.map((arg) => codegenArgument(cx, arg));
|
130934
|
-
value =
|
130762
|
+
value = t3.callExpression(callee2, args2);
|
130935
130763
|
if (instrValue.typeArguments != null) {
|
130936
|
-
value.typeArguments =
|
130764
|
+
value.typeArguments = t3.typeParameterInstantiation(
|
130937
130765
|
instrValue.typeArguments
|
130938
130766
|
);
|
130939
130767
|
}
|
@@ -130959,13 +130787,13 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130959
130787
|
switch (optionalValue.type) {
|
130960
130788
|
case "OptionalCallExpression":
|
130961
130789
|
case "CallExpression": {
|
130962
|
-
CompilerError.invariant(
|
130790
|
+
CompilerError.invariant(t3.isExpression(optionalValue.callee), {
|
130963
130791
|
reason: "v8 intrinsics are validated during lowering",
|
130964
130792
|
description: null,
|
130965
130793
|
loc: (_a = optionalValue.callee.loc) != null ? _a : null,
|
130966
130794
|
suggestions: null
|
130967
130795
|
});
|
130968
|
-
value =
|
130796
|
+
value = t3.optionalCallExpression(
|
130969
130797
|
optionalValue.callee,
|
130970
130798
|
optionalValue.arguments,
|
130971
130799
|
instrValue.optional
|
@@ -130975,13 +130803,13 @@ function codegenInstructionValue(cx, instrValue) {
|
|
130975
130803
|
case "OptionalMemberExpression":
|
130976
130804
|
case "MemberExpression": {
|
130977
130805
|
const property = optionalValue.property;
|
130978
|
-
CompilerError.invariant(
|
130806
|
+
CompilerError.invariant(t3.isExpression(property), {
|
130979
130807
|
reason: "Private names are validated during lowering",
|
130980
130808
|
description: null,
|
130981
130809
|
loc: (_b = property.loc) != null ? _b : null,
|
130982
130810
|
suggestions: null
|
130983
130811
|
});
|
130984
|
-
value =
|
130812
|
+
value = t3.optionalMemberExpression(
|
130985
130813
|
optionalValue.object,
|
130986
130814
|
property,
|
130987
130815
|
optionalValue.computed,
|
@@ -131004,7 +130832,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131004
130832
|
const isHook2 = getHookKind(cx.env, instrValue.property.identifier) != null;
|
131005
130833
|
const memberExpr = codegenPlaceToExpression(cx, instrValue.property);
|
131006
130834
|
CompilerError.invariant(
|
131007
|
-
|
130835
|
+
t3.isMemberExpression(memberExpr) || t3.isOptionalMemberExpression(memberExpr),
|
131008
130836
|
{
|
131009
130837
|
reason: `[Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a \`${memberExpr.type}\``,
|
131010
130838
|
description: null,
|
@@ -131013,7 +130841,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131013
130841
|
}
|
131014
130842
|
);
|
131015
130843
|
CompilerError.invariant(
|
131016
|
-
|
130844
|
+
t3.isNodesEquivalent(
|
131017
130845
|
memberExpr.object,
|
131018
130846
|
codegenPlaceToExpression(cx, instrValue.receiver)
|
131019
130847
|
),
|
@@ -131037,7 +130865,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131037
130865
|
case "NewExpression": {
|
131038
130866
|
const callee = codegenPlaceToExpression(cx, instrValue.callee);
|
131039
130867
|
const args = instrValue.args.map((arg) => codegenArgument(cx, arg));
|
131040
|
-
value =
|
130868
|
+
value = t3.newExpression(callee, args);
|
131041
130869
|
break;
|
131042
130870
|
}
|
131043
130871
|
case "ObjectExpression": {
|
@@ -131049,7 +130877,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131049
130877
|
case "property": {
|
131050
130878
|
const value2 = codegenPlaceToExpression(cx, property.place);
|
131051
130879
|
properties.push(
|
131052
|
-
|
130880
|
+
t3.objectProperty(
|
131053
130881
|
key2,
|
131054
130882
|
value2,
|
131055
130883
|
property.key.kind === "computed",
|
@@ -131079,7 +130907,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131079
130907
|
),
|
131080
130908
|
reactiveFunction
|
131081
130909
|
).unwrap();
|
131082
|
-
const babelNode =
|
130910
|
+
const babelNode = t3.objectMethod(
|
131083
130911
|
"method",
|
131084
130912
|
key2,
|
131085
130913
|
fn.params,
|
@@ -131099,11 +130927,11 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131099
130927
|
}
|
131100
130928
|
} else {
|
131101
130929
|
properties.push(
|
131102
|
-
|
130930
|
+
t3.spreadElement(codegenPlaceToExpression(cx, property.place))
|
131103
130931
|
);
|
131104
130932
|
}
|
131105
130933
|
}
|
131106
|
-
value =
|
130934
|
+
value = t3.objectExpression(properties);
|
131107
130935
|
break;
|
131108
130936
|
}
|
131109
130937
|
case "JSXText": {
|
@@ -131115,7 +130943,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131115
130943
|
for (const attribute of instrValue.props) {
|
131116
130944
|
attributes.push(codegenJsxAttribute(cx, attribute));
|
131117
130945
|
}
|
131118
|
-
let tagValue = instrValue.tag.kind === "Identifier" ? codegenPlaceToExpression(cx, instrValue.tag) :
|
130946
|
+
let tagValue = instrValue.tag.kind === "Identifier" ? codegenPlaceToExpression(cx, instrValue.tag) : t3.stringLiteral(instrValue.tag.name);
|
131119
130947
|
let tag;
|
131120
130948
|
if (tagValue.type === "Identifier") {
|
131121
130949
|
tag = createJsxIdentifier(instrValue.tag.loc, tagValue.name);
|
@@ -131168,16 +130996,16 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131168
130996
|
break;
|
131169
130997
|
}
|
131170
130998
|
case "JsxFragment": {
|
131171
|
-
value =
|
131172
|
-
|
131173
|
-
|
130999
|
+
value = t3.jsxFragment(
|
131000
|
+
t3.jsxOpeningFragment(),
|
131001
|
+
t3.jsxClosingFragment(),
|
131174
131002
|
instrValue.children.map((child) => codegenJsxElement(cx, child))
|
131175
131003
|
);
|
131176
131004
|
break;
|
131177
131005
|
}
|
131178
131006
|
case "UnsupportedNode": {
|
131179
131007
|
const node = instrValue.node;
|
131180
|
-
if (!
|
131008
|
+
if (!t3.isExpression(node)) {
|
131181
131009
|
return node;
|
131182
131010
|
}
|
131183
131011
|
value = node;
|
@@ -131188,19 +131016,19 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131188
131016
|
case "PropertyDelete": {
|
131189
131017
|
let memberExpr;
|
131190
131018
|
if (typeof instrValue.property === "string") {
|
131191
|
-
memberExpr =
|
131019
|
+
memberExpr = t3.memberExpression(
|
131192
131020
|
codegenPlaceToExpression(cx, instrValue.object),
|
131193
|
-
|
131021
|
+
t3.identifier(instrValue.property)
|
131194
131022
|
);
|
131195
131023
|
} else {
|
131196
|
-
memberExpr =
|
131024
|
+
memberExpr = t3.memberExpression(
|
131197
131025
|
codegenPlaceToExpression(cx, instrValue.object),
|
131198
|
-
|
131026
|
+
t3.numericLiteral(instrValue.property),
|
131199
131027
|
true
|
131200
131028
|
);
|
131201
131029
|
}
|
131202
131030
|
if (instrValue.kind === "PropertyStore") {
|
131203
|
-
value =
|
131031
|
+
value = t3.assignmentExpression(
|
131204
131032
|
"=",
|
131205
131033
|
memberExpr,
|
131206
131034
|
codegenPlaceToExpression(cx, instrValue.value)
|
@@ -131208,14 +131036,14 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131208
131036
|
} else if (instrValue.kind === "PropertyLoad") {
|
131209
131037
|
value = memberExpr;
|
131210
131038
|
} else {
|
131211
|
-
value =
|
131039
|
+
value = t3.unaryExpression("delete", memberExpr);
|
131212
131040
|
}
|
131213
131041
|
break;
|
131214
131042
|
}
|
131215
131043
|
case "ComputedStore": {
|
131216
|
-
value =
|
131044
|
+
value = t3.assignmentExpression(
|
131217
131045
|
"=",
|
131218
|
-
|
131046
|
+
t3.memberExpression(
|
131219
131047
|
codegenPlaceToExpression(cx, instrValue.object),
|
131220
131048
|
codegenPlaceToExpression(cx, instrValue.property),
|
131221
131049
|
true
|
@@ -131227,13 +131055,13 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131227
131055
|
case "ComputedLoad": {
|
131228
131056
|
const object = codegenPlaceToExpression(cx, instrValue.object);
|
131229
131057
|
const property = codegenPlaceToExpression(cx, instrValue.property);
|
131230
|
-
value =
|
131058
|
+
value = t3.memberExpression(object, property, true);
|
131231
131059
|
break;
|
131232
131060
|
}
|
131233
131061
|
case "ComputedDelete": {
|
131234
|
-
value =
|
131062
|
+
value = t3.unaryExpression(
|
131235
131063
|
"delete",
|
131236
|
-
|
131064
|
+
t3.memberExpression(
|
131237
131065
|
codegenPlaceToExpression(cx, instrValue.object),
|
131238
131066
|
codegenPlaceToExpression(cx, instrValue.property),
|
131239
131067
|
true
|
@@ -131270,10 +131098,10 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131270
131098
|
body = stmt.argument;
|
131271
131099
|
}
|
131272
131100
|
}
|
131273
|
-
value =
|
131101
|
+
value = t3.arrowFunctionExpression(fn.params, body, fn.async);
|
131274
131102
|
} else {
|
131275
|
-
value =
|
131276
|
-
(_h = fn.id) != null ? _h : instrValue.name != null ?
|
131103
|
+
value = t3.functionExpression(
|
131104
|
+
(_h = fn.id) != null ? _h : instrValue.name != null ? t3.identifier(instrValue.name) : null,
|
131277
131105
|
fn.params,
|
131278
131106
|
fn.body,
|
131279
131107
|
fn.generator,
|
@@ -131286,20 +131114,27 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131286
131114
|
value = createTaggedTemplateExpression(
|
131287
131115
|
instrValue.loc,
|
131288
131116
|
codegenPlaceToExpression(cx, instrValue.tag),
|
131289
|
-
|
131117
|
+
t3.templateLiteral([t3.templateElement(instrValue.value)], [])
|
131290
131118
|
);
|
131291
131119
|
break;
|
131292
131120
|
}
|
131293
131121
|
case "TypeCastExpression": {
|
131294
|
-
if (
|
131295
|
-
|
131296
|
-
|
131297
|
-
|
131298
|
-
|
131122
|
+
if (t3.isTSType(instrValue.typeAnnotation)) {
|
131123
|
+
if (instrValue.typeAnnotationKind === "satisfies") {
|
131124
|
+
value = t3.tsSatisfiesExpression(
|
131125
|
+
codegenPlaceToExpression(cx, instrValue.value),
|
131126
|
+
instrValue.typeAnnotation
|
131127
|
+
);
|
131128
|
+
} else {
|
131129
|
+
value = t3.tsAsExpression(
|
131130
|
+
codegenPlaceToExpression(cx, instrValue.value),
|
131131
|
+
instrValue.typeAnnotation
|
131132
|
+
);
|
131133
|
+
}
|
131299
131134
|
} else {
|
131300
|
-
value =
|
131135
|
+
value = t3.typeCastExpression(
|
131301
131136
|
codegenPlaceToExpression(cx, instrValue.value),
|
131302
|
-
|
131137
|
+
t3.typeAnnotation(instrValue.typeAnnotation)
|
131303
131138
|
);
|
131304
131139
|
}
|
131305
131140
|
break;
|
@@ -131335,7 +131170,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131335
131170
|
if (stmt.type === "ExpressionStatement") {
|
131336
131171
|
return stmt.expression;
|
131337
131172
|
} else {
|
131338
|
-
if (
|
131173
|
+
if (t3.isVariableDeclaration(stmt)) {
|
131339
131174
|
const declarator = stmt.declarations[0];
|
131340
131175
|
cx.errors.push({
|
131341
131176
|
reason: `(CodegenReactiveFunction::codegenInstructionValue) Cannot declare variables in a value block, tried to declare '${declarator.id.name}'`,
|
@@ -131343,7 +131178,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131343
131178
|
loc: (_a2 = declarator.loc) != null ? _a2 : null,
|
131344
131179
|
suggestions: null
|
131345
131180
|
});
|
131346
|
-
return
|
131181
|
+
return t3.stringLiteral(`TODO handle ${declarator.id}`);
|
131347
131182
|
} else {
|
131348
131183
|
cx.errors.push({
|
131349
131184
|
reason: `(CodegenReactiveFunction::codegenInstructionValue) Handle conversion of ${stmt.type} to expression`,
|
@@ -131351,7 +131186,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131351
131186
|
loc: (_b2 = stmt.loc) != null ? _b2 : null,
|
131352
131187
|
suggestions: null
|
131353
131188
|
});
|
131354
|
-
return
|
131189
|
+
return t3.stringLiteral(`TODO handle ${stmt.type}`);
|
131355
131190
|
}
|
131356
131191
|
}
|
131357
131192
|
});
|
@@ -131368,28 +131203,28 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131368
131203
|
case "TemplateLiteral": {
|
131369
131204
|
value = createTemplateLiteral(
|
131370
131205
|
instrValue.loc,
|
131371
|
-
instrValue.quasis.map((q) =>
|
131206
|
+
instrValue.quasis.map((q) => t3.templateElement(q)),
|
131372
131207
|
instrValue.subexprs.map((p) => codegenPlaceToExpression(cx, p))
|
131373
131208
|
);
|
131374
131209
|
break;
|
131375
131210
|
}
|
131376
131211
|
case "LoadGlobal": {
|
131377
|
-
value =
|
131212
|
+
value = t3.identifier(instrValue.binding.name);
|
131378
131213
|
break;
|
131379
131214
|
}
|
131380
131215
|
case "RegExpLiteral": {
|
131381
|
-
value =
|
131216
|
+
value = t3.regExpLiteral(instrValue.pattern, instrValue.flags);
|
131382
131217
|
break;
|
131383
131218
|
}
|
131384
131219
|
case "MetaProperty": {
|
131385
|
-
value =
|
131386
|
-
|
131387
|
-
|
131220
|
+
value = t3.metaProperty(
|
131221
|
+
t3.identifier(instrValue.meta),
|
131222
|
+
t3.identifier(instrValue.property)
|
131388
131223
|
);
|
131389
131224
|
break;
|
131390
131225
|
}
|
131391
131226
|
case "Await": {
|
131392
|
-
value =
|
131227
|
+
value = t3.awaitExpression(codegenPlaceToExpression(cx, instrValue.value));
|
131393
131228
|
break;
|
131394
131229
|
}
|
131395
131230
|
case "GetIterator": {
|
@@ -131405,7 +131240,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131405
131240
|
break;
|
131406
131241
|
}
|
131407
131242
|
case "PostfixUpdate": {
|
131408
|
-
value =
|
131243
|
+
value = t3.updateExpression(
|
131409
131244
|
instrValue.operation,
|
131410
131245
|
codegenPlaceToExpression(cx, instrValue.lvalue),
|
131411
131246
|
false
|
@@ -131413,7 +131248,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131413
131248
|
break;
|
131414
131249
|
}
|
131415
131250
|
case "PrefixUpdate": {
|
131416
|
-
value =
|
131251
|
+
value = t3.updateExpression(
|
131417
131252
|
instrValue.operation,
|
131418
131253
|
codegenPlaceToExpression(cx, instrValue.lvalue),
|
131419
131254
|
true
|
@@ -131430,7 +131265,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131430
131265
|
suggestions: null
|
131431
131266
|
}
|
131432
131267
|
);
|
131433
|
-
value =
|
131268
|
+
value = t3.assignmentExpression(
|
131434
131269
|
"=",
|
131435
131270
|
codegenLValue(cx, instrValue.lvalue.place),
|
131436
131271
|
codegenPlaceToExpression(cx, instrValue.value)
|
@@ -131438,9 +131273,9 @@ function codegenInstructionValue(cx, instrValue) {
|
|
131438
131273
|
break;
|
131439
131274
|
}
|
131440
131275
|
case "StoreGlobal": {
|
131441
|
-
value =
|
131276
|
+
value = t3.assignmentExpression(
|
131442
131277
|
"=",
|
131443
|
-
|
131278
|
+
t3.identifier(instrValue.name),
|
131444
131279
|
codegenPlaceToExpression(cx, instrValue.value)
|
131445
131280
|
);
|
131446
131281
|
break;
|
@@ -131502,7 +131337,7 @@ function codegenJsxAttribute(cx, attribute) {
|
|
131502
131337
|
return createJsxAttribute(attribute.place.loc, propName, value);
|
131503
131338
|
}
|
131504
131339
|
case "JsxSpreadAttribute": {
|
131505
|
-
return
|
131340
|
+
return t3.jsxSpreadAttribute(
|
131506
131341
|
codegenPlaceToExpression(cx, attribute.argument)
|
131507
131342
|
);
|
131508
131343
|
}
|
@@ -131557,9 +131392,9 @@ function convertMemberExpressionToJsx(expr) {
|
|
131557
131392
|
loc: (_a = expr.loc) != null ? _a : null,
|
131558
131393
|
suggestions: null
|
131559
131394
|
});
|
131560
|
-
const property =
|
131395
|
+
const property = t3.jsxIdentifier(expr.property.name);
|
131561
131396
|
if (expr.object.type === "Identifier") {
|
131562
|
-
return
|
131397
|
+
return t3.jsxMemberExpression(t3.jsxIdentifier(expr.object.name), property);
|
131563
131398
|
} else {
|
131564
131399
|
CompilerError.invariant(expr.object.type === "MemberExpression", {
|
131565
131400
|
reason: "Expected JSX member expression to be an identifier or nested member expression",
|
@@ -131568,20 +131403,20 @@ function convertMemberExpressionToJsx(expr) {
|
|
131568
131403
|
suggestions: null
|
131569
131404
|
});
|
131570
131405
|
const object = convertMemberExpressionToJsx(expr.object);
|
131571
|
-
return
|
131406
|
+
return t3.jsxMemberExpression(object, property);
|
131572
131407
|
}
|
131573
131408
|
}
|
131574
131409
|
function codegenObjectPropertyKey(cx, key2) {
|
131575
131410
|
switch (key2.kind) {
|
131576
131411
|
case "string": {
|
131577
|
-
return
|
131412
|
+
return t3.stringLiteral(key2.name);
|
131578
131413
|
}
|
131579
131414
|
case "identifier": {
|
131580
|
-
return
|
131415
|
+
return t3.identifier(key2.name);
|
131581
131416
|
}
|
131582
131417
|
case "computed": {
|
131583
131418
|
const expr = codegenPlace(cx, key2.name);
|
131584
|
-
CompilerError.invariant(
|
131419
|
+
CompilerError.invariant(t3.isExpression(expr), {
|
131585
131420
|
reason: "Expected object property key to be an expression",
|
131586
131421
|
description: null,
|
131587
131422
|
loc: key2.name.loc,
|
@@ -131590,14 +131425,14 @@ function codegenObjectPropertyKey(cx, key2) {
|
|
131590
131425
|
return expr;
|
131591
131426
|
}
|
131592
131427
|
case "number": {
|
131593
|
-
return
|
131428
|
+
return t3.numericLiteral(key2.name);
|
131594
131429
|
}
|
131595
131430
|
}
|
131596
131431
|
}
|
131597
131432
|
function codegenArrayPattern(cx, pattern) {
|
131598
131433
|
const hasHoles = !pattern.items.every((e) => e.kind !== "Hole");
|
131599
131434
|
if (hasHoles) {
|
131600
|
-
const result =
|
131435
|
+
const result = t3.arrayPattern([]);
|
131601
131436
|
for (const item of pattern.items) {
|
131602
131437
|
if (item.kind === "Hole") {
|
131603
131438
|
result.elements.push(null);
|
@@ -131607,7 +131442,7 @@ function codegenArrayPattern(cx, pattern) {
|
|
131607
131442
|
}
|
131608
131443
|
return result;
|
131609
131444
|
} else {
|
131610
|
-
return
|
131445
|
+
return t3.arrayPattern(
|
131611
131446
|
pattern.items.map((item) => {
|
131612
131447
|
if (item.kind === "Hole") {
|
131613
131448
|
return null;
|
@@ -131623,25 +131458,25 @@ function codegenLValue(cx, pattern) {
|
|
131623
131458
|
return codegenArrayPattern(cx, pattern);
|
131624
131459
|
}
|
131625
131460
|
case "ObjectPattern": {
|
131626
|
-
return
|
131461
|
+
return t3.objectPattern(
|
131627
131462
|
pattern.properties.map((property) => {
|
131628
131463
|
if (property.kind === "ObjectProperty") {
|
131629
131464
|
const key2 = codegenObjectPropertyKey(cx, property.key);
|
131630
131465
|
const value = codegenLValue(cx, property.place);
|
131631
|
-
return
|
131466
|
+
return t3.objectProperty(
|
131632
131467
|
key2,
|
131633
131468
|
value,
|
131634
131469
|
property.key.kind === "computed",
|
131635
131470
|
key2.type === "Identifier" && value.type === "Identifier" && value.name === key2.name
|
131636
131471
|
);
|
131637
131472
|
} else {
|
131638
|
-
return
|
131473
|
+
return t3.restElement(codegenLValue(cx, property.place));
|
131639
131474
|
}
|
131640
131475
|
})
|
131641
131476
|
);
|
131642
131477
|
}
|
131643
131478
|
case "Spread": {
|
131644
|
-
return
|
131479
|
+
return t3.restElement(codegenLValue(cx, pattern.place));
|
131645
131480
|
}
|
131646
131481
|
case "Identifier": {
|
131647
131482
|
return convertIdentifier(pattern.identifier);
|
@@ -131656,15 +131491,15 @@ function codegenLValue(cx, pattern) {
|
|
131656
131491
|
}
|
131657
131492
|
function codegenValue(cx, loc, value) {
|
131658
131493
|
if (typeof value === "number") {
|
131659
|
-
return
|
131494
|
+
return t3.numericLiteral(value);
|
131660
131495
|
} else if (typeof value === "boolean") {
|
131661
|
-
return
|
131496
|
+
return t3.booleanLiteral(value);
|
131662
131497
|
} else if (typeof value === "string") {
|
131663
131498
|
return createStringLiteral(loc, value);
|
131664
131499
|
} else if (value === null) {
|
131665
|
-
return
|
131500
|
+
return t3.nullLiteral();
|
131666
131501
|
} else if (value === void 0) {
|
131667
|
-
return
|
131502
|
+
return t3.identifier("undefined");
|
131668
131503
|
} else {
|
131669
131504
|
assertExhaustive(value, "Unexpected primitive value kind");
|
131670
131505
|
}
|
@@ -131673,7 +131508,7 @@ function codegenArgument(cx, arg) {
|
|
131673
131508
|
if (arg.kind === "Identifier") {
|
131674
131509
|
return codegenPlaceToExpression(cx, arg);
|
131675
131510
|
} else {
|
131676
|
-
return
|
131511
|
+
return t3.spreadElement(codegenPlaceToExpression(cx, arg.place));
|
131677
131512
|
}
|
131678
131513
|
}
|
131679
131514
|
function codegenPlaceToExpression(cx, place) {
|
@@ -131707,7 +131542,7 @@ function convertIdentifier(identifier4) {
|
|
131707
131542
|
suggestions: null
|
131708
131543
|
}
|
131709
131544
|
);
|
131710
|
-
return
|
131545
|
+
return t3.identifier(identifier4.name.value);
|
131711
131546
|
}
|
131712
131547
|
function compareScopeDependency(a, b) {
|
131713
131548
|
var _a, _b;
|
@@ -132657,6 +132492,10 @@ function pruneHoistedContexts(fn) {
|
|
132657
132492
|
const hoistedIdentifiers = /* @__PURE__ */ new Map();
|
132658
132493
|
visitReactiveFunction(fn, new Visitor3(), hoistedIdentifiers);
|
132659
132494
|
}
|
132495
|
+
var REWRITTEN_HOISTED_CONST = Symbol(
|
132496
|
+
"REWRITTEN_HOISTED_CONST"
|
132497
|
+
);
|
132498
|
+
var REWRITTEN_HOISTED_LET = Symbol("REWRITTEN_HOISTED_LET");
|
132660
132499
|
var Visitor3 = class extends ReactiveFunctionTransform {
|
132661
132500
|
transformInstruction(instruction, state) {
|
132662
132501
|
this.visitInstruction(instruction, state);
|
@@ -132681,25 +132520,64 @@ var Visitor3 = class extends ReactiveFunctionTransform {
|
|
132681
132520
|
);
|
132682
132521
|
return { kind: "remove" };
|
132683
132522
|
}
|
132684
|
-
if (instruction.value.kind === "StoreContext"
|
132523
|
+
if (instruction.value.kind === "StoreContext") {
|
132685
132524
|
const kind = state.get(
|
132686
132525
|
instruction.value.lvalue.place.identifier.declarationId
|
132687
132526
|
);
|
132688
|
-
|
132689
|
-
kind
|
132690
|
-
|
132691
|
-
|
132692
|
-
|
132693
|
-
|
132694
|
-
|
132695
|
-
|
132696
|
-
|
132697
|
-
|
132698
|
-
|
132699
|
-
|
132700
|
-
|
132527
|
+
if (kind != null) {
|
132528
|
+
CompilerError.invariant(kind !== REWRITTEN_HOISTED_CONST, {
|
132529
|
+
reason: "Expected exactly one store to a hoisted const variable",
|
132530
|
+
loc: instruction.loc
|
132531
|
+
});
|
132532
|
+
if (kind === "Const" /* Const */ || kind === "Function" /* Function */) {
|
132533
|
+
state.set(
|
132534
|
+
instruction.value.lvalue.place.identifier.declarationId,
|
132535
|
+
REWRITTEN_HOISTED_CONST
|
132536
|
+
);
|
132537
|
+
return {
|
132538
|
+
kind: "replace",
|
132539
|
+
value: {
|
132540
|
+
kind: "instruction",
|
132541
|
+
instruction: __spreadProps(__spreadValues({}, instruction), {
|
132542
|
+
value: __spreadProps(__spreadValues({}, instruction.value), {
|
132543
|
+
lvalue: __spreadProps(__spreadValues({}, instruction.value.lvalue), {
|
132544
|
+
kind
|
132545
|
+
}),
|
132546
|
+
type: null,
|
132547
|
+
kind: "StoreLocal"
|
132548
|
+
})
|
132549
|
+
})
|
132550
|
+
}
|
132551
|
+
};
|
132552
|
+
} else if (kind !== REWRITTEN_HOISTED_LET) {
|
132553
|
+
state.set(
|
132554
|
+
instruction.value.lvalue.place.identifier.declarationId,
|
132555
|
+
REWRITTEN_HOISTED_LET
|
132556
|
+
);
|
132557
|
+
return {
|
132558
|
+
kind: "replace-many",
|
132559
|
+
value: [
|
132560
|
+
{
|
132561
|
+
kind: "instruction",
|
132562
|
+
instruction: {
|
132563
|
+
id: instruction.id,
|
132564
|
+
lvalue: null,
|
132565
|
+
value: {
|
132566
|
+
kind: "DeclareContext",
|
132567
|
+
lvalue: {
|
132568
|
+
kind: "Let" /* Let */,
|
132569
|
+
place: __spreadValues({}, instruction.value.lvalue.place)
|
132570
|
+
},
|
132571
|
+
loc: instruction.value.loc
|
132572
|
+
},
|
132573
|
+
loc: instruction.loc
|
132574
|
+
}
|
132575
|
+
},
|
132576
|
+
{ kind: "instruction", instruction }
|
132577
|
+
]
|
132578
|
+
};
|
132701
132579
|
}
|
132702
|
-
}
|
132580
|
+
}
|
132703
132581
|
}
|
132704
132582
|
return { kind: "keep" };
|
132705
132583
|
}
|
@@ -135353,7 +135231,7 @@ var Visitor7 = class extends ReactiveFunctionVisitor {
|
|
135353
135231
|
// src/ReactiveScopes/RenameVariables.ts
|
135354
135232
|
function renameVariables(fn) {
|
135355
135233
|
const globals = collectReferencedGlobals(fn);
|
135356
|
-
const scopes = new Scopes(globals);
|
135234
|
+
const scopes = new Scopes(globals, fn.env.programContext);
|
135357
135235
|
renameVariablesImpl(fn, new Visitor8(), scopes);
|
135358
135236
|
return /* @__PURE__ */ new Set([...scopes.names, ...globals]);
|
135359
135237
|
}
|
@@ -135403,15 +135281,17 @@ var Visitor8 = class extends ReactiveFunctionVisitor {
|
|
135403
135281
|
renameVariablesImpl(_fn, this, _state);
|
135404
135282
|
}
|
135405
135283
|
};
|
135406
|
-
var _seen, _stack, _globals3, _Scopes_instances, lookup_fn;
|
135284
|
+
var _seen, _stack, _globals3, _programContext, _Scopes_instances, lookup_fn;
|
135407
135285
|
var Scopes = class {
|
135408
|
-
constructor(globals) {
|
135286
|
+
constructor(globals, programContext) {
|
135409
135287
|
__privateAdd(this, _Scopes_instances);
|
135410
135288
|
__privateAdd(this, _seen, /* @__PURE__ */ new Map());
|
135411
135289
|
__privateAdd(this, _stack, [/* @__PURE__ */ new Map()]);
|
135412
135290
|
__privateAdd(this, _globals3);
|
135291
|
+
__privateAdd(this, _programContext);
|
135413
135292
|
this.names = /* @__PURE__ */ new Set();
|
135414
135293
|
__privateSet(this, _globals3, globals);
|
135294
|
+
__privateSet(this, _programContext, programContext);
|
135415
135295
|
}
|
135416
135296
|
visit(identifier4) {
|
135417
135297
|
const originalName = identifier4.name;
|
@@ -135439,6 +135319,7 @@ var Scopes = class {
|
|
135439
135319
|
name = `${originalName.value}$${id++}`;
|
135440
135320
|
}
|
135441
135321
|
}
|
135322
|
+
__privateGet(this, _programContext).addNewReference(name);
|
135442
135323
|
const identifierName = makeIdentifierName(name);
|
135443
135324
|
identifier4.name = identifierName;
|
135444
135325
|
__privateGet(this, _seen).set(identifier4.declarationId, identifierName);
|
@@ -135461,6 +135342,7 @@ var Scopes = class {
|
|
135461
135342
|
_seen = new WeakMap();
|
135462
135343
|
_stack = new WeakMap();
|
135463
135344
|
_globals3 = new WeakMap();
|
135345
|
+
_programContext = new WeakMap();
|
135464
135346
|
_Scopes_instances = new WeakSet();
|
135465
135347
|
lookup_fn = function(name) {
|
135466
135348
|
for (let i = __privateGet(this, _stack).length - 1; i >= 0; i--) {
|
@@ -136624,6 +136506,7 @@ function inferEffectDependencies(fn) {
|
|
136624
136506
|
});
|
136625
136507
|
value.args.push(__spreadProps(__spreadValues({}, depsPlace), { effect: "freeze" /* Freeze */ }));
|
136626
136508
|
rewriteInstrs.set(instr.id, newInstructions);
|
136509
|
+
fn.env.inferredEffectLocations.add(callee.loc);
|
136627
136510
|
} else if (loadGlobals.has(value.args[0].identifier.id)) {
|
136628
136511
|
newInstructions.push({
|
136629
136512
|
id: makeInstructionId(0),
|
@@ -136633,6 +136516,7 @@ function inferEffectDependencies(fn) {
|
|
136633
136516
|
});
|
136634
136517
|
value.args.push(__spreadProps(__spreadValues({}, depsPlace), { effect: "freeze" /* Freeze */ }));
|
136635
136518
|
rewriteInstrs.set(instr.id, newInstructions);
|
136519
|
+
fn.env.inferredEffectLocations.add(callee.loc);
|
136636
136520
|
}
|
136637
136521
|
}
|
136638
136522
|
}
|
@@ -136654,6 +136538,7 @@ function inferEffectDependencies(fn) {
|
|
136654
136538
|
if (hasRewrite) {
|
136655
136539
|
markInstructionIds(fn.body);
|
136656
136540
|
fixScopeAndIdentifierRanges(fn.body);
|
136541
|
+
fn.env.hasInferredEffect = true;
|
136657
136542
|
}
|
136658
136543
|
}
|
136659
136544
|
function writeDependencyToInstructions(dep, reactive, env, loc) {
|
@@ -139861,7 +139746,7 @@ function propagatePhiTypes(fn) {
|
|
139861
139746
|
}
|
139862
139747
|
|
139863
139748
|
// src/Optimization/LowerContextAccess.ts
|
139864
|
-
function lowerContextAccess(fn,
|
139749
|
+
function lowerContextAccess(fn, loweredContextCalleeConfig) {
|
139865
139750
|
const contextAccess = /* @__PURE__ */ new Map();
|
139866
139751
|
const contextKeys = /* @__PURE__ */ new Map();
|
139867
139752
|
for (const [, block] of fn.body.blocks) {
|
@@ -139889,6 +139774,7 @@ function lowerContextAccess(fn, loweredContextCallee) {
|
|
139889
139774
|
}
|
139890
139775
|
}
|
139891
139776
|
}
|
139777
|
+
let importLoweredContextCallee = null;
|
139892
139778
|
if (contextAccess.size > 0 && contextKeys.size > 0) {
|
139893
139779
|
for (const [, block] of fn.body.blocks) {
|
139894
139780
|
let nextInstructions = null;
|
@@ -139896,9 +139782,12 @@ function lowerContextAccess(fn, loweredContextCallee) {
|
|
139896
139782
|
const instr = block.instructions[i];
|
139897
139783
|
const { lvalue, value } = instr;
|
139898
139784
|
if (value.kind === "CallExpression" && isUseContextHookType(value.callee.identifier) && contextKeys.has(lvalue.identifier.id)) {
|
139785
|
+
importLoweredContextCallee != null ? importLoweredContextCallee : importLoweredContextCallee = fn.env.programContext.addImportSpecifier(
|
139786
|
+
loweredContextCalleeConfig
|
139787
|
+
);
|
139899
139788
|
const loweredContextCalleeInstr = emitLoadLoweredContextCallee(
|
139900
139789
|
fn.env,
|
139901
|
-
|
139790
|
+
importLoweredContextCallee
|
139902
139791
|
);
|
139903
139792
|
if (nextInstructions === null) {
|
139904
139793
|
nextInstructions = block.instructions.slice(0, i);
|
@@ -139922,17 +139811,12 @@ function lowerContextAccess(fn, loweredContextCallee) {
|
|
139922
139811
|
}
|
139923
139812
|
markInstructionIds(fn.body);
|
139924
139813
|
inferTypes(fn);
|
139925
|
-
fn.env.hasLoweredContextAccess = true;
|
139926
139814
|
}
|
139927
139815
|
}
|
139928
|
-
function emitLoadLoweredContextCallee(env,
|
139816
|
+
function emitLoadLoweredContextCallee(env, importedLowerContextCallee) {
|
139929
139817
|
const loadGlobal = {
|
139930
139818
|
kind: "LoadGlobal",
|
139931
|
-
binding: {
|
139932
|
-
kind: "ImportNamespace",
|
139933
|
-
module: loweredContextCallee.source,
|
139934
|
-
name: loweredContextCallee.importSpecifierName
|
139935
|
-
},
|
139819
|
+
binding: __spreadValues({}, importedLowerContextCallee),
|
139936
139820
|
loc: GeneratedSource
|
139937
139821
|
};
|
139938
139822
|
return {
|
@@ -141639,7 +141523,7 @@ function process2(fn, jsx, globals) {
|
|
141639
141523
|
if (fn.fnType === "Component") {
|
141640
141524
|
return null;
|
141641
141525
|
}
|
141642
|
-
const props = collectProps(jsx);
|
141526
|
+
const props = collectProps(fn.env, jsx);
|
141643
141527
|
if (!props) return null;
|
141644
141528
|
const outlinedTag = fn.env.generateGloballyUniqueIdentifierName(null).value;
|
141645
141529
|
const newInstrs = emitOutlinedJsx(fn.env, jsx, props, outlinedTag);
|
@@ -141649,7 +141533,7 @@ function process2(fn, jsx, globals) {
|
|
141649
141533
|
outlinedFn.id = outlinedTag;
|
141650
141534
|
return { instrs: newInstrs, fn: outlinedFn };
|
141651
141535
|
}
|
141652
|
-
function collectProps(instructions) {
|
141536
|
+
function collectProps(env, instructions) {
|
141653
141537
|
let id = 1;
|
141654
141538
|
function generateName(oldName) {
|
141655
141539
|
let newName = oldName;
|
@@ -141657,6 +141541,7 @@ function collectProps(instructions) {
|
|
141657
141541
|
newName = `${oldName}${id++}`;
|
141658
141542
|
}
|
141659
141543
|
seen.add(newName);
|
141544
|
+
env.programContext.addNewReference(newName);
|
141660
141545
|
return newName;
|
141661
141546
|
}
|
141662
141547
|
const attributes = [];
|
@@ -141919,6 +141804,7 @@ function transformFire(fn) {
|
|
141919
141804
|
context.throwIfErrorsFound();
|
141920
141805
|
}
|
141921
141806
|
function replaceFireFunctions(fn, context) {
|
141807
|
+
let importedUseFire = null;
|
141922
141808
|
let hasRewrite = false;
|
141923
141809
|
for (const [, block] of fn.body.blocks) {
|
141924
141810
|
const rewriteInstrs = /* @__PURE__ */ new Map();
|
@@ -141942,7 +141828,14 @@ function replaceFireFunctions(fn, context) {
|
|
141942
141828
|
] of capturedCallees.entries()) {
|
141943
141829
|
if (!context.hasCalleeWithInsertedFire(fireCalleePlace)) {
|
141944
141830
|
context.addCalleeWithInsertedFire(fireCalleePlace);
|
141945
|
-
|
141831
|
+
importedUseFire != null ? importedUseFire : importedUseFire = fn.env.programContext.addImportSpecifier({
|
141832
|
+
source: fn.env.programContext.reactRuntimeModule,
|
141833
|
+
importSpecifierName: USE_FIRE_FUNCTION_NAME
|
141834
|
+
});
|
141835
|
+
const loadUseFireInstr = makeLoadUseFireInstruction(
|
141836
|
+
fn.env,
|
141837
|
+
importedUseFire
|
141838
|
+
);
|
141946
141839
|
const loadFireCalleeInstr = makeLoadFireCalleeInstruction(
|
141947
141840
|
fn.env,
|
141948
141841
|
fireCalleeInfo.capturedCalleeIdentifier
|
@@ -142162,18 +142055,13 @@ function ensureNoMoreFireUses(fn, context) {
|
|
142162
142055
|
}
|
142163
142056
|
}
|
142164
142057
|
}
|
142165
|
-
function makeLoadUseFireInstruction(env) {
|
142058
|
+
function makeLoadUseFireInstruction(env, importedLoadUseFire) {
|
142166
142059
|
const useFirePlace = createTemporaryPlace(env, GeneratedSource);
|
142167
142060
|
useFirePlace.effect = "read" /* Read */;
|
142168
142061
|
useFirePlace.identifier.type = DefaultNonmutatingHook;
|
142169
142062
|
const instrValue = {
|
142170
142063
|
kind: "LoadGlobal",
|
142171
|
-
binding: {
|
142172
|
-
kind: "ImportSpecifier",
|
142173
|
-
name: "useFire",
|
142174
|
-
module: "react",
|
142175
|
-
imported: "useFire"
|
142176
|
-
},
|
142064
|
+
binding: __spreadValues({}, importedLoadUseFire),
|
142177
142065
|
loc: GeneratedSource
|
142178
142066
|
};
|
142179
142067
|
return {
|
@@ -142506,7 +142394,7 @@ function validateStaticComponents(fn) {
|
|
142506
142394
|
}
|
142507
142395
|
|
142508
142396
|
// src/Entrypoint/Pipeline.ts
|
142509
|
-
function run(func, config, fnType, mode,
|
142397
|
+
function run(func, config, fnType, mode, programContext, logger, filename, code) {
|
142510
142398
|
var _a, _b;
|
142511
142399
|
const contextIdentifiers = findContextIdentifiers(func);
|
142512
142400
|
const env = new Environment(
|
@@ -142518,7 +142406,7 @@ function run(func, config, fnType, mode, useMemoCacheIdentifier, logger, filenam
|
|
142518
142406
|
logger,
|
142519
142407
|
filename,
|
142520
142408
|
code,
|
142521
|
-
|
142409
|
+
programContext
|
142522
142410
|
);
|
142523
142411
|
(_b = (_a = env.logger) == null ? void 0 : _a.debugLogIRs) == null ? void 0 : _b.call(_a, {
|
142524
142412
|
kind: "debug",
|
@@ -142834,29 +142722,19 @@ function runWithEnvironment(func, env) {
|
|
142834
142722
|
}
|
142835
142723
|
return ast;
|
142836
142724
|
}
|
142837
|
-
function compileFn(func, config, fnType, mode,
|
142725
|
+
function compileFn(func, config, fnType, mode, programContext, logger, filename, code) {
|
142838
142726
|
return run(
|
142839
142727
|
func,
|
142840
142728
|
config,
|
142841
142729
|
fnType,
|
142842
142730
|
mode,
|
142843
|
-
|
142731
|
+
programContext,
|
142844
142732
|
logger,
|
142845
142733
|
filename,
|
142846
142734
|
code
|
142847
142735
|
);
|
142848
142736
|
}
|
142849
142737
|
|
142850
|
-
// src/Utils/ComponentDeclaration.ts
|
142851
|
-
function isComponentDeclaration(node) {
|
142852
|
-
return Object.prototype.hasOwnProperty.call(node, "__componentDeclaration");
|
142853
|
-
}
|
142854
|
-
|
142855
|
-
// src/Utils/HookDeclaration.ts
|
142856
|
-
function isHookDeclaration(node) {
|
142857
|
-
return Object.prototype.hasOwnProperty.call(node, "__hookDeclaration");
|
142858
|
-
}
|
142859
|
-
|
142860
142738
|
// src/Entrypoint/Suppression.ts
|
142861
142739
|
function filterSuppressionsThatAffectFunction(suppressionRanges, fn) {
|
142862
142740
|
const suppressionsInScope = [];
|
@@ -143159,7 +143037,11 @@ function compileProgram(program, pass) {
|
|
143159
143037
|
handleError(restrictedImportsErr, pass, null);
|
143160
143038
|
return null;
|
143161
143039
|
}
|
143162
|
-
const
|
143040
|
+
const programContext = new ProgramContext2(
|
143041
|
+
program,
|
143042
|
+
pass.opts.target,
|
143043
|
+
environment.hookPattern
|
143044
|
+
);
|
143163
143045
|
const suppressions = findProgramSuppressions(
|
143164
143046
|
pass.comments,
|
143165
143047
|
(_a = pass.opts.eslintSuppressionRules) != null ? _a : DEFAULT_ESLINT_SUPPRESSIONS,
|
@@ -143196,6 +143078,7 @@ function compileProgram(program, pass) {
|
|
143196
143078
|
})
|
143197
143079
|
);
|
143198
143080
|
const retryErrors = [];
|
143081
|
+
const inferredEffectLocations = /* @__PURE__ */ new Set();
|
143199
143082
|
const processFn = (fn, fnType) => {
|
143200
143083
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
143201
143084
|
let optInDirectives = [];
|
@@ -143227,7 +143110,7 @@ function compileProgram(program, pass) {
|
|
143227
143110
|
environment,
|
143228
143111
|
fnType,
|
143229
143112
|
"all_features",
|
143230
|
-
|
143113
|
+
programContext,
|
143231
143114
|
pass.opts.logger,
|
143232
143115
|
pass.filename,
|
143233
143116
|
pass.code
|
@@ -143254,13 +143137,13 @@ function compileProgram(program, pass) {
|
|
143254
143137
|
environment,
|
143255
143138
|
fnType,
|
143256
143139
|
"no_inferred_memo",
|
143257
|
-
|
143140
|
+
programContext,
|
143258
143141
|
pass.opts.logger,
|
143259
143142
|
pass.filename,
|
143260
143143
|
pass.code
|
143261
143144
|
)
|
143262
143145
|
};
|
143263
|
-
if (!compileResult.compiledFn.hasFireRewrite && !compileResult.compiledFn.
|
143146
|
+
if (!compileResult.compiledFn.hasFireRewrite && !compileResult.compiledFn.hasInferredEffect) {
|
143264
143147
|
return null;
|
143265
143148
|
}
|
143266
143149
|
} catch (err) {
|
@@ -143299,6 +143182,9 @@ function compileProgram(program, pass) {
|
|
143299
143182
|
if (!pass.opts.noEmit) {
|
143300
143183
|
return compileResult.compiledFn;
|
143301
143184
|
}
|
143185
|
+
for (const loc of compileResult.compiledFn.inferredEffectLocations) {
|
143186
|
+
if (loc !== GeneratedSource) inferredEffectLocations.add(loc);
|
143187
|
+
}
|
143302
143188
|
return null;
|
143303
143189
|
};
|
143304
143190
|
while (queue.length !== 0) {
|
@@ -143339,84 +143225,30 @@ function compileProgram(program, pass) {
|
|
143339
143225
|
if (moduleScopeOptOutDirectives.length > 0) {
|
143340
143226
|
return null;
|
143341
143227
|
}
|
143342
|
-
|
143343
|
-
if (pass.opts.gating != null) {
|
143344
|
-
gating = {
|
143345
|
-
gatingFn: pass.opts.gating,
|
143346
|
-
referencedBeforeDeclared: getFunctionReferencedBeforeDeclarationAtTopLevel(program, compiledFns)
|
143347
|
-
};
|
143348
|
-
}
|
143349
|
-
const hasLoweredContextAccess = compiledFns.some(
|
143350
|
-
(c2) => c2.compiledFn.hasLoweredContextAccess
|
143351
|
-
);
|
143352
|
-
const externalFunctions = [];
|
143353
|
-
try {
|
143354
|
-
if (gating != null) {
|
143355
|
-
externalFunctions.push(gating.gatingFn);
|
143356
|
-
}
|
143357
|
-
const lowerContextAccess2 = environment.lowerContextAccess;
|
143358
|
-
if (lowerContextAccess2 && hasLoweredContextAccess) {
|
143359
|
-
externalFunctions.push(lowerContextAccess2);
|
143360
|
-
}
|
143361
|
-
const enableEmitInstrumentForget = environment.enableEmitInstrumentForget;
|
143362
|
-
if (enableEmitInstrumentForget != null) {
|
143363
|
-
externalFunctions.push(enableEmitInstrumentForget.fn);
|
143364
|
-
if (enableEmitInstrumentForget.gating != null) {
|
143365
|
-
externalFunctions.push(enableEmitInstrumentForget.gating);
|
143366
|
-
}
|
143367
|
-
}
|
143368
|
-
if (environment.enableEmitFreeze != null) {
|
143369
|
-
externalFunctions.push(environment.enableEmitFreeze);
|
143370
|
-
}
|
143371
|
-
if (environment.enableEmitHookGuards != null) {
|
143372
|
-
externalFunctions.push(environment.enableEmitHookGuards);
|
143373
|
-
}
|
143374
|
-
if (environment.enableChangeDetectionForDebugging != null) {
|
143375
|
-
externalFunctions.push(environment.enableChangeDetectionForDebugging);
|
143376
|
-
}
|
143377
|
-
const hasFireRewrite = compiledFns.some((c2) => c2.compiledFn.hasFireRewrite);
|
143378
|
-
if (environment.enableFire && hasFireRewrite) {
|
143379
|
-
externalFunctions.push({
|
143380
|
-
source: getReactCompilerRuntimeModule(pass.opts),
|
143381
|
-
importSpecifierName: "useFire"
|
143382
|
-
});
|
143383
|
-
}
|
143384
|
-
} catch (err) {
|
143385
|
-
handleError(err, pass, null);
|
143386
|
-
return null;
|
143387
|
-
}
|
143228
|
+
const referencedBeforeDeclared = pass.opts.gating != null ? getFunctionReferencedBeforeDeclarationAtTopLevel(program, compiledFns) : null;
|
143388
143229
|
for (const result of compiledFns) {
|
143389
143230
|
const { kind, originalFn, compiledFn } = result;
|
143390
143231
|
const transformedFn = createNewFunctionNode(originalFn, compiledFn);
|
143391
|
-
if (
|
143232
|
+
if (referencedBeforeDeclared != null && kind === "original") {
|
143233
|
+
CompilerError.invariant(pass.opts.gating != null, {
|
143234
|
+
reason: "Expected 'gating' import to be present",
|
143235
|
+
loc: null
|
143236
|
+
});
|
143392
143237
|
insertGatedFunctionDeclaration(
|
143393
143238
|
originalFn,
|
143394
143239
|
transformedFn,
|
143395
|
-
|
143396
|
-
|
143240
|
+
programContext,
|
143241
|
+
pass.opts.gating,
|
143242
|
+
referencedBeforeDeclared.has(result)
|
143397
143243
|
);
|
143398
143244
|
} else {
|
143399
143245
|
originalFn.replaceWith(transformedFn);
|
143400
143246
|
}
|
143401
143247
|
}
|
143402
143248
|
if (compiledFns.length > 0) {
|
143403
|
-
|
143404
|
-
for (const fn of compiledFns) {
|
143405
|
-
if (fn.compiledFn.memoSlotsUsed > 0) {
|
143406
|
-
needsMemoCacheFunctionImport = true;
|
143407
|
-
break;
|
143408
|
-
}
|
143409
|
-
}
|
143410
|
-
if (needsMemoCacheFunctionImport) {
|
143411
|
-
updateMemoCacheFunctionImport(
|
143412
|
-
program,
|
143413
|
-
getReactCompilerRuntimeModule(pass.opts),
|
143414
|
-
useMemoCacheIdentifier.name
|
143415
|
-
);
|
143416
|
-
}
|
143417
|
-
addImportsToProgram(program, externalFunctions);
|
143249
|
+
addImportsToProgram(program, programContext);
|
143418
143250
|
}
|
143419
|
-
return { retryErrors };
|
143251
|
+
return { retryErrors, inferredEffectLocations };
|
143420
143252
|
}
|
143421
143253
|
function shouldSkipCompilation(program, pass) {
|
143422
143254
|
if (pass.opts.sources) {
|
@@ -143439,7 +143271,7 @@ function shouldSkipCompilation(program, pass) {
|
|
143439
143271
|
}
|
143440
143272
|
if (hasMemoCacheFunctionImport(
|
143441
143273
|
program,
|
143442
|
-
getReactCompilerRuntimeModule(pass.opts)
|
143274
|
+
getReactCompilerRuntimeModule(pass.opts.target)
|
143443
143275
|
)) {
|
143444
143276
|
return true;
|
143445
143277
|
}
|
@@ -143733,14 +143565,14 @@ function getFunctionReferencedBeforeDeclarationAtTopLevel(program, fns) {
|
|
143733
143565
|
});
|
143734
143566
|
return referencedBeforeDeclaration;
|
143735
143567
|
}
|
143736
|
-
function getReactCompilerRuntimeModule(
|
143737
|
-
if (
|
143568
|
+
function getReactCompilerRuntimeModule(target) {
|
143569
|
+
if (target === "19") {
|
143738
143570
|
return "react/compiler-runtime";
|
143739
|
-
} else if (
|
143571
|
+
} else if (target === "17" || target === "18") {
|
143740
143572
|
return "react-compiler-runtime";
|
143741
143573
|
} else {
|
143742
143574
|
CompilerError.invariant(
|
143743
|
-
|
143575
|
+
target != null && target.kind === "donotuse_meta_internal" && typeof target.runtimeModule === "string",
|
143744
143576
|
{
|
143745
143577
|
reason: "Expected target to already be validated",
|
143746
143578
|
description: null,
|
@@ -143748,10 +143580,315 @@ function getReactCompilerRuntimeModule(opts) {
|
|
143748
143580
|
suggestions: null
|
143749
143581
|
}
|
143750
143582
|
);
|
143751
|
-
return
|
143583
|
+
return target.runtimeModule;
|
143752
143584
|
}
|
143753
143585
|
}
|
143754
143586
|
|
143587
|
+
// src/Entrypoint/Imports.ts
|
143588
|
+
function validateRestrictedImports(path, { validateBlocklistedImports }) {
|
143589
|
+
if (validateBlocklistedImports == null || validateBlocklistedImports.length === 0) {
|
143590
|
+
return null;
|
143591
|
+
}
|
143592
|
+
const error = new CompilerError();
|
143593
|
+
const restrictedImports = new Set(validateBlocklistedImports);
|
143594
|
+
path.traverse({
|
143595
|
+
ImportDeclaration(importDeclPath) {
|
143596
|
+
var _a;
|
143597
|
+
if (restrictedImports.has(importDeclPath.node.source.value)) {
|
143598
|
+
error.push({
|
143599
|
+
severity: "Todo" /* Todo */,
|
143600
|
+
reason: "Bailing out due to blocklisted import",
|
143601
|
+
description: `Import from module ${importDeclPath.node.source.value}`,
|
143602
|
+
loc: (_a = importDeclPath.node.loc) != null ? _a : null
|
143603
|
+
});
|
143604
|
+
}
|
143605
|
+
}
|
143606
|
+
});
|
143607
|
+
if (error.hasErrors()) {
|
143608
|
+
return error;
|
143609
|
+
} else {
|
143610
|
+
return null;
|
143611
|
+
}
|
143612
|
+
}
|
143613
|
+
var ProgramContext2 = class {
|
143614
|
+
constructor(program, reactRuntimeModule, hookPattern) {
|
143615
|
+
// known generated or referenced identifiers in the program
|
143616
|
+
this.knownReferencedNames = /* @__PURE__ */ new Set();
|
143617
|
+
// generated imports
|
143618
|
+
this.imports = /* @__PURE__ */ new Map();
|
143619
|
+
this.hookPattern = hookPattern;
|
143620
|
+
this.scope = program.scope;
|
143621
|
+
this.reactRuntimeModule = getReactCompilerRuntimeModule(reactRuntimeModule);
|
143622
|
+
}
|
143623
|
+
isHookName(name) {
|
143624
|
+
if (this.hookPattern == null) {
|
143625
|
+
return isHookName(name);
|
143626
|
+
} else {
|
143627
|
+
const match = new RegExp(this.hookPattern).exec(name);
|
143628
|
+
return match != null && typeof match[1] === "string" && isHookName(match[1]);
|
143629
|
+
}
|
143630
|
+
}
|
143631
|
+
hasReference(name) {
|
143632
|
+
return this.knownReferencedNames.has(name) || this.scope.hasBinding(name) || this.scope.hasGlobal(name) || this.scope.hasReference(name);
|
143633
|
+
}
|
143634
|
+
newUid(name) {
|
143635
|
+
let uid;
|
143636
|
+
if (this.isHookName(name)) {
|
143637
|
+
uid = name;
|
143638
|
+
let i = 0;
|
143639
|
+
while (this.hasReference(uid)) {
|
143640
|
+
this.knownReferencedNames.add(uid);
|
143641
|
+
uid = `${name}_${i++}`;
|
143642
|
+
}
|
143643
|
+
} else if (!this.hasReference(name)) {
|
143644
|
+
uid = name;
|
143645
|
+
} else {
|
143646
|
+
uid = this.scope.generateUid(name);
|
143647
|
+
}
|
143648
|
+
this.knownReferencedNames.add(uid);
|
143649
|
+
return uid;
|
143650
|
+
}
|
143651
|
+
addMemoCacheImport() {
|
143652
|
+
return this.addImportSpecifier(
|
143653
|
+
{
|
143654
|
+
source: this.reactRuntimeModule,
|
143655
|
+
importSpecifierName: "c"
|
143656
|
+
},
|
143657
|
+
"_c"
|
143658
|
+
);
|
143659
|
+
}
|
143660
|
+
/**
|
143661
|
+
*
|
143662
|
+
* @param externalFunction
|
143663
|
+
* @param nameHint if defined, will be used as the name of the import specifier
|
143664
|
+
* @returns
|
143665
|
+
*/
|
143666
|
+
addImportSpecifier({ source: module2, importSpecifierName: specifier }, nameHint) {
|
143667
|
+
var _a;
|
143668
|
+
const maybeBinding = (_a = this.imports.get(module2)) == null ? void 0 : _a.get(specifier);
|
143669
|
+
if (maybeBinding != null) {
|
143670
|
+
return __spreadValues({}, maybeBinding);
|
143671
|
+
}
|
143672
|
+
const binding = {
|
143673
|
+
kind: "ImportSpecifier",
|
143674
|
+
name: this.newUid(nameHint != null ? nameHint : specifier),
|
143675
|
+
module: module2,
|
143676
|
+
imported: specifier
|
143677
|
+
};
|
143678
|
+
getOrInsertWith(this.imports, module2, () => /* @__PURE__ */ new Map()).set(specifier, __spreadValues({}, binding));
|
143679
|
+
return binding;
|
143680
|
+
}
|
143681
|
+
addNewReference(name) {
|
143682
|
+
this.knownReferencedNames.add(name);
|
143683
|
+
}
|
143684
|
+
assertGlobalBinding(name, localScope) {
|
143685
|
+
var _a, _b;
|
143686
|
+
const scope = localScope != null ? localScope : this.scope;
|
143687
|
+
if (!scope.hasReference(name) && !scope.hasBinding(name)) {
|
143688
|
+
return Ok(void 0);
|
143689
|
+
}
|
143690
|
+
const error = new CompilerError();
|
143691
|
+
error.push({
|
143692
|
+
severity: "Todo" /* Todo */,
|
143693
|
+
reason: "Encountered conflicting global in generated program",
|
143694
|
+
description: `Conflict from local binding ${name}`,
|
143695
|
+
loc: (_b = (_a = scope.getBinding(name)) == null ? void 0 : _a.path.node.loc) != null ? _b : null,
|
143696
|
+
suggestions: null
|
143697
|
+
});
|
143698
|
+
return Err(error);
|
143699
|
+
}
|
143700
|
+
};
|
143701
|
+
function getExistingImports(program) {
|
143702
|
+
const existingImports = /* @__PURE__ */ new Map();
|
143703
|
+
program.traverse({
|
143704
|
+
ImportDeclaration(path) {
|
143705
|
+
if (isNonNamespacedImport(path)) {
|
143706
|
+
existingImports.set(path.node.source.value, path);
|
143707
|
+
}
|
143708
|
+
}
|
143709
|
+
});
|
143710
|
+
return existingImports;
|
143711
|
+
}
|
143712
|
+
function addImportsToProgram(path, programContext) {
|
143713
|
+
const existingImports = getExistingImports(path);
|
143714
|
+
const stmts = [];
|
143715
|
+
const sortedModules = [...programContext.imports.entries()].sort(
|
143716
|
+
([a], [b]) => a.localeCompare(b)
|
143717
|
+
);
|
143718
|
+
for (const [moduleName, importsMap] of sortedModules) {
|
143719
|
+
for (const [specifierName, loweredImport] of importsMap) {
|
143720
|
+
CompilerError.invariant(
|
143721
|
+
path.scope.getBinding(loweredImport.name) == null,
|
143722
|
+
{
|
143723
|
+
reason: "Encountered conflicting import specifiers in generated program",
|
143724
|
+
description: `Conflict from import ${loweredImport.module}:(${loweredImport.imported} as ${loweredImport.name}).`,
|
143725
|
+
loc: GeneratedSource,
|
143726
|
+
suggestions: null
|
143727
|
+
}
|
143728
|
+
);
|
143729
|
+
CompilerError.invariant(
|
143730
|
+
loweredImport.module === moduleName && loweredImport.imported === specifierName,
|
143731
|
+
{
|
143732
|
+
reason: "Found inconsistent import specifier. This is an internal bug.",
|
143733
|
+
description: `Expected import ${moduleName}:${specifierName} but found ${loweredImport.module}:${loweredImport.imported}`,
|
143734
|
+
loc: GeneratedSource
|
143735
|
+
}
|
143736
|
+
);
|
143737
|
+
}
|
143738
|
+
const sortedImport = [
|
143739
|
+
...importsMap.values()
|
143740
|
+
].sort(({ imported: a }, { imported: b }) => a.localeCompare(b));
|
143741
|
+
const importSpecifiers = sortedImport.map((specifier) => {
|
143742
|
+
return t4.importSpecifier(
|
143743
|
+
t4.identifier(specifier.name),
|
143744
|
+
t4.identifier(specifier.imported)
|
143745
|
+
);
|
143746
|
+
});
|
143747
|
+
const maybeExistingImports = existingImports.get(moduleName);
|
143748
|
+
if (maybeExistingImports != null) {
|
143749
|
+
maybeExistingImports.pushContainer("specifiers", importSpecifiers);
|
143750
|
+
} else {
|
143751
|
+
stmts.push(
|
143752
|
+
t4.importDeclaration(importSpecifiers, t4.stringLiteral(moduleName))
|
143753
|
+
);
|
143754
|
+
}
|
143755
|
+
}
|
143756
|
+
path.unshiftContainer("body", stmts);
|
143757
|
+
}
|
143758
|
+
function isNonNamespacedImport(importDeclPath) {
|
143759
|
+
return importDeclPath.get("specifiers").every((specifier) => specifier.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
143760
|
+
}
|
143761
|
+
|
143762
|
+
// src/Entrypoint/Options.ts
|
143763
|
+
var PanicThresholdOptionsSchema = z.enum([
|
143764
|
+
/*
|
143765
|
+
* Any errors will panic the compiler by throwing an exception, which will
|
143766
|
+
* bubble up to the nearest exception handler above the Forget transform.
|
143767
|
+
* If Forget is invoked through `BabelPluginReactCompiler`, this will at the least
|
143768
|
+
* skip Forget compilation for the rest of current file.
|
143769
|
+
*/
|
143770
|
+
"all_errors",
|
143771
|
+
/*
|
143772
|
+
* Panic by throwing an exception only on critical or unrecognized errors.
|
143773
|
+
* For all other errors, skip the erroring function without inserting
|
143774
|
+
* a Forget-compiled version (i.e. same behavior as noEmit).
|
143775
|
+
*/
|
143776
|
+
"critical_errors",
|
143777
|
+
// Never panic by throwing an exception.
|
143778
|
+
"none"
|
143779
|
+
]);
|
143780
|
+
var CompilerReactTargetSchema = z.union([
|
143781
|
+
z.literal("17"),
|
143782
|
+
z.literal("18"),
|
143783
|
+
z.literal("19"),
|
143784
|
+
/**
|
143785
|
+
* Used exclusively for Meta apps which are guaranteed to have compatible
|
143786
|
+
* react runtime and compiler versions. Note that only the FB-internal bundles
|
143787
|
+
* re-export useMemoCache (see
|
143788
|
+
* https://github.com/facebook/react/blob/5b0ef217ef32333a8e56f39be04327c89efa346f/packages/react/index.fb.js#L68-L70),
|
143789
|
+
* so this option is invalid / creates runtime errors for open-source users.
|
143790
|
+
*/
|
143791
|
+
z.object({
|
143792
|
+
kind: z.literal("donotuse_meta_internal"),
|
143793
|
+
runtimeModule: z.string().default("react")
|
143794
|
+
})
|
143795
|
+
]);
|
143796
|
+
var CompilationModeSchema = z.enum([
|
143797
|
+
/*
|
143798
|
+
* Compiles functions annotated with "use forget" or component/hook-like functions.
|
143799
|
+
* This latter includes:
|
143800
|
+
* * Components declared with component syntax.
|
143801
|
+
* * Functions which can be inferred to be a component or hook:
|
143802
|
+
* - Be named like a hook or component. This logic matches the ESLint rule.
|
143803
|
+
* - *and* create JSX and/or call a hook. This is an additional check to help prevent
|
143804
|
+
* false positives, since compilation has a greater impact than linting.
|
143805
|
+
* This is the default mode
|
143806
|
+
*/
|
143807
|
+
"infer",
|
143808
|
+
// Compile only components using Flow component syntax and hooks using hook syntax.
|
143809
|
+
"syntax",
|
143810
|
+
// Compile only functions which are explicitly annotated with "use forget"
|
143811
|
+
"annotation",
|
143812
|
+
// Compile all top-level functions
|
143813
|
+
"all"
|
143814
|
+
]);
|
143815
|
+
var defaultOptions = {
|
143816
|
+
compilationMode: "infer",
|
143817
|
+
panicThreshold: "none",
|
143818
|
+
environment: parseEnvironmentConfig({}).unwrap(),
|
143819
|
+
logger: null,
|
143820
|
+
gating: null,
|
143821
|
+
noEmit: false,
|
143822
|
+
eslintSuppressionRules: null,
|
143823
|
+
flowSuppressions: true,
|
143824
|
+
ignoreUseNoForget: false,
|
143825
|
+
sources: (filename) => {
|
143826
|
+
return filename.indexOf("node_modules") === -1;
|
143827
|
+
},
|
143828
|
+
enableReanimatedCheck: true,
|
143829
|
+
target: "19"
|
143830
|
+
};
|
143831
|
+
function parsePluginOptions(obj) {
|
143832
|
+
if (obj == null || typeof obj !== "object") {
|
143833
|
+
return defaultOptions;
|
143834
|
+
}
|
143835
|
+
const parsedOptions = /* @__PURE__ */ Object.create(null);
|
143836
|
+
for (let [key2, value] of Object.entries(obj)) {
|
143837
|
+
if (typeof value === "string") {
|
143838
|
+
value = value.toLowerCase();
|
143839
|
+
}
|
143840
|
+
if (isCompilerFlag(key2)) {
|
143841
|
+
switch (key2) {
|
143842
|
+
case "environment": {
|
143843
|
+
const environmentResult = parseEnvironmentConfig(value);
|
143844
|
+
if (environmentResult.isErr()) {
|
143845
|
+
CompilerError.throwInvalidConfig({
|
143846
|
+
reason: "Error in validating environment config. This is an advanced setting and not meant to be used directly",
|
143847
|
+
description: environmentResult.unwrapErr().toString(),
|
143848
|
+
suggestions: null,
|
143849
|
+
loc: null
|
143850
|
+
});
|
143851
|
+
}
|
143852
|
+
parsedOptions[key2] = environmentResult.unwrap();
|
143853
|
+
break;
|
143854
|
+
}
|
143855
|
+
case "target": {
|
143856
|
+
parsedOptions[key2] = parseTargetConfig(value);
|
143857
|
+
break;
|
143858
|
+
}
|
143859
|
+
case "gating": {
|
143860
|
+
if (value == null) {
|
143861
|
+
parsedOptions[key2] = null;
|
143862
|
+
} else {
|
143863
|
+
parsedOptions[key2] = tryParseExternalFunction(value);
|
143864
|
+
}
|
143865
|
+
break;
|
143866
|
+
}
|
143867
|
+
default: {
|
143868
|
+
parsedOptions[key2] = value;
|
143869
|
+
}
|
143870
|
+
}
|
143871
|
+
}
|
143872
|
+
}
|
143873
|
+
return __spreadValues(__spreadValues({}, defaultOptions), parsedOptions);
|
143874
|
+
}
|
143875
|
+
function parseTargetConfig(value) {
|
143876
|
+
const parsed = CompilerReactTargetSchema.safeParse(value);
|
143877
|
+
if (parsed.success) {
|
143878
|
+
return parsed.data;
|
143879
|
+
} else {
|
143880
|
+
CompilerError.throwInvalidConfig({
|
143881
|
+
reason: "Not a valid target",
|
143882
|
+
description: `${fromZodError(parsed.error)}`,
|
143883
|
+
suggestions: null,
|
143884
|
+
loc: null
|
143885
|
+
});
|
143886
|
+
}
|
143887
|
+
}
|
143888
|
+
function isCompilerFlag(s) {
|
143889
|
+
return hasOwnProperty2(defaultOptions, s);
|
143890
|
+
}
|
143891
|
+
|
143755
143892
|
// src/Entrypoint/Reanimated.ts
|
143756
143893
|
function hasModule(name) {
|
143757
143894
|
if (typeof require === "undefined") {
|
@@ -143805,7 +143942,9 @@ function assertValidEffectImportReference(numArgs, paths, context) {
|
|
143805
143942
|
const parent = path.parentPath;
|
143806
143943
|
if (parent != null && parent.isCallExpression()) {
|
143807
143944
|
const args = parent.get("arguments");
|
143808
|
-
|
143945
|
+
const maybeCalleeLoc = path.node.loc;
|
143946
|
+
const hasInferredEffect = maybeCalleeLoc != null && context.inferredEffectLocations.has(maybeCalleeLoc);
|
143947
|
+
if (args.length === numArgs && !hasInferredEffect) {
|
143809
143948
|
const maybeErrorDiagnostic = matchCompilerDiagnostic(
|
143810
143949
|
path,
|
143811
143950
|
context.transformErrors
|
@@ -143839,7 +143978,7 @@ function assertValidFireImportReference(paths, context) {
|
|
143839
143978
|
);
|
143840
143979
|
}
|
143841
143980
|
}
|
143842
|
-
function validateNoUntransformedReferences(path, filename, logger, env,
|
143981
|
+
function validateNoUntransformedReferences(path, filename, logger, env, compileResult) {
|
143843
143982
|
const moduleLoadChecks = /* @__PURE__ */ new Map();
|
143844
143983
|
if (env.enableFire) {
|
143845
143984
|
for (const module2 of Environment.knownReactModules) {
|
@@ -143860,7 +143999,7 @@ function validateNoUntransformedReferences(path, filename, logger, env, transfor
|
|
143860
143999
|
}
|
143861
144000
|
}
|
143862
144001
|
if (moduleLoadChecks.size > 0) {
|
143863
|
-
transformProgram(path, moduleLoadChecks, filename, logger,
|
144002
|
+
transformProgram(path, moduleLoadChecks, filename, logger, compileResult);
|
143864
144003
|
}
|
143865
144004
|
}
|
143866
144005
|
function validateImportSpecifier(specifier, importSpecifierChecks, state) {
|
@@ -143918,13 +144057,15 @@ function validateNamespacedImport(specifier, importSpecifierChecks, state) {
|
|
143918
144057
|
checkFn(references, state);
|
143919
144058
|
}
|
143920
144059
|
}
|
143921
|
-
function transformProgram(path, moduleLoadChecks, filename, logger,
|
144060
|
+
function transformProgram(path, moduleLoadChecks, filename, logger, compileResult) {
|
144061
|
+
var _a, _b;
|
143922
144062
|
const traversalState = {
|
143923
144063
|
shouldInvalidateScopes: true,
|
143924
144064
|
program: path,
|
143925
144065
|
filename,
|
143926
144066
|
logger,
|
143927
|
-
transformErrors
|
144067
|
+
transformErrors: (_a = compileResult == null ? void 0 : compileResult.retryErrors) != null ? _a : [],
|
144068
|
+
inferredEffectLocations: (_b = compileResult == null ? void 0 : compileResult.inferredEffectLocations) != null ? _b : /* @__PURE__ */ new Set()
|
143928
144069
|
};
|
143929
144070
|
path.traverse({
|
143930
144071
|
ImportDeclaration(path2) {
|
@@ -143975,7 +144116,7 @@ function BabelPluginReactCompiler(_babel) {
|
|
143975
144116
|
*/
|
143976
144117
|
Program: {
|
143977
144118
|
enter(prog, pass) {
|
143978
|
-
var _a, _b, _c, _d
|
144119
|
+
var _a, _b, _c, _d;
|
143979
144120
|
const filename = (_a = pass.filename) != null ? _a : "unknown";
|
143980
144121
|
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
|
143981
144122
|
performance.mark(`${filename}:start`, {
|
@@ -144005,7 +144146,7 @@ function BabelPluginReactCompiler(_babel) {
|
|
144005
144146
|
(_d = pass.filename) != null ? _d : null,
|
144006
144147
|
opts.logger,
|
144007
144148
|
opts.environment,
|
144008
|
-
|
144149
|
+
result
|
144009
144150
|
);
|
144010
144151
|
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
|
144011
144152
|
performance.mark(`${filename}:end`, {
|
@@ -144075,6 +144216,7 @@ var index_default = BabelPluginReactCompiler;
|
|
144075
144216
|
ErrorSeverity,
|
144076
144217
|
OPT_IN_DIRECTIVES,
|
144077
144218
|
OPT_OUT_DIRECTIVES,
|
144219
|
+
ProgramContext,
|
144078
144220
|
ValueKind,
|
144079
144221
|
compile,
|
144080
144222
|
compileProgram,
|
@@ -144082,8 +144224,10 @@ var index_default = BabelPluginReactCompiler;
|
|
144082
144224
|
findDirectiveEnablingMemoization,
|
144083
144225
|
parseConfigPragmaForTests,
|
144084
144226
|
parsePluginOptions,
|
144227
|
+
printFunctionWithOutlined,
|
144085
144228
|
printHIR,
|
144086
144229
|
printReactiveFunction,
|
144230
|
+
printReactiveFunctionWithOutlined,
|
144087
144231
|
runBabelPluginReactCompiler,
|
144088
144232
|
validateEnvironmentConfig
|
144089
144233
|
});
|