@barefootjs/client 0.29.0 → 0.30.2

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":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,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,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACnC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,IAAI,CAAC,EAAE,uBAAuB,EAC9B,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GACvB,WAAW,CAcb;AA2ND;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,M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{
1412
1412
  });
1413
1413
  const def = getRegisteredDef(name);
1414
1414
  const isCommentWrapper = def?.comment === true;
1415
- const scopeId = isCommentWrapper ? null : `${name}_${generateId()}`;
1415
+ const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
1416
+ const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${name}_${generateId()}`;
1416
1417
  const prevParentScopeId = _parentScopeId;
1417
- if (slot?.parent) {
1418
- _parentScopeId = slot.parent;
1419
- } else if (scopeId) {
1418
+ if (scopeId) {
1420
1419
  _parentScopeId = scopeId;
1420
+ } else if (slot?.parent) {
1421
+ _parentScopeId = slot.parent;
1421
1422
  }
1422
1423
  let html;
1423
1424
  try {
@@ -1485,7 +1486,8 @@ function renderChild(name, props, key, slotSuffix) {
1485
1486
  if (!templateFn) {
1486
1487
  return `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`;
1487
1488
  }
1488
- let html = templateFn(props).trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
1489
+ const raw = templateFn(props);
1490
+ let html = raw.trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
1489
1491
  const firstElMatch = html.match(/<(\w+)/);
1490
1492
  if (!firstElMatch)
1491
1493
  return html;
@@ -1818,12 +1818,13 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
1818
1818
  });
1819
1819
  const def = getRegisteredDef(name);
1820
1820
  const isCommentWrapper = def?.comment === true;
1821
- const scopeId = isCommentWrapper ? null : `${name}_${generateId()}`;
1821
+ const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
1822
+ const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${name}_${generateId()}`;
1822
1823
  const prevParentScopeId = _parentScopeId;
1823
- if (slot?.parent) {
1824
- _parentScopeId = slot.parent;
1825
- } else if (scopeId) {
1824
+ if (scopeId) {
1826
1825
  _parentScopeId = scopeId;
1826
+ } else if (slot?.parent) {
1827
+ _parentScopeId = slot.parent;
1827
1828
  }
1828
1829
  let html;
1829
1830
  try {
@@ -1891,7 +1892,8 @@ function renderChild(name, props, key, slotSuffix) {
1891
1892
  if (!templateFn) {
1892
1893
  return `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`;
1893
1894
  }
1894
- let html = templateFn(props).trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
1895
+ const raw = templateFn(props);
1896
+ let html = raw.trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
1895
1897
  const firstElMatch = html.match(/<(\w+)/);
1896
1898
  if (!firstElMatch)
1897
1899
  return html;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/client",
3
- "version": "0.29.0",
3
+ "version": "0.30.2",
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.29.0"
58
+ "@barefootjs/shared": "0.30.2"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@barefootjs/jsx": ">=0.2.0"
@@ -235,9 +235,18 @@ function materializeComponent(
235
235
  // already the inner component's root with its own bf-s. Don't overwrite
236
236
  // it (scopeId stays null), or `$c(__scope, 's0')` from the wrapper's
237
237
  // init resolves to null.
238
+ //
239
+ // `slot` is only supplied by `upsertChild` / `upsertChildItem` mounting a
240
+ // component nested below a loop row root — the SSR reference (Hono)
241
+ // derives that child's `bf-s` from `${hostScope}_${mountSlot}` rather
242
+ // than randomizing it (#2444), so CSR must match or the primary
243
+ // `(bf-h, bf-m)` SSR-scope lookup never finds the CSR-created element.
244
+ // A row root itself is never passed a `slot`, so it keeps its own
245
+ // random id, matching the reference behaviour.
238
246
  const def = getRegisteredDef(name)
239
247
  const isCommentWrapper = def?.comment === true
240
- const scopeId = isCommentWrapper ? null : `${name}_${generateId()}`
248
+ const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null
249
+ const scopeId = isCommentWrapper ? null : (derivedScopeId ?? `${name}_${generateId()}`)
241
250
 
242
251
  // 5. Generate HTML from props.
243
252
  //
@@ -246,13 +255,18 @@ function materializeComponent(
246
255
  // bf-m on child components — matching the SSR convention so a later
247
256
  // `$c(scope, 'sN')` lookup resolves them. Without this, CSR-created
248
257
  // children carry a random prefix and their event handlers never wire
249
- // up (#1627). `slot.parent` takes precedence so hoisted-children
250
- // placeholders (#1320) still resolve to the calling site's scope.
258
+ // up (#1627). `scopeId` takes precedence over `slot.parent` once a
259
+ // slotted component derives its OWN scope id (above), that derived id
260
+ // is what ITS children must nest under, not the grandparent's `slot.parent`
261
+ // (that used to collapse a third composition level back onto the second,
262
+ // #2444's `grandchild-composition` case). A comment wrapper keeps
263
+ // `scopeId === null` and falls through to `slot?.parent`, preserving the
264
+ // hoisted-children placeholder resolution (#1320).
251
265
  const prevParentScopeId = _parentScopeId
252
- if (slot?.parent) {
253
- _parentScopeId = slot.parent
254
- } else if (scopeId) {
266
+ if (scopeId) {
255
267
  _parentScopeId = scopeId
268
+ } else if (slot?.parent) {
269
+ _parentScopeId = slot.parent
256
270
  }
257
271
  let html: string
258
272
  try {
@@ -416,11 +430,31 @@ export function renderChild(
416
430
  return `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`
417
431
  }
418
432
 
433
+ // NOTE: does NOT push `_parentScopeId` to this child's own derived scope
434
+ // while `templateFn` evaluates. That was tried (deriving a GRANDCHILD's
435
+ // scope from this scope rather than the caller's, to fix a third
436
+ // composition level collapsing onto the second — `grandchild-composition`)
437
+ // but it collides with `comment: true` wrapper transparency (#1211
438
+ // synthesized inline-JSX-callback wrappers, e.g. a `renderNode` callback
439
+ // prop): such a wrapper's OWN scope element IS its single child's element,
440
+ // and its init resolves itself via `$c(scope, 's0')`'s short-suffix
441
+ // self-match fallback (`query.ts`'s `$cSingle`). Pushing this scope makes
442
+ // a nested descendant of that SAME child derive `..._s0_s0` whenever the
443
+ // descendant's own first slot id also happens to be `s0` — the PRECISE
444
+ // suffix match then finds that unrelated descendant instead of falling
445
+ // through to the self-match, silently misrouting `initChild` (confirmed
446
+ // via `site/ui`'s xyflow Highlight-Depth demo, where this broke the
447
+ // `--node-glow` style effect). `grandchild-composition` stays a known
448
+ // limitation (CSR conformance skip) until the self-match lookup can be
449
+ // made unambiguous against a nested descendant sharing the same slot
450
+ // suffix.
451
+ const raw = templateFn(props)
452
+
419
453
  // The placeholder substitution is anchored to the exact `bf-s="…"`
420
454
  // shape so user content that contains the sentinel as text survives
421
455
  // unchanged. When `_parentScopeId` is null (top-level render) the
422
456
  // attribute strips rather than emitting `bf-s=""`. (#1320)
423
- let html = templateFn(props).trim().replace(
457
+ let html = raw.trim().replace(
424
458
  PLACEHOLDER_ATTR_PATTERN,
425
459
  _parentScopeId ? ` bf-s="${_parentScopeId}"` : '',
426
460
  )