@barefootjs/jinja 0.31.6 → 0.31.8

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.
@@ -1,11 +1,10 @@
1
1
  /**
2
- * Per-fixture build-time contracts for shapes the Jinja adapter
3
- * intentionally refuses to lower. Mirrors xslate's set the lowering
4
- * gates are shared code paths in the ported adapter (BF103/BF104 are
5
- * structural: cross-template child registration / destructure-loop-param
6
- * limits that apply identically regardless of target template language).
7
- * Consumed by this package's own conformance test (as `expectedDiagnostics`)
8
- * and by `bf compat` (issue-URL attribution).
2
+ * Per-fixture build-time contracts for shapes this adapter intentionally
3
+ * refuses to lower. Declared per adapter, not on the shared fixtures, so
4
+ * adding a new adapter never touches a cross-adapter file. Per-fixture
5
+ * rationale lives on each fixture's docstring
6
+ * (`packages/adapter-tests/fixtures/<id>.ts`) and spec/callback-fidelity.md;
7
+ * comments below only mark where this adapter's set diverges from siblings.
9
8
  */
10
9
  import type { ConformancePins } from '@barefootjs/jsx';
11
10
  export declare const conformancePins: ConformancePins;
@@ -1 +1 @@
1
- {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eAkJ7B,CAAA"}
1
+ {"version":3,"file":"conformance-pins.d.ts","sourceRoot":"","sources":["../src/conformance-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,eAAO,MAAM,eAAe,EAAE,eA+C7B,CAAA"}
package/dist/index.js CHANGED
@@ -189250,7 +189250,8 @@ var conformancePins = {
189250
189250
  { code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }
189251
189251
  ],
189252
189252
  "filter-nested-find-predicate": [{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }],
189253
- "date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2356" }]
189253
+ "date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2356" }],
189254
+ "rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }]
189254
189255
  };
189255
189256
  // src/render-divergences.ts
189256
189257
  var renderDivergences = {};
@@ -1,15 +1,10 @@
1
1
  /**
2
- * Render-level divergences against the shared conformance corpus
3
- * (Priority-12 edge-case sweep, #2168): fixtures that COMPILE clean on
4
- * this adapter but whose rendered output diverges from the Hono
5
- * reference on real Python jinja2.
6
- *
7
- * Consumed by this package's conformance test (its `skipJsx` set is
8
- * derived from these keys, so the skip list and this declaration can't
9
- * drift) and by `packages/compat`, which publishes the entries in the
10
- * fixture-divergences section of `ui/compat.lock.json` — surfaced on
11
- * the docs compatibility-matrix page. Graduating an entry means fixing
12
- * the adapter (or the shared compiler layer) and deleting the line.
2
+ * Fixtures that compile clean on this adapter but render divergent from the
3
+ * Hono reference on real Python jinja2. The conformance `skipJsx` set and
4
+ * `packages/compat`'s published fixture-divergences both derive from this
5
+ * one object, so the skip list and the declaration can't drift. Keep the
6
+ * file even when the set is empty — the next divergence lands here, not in
7
+ * a re-created file.
13
8
  */
14
9
  import type { RenderDivergences } from '@barefootjs/jsx';
15
10
  export declare const renderDivergences: RenderDivergences;
