@barefootjs/jinja 0.31.2 → 0.31.3
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 +84 -4
- package/package.json +5 -5
package/dist/vite.js
CHANGED
|
@@ -2891,6 +2891,83 @@ var toLocaleDatePlugin = {
|
|
|
2891
2891
|
}
|
|
2892
2892
|
};
|
|
2893
2893
|
|
|
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
|
+
|
|
2894
2971
|
// ../jsx/src/jsx-to-ir.ts
|
|
2895
2972
|
var EMPTY_BOUND = new Set;
|
|
2896
2973
|
var constInitializerCache = new WeakMap;
|
|
@@ -3936,7 +4013,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
3936
4013
|
continue;
|
|
3937
4014
|
const keyword = constant.declarationKind ?? "const";
|
|
3938
4015
|
if (!constant.value) {
|
|
3939
|
-
const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type
|
|
4016
|
+
const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
|
|
3940
4017
|
lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
|
|
3941
4018
|
continue;
|
|
3942
4019
|
}
|
|
@@ -3946,7 +4023,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
3946
4023
|
if (!reachable.has(constant.name))
|
|
3947
4024
|
continue;
|
|
3948
4025
|
const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
3949
|
-
|
|
4026
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
4027
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
|
|
3950
4028
|
}
|
|
3951
4029
|
for (const func of localFunctions) {
|
|
3952
4030
|
if (moduleScopeNames.has(func.name))
|
|
@@ -4053,7 +4131,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
4053
4131
|
const keyword = c.declarationKind ?? "const";
|
|
4054
4132
|
const exportKw = c.isExported ? "export " : "";
|
|
4055
4133
|
if (!c.value) {
|
|
4056
|
-
|
|
4134
|
+
const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
|
|
4135
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
|
|
4057
4136
|
continue;
|
|
4058
4137
|
}
|
|
4059
4138
|
const trimmed = c.value.trim();
|
|
@@ -4062,7 +4141,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
4062
4141
|
if (c.isExported && /^createContext\b/.test(trimmed))
|
|
4063
4142
|
continue;
|
|
4064
4143
|
const value = preserveTypes ? c.typedValue ?? c.value : c.value;
|
|
4065
|
-
|
|
4144
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
|
|
4145
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
|
|
4066
4146
|
}
|
|
4067
4147
|
for (const f of ir.metadata.localFunctions) {
|
|
4068
4148
|
if (!f.isModule || !moduleNames.has(f.name))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/jinja",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.3",
|
|
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.3"
|
|
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.3",
|
|
74
|
+
"@barefootjs/vite": "0.31.3",
|
|
75
|
+
"@barefootjs/client": "0.31.3",
|
|
76
76
|
"typescript": "^5.0.0",
|
|
77
77
|
"vite": "^6.0.0"
|
|
78
78
|
}
|