@barefootjs/go-template 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
|
@@ -2909,6 +2909,83 @@ var toLocaleDatePlugin = {
|
|
|
2909
2909
|
}
|
|
2910
2910
|
};
|
|
2911
2911
|
|
|
2912
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
2913
|
+
class BindingScope {
|
|
2914
|
+
frames;
|
|
2915
|
+
static EMPTY = new BindingScope([]);
|
|
2916
|
+
constructor(frames) {
|
|
2917
|
+
this.frames = frames;
|
|
2918
|
+
}
|
|
2919
|
+
enterLoopRow(loop) {
|
|
2920
|
+
const bindings = new Map;
|
|
2921
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
2922
|
+
for (const b of loop.paramBindings)
|
|
2923
|
+
bindings.set(b.name, { source: "destructure" });
|
|
2924
|
+
} else {
|
|
2925
|
+
bindings.set(loop.param, { source: "item" });
|
|
2926
|
+
}
|
|
2927
|
+
if (loop.index != null)
|
|
2928
|
+
bindings.set(loop.index, { source: "index" });
|
|
2929
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
2930
|
+
bindings.set(name, { source: "preamble" });
|
|
2931
|
+
const frame = { kind: "loop-row", bindings };
|
|
2932
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2933
|
+
}
|
|
2934
|
+
enterCallback(params) {
|
|
2935
|
+
const bindings = new Map;
|
|
2936
|
+
for (const name of params)
|
|
2937
|
+
bindings.set(name, { source: "param" });
|
|
2938
|
+
const frame = { kind: "callback", bindings };
|
|
2939
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2940
|
+
}
|
|
2941
|
+
isBound(name) {
|
|
2942
|
+
for (const frame of this.frames) {
|
|
2943
|
+
if (frame.bindings.has(name))
|
|
2944
|
+
return true;
|
|
2945
|
+
}
|
|
2946
|
+
return false;
|
|
2947
|
+
}
|
|
2948
|
+
lookup(name) {
|
|
2949
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
2950
|
+
const frame = this.frames[depth];
|
|
2951
|
+
const binding = frame.bindings.get(name);
|
|
2952
|
+
if (binding)
|
|
2953
|
+
return { depth, frame, binding };
|
|
2954
|
+
}
|
|
2955
|
+
return null;
|
|
2956
|
+
}
|
|
2957
|
+
boundNames() {
|
|
2958
|
+
if (this.boundNamesCache)
|
|
2959
|
+
return this.boundNamesCache;
|
|
2960
|
+
const names = new Set;
|
|
2961
|
+
for (const frame of this.frames) {
|
|
2962
|
+
for (const name of frame.bindings.keys())
|
|
2963
|
+
names.add(name);
|
|
2964
|
+
}
|
|
2965
|
+
this.boundNamesCache = names;
|
|
2966
|
+
return names;
|
|
2967
|
+
}
|
|
2968
|
+
boundNamesCache;
|
|
2969
|
+
valueBoundNamesCache;
|
|
2970
|
+
valueBoundNames() {
|
|
2971
|
+
if (this.valueBoundNamesCache)
|
|
2972
|
+
return this.valueBoundNamesCache;
|
|
2973
|
+
const names = new Set;
|
|
2974
|
+
for (const frame of this.frames) {
|
|
2975
|
+
for (const [name, binding] of frame.bindings) {
|
|
2976
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
2977
|
+
names.add(name);
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
this.valueBoundNamesCache = names;
|
|
2982
|
+
return names;
|
|
2983
|
+
}
|
|
2984
|
+
asShadowPredicate() {
|
|
2985
|
+
return (name) => this.isBound(name);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2912
2989
|
// ../jsx/src/jsx-to-ir.ts
|
|
2913
2990
|
var EMPTY_BOUND = new Set;
|
|
2914
2991
|
var constInitializerCache = new WeakMap;
|
|
@@ -3899,7 +3976,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
3899
3976
|
continue;
|
|
3900
3977
|
const keyword = constant.declarationKind ?? "const";
|
|
3901
3978
|
if (!constant.value) {
|
|
3902
|
-
const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type
|
|
3979
|
+
const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
|
|
3903
3980
|
lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
|
|
3904
3981
|
continue;
|
|
3905
3982
|
}
|
|
@@ -3909,7 +3986,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
3909
3986
|
if (!reachable.has(constant.name))
|
|
3910
3987
|
continue;
|
|
3911
3988
|
const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
3912
|
-
|
|
3989
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
3990
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
|
|
3913
3991
|
}
|
|
3914
3992
|
for (const func of localFunctions) {
|
|
3915
3993
|
if (moduleScopeNames.has(func.name))
|
|
@@ -4016,7 +4094,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
4016
4094
|
const keyword = c.declarationKind ?? "const";
|
|
4017
4095
|
const exportKw = c.isExported ? "export " : "";
|
|
4018
4096
|
if (!c.value) {
|
|
4019
|
-
|
|
4097
|
+
const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
|
|
4098
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
|
|
4020
4099
|
continue;
|
|
4021
4100
|
}
|
|
4022
4101
|
const trimmed = c.value.trim();
|
|
@@ -4025,7 +4104,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
4025
4104
|
if (c.isExported && /^createContext\b/.test(trimmed))
|
|
4026
4105
|
continue;
|
|
4027
4106
|
const value = preserveTypes ? c.typedValue ?? c.value : c.value;
|
|
4028
|
-
|
|
4107
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
|
|
4108
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
|
|
4029
4109
|
}
|
|
4030
4110
|
for (const f of ir.metadata.localFunctions) {
|
|
4031
4111
|
if (!f.isModule || !moduleNames.has(f.name))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/go-template",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.3",
|
|
4
4
|
"description": "Go html/template adapter for BarefootJS - generates Go template files from IR",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"directory": "packages/adapter-go-template"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@barefootjs/shared": "0.31.
|
|
52
|
+
"@barefootjs/shared": "0.31.3"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
70
|
-
"@barefootjs/client": "0.31.
|
|
71
|
-
"@barefootjs/jsx": "0.31.
|
|
72
|
-
"@barefootjs/vite": "0.31.
|
|
70
|
+
"@barefootjs/client": "0.31.3",
|
|
71
|
+
"@barefootjs/jsx": "0.31.3",
|
|
72
|
+
"@barefootjs/vite": "0.31.3",
|
|
73
73
|
"vite": "^6.0.0"
|
|
74
74
|
}
|
|
75
75
|
}
|