@barefootjs/hono 0.31.2 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"hono-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/hono-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,MAAM,EAIX,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,UAAU,EAOX,MAAM,iBAAiB,CAAA;AAExB;;;;;GAKG;AACH,KAAK,aAAa,GAAG;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAuBD,qBAAa,WAAY,SAAQ,UAAW,YAAW,aAAa,CAAC,aAAa,CAAC;IACjF,IAAI,SAAS;IACb,SAAS,SAAS;IAClB,gBAAgB,SAAiC;IAmBjD,mBAAmB,QAAO,OAAO,CAAQ;IAEzC,SAAS,CAAC,SAAS,EAAE,gBAAgB,CAA0B;IAE/D,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,iBAAiB,CAAiB;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O,CAAC,oBAAoB;IAyB5B,OAAO,CAAC,iBAAiB;IAYzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,0BAA0B;CAInC;AAGD,eAAO,MAAM,WAAW,aAAoB,CAAA"}
@@ -3,6 +3,7 @@ import {
3
3
  JsxAdapter,
4
4
  isBooleanAttr,
5
5
  rewriteImportsForTemplate,
6
+ rewriteDynamicImportsInSource,
6
7
  emitIRNode,
7
8
  emitAttrValue,
8
9
  buildLoopChainExpr,
@@ -53,9 +54,11 @@ class HonoAdapter extends JsxAdapter {
53
54
  this.scriptAssets = options?.scriptAssets;
54
55
  this.preloadAssets = options?.preloadAssets;
55
56
  }
56
- const component = this.generateComponent(ir);
57
- const types = this.generateTypes(ir);
58
- const moduleConstants = this.generateModuleScopeDeclarations(ir);
57
+ const reanchor = this.rewriteRelativeImport;
58
+ const withRewrittenDynamicImports = (text) => reanchor && text ? rewriteDynamicImportsInSource(text, reanchor) : text;
59
+ const component = withRewrittenDynamicImports(this.generateComponent(ir));
60
+ const types = withRewrittenDynamicImports(this.generateTypes(ir));
61
+ const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir));
59
62
  const componentCode = [moduleConstants, types, component].filter(Boolean).join(`
60
63
  `);
61
64
  const imports = this.generateImports(ir, componentCode);
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  JsxAdapter,
4
4
  isBooleanAttr,
5
5
  rewriteImportsForTemplate,
6
+ rewriteDynamicImportsInSource,
6
7
  emitIRNode,
7
8
  emitAttrValue,
8
9
  buildLoopChainExpr,
@@ -53,9 +54,11 @@ class HonoAdapter extends JsxAdapter {
53
54
  this.scriptAssets = options?.scriptAssets;
54
55
  this.preloadAssets = options?.preloadAssets;
55
56
  }
56
- const component = this.generateComponent(ir);
57
- const types = this.generateTypes(ir);
58
- const moduleConstants = this.generateModuleScopeDeclarations(ir);
57
+ const reanchor = this.rewriteRelativeImport;
58
+ const withRewrittenDynamicImports = (text) => reanchor && text ? rewriteDynamicImportsInSource(text, reanchor) : text;
59
+ const component = withRewrittenDynamicImports(this.generateComponent(ir));
60
+ const types = withRewrittenDynamicImports(this.generateTypes(ir));
61
+ const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir));
59
62
  const componentCode = [moduleConstants, types, component].filter(Boolean).join(`
60
63
  `);
61
64
  const imports = this.generateImports(ir, componentCode);
package/dist/vite.js CHANGED
@@ -124,6 +124,20 @@ function templatePartsToJsExpr(parts, opts) {
124
124
  return result;
125
125
  }
126
126
 
127
+ // ../jsx/src/identifier-pattern.ts
128
+ function withUnicodeFlag(flags) {
129
+ return flags.includes("u") ? flags : `${flags}u`;
130
+ }
131
+ function escapeIdentifierForRegex(name) {
132
+ return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
133
+ }
134
+ var ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
135
+ var ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
136
+ function identifierPattern(name, flags = "") {
137
+ const esc = escapeIdentifierForRegex(name);
138
+ return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
139
+ }
140
+
127
141
  // ../jsx/src/scanner/js-scanner.ts
128
142
  import ts2 from "typescript";
