@barefootjs/jinja 0.31.3 → 0.31.4
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/vite.js +100 -85
- package/package.json +5 -5
package/dist/vite.js
CHANGED
|
@@ -2000,6 +2000,20 @@ function templatePartsToJsExpr(parts, opts) {
|
|
|
2000
2000
|
return result;
|
|
2001
2001
|
}
|
|
2002
2002
|
|
|
2003
|
+
// ../jsx/src/identifier-pattern.ts
|
|
2004
|
+
function withUnicodeFlag(flags) {
|
|
2005
|
+
return flags.includes("u") ? flags : `${flags}u`;
|
|
2006
|
+
}
|
|
2007
|
+
function escapeIdentifierForRegex(name) {
|
|
2008
|
+
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2009
|
+
}
|
|
2010
|
+
var ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
|
|
2011
|
+
var ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
|
|
2012
|
+
function identifierPattern(name, flags = "") {
|
|
2013
|
+
const esc = escapeIdentifierForRegex(name);
|
|
2014
|
+
return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2003
2017
|
// ../jsx/src/scanner/js-scanner.ts
|
|
2004
2018
|
import ts2 from "typescript";
|
|
2005
2019
|
|
|
@@ -2117,6 +2131,83 @@ function derivesScopeFromSlot(comp) {
|
|
|
2117
2131
|
return comp.slotId != null && comp.loopItemRoot !== true;
|
|
2118
2132
|
}
|
|
2119
2133
|
|
|
2134
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
2135
|
+
class BindingScope {
|
|
2136
|
+
frames;
|
|
2137
|
+
static EMPTY = new BindingScope([]);
|
|
2138
|
+
constructor(frames) {
|
|
2139
|
+
this.frames = frames;
|
|
2140
|
+
}
|
|
2141
|
+
enterLoopRow(loop) {
|
|
2142
|
+
const bindings = new Map;
|
|
2143
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
2144
|
+
for (const b of loop.paramBindings)
|
|
2145
|
+
bindings.set(b.name, { source: "destructure" });
|
|
2146
|
+
} else {
|
|
2147
|
+
bindings.set(loop.param, { source: "item" });
|
|
2148
|
+
}
|
|
2149
|
+
if (loop.index != null)
|
|
2150
|
+
bindings.set(loop.index, { source: "index" });
|
|
2151
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
2152
|
+
bindings.set(name, { source: "preamble" });
|
|
2153
|
+
const frame = { kind: "loop-row", bindings };
|
|
2154
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2155
|
+
}
|
|
2156
|
+
enterCallback(params) {
|
|
2157
|
+
const bindings = new Map;
|
|
2158
|
+
for (const name of params)
|
|
2159
|
+
bindings.set(name, { source: "param" });
|
|
2160
|
+
const frame = { kind: "callback", bindings };
|
|
2161
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2162
|
+
}
|
|
2163
|
+
isBound(name) {
|
|
2164
|
+
for (const frame of this.frames) {
|
|
2165
|
+
if (frame.bindings.has(name))
|
|
2166
|
+
return true;
|
|
2167
|
+
}
|
|
2168
|
+
return false;
|
|
2169
|
+
}
|
|
2170
|
+
lookup(name) {
|
|
2171
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
2172
|
+
const frame = this.frames[depth];
|
|
2173
|
+
const binding = frame.bindings.get(name);
|
|
2174
|
+
if (binding)
|
|
2175
|
+
return { depth, frame, binding };
|
|
2176
|
+
}
|
|
2177
|
+
return null;
|
|
2178
|
+
}
|
|
2179
|
+
boundNames() {
|
|
2180
|
+
if (this.boundNamesCache)
|
|
2181
|
+
return this.boundNamesCache;
|
|
2182
|
+
const names = new Set;
|
|
2183
|
+
for (const frame of this.frames) {
|
|
2184
|
+
for (const name of frame.bindings.keys())
|
|
2185
|
+
names.add(name);
|
|
2186
|
+
}
|
|
2187
|
+
this.boundNamesCache = names;
|
|
2188
|
+
return names;
|
|
2189
|
+
}
|
|
2190
|
+
boundNamesCache;
|
|
2191
|
+
valueBoundNamesCache;
|
|
2192
|
+
valueBoundNames() {
|
|
2193
|
+
if (this.valueBoundNamesCache)
|
|
2194
|
+
return this.valueBoundNamesCache;
|
|
2195
|
+
const names = new Set;
|
|
2196
|
+
for (const frame of this.frames) {
|
|
2197
|
+
for (const [name, binding] of frame.bindings) {
|
|
2198
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
2199
|
+
names.add(name);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
this.valueBoundNamesCache = names;
|
|
2204
|
+
return names;
|
|
2205
|
+
}
|
|
2206
|
+
asShadowPredicate() {
|
|
2207
|
+
return (name) => this.isBound(name);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2120
2211
|
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
2121
2212
|
var VOID_ELEMENTS = new Set([
|
|
2122
2213
|
"area",
|
|
@@ -2551,7 +2642,7 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
2551
2642
|
const reachable = new Set;
|
|
2552
2643
|
const queue = [];
|
|
2553
2644
|
for (const name of allNames) {
|
|
2554
|
-
if (
|
|
2645
|
+
if (identifierPattern(name).test(primaryRefs)) {
|
|
2555
2646
|
reachable.add(name);
|
|
2556
2647
|
queue.push(name);
|
|
2557
2648
|
}
|
|
@@ -2560,7 +2651,7 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
2560
2651
|
const current = queue.shift();
|
|
2561
2652
|
const body = bodyMap.get(current) || "";
|
|
2562
2653
|
for (const name of allNames) {
|
|
2563
|
-
if (!reachable.has(name) &&
|
|
2654
|
+
if (!reachable.has(name) && identifierPattern(name).test(body)) {
|
|
2564
2655
|
reachable.add(name);
|
|
2565
2656
|
queue.push(name);
|
|
2566
2657
|
}
|
|
@@ -2891,83 +2982,6 @@ var toLocaleDatePlugin = {
|
|
|
2891
2982
|
}
|
|
2892
2983
|
};
|
|
2893
2984
|
|
|
2894
|
-
// ../jsx/src/scope/binding-scope.ts
|
|
2895
|
-
class BindingScope {
|
|
2896
|
-
frames;
|
|
2897
|
-
static EMPTY = new BindingScope([]);
|
|
2898
|
-
constructor(frames) {
|
|
2899
|
-
this.frames = frames;
|
|
2900
|
-
}
|
|
2901
|
-
enterLoopRow(loop) {
|
|
2902
|
-
const bindings = new Map;
|
|
2903
|
-
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
2904
|
-
for (const b of loop.paramBindings)
|
|
2905
|
-
bindings.set(b.name, { source: "destructure" });
|
|
2906
|
-
} else {
|
|
2907
|
-
bindings.set(loop.param, { source: "item" });
|
|
2908
|
-
}
|
|
2909
|
-
if (loop.index != null)
|
|
2910
|
-
bindings.set(loop.index, { source: "index" });
|
|
2911
|
-
for (const name of loop.preamble?.declaredNames ?? [])
|
|
2912
|
-
bindings.set(name, { source: "preamble" });
|
|
2913
|
-
const frame = { kind: "loop-row", bindings };
|
|
2914
|
-
return new BindingScope([frame, ...this.frames]);
|
|
2915
|
-
}
|
|
2916
|
-
enterCallback(params) {
|
|
2917
|
-
const bindings = new Map;
|
|
2918
|
-
for (const name of params)
|
|
2919
|
-
bindings.set(name, { source: "param" });
|
|
2920
|
-
const frame = { kind: "callback", bindings };
|
|
2921
|
-
return new BindingScope([frame, ...this.frames]);
|
|
2922
|
-
}
|
|
2923
|
-
isBound(name) {
|
|
2924
|
-
for (const frame of this.frames) {
|
|
2925
|
-
if (frame.bindings.has(name))
|
|
2926
|
-
return true;
|
|
2927
|
-
}
|
|
2928
|
-
return false;
|
|
2929
|
-
}
|
|
2930
|
-
lookup(name) {
|
|
2931
|
-
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
2932
|
-
const frame = this.frames[depth];
|
|
2933
|
-
const binding = frame.bindings.get(name);
|
|
2934
|
-
if (binding)
|
|
2935
|
-
return { depth, frame, binding };
|
|
2936
|
-
}
|
|
2937
|
-
return null;
|
|
2938
|
-
}
|
|
2939
|
-
boundNames() {
|
|
2940
|
-
if (this.boundNamesCache)
|
|
2941
|
-
return this.boundNamesCache;
|
|
2942
|
-
const names = new Set;
|
|
2943
|
-
for (const frame of this.frames) {
|
|
2944
|
-
for (const name of frame.bindings.keys())
|
|
2945
|
-
names.add(name);
|
|
2946
|
-
}
|
|
2947
|
-
this.boundNamesCache = names;
|
|
2948
|
-
return names;
|
|
2949
|
-
}
|
|
2950
|
-
boundNamesCache;
|
|
2951
|
-
valueBoundNamesCache;
|
|
2952
|
-
valueBoundNames() {
|
|
2953
|
-
if (this.valueBoundNamesCache)
|
|
2954
|
-
return this.valueBoundNamesCache;
|
|
2955
|
-
const names = new Set;
|
|
2956
|
-
for (const frame of this.frames) {
|
|
2957
|
-
for (const [name, binding] of frame.bindings) {
|
|
2958
|
-
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
2959
|
-
names.add(name);
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
this.valueBoundNamesCache = names;
|
|
2964
|
-
return names;
|
|
2965
|
-
}
|
|
2966
|
-
asShadowPredicate() {
|
|
2967
|
-
return (name) => this.isBound(name);
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
|
|
2971
2985
|
// ../jsx/src/jsx-to-ir.ts
|
|
2972
2986
|
var EMPTY_BOUND = new Set;
|
|
2973
2987
|
var constInitializerCache = new WeakMap;
|
|
@@ -3993,7 +4007,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
3993
4007
|
lines.push(` const ${signal.getter} = () => ${initialValue}`);
|
|
3994
4008
|
}
|
|
3995
4009
|
if (signal.setter) {
|
|
3996
|
-
const setterUsed =
|
|
4010
|
+
const setterUsed = identifierPattern(signal.setter).test(setterRefText);
|
|
3997
4011
|
if (setterUsed) {
|
|
3998
4012
|
lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
|
|
3999
4013
|
}
|
|
@@ -4191,6 +4205,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
4191
4205
|
}
|
|
4192
4206
|
|
|
4193
4207
|
// ../jsx/src/adapters/template-imports.ts
|
|
4208
|
+
import ts25 from "typescript";
|
|
4194
4209
|
var CLIENT_PACKAGE_SOURCES = new Set([
|
|
4195
4210
|
"@barefootjs/client",
|
|
4196
4211
|
"@barefootjs/client/runtime"
|
|
@@ -4933,7 +4948,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
|
|
|
4933
4948
|
};
|
|
4934
4949
|
}
|
|
4935
4950
|
// ../jsx/src/combine-client-js.ts
|
|
4936
|
-
import
|
|
4951
|
+
import ts26 from "typescript";
|
|
4937
4952
|
// ../jsx/src/loop-destructure.ts
|
|
4938
4953
|
function isLowerableLoopDestructure(loop) {
|
|
4939
4954
|
const bindings = loop.paramBindings;
|
|
@@ -5073,9 +5088,9 @@ function escapeRe(s) {
|
|
|
5073
5088
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5074
5089
|
}
|
|
5075
5090
|
// ../jsx/src/debug.ts
|
|
5076
|
-
import ts26 from "typescript";
|
|
5077
|
-
// ../jsx/src/profiler.ts
|
|
5078
5091
|
import ts27 from "typescript";
|
|
5092
|
+
// ../jsx/src/profiler.ts
|
|
5093
|
+
import ts28 from "typescript";
|
|
5079
5094
|
|
|
5080
5095
|
// ../jsx/src/index.ts
|
|
5081
5096
|
registerBuiltinLoweringPlugins();
|
|
@@ -5901,7 +5916,7 @@ function collectImportedLoopChildComponentErrors(ir, componentName) {
|
|
|
5901
5916
|
}
|
|
5902
5917
|
|
|
5903
5918
|
// src/adapter/spread/spread-codegen.ts
|
|
5904
|
-
import
|
|
5919
|
+
import ts29 from "typescript";
|
|
5905
5920
|
function conditionalSpreadToJinja(ctx, expr) {
|
|
5906
5921
|
if (!expr || expr.kind !== "conditional")
|
|
5907
5922
|
return null;
|
|
@@ -5956,7 +5971,7 @@ function recordIndexAccessToJinja(ctx, val) {
|
|
|
5956
5971
|
if (val.kind !== "index-access" || val.object.kind !== "identifier" || val.index.kind !== "identifier") {
|
|
5957
5972
|
return null;
|
|
5958
5973
|
}
|
|
5959
|
-
const tsVal =
|
|
5974
|
+
const tsVal = ts29.factory.createElementAccessExpression(ts29.factory.createIdentifier(val.object.name), ts29.factory.createIdentifier(val.index.name));
|
|
5960
5975
|
const parsed = parseRecordIndexAccess(tsVal, ctx.localConstants ?? [], ctx.propsParams);
|
|
5961
5976
|
if (!parsed)
|
|
5962
5977
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/jinja",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.4",
|
|
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.
|
|
56
|
+
"@barefootjs/shared": "0.31.4"
|
|
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.
|
|
74
|
-
"@barefootjs/vite": "0.31.
|
|
75
|
-
"@barefootjs/client": "0.31.
|
|
73
|
+
"@barefootjs/jsx": "0.31.4",
|
|
74
|
+
"@barefootjs/vite": "0.31.4",
|
|
75
|
+
"@barefootjs/client": "0.31.4",
|
|
76
76
|
"typescript": "^5.0.0",
|
|
77
77
|
"vite": "^6.0.0"
|
|
78
78
|
}
|