@barefootjs/client 0.17.0 → 0.18.0
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/build.d.ts +16 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +3 -1
- package/dist/reactive.d.ts.map +1 -1
- package/dist/reactive.js +59 -26
- package/dist/runtime/component.d.ts +13 -3
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/index.js +128 -46
- package/dist/runtime/map-array.d.ts.map +1 -1
- package/dist/runtime/standalone.js +187 -72
- package/package.json +2 -2
- package/src/build.ts +16 -0
- package/src/reactive.ts +167 -32
- package/src/runtime/component.ts +14 -3
- package/src/runtime/map-array.ts +172 -29
package/dist/build.d.ts
CHANGED
|
@@ -30,6 +30,20 @@ export interface CSRBuildOptions {
|
|
|
30
30
|
adapter?: TemplateAdapter;
|
|
31
31
|
/** Options forwarded to the default `CSRAdapter`. Ignored when `adapter` is set. */
|
|
32
32
|
adapterOptions?: CSRAdapterOptions;
|
|
33
|
+
/**
|
|
34
|
+
* How the CLI produces `barefoot.js`. Defaults to `'treeshake'`, which
|
|
35
|
+
* bundles only the runtime exports this project's compiled client JS
|
|
36
|
+
* actually imports (plus the always-kept public mount API). Set to
|
|
37
|
+
* `'full'` to copy the entire prebuilt runtime bundle verbatim, matching
|
|
38
|
+
* pre-tree-shaking behavior.
|
|
39
|
+
*/
|
|
40
|
+
runtimeBundle?: 'treeshake' | 'full';
|
|
41
|
+
/**
|
|
42
|
+
* Extra `@barefootjs/client*` export names to force-keep in `barefoot.js`
|
|
43
|
+
* under `runtimeBundle: 'treeshake'` — for names only ever referenced
|
|
44
|
+
* from hand-written page scripts the CLI never compiles.
|
|
45
|
+
*/
|
|
46
|
+
runtimeKeep?: string[];
|
|
33
47
|
}
|
|
34
48
|
/**
|
|
35
49
|
* Create a BarefootBuildConfig for CSR projects.
|
|
@@ -50,6 +64,8 @@ export declare function createConfig(options?: CSRBuildOptions): {
|
|
|
50
64
|
bundleEntries: BundleEntry[] | undefined;
|
|
51
65
|
outputLayout: OutputLayout | undefined;
|
|
52
66
|
postBuild: ((ctx: PostBuildContext) => Promise<void> | void) | undefined;
|
|
67
|
+
runtimeBundle: "full" | "treeshake" | undefined;
|
|
68
|
+
runtimeKeep: string[] | undefined;
|
|
53
69
|
};
|
|
54
70
|
export { CSRAdapter } from './csr-adapter.ts';
|
|
55
71
|
export type { CSRAdapterOptions } from './csr-adapter.ts';
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,sCAAsC;IACtC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,wEAAwE;IACxE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC3D,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACxC,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAA;I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ACH,aAAa,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,eAAoB;;;;;;;;;;;;sBArCtC,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;;;EA2D5D;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/build.js
CHANGED
|
@@ -67,7 +67,9 @@ function createConfig(options = {}) {
|
|
|
67
67
|
externalsBasePath: options.externalsBasePath,
|
|
68
68
|
bundleEntries: options.bundleEntries,
|
|
69
69
|
outputLayout: options.outputLayout,
|
|
70
|
-
postBuild: options.postBuild
|
|
70
|
+
postBuild: options.postBuild,
|
|
71
|
+
runtimeBundle: options.runtimeBundle,
|
|
72
|
+
runtimeKeep: options.runtimeKeep
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
export {
|
package/dist/reactive.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../src/reactive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAA;CAAE,CAAA;AAE3D,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IACtB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjB,uDAAuD;IACvD,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;CAC1C,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,IAAI,CAAA;AAClC,MAAM,MAAM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changed) {
|
|
|
110
110
|
var Owner = null;
|
|
111
111
|
var Listener = null;
|
|
112
112
|
var MAX_EFFECT_RUNS = 100;
|
|
113
|
+
function registerChild(owner, child) {
|
|
114
|
+
if (!owner.children)
|
|
115
|
+
owner.children = new Set;
|
|
116
|
+
owner.children.add(child);
|
|
117
|
+
}
|
|
113
118
|
var BatchDepth = 0;
|
|
114
119
|
var PendingEffects = new Set;
|
|
115
120
|
function createSignal(initialValue, __bfId) {
|
|
@@ -119,10 +124,18 @@ function createSignal(initialValue, __bfId) {
|
|
|
119
124
|
subscribers.__bfSignalId = id;
|
|
120
125
|
const get = () => {
|
|
121
126
|
if (Listener) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
if (profilerSink) {
|
|
128
|
+
subscribers.add(Listener);
|
|
129
|
+
subscribers.__bfSnapshot = null;
|
|
130
|
+
Listener.dependencies.set(subscribers, Listener.gen);
|
|
125
131
|
profilerSink.subscribeAdd(id, Listener.id);
|
|
132
|
+
} else if (!Listener.dependencies.has(subscribers)) {
|
|
133
|
+
subscribers.add(Listener);
|
|
134
|
+
subscribers.__bfSnapshot = null;
|
|
135
|
+
Listener.dependencies.set(subscribers, Listener.gen);
|
|
136
|
+
} else {
|
|
137
|
+
Listener.dependencies.set(subscribers, Listener.gen);
|
|
138
|
+
}
|
|
126
139
|
}
|
|
127
140
|
return value;
|
|
128
141
|
};
|
|
@@ -139,9 +152,12 @@ function createSignal(initialValue, __bfId) {
|
|
|
139
152
|
PendingEffects.add(effect);
|
|
140
153
|
}
|
|
141
154
|
} else {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
let snapshot = subscribers.__bfSnapshot;
|
|
156
|
+
if (!snapshot) {
|
|
157
|
+
snapshot = subscribers.__bfSnapshot = [...subscribers];
|
|
158
|
+
}
|
|
159
|
+
for (let i = 0;i < snapshot.length; i++) {
|
|
160
|
+
runEffect(snapshot[i]);
|
|
145
161
|
}
|
|
146
162
|
}
|
|
147
163
|
};
|
|
@@ -151,9 +167,10 @@ function createEffect(fn, __bfId, __bfKind = "effect") {
|
|
|
151
167
|
const effect = {
|
|
152
168
|
fn,
|
|
153
169
|
cleanup: null,
|
|
154
|
-
dependencies: new
|
|
170
|
+
dependencies: new Map,
|
|
171
|
+
gen: 0,
|
|
155
172
|
owner: Owner,
|
|
156
|
-
children:
|
|
173
|
+
children: null,
|
|
157
174
|
disposed: false,
|
|
158
175
|
runCount: 0,
|
|
159
176
|
id: __bfId ?? (profilerSink ? `e${++subscriberSeq}` : ""),
|
|
@@ -164,7 +181,7 @@ function createEffect(fn, __bfId, __bfKind = "effect") {
|
|
|
164
181
|
if (profilerSink)
|
|
165
182
|
profilerSink.effectCreate(effect.id, effect.kind);
|
|
166
183
|
if (Owner)
|
|
167
|
-
Owner
|
|
184
|
+
registerChild(Owner, effect);
|
|
168
185
|
runEffect(effect);
|
|
169
186
|
}
|
|
170
187
|
function runEffect(effect) {
|
|
@@ -175,22 +192,26 @@ function runEffect(effect) {
|
|
|
175
192
|
effect.runCount = 0;
|
|
176
193
|
throw new Error(`Circular dependency detected: effect re-entered itself ${MAX_EFFECT_RUNS} times.`);
|
|
177
194
|
}
|
|
195
|
+
const isOutermostRun = effect.runCount === 1;
|
|
178
196
|
if (profilerSink)
|
|
179
197
|
profilerSink.effectEnter(effect.id);
|
|
180
198
|
if (effect.cleanup) {
|
|
181
199
|
effect.cleanup();
|
|
182
200
|
effect.cleanup = null;
|
|
183
201
|
}
|
|
184
|
-
|
|
185
|
-
dep.
|
|
186
|
-
|
|
202
|
+
if (profilerSink) {
|
|
203
|
+
for (const dep of effect.dependencies.keys()) {
|
|
204
|
+
dep.delete(effect);
|
|
205
|
+
dep.__bfSnapshot = null;
|
|
187
206
|
profilerSink.subscribeRemove(dep.__bfSignalId ?? "", effect.id);
|
|
207
|
+
}
|
|
208
|
+
effect.dependencies.clear();
|
|
188
209
|
}
|
|
189
|
-
effect.dependencies.clear();
|
|
190
210
|
const prevOwner = Owner;
|
|
191
211
|
const prevListener = Listener;
|
|
192
212
|
Owner = effect;
|
|
193
213
|
Listener = effect;
|
|
214
|
+
effect.gen++;
|
|
194
215
|
effect.outputReported = false;
|
|
195
216
|
effect.outputChanged = false;
|
|
196
217
|
const start = profilerSink ? performance.now() : 0;
|
|
@@ -203,6 +224,15 @@ function runEffect(effect) {
|
|
|
203
224
|
Owner = prevOwner;
|
|
204
225
|
Listener = prevListener;
|
|
205
226
|
effect.runCount--;
|
|
227
|
+
if (!profilerSink && isOutermostRun) {
|
|
228
|
+
for (const [dep, gen] of effect.dependencies) {
|
|
229
|
+
if (gen !== effect.gen) {
|
|
230
|
+
effect.dependencies.delete(dep);
|
|
231
|
+
dep.delete(effect);
|
|
232
|
+
dep.__bfSnapshot = null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
206
236
|
if (profilerSink) {
|
|
207
237
|
profilerSink.effectExit(effect.id, performance.now() - start);
|
|
208
238
|
if (effect.outputReported)
|
|
@@ -214,16 +244,19 @@ function disposeSubtree(effect) {
|
|
|
214
244
|
if (effect.disposed)
|
|
215
245
|
return;
|
|
216
246
|
effect.disposed = true;
|
|
217
|
-
|
|
218
|
-
|
|
247
|
+
if (effect.children) {
|
|
248
|
+
for (const child of effect.children) {
|
|
249
|
+
disposeSubtree(child);
|
|
250
|
+
}
|
|
251
|
+
effect.children.clear();
|
|
219
252
|
}
|
|
220
|
-
effect.children.length = 0;
|
|
221
253
|
if (effect.cleanup) {
|
|
222
254
|
effect.cleanup();
|
|
223
255
|
effect.cleanup = null;
|
|
224
256
|
}
|
|
225
|
-
for (const dep of effect.dependencies) {
|
|
257
|
+
for (const dep of effect.dependencies.keys()) {
|
|
226
258
|
dep.delete(effect);
|
|
259
|
+
dep.__bfSnapshot = null;
|
|
227
260
|
if (profilerSink)
|
|
228
261
|
profilerSink.subscribeRemove(dep.__bfSignalId ?? "", effect.id);
|
|
229
262
|
}
|
|
@@ -236,9 +269,7 @@ function disposeEffect(effect) {
|
|
|
236
269
|
if (effect.disposed)
|
|
237
270
|
return;
|
|
238
271
|
if (effect.owner) {
|
|
239
|
-
|
|
240
|
-
if (idx >= 0)
|
|
241
|
-
effect.owner.children.splice(idx, 1);
|
|
272
|
+
effect.owner.children?.delete(effect);
|
|
242
273
|
}
|
|
243
274
|
disposeSubtree(effect);
|
|
244
275
|
}
|
|
@@ -246,9 +277,10 @@ function createRoot(fn) {
|
|
|
246
277
|
const root = {
|
|
247
278
|
fn: () => {},
|
|
248
279
|
cleanup: null,
|
|
249
|
-
dependencies: new
|
|
280
|
+
dependencies: new Map,
|
|
281
|
+
gen: 0,
|
|
250
282
|
owner: Owner,
|
|
251
|
-
children:
|
|
283
|
+
children: null,
|
|
252
284
|
disposed: false,
|
|
253
285
|
runCount: 0,
|
|
254
286
|
id: profilerSink ? `r${++subscriberSeq}` : "",
|
|
@@ -259,7 +291,7 @@ function createRoot(fn) {
|
|
|
259
291
|
if (profilerSink)
|
|
260
292
|
profilerSink.effectCreate(root.id, "root");
|
|
261
293
|
if (Owner)
|
|
262
|
-
Owner
|
|
294
|
+
registerChild(Owner, root);
|
|
263
295
|
const prevOwner = Owner;
|
|
264
296
|
const prevListener = Listener;
|
|
265
297
|
Owner = root;
|
|
@@ -280,9 +312,10 @@ function createDisposableEffect(fn, __bfId) {
|
|
|
280
312
|
return fn();
|
|
281
313
|
},
|
|
282
314
|
cleanup: null,
|
|
283
|
-
dependencies: new
|
|
315
|
+
dependencies: new Map,
|
|
316
|
+
gen: 0,
|
|
284
317
|
owner: Owner,
|
|
285
|
-
children:
|
|
318
|
+
children: null,
|
|
286
319
|
disposed: false,
|
|
287
320
|
runCount: 0,
|
|
288
321
|
id: __bfId ?? (profilerSink ? `e${++subscriberSeq}` : ""),
|
|
@@ -293,7 +326,7 @@ function createDisposableEffect(fn, __bfId) {
|
|
|
293
326
|
if (profilerSink)
|
|
294
327
|
profilerSink.effectCreate(effect.id, effect.kind);
|
|
295
328
|
if (Owner)
|
|
296
|
-
Owner
|
|
329
|
+
registerChild(Owner, effect);
|
|
297
330
|
runEffect(effect);
|
|
298
331
|
return () => {
|
|
299
332
|
disposeEffect(effect);
|
|
@@ -97,10 +97,20 @@ export declare function escapeAttr(value: unknown): string;
|
|
|
97
97
|
* slots). The HTML spec only requires `& < >` in text, but the SSR
|
|
98
98
|
* adapters (Hono) escape text with the same set as attribute values
|
|
99
99
|
* (`& " ' < >`), and the fixture-hydrate / CSR-conformance layer requires
|
|
100
|
-
* byte-parity with the server-rendered output — so
|
|
101
|
-
* `escapeAttr`. Kept as a distinct export so generated code reads
|
|
100
|
+
* byte-parity with the server-rendered output — so the escaping delegates
|
|
101
|
+
* to `escapeAttr`. Kept as a distinct export so generated code reads
|
|
102
102
|
* `escapeText(...)` at text sites (self-documenting) and so the two
|
|
103
|
-
* contexts can diverge
|
|
103
|
+
* contexts can diverge (as they now do for nullish) without touching call
|
|
104
|
+
* sites.
|
|
105
|
+
*
|
|
106
|
+
* A nullish value renders as empty text — the JSX/Solid semantics the Hono
|
|
107
|
+
* SSR reference follows (`{undefined}` / `{null}` produce no text), and
|
|
108
|
+
* what the reactive text-update path already does (`dynamic-text.ts` and
|
|
109
|
+
* `client-marker.ts` both `String(value ?? '')`). Only this initial-render
|
|
110
|
+
* escape site used to stringify `undefined` / `null` into literal
|
|
111
|
+
* "undefined" / "null" text, so a bare `{props.x}` on an absent prop
|
|
112
|
+
* diverged from SSR at first paint (#2137). Non-nullish values (including
|
|
113
|
+
* `0` and `false`) keep their `String()` form, matching the reactive path.
|
|
104
114
|
*/
|
|
105
115
|
export declare function escapeText(value: unknown): string;
|
|
106
116
|
/**
|
|
@@ -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,M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K,EAAE,OAAO,GAAG,MAAM,CAGjD;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAcjF"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1245,6 +1245,8 @@ function escapeAttr(value) {
|
|
|
1245
1245
|
return String(value).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
1246
1246
|
}
|
|
1247
1247
|
function escapeText(value) {
|
|
1248
|
+
if (value == null)
|
|
1249
|
+
return "";
|
|
1248
1250
|
return escapeAttr(value);
|
|
1249
1251
|
}
|
|
1250
1252
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
@@ -1665,7 +1667,7 @@ function findLoopMarkers2(container, markerId) {
|
|
|
1665
1667
|
if (markerId) {
|
|
1666
1668
|
const startVal = loopStartMarker(markerId);
|
|
1667
1669
|
const endVal = loopEndMarker(markerId);
|
|
1668
|
-
for (
|
|
1670
|
+
for (let node = container.firstChild;node; node = node.nextSibling) {
|
|
1669
1671
|
if (node.nodeType !== Node.COMMENT_NODE)
|
|
1670
1672
|
continue;
|
|
1671
1673
|
const value = node.nodeValue;
|
|
@@ -1677,7 +1679,7 @@ function findLoopMarkers2(container, markerId) {
|
|
|
1677
1679
|
} else {
|
|
1678
1680
|
const startPrefix = `${BF_LOOP_START}:`;
|
|
1679
1681
|
const endPrefix = `${BF_LOOP_END}:`;
|
|
1680
|
-
for (
|
|
1682
|
+
for (let node = container.firstChild;node; node = node.nextSibling) {
|
|
1681
1683
|
if (node.nodeType !== Node.COMMENT_NODE)
|
|
1682
1684
|
continue;
|
|
1683
1685
|
const value = node.nodeValue ?? "";
|
|
@@ -1717,12 +1719,44 @@ function findItemRanges(start, end) {
|
|
|
1717
1719
|
}
|
|
1718
1720
|
return ranges.filter((r) => r.primaryEl !== null);
|
|
1719
1721
|
}
|
|
1720
|
-
function insertScope(scope,
|
|
1722
|
+
function insertScope(scope, target, anchor) {
|
|
1721
1723
|
if (scope.startMarker)
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
+
target.insertBefore(scope.startMarker, anchor);
|
|
1725
|
+
target.insertBefore(scope.primaryEl, anchor);
|
|
1724
1726
|
for (const ex of scope.extras)
|
|
1725
|
-
|
|
1727
|
+
target.insertBefore(ex, anchor);
|
|
1728
|
+
}
|
|
1729
|
+
function longestIncreasingSubsequenceIndices(arr) {
|
|
1730
|
+
const n = arr.length;
|
|
1731
|
+
if (n === 0)
|
|
1732
|
+
return [];
|
|
1733
|
+
const tails = [];
|
|
1734
|
+
const predecessors = new Array(n).fill(-1);
|
|
1735
|
+
for (let i = 0;i < n; i++) {
|
|
1736
|
+
const value = arr[i];
|
|
1737
|
+
let lo = 0;
|
|
1738
|
+
let hi = tails.length;
|
|
1739
|
+
while (lo < hi) {
|
|
1740
|
+
const mid = lo + hi >>> 1;
|
|
1741
|
+
if (arr[tails[mid]] < value)
|
|
1742
|
+
lo = mid + 1;
|
|
1743
|
+
else
|
|
1744
|
+
hi = mid;
|
|
1745
|
+
}
|
|
1746
|
+
if (lo > 0)
|
|
1747
|
+
predecessors[i] = tails[lo - 1];
|
|
1748
|
+
if (lo === tails.length)
|
|
1749
|
+
tails.push(i);
|
|
1750
|
+
else
|
|
1751
|
+
tails[lo] = i;
|
|
1752
|
+
}
|
|
1753
|
+
const result = new Array(tails.length);
|
|
1754
|
+
let k = tails[tails.length - 1];
|
|
1755
|
+
for (let i = tails.length - 1;i >= 0; i--) {
|
|
1756
|
+
result[i] = k;
|
|
1757
|
+
k = predecessors[k];
|
|
1758
|
+
}
|
|
1759
|
+
return result;
|
|
1726
1760
|
}
|
|
1727
1761
|
function removeScope(scope) {
|
|
1728
1762
|
if (scope.startMarker?.parentNode)
|
|
@@ -1765,37 +1799,48 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
1765
1799
|
return;
|
|
1766
1800
|
const scopes = new Map;
|
|
1767
1801
|
let hydrated = false;
|
|
1802
|
+
let cachedStart = null;
|
|
1803
|
+
let cachedEnd = null;
|
|
1804
|
+
const resolveMarkers = () => {
|
|
1805
|
+
if (cachedStart && cachedEnd && cachedStart.isConnected && cachedEnd.isConnected) {
|
|
1806
|
+
return { start: cachedStart, end: cachedEnd };
|
|
1807
|
+
}
|
|
1808
|
+
const found = findLoopMarkers2(container, markerId);
|
|
1809
|
+
cachedStart = found.start;
|
|
1810
|
+
cachedEnd = found.end;
|
|
1811
|
+
return found;
|
|
1812
|
+
};
|
|
1768
1813
|
createEffect(() => {
|
|
1769
1814
|
const items = accessor();
|
|
1770
1815
|
if (!items)
|
|
1771
1816
|
return;
|
|
1772
|
-
const { start: startMarker, end: endMarker } =
|
|
1817
|
+
const { start: startMarker, end: endMarker } = resolveMarkers();
|
|
1773
1818
|
const anchor = endMarker ?? null;
|
|
1774
1819
|
if (!hydrated) {
|
|
1775
1820
|
hydrated = true;
|
|
1776
1821
|
const existingRanges = startMarker ? findItemRanges(startMarker, endMarker) : Array.from(container.children).map((el) => ({ startMarker: null, primaryEl: el, extras: [] }));
|
|
1777
1822
|
const needsHydration = existingRanges.length > 0 && (!existingRanges[0]?.primaryEl.hasAttribute("data-key") || scopes.size === 0);
|
|
1778
1823
|
if (needsHydration) {
|
|
1779
|
-
for (let
|
|
1780
|
-
const range = existingRanges[
|
|
1781
|
-
const item = items[
|
|
1782
|
-
const key = getKey ? getKey(item,
|
|
1824
|
+
for (let i2 = 0;i2 < existingRanges.length && i2 < items.length; i2++) {
|
|
1825
|
+
const range = existingRanges[i2];
|
|
1826
|
+
const item = items[i2];
|
|
1827
|
+
const key = getKey ? getKey(item, i2) : String(i2);
|
|
1783
1828
|
range.primaryEl.setAttribute(BF_KEY, key);
|
|
1784
|
-
const scope = createItemScope(item,
|
|
1829
|
+
const scope = createItemScope(item, i2, renderItem, range.primaryEl, range.extras, range.startMarker);
|
|
1785
1830
|
scopes.set(key, scope);
|
|
1786
1831
|
hydratedScopes.add(range.primaryEl);
|
|
1787
1832
|
}
|
|
1788
|
-
for (let
|
|
1789
|
-
const item = items[
|
|
1790
|
-
const key = getKey ? getKey(item,
|
|
1791
|
-
const scope = createItemScope(item,
|
|
1833
|
+
for (let i2 = existingRanges.length;i2 < items.length; i2++) {
|
|
1834
|
+
const item = items[i2];
|
|
1835
|
+
const key = getKey ? getKey(item, i2) : String(i2);
|
|
1836
|
+
const scope = createItemScope(item, i2, renderItem);
|
|
1792
1837
|
if (!scope.primaryEl.dataset.key)
|
|
1793
1838
|
scope.primaryEl.setAttribute(BF_KEY, key);
|
|
1794
1839
|
scopes.set(key, scope);
|
|
1795
1840
|
insertScope(scope, container, anchor);
|
|
1796
1841
|
}
|
|
1797
|
-
for (let
|
|
1798
|
-
const range = existingRanges[
|
|
1842
|
+
for (let i2 = items.length;i2 < existingRanges.length; i2++) {
|
|
1843
|
+
const range = existingRanges[i2];
|
|
1799
1844
|
if (range.startMarker?.parentNode)
|
|
1800
1845
|
range.startMarker.remove();
|
|
1801
1846
|
if (range.primaryEl.parentNode)
|
|
@@ -1823,12 +1868,40 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
1823
1868
|
}
|
|
1824
1869
|
}
|
|
1825
1870
|
}
|
|
1871
|
+
if (items.length === 0) {
|
|
1872
|
+
if (scopes.size > 0) {
|
|
1873
|
+
for (const scope of scopes.values())
|
|
1874
|
+
scope.dispose();
|
|
1875
|
+
if (startMarker && endMarker) {
|
|
1876
|
+
const range = document.createRange();
|
|
1877
|
+
range.setStartAfter(startMarker);
|
|
1878
|
+
range.setEndBefore(endMarker);
|
|
1879
|
+
range.deleteContents();
|
|
1880
|
+
} else {
|
|
1881
|
+
let expectedNodeCount = 0;
|
|
1882
|
+
for (const scope of scopes.values()) {
|
|
1883
|
+
expectedNodeCount += 1 + scope.extras.length + (scope.startMarker ? 1 : 0);
|
|
1884
|
+
}
|
|
1885
|
+
let actualNodeCount = 0;
|
|
1886
|
+
for (let node = container.firstChild;node; node = node.nextSibling)
|
|
1887
|
+
actualNodeCount++;
|
|
1888
|
+
if (actualNodeCount === expectedNodeCount) {
|
|
1889
|
+
container.textContent = "";
|
|
1890
|
+
} else {
|
|
1891
|
+
for (const scope of scopes.values())
|
|
1892
|
+
removeScope(scope);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
scopes.clear();
|
|
1896
|
+
}
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1826
1899
|
const newKeys = new Set;
|
|
1827
1900
|
const warnedKeys = new Set;
|
|
1828
1901
|
const desiredOrder = [];
|
|
1829
|
-
for (let
|
|
1830
|
-
const item = items[
|
|
1831
|
-
const key = getKey ? getKey(item,
|
|
1902
|
+
for (let i2 = 0;i2 < items.length; i2++) {
|
|
1903
|
+
const item = items[i2];
|
|
1904
|
+
const key = getKey ? getKey(item, i2) : String(i2);
|
|
1832
1905
|
if (newKeys.has(key) && !warnedKeys.has(key)) {
|
|
1833
1906
|
warnedKeys.add(key);
|
|
1834
1907
|
console.warn(`[BarefootJS] mapArray: duplicate key "${key}" — items with this key collapse to a single DOM scope, ` + `so only the last one renders. Use a per-item identifier (e.g. \`key={item.id}\`) for correct reconciliation.`);
|
|
@@ -1839,7 +1912,7 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
1839
1912
|
existing.setItem(item);
|
|
1840
1913
|
desiredOrder.push(existing);
|
|
1841
1914
|
} else {
|
|
1842
|
-
const scope = createItemScope(item,
|
|
1915
|
+
const scope = createItemScope(item, i2, renderItem);
|
|
1843
1916
|
if (!scope.primaryEl.dataset.key)
|
|
1844
1917
|
scope.primaryEl.setAttribute(BF_KEY, key);
|
|
1845
1918
|
scopes.set(key, scope);
|
|
@@ -1853,32 +1926,41 @@ function mapArray(accessor, container, getKey, renderItem, markerId, bfId) {
|
|
|
1853
1926
|
scopes.delete(key);
|
|
1854
1927
|
}
|
|
1855
1928
|
}
|
|
1856
|
-
|
|
1857
|
-
let
|
|
1858
|
-
|
|
1859
|
-
while (checkNode && checkNode.nodeType !== Node.ELEMENT_NODE)
|
|
1860
|
-
checkNode = checkNode.nextSibling;
|
|
1861
|
-
if (checkNode !== scope.primaryEl) {
|
|
1862
|
-
inOrder = false;
|
|
1863
|
-
break;
|
|
1864
|
-
}
|
|
1865
|
-
checkNode = checkNode.nextSibling;
|
|
1866
|
-
for (let i = 0;i < scope.extras.length; i++) {
|
|
1867
|
-
while (checkNode && checkNode.nodeType !== Node.ELEMENT_NODE)
|
|
1868
|
-
checkNode = checkNode.nextSibling;
|
|
1869
|
-
if (checkNode !== scope.extras[i]) {
|
|
1870
|
-
inOrder = false;
|
|
1871
|
-
break;
|
|
1872
|
-
}
|
|
1873
|
-
checkNode = checkNode.nextSibling;
|
|
1874
|
-
}
|
|
1875
|
-
if (!inOrder)
|
|
1876
|
-
break;
|
|
1929
|
+
const primaryElToDesiredIndex = new Map;
|
|
1930
|
+
for (let i2 = 0;i2 < desiredOrder.length; i2++) {
|
|
1931
|
+
primaryElToDesiredIndex.set(desiredOrder[i2].primaryEl, i2);
|
|
1877
1932
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1933
|
+
const domOrderIndices = [];
|
|
1934
|
+
for (let node = startMarker ? startMarker.nextSibling : container.firstChild;node && node !== anchor; node = node.nextSibling) {
|
|
1935
|
+
if (node.nodeType !== Node.ELEMENT_NODE)
|
|
1936
|
+
continue;
|
|
1937
|
+
const idx = primaryElToDesiredIndex.get(node);
|
|
1938
|
+
if (idx !== undefined)
|
|
1939
|
+
domOrderIndices.push(idx);
|
|
1940
|
+
}
|
|
1941
|
+
const stationary = new Array(desiredOrder.length).fill(false);
|
|
1942
|
+
for (const pos of longestIncreasingSubsequenceIndices(domOrderIndices)) {
|
|
1943
|
+
stationary[domOrderIndices[pos]] = true;
|
|
1944
|
+
}
|
|
1945
|
+
let i = 0;
|
|
1946
|
+
while (i < desiredOrder.length) {
|
|
1947
|
+
if (stationary[i]) {
|
|
1948
|
+
i++;
|
|
1949
|
+
continue;
|
|
1950
|
+
}
|
|
1951
|
+
let j = i;
|
|
1952
|
+
while (j < desiredOrder.length && !stationary[j])
|
|
1953
|
+
j++;
|
|
1954
|
+
const before = j < desiredOrder.length ? desiredOrder[j].startMarker ?? desiredOrder[j].primaryEl : anchor;
|
|
1955
|
+
if (j - i === 1) {
|
|
1956
|
+
insertScope(desiredOrder[i], container, before);
|
|
1957
|
+
} else {
|
|
1958
|
+
const runFragment = document.createDocumentFragment();
|
|
1959
|
+
for (let k = i;k < j; k++)
|
|
1960
|
+
insertScope(desiredOrder[k], runFragment, null);
|
|
1961
|
+
container.insertBefore(runFragment, before);
|
|
1881
1962
|
}
|
|
1963
|
+
i = j;
|
|
1882
1964
|
}
|
|
1883
1965
|
}, bfId);
|
|
1884
1966
|
}
|
|
@@ -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;;;;;;;;;;;;;;;;;;GAkBG;AAgPH;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,MAAM,CAAC,EAAE,EACnB,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,KAAK,WAAW,EACjF,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CAoQN;AAqHD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,QAAQ,EAAE,MAAM,CAAC,EAAE,EACnB,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,gBAAgB,GAAG,OAAO,EAC5F,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CA+FN"}
|