@barefootjs/jinja 0.18.0 → 0.18.2
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/conformance-pins.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -1
- package/dist/render-divergences.d.ts +16 -0
- package/dist/render-divergences.d.ts.map +1 -0
- package/package.json +3 -3
- package/python/README.md +43 -0
- package/python/pyproject.toml +1 -0
- package/src/__tests__/jinja-adapter.test.ts +8 -0
- package/src/conformance-pins.ts +11 -0
- package/src/index.ts +1 -0
- package/src/render-divergences.ts +44 -0
|
@@ -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,
|
|
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,eAmG7B,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@
|
|
|
6
6
|
export { JinjaAdapter, jinjaAdapter } from './adapter/index.ts';
|
|
7
7
|
export type { JinjaAdapterOptions } from './adapter/index.ts';
|
|
8
8
|
export { conformancePins } from './conformance-pins.ts';
|
|
9
|
+
export { renderDivergences } from './render-divergences.ts';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -189109,9 +189109,28 @@ var conformancePins = {
|
|
|
189109
189109
|
"filter-nested-find-predicate": [
|
|
189110
189110
|
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2038" }
|
|
189111
189111
|
],
|
|
189112
|
-
"array-map-function-reference": [{ code: "BF101", severity: "error" }]
|
|
189112
|
+
"array-map-function-reference": [{ code: "BF101", severity: "error" }],
|
|
189113
|
+
"dangerous-inner-html": [{ code: "BF101", severity: "error" }],
|
|
189114
|
+
"string-replaceall": [{ code: "BF101", severity: "error" }]
|
|
189115
|
+
};
|
|
189116
|
+
// src/render-divergences.ts
|
|
189117
|
+
var renderDivergences = {
|
|
189118
|
+
"arithmetic-text": "`(count() + 2) * 3` renders 10 instead of 18 — the parenthesised sub-expression loses its grouping (silent wrong arithmetic)",
|
|
189119
|
+
"falsy-text-values": '`{false}` renders "false" (Hono drops it); `{null}`/`{undefined}` render empty (Hono renders "null") — neither side matches JSX semantics',
|
|
189120
|
+
"html-entity-text": "`©` in JSX literal text: Hono decodes to `©`, this adapter re-emits the raw entity — same DOM, different bytes",
|
|
189121
|
+
"math-methods": "Math.min/max/abs over a signal render empty (only Math.floor is in the template-primitive registry)",
|
|
189122
|
+
"boolean-attr-literals": 'camelCase boolean alias `readOnly`: Hono SSRs `readOnly="true"`, this adapter emits bare presence',
|
|
189123
|
+
"camelcase-attributes": "`htmlFor` is not lowered to `for` (Hono maps it)",
|
|
189124
|
+
"static-attr-escape": 'static attribute values are not HTML-escaped (`title="Fish & Chips"` emitted raw; Hono escapes)',
|
|
189125
|
+
"svg-icon": "SVG camelCase presentation attrs (`strokeWidth`, `strokeLinecap`) pass through unmapped; Hono lowers to kebab-case",
|
|
189126
|
+
"object-entries-map": "`Object.entries(prop).map(([k, v]) => …)` renders an EMPTY list — the object-shaped prop silently produces zero iterations",
|
|
189127
|
+
"nested-loop-outer-binding": "nested-loop inner items carry `data-key` where the reference emits the depth-suffixed `data-key-1`",
|
|
189128
|
+
"jsx-element-prop": "a JSX element passed as a NON-children prop renders an empty slot — the element value is silently dropped",
|
|
189129
|
+
"string-slice": "`.slice()` on a STRING renders empty (array-slice helper misfires on strings)",
|
|
189130
|
+
"string-trim-sided": "`.trimStart()` / `.trimEnd()` render empty (no lowering)"
|
|
189113
189131
|
};
|
|
189114
189132
|
export {
|
|
189133
|
+
renderDivergences,
|
|
189115
189134
|
jinjaAdapter,
|
|
189116
189135
|
conformancePins,
|
|
189117
189136
|
JinjaAdapter
|
|
@@ -0,0 +1,16 @@
|
|
|
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.
|
|
13
|
+
*/
|
|
14
|
+
import type { RenderDivergences } from '@barefootjs/jsx';
|
|
15
|
+
export declare const renderDivergences: RenderDivergences;
|
|
16
|
+
//# sourceMappingURL=render-divergences.d.ts.map
|
|
@@ -0,0 +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,iBA2B/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/jinja",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
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,14 +53,14 @@
|
|
|
53
53
|
"directory": "packages/adapter-jinja"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@barefootjs/shared": "0.18.
|
|
56
|
+
"@barefootjs/shared": "0.18.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@barefootjs/jsx": ">=0.2.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
63
|
-
"@barefootjs/jsx": "0.18.
|
|
63
|
+
"@barefootjs/jsx": "0.18.2",
|
|
64
64
|
"typescript": "^5.0.0"
|
|
65
65
|
}
|
|
66
66
|
}
|
package/python/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# barefootjs
|
|
2
|
+
|
|
3
|
+
Python runtime for [BarefootJS](https://barefootjs.dev/) marked templates, targeting [Jinja2](https://jinja.palletsprojects.com/).
|
|
4
|
+
|
|
5
|
+
[BarefootJS](https://github.com/piconic-ai/barefootjs) is a fine-grained reactive TSX compiler: you write components in TSX, and the compiler emits templates for your backend's template engine plus the client-side JS that hydrates them. This package is the server half for Python — it renders the `.jinja` templates produced by the `@barefootjs/jinja` adapter.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pip install barefootjs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The only dependency is `jinja2`; everything else is stdlib.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
Generated `.jinja` templates call the `BarefootJS` instance as a `bf` object (`{{ bf.scope_attr() }}`, `{{ bf.json(x) }}`, `{{ bf.spread_attrs(bag) }}`):
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from barefootjs import BarefootJS, JinjaBackend
|
|
21
|
+
|
|
22
|
+
backend = JinjaBackend(paths=["templates"])
|
|
23
|
+
bf = BarefootJS(None, {"backend": backend})
|
|
24
|
+
html = backend.render_named("counter", bf, {"count": 0})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Package layout
|
|
28
|
+
|
|
29
|
+
| Module | Role |
|
|
30
|
+
|--------|------|
|
|
31
|
+
| `runtime.py` | the engine-agnostic `bf` object |
|
|
32
|
+
| `evaluator.py` | ParsedExpr evaluator for the `*_eval` helpers |
|
|
33
|
+
| `search_params.py` | `searchParams()` SSR reader |
|
|
34
|
+
| `backend_jinja.py` | the Jinja2 engine backend |
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
- [barefootjs.dev](https://barefootjs.dev/) — core documentation
|
|
39
|
+
- [GitHub: piconic-ai/barefootjs](https://github.com/piconic-ai/barefootjs) — monorepo (this package lives at `packages/adapter-jinja/python`)
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/python/pyproject.toml
CHANGED
|
@@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
name = "barefootjs"
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = "Python runtime for the @barefootjs/jinja adapter"
|
|
9
|
+
readme = "README.md"
|
|
9
10
|
license = {text = "MIT"}
|
|
10
11
|
requires-python = ">=3.10"
|
|
11
12
|
authors = [{ name = "kobaken", email = "kentafly88@gmail.com" }]
|
|
@@ -16,11 +16,19 @@ import { runAdapterConformanceTests } from '@barefootjs/adapter-tests'
|
|
|
16
16
|
import { JinjaAdapter } from '../adapter'
|
|
17
17
|
import { renderJinjaComponent, PythonNotAvailableError } from '../test-render'
|
|
18
18
|
import { conformancePins } from '../conformance-pins'
|
|
19
|
+
import { renderDivergences } from '../render-divergences'
|
|
19
20
|
|
|
20
21
|
runAdapterConformanceTests({
|
|
21
22
|
name: 'jinja',
|
|
22
23
|
factory: () => new JinjaAdapter(),
|
|
23
24
|
render: renderJinjaComponent,
|
|
25
|
+
// Priority-12 edge-case sweep (炙り出し, #2168): render-level
|
|
26
|
+
// divergences are declared in `../render-divergences` (exported from the
|
|
27
|
+
// package index and published to `ui/compat.lock.json` / the docs
|
|
28
|
+
// compatibility-matrix page by `packages/compat`). Deriving the skip
|
|
29
|
+
// list from that object keeps the public declaration and these test
|
|
30
|
+
// skips from drifting; each entry's rationale lives there.
|
|
31
|
+
skipJsx: Object.keys(renderDivergences),
|
|
24
32
|
// Per-fixture build-time contracts for shapes the Jinja adapter
|
|
25
33
|
// intentionally refuses to lower. Lives in `../conformance-pins` —
|
|
26
34
|
// mirrors xslate's set (the lowering gates are shared code paths in
|
package/src/conformance-pins.ts
CHANGED
|
@@ -98,4 +98,15 @@ export const conformancePins: ConformancePins = {
|
|
|
98
98
|
// "Expression not supported" BF101 rather than emitting a broken
|
|
99
99
|
// template.
|
|
100
100
|
'array-map-function-reference': [{ code: 'BF101', severity: 'error' }],
|
|
101
|
+
// Edge-case sweep (Priority 12): `dangerouslySetInnerHTML` requires a
|
|
102
|
+
// deliberate raw-HTML (unescaped) output affordance in the target
|
|
103
|
+
// template language. No lowering exists yet, so the compiler refuses
|
|
104
|
+
// the shape loudly instead of emitting entity-escaped markup that
|
|
105
|
+
// silently renders tags as text.
|
|
106
|
+
'dangerous-inner-html': [{ code: 'BF101', severity: 'error' }],
|
|
107
|
+
// Edge-case sweep (Priority 12): `.replaceAll` has no lowering yet —
|
|
108
|
+
// only first-occurrence `.replace` is wired to the runtime helpers.
|
|
109
|
+
// Refused with BF101 rather than reusing the first-only lowering,
|
|
110
|
+
// which would silently change semantics.
|
|
111
|
+
'string-replaceall': [{ code: 'BF101', severity: 'error' }],
|
|
101
112
|
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
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.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { RenderDivergences } from '@barefootjs/jsx'
|
|
16
|
+
|
|
17
|
+
export const renderDivergences: RenderDivergences = {
|
|
18
|
+
'arithmetic-text':
|
|
19
|
+
'`(count() + 2) * 3` renders 10 instead of 18 — the parenthesised sub-expression loses its grouping (silent wrong arithmetic)',
|
|
20
|
+
'falsy-text-values':
|
|
21
|
+
'`{false}` renders "false" (Hono drops it); `{null}`/`{undefined}` render empty (Hono renders "null") — neither side matches JSX semantics',
|
|
22
|
+
'html-entity-text':
|
|
23
|
+
'`©` in JSX literal text: Hono decodes to `©`, this adapter re-emits the raw entity — same DOM, different bytes',
|
|
24
|
+
'math-methods':
|
|
25
|
+
'Math.min/max/abs over a signal render empty (only Math.floor is in the template-primitive registry)',
|
|
26
|
+
'boolean-attr-literals':
|
|
27
|
+
'camelCase boolean alias `readOnly`: Hono SSRs `readOnly="true"`, this adapter emits bare presence',
|
|
28
|
+
'camelcase-attributes':
|
|
29
|
+
'`htmlFor` is not lowered to `for` (Hono maps it)',
|
|
30
|
+
'static-attr-escape':
|
|
31
|
+
'static attribute values are not HTML-escaped (`title="Fish & Chips"` emitted raw; Hono escapes)',
|
|
32
|
+
'svg-icon':
|
|
33
|
+
'SVG camelCase presentation attrs (`strokeWidth`, `strokeLinecap`) pass through unmapped; Hono lowers to kebab-case',
|
|
34
|
+
'object-entries-map':
|
|
35
|
+
'`Object.entries(prop).map(([k, v]) => …)` renders an EMPTY list — the object-shaped prop silently produces zero iterations',
|
|
36
|
+
'nested-loop-outer-binding':
|
|
37
|
+
'nested-loop inner items carry `data-key` where the reference emits the depth-suffixed `data-key-1`',
|
|
38
|
+
'jsx-element-prop':
|
|
39
|
+
'a JSX element passed as a NON-children prop renders an empty slot — the element value is silently dropped',
|
|
40
|
+
'string-slice':
|
|
41
|
+
'`.slice()` on a STRING renders empty (array-slice helper misfires on strings)',
|
|
42
|
+
'string-trim-sided':
|
|
43
|
+
'`.trimStart()` / `.trimEnd()` render empty (no lowering)',
|
|
44
|
+
}
|