@barefootjs/blade 0.18.4 → 0.18.7
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/adapter/blade-adapter.d.ts +56 -0
- package/dist/adapter/blade-adapter.d.ts.map +1 -1
- package/dist/adapter/expr/array-method.d.ts.map +1 -1
- package/dist/adapter/expr/emitters.d.ts +2 -2
- package/dist/adapter/expr/emitters.d.ts.map +1 -1
- package/dist/adapter/index.js +129 -18
- package/dist/adapter/lib/constants.d.ts.map +1 -1
- package/dist/adapter/lib/static-value.d.ts +13 -0
- package/dist/adapter/lib/static-value.d.ts.map +1 -0
- package/dist/adapter/props/prop-classes.d.ts +26 -9
- package/dist/adapter/props/prop-classes.d.ts.map +1 -1
- package/dist/build.js +129 -18
- package/dist/conformance-pins.d.ts.map +1 -1
- package/dist/index.js +132 -38
- package/dist/render-divergences.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/blade-adapter-unit.test.ts +141 -0
- package/src/adapter/blade-adapter.ts +180 -12
- package/src/adapter/expr/array-method.ts +19 -0
- package/src/adapter/expr/emitters.ts +2 -2
- package/src/adapter/lib/constants.ts +3 -0
- package/src/adapter/lib/static-value.ts +39 -0
- package/src/adapter/props/prop-classes.ts +30 -9
- package/src/conformance-pins.ts +25 -33
- package/src/render-divergences.ts +4 -16
- package/src/test-render.ts +10 -119
|
@@ -262,6 +262,14 @@ export declare class BladeAdapter extends BaseAdapter implements IRNodeEmitter<B
|
|
|
262
262
|
private options;
|
|
263
263
|
private errors;
|
|
264
264
|
private inLoop;
|
|
265
|
+
/**
|
|
266
|
+
* `IRLoop.depth` of the loop currently being rendered (save/restore
|
|
267
|
+
* around `renderChildren(loop.children)`, mirroring `inLoop` above).
|
|
268
|
+
* `renderAttributes` reads this to derive the `key` → `data-key`/
|
|
269
|
+
* `data-key-N` suffix — the depth is IR-computed (jsx-to-ir.ts), not
|
|
270
|
+
* re-derived here (#2168 nested-loop-outer-binding).
|
|
271
|
+
*/
|
|
272
|
+
private currentLoopKeyDepth;
|
|
265
273
|
/**
|
|
266
274
|
* SolidJS-style props identifier (`function(props: P)`) and the
|
|
267
275
|
* analyzer-extracted prop names. Stashed at `generate()` entry so the
|
|
@@ -310,6 +318,16 @@ export declare class BladeAdapter extends BaseAdapter implements IRNodeEmitter<B
|
|
|
310
318
|
* const (`const sizeAttrs = size ? {…} : {}`) to its initializer text.
|
|
311
319
|
*/
|
|
312
320
|
private localConstants;
|
|
321
|
+
/**
|
|
322
|
+
* Every name a `.map()`/`.filter()` loop callback binds as its item/index
|
|
323
|
+
* parameter anywhere in the component (#2208 fable review). A static
|
|
324
|
+
* loop-SOURCE name (e.g. a function-scope `const items = [...]`) must
|
|
325
|
+
* never resolve through `resolveStaticLoopSource` at a use site where a
|
|
326
|
+
* DIFFERENT, enclosing loop's own callback param shadows it — same
|
|
327
|
+
* shadowing hazard, and same coarse-but-safe mitigation, as #2212's
|
|
328
|
+
* `collectLoopBoundNames` use in `collectStringValueNames`.
|
|
329
|
+
*/
|
|
330
|
+
private staticLoopSourceBoundNames;
|
|
313
331
|
/**
|
|
314
332
|
* Optional, no-default props that are `None` when the caller omits them.
|
|
315
333
|
* Their bare-reference attribute emission is guarded with a Blade
|
|
@@ -361,6 +379,20 @@ export declare class BladeAdapter extends BaseAdapter implements IRNodeEmitter<B
|
|
|
361
379
|
private providerObjectLiteralBlade;
|
|
362
380
|
emitAsync(node: IRAsync, _ctx: BladeRenderCtx, _emit: EmitIRNode<BladeRenderCtx>): string;
|
|
363
381
|
renderElement(element: IRElement): string;
|
|
382
|
+
/**
|
|
383
|
+
* `dangerouslySetInnerHTML={{ __html: '...' }}` (#2207) — replaces the
|
|
384
|
+
* element's normal children with a compile-time-literal raw-HTML string,
|
|
385
|
+
* spliced directly as template text (never through a `{!! !!}`-style
|
|
386
|
+
* runtime raw-output primitive: the value is already fully known at
|
|
387
|
+
* compile time, so no runtime escape hatch is needed, and using one would
|
|
388
|
+
* reopen a template-source injection surface for no benefit). Returns
|
|
389
|
+
* `null` when the attribute is absent (caller falls through to normal
|
|
390
|
+
* `renderChildren`); a non-`null` string (possibly `''`) means the caller
|
|
391
|
+
* must use it as-is instead — including the dynamic/guard-violation
|
|
392
|
+
* refusal cases, where the empty string is safe filler for a compile that
|
|
393
|
+
* fails anyway.
|
|
394
|
+
*/
|
|
395
|
+
private renderDangerousInnerHtml;
|
|
364
396
|
renderExpression(expr: IRExpression): string;
|
|
365
397
|
renderConditional(cond: IRConditional): string;
|
|
366
398
|
private renderNodeOrNull;
|
|
@@ -525,8 +557,32 @@ export declare class BladeAdapter extends BaseAdapter implements IRNodeEmitter<B
|
|
|
525
557
|
* single-quoted string literal (`const totalPages = 5`, #1897
|
|
526
558
|
* pagination) — function-scope consts never reach the per-render
|
|
527
559
|
* context, so a bare reference would resolve to an undefined variable.
|
|
560
|
+
*
|
|
561
|
+
* The lookup is a flat name match with no notion of AST scope, so a
|
|
562
|
+
* name that any loop callback binds as its item/index param never
|
|
563
|
+
* inlines (#2221) — the occurrence may be the loop's own (shadowing)
|
|
564
|
+
* binding, and substituting the outer const's value there renders every
|
|
565
|
+
* iteration with the same hard-coded literal. Coarse (a genuinely
|
|
566
|
+
* non-shadowed same-named const elsewhere in the component also stops
|
|
567
|
+
* inlining, falling back to the bare identifier) but safe — the same
|
|
568
|
+
* trade-off as #2212's `collectLoopBoundNames` use in
|
|
569
|
+
* `collectStringValueNames`.
|
|
528
570
|
*/
|
|
529
571
|
private _resolveLiteralConst;
|
|
572
|
+
/**
|
|
573
|
+
* Resolve `IDENT.key` where `IDENT` is a module-scope object-literal const
|
|
574
|
+
* (`variantClasses.ghost`, #1896/#1897) to the looked-up scalar.
|
|
575
|
+
*
|
|
576
|
+
* The lookup is a flat name match on `objectName` with no notion of AST
|
|
577
|
+
* scope, so an enclosing loop callback's own param of the same name
|
|
578
|
+
* (`.map((cfg) => <li>{cfg.x}</li>)` shadowing a module `const cfg = {…}`)
|
|
579
|
+
* still resolved to the OUTER const's member value at every iteration
|
|
580
|
+
* (#2237) — the sibling hazard to #2221's `_resolveLiteralConst`. Same
|
|
581
|
+
* coarse-but-safe `staticLoopSourceBoundNames` guard: any name a loop
|
|
582
|
+
* binds anywhere in the component never inlines, falling back to the bare
|
|
583
|
+
* `data_get($cfg, 'x')` member expression (which a Blade `@foreach`
|
|
584
|
+
* binds correctly at the shadowed occurrences).
|
|
585
|
+
*/
|
|
530
586
|
private _resolveStaticRecordLiteral;
|
|
531
587
|
private _resolveModuleStringConst;
|
|
532
588
|
private _recordExprBF101;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blade-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/blade-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6OG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAKP,yBAAyB,EAE1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"blade-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/blade-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,CAO3C;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IAKrB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,4BAA4B;CAGrC;AAED,eAAO,MAAM,YAAY,cAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-method.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/array-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAA;AAGxB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,
|
|
1
|
+
{"version":3,"file":"array-method.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/array-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAA;AAGxB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAgJR;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,CAAC,CAAC,EAAE,U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M,GAC9B,MAAM,CAmBR"}
|
|
@@ -111,7 +111,7 @@ export declare class BladeFilterEmitter implements ParsedExprEmitter {
|
|
|
111
111
|
constructor(param: string, localVarMap: Map<string, string>, isStringName?: (n: string) => boolean, onUnsupported?: ((message: string, reason?: string) => void) | undefined);
|
|
112
112
|
identifier(name: string): string;
|
|
113
113
|
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
114
|
-
member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
|
|
114
|
+
member(object: ParsedExpr, property: string, _computed: boolean, _optional: boolean, emit: (e: ParsedExpr) => string): string;
|
|
115
115
|
indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
116
116
|
call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
117
117
|
unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
@@ -145,7 +145,7 @@ export declare class BladeTopLevelEmitter implements ParsedExprEmitter {
|
|
|
145
145
|
constructor(ctx: BladeEmitContext);
|
|
146
146
|
identifier(name: string): string;
|
|
147
147
|
literal(value: string | number | boolean | null, literalType: LiteralType): string;
|
|
148
|
-
member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
|
|
148
|
+
member(object: ParsedExpr, property: string, _computed: boolean, _optional: boolean, emit: (e: ParsedExpr) => string): string;
|
|
149
149
|
indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
150
150
|
call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
|
|
151
151
|
unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,UAAU,CACR,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,EACvC,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAER;IAED,WAAW,CACT,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAGR;IAED,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAyB9E;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAMlD;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;IAED,aAAa,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAWzG;CACF"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -187308,7 +187308,13 @@ import {
|
|
|
187308
187308
|
prepareLoweringMatchers,
|
|
187309
187309
|
queryHrefArgs,
|
|
187310
187310
|
sortComparatorFromArrow as sortComparatorFromArrow2,
|
|
187311
|
-
isValidHelperId
|
|
187311
|
+
isValidHelperId,
|
|
187312
|
+
isDangerousInnerHtmlAttr,
|
|
187313
|
+
resolveDangerousInnerHtml,
|
|
187314
|
+
dangerousInnerHtmlMetacharViolation,
|
|
187315
|
+
dangerousInnerHtmlDiagnostic,
|
|
187316
|
+
resolveStaticLoopSource,
|
|
187317
|
+
collectLoopBoundNames as collectLoopBoundNames2
|
|
187312
187318
|
} from "@barefootjs/jsx";
|
|
187313
187319
|
|
|
187314
187320
|
// src/adapter/boolean-result.ts
|
|
@@ -187369,7 +187375,7 @@ function isAriaBooleanAttr(name) {
|
|
|
187369
187375
|
}
|
|
187370
187376
|
|
|
187371
187377
|
// src/adapter/blade-adapter.ts
|
|
187372
|
-
import { BF_SLOT, BF_COND, BF_REGION } from "@barefootjs/shared";
|
|
187378
|
+
import { BF_SLOT, BF_COND, BF_REGION, escapeHtml } from "@barefootjs/shared";
|
|
187373
187379
|
|
|
187374
187380
|
// src/adapter/lib/constants.ts
|
|
187375
187381
|
var BLADE_TEMPLATE_PRIMITIVES = {
|
|
@@ -187378,7 +187384,10 @@ var BLADE_TEMPLATE_PRIMITIVES = {
|
|
|
187378
187384
|
Number: { arity: 1, emit: (args) => `$bf->number(${args[0]})` },
|
|
187379
187385
|
"Math.floor": { arity: 1, emit: (args) => `$bf->floor(${args[0]})` },
|
|
187380
187386
|
"Math.ceil": { arity: 1, emit: (args) => `$bf->ceil(${args[0]})` },
|
|
187381
|
-
"Math.round": { arity: 1, emit: (args) => `$bf->round(${args[0]})` }
|
|
187387
|
+
"Math.round": { arity: 1, emit: (args) => `$bf->round(${args[0]})` },
|
|
187388
|
+
"Math.min": { arity: 2, emit: (args) => `$bf->min(${args[0]}, ${args[1]})` },
|
|
187389
|
+
"Math.max": { arity: 2, emit: (args) => `$bf->max(${args[0]}, ${args[1]})` },
|
|
187390
|
+
"Math.abs": { arity: 1, emit: (args) => `$bf->abs(${args[0]})` }
|
|
187382
187391
|
};
|
|
187383
187392
|
var BLADE_PRIMITIVE_EMIT_MAP = Object.fromEntries(Object.entries(BLADE_TEMPLATE_PRIMITIVES).map(([k, v]) => [k, v.emit]));
|
|
187384
187393
|
|
|
@@ -187512,6 +187521,12 @@ function renderArrayMethod(method, object, args, emit) {
|
|
|
187512
187521
|
const recv = emit(object);
|
|
187513
187522
|
return `$bf->trim(${recv})`;
|
|
187514
187523
|
}
|
|
187524
|
+
case "trimStart":
|
|
187525
|
+
case "trimEnd": {
|
|
187526
|
+
const fn = method === "trimStart" ? "trim_start" : "trim_end";
|
|
187527
|
+
const recv = emit(object);
|
|
187528
|
+
return `$bf->${fn}(${recv})`;
|
|
187529
|
+
}
|
|
187515
187530
|
case "toFixed": {
|
|
187516
187531
|
const recv = emit(object);
|
|
187517
187532
|
const digits = args.length >= 1 ? emit(args[0]) : "0";
|
|
@@ -187545,6 +187560,12 @@ function renderArrayMethod(method, object, args, emit) {
|
|
|
187545
187560
|
const newS = emit(args[1]);
|
|
187546
187561
|
return `$bf->replace(${recv}, ${oldS}, ${newS})`;
|
|
187547
187562
|
}
|
|
187563
|
+
case "replaceAll": {
|
|
187564
|
+
const recv = emit(object);
|
|
187565
|
+
const oldS = emit(args[0]);
|
|
187566
|
+
const newS = emit(args[1]);
|
|
187567
|
+
return `$bf->replace_all(${recv}, ${oldS}, ${newS})`;
|
|
187568
|
+
}
|
|
187548
187569
|
case "repeat": {
|
|
187549
187570
|
const recv = emit(object);
|
|
187550
187571
|
const count = args.length === 0 ? "0" : emit(args[0]);
|
|
@@ -187639,6 +187660,39 @@ function renderFlatMethod(recv, depth, emit) {
|
|
|
187639
187660
|
return `$bf->flat(${recv}, ${d})`;
|
|
187640
187661
|
}
|
|
187641
187662
|
|
|
187663
|
+
// src/adapter/lib/static-value.ts
|
|
187664
|
+
function staticValueToBlade(value) {
|
|
187665
|
+
if (value === null || value === undefined)
|
|
187666
|
+
return "null";
|
|
187667
|
+
if (typeof value === "boolean")
|
|
187668
|
+
return value ? "true" : "false";
|
|
187669
|
+
if (typeof value === "number")
|
|
187670
|
+
return String(value);
|
|
187671
|
+
if (typeof value === "string")
|
|
187672
|
+
return `'${escapeBladeSingleQuoted(value)}'`;
|
|
187673
|
+
if (Array.isArray(value)) {
|
|
187674
|
+
const items = [];
|
|
187675
|
+
for (const el of value) {
|
|
187676
|
+
const serialized = staticValueToBlade(el);
|
|
187677
|
+
if (serialized === null)
|
|
187678
|
+
return null;
|
|
187679
|
+
items.push(serialized);
|
|
187680
|
+
}
|
|
187681
|
+
return `[${items.join(", ")}]`;
|
|
187682
|
+
}
|
|
187683
|
+
if (typeof value === "object") {
|
|
187684
|
+
const entries = [];
|
|
187685
|
+
for (const [key, val] of Object.entries(value)) {
|
|
187686
|
+
const serialized = staticValueToBlade(val);
|
|
187687
|
+
if (serialized === null)
|
|
187688
|
+
return null;
|
|
187689
|
+
entries.push(`${bladeHashKey(key)} => ${serialized}`);
|
|
187690
|
+
}
|
|
187691
|
+
return `[${entries.join(", ")}]`;
|
|
187692
|
+
}
|
|
187693
|
+
return null;
|
|
187694
|
+
}
|
|
187695
|
+
|
|
187642
187696
|
// src/adapter/expr/emitters.ts
|
|
187643
187697
|
import {
|
|
187644
187698
|
groupBinaryOperand,
|
|
@@ -187688,7 +187742,7 @@ class BladeFilterEmitter {
|
|
|
187688
187742
|
return "null";
|
|
187689
187743
|
return String(value);
|
|
187690
187744
|
}
|
|
187691
|
-
member(object, property, _computed, emit) {
|
|
187745
|
+
member(object, property, _computed, _optional, emit) {
|
|
187692
187746
|
if (property === "length") {
|
|
187693
187747
|
return `$bf->length(${emit(object)})`;
|
|
187694
187748
|
}
|
|
@@ -187799,7 +187853,7 @@ class BladeTopLevelEmitter {
|
|
|
187799
187853
|
return "null";
|
|
187800
187854
|
return String(value);
|
|
187801
187855
|
}
|
|
187802
|
-
member(object, property, _computed, emit) {
|
|
187856
|
+
member(object, property, _computed, _optional, emit) {
|
|
187803
187857
|
if (object.kind === "identifier" && object.name === "props") {
|
|
187804
187858
|
return bladeVar(property);
|
|
187805
187859
|
}
|
|
@@ -188178,6 +188232,9 @@ function generateDerivedMemoSeed(ctx, ir) {
|
|
|
188178
188232
|
` : "";
|
|
188179
188233
|
}
|
|
188180
188234
|
|
|
188235
|
+
// src/adapter/props/prop-classes.ts
|
|
188236
|
+
import { collectLoopBoundNames } from "@barefootjs/jsx";
|
|
188237
|
+
|
|
188181
188238
|
// src/adapter/value/parsed-literal.ts
|
|
188182
188239
|
import { evalStringArrayJoin } from "@barefootjs/jsx";
|
|
188183
188240
|
function isStringTypeInfo(type2) {
|
|
@@ -188208,6 +188265,12 @@ function collectStringValueNames(ir) {
|
|
|
188208
188265
|
if (isStringTypeInfo(p.type))
|
|
188209
188266
|
names.add(p.name);
|
|
188210
188267
|
}
|
|
188268
|
+
for (const c of ir.metadata.localConstants) {
|
|
188269
|
+
if (isStringTypeInfo(c.type ?? undefined) || isBareStringLiteral(c.value))
|
|
188270
|
+
names.add(c.name);
|
|
188271
|
+
}
|
|
188272
|
+
for (const bound of collectLoopBoundNames(ir))
|
|
188273
|
+
names.delete(bound);
|
|
188211
188274
|
return names;
|
|
188212
188275
|
}
|
|
188213
188276
|
|
|
@@ -188223,6 +188286,7 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188223
188286
|
options;
|
|
188224
188287
|
errors = [];
|
|
188225
188288
|
inLoop = false;
|
|
188289
|
+
currentLoopKeyDepth = 0;
|
|
188226
188290
|
propsObjectName = null;
|
|
188227
188291
|
propsParams = [];
|
|
188228
188292
|
booleanTypedProps = new Set;
|
|
@@ -188231,6 +188295,7 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188231
188295
|
_searchParamsLocals = new Set;
|
|
188232
188296
|
_loweringMatchers = [];
|
|
188233
188297
|
localConstants = [];
|
|
188298
|
+
staticLoopSourceBoundNames = new Set;
|
|
188234
188299
|
nullableOptionalProps = new Set;
|
|
188235
188300
|
constructor(options = {}) {
|
|
188236
188301
|
super();
|
|
@@ -188246,6 +188311,7 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188246
188311
|
this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name }));
|
|
188247
188312
|
this.booleanTypedProps = collectBooleanTypedProps(ir);
|
|
188248
188313
|
this.localConstants = ir.metadata.localConstants ?? [];
|
|
188314
|
+
this.staticLoopSourceBoundNames = collectLoopBoundNames2(ir);
|
|
188249
188315
|
this.nullableOptionalProps = collectNullableOptionalProps(ir);
|
|
188250
188316
|
this.stringValueNames = collectStringValueNames(ir);
|
|
188251
188317
|
this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
|
|
@@ -188299,7 +188365,7 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188299
188365
|
return this.renderElement(node);
|
|
188300
188366
|
}
|
|
188301
188367
|
emitText(node) {
|
|
188302
|
-
return node.value;
|
|
188368
|
+
return escapeHtml(node.value);
|
|
188303
188369
|
}
|
|
188304
188370
|
emitExpression(node) {
|
|
188305
188371
|
return this.renderExpression(node);
|
|
@@ -188367,7 +188433,8 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188367
188433
|
renderElement(element) {
|
|
188368
188434
|
const tag = element.tag;
|
|
188369
188435
|
const attrs = this.renderAttributes(element);
|
|
188370
|
-
const
|
|
188436
|
+
const dangerousHtml = this.renderDangerousInnerHtml(element);
|
|
188437
|
+
const children = dangerousHtml !== null ? dangerousHtml : this.renderChildren(element.children);
|
|
188371
188438
|
let hydrationAttrs = "";
|
|
188372
188439
|
if (element.needsScope) {
|
|
188373
188440
|
hydrationAttrs += ` ${this.renderScopeMarker("")}`;
|
|
@@ -188402,6 +188469,22 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188402
188469
|
}
|
|
188403
188470
|
return `<${tag}${attrs}${hydrationAttrs}>${children}</${tag}>`;
|
|
188404
188471
|
}
|
|
188472
|
+
renderDangerousInnerHtml(element) {
|
|
188473
|
+
const resolution = resolveDangerousInnerHtml(element);
|
|
188474
|
+
if (!resolution)
|
|
188475
|
+
return null;
|
|
188476
|
+
if (resolution.kind === "dynamic") {
|
|
188477
|
+
this.errors.push(dangerousInnerHtmlDiagnostic(resolution.expr, resolution.loc));
|
|
188478
|
+
return "";
|
|
188479
|
+
}
|
|
188480
|
+
const violation = dangerousInnerHtmlMetacharViolation(resolution.html, this.name);
|
|
188481
|
+
if (violation) {
|
|
188482
|
+
const attr = element.attrs.find(isDangerousInnerHtmlAttr);
|
|
188483
|
+
this.errors.push(dangerousInnerHtmlDiagnostic(`{ __html: ${JSON.stringify(resolution.html)} }`, attr.loc, violation));
|
|
188484
|
+
return "";
|
|
188485
|
+
}
|
|
188486
|
+
return resolution.html;
|
|
188487
|
+
}
|
|
188405
188488
|
renderExpression(expr) {
|
|
188406
188489
|
if (expr.clientOnly) {
|
|
188407
188490
|
if (expr.slotId) {
|
|
@@ -188409,7 +188492,7 @@ class BladeAdapter extends BaseAdapter {
|
|
|
188409
188492
|
}
|
|
188410
188493
|
return "";
|
|
188411
188494
|
}
|
|
188412
|
-
const bladeExpr = `$bf->string(${this.convertExpressionToBlade(expr.expr)})`;
|
|
188495
|
+
const bladeExpr = `$bf->string(${this.convertExpressionToBlade(expr.expr, expr.parsed)})`;
|
|
188413
188496
|
if (expr.slotId) {
|
|
188414
188497
|
return `{!! $bf->text_start("${expr.slotId}") !!}{!! e(${bladeExpr}) !!}{!! $bf->text_end() !!}`;
|
|
188415
188498
|
}
|
|
@@ -188500,8 +188583,12 @@ ${whenTrue}
|
|
|
188500
188583
|
}
|
|
188501
188584
|
});
|
|
188502
188585
|
}
|
|
188586
|
+
const staticItems = resolveStaticLoopSource(loop.arrayParsed, this.localConstants, {
|
|
188587
|
+
isNameShadowed: (name) => this.staticLoopSourceBoundNames.has(name)
|
|
188588
|
+
});
|
|
188589
|
+
const staticArray = staticItems !== null ? staticValueToBlade(staticItems) : null;
|
|
188503
188590
|
const arrayName = loop.array.trim();
|
|
188504
|
-
if (/^[A-Za-z_$][\w$]*$/.test(arrayName)) {
|
|
188591
|
+
if (staticArray === null && /^[A-Za-z_$][\w$]*$/.test(arrayName)) {
|
|
188505
188592
|
const arrayConst = (this.localConstants ?? []).find((c) => c.name === arrayName);
|
|
188506
188593
|
if (arrayConst && !arrayConst.isModule && this._resolveLiteralConst(arrayName) === null) {
|
|
188507
188594
|
this.errors.push({
|
|
@@ -188515,7 +188602,7 @@ ${whenTrue}
|
|
|
188515
188602
|
});
|
|
188516
188603
|
}
|
|
188517
188604
|
}
|
|
188518
|
-
const rawArray = this.convertExpressionToBlade(loop.array);
|
|
188605
|
+
const rawArray = staticArray ?? this.convertExpressionToBlade(loop.array);
|
|
188519
188606
|
let array = rawArray;
|
|
188520
188607
|
if (loop.sortComparator) {
|
|
188521
188608
|
const sort = loop.sortComparator;
|
|
@@ -188529,7 +188616,7 @@ ${whenTrue}
|
|
|
188529
188616
|
const renderedChildren = this.renderChildren(loop.children);
|
|
188530
188617
|
const loopVar = loop.iterationShape === "keys" ? "__bf_item" : supportableDestructure ? "__bf_item" : param;
|
|
188531
188618
|
const indexLocalLines = [];
|
|
188532
|
-
if (loop.iterationShape === "keys") {
|
|
188619
|
+
if (loop.objectIteration) {} else if (loop.iterationShape === "keys") {
|
|
188533
188620
|
indexLocalLines.push(`@php(${bladeVar(param)} = $loop->index)`);
|
|
188534
188621
|
} else if (loop.index) {
|
|
188535
188622
|
indexLocalLines.push(`@php(${bladeVar(loop.index)} = $loop->index)`);
|
|
@@ -188550,13 +188637,17 @@ ${whenTrue}
|
|
|
188550
188637
|
}
|
|
188551
188638
|
const prevInLoop = this.inLoop;
|
|
188552
188639
|
this.inLoop = true;
|
|
188640
|
+
const prevLoopKeyDepth = this.currentLoopKeyDepth;
|
|
188641
|
+
this.currentLoopKeyDepth = loop.depth;
|
|
188553
188642
|
const childrenUnderLoop = this.renderChildren(loop.children);
|
|
188643
|
+
this.currentLoopKeyDepth = prevLoopKeyDepth;
|
|
188554
188644
|
this.inLoop = prevInLoop;
|
|
188555
188645
|
const bodyChildren = loop.bodyIsItemConditional && loop.key ? `{!! $bf->comment('loop-i:' . $bf->string(${this.convertExpressionToBlade(loop.key)})) !!}
|
|
188556
188646
|
${childrenUnderLoop}` : childrenUnderLoop;
|
|
188557
188647
|
const lines = [];
|
|
188558
188648
|
lines.push(`{!! $bf->comment("loop:${loop.markerId}") !!}`);
|
|
188559
|
-
|
|
188649
|
+
const forHeader = loop.objectIteration === "entries" ? `@foreach($bf->entries(${array} ?? []) as ${bladeVar(loop.index ?? param)} => ${bladeVar(param)})` : loop.objectIteration === "keys" ? `@foreach($bf->keys(${array} ?? []) as ${bladeVar(param)})` : loop.objectIteration === "values" ? `@foreach($bf->values(${array} ?? []) as ${bladeVar(param)})` : `@foreach((${array} ?? []) as ${bladeVar(loopVar)})`;
|
|
188650
|
+
lines.push(forHeader);
|
|
188560
188651
|
for (const il of indexLocalLines)
|
|
188561
188652
|
lines.push(il);
|
|
188562
188653
|
if (loop.filterPredicate) {
|
|
@@ -188626,9 +188717,22 @@ ${childrenUnderLoop}` : childrenUnderLoop;
|
|
|
188626
188717
|
renderComponent(comp) {
|
|
188627
188718
|
const segments = [{ kind: "entries", parts: [] }];
|
|
188628
188719
|
const currentEntries = () => this.componentPropSegmentEntries(segments);
|
|
188720
|
+
const namedSlotCaptures = [];
|
|
188629
188721
|
for (const p of comp.props) {
|
|
188630
188722
|
if ((p.name.match(/^on[A-Z]/) || p.name === "ref") && p.value.kind === "expression")
|
|
188631
188723
|
continue;
|
|
188724
|
+
if (p.value.kind === "jsx-children" && p.name !== "children") {
|
|
188725
|
+
const prevInLoop = this.inLoop;
|
|
188726
|
+
this.inLoop = false;
|
|
188727
|
+
const slotBody = this.renderChildren(p.value.children);
|
|
188728
|
+
this.inLoop = prevInLoop;
|
|
188729
|
+
const captureVar = bladeVar(`bf_prop_${this.childrenCaptureCounter++}`);
|
|
188730
|
+
namedSlotCaptures.push(`@php(ob_start())
|
|
188731
|
+
${slotBody}
|
|
188732
|
+
` + `@php(${captureVar} = $bf->backend->mark_raw(preg_replace('/\\n\\z/', '', ob_get_clean(), 1)))`);
|
|
188733
|
+
currentEntries().push(`${bladeHashKey(p.name)} => ${captureVar}`);
|
|
188734
|
+
continue;
|
|
188735
|
+
}
|
|
188632
188736
|
if (p.value.kind === "spread") {
|
|
188633
188737
|
const trimmed = p.value.expr.trim();
|
|
188634
188738
|
if (this.propsObjectName && this.propsObjectName === trimmed) {
|
|
@@ -188658,13 +188762,13 @@ ${childrenUnderLoop}` : childrenUnderLoop;
|
|
|
188658
188762
|
const captureVar = bladeVar(`bf_children_${comp.slotId ?? "c" + this.childrenCaptureCounter++}`);
|
|
188659
188763
|
currentEntries().push(`${bladeHashKey("children")} => ${captureVar}`);
|
|
188660
188764
|
const dict = this.combineComponentPropSegments(segments);
|
|
188661
|
-
return `@php(ob_start())
|
|
188765
|
+
return namedSlotCaptures.join("") + `@php(ob_start())
|
|
188662
188766
|
${childrenBody}
|
|
188663
188767
|
` + `@php(${captureVar} = $bf->backend->mark_raw(preg_replace('/\\n\\z/', '', ob_get_clean(), 1)))` + `{!! $bf->render_child('${tplName}', ${dict}) !!}`;
|
|
188664
188768
|
}
|
|
188665
188769
|
const isEmpty = segments.every((s) => s.kind === "entries" && s.parts.length === 0);
|
|
188666
188770
|
const dictEntries = isEmpty ? "" : `, ${this.combineComponentPropSegments(segments)}`;
|
|
188667
|
-
return
|
|
188771
|
+
return `${namedSlotCaptures.join("")}{!! $bf->render_child('${tplName}'${dictEntries}) !!}`;
|
|
188668
188772
|
}
|
|
188669
188773
|
childrenCaptureCounter = 0;
|
|
188670
188774
|
presenceVarCounter = 0;
|
|
@@ -188711,7 +188815,7 @@ ${fallback}
|
|
|
188711
188815
|
${children}`;
|
|
188712
188816
|
}
|
|
188713
188817
|
elementAttrEmitter = {
|
|
188714
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
188818
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
188715
188819
|
emitExpression: (value, name) => {
|
|
188716
188820
|
if (name === "style") {
|
|
188717
188821
|
const css = this.tryLowerStyleObject(value.expr);
|
|
@@ -188817,12 +188921,15 @@ ${name}="{!! e($bf->string(${val})) !!}"
|
|
|
188817
188921
|
for (const attr of element.attrs) {
|
|
188818
188922
|
if (attr.clientOnly)
|
|
188819
188923
|
continue;
|
|
188924
|
+
if (isDangerousInnerHtmlAttr(attr))
|
|
188925
|
+
continue;
|
|
188820
188926
|
let attrName;
|
|
188821
188927
|
if (attr.name === "className")
|
|
188822
188928
|
attrName = "class";
|
|
188823
|
-
else if (attr.name === "key")
|
|
188824
|
-
|
|
188825
|
-
|
|
188929
|
+
else if (attr.name === "key") {
|
|
188930
|
+
const depth = this.currentLoopKeyDepth;
|
|
188931
|
+
attrName = depth > 0 ? `data-key-${depth}` : "data-key";
|
|
188932
|
+
} else
|
|
188826
188933
|
attrName = attr.name;
|
|
188827
188934
|
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, attrName);
|
|
188828
188935
|
if (lowered)
|
|
@@ -189016,6 +189123,8 @@ Options:
|
|
|
189016
189123
|
return isBooleanResultExpr(expr) || isAriaBooleanAttr(name) || this.isBooleanTypedPropRef(expr);
|
|
189017
189124
|
}
|
|
189018
189125
|
_resolveLiteralConst(name) {
|
|
189126
|
+
if (this.staticLoopSourceBoundNames.has(name))
|
|
189127
|
+
return null;
|
|
189019
189128
|
const c = (this.localConstants ?? []).find((lc) => lc.name === name);
|
|
189020
189129
|
if (c?.value === undefined)
|
|
189021
189130
|
return null;
|
|
@@ -189028,6 +189137,8 @@ Options:
|
|
|
189028
189137
|
return null;
|
|
189029
189138
|
}
|
|
189030
189139
|
_resolveStaticRecordLiteral(objectName, key) {
|
|
189140
|
+
if (this.staticLoopSourceBoundNames.has(objectName))
|
|
189141
|
+
return null;
|
|
189031
189142
|
const hit = lookupStaticRecordLiteral(objectName, key, this.localConstants);
|
|
189032
189143
|
if (!hit)
|
|
189033
189144
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAUnE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAG7E,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize a compile-time-evaluated JS value (`@barefootjs/jsx`'s
|
|
3
|
+
* `evaluateStaticLiteral`/`resolveStaticLoopSource`, #2208) into a native
|
|
4
|
+
* PHP literal. Used to inline a fully-static loop source (an inline array
|
|
5
|
+
* literal, or a function-scope local const with a static initializer)
|
|
6
|
+
* directly in a `@foreach` header, rather than requiring a bound template
|
|
7
|
+
* variable.
|
|
8
|
+
*
|
|
9
|
+
* Returns `null` for a value this adapter can't represent as a literal —
|
|
10
|
+
* the caller falls back to its existing BF101 refusal instead of guessing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function staticValueToBlade(value: unknown): string | null;
|
|
13
|
+
//# sourceMappingURL=static-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-value.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/static-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAwBhE"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Pure functions over `ir.metadata` that derive the per-compile prop/name
|
|
6
6
|
* sets the adapter consults during lowering. No adapter instance state.
|
|
7
7
|
*/
|
|
8
|
-
import type
|
|
8
|
+
import { type ComponentIR } from '@barefootjs/jsx';
|
|
9
9
|
/**
|
|
10
10
|
* Props whose declared TS type is boolean — a bare binding of one
|
|
11
11
|
* (`data-active={props.isActive}`) must stringify as JS `String(boolean)`
|
|
@@ -21,14 +21,31 @@ export declare function collectBooleanTypedProps(ir: ComponentIR): Set<string>;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function collectNullableOptionalProps(ir: ComponentIR): Set<string>;
|
|
23
23
|
/**
|
|
24
|
-
* String-typed signals
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
24
|
+
* String-typed signals, props, and same-file local consts (#2212). A
|
|
25
|
+
* signal is string-typed when its inferred type is `string` (or,
|
|
26
|
+
* defensively, when its initial value is a bare string literal); a prop
|
|
27
|
+
* when its annotated type is `string`; a local const the same way. Consumed
|
|
28
|
+
* by `isStringConcatBinary`/`isStringTypedOperand` (`@barefootjs/jsx`) to
|
|
29
|
+
* pick `.` over JS `+`'s numeric fallback (#2163, #2212) — including now
|
|
30
|
+
* for a bare identifier operand, not just a prop/getter/literal. In the
|
|
31
|
+
* Mojo adapter this ALSO drives `eq`/`ne` selection for string equality;
|
|
32
|
+
* the Blade emitters don't consume the distinction there — `===`/`!==`
|
|
33
|
+
* ALWAYS route through `bf.eq`/`bf.neq` regardless of operand type (see
|
|
34
|
+
* `expr/emitters.ts`'s file header, divergence 4) — so that half of this
|
|
35
|
+
* set is carried only for parity with the Perl-family adapters.
|
|
36
|
+
*
|
|
37
|
+
* Excludes any name bound as a `.map()`/`.filter()` loop callback's item
|
|
38
|
+
* or index parameter ANYWHERE in the component (Fable review, #2212): the
|
|
39
|
+
* lookup below is a flat, scope-blind `Set<string>` with no notion of a
|
|
40
|
+
* loop param shadowing an outer string-typed binding of the same name
|
|
41
|
+
* (`items.map((name) => 1 + name)` inside a component that also has a
|
|
42
|
+
* string `name` prop) — left unguarded, that shadowed `name` would be
|
|
43
|
+
* misdetected as string-typed and `1 + name` would silently lower to `.`
|
|
44
|
+
* instead of staying numeric `+`. Subtracting loop-bound names is coarse
|
|
45
|
+
* (it also suppresses a genuinely non-shadowed same-named string
|
|
46
|
+
* elsewhere in the component) but safe: the suppressed case just falls
|
|
47
|
+
* back to today's numeric `+` — the same, already-accepted residual as an
|
|
48
|
+
* unresolvable operand — never silently-wrong output.
|
|
32
49
|
*/
|
|
33
50
|
export declare function collectStringValueNames(ir: ComponentIR): Set<string>;
|
|
34
51
|
//# sourceMappingURL=prop-classes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-classes.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-classes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"prop-classes.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-classes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGzE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAMrE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAWzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAepE"}
|