@barefootjs/client 0.33.0 → 0.33.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.
- package/dist/csr-adapter.js +6 -0
- package/dist/runtime/component.d.ts +27 -1
- 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 +141 -32
- package/dist/runtime/insert.d.ts +21 -0
- package/dist/runtime/insert.d.ts.map +1 -1
- package/dist/runtime/map-array.d.ts.map +1 -1
- package/dist/runtime/qsa-item.d.ts.map +1 -1
- package/dist/runtime/registry.d.ts.map +1 -1
- package/dist/runtime/standalone.js +141 -32
- package/dist/runtime/types.d.ts +19 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/runtime/component.ts +304 -41
- package/src/runtime/hydrate.ts +11 -2
- package/src/runtime/index.ts +1 -1
- package/src/runtime/insert.ts +30 -0
- package/src/runtime/map-array.ts +136 -21
- package/src/runtime/qsa-item.ts +3 -1
- package/src/runtime/registry.ts +4 -1
- package/src/runtime/types.ts +19 -1
package/dist/csr-adapter.js
CHANGED
|
@@ -169152,6 +169152,7 @@ var ErrorCodes = {
|
|
|
169152
169152
|
MISSING_KEY_IN_LIST: "BF023",
|
|
169153
169153
|
MISSING_KEY_IN_NESTED_LIST: "BF024",
|
|
169154
169154
|
UNSUPPORTED_DESTRUCTURE_REST: "BF025",
|
|
169155
|
+
RETURN_VALUE_NOT_JSX: "BF027",
|
|
169155
169156
|
PROPS_DESTRUCTURING: "BF043",
|
|
169156
169157
|
SIGNAL_GETTER_NOT_CALLED: "BF044",
|
|
169157
169158
|
JSX_IN_LOCAL_FUNCTION: "BF045",
|
|
@@ -169183,6 +169184,7 @@ var errorMessages = {
|
|
|
169183
169184
|
[ErrorCodes.MISSING_KEY_IN_LIST]: "Missing key attribute in list rendering. Add a key prop for efficient updates",
|
|
169184
169185
|
[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",
|
|
169185
169186
|
[ErrorCodes.UNSUPPORTED_DESTRUCTURE_REST]: "Computed property key in .map() callback destructure is not supported. Rewrite the callback to destructure explicit bindings (e.g., `({ a, b }) => ...`) so the compiler can rewrite references to per-item signal accessors.",
|
|
169187
|
+
[ErrorCodes.RETURN_VALUE_NOT_JSX]: "Component's return value is not recognized as JSX — return the JSX expression directly instead of binding it to a local variable first.",
|
|
169186
169188
|
[ErrorCodes.PROPS_DESTRUCTURING]: "Props destructuring in function parameters breaks reactivity. Use props object directly.",
|
|
169187
169189
|
[ErrorCodes.SIGNAL_GETTER_NOT_CALLED]: "Signal/memo getter passed without calling it. Use getter() to read the value.",
|
|
169188
169190
|
[ErrorCodes.JSX_IN_LOCAL_FUNCTION]: "Local function returns JSX but cannot be inlined. Extract it as a top-level PascalCase component or use a single return statement.",
|
|
@@ -169871,6 +169873,10 @@ var EMPTY_BOUND = new Set;
|
|
|
169871
169873
|
var constInitializerCache = new WeakMap;
|
|
169872
169874
|
var functionInfoExprCache = new WeakMap;
|
|
169873
169875
|
|
|
169876
|
+
// ../jsx/src/ir-to-client-js/prop-handling.ts
|
|
169877
|
+
var _localConstantValuesCache = new WeakMap;
|
|
169878
|
+
var _restSpreadNamesCache = new WeakMap;
|
|
169879
|
+
|
|
169874
169880
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/template-parse.ts
|
|
169875
169881
|
var SVG_ROOT_TAGS = new Set([
|
|
169876
169882
|
"svg",
|
|
@@ -80,7 +80,33 @@ export interface CreateComponentSlotInfo {
|
|
|
80
80
|
/** Slot id in the host (this child's `bf-m` value). */
|
|
81
81
|
mount: string;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
/**
|
|
84
|
+
* The `HTMLElement | DocumentFragment` return covers exactly one shape: a
|
|
85
|
+
* BARE call (no `mountAt`, no ambient row-mount point) for a genuine
|
|
86
|
+
* fragment-root component (#2722). Every other combination — a normal
|
|
87
|
+
* component, or a fragment-root one with `mountAt`/row-mount already
|
|
88
|
+
* telling this function where to connect — still returns the real,
|
|
89
|
+
* single `HTMLElement`, unchanged (that element stays the caller-visible
|
|
90
|
+
* proxy even when the fragment root has further sibling roots of its own
|
|
91
|
+
* — #2735 — those travel alongside it, never in place of it). Only the
|
|
92
|
+
* no-known-destination case has no single element to hand back: the
|
|
93
|
+
* fragment root's own `<!--bf-scope:-->` boundary comments PLUS every
|
|
94
|
+
* top-level node the fragment's template rendered — elements, bare text
|
|
95
|
+
* and `<!--bf:sN-->` slot markers alike (`materializeComponent` step 7b)
|
|
96
|
+
* — must travel to wherever the caller inserts the result, and a
|
|
97
|
+
* `DocumentFragment` is the one `Node` a plain `container.appendChild(...)`
|
|
98
|
+
* / `el.replaceWith(...)` moves as a unit without the caller needing to
|
|
99
|
+
* know why.
|
|
100
|
+
*
|
|
101
|
+
* The first overload states that in the type system rather than only here:
|
|
102
|
+
* a call that passes a non-null `mountAt` is telling this function where to
|
|
103
|
+
* connect, so it can only get the real `HTMLElement` back. Callers on that
|
|
104
|
+
* overload need no cast, which is why `upsertChild` (registry.ts) and
|
|
105
|
+
* `upsertChildItem` (qsa-item.ts) assert nothing — the narrowing is the
|
|
106
|
+
* signature's job, not theirs.
|
|
107
|
+
*/
|
|
108
|
+
export declare function createComponent(nameOrDef: string | ComponentDef, props: Record<string, unknown>, key: string | number | undefined, slot: CreateComponentSlotInfo | undefined, mountAt: Element): HTMLElement;
|
|
109
|
+
export declare function createComponent(nameOrDef: string | ComponentDef, props?: Record<string, unknown>, key?: string | number, slot?: CreateComponentSlotInfo, mountAt?: Element | null): HTMLElement | DocumentFragment;
|
|
84
110
|
/**
|
|
85
111
|
* Render a child component's template to an HTML string.
|
|
86
112
|
* Used by compiler-generated template functions when a stateless component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mapp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MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAejF"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { findScope, find, $, $c, $t, qsa, qsaChildScope, qsaChildScopes, cssEsca
|
|
|
23
23
|
export { date } from './date.ts';
|
|
24
24
|
export { hydrate, rehydrateAll, rehydrateScope, disposeScope, flushHydration, getRegisteredDef } from './hydrate.ts';
|
|
25
25
|
export { registerComponent, getComponentInit, initChild, upsertChild } from './registry.ts';
|
|
26
|
-
export { insert, type BranchConfig, type BranchTemplateResult } from './insert.ts';
|
|
26
|
+
export { insert, findCondContainer, type BranchConfig, type BranchTemplateResult } from './insert.ts';
|
|
27
27
|
export { __bfSlot } from './branch-slot.ts';
|
|
28
28
|
export { __bfText } from './dynamic-text.ts';
|
|
29
29
|
export { hydratedScopes } from './hydration-state.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,KAAK,EACL,eAAe,EACf,SAAS,EACT,OAAO,EACP,gBAAgB,EAOhB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,UA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hydrateCommentScope(comment) {
|
|
|
1330
1330
|
if (hydratedScopes.has(proxyEl))
|
|
1331
1331
|
return;
|
|
1332
1332
|
commentScopeRegistry.set(proxyEl, { commentNode: comment, scopeId });
|
|
1333
|
-
const
|
|
1334
|
-
const props = parsed[name] ?? {};
|
|
1333
|
+
const props = parseProps(propsJson || null, `comment scope ${scopeId}`);
|
|
1335
1334
|
runInit(proxyEl, def, props);
|
|
1336
1335
|
}
|
|
1337
1336
|
function nextElementSibling2(node) {
|
|
@@ -1412,8 +1411,9 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1412
1411
|
});
|
|
1413
1412
|
const def = getRegisteredDef(name);
|
|
1414
1413
|
const isCommentWrapper = def?.comment === true;
|
|
1414
|
+
const isFragmentRoot = def?.fragmentRoot === true;
|
|
1415
1415
|
const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
|
|
1416
|
-
const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${def?.name ?? name}_${generateId()}`;
|
|
1416
|
+
const scopeId = isCommentWrapper && !isFragmentRoot ? null : derivedScopeId ?? `${def?.name ?? name}_${generateId()}`;
|
|
1417
1417
|
const prevParentScopeId = _parentScopeId;
|
|
1418
1418
|
if (scopeId) {
|
|
1419
1419
|
_parentScopeId = scopeId;
|
|
@@ -1426,12 +1426,18 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1426
1426
|
} finally {
|
|
1427
1427
|
_parentScopeId = prevParentScopeId;
|
|
1428
1428
|
}
|
|
1429
|
-
const
|
|
1429
|
+
const parsedFragment = parseHTML(html.trim());
|
|
1430
|
+
const roots = isFragmentRoot ? Array.from(parsedFragment.childNodes) : parsedFragment.firstChild ? [parsedFragment.firstChild] : [];
|
|
1431
|
+
const element = isFragmentRoot ? roots.find((node) => node.nodeType === Node.ELEMENT_NODE) : roots[0];
|
|
1432
|
+
if (isFragmentRoot && roots.length > 0 && !element) {
|
|
1433
|
+
console.warn(`[BarefootJS] Fragment-root component ${name} rendered no element root; ` + "a scope needs at least one element to attach to. Wrap the content in an element.");
|
|
1434
|
+
return createPlaceholder(name, key);
|
|
1435
|
+
}
|
|
1430
1436
|
if (!element) {
|
|
1431
1437
|
console.warn(`[BarefootJS] Template returned empty HTML for component: ${name}`);
|
|
1432
1438
|
return createPlaceholder(name, key);
|
|
1433
1439
|
}
|
|
1434
|
-
if (scopeId) {
|
|
1440
|
+
if (scopeId && !isFragmentRoot) {
|
|
1435
1441
|
element.setAttribute(BF_SCOPE, scopeId);
|
|
1436
1442
|
}
|
|
1437
1443
|
if (slot) {
|
|
@@ -1442,11 +1448,36 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1442
1448
|
if (key !== undefined) {
|
|
1443
1449
|
element.setAttribute(BF_KEY, String(key));
|
|
1444
1450
|
}
|
|
1451
|
+
const fragmentComments = isFragmentRoot && scopeId ? {
|
|
1452
|
+
start: document.createComment(`${BF_SCOPE_COMMENT_PREFIX}${scopeId}`),
|
|
1453
|
+
end: document.createComment(`${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}`)
|
|
1454
|
+
} : null;
|
|
1455
|
+
if (fragmentComments) {
|
|
1456
|
+
commentScopeRegistry.set(element, { commentNode: fragmentComments.start, scopeId });
|
|
1457
|
+
}
|
|
1445
1458
|
const rootIsDeferredPlaceholder = element.hasAttribute(BF_PLACEHOLDER);
|
|
1459
|
+
let bareFragment = null;
|
|
1446
1460
|
if (mountAt && !rootIsDeferredPlaceholder) {
|
|
1447
|
-
|
|
1461
|
+
if (fragmentComments) {
|
|
1462
|
+
mountAt.replaceWith(fragmentComments.start, ...roots, fragmentComments.end);
|
|
1463
|
+
} else {
|
|
1464
|
+
mountAt.replaceWith(element);
|
|
1465
|
+
}
|
|
1448
1466
|
} else if (rowMount && !rootIsDeferredPlaceholder) {
|
|
1449
|
-
|
|
1467
|
+
if (fragmentComments) {
|
|
1468
|
+
rowMount.container.insertBefore(fragmentComments.start, rowMount.anchor);
|
|
1469
|
+
rowMount.container.insertBefore(element, rowMount.anchor);
|
|
1470
|
+
rowMount.container.insertBefore(fragmentComments.end, rowMount.anchor);
|
|
1471
|
+
element.__bfScopeComments = fragmentComments;
|
|
1472
|
+
if (roots.length > 1) {
|
|
1473
|
+
console.warn(`[BarefootJS] Fragment-root component ${name} used as a loop row renders ` + `${roots.length} top-level nodes; only the first element is connected here. ` + "See https://github.com/piconic-ai/barefootjs/issues/2733");
|
|
1474
|
+
}
|
|
1475
|
+
} else {
|
|
1476
|
+
rowMount.container.insertBefore(element, rowMount.anchor);
|
|
1477
|
+
}
|
|
1478
|
+
} else if (fragmentComments && !rootIsDeferredPlaceholder) {
|
|
1479
|
+
bareFragment = document.createDocumentFragment();
|
|
1480
|
+
bareFragment.append(fragmentComments.start, ...roots, fragmentComments.end);
|
|
1450
1481
|
}
|
|
1451
1482
|
const prevScope = setCurrentScope(element);
|
|
1452
1483
|
let placeholderWrapper = null;
|
|
@@ -1474,22 +1505,46 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1474
1505
|
}
|
|
1475
1506
|
setCurrentScope(prevScope);
|
|
1476
1507
|
hydratedScopes.add(element);
|
|
1477
|
-
return element;
|
|
1508
|
+
return bareFragment ?? element;
|
|
1509
|
+
}
|
|
1510
|
+
var FIRST_TAG_PATTERN = /<([a-zA-Z][^\s/>]*)/;
|
|
1511
|
+
var TAG_HEAD_PATTERN = /^(<[a-zA-Z][^\s/>]*)/;
|
|
1512
|
+
function spliceAttrsAfterFirstTag(html, attrs) {
|
|
1513
|
+
const firstElMatch = html.match(FIRST_TAG_PATTERN);
|
|
1514
|
+
if (!firstElMatch)
|
|
1515
|
+
return html;
|
|
1516
|
+
const insertPos = firstElMatch.index;
|
|
1517
|
+
return html.slice(0, insertPos) + html.slice(insertPos).replace(TAG_HEAD_PATTERN, `$1${attrs}`);
|
|
1478
1518
|
}
|
|
1479
1519
|
function renderChild(name, props, key, slotSuffix) {
|
|
1480
1520
|
const templateFn = getTemplate(name);
|
|
1481
1521
|
const suffix = slotSuffix ? `_${slotSuffix}` : "";
|
|
1482
|
-
const
|
|
1522
|
+
const def = getRegisteredDef(name);
|
|
1523
|
+
const displayName = def?.name ?? name;
|
|
1524
|
+
const isFragmentRoot = def?.fragmentRoot === true;
|
|
1483
1525
|
const scopePrefix = _parentScopeId && slotSuffix ? _parentScopeId : `${displayName}_${generateId()}`;
|
|
1526
|
+
const scopeId = `${scopePrefix}${suffix}`;
|
|
1484
1527
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : "";
|
|
1485
1528
|
const slotAttrs = _parentScopeId && slotSuffix ? ` ${BF_HOST}="${_parentScopeId}" ${BF_AT}="${slotSuffix}"` : "";
|
|
1486
|
-
const bfsAttr = `${BF_SCOPE}="${
|
|
1529
|
+
const bfsAttr = `${BF_SCOPE}="${scopeId}"`;
|
|
1487
1530
|
if (!templateFn) {
|
|
1488
|
-
return `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`;
|
|
1531
|
+
return isFragmentRoot ? `<!--${BF_SCOPE_COMMENT_PREFIX}${scopeId}--><div></div><!--${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}-->` : `<div ${bfsAttr}${slotAttrs}${keyAttr}></div>`;
|
|
1532
|
+
}
|
|
1533
|
+
const prevParentScopeId = _parentScopeId;
|
|
1534
|
+
_parentScopeId = `${scopePrefix}${suffix}`;
|
|
1535
|
+
let raw;
|
|
1536
|
+
try {
|
|
1537
|
+
raw = templateFn(props);
|
|
1538
|
+
} finally {
|
|
1539
|
+
_parentScopeId = prevParentScopeId;
|
|
1489
1540
|
}
|
|
1490
|
-
const raw = templateFn(props);
|
|
1491
1541
|
let html = raw.trim().replace(PLACEHOLDER_ATTR_PATTERN, _parentScopeId ? ` bf-s="${_parentScopeId}"` : "");
|
|
1492
|
-
|
|
1542
|
+
if (isFragmentRoot) {
|
|
1543
|
+
const hostSuffix = _parentScopeId && slotSuffix ? `|h=${_parentScopeId}|m=${slotSuffix}` : "";
|
|
1544
|
+
const keyedHtml = keyAttr ? spliceAttrsAfterFirstTag(html, keyAttr) : html;
|
|
1545
|
+
return `<!--${BF_SCOPE_COMMENT_PREFIX}${scopeId}${hostSuffix}-->${keyedHtml}<!--${BF_SCOPE_COMMENT_END_PREFIX}${scopeId}-->`;
|
|
1546
|
+
}
|
|
1547
|
+
const firstElMatch = html.match(FIRST_TAG_PATTERN);
|
|
1493
1548
|
if (!firstElMatch)
|
|
1494
1549
|
return html;
|
|
1495
1550
|
const insertPos = firstElMatch.index;
|
|
@@ -1498,9 +1553,9 @@ function renderChild(name, props, key, slotSuffix) {
|
|
|
1498
1553
|
if (ROOT_HAS_BFS_PATTERN.test(afterInsert)) {
|
|
1499
1554
|
if (!extraAttrs)
|
|
1500
1555
|
return html;
|
|
1501
|
-
return html.slice(0, insertPos) + afterInsert.replace(
|
|
1556
|
+
return html.slice(0, insertPos) + afterInsert.replace(TAG_HEAD_PATTERN, `$1${extraAttrs}`);
|
|
1502
1557
|
}
|
|
1503
|
-
return html.slice(0, insertPos) + afterInsert.replace(
|
|
1558
|
+
return html.slice(0, insertPos) + afterInsert.replace(TAG_HEAD_PATTERN, `$1 ${bfsAttr}${extraAttrs}`);
|
|
1504
1559
|
}
|
|
1505
1560
|
var PLACEHOLDER_ATTR_PATTERN = new RegExp(`\\s+bf-s="${BF_PARENT_SCOPE_PLACEHOLDER}"`, "g");
|
|
1506
1561
|
var ROOT_HAS_BFS_PATTERN = /^<\w+[^>]*\sbf-s="/;
|
|
@@ -1831,6 +1886,11 @@ function upsertChildItem(primaryEl, name, slotId, props, key, anchorScope) {
|
|
|
1831
1886
|
}
|
|
1832
1887
|
// src/runtime/map-array.ts
|
|
1833
1888
|
import { createSignal, createEffect, createRoot as createRoot2 } from "@barefootjs/client/reactive";
|
|
1889
|
+
function scopeIdOf(start) {
|
|
1890
|
+
const rest = (start.nodeValue ?? "").slice(BF_SCOPE_COMMENT_PREFIX.length);
|
|
1891
|
+
const pipe = rest.indexOf("|");
|
|
1892
|
+
return pipe >= 0 ? rest.slice(0, pipe) : rest;
|
|
1893
|
+
}
|
|
1834
1894
|
function findLoopMarkers2(container, markerId) {
|
|
1835
1895
|
let start = null;
|
|
1836
1896
|
let end = null;
|
|
@@ -1868,31 +1928,55 @@ function findItemRanges(start, end) {
|
|
|
1868
1928
|
const ranges = [];
|
|
1869
1929
|
let current = null;
|
|
1870
1930
|
let sawItemMarker = false;
|
|
1931
|
+
let pendingScopeStart = null;
|
|
1932
|
+
let openScopeComments = null;
|
|
1871
1933
|
let node = start.nextSibling;
|
|
1872
1934
|
while (node && node !== end) {
|
|
1873
|
-
if (node.nodeType === Node.COMMENT_NODE
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1935
|
+
if (node.nodeType === Node.COMMENT_NODE) {
|
|
1936
|
+
const value = node.nodeValue ?? "";
|
|
1937
|
+
if (value === BF_LOOP_ITEM) {
|
|
1938
|
+
sawItemMarker = true;
|
|
1939
|
+
current = { startMarker: node, primaryEl: null, extras: [], scopeComments: null };
|
|
1940
|
+
ranges.push(current);
|
|
1941
|
+
} else if (value.startsWith(BF_SCOPE_COMMENT_PREFIX)) {
|
|
1942
|
+
pendingScopeStart = node;
|
|
1943
|
+
} else if (openScopeComments && value === BF_SCOPE_COMMENT_END_PREFIX + scopeIdOf(openScopeComments.start)) {
|
|
1944
|
+
openScopeComments.end = node;
|
|
1945
|
+
openScopeComments = null;
|
|
1946
|
+
}
|
|
1877
1947
|
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1878
1948
|
const el = node;
|
|
1949
|
+
let scopeComments = null;
|
|
1950
|
+
if (pendingScopeStart) {
|
|
1951
|
+
scopeComments = { start: pendingScopeStart, end: null };
|
|
1952
|
+
openScopeComments = scopeComments;
|
|
1953
|
+
pendingScopeStart = null;
|
|
1954
|
+
}
|
|
1879
1955
|
if (sawItemMarker) {
|
|
1880
|
-
if (!current.primaryEl)
|
|
1956
|
+
if (!current.primaryEl) {
|
|
1881
1957
|
current.primaryEl = el;
|
|
1882
|
-
|
|
1958
|
+
current.scopeComments = scopeComments;
|
|
1959
|
+
} else
|
|
1883
1960
|
current.extras.push(el);
|
|
1884
1961
|
} else {
|
|
1885
|
-
ranges.push({ startMarker: null, primaryEl: el, extras: [] });
|
|
1962
|
+
ranges.push({ startMarker: null, primaryEl: el, extras: [], scopeComments });
|
|
1886
1963
|
}
|
|
1887
1964
|
}
|
|
1888
1965
|
node = node.nextSibling;
|
|
1889
1966
|
}
|
|
1890
|
-
return ranges.filter((r) => r.primaryEl !== null)
|
|
1967
|
+
return ranges.filter((r) => r.primaryEl !== null).map((r) => ({
|
|
1968
|
+
...r,
|
|
1969
|
+
scopeComments: r.scopeComments?.end ? r.scopeComments : null
|
|
1970
|
+
}));
|
|
1891
1971
|
}
|
|
1892
1972
|
function insertScope(scope, target, anchor) {
|
|
1893
1973
|
if (scope.startMarker)
|
|
1894
1974
|
target.insertBefore(scope.startMarker, anchor);
|
|
1975
|
+
if (scope.scopeComments)
|
|
1976
|
+
target.insertBefore(scope.scopeComments.start, anchor);
|
|
1895
1977
|
target.insertBefore(scope.primaryEl, anchor);
|
|
1978
|
+
if (scope.scopeComments)
|
|
1979
|
+
target.insertBefore(scope.scopeComments.end, anchor);
|
|
1896
1980
|
for (const ex of scope.extras)
|
|
1897
1981
|
target.insertBefore(ex, anchor);
|
|
1898
1982
|
}
|
|
@@ -1931,19 +2015,24 @@ function longestIncreasingSubsequenceIndices(arr) {
|
|
|
1931
2015
|
function removeScope(scope) {
|
|
1932
2016
|
if (scope.startMarker?.parentNode)
|
|
1933
2017
|
scope.startMarker.remove();
|
|
2018
|
+
if (scope.scopeComments?.start.parentNode)
|
|
2019
|
+
scope.scopeComments.start.remove();
|
|
1934
2020
|
if (scope.primaryEl.parentNode)
|
|
1935
2021
|
scope.primaryEl.remove();
|
|
2022
|
+
if (scope.scopeComments?.end.parentNode)
|
|
2023
|
+
scope.scopeComments.end.remove();
|
|
1936
2024
|
for (const ex of scope.extras) {
|
|
1937
2025
|
if (ex.parentNode)
|
|
1938
2026
|
ex.remove();
|
|
1939
2027
|
}
|
|
1940
2028
|
}
|
|
1941
|
-
function createItemScope(item, index, renderItem, existingPrimary, existingExtras, existingStart, rowMount) {
|
|
2029
|
+
function createItemScope(item, index, renderItem, existingPrimary, existingExtras, existingStart, existingScopeComments, rowMount) {
|
|
1942
2030
|
let primaryEl;
|
|
1943
2031
|
let dispose;
|
|
1944
2032
|
let setItem;
|
|
1945
2033
|
let extras = [];
|
|
1946
2034
|
let startMarker = null;
|
|
2035
|
+
let scopeComments = null;
|
|
1947
2036
|
createRoot2((d) => {
|
|
1948
2037
|
dispose = d;
|
|
1949
2038
|
const [itemAccessor, itemSetter] = createSignal(item);
|
|
@@ -1966,6 +2055,7 @@ function createItemScope(item, index, renderItem, existingPrimary, existingExtra
|
|
|
1966
2055
|
if (existingPrimary) {
|
|
1967
2056
|
extras = existingExtras ?? [];
|
|
1968
2057
|
startMarker = existingStart ?? null;
|
|
2058
|
+
scopeComments = existingScopeComments ?? null;
|
|
1969
2059
|
} else {
|
|
1970
2060
|
const stashed = primaryEl.__bfExtras;
|
|
1971
2061
|
if (stashed && stashed.length > 0) {
|
|
@@ -1973,13 +2063,17 @@ function createItemScope(item, index, renderItem, existingPrimary, existingExtra
|
|
|
1973
2063
|
startMarker = document.createComment(BF_LOOP_ITEM);
|
|
1974
2064
|
}
|
|
1975
2065
|
delete primaryEl.__bfExtras;
|
|
2066
|
+
const stashedScopeComments = primaryEl.__bfScopeComments;
|
|
2067
|
+
if (stashedScopeComments)
|
|
2068
|
+
scopeComments = stashedScopeComments;
|
|
2069
|
+
delete primaryEl.__bfScopeComments;
|
|
1976
2070
|
}
|
|
1977
2071
|
return;
|
|
1978
2072
|
});
|
|
1979
2073
|
if (rowMount && !existingPrimary && extras.length > 0 && primaryEl.parentNode) {
|
|
1980
2074
|
primaryEl.remove();
|
|
1981
2075
|
}
|
|
1982
|
-
return { startMarker, primaryEl, extras, dispose, setItem };
|
|
2076
|
+
return { startMarker, primaryEl, extras, scopeComments, dispose, setItem };
|
|
1983
2077
|
}
|
|
1984
2078
|
function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
1985
2079
|
if (!container)
|
|
@@ -2005,7 +2099,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2005
2099
|
const anchor = endMarker ?? null;
|
|
2006
2100
|
if (!hydrated) {
|
|
2007
2101
|
hydrated = true;
|
|
2008
|
-
const existingRanges = startMarker ? findItemRanges(startMarker, endMarker) : Array.from(container.children).map((el) => ({ startMarker: null, primaryEl: el, extras: [] }));
|
|
2102
|
+
const existingRanges = startMarker ? findItemRanges(startMarker, endMarker) : Array.from(container.children).map((el) => ({ startMarker: null, primaryEl: el, extras: [], scopeComments: null }));
|
|
2009
2103
|
const needsHydration = existingRanges.length > 0 && (!existingRanges[0]?.primaryEl.hasAttribute("data-key") || scopes.size === 0);
|
|
2010
2104
|
if (needsHydration) {
|
|
2011
2105
|
for (let i2 = 0;i2 < existingRanges.length && i2 < items.length; i2++) {
|
|
@@ -2013,14 +2107,14 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2013
2107
|
const item = items[i2];
|
|
2014
2108
|
const key = getKey ? getKey(item, i2) : String(i2);
|
|
2015
2109
|
range.primaryEl.setAttribute(BF_KEY, key);
|
|
2016
|
-
const scope = createItemScope(item, i2, renderItem, range.primaryEl, range.extras, range.startMarker);
|
|
2110
|
+
const scope = createItemScope(item, i2, renderItem, range.primaryEl, range.extras, range.startMarker, range.scopeComments);
|
|
2017
2111
|
scopes.set(key, scope);
|
|
2018
2112
|
hydratedScopes.add(range.primaryEl);
|
|
2019
2113
|
}
|
|
2020
2114
|
for (let i2 = existingRanges.length;i2 < items.length; i2++) {
|
|
2021
2115
|
const item = items[i2];
|
|
2022
2116
|
const key = getKey ? getKey(item, i2) : String(i2);
|
|
2023
|
-
const scope = createItemScope(item, i2, renderItem, undefined, undefined, undefined, { container, anchor });
|
|
2117
|
+
const scope = createItemScope(item, i2, renderItem, undefined, undefined, undefined, undefined, { container, anchor });
|
|
2024
2118
|
if (!scope.primaryEl.dataset.key)
|
|
2025
2119
|
scope.primaryEl.setAttribute(BF_KEY, key);
|
|
2026
2120
|
scopes.set(key, scope);
|
|
@@ -2030,8 +2124,12 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2030
2124
|
const range = existingRanges[i2];
|
|
2031
2125
|
if (range.startMarker?.parentNode)
|
|
2032
2126
|
range.startMarker.remove();
|
|
2127
|
+
if (range.scopeComments?.start.parentNode)
|
|
2128
|
+
range.scopeComments.start.remove();
|
|
2033
2129
|
if (range.primaryEl.parentNode)
|
|
2034
2130
|
range.primaryEl.remove();
|
|
2131
|
+
if (range.scopeComments?.end.parentNode)
|
|
2132
|
+
range.scopeComments.end.remove();
|
|
2035
2133
|
for (const ex of range.extras) {
|
|
2036
2134
|
if (ex.parentNode)
|
|
2037
2135
|
ex.remove();
|
|
@@ -2041,7 +2139,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2041
2139
|
}
|
|
2042
2140
|
}
|
|
2043
2141
|
if (scopes.size === 0) {
|
|
2044
|
-
const loopRanges = startMarker ? findItemRanges(startMarker, endMarker) : Array.from(container.children).map((el) => ({ startMarker: null, primaryEl: el, extras: [] }));
|
|
2142
|
+
const loopRanges = startMarker ? findItemRanges(startMarker, endMarker) : Array.from(container.children).map((el) => ({ startMarker: null, primaryEl: el, extras: [], scopeComments: null }));
|
|
2045
2143
|
for (const range of loopRanges) {
|
|
2046
2144
|
const existingKey = range.primaryEl.dataset?.key;
|
|
2047
2145
|
if (existingKey && !scopes.has(existingKey)) {
|
|
@@ -2049,6 +2147,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2049
2147
|
startMarker: range.startMarker,
|
|
2050
2148
|
primaryEl: range.primaryEl,
|
|
2051
2149
|
extras: range.extras,
|
|
2150
|
+
scopeComments: range.scopeComments,
|
|
2052
2151
|
dispose: () => {},
|
|
2053
2152
|
setItem: () => {}
|
|
2054
2153
|
});
|
|
@@ -2067,7 +2166,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2067
2166
|
} else {
|
|
2068
2167
|
let expectedNodeCount = 0;
|
|
2069
2168
|
for (const scope of scopes.values()) {
|
|
2070
|
-
expectedNodeCount += 1 + scope.extras.length + (scope.startMarker ? 1 : 0);
|
|
2169
|
+
expectedNodeCount += 1 + scope.extras.length + (scope.startMarker ? 1 : 0) + (scope.scopeComments ? 2 : 0);
|
|
2071
2170
|
}
|
|
2072
2171
|
let actualNodeCount = 0;
|
|
2073
2172
|
for (let node = container.firstChild;node; node = node.nextSibling)
|
|
@@ -2099,7 +2198,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2099
2198
|
existing.setItem(item);
|
|
2100
2199
|
desiredOrder.push(existing);
|
|
2101
2200
|
} else {
|
|
2102
|
-
const scope = createItemScope(item, i2, renderItem, undefined, undefined, undefined, { container, anchor });
|
|
2201
|
+
const scope = createItemScope(item, i2, renderItem, undefined, undefined, undefined, undefined, { container, anchor });
|
|
2103
2202
|
if (!scope.primaryEl.dataset.key)
|
|
2104
2203
|
scope.primaryEl.setAttribute(BF_KEY, key);
|
|
2105
2204
|
scopes.set(key, scope);
|
|
@@ -2138,7 +2237,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
2138
2237
|
let j = i;
|
|
2139
2238
|
while (j < desiredOrder.length && !stationary[j])
|
|
2140
2239
|
j++;
|
|
2141
|
-
const before = j < desiredOrder.length ? desiredOrder[j].startMarker ?? desiredOrder[j].primaryEl : anchor;
|
|
2240
|
+
const before = j < desiredOrder.length ? desiredOrder[j].startMarker ?? desiredOrder[j].scopeComments?.start ?? desiredOrder[j].primaryEl : anchor;
|
|
2142
2241
|
if (j - i === 1) {
|
|
2143
2242
|
insertScope(desiredOrder[i], container, before);
|
|
2144
2243
|
} else {
|
|
@@ -2916,6 +3015,15 @@ function findCondStartInRange(anchor, id) {
|
|
|
2916
3015
|
}
|
|
2917
3016
|
return null;
|
|
2918
3017
|
}
|
|
3018
|
+
function findCondContainer(scope, id) {
|
|
3019
|
+
const want = `bf-cond-start:${id}`;
|
|
3020
|
+
for (const comment of commentsInScope(scope)) {
|
|
3021
|
+
if (comment.nodeValue === want) {
|
|
3022
|
+
return comment.parentElement ?? scope;
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
return scope;
|
|
3026
|
+
}
|
|
2919
3027
|
var EMPTY_SLOTS = [];
|
|
2920
3028
|
function normalizeTemplate(value) {
|
|
2921
3029
|
return typeof value === "string" ? { html: value, slots: EMPTY_SLOTS } : value;
|
|
@@ -3319,6 +3427,7 @@ export {
|
|
|
3319
3427
|
flushHydration,
|
|
3320
3428
|
findSiblingSlot,
|
|
3321
3429
|
findScope,
|
|
3430
|
+
findCondContainer,
|
|
3322
3431
|
find,
|
|
3323
3432
|
escapeTextOrNode,
|
|
3324
3433
|
escapeTextOrMarkup,
|
package/dist/runtime/insert.d.ts
CHANGED
|
@@ -5,6 +5,27 @@
|
|
|
5
5
|
* SolidJS-inspired replacement for legacy cond() that properly
|
|
6
6
|
* handles event binding for both branches.
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the DOM element that actually hosts an element-scoped loop-row
|
|
10
|
+
* conditional's branch content (#2705). A nested `mapArray` inside the
|
|
11
|
+
* branch's `bindEvents` needs a container to search for its own loop
|
|
12
|
+
* markers, but has no `bf="<slot>"` marker to query when the conditional
|
|
13
|
+
* sits inside a wrapper element the container-slot collector never visits
|
|
14
|
+
* (`collectInnerLoops`'s branch walk only sees elements INSIDE the
|
|
15
|
+
* branch's own IR subtree — a wrapper enclosing the conditional from the
|
|
16
|
+
* outside, e.g. `<article>{cond && items.map(...)}</article>`, is never
|
|
17
|
+
* one of them, so `containerSlotId` comes back `null`).
|
|
18
|
+
*
|
|
19
|
+
* The one DOM anchor available in that case is the conditional's own
|
|
20
|
+
* `<!--bf-cond-start:id-->` marker: whatever element that marker's parent
|
|
21
|
+
* is, is where `insert()` keeps the branch's content — adopted from SSR or
|
|
22
|
+
* freshly spliced by `updateFragmentConditional`, either way the marker
|
|
23
|
+
* stays put as one of the range's boundaries. Falls back to `scope` itself
|
|
24
|
+
* when no such marker is found (an element-conditional branch with no
|
|
25
|
+
* comment markers, or a conditional with no wrapper at all — `scope` IS
|
|
26
|
+
* the right container in that shape too) — never throws.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findCondContainer(scope: Element, id: string): Element;
|
|
8
29
|
/**
|
|
9
30
|
* Result returned by a branch's `template()` when the template captures
|
|
10
31
|
* live DOM nodes via `__bfSlot` (#1213). `html` carries the marker-bearing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/runtime/insert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmFH;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,IAAI,EAAE,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,EAAE,MAAM,MAAM,GAAG,oBAAoB,CAAA;IAE7C;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;CACrF;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,EAC/B,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,OAAO,EAC1B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,YAAY,EACvB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CA+IN"}
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/runtime/insert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmFH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAQrE;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,IAAI,EAAE,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,EAAE,MAAM,MAAM,GAAG,oBAAoB,CAAA;IAE7C;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;CACrF;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,EAC/B,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,OAAO,EAC1B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,YAAY,EACvB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CA+IN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-array.d.ts","sourceRoot":"","sources":["../../src/runtime/map-array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"map-array.d.ts","sourceRoot":"","sources":["../../src/runtime/map-array.ts"],"names":[],"mappings":"AAAA;;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 @@
|
|
|
1
|
-
{"version":3,"file":"qsa-item.d.ts","sourceRoot":"","sources":["../../src/runtime/qsa-item.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AA4CH;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAQnF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"qsa-item.d.ts","sourceRoot":"","sources":["../../src/runtime/qsa-item.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AA4CH;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAQnF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B,WAAW,GAAG,IAAI,CAyBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/runtime/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAaxC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAclE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,GAAG,IAAI,EAC1B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,IAAI,CAoCN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/runtime/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAaxC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAclE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,GAAG,IAAI,E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