@barefootjs/jsx 0.39.4 → 0.39.5
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/adapters/filter-capture-collisions.d.ts +17 -0
- package/dist/adapters/filter-capture-collisions.d.ts.map +1 -0
- package/dist/adapters/parsed-expr-emitter.d.ts +8 -0
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/template-name-collisions.d.ts +21 -0
- package/dist/adapters/template-name-collisions.d.ts.map +1 -0
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +10 -0
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +358 -132
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +8 -0
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts +3 -2
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +39 -1
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +12 -0
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/scope/binding-scope.d.ts +10 -0
- package/dist/scope/binding-scope.d.ts.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/binding-scope-ratchet.test.ts +1 -1
- package/src/__tests__/binding-scope.test.ts +11 -0
- package/src/__tests__/compile-without-node-process.test.ts +78 -0
- package/src/__tests__/doc-examples.test.ts +1 -0
- package/src/__tests__/nested-row-shadowing.test.ts +57 -0
- package/src/__tests__/rename-free-identifiers.test.ts +26 -0
- package/src/__tests__/template-name-collisions.test.ts +81 -0
- package/src/adapters/filter-capture-collisions.ts +29 -0
- package/src/adapters/parsed-expr-emitter.ts +18 -0
- package/src/adapters/template-name-collisions.ts +120 -0
- package/src/analyzer-context.ts +15 -1
- package/src/expression-parser.ts +32 -0
- package/src/index.ts +6 -2
- package/src/ir-to-client-js/collect-elements.ts +11 -7
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +31 -10
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +12 -5
- package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +2 -2
- package/src/ir-to-client-js/control-flow/shared.ts +4 -1
- package/src/ir-to-client-js/html-template.ts +13 -7
- package/src/ir-to-client-js/index.ts +7 -2
- package/src/ir-to-client-js/utils.ts +81 -7
- package/src/nullable-signal-attr.ts +38 -6
- package/src/scope/binding-scope.ts +19 -0
- package/src/types.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -2144,6 +2144,33 @@ function freeVarsInBody(body, params) {
|
|
|
2144
2144
|
visit(body, params);
|
|
2145
2145
|
return [...found].sort();
|
|
2146
2146
|
}
|
|
2147
|
+
function renameFreeIdentifiers(expr, renames) {
|
|
2148
|
+
if (renames.size === 0)
|
|
2149
|
+
return expr;
|
|
2150
|
+
const walk = (value, active) => {
|
|
2151
|
+
if (Array.isArray(value))
|
|
2152
|
+
return value.map((v) => walk(v, active));
|
|
2153
|
+
if (value === null || typeof value !== "object")
|
|
2154
|
+
return value;
|
|
2155
|
+
const node = value;
|
|
2156
|
+
if (node.kind === "identifier" && typeof node.name === "string") {
|
|
2157
|
+
const renamed = active.get(node.name);
|
|
2158
|
+
return renamed === undefined ? node : { ...node, name: renamed };
|
|
2159
|
+
}
|
|
2160
|
+
let inner = active;
|
|
2161
|
+
if (node.kind === "arrow" && Array.isArray(node.params)) {
|
|
2162
|
+
const shadowed = new Map(active);
|
|
2163
|
+
for (const p of node.params)
|
|
2164
|
+
shadowed.delete(p);
|
|
2165
|
+
inner = shadowed;
|
|
2166
|
+
}
|
|
2167
|
+
const out = {};
|
|
2168
|
+
for (const [k, v] of Object.entries(node))
|
|
2169
|
+
out[k] = walk(v, inner);
|
|
2170
|
+
return out;
|
|
2171
|
+
};
|
|
2172
|
+
return walk(expr, renames);
|
|
2173
|
+
}
|
|
2147
2174
|
function freeIdentifiers(expr) {
|
|
2148
2175
|
const free = new Set;
|
|
2149
2176
|
function visit(e, bound) {
|
|
@@ -2397,6 +2424,112 @@ import ts11 from "typescript";
|
|
|
2397
2424
|
// src/ir-to-client-js/utils.ts
|
|
2398
2425
|
import ts5 from "typescript";
|
|
2399
2426
|
|
|
2427
|
+
// src/scope/binding-scope.ts
|
|
2428
|
+
function isStringLoopValue(type) {
|
|
2429
|
+
return type.primitive === "string" || type.unionTypes !== undefined && type.unionTypes.length > 0 && type.unionTypes.every(isStringLoopValue);
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
class BindingScope {
|
|
2433
|
+
frames;
|
|
2434
|
+
static EMPTY = new BindingScope([]);
|
|
2435
|
+
constructor(frames) {
|
|
2436
|
+
this.frames = frames;
|
|
2437
|
+
}
|
|
2438
|
+
enterLoopRow(loop) {
|
|
2439
|
+
const bindings = new Map;
|
|
2440
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
2441
|
+
for (const b of loop.paramBindings)
|
|
2442
|
+
bindings.set(b.name, { source: "destructure" });
|
|
2443
|
+
} else {
|
|
2444
|
+
bindings.set(loop.param, {
|
|
2445
|
+
source: "item",
|
|
2446
|
+
...loop.itemType ? { stringValue: isStringLoopValue(loop.itemType) } : {}
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
if (loop.index != null)
|
|
2450
|
+
bindings.set(loop.index, { source: "index" });
|
|
2451
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
2452
|
+
bindings.set(name, { source: "preamble" });
|
|
2453
|
+
const frame = { kind: "loop-row", bindings };
|
|
2454
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2455
|
+
}
|
|
2456
|
+
enterCallback(params) {
|
|
2457
|
+
const bindings = new Map;
|
|
2458
|
+
for (const name of params)
|
|
2459
|
+
bindings.set(name, { source: "param" });
|
|
2460
|
+
const frame = { kind: "callback", bindings };
|
|
2461
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2462
|
+
}
|
|
2463
|
+
enterAliases(aliasToOriginal) {
|
|
2464
|
+
const bindings = new Map;
|
|
2465
|
+
for (const [alias, original] of aliasToOriginal) {
|
|
2466
|
+
const hit = this.lookup(original);
|
|
2467
|
+
if (hit)
|
|
2468
|
+
bindings.set(alias, hit.binding);
|
|
2469
|
+
}
|
|
2470
|
+
if (bindings.size === 0)
|
|
2471
|
+
return this;
|
|
2472
|
+
return new BindingScope([{ kind: "callback", bindings }, ...this.frames]);
|
|
2473
|
+
}
|
|
2474
|
+
isBound(name) {
|
|
2475
|
+
for (const frame of this.frames) {
|
|
2476
|
+
if (frame.bindings.has(name))
|
|
2477
|
+
return true;
|
|
2478
|
+
}
|
|
2479
|
+
return false;
|
|
2480
|
+
}
|
|
2481
|
+
isStringValueName(name, outer, componentProperty = false) {
|
|
2482
|
+
if (componentProperty)
|
|
2483
|
+
return outer(name);
|
|
2484
|
+
const hit = this.lookup(name);
|
|
2485
|
+
return hit ? hit.binding.stringValue === true : outer(name);
|
|
2486
|
+
}
|
|
2487
|
+
shadowedNames() {
|
|
2488
|
+
if (!this.frames[0])
|
|
2489
|
+
return [];
|
|
2490
|
+
return [...this.frames[0].bindings.keys()].filter((name) => this.frames.slice(1).some((frame) => frame.bindings.has(name)));
|
|
2491
|
+
}
|
|
2492
|
+
lookup(name) {
|
|
2493
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
2494
|
+
const frame = this.frames[depth];
|
|
2495
|
+
const binding = frame.bindings.get(name);
|
|
2496
|
+
if (binding)
|
|
2497
|
+
return { depth, frame, binding };
|
|
2498
|
+
}
|
|
2499
|
+
return null;
|
|
2500
|
+
}
|
|
2501
|
+
boundNames() {
|
|
2502
|
+
if (this.boundNamesCache)
|
|
2503
|
+
return this.boundNamesCache;
|
|
2504
|
+
const names = new Set;
|
|
2505
|
+
for (const frame of this.frames) {
|
|
2506
|
+
for (const name of frame.bindings.keys())
|
|
2507
|
+
names.add(name);
|
|
2508
|
+
}
|
|
2509
|
+
this.boundNamesCache = names;
|
|
2510
|
+
return names;
|
|
2511
|
+
}
|
|
2512
|
+
boundNamesCache;
|
|
2513
|
+
valueBoundNamesCache;
|
|
2514
|
+
valueBoundNames() {
|
|
2515
|
+
if (this.valueBoundNamesCache)
|
|
2516
|
+
return this.valueBoundNamesCache;
|
|
2517
|
+
const names = new Set;
|
|
2518
|
+
for (const frame of this.frames) {
|
|
2519
|
+
for (const [name, binding] of frame.bindings) {
|
|
2520
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
2521
|
+
names.add(name);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
this.valueBoundNamesCache = names;
|
|
2526
|
+
return names;
|
|
2527
|
+
}
|
|
2528
|
+
asShadowPredicate() {
|
|
2529
|
+
return (name) => this.isBound(name);
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2400
2533
|
// src/loop-chain.ts
|
|
2401
2534
|
function buildLoopChainExpr(opts) {
|
|
2402
2535
|
const sortExpr = opts.sortComparator ? `.toSorted((${opts.sortComparator.paramA}, ${opts.sortComparator.paramB}) => ${opts.sortComparator.raw})` : "";
|
|
@@ -2823,6 +2956,9 @@ function isCommentScopedRoot(root) {
|
|
|
2823
2956
|
function isScopeCommentFragmentRoot(root) {
|
|
2824
2957
|
return root.type === "fragment" && !!root.needsScopeComment;
|
|
2825
2958
|
}
|
|
2959
|
+
function isTransparentFragmentRoot(root) {
|
|
2960
|
+
return root.type === "fragment" && !!root.transparent;
|
|
2961
|
+
}
|
|
2826
2962
|
function componentDefScopeFlags(root) {
|
|
2827
2963
|
const flags = [];
|
|
2828
2964
|
if (isCommentScopedRoot(root))
|
|
@@ -3066,7 +3202,7 @@ function scanForIdentifiers(expr, predicate) {
|
|
|
3066
3202
|
return false;
|
|
3067
3203
|
}
|
|
3068
3204
|
function renderLoopBindingAccess(b, base) {
|
|
3069
|
-
const parent = `${base}${b.path}`;
|
|
3205
|
+
const parent = `${b.accessor ?? base}${b.path}`;
|
|
3070
3206
|
if (b.rest?.kind === "object") {
|
|
3071
3207
|
if (b.rest.exclude.length === 0) {
|
|
3072
3208
|
return `({...${parent}})`;
|
|
@@ -3081,18 +3217,27 @@ function renderLoopBindingAccess(b, base) {
|
|
|
3081
3217
|
}
|
|
3082
3218
|
return parent;
|
|
3083
3219
|
}
|
|
3084
|
-
function wrapLoopParamAsAccessor(expr, paramName, bindings, indexParam) {
|
|
3220
|
+
function wrapLoopParamAsAccessor(expr, paramName, bindings, indexParam, shadowed) {
|
|
3221
|
+
const destructured = !!bindings && bindings.length > 0;
|
|
3222
|
+
const liveBindings = destructured && shadowed ? bindings.filter((b) => !shadowed.has(b.name)) : bindings;
|
|
3223
|
+
const liveIndex = indexParam && shadowed?.has(indexParam) ? null : indexParam;
|
|
3085
3224
|
let result;
|
|
3086
|
-
if (
|
|
3087
|
-
result = rewriteLoopBindingRefs(expr,
|
|
3225
|
+
if (destructured) {
|
|
3226
|
+
result = liveBindings && liveBindings.length > 0 ? rewriteLoopBindingRefs(expr, liveBindings, "__bfItem()") : expr;
|
|
3088
3227
|
} else {
|
|
3089
|
-
result = rewriteIdentifierAsAccessor(expr, paramName);
|
|
3228
|
+
result = shadowed?.has(paramName) ? expr : rewriteIdentifierAsAccessor(expr, paramName);
|
|
3090
3229
|
}
|
|
3091
|
-
if (
|
|
3092
|
-
result = wrapIndexParamAsAccessor(result,
|
|
3230
|
+
if (liveIndex && liveIndex !== paramName) {
|
|
3231
|
+
result = wrapIndexParamAsAccessor(result, liveIndex);
|
|
3093
3232
|
}
|
|
3094
3233
|
return result;
|
|
3095
3234
|
}
|
|
3235
|
+
function unionNames(a, b) {
|
|
3236
|
+
return b && b.size > 0 ? new Set([...a, ...b]) : a;
|
|
3237
|
+
}
|
|
3238
|
+
function rowBoundNames(loop) {
|
|
3239
|
+
return BindingScope.EMPTY.enterLoopRow(loop).boundNames();
|
|
3240
|
+
}
|
|
3096
3241
|
function wrapIndexParamAsAccessor(expr, indexParam) {
|
|
3097
3242
|
return rewriteIdentifierAsAccessor(expr, indexParam);
|
|
3098
3243
|
}
|
|
@@ -3171,10 +3316,28 @@ function wrapExprWithLoopParams(expr, loopParams) {
|
|
|
3171
3316
|
let result = expr;
|
|
3172
3317
|
for (const p of loopParams) {
|
|
3173
3318
|
const spec = typeof p === "string" ? { param: p } : p;
|
|
3174
|
-
result = wrapLoopParamAsAccessor(result, spec.param, spec.bindings, spec.index);
|
|
3319
|
+
result = wrapLoopParamAsAccessor(result, spec.param, spec.bindings, spec.index, spec.shadowed);
|
|
3175
3320
|
}
|
|
3176
3321
|
return result;
|
|
3177
3322
|
}
|
|
3323
|
+
function specsInsideRow(specs, loop) {
|
|
3324
|
+
if (!specs)
|
|
3325
|
+
return specs;
|
|
3326
|
+
const names = rowBoundNames(loop);
|
|
3327
|
+
if (names.size === 0)
|
|
3328
|
+
return specs;
|
|
3329
|
+
return specs.map((p) => {
|
|
3330
|
+
const spec = typeof p === "string" ? { param: p } : p;
|
|
3331
|
+
const shadowed = spec.shadowed ? new Set([...spec.shadowed, ...names]) : names;
|
|
3332
|
+
return { ...spec, shadowed };
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
function withRowAccessor(bindings, markerId) {
|
|
3336
|
+
if (!bindings || bindings.length === 0)
|
|
3337
|
+
return bindings;
|
|
3338
|
+
const accessor = `__bfItem_${markerId}()`;
|
|
3339
|
+
return bindings.map((b) => ({ ...b, accessor }));
|
|
3340
|
+
}
|
|
3178
3341
|
|
|
3179
3342
|
// src/html-constants.ts
|
|
3180
3343
|
import { BOOLEAN_ATTRS, isBooleanAttr } from "@barefootjs/shared";
|
|
@@ -4168,101 +4331,6 @@ function renderChildScopeArgs(comp, keyArg) {
|
|
|
4168
4331
|
return derivesScopeFromSlot(comp) ? `${key}, '${comp.slotId}'` : `${key}, '${comp.slotId}', true`;
|
|
4169
4332
|
}
|
|
4170
4333
|
|
|
4171
|
-
// src/scope/binding-scope.ts
|
|
4172
|
-
function isStringLoopValue(type) {
|
|
4173
|
-
return type.primitive === "string" || type.unionTypes !== undefined && type.unionTypes.length > 0 && type.unionTypes.every(isStringLoopValue);
|
|
4174
|
-
}
|
|
4175
|
-
|
|
4176
|
-
class BindingScope {
|
|
4177
|
-
frames;
|
|
4178
|
-
static EMPTY = new BindingScope([]);
|
|
4179
|
-
constructor(frames) {
|
|
4180
|
-
this.frames = frames;
|
|
4181
|
-
}
|
|
4182
|
-
enterLoopRow(loop) {
|
|
4183
|
-
const bindings = new Map;
|
|
4184
|
-
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
4185
|
-
for (const b of loop.paramBindings)
|
|
4186
|
-
bindings.set(b.name, { source: "destructure" });
|
|
4187
|
-
} else {
|
|
4188
|
-
bindings.set(loop.param, {
|
|
4189
|
-
source: "item",
|
|
4190
|
-
...loop.itemType ? { stringValue: isStringLoopValue(loop.itemType) } : {}
|
|
4191
|
-
});
|
|
4192
|
-
}
|
|
4193
|
-
if (loop.index != null)
|
|
4194
|
-
bindings.set(loop.index, { source: "index" });
|
|
4195
|
-
for (const name of loop.preamble?.declaredNames ?? [])
|
|
4196
|
-
bindings.set(name, { source: "preamble" });
|
|
4197
|
-
const frame = { kind: "loop-row", bindings };
|
|
4198
|
-
return new BindingScope([frame, ...this.frames]);
|
|
4199
|
-
}
|
|
4200
|
-
enterCallback(params) {
|
|
4201
|
-
const bindings = new Map;
|
|
4202
|
-
for (const name of params)
|
|
4203
|
-
bindings.set(name, { source: "param" });
|
|
4204
|
-
const frame = { kind: "callback", bindings };
|
|
4205
|
-
return new BindingScope([frame, ...this.frames]);
|
|
4206
|
-
}
|
|
4207
|
-
isBound(name) {
|
|
4208
|
-
for (const frame of this.frames) {
|
|
4209
|
-
if (frame.bindings.has(name))
|
|
4210
|
-
return true;
|
|
4211
|
-
}
|
|
4212
|
-
return false;
|
|
4213
|
-
}
|
|
4214
|
-
isStringValueName(name, outer, componentProperty = false) {
|
|
4215
|
-
if (componentProperty)
|
|
4216
|
-
return outer(name);
|
|
4217
|
-
const hit = this.lookup(name);
|
|
4218
|
-
return hit ? hit.binding.stringValue === true : outer(name);
|
|
4219
|
-
}
|
|
4220
|
-
shadowedNames() {
|
|
4221
|
-
if (!this.frames[0])
|
|
4222
|
-
return [];
|
|
4223
|
-
return [...this.frames[0].bindings.keys()].filter((name) => this.frames.slice(1).some((frame) => frame.bindings.has(name)));
|
|
4224
|
-
}
|
|
4225
|
-
lookup(name) {
|
|
4226
|
-
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
4227
|
-
const frame = this.frames[depth];
|
|
4228
|
-
const binding = frame.bindings.get(name);
|
|
4229
|
-
if (binding)
|
|
4230
|
-
return { depth, frame, binding };
|
|
4231
|
-
}
|
|
4232
|
-
return null;
|
|
4233
|
-
}
|
|
4234
|
-
boundNames() {
|
|
4235
|
-
if (this.boundNamesCache)
|
|
4236
|
-
return this.boundNamesCache;
|
|
4237
|
-
const names = new Set;
|
|
4238
|
-
for (const frame of this.frames) {
|
|
4239
|
-
for (const name of frame.bindings.keys())
|
|
4240
|
-
names.add(name);
|
|
4241
|
-
}
|
|
4242
|
-
this.boundNamesCache = names;
|
|
4243
|
-
return names;
|
|
4244
|
-
}
|
|
4245
|
-
boundNamesCache;
|
|
4246
|
-
valueBoundNamesCache;
|
|
4247
|
-
valueBoundNames() {
|
|
4248
|
-
if (this.valueBoundNamesCache)
|
|
4249
|
-
return this.valueBoundNamesCache;
|
|
4250
|
-
const names = new Set;
|
|
4251
|
-
for (const frame of this.frames) {
|
|
4252
|
-
for (const [name, binding] of frame.bindings) {
|
|
4253
|
-
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
4254
|
-
names.add(name);
|
|
4255
|
-
}
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
this.valueBoundNamesCache = names;
|
|
4259
|
-
return names;
|
|
4260
|
-
}
|
|
4261
|
-
asShadowPredicate() {
|
|
4262
|
-
return (name) => this.isBound(name);
|
|
4263
|
-
}
|
|
4264
|
-
}
|
|
4265
|
-
|
|
4266
4334
|
// src/ir-to-client-js/safe-html.ts
|
|
4267
4335
|
function safeHtml(expr) {
|
|
4268
4336
|
return expr;
|
|
@@ -4791,7 +4859,8 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
4791
4859
|
return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, renderChildScopeArgs(node, keyArg)));
|
|
4792
4860
|
}
|
|
4793
4861
|
case "loop": {
|
|
4794
|
-
const
|
|
4862
|
+
const rowLoopParams = specsInsideRow(loopParams, node);
|
|
4863
|
+
const innerRecurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth + 1, rowLoopParams, branchSlotsVar);
|
|
4795
4864
|
let childTemplate = node.children.map(innerRecurse).join("");
|
|
4796
4865
|
if (node.bodyIsItemConditional && node.key) {
|
|
4797
4866
|
childTemplate = `${itemAnchorTemplate(node.key)}${childTemplate}`;
|
|
@@ -4804,11 +4873,11 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
4804
4873
|
let mapExpr;
|
|
4805
4874
|
if (node.flatMapCallback) {
|
|
4806
4875
|
const body = renderPreamble(node.flatMapCallback, {
|
|
4807
|
-
renderLeaf: (ir) => irToHtmlTemplate(leafKeyAsDataKeyAttr(ir), restSpreadNames, loopDepth + 1,
|
|
4876
|
+
renderLeaf: (ir) => irToHtmlTemplate(leafKeyAsDataKeyAttr(ir), restSpreadNames, loopDepth + 1, rowLoopParams, branchSlotsVar)
|
|
4808
4877
|
});
|
|
4809
4878
|
mapExpr = interp(mappedRowsMarkup(wrappedArray, "flatMap", node.flatMapCallback.params, body));
|
|
4810
4879
|
} else if (node.preamble) {
|
|
4811
|
-
const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToHtmlTemplate(ir, restSpreadNames, loopDepth + 1,
|
|
4880
|
+
const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToHtmlTemplate(ir, restSpreadNames, loopDepth + 1, rowLoopParams, branchSlotsVar) });
|
|
4812
4881
|
mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
|
|
4813
4882
|
} else {
|
|
4814
4883
|
mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `\`${childTemplate}\``));
|
|
@@ -5090,7 +5159,8 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
|
|
|
5090
5159
|
return `<div ${DATA_BF_PH}="${phId}"></div>`;
|
|
5091
5160
|
}
|
|
5092
5161
|
case "loop": {
|
|
5093
|
-
const
|
|
5162
|
+
const rowLoopParams = specsInsideRow(loopParams, node);
|
|
5163
|
+
const innerRecurse = (n) => irToPlaceholderTemplate(n, restSpreadNames, loopDepth + 1, rowLoopParams);
|
|
5094
5164
|
const childTemplate = node.children.map(innerRecurse).join("");
|
|
5095
5165
|
const indexParam = node.index ? `, ${node.index}` : "";
|
|
5096
5166
|
const rawChainedArray = applyLoopChain(node);
|
|
@@ -5100,11 +5170,11 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
|
|
|
5100
5170
|
let mapExpr;
|
|
5101
5171
|
if (node.flatMapCallback) {
|
|
5102
5172
|
const body = renderPreamble(node.flatMapCallback, {
|
|
5103
|
-
renderLeaf: (ir) => irToPlaceholderTemplate(leafKeyAsDataKeyAttr(ir), restSpreadNames, loopDepth + 1,
|
|
5173
|
+
renderLeaf: (ir) => irToPlaceholderTemplate(leafKeyAsDataKeyAttr(ir), restSpreadNames, loopDepth + 1, rowLoopParams)
|
|
5104
5174
|
});
|
|
5105
5175
|
mapExpr = interp(mappedRowsMarkup(wrappedArray, "flatMap", node.flatMapCallback.params, body));
|
|
5106
5176
|
} else if (node.preamble) {
|
|
5107
|
-
const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToPlaceholderTemplate(ir, restSpreadNames, loopDepth + 1,
|
|
5177
|
+
const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToPlaceholderTemplate(ir, restSpreadNames, loopDepth + 1, rowLoopParams) });
|
|
5108
5178
|
mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
|
|
5109
5179
|
} else {
|
|
5110
5180
|
mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `\`${childTemplate}\``));
|
|
@@ -6376,6 +6446,10 @@ function collectReactiveBrandLeaves(node, checker) {
|
|
|
6376
6446
|
}
|
|
6377
6447
|
|
|
6378
6448
|
// src/analyzer-context.ts
|
|
6449
|
+
function isGetJsAssertionArmed() {
|
|
6450
|
+
const env = globalThis.process?.env;
|
|
6451
|
+
return env?.BF_ASSERT_NO_JSX_IN_GETJS === "1";
|
|
6452
|
+
}
|
|
6379
6453
|
function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
6380
6454
|
return {
|
|
6381
6455
|
sourceFile,
|
|
@@ -6426,7 +6500,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
6426
6500
|
} catch {
|
|
6427
6501
|
ownSourceFile = undefined;
|
|
6428
6502
|
}
|
|
6429
|
-
if (
|
|
6503
|
+
if (isGetJsAssertionArmed() && !this.errors.some((e) => e.severity === "error") && nodeContainsJsx(node)) {
|
|
6430
6504
|
throw new Error("getJS() called on a JSX-bearing node — raw JSX must never be spliced " + "into emitted output. Carry mixed content as structured segments " + "(MapCallbackPreamble / FlatMapCallback) instead.");
|
|
6431
6505
|
}
|
|
6432
6506
|
if (ownSourceFile && ownSourceFile !== sourceFile) {
|
|
@@ -17883,17 +17957,18 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
|
|
|
17883
17957
|
},
|
|
17884
17958
|
loop: ({ node: n, scope, descend }) => {
|
|
17885
17959
|
const emitDepth = fixedDepth ?? scope.depth + 1;
|
|
17886
|
-
const
|
|
17960
|
+
const rowBindings = withRowAccessor(n.paramBindings, n.markerId);
|
|
17961
|
+
const loopParamsForTemplate = outerSpec ? [{ ...outerSpec, shadowed: rowBoundNames(n) }, { param: n.param, bindings: rowBindings, index: n.index }] : undefined;
|
|
17887
17962
|
const template = n.children.map((c) => irToPlaceholderTemplate(c, undefined, emitDepth, loopParamsForTemplate)).join("");
|
|
17888
17963
|
const bindings = emptyLoopChildBindings();
|
|
17889
17964
|
const innerPreambleNames = preambleNamesOf(n);
|
|
17890
17965
|
if (ctx) {
|
|
17891
17966
|
for (const child of n.children) {
|
|
17892
|
-
bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param,
|
|
17893
|
-
bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param,
|
|
17967
|
+
bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, rowBindings, true, innerPreambleNames, n.index, scope.bindingScope));
|
|
17968
|
+
bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, rowBindings, true, innerPreambleNames, n.index, scope.bindingScope));
|
|
17894
17969
|
bindings.refs.push(...collectLoopChildRefs(child));
|
|
17895
17970
|
}
|
|
17896
|
-
bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param,
|
|
17971
|
+
bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, rowBindings, innerPreambleNames, n.index, loopParamsForTemplate, scope.bindingScope));
|
|
17897
17972
|
}
|
|
17898
17973
|
let childComponents;
|
|
17899
17974
|
if (collectBindings) {
|
|
@@ -17924,7 +17999,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
|
|
|
17924
17999
|
array: n.array,
|
|
17925
18000
|
arrayFreeIdentifiers: n.arrayFreeIdentifiers,
|
|
17926
18001
|
param: n.param,
|
|
17927
|
-
paramBindings:
|
|
18002
|
+
paramBindings: rowBindings,
|
|
17928
18003
|
index: n.index,
|
|
17929
18004
|
key: n.key,
|
|
17930
18005
|
markerId: n.markerId,
|
|
@@ -17944,7 +18019,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
|
|
|
17944
18019
|
descend({
|
|
17945
18020
|
...scope,
|
|
17946
18021
|
depth: scope.depth + 1,
|
|
17947
|
-
bindingScope: buildLoopRowScope(n.param,
|
|
18022
|
+
bindingScope: buildLoopRowScope(n.param, rowBindings, innerPreambleNames, n.index, scope.bindingScope)
|
|
17948
18023
|
});
|
|
17949
18024
|
}
|
|
17950
18025
|
}
|
|
@@ -20508,7 +20583,8 @@ function exprRefsLoopBinding(freeIds, loop) {
|
|
|
20508
20583
|
function destructureLoopParam(param, paramBindings) {
|
|
20509
20584
|
if (param.startsWith("[") || param.startsWith("{")) {
|
|
20510
20585
|
if (paramBindings && paramBindings.length > 0) {
|
|
20511
|
-
|
|
20586
|
+
const accessor = paramBindings[0].accessor;
|
|
20587
|
+
return { head: accessor ? accessor.replace(/\(\)$/, "") : "__bfItem", unwrap: "" };
|
|
20512
20588
|
}
|
|
20513
20589
|
return {
|
|
20514
20590
|
head: "__bfItem",
|
|
@@ -20743,7 +20819,9 @@ function buildBranchInnerLoopsPlan(args) {
|
|
|
20743
20819
|
if (!inner.template)
|
|
20744
20820
|
continue;
|
|
20745
20821
|
const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
|
|
20746
|
-
const
|
|
20822
|
+
const innerShadowed = rowBoundNames(inner);
|
|
20823
|
+
const wrapOuterRow = (expr, shadowed) => wrapOuter(expr, unionNames(innerShadowed, shadowed));
|
|
20824
|
+
const wrapBoth = (expr, shadowed) => wrapLoopParamAsAccessor(wrapOuterRow(expr, shadowed), inner.param, inner.paramBindings, inner.index, shadowed);
|
|
20747
20825
|
const csl = inner.containerSlotId;
|
|
20748
20826
|
const containerExpr = csl ? `(${scopeVar}.querySelector('[bf="${csl}"]') ?? ${scopeVar}.querySelector(\`[${BF_HOST2}="\${__scopeId}"][${BF_AT2}="${csl}"]\`) ?? ${scopeVar})` : `findCondContainer(${scopeVar}, '${condSlotId}')`;
|
|
20749
20827
|
const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
|
|
@@ -20922,7 +21000,7 @@ function buildLoopChildArmPlan(args) {
|
|
|
20922
21000
|
// src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts
|
|
20923
21001
|
function buildReactiveEffectsPlan(args) {
|
|
20924
21002
|
const { attrs, texts, conditionals, loopParam, loopParamBindings, loopIndex, profileComponentName } = args;
|
|
20925
|
-
const wrap = (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex);
|
|
21003
|
+
const wrap = (expr, shadowed) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex, shadowed);
|
|
20926
21004
|
const attrsBySlot = new Map;
|
|
20927
21005
|
for (const attr of attrs) {
|
|
20928
21006
|
let bucket = attrsBySlot.get(attr.childSlotId);
|
|
@@ -21728,7 +21806,7 @@ function wrapAttrValueExpression2(value, wrap) {
|
|
|
21728
21806
|
}
|
|
21729
21807
|
function buildInnerLoopsPlan(args) {
|
|
21730
21808
|
const { levels, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex, rowHasPortal } = args;
|
|
21731
|
-
const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings, outerLoopIndex) : (expr) => expr;
|
|
21809
|
+
const wrapOuter = args.wrapOuter ?? (outerLoopParam ? (expr, shadowed) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings, outerLoopIndex, shadowed) : (expr) => expr);
|
|
21732
21810
|
const plan = [];
|
|
21733
21811
|
let i = 0;
|
|
21734
21812
|
while (i < levels.length) {
|
|
@@ -21757,7 +21835,8 @@ function buildInnerLoopsPlan(args) {
|
|
|
21757
21835
|
parentElVar: `__innerEl${uidSuffix}`,
|
|
21758
21836
|
outerLoopParam: inner.param,
|
|
21759
21837
|
outerLoopParamBindings: inner.paramBindings,
|
|
21760
|
-
outerLoopIndex: inner.index
|
|
21838
|
+
outerLoopIndex: inner.index,
|
|
21839
|
+
wrapOuter: (expr, shadowed) => wrapLoopParamAsAccessor(wrapOuter(expr, unionNames(rowBoundNames(inner), shadowed)), inner.param, inner.paramBindings, inner.index, shadowed)
|
|
21761
21840
|
}) : [];
|
|
21762
21841
|
plan.push({
|
|
21763
21842
|
uidSuffix,
|
|
@@ -21780,7 +21859,9 @@ function buildInnerLoopsPlan(args) {
|
|
|
21780
21859
|
}
|
|
21781
21860
|
function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex) {
|
|
21782
21861
|
const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
|
|
21783
|
-
const
|
|
21862
|
+
const innerShadowed = rowBoundNames(inner);
|
|
21863
|
+
const wrapOuterRow = (expr, shadowed) => wrapOuter(expr, unionNames(innerShadowed, shadowed));
|
|
21864
|
+
const wrapBoth = (expr, shadowed) => wrapLoopParamAsAccessor(wrapOuterRow(expr, shadowed), inner.param, inner.paramBindings, inner.index, shadowed);
|
|
21784
21865
|
const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
|
|
21785
21866
|
const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings, inner.index) : null;
|
|
21786
21867
|
const wrapIRNode = (node) => {
|
|
@@ -21813,11 +21894,11 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
|
|
|
21813
21894
|
}));
|
|
21814
21895
|
const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
|
|
21815
21896
|
slotId: text.slotId,
|
|
21816
|
-
wrappedExpression: wrapLoopParamAsAccessor(
|
|
21897
|
+
wrappedExpression: wrapLoopParamAsAccessor(wrapOuterRow(text.expression), inner.param, inner.paramBindings, inner.index),
|
|
21817
21898
|
insideConditional: !!text.insideConditional
|
|
21818
21899
|
}));
|
|
21819
21900
|
const reactiveAttrs = inner.bindings.reactiveAttrs.map((attr) => {
|
|
21820
|
-
const wrapped = wrapLoopParamAsAccessor(
|
|
21901
|
+
const wrapped = wrapLoopParamAsAccessor(wrapOuterRow(attr.expression), inner.param, inner.paramBindings, inner.index);
|
|
21821
21902
|
return {
|
|
21822
21903
|
slotId: attr.childSlotId,
|
|
21823
21904
|
attrName: attr.attrName,
|
|
@@ -21833,11 +21914,11 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
|
|
|
21833
21914
|
preludeStatements.push(paramUnwrap);
|
|
21834
21915
|
if (inner.preamble) {
|
|
21835
21916
|
const leafLoopParams = outerLoopParam ? [
|
|
21836
|
-
{ param: outerLoopParam, bindings: outerLoopParamBindings, index: outerLoopIndex },
|
|
21917
|
+
{ param: outerLoopParam, bindings: outerLoopParamBindings, index: outerLoopIndex, shadowed: innerShadowed },
|
|
21837
21918
|
{ param: inner.param, bindings: inner.paramBindings, index: inner.index }
|
|
21838
21919
|
] : [{ param: inner.param, bindings: inner.paramBindings, index: inner.index }];
|
|
21839
21920
|
preludeStatements.push(renderPreamble(inner.preamble, {
|
|
21840
|
-
transformJs: (t) => wrapInner(
|
|
21921
|
+
transformJs: (t) => wrapInner(wrapOuterRow(t)),
|
|
21841
21922
|
renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, leafLoopParams, undefined)
|
|
21842
21923
|
}));
|
|
21843
21924
|
}
|
|
@@ -25456,7 +25537,8 @@ function generateTemplateOnlyMount(ir, ctx) {
|
|
|
25456
25537
|
lines.push(`function ${initName}() {}`);
|
|
25457
25538
|
lines.push("");
|
|
25458
25539
|
const nameField = registryKey !== name ? `, name: '${name}'` : "";
|
|
25459
|
-
const
|
|
25540
|
+
const transparentFlag = isTransparentFragmentRoot(ir.root) ? ["transparent: true"] : [];
|
|
25541
|
+
const scopeFlags = [...componentDefScopeFlags(ir.root), ...transparentFlag].map((f) => `, ${f}`).join("");
|
|
25460
25542
|
lines.push(`hydrate('${registryKey}', { init: ${initName}, template: (${PROPS_PARAM}) => \`${templateHtml}\`${scopeFlags}${nameField} })`);
|
|
25461
25543
|
lines.push(`export function ${name}(${PROPS_PARAM}, __bfKey) { return createComponent('${registryKey}', ${PROPS_PARAM}, __bfKey) }`);
|
|
25462
25544
|
const generatedCode = lines.join(`
|
|
@@ -28854,6 +28936,17 @@ function isStringTypedOperand(expr, isStringName) {
|
|
|
28854
28936
|
function isStringConcatBinary(op, left, right, isStringName) {
|
|
28855
28937
|
return op === "+" && (isStringTypedOperand(left, isStringName) || isStringTypedOperand(right, isStringName));
|
|
28856
28938
|
}
|
|
28939
|
+
function isNumericArithmeticResult(expr, isStringName) {
|
|
28940
|
+
if (!expr)
|
|
28941
|
+
return false;
|
|
28942
|
+
if (expr.kind === "unary")
|
|
28943
|
+
return expr.op === "-";
|
|
28944
|
+
if (expr.kind !== "binary")
|
|
28945
|
+
return false;
|
|
28946
|
+
if (expr.op === "+")
|
|
28947
|
+
return !isStringConcatBinary(expr.op, expr.left, expr.right, isStringName);
|
|
28948
|
+
return expr.op === "-" || expr.op === "*" || expr.op === "/" || expr.op === "%";
|
|
28949
|
+
}
|
|
28857
28950
|
function groupBinaryOperand(operand, emitted) {
|
|
28858
28951
|
return operand.kind === "binary" || operand.kind === "logical" || operand.kind === "conditional" ? `(${emitted})` : emitted;
|
|
28859
28952
|
}
|
|
@@ -29002,6 +29095,122 @@ function collectLoopBoundNames(ir) {
|
|
|
29002
29095
|
visit3(ir.root);
|
|
29003
29096
|
return names;
|
|
29004
29097
|
}
|
|
29098
|
+
// src/adapters/filter-capture-collisions.ts
|
|
29099
|
+
function filterCaptureCollisions(loop) {
|
|
29100
|
+
const filter = loop.filterPredicate;
|
|
29101
|
+
if (!filter?.predicate)
|
|
29102
|
+
return [];
|
|
29103
|
+
const free = freeIdentifiers(filter.predicate);
|
|
29104
|
+
if (!free)
|
|
29105
|
+
return [];
|
|
29106
|
+
free.delete(filter.param);
|
|
29107
|
+
const rowBound = new Set(loop.paramBindings && loop.paramBindings.length > 0 ? loop.paramBindings.map((b) => b.name) : [loop.param]);
|
|
29108
|
+
if (loop.index)
|
|
29109
|
+
rowBound.add(loop.index);
|
|
29110
|
+
return [...free].filter((name) => rowBound.has(name)).sort();
|
|
29111
|
+
}
|
|
29112
|
+
// src/adapters/template-name-collisions.ts
|
|
29113
|
+
function templateNameCollisionErrors(ir, propNames, ident, adapterName, componentName) {
|
|
29114
|
+
const { metadata } = ir;
|
|
29115
|
+
const rootNames = new Set([
|
|
29116
|
+
...propNames,
|
|
29117
|
+
...metadata.localConstants.map((c) => c.name),
|
|
29118
|
+
...metadata.localFunctions.map((f) => f.name),
|
|
29119
|
+
...metadata.signals.flatMap((s) => s.setter ? [s.getter, s.setter] : [s.getter]),
|
|
29120
|
+
...metadata.memos.map((m) => m.name)
|
|
29121
|
+
]);
|
|
29122
|
+
const errors = [];
|
|
29123
|
+
const reported = new Set;
|
|
29124
|
+
const check = (scope) => {
|
|
29125
|
+
const byTarget = new Map;
|
|
29126
|
+
for (const name of new Set([...rootNames, ...scope.boundNames()])) {
|
|
29127
|
+
const target = ident(name);
|
|
29128
|
+
const group = byTarget.get(target);
|
|
29129
|
+
if (group)
|
|
29130
|
+
group.push(name);
|
|
29131
|
+
else
|
|
29132
|
+
byTarget.set(target, [name]);
|
|
29133
|
+
}
|
|
29134
|
+
for (const [target, group] of byTarget) {
|
|
29135
|
+
if (group.length < 2)
|
|
29136
|
+
continue;
|
|
29137
|
+
const key = `${target}\x00${[...group].sort().join("\x00")}`;
|
|
29138
|
+
if (reported.has(key))
|
|
29139
|
+
continue;
|
|
29140
|
+
reported.add(key);
|
|
29141
|
+
const list = group.map((n) => `\`${n}\``).join(" and ");
|
|
29142
|
+
errors.push({
|
|
29143
|
+
code: "BF105",
|
|
29144
|
+
severity: "error",
|
|
29145
|
+
message: `${list} both become the ${adapterName} template variable \`${target}\`, so they would read the same value. ${adapterName} reserves some names and renames them, and the new name collides with another name in this component.`,
|
|
29146
|
+
loc: { file: `${componentName}.tsx`, start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
29147
|
+
suggestion: {
|
|
29148
|
+
message: `Rename one of ${list} so the two names stay distinct after the ${adapterName} renaming.`,
|
|
29149
|
+
escape: [{ kind: "rewrite" }]
|
|
29150
|
+
}
|
|
29151
|
+
});
|
|
29152
|
+
}
|
|
29153
|
+
};
|
|
29154
|
+
const visit3 = (node, scope) => {
|
|
29155
|
+
if (!node)
|
|
29156
|
+
return;
|
|
29157
|
+
switch (node.type) {
|
|
29158
|
+
case "element":
|
|
29159
|
+
case "component":
|
|
29160
|
+
case "fragment":
|
|
29161
|
+
case "provider":
|
|
29162
|
+
for (const child of node.children)
|
|
29163
|
+
visit3(child, scope);
|
|
29164
|
+
break;
|
|
29165
|
+
case "async":
|
|
29166
|
+
visit3(node.fallback, scope);
|
|
29167
|
+
for (const child of node.children)
|
|
29168
|
+
visit3(child, scope);
|
|
29169
|
+
break;
|
|
29170
|
+
case "loop": {
|
|
29171
|
+
if (node.filterPredicate)
|
|
29172
|
+
check(scope.enterCallback([node.filterPredicate.param]));
|
|
29173
|
+
const row = scope.enterLoopRow(node);
|
|
29174
|
+
check(row);
|
|
29175
|
+
for (const child of node.children)
|
|
29176
|
+
visit3(child, row);
|
|
29177
|
+
if (node.childComponent) {
|
|
29178
|
+
for (const child of node.childComponent.children)
|
|
29179
|
+
visit3(child, row);
|
|
29180
|
+
}
|
|
29181
|
+
for (const nested of node.nestedComponents ?? []) {
|
|
29182
|
+
for (const child of nested.children)
|
|
29183
|
+
visit3(child, row);
|
|
29184
|
+
}
|
|
29185
|
+
for (const seg of node.flatMapCallback?.segments ?? []) {
|
|
29186
|
+
if (seg.kind === "jsx")
|
|
29187
|
+
visit3(seg.ir, row);
|
|
29188
|
+
}
|
|
29189
|
+
for (const seg of node.preamble?.segments ?? []) {
|
|
29190
|
+
if (seg.kind === "jsx")
|
|
29191
|
+
visit3(seg.ir, row);
|
|
29192
|
+
}
|
|
29193
|
+
break;
|
|
29194
|
+
}
|
|
29195
|
+
case "conditional":
|
|
29196
|
+
visit3(node.whenTrue, scope);
|
|
29197
|
+
visit3(node.whenFalse, scope);
|
|
29198
|
+
break;
|
|
29199
|
+
case "if-statement":
|
|
29200
|
+
visit3(node.consequent, scope);
|
|
29201
|
+
if (node.alternate)
|
|
29202
|
+
visit3(node.alternate, scope);
|
|
29203
|
+
break;
|
|
29204
|
+
case "text":
|
|
29205
|
+
case "expression":
|
|
29206
|
+
case "slot":
|
|
29207
|
+
break;
|
|
29208
|
+
}
|
|
29209
|
+
};
|
|
29210
|
+
check(BindingScope.EMPTY);
|
|
29211
|
+
visit3(ir.root, BindingScope.EMPTY);
|
|
29212
|
+
return errors;
|
|
29213
|
+
}
|
|
29005
29214
|
// src/adapters/boolean-result.ts
|
|
29006
29215
|
var COMPARISON_OPS = new Set([
|
|
29007
29216
|
"<",
|
|
@@ -29190,6 +29399,7 @@ function collectNullishAttrContext(ir) {
|
|
|
29190
29399
|
return {
|
|
29191
29400
|
nullableSignals: collectNullableSignalGetters(ir),
|
|
29192
29401
|
nullSeededSignals: new Set(signals.filter((s) => s.parsed?.kind === "literal" && s.parsed.literalType === "null").map((s) => s.getter)),
|
|
29402
|
+
undefinedSeededSignals: new Set(signals.filter((s) => s.parsed?.kind === "identifier" && s.parsed.name === "undefined").map((s) => s.getter)),
|
|
29193
29403
|
memos: new Map((ir.metadata.memos ?? []).map((m) => [m.name, m]))
|
|
29194
29404
|
};
|
|
29195
29405
|
}
|
|
@@ -29232,24 +29442,34 @@ function attrValueMayBeNullish(parsed, ctx, isShadowed = () => false) {
|
|
|
29232
29442
|
return parsed !== undefined && walk(parsed, isShadowed);
|
|
29233
29443
|
}
|
|
29234
29444
|
function arithmeticOperandIsNull(parsed, ctx, isShadowed = () => false) {
|
|
29445
|
+
return arithmeticOperandSeed(parsed, ctx, isShadowed) === "null";
|
|
29446
|
+
}
|
|
29447
|
+
function arithmeticOperandIsUndefined(parsed, ctx, isShadowed = () => false) {
|
|
29448
|
+
return arithmeticOperandSeed(parsed, ctx, isShadowed) === "undefined";
|
|
29449
|
+
}
|
|
29450
|
+
function arithmeticOperandSeed(parsed, ctx, isShadowed) {
|
|
29235
29451
|
const visiting = new Set;
|
|
29236
29452
|
const walk = (expr, shadowed) => {
|
|
29237
29453
|
if (expr.kind === "literal")
|
|
29238
|
-
return expr.literalType === "null";
|
|
29454
|
+
return expr.literalType === "null" ? "null" : null;
|
|
29455
|
+
if (expr.kind === "identifier" && expr.name === "undefined" && !shadowed("undefined"))
|
|
29456
|
+
return "undefined";
|
|
29239
29457
|
const getter = expr.kind === "identifier" ? expr.name : bareGetterCallName(expr);
|
|
29240
29458
|
if (getter === null || shadowed(getter))
|
|
29241
|
-
return
|
|
29459
|
+
return null;
|
|
29242
29460
|
if (ctx.nullSeededSignals?.has(getter))
|
|
29243
|
-
return
|
|
29461
|
+
return "null";
|
|
29462
|
+
if (ctx.undefinedSeededSignals?.has(getter))
|
|
29463
|
+
return "undefined";
|
|
29244
29464
|
const memo = ctx.memos.get(getter);
|
|
29245
29465
|
if (!memo?.parsed || visiting.has(getter))
|
|
29246
|
-
return
|
|
29466
|
+
return null;
|
|
29247
29467
|
visiting.add(getter);
|
|
29248
29468
|
const result = walk(memo.parsed, () => false);
|
|
29249
29469
|
visiting.delete(getter);
|
|
29250
29470
|
return result;
|
|
29251
29471
|
};
|
|
29252
|
-
return parsed
|
|
29472
|
+
return parsed === undefined ? null : walk(parsed, isShadowed);
|
|
29253
29473
|
}
|
|
29254
29474
|
var NULL_COERCING_ARITHMETIC_OPS = new Set(["-", "*", "/", "%", "**"]);
|
|
29255
29475
|
// src/query-href-lowering.ts
|
|
@@ -32602,6 +32822,7 @@ export {
|
|
|
32602
32822
|
traceableNames,
|
|
32603
32823
|
traceUpdatePath,
|
|
32604
32824
|
testAdapter,
|
|
32825
|
+
templateNameCollisionErrors,
|
|
32605
32826
|
stringifyParsedExpr,
|
|
32606
32827
|
stringifyBooleanTernaryBranches,
|
|
32607
32828
|
sortComparatorFromArrow,
|
|
@@ -32620,6 +32841,7 @@ export {
|
|
|
32620
32841
|
resolveDangerousInnerHtml,
|
|
32621
32842
|
resolveBodyDestructuredPropAliases,
|
|
32622
32843
|
resetCompilerCounters,
|
|
32844
|
+
renameFreeIdentifiers,
|
|
32623
32845
|
registerLoweringPlugin,
|
|
32624
32846
|
registerBuiltinLoweringPlugins,
|
|
32625
32847
|
queryHrefPlugin,
|
|
@@ -32658,6 +32880,7 @@ export {
|
|
|
32658
32880
|
isStringTypedOperand,
|
|
32659
32881
|
isStringConcatBinary,
|
|
32660
32882
|
isOpaqueLocalAccessorName,
|
|
32883
|
+
isNumericArithmeticResult,
|
|
32661
32884
|
isNullishLiteral,
|
|
32662
32885
|
isNullableSignal,
|
|
32663
32886
|
isLowerableObjectRestDestructure,
|
|
@@ -32707,6 +32930,7 @@ export {
|
|
|
32707
32930
|
foldBlockToExpr,
|
|
32708
32931
|
findUninstrumentedEffects,
|
|
32709
32932
|
findReachableNames,
|
|
32933
|
+
filterCaptureCollisions,
|
|
32710
32934
|
extractSsrDefaults,
|
|
32711
32935
|
extractFunctionParams,
|
|
32712
32936
|
extractArrowBodyExpression,
|
|
@@ -32763,9 +32987,11 @@ export {
|
|
|
32763
32987
|
buildComponentSummary,
|
|
32764
32988
|
buildComponentGraph,
|
|
32765
32989
|
buildComponentAnalysis,
|
|
32990
|
+
bareGetterCallName,
|
|
32766
32991
|
augmentInheritedPropAccesses,
|
|
32767
32992
|
attrValueMayBeNullish,
|
|
32768
32993
|
asCallbackMethodCall,
|
|
32994
|
+
arithmeticOperandIsUndefined,
|
|
32769
32995
|
arithmeticOperandIsNull,
|
|
32770
32996
|
applyCssLayerPrefix,
|
|
32771
32997
|
analyzeWastedReReruns,
|