@barefootjs/client 0.33.3 → 0.33.6
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/csr-adapter.js +69 -64
- package/dist/runtime/component.d.ts +25 -3
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +25 -10
- package/dist/runtime/standalone.js +25 -10
- package/package.json +2 -2
- package/src/runtime/component.ts +64 -13
- package/src/runtime/index.ts +1 -0
package/dist/csr-adapter.js
CHANGED
|
@@ -168757,7 +168757,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
168757
168757
|
var import_typescript25 = __toESM(require_typescript(), 1);
|
|
168758
168758
|
|
|
168759
168759
|
// ../jsx/src/analyzer.ts
|
|
168760
|
-
var
|
|
168760
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
168761
168761
|
|
|
168762
168762
|
// ../jsx/src/expression-parser.ts
|
|
168763
168763
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
@@ -168833,7 +168833,7 @@ var EVAL_MATH_METHODS = new Set([
|
|
|
168833
168833
|
]);
|
|
168834
168834
|
|
|
168835
168835
|
// ../jsx/src/prop-rewrite.ts
|
|
168836
|
-
var
|
|
168836
|
+
var import_typescript7 = __toESM(require_typescript(), 1);
|
|
168837
168837
|
|
|
168838
168838
|
// ../jsx/src/ir-to-client-js/utils.ts
|
|
168839
168839
|
var import_typescript3 = __toESM(require_typescript(), 1);
|
|
@@ -168967,18 +168967,45 @@ var SVG_XML_CAMEL_ATTRS = new Set([
|
|
|
168967
168967
|
"zoomAndPan"
|
|
168968
168968
|
]);
|
|
168969
168969
|
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
168970
|
+
var import_typescript5 = __toESM(require_typescript(), 1);
|
|
168971
|
+
|
|
168972
|
+
// ../jsx/src/props-binding.ts
|
|
168970
168973
|
var import_typescript4 = __toESM(require_typescript(), 1);
|
|
168974
|
+
function isIdentifierName(key) {
|
|
168975
|
+
if (key.length === 0)
|
|
168976
|
+
return false;
|
|
168977
|
+
for (let i = 0;i < key.length; ) {
|
|
168978
|
+
const cp = key.codePointAt(i);
|
|
168979
|
+
const ok = i === 0 ? import_typescript4.default.isIdentifierStart(cp, import_typescript4.default.ScriptTarget.Latest) : import_typescript4.default.isIdentifierPart(cp, import_typescript4.default.ScriptTarget.Latest);
|
|
168980
|
+
if (!ok)
|
|
168981
|
+
return false;
|
|
168982
|
+
i += cp > 65535 ? 2 : 1;
|
|
168983
|
+
}
|
|
168984
|
+
return true;
|
|
168985
|
+
}
|
|
168986
|
+
function propsDestructureBinding(p) {
|
|
168987
|
+
const callerKey = p.sourceName ?? p.name;
|
|
168988
|
+
const localName = p.name;
|
|
168989
|
+
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
168990
|
+
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
168991
|
+
}
|
|
168992
|
+
var EMPTY_SET = new Set;
|
|
168993
|
+
|
|
168994
|
+
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
168971
168995
|
function extractFreeIdentifiersFromText(text) {
|
|
168972
168996
|
if (!text || text.trim().length === 0)
|
|
168973
168997
|
return new Set;
|
|
168974
|
-
const sf =
|
|
168998
|
+
const sf = import_typescript5.default.createSourceFile("__free_ids__.ts", `(${text});`, import_typescript5.default.ScriptTarget.Latest, true, import_typescript5.default.ScriptKind.TS);
|
|
168975
168999
|
const stmt = sf.statements[0];
|
|
168976
|
-
if (!stmt || !
|
|
169000
|
+
if (!stmt || !import_typescript5.default.isExpressionStatement(stmt))
|
|
168977
169001
|
return new Set;
|
|
168978
|
-
const expr =
|
|
169002
|
+
const expr = import_typescript5.default.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
|
|
168979
169003
|
return extractFreeIdentifiersFromNode(expr);
|
|
168980
169004
|
}
|
|
168981
169005
|
|
|
169006
|
+
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
169007
|
+
var import_typescript6 = __toESM(require_typescript(), 1);
|
|
169008
|
+
|
|
168982
169009
|
// ../jsx/src/scope/binding-scope.ts
|
|
168983
169010
|
class BindingScope {
|
|
168984
169011
|
frames;
|
|
@@ -169100,27 +169127,6 @@ var SKELETON_PATH_FORCE_CLOSE_GROUPS = [
|
|
|
169100
169127
|
new Set(["li"])
|
|
169101
169128
|
];
|
|
169102
169129
|
|
|
169103
|
-
// ../jsx/src/props-binding.ts
|
|
169104
|
-
var import_typescript6 = __toESM(require_typescript(), 1);
|
|
169105
|
-
function isIdentifierName(key) {
|
|
169106
|
-
if (key.length === 0)
|
|
169107
|
-
return false;
|
|
169108
|
-
for (let i = 0;i < key.length; ) {
|
|
169109
|
-
const cp = key.codePointAt(i);
|
|
169110
|
-
const ok = i === 0 ? import_typescript6.default.isIdentifierStart(cp, import_typescript6.default.ScriptTarget.Latest) : import_typescript6.default.isIdentifierPart(cp, import_typescript6.default.ScriptTarget.Latest);
|
|
169111
|
-
if (!ok)
|
|
169112
|
-
return false;
|
|
169113
|
-
i += cp > 65535 ? 2 : 1;
|
|
169114
|
-
}
|
|
169115
|
-
return true;
|
|
169116
|
-
}
|
|
169117
|
-
function propsDestructureBinding(p) {
|
|
169118
|
-
const callerKey = p.sourceName ?? p.name;
|
|
169119
|
-
const localName = p.name;
|
|
169120
|
-
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
169121
|
-
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
169122
|
-
}
|
|
169123
|
-
|
|
169124
169130
|
// ../jsx/src/instrumentation.ts
|
|
169125
169131
|
var _counters = freshCounters();
|
|
169126
169132
|
function freshCounters() {
|
|
@@ -169134,20 +169140,21 @@ function freshCounters() {
|
|
|
169134
169140
|
}
|
|
169135
169141
|
|
|
169136
169142
|
// ../jsx/src/analyzer-context.ts
|
|
169137
|
-
var
|
|
169143
|
+
var import_typescript9 = __toESM(require_typescript(), 1);
|
|
169138
169144
|
|
|
169139
169145
|
// ../jsx/src/strip-types.ts
|
|
169140
|
-
var
|
|
169146
|
+
var import_typescript8 = __toESM(require_typescript(), 1);
|
|
169141
169147
|
|
|
169142
169148
|
// ../jsx/src/analyzer-context.ts
|
|
169143
|
-
var _typePrinter =
|
|
169144
|
-
var _blankTypeSourceFile =
|
|
169149
|
+
var _typePrinter = import_typescript9.default.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
169150
|
+
var _blankTypeSourceFile = import_typescript9.default.createSourceFile("__bf_types__.ts", "", import_typescript9.default.ScriptTarget.Latest);
|
|
169145
169151
|
|
|
169146
169152
|
// ../jsx/src/errors.ts
|
|
169147
169153
|
var ErrorCodes = {
|
|
169148
169154
|
MISSING_USE_CLIENT: "BF001",
|
|
169149
169155
|
CLIENT_IMPORTING_SERVER: "BF003",
|
|
169150
169156
|
SIGNAL_OUTSIDE_COMPONENT: "BF011",
|
|
169157
|
+
PRIMITIVE_VIA_NAMESPACE_IMPORT: "BF013",
|
|
169151
169158
|
UNSUPPORTED_JSX_PATTERN: "BF021",
|
|
169152
169159
|
MISSING_KEY_IN_LIST: "BF023",
|
|
169153
169160
|
MISSING_KEY_IN_NESTED_LIST: "BF024",
|
|
@@ -169180,6 +169187,7 @@ var errorMessages = {
|
|
|
169180
169187
|
[ErrorCodes.MISSING_USE_CLIENT]: "'use client' directive required for components with createSignal or event handlers",
|
|
169181
169188
|
[ErrorCodes.CLIENT_IMPORTING_SERVER]: "Client component cannot import server component",
|
|
169182
169189
|
[ErrorCodes.SIGNAL_OUTSIDE_COMPONENT]: "Module-level reactive declaration (createSignal / createMemo) is not allowed. " + "The downstream codegen drops the declaration silently and every reference becomes a ReferenceError at SSR and at hydrate. " + "Move the declaration inside a component function so each mount gets its own state.",
|
|
169190
|
+
[ErrorCodes.PRIMITIVE_VIA_NAMESPACE_IMPORT]: "Reactive primitive called through a namespace import of '@barefootjs/client' (import * as ns) is not recognized; " + "the declaration is dropped and its references throw ReferenceError at hydrate. Import the primitive by name instead.",
|
|
169183
169191
|
[ErrorCodes.UNSUPPORTED_JSX_PATTERN]: "Unsupported JSX pattern",
|
|
169184
169192
|
[ErrorCodes.MISSING_KEY_IN_LIST]: "Missing key attribute in list rendering. Add a key prop for efficient updates",
|
|
169185
169193
|
[ErrorCodes.MISSING_KEY_IN_NESTED_LIST]: "Nested .map() loop requires key attribute for event delegation. Add a key prop to elements in the inner loop",
|
|
@@ -169371,46 +169379,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
169371
169379
|
const ids = new Set;
|
|
169372
169380
|
const boundNames = new Set;
|
|
169373
169381
|
function addBindingNames(name, out) {
|
|
169374
|
-
if (
|
|
169382
|
+
if (import_typescript10.default.isIdentifier(name))
|
|
169375
169383
|
out.push(name.text);
|
|
169376
|
-
else if (
|
|
169384
|
+
else if (import_typescript10.default.isObjectBindingPattern(name))
|
|
169377
169385
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
169378
|
-
else if (
|
|
169386
|
+
else if (import_typescript10.default.isArrayBindingPattern(name))
|
|
169379
169387
|
name.elements.forEach((e) => {
|
|
169380
|
-
if (!
|
|
169388
|
+
if (!import_typescript10.default.isOmittedExpression(e))
|
|
169381
169389
|
addBindingNames(e.name, out);
|
|
169382
169390
|
});
|
|
169383
169391
|
}
|
|
169384
169392
|
function visit(n) {
|
|
169385
|
-
if (
|
|
169393
|
+
if (import_typescript10.default.isTypeNode(n))
|
|
169386
169394
|
return;
|
|
169387
|
-
if (
|
|
169395
|
+
if (import_typescript10.default.isIdentifier(n)) {
|
|
169388
169396
|
const parent = n.parent;
|
|
169389
|
-
if (parent &&
|
|
169397
|
+
if (parent && import_typescript10.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
169390
169398
|
return;
|
|
169391
|
-
if (parent &&
|
|
169399
|
+
if (parent && import_typescript10.default.isPropertyAssignment(parent) && parent.name === n)
|
|
169392
169400
|
return;
|
|
169393
|
-
if (parent &&
|
|
169401
|
+
if (parent && import_typescript10.default.isParameter(parent) && parent.name === n)
|
|
169394
169402
|
return;
|
|
169395
|
-
if (parent &&
|
|
169403
|
+
if (parent && import_typescript10.default.isVariableDeclaration(parent) && parent.name === n)
|
|
169396
169404
|
return;
|
|
169397
169405
|
if (boundNames.has(n.text))
|
|
169398
169406
|
return;
|
|
169399
169407
|
ids.add(n.text);
|
|
169400
169408
|
return;
|
|
169401
169409
|
}
|
|
169402
|
-
if (
|
|
169410
|
+
if (import_typescript10.default.isArrowFunction(n)) {
|
|
169403
169411
|
const params = [];
|
|
169404
169412
|
for (const p of n.parameters)
|
|
169405
169413
|
addBindingNames(p.name, params);
|
|
169406
169414
|
for (const name of params)
|
|
169407
169415
|
boundNames.add(name);
|
|
169408
|
-
|
|
169416
|
+
import_typescript10.default.forEachChild(n, visit);
|
|
169409
169417
|
for (const name of params)
|
|
169410
169418
|
boundNames.delete(name);
|
|
169411
169419
|
return;
|
|
169412
169420
|
}
|
|
169413
|
-
|
|
169421
|
+
import_typescript10.default.forEachChild(n, visit);
|
|
169414
169422
|
}
|
|
169415
169423
|
visit(node);
|
|
169416
169424
|
return ids;
|
|
@@ -169433,7 +169441,7 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
169433
169441
|
]);
|
|
169434
169442
|
|
|
169435
169443
|
// ../jsx/src/jsx-to-ir.ts
|
|
169436
|
-
var
|
|
169444
|
+
var import_typescript14 = __toESM(require_typescript(), 1);
|
|
169437
169445
|
|
|
169438
169446
|
// ../jsx/src/types.ts
|
|
169439
169447
|
var SCOPE_FORBIDDEN = {
|
|
@@ -169469,7 +169477,7 @@ var REACTIVE_BINDING_KINDS = new Set([
|
|
|
169469
169477
|
]);
|
|
169470
169478
|
|
|
169471
169479
|
// ../jsx/src/module-exports.ts
|
|
169472
|
-
var
|
|
169480
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
169473
169481
|
function formatParamWithType(p) {
|
|
169474
169482
|
const rest = p.isRest ? "..." : "";
|
|
169475
169483
|
const optional = p.optional ? "?" : "";
|
|
@@ -169504,21 +169512,21 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
169504
169512
|
const assigned = new Set;
|
|
169505
169513
|
if (candidates.size === 0)
|
|
169506
169514
|
return assigned;
|
|
169507
|
-
const sf =
|
|
169515
|
+
const sf = import_typescript11.default.createSourceFile("bf-assignment-scan.tsx", bodyText, import_typescript11.default.ScriptTarget.Latest, false, import_typescript11.default.ScriptKind.TSX);
|
|
169508
169516
|
const record = (target) => {
|
|
169509
|
-
if (
|
|
169517
|
+
if (import_typescript11.default.isIdentifier(target) && candidates.has(target.text)) {
|
|
169510
169518
|
assigned.add(target.text);
|
|
169511
169519
|
}
|
|
169512
169520
|
};
|
|
169513
169521
|
const visit = (node) => {
|
|
169514
|
-
if (
|
|
169522
|
+
if (import_typescript11.default.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
169515
169523
|
record(node.left);
|
|
169516
|
-
} else if ((
|
|
169524
|
+
} else if ((import_typescript11.default.isPrefixUnaryExpression(node) || import_typescript11.default.isPostfixUnaryExpression(node)) && (node.operator === import_typescript11.default.SyntaxKind.PlusPlusToken || node.operator === import_typescript11.default.SyntaxKind.MinusMinusToken)) {
|
|
169517
169525
|
record(node.operand);
|
|
169518
169526
|
}
|
|
169519
|
-
|
|
169527
|
+
import_typescript11.default.forEachChild(node, visit);
|
|
169520
169528
|
};
|
|
169521
|
-
|
|
169529
|
+
import_typescript11.default.forEachChild(sf, visit);
|
|
169522
169530
|
return assigned;
|
|
169523
169531
|
}
|
|
169524
169532
|
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
@@ -169541,14 +169549,14 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
169541
169549
|
return reachable;
|
|
169542
169550
|
}
|
|
169543
169551
|
function isAssignmentOperator(kind) {
|
|
169544
|
-
return kind >=
|
|
169552
|
+
return kind >= import_typescript11.default.SyntaxKind.FirstAssignment && kind <= import_typescript11.default.SyntaxKind.LastAssignment;
|
|
169545
169553
|
}
|
|
169546
169554
|
|
|
169547
169555
|
// ../jsx/src/reactivity-checker.ts
|
|
169548
|
-
var
|
|
169556
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
169549
169557
|
|
|
169550
169558
|
// ../jsx/src/free-refs.ts
|
|
169551
|
-
var
|
|
169559
|
+
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
169552
169560
|
var _bindingMapCache = new WeakMap;
|
|
169553
169561
|
|
|
169554
169562
|
// ../jsx/src/to-locale-date-lowering.ts
|
|
@@ -169996,16 +170004,16 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
169996
170004
|
]);
|
|
169997
170005
|
|
|
169998
170006
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
169999
|
-
var
|
|
170007
|
+
var import_typescript15 = __toESM(require_typescript(), 1);
|
|
170000
170008
|
|
|
170001
170009
|
// ../jsx/src/ir-to-client-js/imports.ts
|
|
170002
|
-
var
|
|
170010
|
+
var import_typescript17 = __toESM(require_typescript(), 1);
|
|
170003
170011
|
|
|
170004
170012
|
// ../jsx/src/value-references.ts
|
|
170005
|
-
var
|
|
170013
|
+
var import_typescript16 = __toESM(require_typescript(), 1);
|
|
170006
170014
|
|
|
170007
170015
|
// ../jsx/src/relocate.ts
|
|
170008
|
-
var
|
|
170016
|
+
var import_typescript18 = __toESM(require_typescript(), 1);
|
|
170009
170017
|
|
|
170010
170018
|
// ../jsx/src/lowering-registry.ts
|
|
170011
170019
|
var plugins = [];
|
|
@@ -170184,10 +170192,10 @@ function formatDateLocalNames(metadata) {
|
|
|
170184
170192
|
}
|
|
170185
170193
|
|
|
170186
170194
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
170187
|
-
var
|
|
170195
|
+
var import_typescript19 = __toESM(require_typescript(), 1);
|
|
170188
170196
|
|
|
170189
170197
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
170190
|
-
var
|
|
170198
|
+
var import_typescript20 = __toESM(require_typescript(), 1);
|
|
170191
170199
|
var NO_PREAMBLE = {
|
|
170192
170200
|
lazySafe: true,
|
|
170193
170201
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -170237,7 +170245,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
170237
170245
|
]);
|
|
170238
170246
|
|
|
170239
170247
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
170240
|
-
var
|
|
170248
|
+
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
170241
170249
|
|
|
170242
170250
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
170243
170251
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -170251,9 +170259,6 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
170251
170259
|
"pointerleave"
|
|
170252
170260
|
]);
|
|
170253
170261
|
|
|
170254
|
-
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
170255
|
-
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
170256
|
-
|
|
170257
170262
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
170258
170263
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
170259
170264
|
function encodeVLQ(value) {
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ComponentDef } from './types.ts';
|
|
8
8
|
export declare function setParentScopeId(id: string | null): void;
|
|
9
|
+
/**
|
|
10
|
+
* Run `fn` with `_parentScopeId` temporarily set to `id`, restoring the
|
|
11
|
+
* previous value afterward (even if `fn` throws). A static loop's
|
|
12
|
+
* materialize `forEach` (#2833) runs during `init`, not template
|
|
13
|
+
* evaluation, so `_parentScopeId` is null there — this lets it evaluate the
|
|
14
|
+
* row's template as if it were still inside the parent's own template, so
|
|
15
|
+
* `renderChild` stamps `bf-h` with the same `__scopeId` the static init's
|
|
16
|
+
* `qsaChildScopes` selector interpolates.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withParentScope<T>(id: string | null, fn: () => T): T;
|
|
9
19
|
/**
|
|
10
20
|
* Where `mapArray` wants a fresh loop row connected before its `init` runs.
|
|
11
21
|
*
|
|
@@ -81,9 +91,13 @@ export interface CreateComponentSlotInfo {
|
|
|
81
91
|
mount: string;
|
|
82
92
|
}
|
|
83
93
|
/**
|
|
84
|
-
* The `HTMLElement | DocumentFragment` return covers exactly
|
|
94
|
+
* The `HTMLElement | DocumentFragment` return covers exactly two shapes: a
|
|
85
95
|
* BARE call (no `mountAt`, no ambient row-mount point) for a genuine
|
|
86
|
-
* fragment-root component (#2722)
|
|
96
|
+
* fragment-root component (#2722), or for a root-is-a-child-call comment
|
|
97
|
+
* wrapper mounted at the top level (#2728 — same rule: no single element
|
|
98
|
+
* can carry the `<!--bf-scope:-->` boundary comments to an unknown
|
|
99
|
+
* destination, so the caller gets the whole bundle back as a fragment).
|
|
100
|
+
* Every other combination — a normal
|
|
87
101
|
* component, or a fragment-root one with `mountAt`/row-mount already
|
|
88
102
|
* telling this function where to connect — still returns the real,
|
|
89
103
|
* single `HTMLElement`, unchanged (that element stays the caller-visible
|
|
@@ -118,9 +132,17 @@ export declare function createComponent(nameOrDef: string | ComponentDef, props?
|
|
|
118
132
|
* @param name - Component name (e.g., 'Spinner')
|
|
119
133
|
* @param props - Props to pass to the template
|
|
120
134
|
* @param key - Optional key for list reconciliation
|
|
135
|
+
* @param slotSuffix - Slot id in the parent (e.g. 's0') this child was rendered into
|
|
136
|
+
* @param loopItemRoot - True when this child IS a keyed loop's row root
|
|
137
|
+
* (`IRComponent.loopItemRoot`, #2833): it still gets slot identity
|
|
138
|
+
* (`bf-h`/`bf-m`, so a pure-CSR mount's static `qsaChildScopes` init can
|
|
139
|
+
* find it the same way it finds a slotted non-root child) but derives its
|
|
140
|
+
* OWN scope id rather than the parent's — matching Hono, which stamps
|
|
141
|
+
* `__bfParent`/`__bfMount` on a loop item root while still letting an
|
|
142
|
+
* interactive child's own `__scopeId` win over `__bfScope`.
|
|
121
143
|
* @returns HTML string with scope marker
|
|
122
144
|
*/
|
|
123
|
-
export declare function renderChild(name: string, props: Record<string, unknown>, key?: string | number, slotSuffix?: string): string;
|
|
145
|
+
export declare function renderChild(name: string, props: Record<string, unknown>, key?: string | number, slotSuffix?: string, loopItemRoot?: boolean): string;
|
|
124
146
|
/**
|
|
125
147
|
* Escape ">" inside HTML attribute values to prevent broken parsing.
|
|
126
148
|
* UnoCSS classes like has-[>svg]:shrink-0 contain ">" which terminates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAS9C,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAExD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAA;AAsB9F,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,aAAa,GAAG,IAAI,CAI9E;AAQD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAQjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,MAAM,EA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,QAAQ,CAU5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGzD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI9D;AAaD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAejF"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { mapArrayLazy, type LazyRowEntry, type LazyRowPlan } from './map-array-l
|
|
|
15
15
|
export { patchLeaf } from './patch-leaf.ts';
|
|
16
16
|
export { claimSlots, lazySlots, lazyClaimSlots, textOrNode, type SlotSpec, type ClaimPlan, type ClaimedSlots, type ClaimedSlotsRW, type SlotWriter } from './claim-slots.ts';
|
|
17
17
|
export { registerTemplate, getTemplate, hasTemplate, type TemplateFn } from './template.ts';
|
|
18
|
-
export { createComponent, mountRowRoot, renderChild, parseHTML, escapeAttr, escapeText, escapeTextOrNode, bfMarkup, isBfMarkup, escapeTextOrMarkup, markupOrEmpty, type BfMarkup, } from './component.ts';
|
|
18
|
+
export { createComponent, mountRowRoot, renderChild, withParentScope, parseHTML, escapeAttr, escapeText, escapeTextOrNode, bfMarkup, isBfMarkup, escapeTextOrMarkup, markupOrEmpty, type BfMarkup, } from './component.ts';
|
|
19
19
|
export { applyRestAttrs } from './apply-rest-attrs.ts';
|
|
20
20
|
export { spreadAttrs } from './spread-attrs.ts';
|
|
21
21
|
export { styleToCss } from './style.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":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ACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC9G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3F,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAQ3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG1D,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1349,6 +1349,15 @@ var _parentScopeId = null;
|
|
|
1349
1349
|
function setParentScopeId(id) {
|
|
1350
1350
|
_parentScopeId = id;
|
|
1351
1351
|
}
|
|
1352
|
+
function withParentScope(id, fn) {
|
|
1353
|
+
const prev = _parentScopeId;
|
|
1354
|
+
_parentScopeId = id;
|
|
1355
|
+
try {
|
|
1356
|
+
return fn();
|
|
1357
|
+
} finally {
|
|
1358
|
+
_parentScopeId = prev;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1352
1361
|
var _rowMountPoint = null;
|
|
1353
1362
|
function setRowMountPoint(p) {
|
|
1354
1363
|
const prev = _rowMountPoint;
|
|
@@ -1415,12 +1424,14 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt, keyAttr
|
|
|
1415
1424
|
const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
|
|
1416
1425
|
const scopeId = isCommentWrapper && !isFragmentRoot ? null : derivedScopeId ?? `${def?.name ?? name}_${generateId()}`;
|
|
1417
1426
|
const prevParentScopeId = _parentScopeId;
|
|
1427
|
+
let wrapperScopeId = null;
|
|
1418
1428
|
if (scopeId) {
|
|
1419
1429
|
_parentScopeId = scopeId;
|
|
1420
1430
|
} else if (slot?.parent) {
|
|
1421
1431
|
_parentScopeId = slot.parent;
|
|
1422
1432
|
} else if (!_parentScopeId) {
|
|
1423
|
-
|
|
1433
|
+
wrapperScopeId = `${def?.name ?? name}_${generateId()}`;
|
|
1434
|
+
_parentScopeId = wrapperScopeId;
|
|
1424
1435
|
}
|
|
1425
1436
|
let html;
|
|
1426
1437
|
try {
|
|
@@ -1450,12 +1461,13 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt, keyAttr
|
|
|
1450
1461
|
if (key !== undefined) {
|
|
1451
1462
|
element.setAttribute(keyAttrName2, String(key));
|
|
1452
1463
|
}
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1455
|
-
|
|
1464
|
+
const commentScopeId = isFragmentRoot ? scopeId : isCommentWrapper ? wrapperScopeId : null;
|
|
1465
|
+
const fragmentComments = commentScopeId ? {
|
|
1466
|
+
start: document.createComment(`${BF_SCOPE_COMMENT_PREFIX}${commentScopeId}`),
|
|
1467
|
+
end: document.createComment(`${BF_SCOPE_COMMENT_END_PREFIX}${commentScopeId}`)
|
|
1456
1468
|
} : null;
|
|
1457
1469
|
if (fragmentComments) {
|
|
1458
|
-
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId });
|
|
1470
|
+
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId: commentScopeId });
|
|
1459
1471
|
}
|
|
1460
1472
|
const rootIsDeferredPlaceholder = element.hasAttribute(BF_PLACEHOLDER);
|
|
1461
1473
|
let bareFragment = null;
|
|
@@ -1518,16 +1530,18 @@ function spliceAttrsAfterFirstTag(html, attrs) {
|
|
|
1518
1530
|
const insertPos = firstElMatch.index;
|
|
1519
1531
|
return html.slice(0, insertPos) + html.slice(insertPos).replace(TAG_HEAD_PATTERN, `$1${attrs}`);
|
|
1520
1532
|
}
|
|
1521
|
-
function renderChild(name, props, key, slotSuffix) {
|
|
1533
|
+
function renderChild(name, props, key, slotSuffix, loopItemRoot) {
|
|
1522
1534
|
const templateFn = getTemplate(name);
|
|
1523
|
-
const suffix = slotSuffix ? `_${slotSuffix}` : "";
|
|
1524
1535
|
const def = getRegisteredDef(name);
|
|
1525
1536
|
const displayName = def?.name ?? name;
|
|
1526
1537
|
const isFragmentRoot = def?.fragmentRoot === true;
|
|
1527
|
-
const
|
|
1538
|
+
const hasSlot = !!(_parentScopeId && slotSuffix);
|
|
1539
|
+
const derivesFromParent = hasSlot && !loopItemRoot;
|
|
1540
|
+
const suffix = slotSuffix && !loopItemRoot ? `_${slotSuffix}` : "";
|
|
1541
|
+
const scopePrefix = derivesFromParent ? _parentScopeId : `${displayName}_${generateId()}`;
|
|
1528
1542
|
const scopeId = `${scopePrefix}${suffix}`;
|
|
1529
1543
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : "";
|
|
1530
|
-
const slotAttrs =
|
|
1544
|
+
const slotAttrs = hasSlot ? ` ${BF_HOST}="${_parentScopeId}" ${BF_AT}="${slotSuffix}"` : "";
|
|
1531
1545
|
const bfsAttr = `${BF_SCOPE}="${scopeId}"`;
|
|
1532
1546
|
if (!templateFn) {
|
|
1533
1547
|
return isFragmentRoot ? `<!--${BF_SCOPE_COMMENT_PREFIX}${scopeId}--><div></div><!--${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}-->` : `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`;
|
|
@@ -1542,7 +1556,7 @@ function renderChild(name, props, key, slotSuffix) {
|
|
|
1542
1556
|
}
|
|
1543
1557
|
let html = raw.trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
|
|
1544
1558
|
if (isFragmentRoot) {
|
|
1545
|
-
const hostSuffix =
|
|
1559
|
+
const hostSuffix = hasSlot ? `|h=${_parentScopeId}|m=${slotSuffix}` : "";
|
|
1546
1560
|
const keyedHtml = keyAttr ? spliceAttrsAfterFirstTag(html, keyAttr) : html;
|
|
1547
1561
|
return `<!--${BF_SCOPE_COMMENT_PREFIX}${scopeId}${hostSuffix}-->${keyedHtml}<!--${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}-->`;
|
|
1548
1562
|
}
|
|
@@ -3382,6 +3396,7 @@ function setupStreaming() {
|
|
|
3382
3396
|
w[BF_SEAM_DISPOSE_WITHIN] = disposeScope;
|
|
3383
3397
|
}
|
|
3384
3398
|
export {
|
|
3399
|
+
withParentScope,
|
|
3385
3400
|
useContext,
|
|
3386
3401
|
upsertChildItem,
|
|
3387
3402
|
upsertChild,
|
|
@@ -1755,6 +1755,15 @@ var _parentScopeId = null;
|
|
|
1755
1755
|
function setParentScopeId(id) {
|
|
1756
1756
|
_parentScopeId = id;
|
|
1757
1757
|
}
|
|
1758
|
+
function withParentScope(id, fn) {
|
|
1759
|
+
const prev = _parentScopeId;
|
|
1760
|
+
_parentScopeId = id;
|
|
1761
|
+
try {
|
|
1762
|
+
return fn();
|
|
1763
|
+
} finally {
|
|
1764
|
+
_parentScopeId = prev;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1758
1767
|
var _rowMountPoint = null;
|
|
1759
1768
|
function setRowMountPoint(p) {
|
|
1760
1769
|
const prev = _rowMountPoint;
|
|
@@ -1821,12 +1830,14 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt, keyAttr
|
|
|
1821
1830
|
const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
|
|
1822
1831
|
const scopeId = isCommentWrapper && !isFragmentRoot ? null : derivedScopeId ?? `${def?.name ?? name}_${generateId()}`;
|
|
1823
1832
|
const prevParentScopeId = _parentScopeId;
|
|
1833
|
+
let wrapperScopeId = null;
|
|
1824
1834
|
if (scopeId) {
|
|
1825
1835
|
_parentScopeId = scopeId;
|
|
1826
1836
|
} else if (slot?.parent) {
|
|
1827
1837
|
_parentScopeId = slot.parent;
|
|
1828
1838
|
} else if (!_parentScopeId) {
|
|
1829
|
-
|
|
1839
|
+
wrapperScopeId = `${def?.name ?? name}_${generateId()}`;
|
|
1840
|
+
_parentScopeId = wrapperScopeId;
|
|
1830
1841
|
}
|
|
1831
1842
|
let html;
|
|
1832
1843
|
try {
|
|
@@ -1856,12 +1867,13 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt, keyAttr
|
|
|
1856
1867
|
if (key !== undefined) {
|
|
1857
1868
|
element.setAttribute(keyAttrName2, String(key));
|
|
1858
1869
|
}
|
|
1859
|
-
const
|
|
1860
|
-
|
|
1861
|
-
|
|
1870
|
+
const commentScopeId = isFragmentRoot ? scopeId : isCommentWrapper ? wrapperScopeId : null;
|
|
1871
|
+
const fragmentComments = commentScopeId ? {
|
|
1872
|
+
start: document.createComment(`${BF_SCOPE_COMMENT_PREFIX}${commentScopeId}`),
|
|
1873
|
+
end: document.createComment(`${BF_SCOPE_COMMENT_END_PREFIX}${commentScopeId}`)
|
|
1862
1874
|
} : null;
|
|
1863
1875
|
if (fragmentComments) {
|
|
1864
|
-
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId });
|
|
1876
|
+
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId: commentScopeId });
|
|
1865
1877
|
}
|
|
1866
1878
|
const rootIsDeferredPlaceholder = element.hasAttribute(BF_PLACEHOLDER);
|
|
1867
1879
|
let bareFragment = null;
|
|
@@ -1924,16 +1936,18 @@ function spliceAttrsAfterFirstTag(html, attrs) {
|
|
|
1924
1936
|
const insertPos = firstElMatch.index;
|
|
1925
1937
|
return html.slice(0, insertPos) + html.slice(insertPos).replace(TAG_HEAD_PATTERN, `$1${attrs}`);
|
|
1926
1938
|
}
|
|
1927
|
-
function renderChild(name, props, key, slotSuffix) {
|
|
1939
|
+
function renderChild(name, props, key, slotSuffix, loopItemRoot) {
|
|
1928
1940
|
const templateFn = getTemplate(name);
|
|
1929
|
-
const suffix = slotSuffix ? `_${slotSuffix}` : "";
|
|
1930
1941
|
const def = getRegisteredDef(name);
|
|
1931
1942
|
const displayName = def?.name ?? name;
|
|
1932
1943
|
const isFragmentRoot = def?.fragmentRoot === true;
|
|
1933
|
-
const
|
|
1944
|
+
const hasSlot = !!(_parentScopeId && slotSuffix);
|
|
1945
|
+
const derivesFromParent = hasSlot && !loopItemRoot;
|
|
1946
|
+
const suffix = slotSuffix && !loopItemRoot ? `_${slotSuffix}` : "";
|
|
1947
|
+
const scopePrefix = derivesFromParent ? _parentScopeId : `${displayName}_${generateId()}`;
|
|
1934
1948
|
const scopeId = `${scopePrefix}${suffix}`;
|
|
1935
1949
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : "";
|
|
1936
|
-
const slotAttrs =
|
|
1950
|
+
const slotAttrs = hasSlot ? ` ${BF_HOST}="${_parentScopeId}" ${BF_AT}="${slotSuffix}"` : "";
|
|
1937
1951
|
const bfsAttr = `${BF_SCOPE}="${scopeId}"`;
|
|
1938
1952
|
if (!templateFn) {
|
|
1939
1953
|
return isFragmentRoot ? `<!--${BF_SCOPE_COMMENT_PREFIX}${scopeId}--><div></div><!--${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}-->` : `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`;
|
|
@@ -1948,7 +1962,7 @@ function renderChild(name, props, key, slotSuffix) {
|
|
|
1948
1962
|
}
|
|
1949
1963
|
let html = raw.trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
|
|
1950
1964
|
if (isFragmentRoot) {
|
|
1951
|
-
const hostSuffix =
|
|
1965
|
+
const hostSuffix = hasSlot ? `|h=${_parentScopeId}|m=${slotSuffix}` : "";
|
|
1952
1966
|
const keyedHtml = keyAttr ? spliceAttrsAfterFirstTag(html, keyAttr) : html;
|
|
1953
1967
|
return `<!--${BF_SCOPE_COMMENT_PREFIX}${scopeId}${hostSuffix}-->${keyedHtml}<!--${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}-->`;
|
|
1954
1968
|
}
|
|
@@ -3781,6 +3795,7 @@ function setupStreaming() {
|
|
|
3781
3795
|
w[BF_SEAM_DISPOSE_WITHIN] = disposeScope;
|
|
3782
3796
|
}
|
|
3783
3797
|
export {
|
|
3798
|
+
withParentScope,
|
|
3784
3799
|
useContext,
|
|
3785
3800
|
upsertChildItem,
|
|
3786
3801
|
upsertChild,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/client",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.6",
|
|
4
4
|
"description": "BarefootJS client package: reactive primitives (SSR-safe) plus browser runtime under the `/runtime` subpath (compiler target)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"directory": "packages/client"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@barefootjs/shared": "0.33.
|
|
58
|
+
"@barefootjs/shared": "0.33.6"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@barefootjs/jsx": ">=0.2.0"
|
package/src/runtime/component.ts
CHANGED
|
@@ -35,6 +35,25 @@ export function setParentScopeId(id: string | null): void {
|
|
|
35
35
|
_parentScopeId = id
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Run `fn` with `_parentScopeId` temporarily set to `id`, restoring the
|
|
40
|
+
* previous value afterward (even if `fn` throws). A static loop's
|
|
41
|
+
* materialize `forEach` (#2833) runs during `init`, not template
|
|
42
|
+
* evaluation, so `_parentScopeId` is null there — this lets it evaluate the
|
|
43
|
+
* row's template as if it were still inside the parent's own template, so
|
|
44
|
+
* `renderChild` stamps `bf-h` with the same `__scopeId` the static init's
|
|
45
|
+
* `qsaChildScopes` selector interpolates.
|
|
46
|
+
*/
|
|
47
|
+
export function withParentScope<T>(id: string | null, fn: () => T): T {
|
|
48
|
+
const prev = _parentScopeId
|
|
49
|
+
_parentScopeId = id
|
|
50
|
+
try {
|
|
51
|
+
return fn()
|
|
52
|
+
} finally {
|
|
53
|
+
_parentScopeId = prev
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
38
57
|
/**
|
|
39
58
|
* Where `mapArray` wants a fresh loop row connected before its `init` runs.
|
|
40
59
|
*
|
|
@@ -148,9 +167,13 @@ export interface CreateComponentSlotInfo {
|
|
|
148
167
|
}
|
|
149
168
|
|
|
150
169
|
/**
|
|
151
|
-
* The `HTMLElement | DocumentFragment` return covers exactly
|
|
170
|
+
* The `HTMLElement | DocumentFragment` return covers exactly two shapes: a
|
|
152
171
|
* BARE call (no `mountAt`, no ambient row-mount point) for a genuine
|
|
153
|
-
* fragment-root component (#2722)
|
|
172
|
+
* fragment-root component (#2722), or for a root-is-a-child-call comment
|
|
173
|
+
* wrapper mounted at the top level (#2728 — same rule: no single element
|
|
174
|
+
* can carry the `<!--bf-scope:-->` boundary comments to an unknown
|
|
175
|
+
* destination, so the caller gets the whole bundle back as a fragment).
|
|
176
|
+
* Every other combination — a normal
|
|
154
177
|
* component, or a fragment-root one with `mountAt`/row-mount already
|
|
155
178
|
* telling this function where to connect — still returns the real,
|
|
156
179
|
* single `HTMLElement`, unchanged (that element stays the caller-visible
|
|
@@ -351,13 +374,18 @@ function materializeComponent(
|
|
|
351
374
|
// wrapper materialized while an OUTER template eval is in flight keeps
|
|
352
375
|
// inheriting that caller's ambient scope rather than being renamed under a
|
|
353
376
|
// fresh random id. Only the genuinely-rootless mount is affected.
|
|
377
|
+
// #2728: also capture this derived id as `wrapperScopeId`, not just in
|
|
378
|
+
// `_parentScopeId` — step 7a needs it AFTER the template-eval `finally`
|
|
379
|
+
// block below restores `_parentScopeId` to its previous value.
|
|
354
380
|
const prevParentScopeId = _parentScopeId
|
|
381
|
+
let wrapperScopeId: string | null = null
|
|
355
382
|
if (scopeId) {
|
|
356
383
|
_parentScopeId = scopeId
|
|
357
384
|
} else if (slot?.parent) {
|
|
358
385
|
_parentScopeId = slot.parent
|
|
359
386
|
} else if (!_parentScopeId) {
|
|
360
|
-
|
|
387
|
+
wrapperScopeId = `${def?.name ?? name}_${generateId()}`
|
|
388
|
+
_parentScopeId = wrapperScopeId
|
|
361
389
|
}
|
|
362
390
|
let html: string
|
|
363
391
|
try {
|
|
@@ -447,14 +475,19 @@ function materializeComponent(
|
|
|
447
475
|
// are built now and threaded through to wherever `element` ends up
|
|
448
476
|
// connected below, exactly mirroring the SSR/hydrate shape:
|
|
449
477
|
// <!--bf-scope:ID-->` + element + `<!--bf-/scope:ID-->`
|
|
450
|
-
|
|
478
|
+
//
|
|
479
|
+
// A root-is-a-child-call wrapper (#2728) gets the same treatment under
|
|
480
|
+
// its own `wrapperScopeId`, captured separately since `_parentScopeId`
|
|
481
|
+
// is already restored by the `finally` block above by the time this runs.
|
|
482
|
+
const commentScopeId = isFragmentRoot ? scopeId : (isCommentWrapper ? wrapperScopeId : null)
|
|
483
|
+
const fragmentComments = commentScopeId
|
|
451
484
|
? {
|
|
452
|
-
start: document.createComment(`${BF_SCOPE_COMMENT_PREFIX}${
|
|
453
|
-
end: document.createComment(`${BF_SCOPE_COMMENT_END_PREFIX}${
|
|
485
|
+
start: document.createComment(`${BF_SCOPE_COMMENT_PREFIX}${commentScopeId}`),
|
|
486
|
+
end: document.createComment(`${BF_SCOPE_COMMENT_END_PREFIX}${commentScopeId}`),
|
|
454
487
|
}
|
|
455
488
|
: null
|
|
456
489
|
if (fragmentComments) {
|
|
457
|
-
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId:
|
|
490
|
+
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId: commentScopeId! })
|
|
458
491
|
}
|
|
459
492
|
|
|
460
493
|
// 7b. Connect before init.
|
|
@@ -654,16 +687,24 @@ function spliceAttrsAfterFirstTag(html: string, attrs: string): string {
|
|
|
654
687
|
* @param name - Component name (e.g., 'Spinner')
|
|
655
688
|
* @param props - Props to pass to the template
|
|
656
689
|
* @param key - Optional key for list reconciliation
|
|
690
|
+
* @param slotSuffix - Slot id in the parent (e.g. 's0') this child was rendered into
|
|
691
|
+
* @param loopItemRoot - True when this child IS a keyed loop's row root
|
|
692
|
+
* (`IRComponent.loopItemRoot`, #2833): it still gets slot identity
|
|
693
|
+
* (`bf-h`/`bf-m`, so a pure-CSR mount's static `qsaChildScopes` init can
|
|
694
|
+
* find it the same way it finds a slotted non-root child) but derives its
|
|
695
|
+
* OWN scope id rather than the parent's — matching Hono, which stamps
|
|
696
|
+
* `__bfParent`/`__bfMount` on a loop item root while still letting an
|
|
697
|
+
* interactive child's own `__scopeId` win over `__bfScope`.
|
|
657
698
|
* @returns HTML string with scope marker
|
|
658
699
|
*/
|
|
659
700
|
export function renderChild(
|
|
660
701
|
name: string,
|
|
661
702
|
props: Record<string, unknown>,
|
|
662
703
|
key?: string | number,
|
|
663
|
-
slotSuffix?: string
|
|
704
|
+
slotSuffix?: string,
|
|
705
|
+
loopItemRoot?: boolean
|
|
664
706
|
): string {
|
|
665
707
|
const templateFn = getTemplate(name)
|
|
666
|
-
const suffix = slotSuffix ? `_${slotSuffix}` : ''
|
|
667
708
|
// When inside an insert() branch template with a known parent scope,
|
|
668
709
|
// use the parent scope ID so child scope IDs match the SSR convention
|
|
669
710
|
// (e.g., ~ParentName_parentHash_s5 instead of ~Button_randomHash_s5).
|
|
@@ -687,14 +728,24 @@ export function renderChild(
|
|
|
687
728
|
// `materializeComponent`'s equivalent fix) kept stamping `bf-s` onto an
|
|
688
729
|
// element the SSR/hydrate reference never puts one on.
|
|
689
730
|
const isFragmentRoot = def?.fragmentRoot === true
|
|
690
|
-
|
|
731
|
+
// Slot identity (bf-h/bf-m) and scope id (bf-s) are separate questions
|
|
732
|
+
// (#2833): a loop item root has slot identity — `hasSlot` — but, unlike an
|
|
733
|
+
// ordinary slotted child, does not DERIVE its scope id from the parent, so
|
|
734
|
+
// it gets no `_<slotSuffix>` suffix either (Hono's row root is
|
|
735
|
+
// `Name_<random>`, not `Name_<random>_s0`).
|
|
736
|
+
const hasSlot = !!(_parentScopeId && slotSuffix)
|
|
737
|
+
const derivesFromParent = hasSlot && !loopItemRoot
|
|
738
|
+
const suffix = (slotSuffix && !loopItemRoot) ? `_${slotSuffix}` : ''
|
|
739
|
+
const scopePrefix = derivesFromParent
|
|
691
740
|
? _parentScopeId
|
|
692
741
|
: `${displayName}_${generateId()}`
|
|
693
742
|
const scopeId = `${scopePrefix}${suffix}`
|
|
694
743
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : ''
|
|
695
744
|
// Slot-relationship markers — only emitted when both host and slot are
|
|
696
|
-
// known; top-level renders without parent context omit them.
|
|
697
|
-
|
|
745
|
+
// known; top-level renders without parent context omit them. Stamped
|
|
746
|
+
// regardless of `loopItemRoot`: a loop item root keeps slot identity even
|
|
747
|
+
// though it doesn't derive its scope id from it (see `hasSlot` above).
|
|
748
|
+
const slotAttrs = hasSlot
|
|
698
749
|
? ` ${BF_HOST}="${_parentScopeId}" ${BF_AT}="${slotSuffix}"`
|
|
699
750
|
: ''
|
|
700
751
|
const bfsAttr = `${BF_SCOPE}="${scopeId}"`
|
|
@@ -744,7 +795,7 @@ export function renderChild(
|
|
|
744
795
|
// `wrapWithScopeComment`'s CSR mirror, same as `materializeComponent`'s
|
|
745
796
|
// fix for a top-level mount.
|
|
746
797
|
if (isFragmentRoot) {
|
|
747
|
-
const hostSuffix =
|
|
798
|
+
const hostSuffix = hasSlot ? `|h=${_parentScopeId}|m=${slotSuffix}` : ''
|
|
748
799
|
// #2732: `data-key` for a fragment-root loop row lands on the row's own
|
|
749
800
|
// first element — the same "first element, not first node" convention
|
|
750
801
|
// `IRElement.keyAttr` uses on the SSR side (jsx-to-ir.ts) — not on the
|