@barefootjs/hono 0.33.2 → 0.33.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/adapter/hono-adapter.d.ts +0 -2
- package/dist/adapter/hono-adapter.d.ts.map +1 -1
- package/dist/adapter/index.js +7 -13
- package/dist/index.js +7 -13
- package/dist/vite.js +30 -33
- package/package.json +2 -2
- package/src/adapter/hono-adapter.ts +34 -28
|
@@ -57,8 +57,6 @@ export declare class HonoAdapter extends JsxAdapter implements IRNodeEmitter<Hon
|
|
|
57
57
|
* components.
|
|
58
58
|
*/
|
|
59
59
|
private rewriteRelativeImport?;
|
|
60
|
-
/** Stack of loop keys for generating data-key / data-key-1 attributes on loop items */
|
|
61
|
-
private loopKeyStack;
|
|
62
60
|
/**
|
|
63
61
|
* Per-call `AdapterGenerateOptions.scriptAssets`, stashed for the
|
|
64
62
|
* duration of one `generate()` call (same lifecycle as
|
|
@@ -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,EAQX,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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HANGED
|
@@ -30,7 +30,6 @@ class HonoAdapter extends JsxAdapter {
|
|
|
30
30
|
hasClientInteractivity = false;
|
|
31
31
|
currentComponentHasProps = false;
|
|
32
32
|
rewriteRelativeImport;
|
|
33
|
-
loopKeyStack = [];
|
|
34
33
|
scriptAssets;
|
|
35
34
|
preloadAssets;
|
|
36
35
|
constructor(options = {}) {
|
|
@@ -354,15 +353,12 @@ export default ${this.componentName}` : "";
|
|
|
354
353
|
if (this.currentComponentHasProps) {
|
|
355
354
|
hydrationAttrs += ` {...(!__bfChild && __bfPropsJson ? { "${BF_PROPS}": __bfPropsJson } : {})}`;
|
|
356
355
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (loop.key) {
|
|
364
|
-
const keyAttrName = this.loopKeyStack.length === 1 ? "data-key" : `data-key-${this.loopKeyStack.length - 1}`;
|
|
365
|
-
hydrationAttrs += ` ${keyAttrName}={String(${loop.key})}`;
|
|
356
|
+
}
|
|
357
|
+
if (element.keyAttr) {
|
|
358
|
+
if (element.keyAttr.value !== undefined) {
|
|
359
|
+
hydrationAttrs += ` ${element.keyAttr.name}={String(${element.keyAttr.value})}`;
|
|
360
|
+
} else {
|
|
361
|
+
hydrationAttrs += ` {...(__dataKey !== undefined ? { "${element.keyAttr.name}": __dataKey } : {})}`;
|
|
366
362
|
}
|
|
367
363
|
}
|
|
368
364
|
if (element.slotId) {
|
|
@@ -462,14 +458,12 @@ export default ${this.componentName}` : "";
|
|
|
462
458
|
const paramAnnotation = loop.paramType ? `: ${loop.paramType}` : "";
|
|
463
459
|
const indexAnnotation = loop.indexType ? `: ${loop.indexType}` : "";
|
|
464
460
|
const indexParam = loop.index ? `, ${loop.index}${indexAnnotation}` : "";
|
|
465
|
-
this.loopKeyStack.push({ key: loop.key, param: loop.param });
|
|
466
461
|
const children = this.renderChildrenInLoop(loop.children);
|
|
467
|
-
this.loopKeyStack.pop();
|
|
468
462
|
let mapExpr;
|
|
469
463
|
const preamble = loop.preamble?.ssrText;
|
|
470
464
|
let safeChildren = children.startsWith("{") ? `<>${children}</>` : children;
|
|
471
465
|
if (loop.bodyIsMultiRoot) {
|
|
472
|
-
safeChildren = `<>{bfComment('
|
|
466
|
+
safeChildren = `<>{bfComment('loop-i')}${children}</>`;
|
|
473
467
|
} else if (loop.bodyIsItemConditional && loop.key) {
|
|
474
468
|
safeChildren = `<>{bfComment('loop-i:' + String(${loop.key}))}${children}</>`;
|
|
475
469
|
}
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,6 @@ class HonoAdapter extends JsxAdapter {
|
|
|
30
30
|
hasClientInteractivity = false;
|
|
31
31
|
currentComponentHasProps = false;
|
|
32
32
|
rewriteRelativeImport;
|
|
33
|
-
loopKeyStack = [];
|
|
34
33
|
scriptAssets;
|
|
35
34
|
preloadAssets;
|
|
36
35
|
constructor(options = {}) {
|
|
@@ -354,15 +353,12 @@ export default ${this.componentName}` : "";
|
|
|
354
353
|
if (this.currentComponentHasProps) {
|
|
355
354
|
hydrationAttrs += ` {...(!__bfChild && __bfPropsJson ? { "${BF_PROPS}": __bfPropsJson } : {})}`;
|
|
356
355
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (loop.key) {
|
|
364
|
-
const keyAttrName = this.loopKeyStack.length === 1 ? "data-key" : `data-key-${this.loopKeyStack.length - 1}`;
|
|
365
|
-
hydrationAttrs += ` ${keyAttrName}={String(${loop.key})}`;
|
|
356
|
+
}
|
|
357
|
+
if (element.keyAttr) {
|
|
358
|
+
if (element.keyAttr.value !== undefined) {
|
|
359
|
+
hydrationAttrs += ` ${element.keyAttr.name}={String(${element.keyAttr.value})}`;
|
|
360
|
+
} else {
|
|
361
|
+
hydrationAttrs += ` {...(__dataKey !== undefined ? { "${element.keyAttr.name}": __dataKey } : {})}`;
|
|
366
362
|
}
|
|
367
363
|
}
|
|
368
364
|
if (element.slotId) {
|
|
@@ -462,14 +458,12 @@ export default ${this.componentName}` : "";
|
|
|
462
458
|
const paramAnnotation = loop.paramType ? `: ${loop.paramType}` : "";
|
|
463
459
|
const indexAnnotation = loop.indexType ? `: ${loop.indexType}` : "";
|
|
464
460
|
const indexParam = loop.index ? `, ${loop.index}${indexAnnotation}` : "";
|
|
465
|
-
this.loopKeyStack.push({ key: loop.key, param: loop.param });
|
|
466
461
|
const children = this.renderChildrenInLoop(loop.children);
|
|
467
|
-
this.loopKeyStack.pop();
|
|
468
462
|
let mapExpr;
|
|
469
463
|
const preamble = loop.preamble?.ssrText;
|
|
470
464
|
let safeChildren = children.startsWith("{") ? `<>${children}</>` : children;
|
|
471
465
|
if (loop.bodyIsMultiRoot) {
|
|
472
|
-
safeChildren = `<>{bfComment('
|
|
466
|
+
safeChildren = `<>{bfComment('loop-i')}${children}</>`;
|
|
473
467
|
} else if (loop.bodyIsItemConditional && loop.key) {
|
|
474
468
|
safeChildren = `<>{bfComment('loop-i:' + String(${loop.key}))}${children}</>`;
|
|
475
469
|
}
|
package/dist/vite.js
CHANGED
|
@@ -5,7 +5,7 @@ import { barefoot as coreBarefoot } from "@barefootjs/vite";
|
|
|
5
5
|
import { devModuleUrl, loadManifest, resolveDevOrigin, resolveScriptAssets, toPosixRelative } from "@barefootjs/vite";
|
|
6
6
|
|
|
7
7
|
// ../jsx/src/compiler.ts
|
|
8
|
-
import
|
|
8
|
+
import ts25 from "typescript";
|
|
9
9
|
|
|
10
10
|
// ../jsx/src/analyzer.ts
|
|
11
11
|
import ts9 from "typescript";
|
|
@@ -1273,11 +1273,14 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
1273
1273
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
1274
1274
|
import ts14 from "typescript";
|
|
1275
1275
|
|
|
1276
|
+
// ../jsx/src/ir-to-client-js/imports.ts
|
|
1277
|
+
import ts16 from "typescript";
|
|
1278
|
+
|
|
1276
1279
|
// ../jsx/src/value-references.ts
|
|
1277
1280
|
import ts15 from "typescript";
|
|
1278
1281
|
|
|
1279
1282
|
// ../jsx/src/relocate.ts
|
|
1280
|
-
import
|
|
1283
|
+
import ts17 from "typescript";
|
|
1281
1284
|
|
|
1282
1285
|
// ../jsx/src/lowering-registry.ts
|
|
1283
1286
|
var plugins = [];
|
|
@@ -1456,10 +1459,10 @@ function formatDateLocalNames(metadata) {
|
|
|
1456
1459
|
}
|
|
1457
1460
|
|
|
1458
1461
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
1459
|
-
import
|
|
1462
|
+
import ts18 from "typescript";
|
|
1460
1463
|
|
|
1461
1464
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
1462
|
-
import
|
|
1465
|
+
import ts19 from "typescript";
|
|
1463
1466
|
var NO_PREAMBLE = {
|
|
1464
1467
|
lazySafe: true,
|
|
1465
1468
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -1509,7 +1512,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
1509
1512
|
]);
|
|
1510
1513
|
|
|
1511
1514
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
1512
|
-
import
|
|
1515
|
+
import ts20 from "typescript";
|
|
1513
1516
|
|
|
1514
1517
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
1515
1518
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -1524,7 +1527,7 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
1524
1527
|
]);
|
|
1525
1528
|
|
|
1526
1529
|
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
1527
|
-
import
|
|
1530
|
+
import ts21 from "typescript";
|
|
1528
1531
|
|
|
1529
1532
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
1530
1533
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -1615,20 +1618,20 @@ class SourceMapGenerator {
|
|
|
1615
1618
|
}
|
|
1616
1619
|
|
|
1617
1620
|
// ../jsx/src/preprocess-inline-jsx-callbacks.ts
|
|
1618
|
-
import
|
|
1621
|
+
import ts22 from "typescript";
|
|
1619
1622
|
|
|
1620
1623
|
// ../jsx/src/ssr-defaults.ts
|
|
1621
|
-
import
|
|
1624
|
+
import ts23 from "typescript";
|
|
1622
1625
|
var UNRESOLVED = Symbol("unresolved");
|
|
1623
1626
|
var NO_RETURN = Symbol("no-return");
|
|
1624
1627
|
|
|
1625
1628
|
// ../jsx/src/augment-inherited-props.ts
|
|
1626
|
-
import
|
|
1629
|
+
import ts24 from "typescript";
|
|
1627
1630
|
|
|
1628
1631
|
// ../jsx/src/rich-type-refusal.ts
|
|
1629
1632
|
var EMPTY_BINDINGS2 = new Map;
|
|
1630
1633
|
// ../jsx/src/shared-program.ts
|
|
1631
|
-
import
|
|
1634
|
+
import ts26 from "typescript";
|
|
1632
1635
|
// ../jsx/src/adapters/interface.ts
|
|
1633
1636
|
class BaseAdapter {
|
|
1634
1637
|
renderChildren(children) {
|
|
@@ -1910,7 +1913,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
1910
1913
|
}
|
|
1911
1914
|
|
|
1912
1915
|
// ../jsx/src/adapters/template-imports.ts
|
|
1913
|
-
import
|
|
1916
|
+
import ts27 from "typescript";
|
|
1914
1917
|
var CLIENT_PACKAGE_SOURCES = new Set([
|
|
1915
1918
|
"@barefootjs/client",
|
|
1916
1919
|
"@barefootjs/client/runtime"
|
|
@@ -1960,18 +1963,18 @@ function specKey(s) {
|
|
|
1960
1963
|
function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
|
|
1961
1964
|
if (!sourceText.includes("import"))
|
|
1962
1965
|
return sourceText;
|
|
1963
|
-
const sf =
|
|
1966
|
+
const sf = ts27.createSourceFile("bf-template-fragment.tsx", sourceText, ts27.ScriptTarget.Latest, false, ts27.ScriptKind.TSX);
|
|
1964
1967
|
const edits = [];
|
|
1965
1968
|
const visit = (node) => {
|
|
1966
|
-
if (
|
|
1969
|
+
if (ts27.isCallExpression(node) && node.expression.kind === ts27.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts27.isStringLiteralLike(node.arguments[0])) {
|
|
1967
1970
|
collect(node.arguments[0]);
|
|
1968
1971
|
}
|
|
1969
|
-
if (
|
|
1972
|
+
if (ts27.isImportTypeNode(node) && ts27.isLiteralTypeNode(node.argument)) {
|
|
1970
1973
|
const literal = node.argument.literal;
|
|
1971
|
-
if (
|
|
1974
|
+
if (ts27.isStringLiteralLike(literal))
|
|
1972
1975
|
collect(literal);
|
|
1973
1976
|
}
|
|
1974
|
-
|
|
1977
|
+
ts27.forEachChild(node, visit);
|
|
1975
1978
|
};
|
|
1976
1979
|
const collect = (literal) => {
|
|
1977
1980
|
const specifier = literal.text;
|
|
@@ -1986,7 +1989,7 @@ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
|
|
|
1986
1989
|
text: `'${next}'`
|
|
1987
1990
|
});
|
|
1988
1991
|
};
|
|
1989
|
-
|
|
1992
|
+
ts27.forEachChild(sf, visit);
|
|
1990
1993
|
if (edits.length === 0)
|
|
1991
1994
|
return sourceText;
|
|
1992
1995
|
let out = sourceText;
|
|
@@ -2396,11 +2399,11 @@ function emitAttrValue(value, emitter, name) {
|
|
|
2396
2399
|
}
|
|
2397
2400
|
}
|
|
2398
2401
|
// ../jsx/src/combine-client-js.ts
|
|
2399
|
-
import ts27 from "typescript";
|
|
2400
|
-
// ../jsx/src/debug.ts
|
|
2401
2402
|
import ts28 from "typescript";
|
|
2402
|
-
// ../jsx/src/
|
|
2403
|
+
// ../jsx/src/debug.ts
|
|
2403
2404
|
import ts29 from "typescript";
|
|
2405
|
+
// ../jsx/src/profiler.ts
|
|
2406
|
+
import ts30 from "typescript";
|
|
2404
2407
|
|
|
2405
2408
|
// ../jsx/src/index.ts
|
|
2406
2409
|
registerBuiltinLoweringPlugins();
|
|
@@ -2426,7 +2429,6 @@ class HonoAdapter extends JsxAdapter {
|
|
|
2426
2429
|
hasClientInteractivity = false;
|
|
2427
2430
|
currentComponentHasProps = false;
|
|
2428
2431
|
rewriteRelativeImport;
|
|
2429
|
-
loopKeyStack = [];
|
|
2430
2432
|
scriptAssets;
|
|
2431
2433
|
preloadAssets;
|
|
2432
2434
|
constructor(options = {}) {
|
|
@@ -2750,15 +2752,12 @@ export default ${this.componentName}` : "";
|
|
|
2750
2752
|
if (this.currentComponentHasProps) {
|
|
2751
2753
|
hydrationAttrs += ` {...(!__bfChild && __bfPropsJson ? { "${BF_PROPS}": __bfPropsJson } : {})}`;
|
|
2752
2754
|
}
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
if (loop.key) {
|
|
2760
|
-
const keyAttrName2 = this.loopKeyStack.length === 1 ? "data-key" : `data-key-${this.loopKeyStack.length - 1}`;
|
|
2761
|
-
hydrationAttrs += ` ${keyAttrName2}={String(${loop.key})}`;
|
|
2755
|
+
}
|
|
2756
|
+
if (element.keyAttr) {
|
|
2757
|
+
if (element.keyAttr.value !== undefined) {
|
|
2758
|
+
hydrationAttrs += ` ${element.keyAttr.name}={String(${element.keyAttr.value})}`;
|
|
2759
|
+
} else {
|
|
2760
|
+
hydrationAttrs += ` {...(__dataKey !== undefined ? { "${element.keyAttr.name}": __dataKey } : {})}`;
|
|
2762
2761
|
}
|
|
2763
2762
|
}
|
|
2764
2763
|
if (element.slotId) {
|
|
@@ -2858,14 +2857,12 @@ export default ${this.componentName}` : "";
|
|
|
2858
2857
|
const paramAnnotation = loop.paramType ? `: ${loop.paramType}` : "";
|
|
2859
2858
|
const indexAnnotation = loop.indexType ? `: ${loop.indexType}` : "";
|
|
2860
2859
|
const indexParam = loop.index ? `, ${loop.index}${indexAnnotation}` : "";
|
|
2861
|
-
this.loopKeyStack.push({ key: loop.key, param: loop.param });
|
|
2862
2860
|
const children = this.renderChildrenInLoop(loop.children);
|
|
2863
|
-
this.loopKeyStack.pop();
|
|
2864
2861
|
let mapExpr;
|
|
2865
2862
|
const preamble = loop.preamble?.ssrText;
|
|
2866
2863
|
let safeChildren = children.startsWith("{") ? `<>${children}</>` : children;
|
|
2867
2864
|
if (loop.bodyIsMultiRoot) {
|
|
2868
|
-
safeChildren = `<>{bfComment('
|
|
2865
|
+
safeChildren = `<>{bfComment('loop-i')}${children}</>`;
|
|
2869
2866
|
} else if (loop.bodyIsItemConditional && loop.key) {
|
|
2870
2867
|
safeChildren = `<>{bfComment('loop-i:' + String(${loop.key}))}${children}</>`;
|
|
2871
2868
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/hono",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.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.33.
|
|
125
|
+
"@barefootjs/vite": "0.33.4",
|
|
126
126
|
"@types/jsdom": "^27.0.0",
|
|
127
127
|
"hono": "^4.6.0",
|
|
128
128
|
"jsdom": "^27.3.0",
|
|
@@ -138,8 +138,6 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
138
138
|
* components.
|
|
139
139
|
*/
|
|
140
140
|
private rewriteRelativeImport?: (importPath: string) => string
|
|
141
|
-
/** Stack of loop keys for generating data-key / data-key-1 attributes on loop items */
|
|
142
|
-
private loopKeyStack: Array<{ key: string | null; param: string }> = []
|
|
143
141
|
/**
|
|
144
142
|
* Per-call `AdapterGenerateOptions.scriptAssets`, stashed for the
|
|
145
143
|
* duration of one `generate()` call (same lifecycle as
|
|
@@ -759,25 +757,32 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
759
757
|
if (this.currentComponentHasProps) {
|
|
760
758
|
hydrationAttrs += ` {...(!__bfChild && __bfPropsJson ? { "${BF_PROPS}": __bfPropsJson } : {})}`
|
|
761
759
|
}
|
|
762
|
-
// Add data-key for list reconciliation (only on root elements with scope)
|
|
763
|
-
hydrationAttrs += ' {...(__dataKey !== undefined ? { "data-key": __dataKey } : {})}'
|
|
764
|
-
} else if (element.carriesDataKey) {
|
|
765
|
-
// Fragment-root scope (#2732): the other four hydration markers live
|
|
766
|
-
// on the wrapping `<!--bf-scope:...-->` comment (`wrapWithScopeComment`
|
|
767
|
-
// below) since `needsScope` is false for every child of a fragment
|
|
768
|
-
// root — but `data-key` still needs to land on an element, because
|
|
769
|
-
// the client runtime's `mapArray` adopt loop reads it as a DOM
|
|
770
|
-
// attribute (`primaryEl.dataset.key`, map-array.ts), not out of the
|
|
771
|
-
// comment. `carriesDataKey` (jsx-to-ir.ts) marks the one child this
|
|
772
|
-
// belongs on.
|
|
773
|
-
hydrationAttrs += ' {...(__dataKey !== undefined ? { "data-key": __dataKey } : {})}'
|
|
774
760
|
}
|
|
775
|
-
//
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
761
|
+
// #2753: `element.keyAttr` is the ONE IR-resolved decision for this
|
|
762
|
+
// row's key attribute — name AND value already worked out once in
|
|
763
|
+
// `jsx-to-ir.ts`, replacing this adapter's own `loopKeyStack` (a mutated
|
|
764
|
+
// stack of "how deep am I" the client runtime had no matching concept
|
|
765
|
+
// of at all) and the separate `carriesDataKey` boolean.
|
|
766
|
+
if (element.keyAttr) {
|
|
767
|
+
if (element.keyAttr.value !== undefined) {
|
|
768
|
+
// Mechanism 1: this element is directly a `.map()` row root compiled
|
|
769
|
+
// inline here — the key is a concrete expression, spliced verbatim
|
|
770
|
+
// exactly like `loopKeyStack`'s old `${loop.key}` did (it is already
|
|
771
|
+
// valid TS source text, lifted straight from the JSX `key={}` attr).
|
|
772
|
+
hydrationAttrs += ` ${element.keyAttr.name}={String(${element.keyAttr.value})}`
|
|
773
|
+
} else {
|
|
774
|
+
// Mechanism 2: this element is one of THIS component's own render
|
|
775
|
+
// roots, relaying a key its OWN caller supplies at runtime (when
|
|
776
|
+
// this component is itself invoked as a caller's keyed loop row) —
|
|
777
|
+
// `__dataKey` is destructured from `__allProps` at the top of every
|
|
778
|
+
// component for exactly this. Fragment-root scope (#2732): the other
|
|
779
|
+
// four hydration markers live on the wrapping `<!--bf-scope:...-->`
|
|
780
|
+
// comment (`wrapWithScopeComment` below) since `needsScope` is false
|
|
781
|
+
// for every child of a fragment root — but `data-key` still needs to
|
|
782
|
+
// land on an element, because the client runtime's `mapArray` adopt
|
|
783
|
+
// loop reads it as a DOM attribute (`primaryEl.dataset.key`,
|
|
784
|
+
// map-array.ts), not out of the comment.
|
|
785
|
+
hydrationAttrs += ` {...(__dataKey !== undefined ? { "${element.keyAttr.name}": __dataKey } : {})}`
|
|
781
786
|
}
|
|
782
787
|
}
|
|
783
788
|
if (element.slotId) {
|
|
@@ -996,14 +1001,13 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
996
1001
|
const paramAnnotation = loop.paramType ? `: ${loop.paramType}` : ''
|
|
997
1002
|
const indexAnnotation = loop.indexType ? `: ${loop.indexType}` : ''
|
|
998
1003
|
const indexParam = loop.index ? `, ${loop.index}${indexAnnotation}` : ''
|
|
999
|
-
// Push loop key info for data-key attribute generation on loop items
|
|
1000
|
-
this.loopKeyStack.push({ key: loop.key, param: loop.param })
|
|
1001
1004
|
// Render children with isLoopItemRoot so a DIRECT component member gets
|
|
1002
1005
|
// its own randomized scope id (matching `IRComponent.loopItemRoot`,
|
|
1003
1006
|
// #2444) rather than deriving from parent scope + slot like an
|
|
1004
|
-
// ordinarily-slotted child.
|
|
1007
|
+
// ordinarily-slotted child. The row's own `data-key`/`data-key-N`
|
|
1008
|
+
// attribute is no longer tracked here at all — `jsx-to-ir.ts` already
|
|
1009
|
+
// resolved it onto the row-root element's `keyAttr` (#2753).
|
|
1005
1010
|
const children = this.renderChildrenInLoop(loop.children)
|
|
1006
|
-
this.loopKeyStack.pop()
|
|
1007
1011
|
|
|
1008
1012
|
let mapExpr: string
|
|
1009
1013
|
// Raw TSX preamble text (types + JSX intact) for the JSX-runtime output
|
|
@@ -1019,10 +1023,12 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
1019
1023
|
// in a Fragment so the prefix and the existing children share an arrow
|
|
1020
1024
|
// expression body.
|
|
1021
1025
|
if (loop.bodyIsMultiRoot) {
|
|
1022
|
-
// Per-item start marker: BF_LOOP_ITEM ('bf-loop-i').
|
|
1023
|
-
//
|
|
1024
|
-
//
|
|
1025
|
-
|
|
1026
|
+
// Per-item start marker: BF_LOOP_ITEM ('bf-loop-i'). `bfComment(k)`
|
|
1027
|
+
// emits `<!--bf-${k}-->`, so the argument here is `'loop-i'`, not
|
|
1028
|
+
// `'bf-loop-i'` (which would double the prefix to `<!--bf-bf-loop-i-->`
|
|
1029
|
+
// — a genuine SSR-emission bug this fixed, caught by #2763's fixture
|
|
1030
|
+
// being the first `bodyIsMultiRoot` case exercised on this adapter).
|
|
1031
|
+
safeChildren = `<>{bfComment('loop-i')}${children}</>`
|
|
1026
1032
|
} else if (loop.bodyIsItemConditional && loop.key) {
|
|
1027
1033
|
// Whole-item conditional (#1665): a per-item `<!--bf-loop-i:KEY-->`
|
|
1028
1034
|
// anchor that is ALWAYS present (even when the item's conditional
|