@barefootjs/hono 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 +2 -2
package/dist/vite.js
CHANGED
|
@@ -1000,6 +1000,83 @@ var toLocaleDatePlugin = {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
1004
|
+
class BindingScope {
|
|
1005
|
+
frames;
|
|
1006
|
+
static EMPTY = new BindingScope([]);
|
|
1007
|
+
constructor(frames) {
|
|
1008
|
+
this.frames = frames;
|
|
1009
|
+
}
|
|
1010
|
+
enterLoopRow(loop) {
|
|
1011
|
+
const bindings = new Map;
|
|
1012
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
1013
|
+
for (const b of loop.paramBindings)
|
|
1014
|
+
bindings.set(b.name, { source: "destructure" });
|
|
1015
|
+
} else {
|
|
1016
|
+
bindings.set(loop.param, { source: "item" });
|
|
1017
|
+
}
|
|
1018
|
+
if (loop.index != null)
|
|
1019
|
+
bindings.set(loop.index, { source: "index" });
|
|
1020
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
1021
|
+
bindings.set(name, { source: "preamble" });
|
|
1022
|
+
const frame = { kind: "loop-row", bindings };
|
|
1023
|
+
return new BindingScope([frame, ...this.frames]);
|
|
1024
|
+
}
|
|
1025
|
+
enterCallback(params) {
|
|
1026
|
+
const bindings = new Map;
|
|
1027
|
+
for (const name of params)
|
|
1028
|
+
bindings.set(name, { source: "param" });
|
|
1029
|
+
const frame = { kind: "callback", bindings };
|
|
1030
|
+
return new BindingScope([frame, ...this.frames]);
|
|
1031
|
+
}
|
|
1032
|
+
isBound(name) {
|
|
1033
|
+
for (const frame of this.frames) {
|
|
1034
|
+
if (frame.bindings.has(name))
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
return false;
|
|
1038
|
+
}
|
|
1039
|
+
lookup(name) {
|
|
1040
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
1041
|
+
const frame = this.frames[depth];
|
|
1042
|
+
const binding = frame.bindings.get(name);
|
|
1043
|
+
if (binding)
|
|
1044
|
+
return { depth, frame, binding };
|
|
1045
|
+
}
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
boundNames() {
|
|
1049
|
+
if (this.boundNamesCache)
|
|
1050
|
+
return this.boundNamesCache;
|
|
1051
|
+
const names = new Set;
|
|
1052
|
+
for (const frame of this.frames) {
|
|
1053
|
+
for (const name of frame.bindings.keys())
|
|
1054
|
+
names.add(name);
|
|
1055
|
+
}
|
|
1056
|
+
this.boundNamesCache = names;
|
|
1057
|
+
return names;
|
|
1058
|
+
}
|
|
1059
|
+
boundNamesCache;
|
|
1060
|
+
valueBoundNamesCache;
|
|
1061
|
+
valueBoundNames() {
|
|
1062
|
+
if (this.valueBoundNamesCache)
|
|
1063
|
+
return this.valueBoundNamesCache;
|
|
1064
|
+
const names = new Set;
|
|
1065
|
+
for (const frame of this.frames) {
|
|
1066
|
+
for (const [name, binding] of frame.bindings) {
|
|
1067
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
1068
|
+
names.add(name);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
this.valueBoundNamesCache = names;
|
|
1073
|
+
return names;
|
|
1074
|
+
}
|
|
1075
|
+
asShadowPredicate() {
|
|
1076
|
+
return (name) => this.isBound(name);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1003
1080
|
// ../jsx/src/jsx-to-ir.ts
|
|
1004
1081
|
var EMPTY_BOUND = new Set;
|
|
1005
1082
|
var constInitializerCache = new WeakMap;
|
|
@@ -1556,7 +1633,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1556
1633
|
continue;
|
|
1557
1634
|
const keyword = constant.declarationKind ?? "const";
|
|
1558
1635
|
if (!constant.value) {
|
|
1559
|
-
const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type
|
|
1636
|
+
const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
|
|
1560
1637
|
lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
|
|
1561
1638
|
continue;
|
|
1562
1639
|
}
|
|
@@ -1566,7 +1643,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1566
1643
|
if (!reachable.has(constant.name))
|
|
1567
1644
|
continue;
|
|
1568
1645
|
const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
1569
|
-
|
|
1646
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
1647
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
|
|
1570
1648
|
}
|
|
1571
1649
|
for (const func of localFunctions) {
|
|
1572
1650
|
if (moduleScopeNames.has(func.name))
|
|
@@ -1673,7 +1751,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1673
1751
|
const keyword = c.declarationKind ?? "const";
|
|
1674
1752
|
const exportKw = c.isExported ? "export " : "";
|
|
1675
1753
|
if (!c.value) {
|
|
1676
|
-
|
|
1754
|
+
const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
|
|
1755
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
|
|
1677
1756
|
continue;
|
|
1678
1757
|
}
|
|
1679
1758
|
const trimmed = c.value.trim();
|
|
@@ -1682,7 +1761,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1682
1761
|
if (c.isExported && /^createContext\b/.test(trimmed))
|
|
1683
1762
|
continue;
|
|
1684
1763
|
const value = preserveTypes ? c.typedValue ?? c.value : c.value;
|
|
1685
|
-
|
|
1764
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
|
|
1765
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
|
|
1686
1766
|
}
|
|
1687
1767
|
for (const f of ir.metadata.localFunctions) {
|
|
1688
1768
|
if (!f.isModule || !moduleNames.has(f.name))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/hono",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.3",
|
|
4
4
|
"description": "Hono integration for BarefootJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
125
|
-
"@barefootjs/vite": "0.31.
|
|
125
|
+
"@barefootjs/vite": "0.31.3",
|
|
126
126
|
"@types/jsdom": "^27.0.0",
|
|
127
127
|
"hono": "^4.6.0",
|
|
128
128
|
"jsdom": "^27.3.0",
|