@@ -1 +1 @@
1
- {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAM/B,CAAA"}
1
+ {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAC/B,CAAA"}
package/dist/vite.js CHANGED
@@ -2310,6 +2310,7 @@ var ErrorCodes = {
2310
2310
  COMPONENT_REQUIRED_PROP_MISSING: "BF046",
2311
2311
  JSX_BRANCH_LOCAL_IN_CALLBACK: "BF047",
2312
2312
  SIBLING_COMPONENT_NOT_COMPILED: "BF048",
2313
+ RICH_TYPE_PROP_NOT_HYDRATABLE: "BF049",
2313
2314
  SHARED_PROGRAM_REQUIRED: "BF050",
2314
2315
  WRONG_PACKAGE_IMPORT: "BF051",
2315
2316
  BUILTIN_REQUIRES_IMPORT: "BF054",
@@ -2340,6 +2341,7 @@ var errorMessages = {
2340
2341
  [ErrorCodes.COMPONENT_REQUIRED_PROP_MISSING]: "Built-in component is missing a required prop.",
2341
2342
  [ErrorCodes.JSX_BRANCH_LOCAL_IN_CALLBACK]: "JSX-typed local declared inside an `if`-block cannot be referenced from a callback body (ref / event handler). " + "Render it as a child instead: `<div ref={...}>{local}</div>`.",
2342
2343
  [ErrorCodes.SIBLING_COMPONENT_NOT_COMPILED]: "Referenced component did not compile to a template, so this reference would throw " + "`ReferenceError` at render time. Multi-return JSX dispatch (a `switch` or `if`/`else` " + "chain across multiple JSX-returning branches) cannot compile as a component in a " + `'use client' file. Extract it to a separate non-"use client" file (where it is preserved ` + "verbatim, see #932), or rewrite it as a single-return ternary/conditional chain so the " + "component pipeline can compile it.",
2344
+ [ErrorCodes.RICH_TYPE_PROP_NOT_HYDRATABLE]: "Rich-typed prop cannot cross the bf-p hydration boundary as JSON.",
2343
2345
  [ErrorCodes.SHARED_PROGRAM_REQUIRED]: "Shared ts.Program required for type-based reactivity classification. This source imports a Reactive<T>-branded library (e.g. @barefootjs/form) whose getters cannot be classified by regex alone. Pass `options.program` (built via `createProgramForCorpus`) so the analyzer can resolve the brand through the TypeChecker.",
2344
2346
  [ErrorCodes.WRONG_PACKAGE_IMPORT]: "Import from wrong package.",
2345
2347
  [ErrorCodes.BUILTIN_REQUIRES_IMPORT]: "Built-in <Async> / <Region> must be imported from '@barefootjs/client'. " + "The compiler recognises these tags by their import (not by tag name), " + "so an unimported tag with this name is treated as an undeclared component.",
@@ -2373,6 +2375,8 @@ var HOST_RICH_TYPE_NAMES = new Set([
2373
2375
  "BigInt",
2374
2376
  "Function"
2375
2377
  ]);
2378
+ var JSON_REVIVABLE_RICH_TYPE_NAMES = new Set(["Date", "URL"]);
2379
+ var JSON_UNSAFE_RICH_TYPE_NAMES = new Set([...HOST_RICH_TYPE_NAMES].filter((n) => !JSON_REVIVABLE_RICH_TYPE_NAMES.has(n)));
2376
2380
  function baseTypeName(raw) {
2377
2381
  const idx = raw.indexOf("<");
2378
2382
  return (idx === -1 ? raw : raw.slice(0, idx)).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/jinja",
3
- "version": "0.31.6",
3
+ "version": "0.31.8",
4
4
  "description": "Jinja2 adapter for BarefootJS — compiles IR to .jinja templates and ships the Python BarefootJS rendering runtime; runs under any Python web framework (Flask, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,7 +53,7 @@
53
53
  "directory": "packages/adapter-jinja"
54
54
  },
55
55
  "dependencies": {
56
- "@barefootjs/shared": "0.31.6"
56
+ "@barefootjs/shared": "0.31.8"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@barefootjs/jsx": ">=0.2.0",
@@ -70,9 +70,9 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@barefootjs/adapter-tests": "0.1.0",
73
- "@barefootjs/jsx": "0.31.6",
74
- "@barefootjs/vite": "0.31.6",
75
- "@barefootjs/client": "0.31.6",
73
+ "@barefootjs/jsx": "0.31.8",
74
+ "@barefootjs/vite": "0.31.8",
75
+ "@barefootjs/client": "0.31.8",
76
76
  "typescript": "^5.0.0",
77
77
  "vite": "^6.0.0"
78
78
  }
@@ -1,89 +1,33 @@
1
1
  /**
2
- * Per-fixture build-time contracts for shapes the Jinja adapter
3
- * intentionally refuses to lower. Mirrors xslate's set the lowering
4
- * gates are shared code paths in the ported adapter (BF103/BF104 are
5
- * structural: cross-template child registration / destructure-loop-param
6
- * limits that apply identically regardless of target template language).
7
- * Consumed by this package's own conformance test (as `expectedDiagnostics`)
8
- * and by `bf compat` (issue-URL attribution).
2
+ * Per-fixture build-time contracts for shapes this adapter intentionally
3
+ * refuses to lower. Declared per adapter, not on the shared fixtures, so
4
+ * adding a new adapter never touches a cross-adapter file. Per-fixture
5
+ * rationale lives on each fixture's docstring
6
+ * (`packages/adapter-tests/fixtures/<id>.ts`) and spec/callback-fidelity.md;
7
+ * comments below only mark where this adapter's set diverges from siblings.
9
8
  */
10
9
 
11
10
  import type { ConformancePins } from '@barefootjs/jsx'
12
11
 
13
12
  export const conformancePins: ConformancePins = {
14
- // Off-subset filter predicate (`typeof`) the compiler can't lower; a
15
- // JS-runtime target runs it, a DSL adapter surfaces BF021 + `/* @client */`.
16
- // See spec/callback-fidelity.md.
17
13
  'filter-typeof-predicate': [{ code: 'BF021', severity: 'error' }],
18
- // Array-builder `.map()` body (imperative `push`-into-array preamble):
19
- // BF021, with a verified `/* @client */` escape — `map-array-builder-
20
- // body-client` (#2613). See that fixture's docstring.
21
14
  'map-array-builder-body': [{ code: 'BF021', severity: 'error' }],
22
15
  'map-array-builder-escaping': [{ code: 'BF021', severity: 'error' }],
23
- // `.fill(value)` mutates the receiver in place — no template lowering
24
- // on any DSL adapter; a JS-runtime target runs it, a DSL adapter
25
- // surfaces BF101 + `/* @client */`. See spec/callback-fidelity.md.
26
16
  'fill-unsupported': [{ code: 'BF101', severity: 'error' }],
27
- // Off-subset `.find()` / `.some()` / `.every()` predicate (`typeof`) the
28
- // compiler can't lower; a JS-runtime target runs it, a DSL adapter
29
- // surfaces BF101 + `/* @client */`. See spec/callback-fidelity.md.
30
17
  'find-typeof-predicate': [{ code: 'BF101', severity: 'error' }],
31
18
  'some-typeof-predicate': [{ code: 'BF101', severity: 'error' }],
32
19
  'every-typeof-predicate': [{ code: 'BF101', severity: 'error' }],
33
- // Off-subset `.reduce()` / `.reduceRight()` body / `.flatMap()`
34
- // projection (`typeof`) the compiler can't lower; a JS-runtime target
35
- // runs it, a DSL adapter surfaces BF101 + `/* @client */`.
36
- // See spec/callback-fidelity.md.
37
20
  'reduce-typeof-body': [{ code: 'BF101', severity: 'error' }],
38
21
  'reduce-right-typeof-body': [{ code: 'BF101', severity: 'error' }],
39
22
  'flatmap-typeof-projection': [{ code: 'BF101', severity: 'error' }],
40
- // JSX-returning `.flatMap()` body carried as structured segments i.e.
41
- // one with STATEMENTS (early returns, consts): a JS runtime executes it
42
- // verbatim; a DSL template runtime can't, so it refuses with BF021 +
43
- // `/* @client */` (pre-gate this emitted an empty loop body — silent
44
- // divergence). A pure PROJECTION body (`flatMap(it => it.tags.map(...))`,
45
- // e.g. the `flatmap-expression-body` fixture) is NOT pinned: it lowers to
46
- // neutral nested-loop IR this adapter templatizes natively.
47
- // See spec/callback-fidelity.md.
23
+ // A pure PROJECTION flatMap body (`flatmap-expression-body`) is NOT pinned
24
+ // it lowers to neutral nested-loop IR this adapter templatizes natively;
25
+ // only the statement-carrying body refuses.
48
26
  'tag-cloud': [{ code: 'BF021', severity: 'error' }],
49
- // A keyed `.map()` row body whose preamble builds a JSX leaf from item
50
- // state (`cells.push(<td>{stateLabel}</td>)`) embedded as `{cells}` — the
51
- // Stage 3 array-builder carrier, jsRuntime-only: a JS runtime runs it
52
- // verbatim (and patches the region on same-key updates, #2389), a DSL
53
- // adapter refuses with BF021 + `/* @client */`. See spec/callback-fidelity.md.
54
27
  'preamble-cells': [{ code: 'BF021', severity: 'error' }],
55
- // `todo-app` / `todo-app-ssr` no longer pinned (#2205) the conformance
56
- // harness now passes `siblingTemplatesRegistered: true` for fixtures with
57
- // sibling `components`, matching `bf build`'s real semantics, so the
58
- // BF103 loop-body cross-template check no longer fires spuriously. (Both
59
- // fixtures are still skipped on this adapter via `render-divergences.ts`
60
- // — #2209 — for an unrelated signal-seeding gap.)
61
- // `static-array-children` no longer pinned (#2208) — `items`'s
62
- // array-literal initializer is now recognized as fully-static
63
- // (`resolveStaticLoopSource`) and inlined as a native Jinja list/dict
64
- // literal in the `{% for %}` header, the same way a module-scope const's
65
- // value is already seeded.
66
- // #2087 Phase A/B widened the destructure gate (`isLowerableLoopDestructure`)
67
- // to admit array-index / nested-path fixed bindings, so the
68
- // `([emoji, users]) => ...` / `([id, t]) => ...` params in these two
69
- // fixtures no longer trip BF104 — the destructure itself now lowers
70
- // cleanly to a native `{% set %}` accessor. But both fixtures' loop
71
- // array is `entries`, a bare identifier bound to a function-scope local
72
- // const with a NON-inlineable initializer
73
- // (`Object.entries(props.x ?? {}).filter(...)`) — a pre-existing,
74
- // orthogonal limitation this adapter has always had (it only ever
75
- // INLINES a local const's value at its use site — numeric/string
76
- // literal, or a static-record-literal lookup — never binds one as a
77
- // `{% set %}` template local), just never reachable before because the
78
- // narrower pre-#2087 gate refused the destructure param first. Left
79
- // unhandled it would silently render an EMPTY list (Jinja's
80
- // `ChainableUndefined` tolerates iterating an unbound name as zero
81
- // iterations) instead of failing loudly, so `renderLoop` in
82
- // `jinja-adapter.ts` now detects this shape and raises BF101 instead —
83
- // see the "Loop array `<name>` is a local computed value" diagnostic.
84
- // Fixing the underlying gap (computed-array-from-props as a loop
85
- // source) is out of scope for #2087; tracked as a follow-up at
86
- // https://github.com/piconic-ai/barefootjs/issues/2321.
28
+ // Refused for the COMPUTED loop array (`const entries = Object.entries(...)
29
+ // .filter(...)`), not the destructure param (that lowers, #2087) — loud
30
+ // BF101 instead of Jinja's ChainableUndefined silently iterating zero times.
87
31
  'static-array-from-props': [
88
32
  {
89
33
  code: 'BF101',
@@ -91,9 +35,7 @@ export const conformancePins: ConformancePins = {
91
35
  issue: 'https://github.com/piconic-ai/barefootjs/issues/2321',
92
36
  },
93
37
  ],
94
- // BF101 (unresolvable computed loop array, see above) fires; BF103
95
- // (imported child in the loop body) no longer does now that the
96
- // conformance harness passes `siblingTemplatesRegistered: true` (#2205).
38
+ // No BF103 pin: the harness registers sibling templates (#2205).
97
39
  'static-array-from-props-with-component': [
98
40
  {
99
41
  code: 'BF101',
@@ -101,59 +43,17 @@ export const conformancePins: ConformancePins = {
101
43
  issue: 'https://github.com/piconic-ai/barefootjs/issues/2321',
102
44
  },
103
45
  ],
104
- // Rest-destructure / structured-path `.map()` callbacks (#2087 Phase B):
105
- // `isLowerableLoopDestructure` now admits fixed bindings at any
106
- // field/index depth, array-rest (`bf.slice`), and object-rest whose uses
107
- // are member reads or a `{...rest}` spread onto an intrinsic element
108
- // (`bf.omit` builds the TRUE residual dict). Each binding becomes a
109
- // native `{% set %}` local off the per-item var — see
110
- // `renderLoop`/`jinjaAccessorFromSegments` in `jinja-adapter.ts`. So
111
- // `rest-destructure-object-in-map`, `rest-destructure-object-spread-in-map`,
112
- // `rest-destructure-array-in-map`, `rest-destructure-nested-in-map`,
113
- // `destructure-array-index-in-map`, and `destructure-nested-object-in-map`
114
- // all render clean now — none of them are pinned here.
115
- // (button/kbd graduated: the site/ui Button/Kbd `<Slot>` `{...props}` /
116
- // `{...children.props}` component-spread now lowers via nested
117
- // `dict(base, **top)` calls — see `jinja-adapter.ts`'s `renderComponent`
118
- // — instead of refusing with BF101, so these two no longer need a pin
119
- // here.)
120
- // (`tagged-template-classname` graduated by #2092 — the tag resolves
121
- // through the interleave-tag catalogue and desugars to an untagged
122
- // template literal, so it lowers like any other className template.)
123
- // #2038: a filter predicate whose body contains a NESTED callback call
124
- // (`t => !picked().some(p => …)` / `t => picked().find(p => …)`). Jinja
125
- // has no inline comprehension-with-nested-callback form usable from the
126
- // evaluator-JSON `*_eval` payload mechanism (this adapter's ONLY
127
- // higher-order-callback lowering path — see `jinja-adapter.ts`'s file
128
- // header, divergence 3), so the compiler is loud (BF101) instead of
129
- // lossy, same as xslate. The `/* @client */` twin
130
- // (`filter-nested-callback-predicate-client`) has no pin here: it must
131
- // render clean on every adapter, which asserts the suppression contract.
132
- // Faithful lowering tracked: https://github.com/piconic-ai/barefootjs/issues/2320 (successor to #2038)
46
+ // #2038: no inline comprehension-with-nested-callback form via the
47
+ // evaluator-JSON `*_eval` mechanism (`jinja-adapter.ts`'s header,
48
+ // divergence 3) loud BF101 instead of lossy.
133
49
  'filter-nested-callback-predicate': [
134
50
  { code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2320' },
135
51
  ],
136
52
  'filter-nested-find-predicate': [{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2320' }],
137
- // NB: TOP-LEVEL `.find` / `.findIndex` / `.findLast` / `.findLastIndex`
138
- // (text position) are NOT pinned here like xslate (unlike mojo, which
139
- // refuses them), Jinja lowers them to `bf.find_eval` / `find_index_eval`
140
- // / etc. via the same evaluator-JSON mechanism as `.filter` / `.every` /
141
- // `.some`, so they render. Only the NESTED-in-a-predicate form above is
142
- // refused (#2038).
143
- // `array-map-function-reference` no longer pinned — a bare-identifier
144
- // `.map(format)` callback now resolves one hop to its declaration
145
- // (`resolveCallbackMethodFunctionReferences`, #2206), the same mechanism
146
- // #2090 established for `.sort(fnref)`.
147
- // `dangerous-inner-html` no longer pinned — a compile-time string-literal
148
- // `dangerouslySetInnerHTML={{ __html: '...' }}` is spliced directly into
149
- // the template as trusted raw text (`resolveDangerousInnerHtml`, #2207).
150
- // A dynamic/signal-derived value now lowers through Jinja's `| safe` filter
151
- // (#2319) — `dangerous-inner-html-dynamic` is no longer pinned and renders
152
- // to Hono parity, same as the static case.
153
- // #2273: a method call on a prop typed as a built-in host rich type
154
- // (Date, Map, …) has no catalogued lowering in any adapter — this is a
155
- // compiler-level refusal (`checkRichTypeMethodCalls`, wired ahead of
156
- // `adapter.generate()`), not an adapter-specific gap, so it is pinned
157
- // identically across every adapter package including Hono.
53
+ // Top-level `.find`/`.findIndex`/`.findLast`/`.findLastIndex` are NOT
54
+ // pinned unlike mojo (which refuses them), Jinja lowers them via the
55
+ // same evaluator-JSON mechanism as `.filter`/`.some`. Only the nested form
56
+ // above is refused.
158
57
  'date-method-uncatalogued': [{ code: 'BF021', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2356' }],
58
+ 'rich-prop-client-read': [{ code: 'BF049', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2648' }],
159
59
  }
@@ -1,23 +1,13 @@
1
1
  /**
2
- * Render-level divergences against the shared conformance corpus
3
- * (Priority-12 edge-case sweep, #2168): fixtures that COMPILE clean on
4
- * this adapter but whose rendered output diverges from the Hono
5
- * reference on real Python jinja2.
6
- *
7
- * Consumed by this package's conformance test (its `skipJsx` set is
8
- * derived from these keys, so the skip list and this declaration can't
9
- * drift) and by `packages/compat`, which publishes the entries in the
10
- * fixture-divergences section of `ui/compat.lock.json` — surfaced on
11
- * the docs compatibility-matrix page. Graduating an entry means fixing
12
- * the adapter (or the shared compiler layer) and deleting the line.
2
+ * Fixtures that compile clean on this adapter but render divergent from the
3
+ * Hono reference on real Python jinja2. The conformance `skipJsx` set and
4
+ * `packages/compat`'s published fixture-divergences both derive from this
5
+ * one object, so the skip list and the declaration can't drift. Keep the
6
+ * file even when the set is empty — the next divergence lands here, not in
7
+ * a re-created file.
13
8
  */
14
9
 
15
10
  import type { RenderDivergences } from '@barefootjs/jsx'
16
11
 
17
12
  export const renderDivergences: RenderDivergences = {
18
- // `todo-app` / `todo-app-ssr` no longer diverge (#2209) — the shared
19
- // `evaluateSignalInit` (`@barefootjs/jsx`, sandboxed real-JS evaluation
20
- // instead of a fixed regex-shape catalogue) now correctly seeds `todos`
21
- // from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))`.
22
-
23
13
  }