@barefootjs/jsx 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/dangerous-inner-html.d.ts +52 -24
- package/dist/adapters/dangerous-inner-html.d.ts.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/index.js +248 -110
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts +15 -1
- 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/plan/build-reactive-effects.d.ts +9 -6
- package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +11 -5
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts +27 -1
- package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts +24 -2
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +13 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/to-locale-date-lowering.d.ts +31 -10
- package/dist/to-locale-date-lowering.d.ts.map +1 -1
- package/dist/types.d.ts +8 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/dangerous-inner-html-resolver.test.ts +27 -7
- package/src/__tests__/nested-loop-conditional.test.ts +133 -0
- package/src/__tests__/profile-nested-binding-ids.test.ts +5 -2
- package/src/__tests__/reactive-factory-cross-file.test.ts +252 -1
- package/src/__tests__/to-locale-date-lowering.test.ts +27 -2
- package/src/adapters/dangerous-inner-html.ts +101 -48
- package/src/analyzer.ts +222 -58
- package/src/ir-to-client-js/collect-elements.ts +28 -2
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +56 -2
- package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +30 -54
- package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +11 -5
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +78 -4
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +3 -25
- package/src/ir-to-client-js/reactivity.ts +61 -7
- package/src/ir-to-client-js/types.ts +13 -0
- package/src/rich-type-refusal.ts +3 -2
- package/src/to-locale-date-lowering.ts +50 -13
- package/src/types.ts +8 -4
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared `dangerouslySetInnerHTML={{ __html: expr }}` recognition + policy
|
|
3
|
-
* (#2207). Single place every template adapter calls
|
|
4
|
-
* so the injection-safety-relevant policy
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* (#2207, dynamic lowering #2319). Single place every template adapter calls
|
|
4
|
+
* from `renderElement`, so the injection-safety-relevant policy lives in
|
|
5
|
+
* exactly one reviewable spot instead of being re-derived independently in
|
|
6
|
+
* 8 adapters. `resolveDangerousInnerHtml` classifies the `__html` value into
|
|
7
|
+
* three cases the adapter then renders uniformly:
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* runtime raw-output primitive
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* into
|
|
9
|
+
* - `static` — a compile-time string literal. Spliced directly into the
|
|
10
|
+
* adapter's OWN template source as trusted text (same trust domain as
|
|
11
|
+
* hand-writing the HTML into the template), guarded per-adapter against
|
|
12
|
+
* that language's template metacharacters (`dangerousInnerHtmlMetachar
|
|
13
|
+
* Violation`). NOT routed through a runtime raw-output primitive — the
|
|
14
|
+
* value is fully known at compile time, so a runtime sink would reopen a
|
|
15
|
+
* template-source injection surface for no benefit.
|
|
16
|
+
*
|
|
17
|
+
* - `dynamic` — a prop-/signal-derived value (a signal read, prop, template
|
|
18
|
+
* literal WITH a substitution, local const, `??`-fallback, anything
|
|
19
|
+
* non-literal). The adapter serializes the `__html` expression via its own
|
|
20
|
+
* `convertExpressionTo<Lang>` and wraps the result in its runtime
|
|
21
|
+
* raw-output sink (Blade `{!! !!}`, ERB bare `<%= %>`, Go `template.HTML`,
|
|
22
|
+
* Jinja/MiniJinja `|safe`, Twig `|raw`, Mojolicious `<%== %>`, Xslate
|
|
23
|
+
* `mark_raw`). The runtime evaluates the expression at request time — the
|
|
24
|
+
* VALUE is never spliced into template source, so no metachar guard
|
|
25
|
+
* applies. This matches React's contract ("dangerously" = the caller owns
|
|
26
|
+
* the value's safety) and the Hono/CSR path, which already drives a
|
|
27
|
+
* `createEffect`-based `el.innerHTML = …` assignment (see
|
|
28
|
+
* `ir-to-client-js/emit-reactive.ts`).
|
|
29
|
+
*
|
|
30
|
+
* - `unlowerable` — the value is not a `{ __html: <expr> }` object literal
|
|
31
|
+
* at all (bare boolean/spread, or a variable holding the object). No
|
|
32
|
+
* `__html` expression to lower, so the adapter refuses with `BF101`.
|
|
24
33
|
*/
|
|
25
34
|
import type { CompilerError, IRAttribute, IRElement, SourceLocation } from '../types.ts';
|
|
35
|
+
import { type ParsedExpr } from '../expression-parser.ts';
|
|
26
36
|
export declare function isDangerousInnerHtmlAttr(attr: IRAttribute): boolean;
|
|
27
37
|
export type DangerousInnerHtmlResolution = {
|
|
28
38
|
kind: 'static';
|
|
29
39
|
html: string;
|
|
30
40
|
} | {
|
|
31
41
|
kind: 'dynamic';
|
|
42
|
+
valueExpr: string;
|
|
43
|
+
valueParsed: ParsedExpr;
|
|
44
|
+
loc: SourceLocation;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'unlowerable';
|
|
32
47
|
expr: string;
|
|
33
48
|
loc: SourceLocation;
|
|
34
49
|
};
|
|
@@ -68,10 +83,23 @@ export declare function resolveDangerousInnerHtml(element: IRElement): Dangerous
|
|
|
68
83
|
export declare function dangerousInnerHtmlMetacharViolation(html: string, adapterId: string): string | null;
|
|
69
84
|
/**
|
|
70
85
|
* Purpose-built `BF101` for a `dangerouslySetInnerHTML` value this adapter
|
|
71
|
-
* can't lower
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
86
|
+
* can't lower. Two distinct failure families funnel through here, so the base
|
|
87
|
+
* message is chosen by whether a `reason` is supplied:
|
|
88
|
+
*
|
|
89
|
+
* - WITHOUT a `reason` — the value is not the required SHAPE: it must be an
|
|
90
|
+
* object literal with exactly one `__html` property (no spreads, extra keys,
|
|
91
|
+
* or computed keys). The message states that contract so a near-miss like
|
|
92
|
+
* `{ __html: x, extra: 1 }` (refused as `unlowerable`) doesn't get told it
|
|
93
|
+
* "expects an { __html: … }" it already appears to have.
|
|
94
|
+
* - WITH a `reason` — the value IS a well-formed `{ __html: … }` object
|
|
95
|
+
* literal that this adapter still can't lower: a static literal carrying
|
|
96
|
+
* template metacharacters (`dangerousInnerHtmlMetacharViolation`), or — on
|
|
97
|
+
* the Go adapter — a template-literal / conditional inner expression with no
|
|
98
|
+
* single-argument raw form. The `reason` is the real story; the base states
|
|
99
|
+
* only that the value can't be lowered here, not that the shape is wrong.
|
|
100
|
+
*
|
|
101
|
+
* A genuinely dynamic value with a lowerable inner expression no longer
|
|
102
|
+
* reaches here — it is lowered through the adapter's raw-output sink (#2319).
|
|
75
103
|
*/
|
|
76
104
|
export declare function dangerousInnerHtmlDiagnostic(expr: string, loc: SourceLocation, reason?: string): CompilerError;
|
|
77
105
|
//# sourceMappingURL=dangerous-inner-html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dangerous-inner-html.d.ts","sourceRoot":"","sources":["../../src/adapters/dangerous-inner-html.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dangerous-inner-html.d.ts","sourceRoot":"","sources":["../../src/adapters/dangerous-inner-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAI/F,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAEnE;AAED,MAAM,MAAM,4BAA4B,GAIpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAahC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,cAAc,CAAA;CAAE,GAKpF;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,cAAc,CAAA;CAAE,CAAA;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,SAAS,GAAG,4BAA4B,GAAG,IAAI,CAyBjG;AAmED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOlG;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,cAAc,EACnB,MAAM,CAAC,EAAE,MAAM,GACd,aAAa,CAcf"}
|
package/dist/analyzer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAA;AAK3B,OAAO,EACL,KAAK,eAAe,EAUrB,MAAM,uBAAuB,CAAA;AAqB9B;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAU/D;AA8BD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf;IAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAA;CAAE,GAAG,IAAI,CA8CpF;AAMD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,GACnB,eAAe,CAwJjB;AAugBD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAavE;AAm4CD;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,OAAO,CA6BpE;AA2LD;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAuCzE;
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAA;AAK3B,OAAO,EACL,KAAK,eAAe,EAUrB,MAAM,uBAAuB,CAAA;AAqB9B;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EA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