129
143
 
@@ -240,6 +254,83 @@ function extractFreeIdentifiersFromText(text) {
240
254
  return extractFreeIdentifiersFromNode(expr);
241
255
  }
242
256
 
257
+ // ../jsx/src/scope/binding-scope.ts
258
+ class BindingScope {
259
+ frames;
260
+ static EMPTY = new BindingScope([]);
261
+ constructor(frames) {
262
+ this.frames = frames;
263
+ }
264
+ enterLoopRow(loop) {
265
+ const bindings = new Map;
266
+ if (loop.paramBindings && loop.paramBindings.length > 0) {
267
+ for (const b of loop.paramBindings)
268
+ bindings.set(b.name, { source: "destructure" });
269
+ } else {
270
+ bindings.set(loop.param, { source: "item" });
271
+ }
272
+ if (loop.index != null)
273
+ bindings.set(loop.index, { source: "index" });
274
+ for (const name of loop.preamble?.declaredNames ?? [])
275
+ bindings.set(name, { source: "preamble" });
276
+ const frame = { kind: "loop-row", bindings };
277
+ return new BindingScope([frame, ...this.frames]);
278
+ }
279
+ enterCallback(params) {
280
+ const bindings = new Map;
281
+ for (const name of params)
282
+ bindings.set(name, { source: "param" });
283
+ const frame = { kind: "callback", bindings };
284
+ return new BindingScope([frame, ...this.frames]);
285
+ }
286
+ isBound(name) {
287
+ for (const frame of this.frames) {
288
+ if (frame.bindings.has(name))
289
+ return true;
290
+ }
291
+ return false;
292
+ }
293
+ lookup(name) {
294
+ for (let depth = 0;depth < this.frames.length; depth++) {
295
+ const frame = this.frames[depth];
296
+ const binding = frame.bindings.get(name);
297
+ if (binding)
298
+ return { depth, frame, binding };
299
+ }
300
+ return null;
301
+ }
302
+ boundNames() {
303
+ if (this.boundNamesCache)
304
+ return this.boundNamesCache;
305
+ const names = new Set;
306
+ for (const frame of this.frames) {
307
+ for (const name of frame.bindings.keys())
308
+ names.add(name);
309
+ }
310
+ this.boundNamesCache = names;
311
+ return names;
312
+ }
313
+ boundNamesCache;
314
+ valueBoundNamesCache;
315
+ valueBoundNames() {
316
+ if (this.valueBoundNamesCache)
317
+ return this.valueBoundNamesCache;
318
+ const names = new Set;
319
+ for (const frame of this.frames) {
320
+ for (const [name, binding] of frame.bindings) {
321
+ if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
322
+ names.add(name);
323
+ }
324
+ }
325
+ }
326
+ this.valueBoundNamesCache = names;
327
+ return names;
328
+ }
329
+ asShadowPredicate() {
330
+ return (name) => this.isBound(name);
331
+ }
332
+ }
333
+
243
334
  // ../jsx/src/ir-to-client-js/html-template.ts
244
335
  var VOID_ELEMENTS = new Set([
245
336
  "area",
@@ -660,7 +751,7 @@ function findReachableNames(primaryRefs, declarations) {
660
751
  const reachable = new Set;
661
752
  const queue = [];
662
753
  for (const name of allNames) {
663
- if (new RegExp(`\\b${name}\\b`).test(primaryRefs)) {
754
+ if (identifierPattern(name).test(primaryRefs)) {
664
755
  reachable.add(name);
665
756
  queue.push(name);
666
757
  }
@@ -669,7 +760,7 @@ function findReachableNames(primaryRefs, declarations) {
669
760
  const current = queue.shift();
670
761
  const body = bodyMap.get(current) || "";
671
762
  for (const name of allNames) {
672
- if (!reachable.has(name) && new RegExp(`\\b${name}\\b`).test(body)) {
763
+ if (!reachable.has(name) && identifierPattern(name).test(body)) {
673
764
  reachable.add(name);
674
765
  queue.push(name);
675
766
  }
@@ -1536,7 +1627,7 @@ class JsxAdapter extends BaseAdapter {
1536
1627
  lines.push(` const ${signal.getter} = () => ${initialValue}`);
1537
1628
  }
1538
1629
  if (signal.setter) {
1539
- const setterUsed = new RegExp(`\\b${signal.setter}\\b`).test(setterRefText);
1630
+ const setterUsed = identifierPattern(signal.setter).test(setterRefText);
1540
1631
  if (setterUsed) {
1541
1632
  lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
1542
1633
  }
@@ -1556,7 +1647,7 @@ class JsxAdapter extends BaseAdapter {
1556
1647
  continue;
1557
1648
  const keyword = constant.declarationKind ?? "const";
1558
1649
  if (!constant.value) {
1559
- const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type.raw}` : "";
1650
+ const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
1560
1651
  lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
1561
1652
  continue;
1562
1653
  }
@@ -1566,7 +1657,8 @@ class JsxAdapter extends BaseAdapter {
1566
1657
  if (!reachable.has(constant.name))
1567
1658
  continue;
1568
1659
  const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
1569
- lines.push(` ${keyword} ${constant.name} = ${constValue}`);
1660
+ const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
1661
+ lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
1570
1662
  }
1571
1663
  for (const func of localFunctions) {
1572
1664
  if (moduleScopeNames.has(func.name))
@@ -1673,7 +1765,8 @@ class JsxAdapter extends BaseAdapter {
1673
1765
  const keyword = c.declarationKind ?? "const";
1674
1766
  const exportKw = c.isExported ? "export " : "";
1675
1767
  if (!c.value) {
1676
- entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}` });
1768
+ const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
1769
+ entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
1677
1770
  continue;
1678
1771
  }
1679
1772
  const trimmed = c.value.trim();
@@ -1682,7 +1775,8 @@ class JsxAdapter extends BaseAdapter {
1682
1775
  if (c.isExported && /^createContext\b/.test(trimmed))
1683
1776
  continue;
1684
1777
  const value = preserveTypes ? c.typedValue ?? c.value : c.value;
1685
- entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name} = ${value}` });
1778
+ const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
1779
+ entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
1686
1780
  }
1687
1781
  for (const f of ir.metadata.localFunctions) {
1688
1782
  if (!f.isModule || !moduleNames.has(f.name))
@@ -1731,6 +1825,7 @@ class JsxAdapter extends BaseAdapter {
1731
1825
  }
1732
1826
 
1733
1827
  // ../jsx/src/adapters/template-imports.ts
1828
+ import ts25 from "typescript";
1734
1829
  var CLIENT_PACKAGE_SOURCES = new Set([
1735
1830
  "@barefootjs/client",
1736
1831
  "@barefootjs/client/runtime"
@@ -1777,6 +1872,44 @@ function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
1777
1872
  function specKey(s) {
1778
1873
  return `${s.isDefault ? "d" : ""}${s.isNamespace ? "n" : ""}:${s.name}:${s.alias ?? ""}`;
1779
1874
  }
1875
+ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
1876
+ if (!sourceText.includes("import"))
1877
+ return sourceText;
1878
+ const sf = ts25.createSourceFile("bf-template-fragment.tsx", sourceText, ts25.ScriptTarget.Latest, false, ts25.ScriptKind.TSX);
1879
+ const edits = [];
1880
+ const visit = (node) => {
1881
+ if (ts25.isCallExpression(node) && node.expression.kind === ts25.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts25.isStringLiteralLike(node.arguments[0])) {
1882
+ collect(node.arguments[0]);
1883
+ }
1884
+ if (ts25.isImportTypeNode(node) && ts25.isLiteralTypeNode(node.argument)) {
1885
+ const literal = node.argument.literal;
1886
+ if (ts25.isStringLiteralLike(literal))
1887
+ collect(literal);
1888
+ }
1889
+ ts25.forEachChild(node, visit);
1890
+ };
1891
+ const collect = (literal) => {
1892
+ const specifier = literal.text;
1893
+ if (!specifier.startsWith("."))
1894
+ return;
1895
+ const next = rewriteRelative(specifier);
1896
+ if (next === specifier)
1897
+ return;
1898
+ edits.push({
1899
+ start: literal.getStart(sf),
1900
+ end: literal.getEnd(),
1901
+ text: `'${next}'`
1902
+ });
1903
+ };
1904
+ ts25.forEachChild(sf, visit);
1905
+ if (edits.length === 0)
1906
+ return sourceText;
1907
+ let out = sourceText;
1908
+ for (const edit of edits.sort((a, b) => b.start - a.start)) {
1909
+ out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
1910
+ }
1911
+ return out;
1912
+ }
1780
1913
 
1781
1914
  // ../jsx/src/adapters/test-adapter.ts
1782
1915
  class TestAdapter extends JsxAdapter {
@@ -2175,11 +2308,11 @@ function emitAttrValue(value, emitter, name) {
2175
2308
  }
2176
2309
  }
2177
2310
  // ../jsx/src/combine-client-js.ts
2178
- import ts25 from "typescript";
2179
- // ../jsx/src/debug.ts
2180
2311
  import ts26 from "typescript";
2181
- // ../jsx/src/profiler.ts
2312
+ // ../jsx/src/debug.ts
2182
2313
  import ts27 from "typescript";
2314
+ // ../jsx/src/profiler.ts
2315
+ import ts28 from "typescript";
2183
2316
 
2184
2317
  // ../jsx/src/index.ts
2185
2318
  registerBuiltinLoweringPlugins();
@@ -2229,9 +2362,11 @@ class HonoAdapter extends JsxAdapter {
2229
2362
  this.scriptAssets = options?.scriptAssets;
2230
2363
  this.preloadAssets = options?.preloadAssets;
2231
2364
  }
2232
- const component = this.generateComponent(ir);
2233
- const types = this.generateTypes(ir);
2234
- const moduleConstants = this.generateModuleScopeDeclarations(ir);
2365
+ const reanchor = this.rewriteRelativeImport;
2366
+ const withRewrittenDynamicImports = (text) => reanchor && text ? rewriteDynamicImportsInSource(text, reanchor) : text;
2367
+ const component = withRewrittenDynamicImports(this.generateComponent(ir));
2368
+ const types = withRewrittenDynamicImports(this.generateTypes(ir));
2369
+ const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir));
2235
2370
  const componentCode = [moduleConstants, types, component].filter(Boolean).join(`
2236
2371
  `);
2237
2372
  const imports = this.generateImports(ir, componentCode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/hono",
3
- "version": "0.31.2",
3
+ "version": "0.31.4",
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.2",
125
+ "@barefootjs/vite": "0.31.4",
126
126
  "@types/jsdom": "^27.0.0",
127
127
  "hono": "^4.6.0",
128
128
  "jsdom": "^27.3.0",
@@ -31,6 +31,7 @@ import {
31
31
  JsxAdapter,
32
32
  isBooleanAttr,
33
33
  rewriteImportsForTemplate,
34
+ rewriteDynamicImportsInSource,
34
35
  emitIRNode,
35
36
  emitAttrValue,
36
37
  buildLoopChainExpr,
@@ -195,9 +196,19 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
195
196
  // `generateModuleScopeDeclarations`; they join the scan text so a
196
197
  // helper referenced only from a hoisted declaration still pulls its
197
198
  // import.
198
- const component = this.generateComponent(ir)
199
- const types = this.generateTypes(ir)
200
- const moduleConstants = this.generateModuleScopeDeclarations(ir)
199
+ // Re-anchor relative specifiers that ride along INSIDE emitted source
200
+ // text dynamic `import('./x')` and `typeof import('./x')` — which
201
+ // never reach `metadata.templateImports` and so are invisible to
202
+ // `rewriteImportsForTemplate` below (#2588). Applied to every section
203
+ // that can carry verbatim source: module-scope declarations, the
204
+ // component body's local handlers, and type declarations.
205
+ const reanchor = this.rewriteRelativeImport
206
+ const withRewrittenDynamicImports = <T extends string | null>(text: T): T =>
207
+ reanchor && text ? (rewriteDynamicImportsInSource(text, reanchor) as T) : text
208
+
209
+ const component = withRewrittenDynamicImports(this.generateComponent(ir))
210
+ const types = withRewrittenDynamicImports(this.generateTypes(ir))
211
+ const moduleConstants = withRewrittenDynamicImports(this.generateModuleScopeDeclarations(ir))
201
212
  const componentCode = [moduleConstants, types, component].filter(Boolean).join('\n')
202
213
  const imports = this.generateImports(ir, componentCode)
203
214