@wcstack/state 4.9.0 → 4.10.1
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/README.ja.md +33 -12
- package/README.md +33 -12
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.esm.js +29 -31
- package/dist/parser.esm.js +4 -1
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/chunk-65B2K2XD.js +2 -0
- package/dist/split/chunks/{chunk-J3PTKUWV.js.map → chunk-65B2K2XD.js.map} +1 -1
- package/dist/split/chunks/{chunk-ISBASPV2.js → chunk-FFXJVUTT.js} +2 -2
- package/dist/split/chunks/{chunk-LWRYFYOC.js → chunk-FT7OW7CG.js} +2 -2
- package/dist/split/chunks/chunk-GU7IAIWW.js +2 -0
- package/dist/split/chunks/chunk-GU7IAIWW.js.map +1 -0
- package/dist/split/chunks/chunk-IWY3I2DG.js +2 -0
- package/dist/split/chunks/{chunk-47I6RYV3.js.map → chunk-IWY3I2DG.js.map} +1 -1
- package/dist/split/chunks/{chunk-FQUDP3XK.js → chunk-JCQTA35B.js} +2 -2
- package/dist/split/chunks/chunk-MZVF2WEY.js +2 -0
- package/dist/split/chunks/{chunk-P3JKSHRN.js → chunk-PTFWXISY.js} +2 -2
- package/dist/split/chunks/chunk-SANIIUS2.js +2 -0
- package/dist/split/chunks/chunk-SANIIUS2.js.map +1 -0
- package/dist/split/chunks/{chunk-BCL75PFH.js → chunk-SJRJALR4.js} +2 -2
- package/dist/split/chunks/chunk-UE6JK2ZA.js +2 -0
- package/dist/split/chunks/chunk-UE6JK2ZA.js.map +1 -0
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/list-keys.js +1 -1
- package/dist/split/features/native-commands.js +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/dist/wcs-manifest.json +9 -6
- package/package.json +1 -1
- package/dist/split/chunks/chunk-47I6RYV3.js +0 -2
- package/dist/split/chunks/chunk-EBIQH2HE.js +0 -2
- package/dist/split/chunks/chunk-EBIQH2HE.js.map +0 -1
- package/dist/split/chunks/chunk-J3PTKUWV.js +0 -2
- package/dist/split/chunks/chunk-SOFOV2OG.js +0 -2
- package/dist/split/chunks/chunk-SOFOV2OG.js.map +0 -1
- package/dist/split/chunks/chunk-TS2HEHBQ.js +0 -2
- package/dist/split/chunks/chunk-YIDHPXYQ.js +0 -2
- package/dist/split/chunks/chunk-YIDHPXYQ.js.map +0 -1
- /package/dist/split/chunks/{chunk-ISBASPV2.js.map → chunk-FFXJVUTT.js.map} +0 -0
- /package/dist/split/chunks/{chunk-LWRYFYOC.js.map → chunk-FT7OW7CG.js.map} +0 -0
- /package/dist/split/chunks/{chunk-FQUDP3XK.js.map → chunk-JCQTA35B.js.map} +0 -0
- /package/dist/split/chunks/{chunk-TS2HEHBQ.js.map → chunk-MZVF2WEY.js.map} +0 -0
- /package/dist/split/chunks/{chunk-P3JKSHRN.js.map → chunk-PTFWXISY.js.map} +0 -0
- /package/dist/split/chunks/{chunk-BCL75PFH.js.map → chunk-SJRJALR4.js.map} +0 -0
package/dist/manifest.esm.js
CHANGED
|
@@ -254,12 +254,6 @@ var upper = () => (value) => String(value).toUpperCase();
|
|
|
254
254
|
var lower = () => (value) => String(value).toLowerCase();
|
|
255
255
|
var capitalize = () => (value) => {
|
|
256
256
|
const v = String(value);
|
|
257
|
-
if (v.length === 0) {
|
|
258
|
-
return v;
|
|
259
|
-
}
|
|
260
|
-
if (v.length === 1) {
|
|
261
|
-
return v.toUpperCase();
|
|
262
|
-
}
|
|
263
257
|
return v.charAt(0).toUpperCase() + v.slice(1);
|
|
264
258
|
};
|
|
265
259
|
var trim = () => (value) => String(value).trim();
|
|
@@ -308,14 +302,20 @@ var join = (options) => {
|
|
|
308
302
|
};
|
|
309
303
|
var STYLES = ["full", "long", "medium", "short"];
|
|
310
304
|
function dateOptions(options, fn) {
|
|
311
|
-
let [loc, style] = options ?? [];
|
|
312
|
-
if (style
|
|
313
|
-
if (style
|
|
314
|
-
|
|
305
|
+
let [loc, style, zone] = (options ?? []).map((option) => option || void 0);
|
|
306
|
+
if (!style && STYLES.includes(loc)) [loc, style] = [void 0, loc];
|
|
307
|
+
else if (!style && !zone && /\/|^UTC$/.test(loc)) [loc, zone] = [void 0, loc];
|
|
308
|
+
if (style && !STYLES.includes(style)) styleInvalid(fn, style);
|
|
309
|
+
try {
|
|
310
|
+
if (zone) new Intl.DateTimeFormat(void 0, { timeZone: zone });
|
|
311
|
+
} catch {
|
|
312
|
+
raise(54 /* FilterTimeZoneInvalid */, [fn, zone]);
|
|
313
|
+
}
|
|
314
|
+
return [loc, style, zone];
|
|
315
315
|
}
|
|
316
316
|
var date = (options) => {
|
|
317
|
-
const [explicit, style] = dateOptions(options, "date");
|
|
318
|
-
const format = style && { dateStyle: style };
|
|
317
|
+
const [explicit, style, timeZone] = dateOptions(options, "date");
|
|
318
|
+
const format = (style || timeZone) && { dateStyle: style, timeZone };
|
|
319
319
|
return (value) => {
|
|
320
320
|
if (!(value instanceof Date)) {
|
|
321
321
|
valueMustBeDate("date", value);
|
|
@@ -324,8 +324,8 @@ var date = (options) => {
|
|
|
324
324
|
};
|
|
325
325
|
};
|
|
326
326
|
var time = (options) => {
|
|
327
|
-
const [explicit, style] = dateOptions(options, "time");
|
|
328
|
-
const format = style && { timeStyle: style };
|
|
327
|
+
const [explicit, style, timeZone] = dateOptions(options, "time");
|
|
328
|
+
const format = (style || timeZone) && { timeStyle: style, timeZone };
|
|
329
329
|
return (value) => {
|
|
330
330
|
if (!(value instanceof Date)) {
|
|
331
331
|
valueMustBeDate("time", value);
|
|
@@ -334,8 +334,8 @@ var time = (options) => {
|
|
|
334
334
|
};
|
|
335
335
|
};
|
|
336
336
|
var datetime = (options) => {
|
|
337
|
-
const [explicit, style] = dateOptions(options, "datetime");
|
|
338
|
-
const format = style && { dateStyle: style, timeStyle: style };
|
|
337
|
+
const [explicit, style, timeZone] = dateOptions(options, "datetime");
|
|
338
|
+
const format = (style || timeZone) && { dateStyle: style, timeStyle: style, timeZone };
|
|
339
339
|
return (value) => {
|
|
340
340
|
if (!(value instanceof Date)) {
|
|
341
341
|
valueMustBeDate("datetime", value);
|
|
@@ -343,16 +343,14 @@ var datetime = (options) => {
|
|
|
343
343
|
return value.toLocaleString(explicit ?? defaultLocale(), format);
|
|
344
344
|
};
|
|
345
345
|
};
|
|
346
|
+
var two = (n) => String(n).padStart(2, "0");
|
|
346
347
|
var ymd = (options) => {
|
|
347
348
|
const opt = options?.[0] ?? "-";
|
|
348
349
|
return (value) => {
|
|
349
350
|
if (!(value instanceof Date)) {
|
|
350
351
|
valueMustBeDate("ymd", value);
|
|
351
352
|
}
|
|
352
|
-
|
|
353
|
-
const month = (value.getMonth() + 1).toString().padStart(2, "0");
|
|
354
|
-
const day = value.getDate().toString().padStart(2, "0");
|
|
355
|
-
return `${year}${opt}${month}${opt}${day}`;
|
|
353
|
+
return `${value.getFullYear()}${opt}${two(value.getMonth() + 1)}${opt}${two(value.getDate())}`;
|
|
356
354
|
};
|
|
357
355
|
};
|
|
358
356
|
var hms = (options) => {
|
|
@@ -361,10 +359,7 @@ var hms = (options) => {
|
|
|
361
359
|
if (!(value instanceof Date)) {
|
|
362
360
|
valueMustBeDate("hms", value);
|
|
363
361
|
}
|
|
364
|
-
|
|
365
|
-
const minutes = value.getMinutes().toString().padStart(2, "0");
|
|
366
|
-
const seconds = value.getSeconds().toString().padStart(2, "0");
|
|
367
|
-
return `${hours}${opt}${minutes}${opt}${seconds}`;
|
|
362
|
+
return `${two(value.getHours())}${opt}${two(value.getMinutes())}${opt}${two(value.getSeconds())}`;
|
|
368
363
|
};
|
|
369
364
|
};
|
|
370
365
|
var abs = () => (value) => {
|
|
@@ -425,10 +420,11 @@ var registered = {
|
|
|
425
420
|
ceil: { factory: ceil, arity: [0, 1] },
|
|
426
421
|
percent: { factory: percent, arity: [0, 1] },
|
|
427
422
|
unit: { factory: nullishPassthrough(unit), arity: [1, 1] },
|
|
428
|
-
// The locale-dependent three take a locale like `locale` does (`date(ja-JP)`),
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
423
|
+
// The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), a style (`date(ja-JP,long)`)
|
|
424
|
+
// and, since 4.10, a time zone (`date(ja-JP,long,Asia/Tokyo)`)
|
|
425
|
+
date: { factory: nullishPassthrough(date), arity: [0, 3] },
|
|
426
|
+
time: { factory: nullishPassthrough(time), arity: [0, 3] },
|
|
427
|
+
datetime: { factory: nullishPassthrough(datetime), arity: [0, 3] },
|
|
432
428
|
ymd: { factory: nullishPassthrough(ymd), arity: [0, 1] },
|
|
433
429
|
hms: { factory: nullishPassthrough(hms), arity: [0, 1] },
|
|
434
430
|
// the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
|
|
@@ -537,9 +533,11 @@ var builtinFilterMeta = {
|
|
|
537
533
|
// `locale` と同じくロケールを 1 つ受ける(`date(ja-JP)`)。実装は最初からこれを読んでいたが、
|
|
538
534
|
// メタデータ側が maxArgs: 0 だったため lint と補完が正しい書き方を誤りとして報告していた。
|
|
539
535
|
// 4.2: 2 つ目は書式(full / long / medium / short — Intl の dateStyle / timeStyle)。書式だけなら既定のロケール
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
536
|
+
// 4.10: 3 つ目は IANA のタイムゾーン(Intl の timeZone)。無ければ実行環境のゾーン(読み手の、SSR ではサーバーの)。
|
|
537
|
+
// 空の引数は既定のまま(`date(,,Asia/Tokyo)`)
|
|
538
|
+
date: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u65E5\u4ED8 ([locale][, style][, zone]\u3002style \u306F full / long / medium / short\u3001zone \u306F IANA \u306E\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\uFF08Asia/Tokyo \u2014 \u7121\u3051\u308C\u3070\u8AAD\u307F\u624B\u306E\u30BE\u30FC\u30F3\uFF09\u3001\u7A7A\u306E\u5F15\u6570\u306F\u65E2\u5B9A\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 3, argTypes: ["string", "string", "string"] },
|
|
539
|
+
time: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u6642\u523B ([locale][, style][, zone]\u3002style \u306F full / long / medium / short\u3001zone \u306F IANA \u306E\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\uFF08Asia/Tokyo \u2014 \u7121\u3051\u308C\u3070\u8AAD\u307F\u624B\u306E\u30BE\u30FC\u30F3\uFF09\u3001\u7A7A\u306E\u5F15\u6570\u306F\u65E2\u5B9A\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 3, argTypes: ["string", "string", "string"] },
|
|
540
|
+
datetime: { description: "\u30ED\u30B1\u30FC\u30EB\u5F62\u5F0F\u306E\u65E5\u6642 ([locale][, style][, zone]\u3002style \u306F full / long / medium / short\u3001zone \u306F IANA \u306E\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\uFF08Asia/Tokyo \u2014 \u7121\u3051\u308C\u3070\u8AAD\u307F\u624B\u306E\u30BE\u30FC\u30F3\uFF09\u3001\u7A7A\u306E\u5F15\u6570\u306F\u65E2\u5B9A\u3001\u65E2\u5B9A\u306E\u30ED\u30B1\u30FC\u30EB\u306F config.locale)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 3, argTypes: ["string", "string", "string"] },
|
|
543
541
|
ymd: { description: "YYYY-MM-DD \u5F62\u5F0F ([separator]\u3002\u65E2\u5B9A\u306F -)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
|
|
544
542
|
hms: { description: "HH:MM:SS \u5F62\u5F0F ([separator]\u3002\u65E2\u5B9A\u306F :)", hasArgs: true, resultType: "string", acceptTypes: "any", minArgs: 0, maxArgs: 1, argTypes: ["string"] },
|
|
545
543
|
// 真偽値・変換
|
package/dist/parser.esm.js
CHANGED
|
@@ -364,8 +364,11 @@ var SENTENCES = {
|
|
|
364
364
|
[27 /* FilterOptionNotNumber */]: (fn) => `filter ${fn} requires a number as option`,
|
|
365
365
|
[28 /* FilterValueNotNumber */]: (fn, v) => `filter ${fn} requires a number value, not ${was(v)}${typeof v === "string" ? ` \u2014 put |number before |${fn}, or convert it where it is read` : ""}`,
|
|
366
366
|
[29 /* FilterValueNotDate */]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === "string" || typeof v === "number" ? " \u2014 make the Date where it is read: a getter returning new Date(\u2026)" : ""}${typeof v === "string" && /^\d{4}-\d\d-\d\d$/.test(v) ? `. A date-only string is a day, not a moment: new Date(${JSON.stringify(v)}) is midnight UTC, the day before west of Greenwich \u2014 new Date(y, m - 1, d) is that day where the page is` : ""}`,
|
|
367
|
-
|
|
367
|
+
// (a time zone in the style's place — `date(ja-JP,Asia/Tokyo)`, `date(ja-JP,UTC)`, the shapes a lone
|
|
368
|
+
// zone is read by in filters/formats.ts — is told where it goes)
|
|
369
|
+
[52 /* FilterStyleInvalid */]: (fn, v) => `filter ${fn} takes a style of full, long, medium or short, not "${v}"${/\/|^UTC$/.test(v) ? ` \u2014 a time zone is the third argument, after the locale and the style, and an empty argument keeps its default: ${fn}(,,${v}), ${fn}(en-US,long,${v})` : ""}`,
|
|
368
370
|
[53 /* FilterCurrencyInvalid */]: (v) => `filter currency takes an ISO 4217 currency code (JPY, USD, EUR), not "${v}"`,
|
|
371
|
+
[54 /* FilterTimeZoneInvalid */]: (fn, v) => `filter ${fn} takes an IANA time zone (Asia/Tokyo, America/New_York, UTC), not "${v}"`,
|
|
369
372
|
[30 /* FilterValueNotArray */]: (fn) => `filter ${fn} requires an array value`,
|
|
370
373
|
[31 /* DirectionalSyncDisabled */]: () => "init=/sync= modifiers require enableDirectionalInitialSync.",
|
|
371
374
|
[33 /* ModifierUnknown */]: (key, modifier) => `Unknown binding modifier "${key}" in "${modifier}".`,
|
package/dist/split/auto.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as t}from"./chunks/chunk-
|
|
1
|
+
import{d as t}from"./chunks/chunk-FT7OW7CG.js";import"./chunks/chunk-65B2K2XD.js";import"./chunks/chunk-IWY3I2DG.js";import"./chunks/chunk-FFXJVUTT.js";import"./chunks/chunk-GU7IAIWW.js";import{a as n}from"./chunks/chunk-JCQTA35B.js";import"./chunks/chunk-MZVF2WEY.js";import"./chunks/chunk-PTFWXISY.js";import"./chunks/chunk-UE6JK2ZA.js";import{a as s,g as o}from"./chunks/chunk-SJRJALR4.js";var e,r=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools","native-commands"],a=(e=import.meta.url,t=>Promise.all(t.map(async t=>{if(!r.includes(t))throw new Error(`[@wcstack/state] [wcs/feature-unknown] "${t}" is not an add-on (${r.join(", ")}).`);return(await(import(new URL(`./features/${t}.js`,e).href))).default})));s.St=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var c=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(c?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
|
|
2
2
|
//# sourceMappingURL=auto.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{p as n,r as t}from"./chunk-IWY3I2DG.js";import{a as l,b as e,c as r}from"./chunk-MZVF2WEY.js";import{a as o}from"./chunk-SJRJALR4.js";var i=Symbol.for("wcstack.binder"),u=Symbol.for("wcstack.binder.pending"),s=Symbol.for("wcstack.binder.taken");var a=new Map;function f(l,e){if(1!==l.nodeType||!l.isConnected)return;let r=n.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?a.set(l,e):t(r,l,e?.range)}function c(){let n=[...a];a.clear();for(let[t,l]of n)f(t,l);!function(){let n=function(){let n=globalThis[i];return null==n||"wcs-binder"!==n.protocol||"number"!=typeof n.version||n.version<1||"function"!=typeof n.bind?null:n}();if(null===n)return;let t=function(){let n=globalThis,t=n[u];return void 0===t&&(t=[],n[u]=t),t}();if(0===t.length)return;let l=t.splice(0,t.length),e=function(){let n=globalThis,t=n[s];return void 0===t&&(t=new WeakSet,n[s]=t),t}();for(let t of l)e.add(t),n.bind(t)}()}function d(){let n=globalThis;void 0===n[i]&&(n[i]={protocol:"wcs-binder",version:1,bind:f})}var b=class{constructor(){this.name="dirty",this.Z=(n,t)=>{if(0===n.n){let t=n.Y;return t!==l&&t!==e&&(n.Y=e,!0)}let r=null===t?null:t.vt;if(null===r)return!1;let o=r[n.F];return o!==l&&o!==e&&(r[n.F]=e,!0)}}er(n,t,l){null!==t.getter&&this.Z(t,l),n.xt(t,l),n.Rn(t,l,this.Z)}qo(n,t){let l=t.l.o.Lt;if(null!==l)for(let e of l)e.n===t.l.n?n.at(e,t,this.Z):n.en(t,e,t=>n.at(e,t,this.Z))}ke(n,t,l){this.Z(t,l),o.Se?.(n,t,l),n.xt(t,l),n.Rn(t,l,this.Z)}zo(n,t,o){let i=0===t.n;if(!i&&null===o)return;let u=i?null:o.vt??=new Array(n.Le).fill(l),s=null===u?t.Y:u[t.F];if(s!==l&&s!==e&&s!==r&&(null===u||t.F in u))return s;s=r;try{return s=n.Yo(t,null===u?null:o)}finally{null===u?t.Y=s:u[t.F]=s}}Gt(n){n.vt=null}nt(n){for(let t of n.O.all())null!==t.getter&&(0===t.n?t.Y===e&&(t.Y=r):n.nn(t.h[t.n],n=>{let l=n.vt;null!==l&&l[t.F]===e&&(l[t.F]=r)}))}};export{f as a,c as b,d as c,b as d};
|
|
2
|
+
//# sourceMappingURL=chunk-65B2K2XD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BINDER_KEY","Symbol","for","PENDING_KEY","TAKEN_KEY","early","Map","bind","subtree","options","nodeType","isConnected","engine","engines","get","getRootNode","element","set","mountSubtree","range","drainBinds","waiting","clear","binder","candidate","globalThis","protocol","version","getBinder","queue","globals","pendingQueue","length","pending","splice","taken","WeakSet","takenSet","add","flushPendingBinds","installBinder","slot","DirtyStrategy","constructor","this","name","mark","g","row","depth","v","rootValue","UNSET","DIRTY","c","cache","onWrite","p","getter","enqueueBound","walkDependents","onIndexChange","watchers","list","pattern","indexWatchers","visitGetter","forRowsUnder","r","invalidate","hooks","getterReached","readGetter","root","Array","slotCount","fill","FAILED","evalGetter","resetRow","dropped","patterns","all","forAllRows","lists","E","W","h"],"sources":["../../../src/protocol/binder.ts","../../../src/dom/binder.ts","../../../src/strategy/dirty.ts"],"sourcesContent":["// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/binder.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// binder protocol — how a package that inserts DOM hands those nodes to whoever\n// owns data bindings on the page.\n//\n// The dual of transition-runner: that one hands a *mutation* to whoever animates\n// it, this one hands *new nodes* to whoever binds them.\n//\n// A `data-wcs` binding exists only for nodes @wcstack/state walked when it built\n// its bindings. Nodes that arrive later — the content of a route that was not\n// active at that moment, a <wcs-head> child reflected into <head> — were never\n// walked, so their bindings silently do nothing, however often they are inserted.\n// @wcstack/router must not depend on @wcstack/state (zero runtime dependencies,\n// independently publishable), so state installs a binder on a well-known global\n// symbol and inserters look it up lazily.\n//\n// No binder installed means nothing happens — byte-for-byte the behavior these\n// packages had before the protocol existed.\n//\n// docs/binder-protocol-design.md is the normative description.\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/binder.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/binder.ts). Those copies are generated — do not edit them.\n\n/**\n * Global key the binder installs itself under. `Symbol.for` so independently\n * loaded copies of this file (two CDN bundles on one page) still agree.\n */\nexport const BINDER_KEY = Symbol.for(\"wcstack.binder\");\n\n/**\n * What the caller declares about a subtree it hands over (the second argument of `bind`; additive\n * since version 1 — a binder that predates it ignores it, and leaving it out keeps the old contract).\n */\nexport interface IWcsBindOptions {\n /**\n * The caller carries the range the subtree sits in: on removal it takes everything from its own\n * start mark up to its end mark along — what the binder rendered beside the subtree included, as\n * the rows a structural template handed over at the top of the content renders before its anchor —\n * and puts it all back on reinsertion. Only with this may a binder render such a template: without\n * it, what the binder rendered beside the subtree would be left behind, so @wcstack/state 4.0\n * refuses one (#204). @wcstack/state 3.x ignores the option and renders no structural template\n * handed over itself, with or without it (docs/binder-protocol-design.md §2, §9-5, §9-6).\n */\n readonly range?: boolean;\n}\n\nexport interface IWcsBinder {\n readonly protocol: \"wcs-binder\";\n /** Integer protocol version. All versions >= 1 are participant-compatible. */\n readonly version: number;\n /**\n * Take a subtree that has just entered the document and bind whatever\n * declarations it carries.\n *\n * Contract (docs/binder-protocol-design.md §2):\n * - Synchronous. Initial values are applied before this returns, so the\n * caller never shows one frame of unbound markup.\n * - Idempotent. A subtree that is already bound is left alone, so a caller\n * may hand over the same nodes on every insertion without tracking which\n * ones are new.\n * - Binding survives later relocation, so this need not be called again when\n * the same nodes are moved (measured: design doc §8-3).\n * - Never throws for markup reasons; a subtree with no declarations is a\n * no-op.\n * - `options` (optional) is what the caller declares about the subtree\n * ({@link IWcsBindOptions}).\n */\n bind(subtree: Node, options?: IWcsBindOptions): void;\n}\n\n/**\n * The installed binder, or null when there is none or it speaks a version this\n * reader does not.\n *\n * Looked up on every call rather than cached, for the same reason\n * transition-runner does: the page's composition can change at any point, and a\n * stale cache would keep calling into a binder that is no longer there.\n */\nexport function getBinder(): IWcsBinder | null {\n const candidate = (globalThis as Record<symbol, unknown>)[BINDER_KEY] as IWcsBinder | undefined;\n if (candidate === undefined || candidate === null) return null;\n if (candidate.protocol !== \"wcs-binder\") return null;\n if (typeof candidate.version !== \"number\" || candidate.version < 1) return null;\n if (typeof candidate.bind !== \"function\") return null;\n return candidate;\n}\n\n/**\n * Subtrees offered before a binder existed, and the set of everything a binder\n * has taken. Both live on global symbols so that independently loaded copies of\n * this file — the router's and state's — share one queue.\n *\n * The queue is needed because of load order: the router's auto bundle runs\n * before state's, so `<wcs-head>` reflects its children into `<head>` while\n * there is still nothing to bind them. Offering them to a binder that arrives\n * later is the difference between working and silently blank.\n */\nconst PENDING_KEY = Symbol.for(\"wcstack.binder.pending\");\nconst TAKEN_KEY = Symbol.for(\"wcstack.binder.taken\");\n\nfunction pendingQueue(): Node[] {\n const globals = globalThis as Record<symbol, unknown>;\n let queue = globals[PENDING_KEY] as Node[] | undefined;\n if (queue === undefined) {\n queue = [];\n globals[PENDING_KEY] = queue;\n }\n return queue;\n}\n\nfunction takenSet(): WeakSet<Node> {\n const globals = globalThis as Record<symbol, unknown>;\n let taken = globals[TAKEN_KEY] as WeakSet<Node> | undefined;\n if (taken === undefined) {\n taken = new WeakSet<Node>();\n globals[TAKEN_KEY] = taken;\n }\n return taken;\n}\n\n/**\n * Hand `subtree` to the installed binder, or hold it for one that arrives later.\n *\n * Returns whether a binder took it *now*. A `false` does not yet mean the markup\n * is doomed — check {@link wasBoundBy} once module scripts have run.\n *\n * `options` goes to the binder with the subtree. A subtree held for a later binder\n * is handed over without it: that binder's first walk of the page binds what is\n * still in place there.\n */\nexport function bindSubtree(subtree: Node, options?: IWcsBindOptions): boolean {\n const binder = getBinder();\n if (binder === null) {\n pendingQueue().push(subtree);\n return false;\n }\n takenSet().add(subtree);\n binder.bind(subtree, options);\n return true;\n}\n\n/** Whether any binder has taken this subtree. */\nexport function wasBoundBy(subtree: Node): boolean {\n return takenSet().has(subtree);\n}\n\n/**\n * Bind everything offered before this binder existed. Called by the binder right\n * after it installs itself.\n */\nexport function flushPendingBinds(): void {\n const binder = getBinder();\n if (binder === null) return;\n const queue = pendingQueue();\n if (queue.length === 0) return;\n const pending = queue.splice(0, queue.length);\n const taken = takenSet();\n for (const subtree of pending) {\n taken.add(subtree);\n binder.bind(subtree);\n }\n}\n","import { BINDER_KEY, flushPendingBinds, type IWcsBinder, type IWcsBindOptions } from \"../protocol/binder\";\nimport { engines, mountSubtree } from \"./mount\";\n\n/**\n * The binder protocol's provider (docs/binder-protocol-design.md): a package that inserts\n * DOM after the mount — the router's route content, `<wcs-head>`'s clones in <head> —\n * hands the subtree over, and it is bound to the engine of its root, synchronously.\n * Only what is handed over is bound (no scan of every insertion), and binding twice is a\n * no-op, so the router may hand the same nodes over on every insertion.\n */\n\n/**\n * Subtrees handed over before their root's engine finished its first mount, or while it was out of the\n * page, with what the caller declared (a range: a route's top-level template is rendered then).\n */\nconst early = new Map<Element, IWcsBindOptions | undefined>();\n\nexport function bind(subtree: Node, options?: IWcsBindOptions): void {\n // not in a document (it left, or was replaced, as a chain's `else:` template by its anchor): nothing to bind\n if (subtree.nodeType !== 1 || !subtree.isConnected) return;\n // (a root taken out of the page lets go of its root node: it binds what waited here when it is back.\n // A component's, whose <wcs-state> alone left, is still registered: not one to bind to either)\n const engine = engines.get(subtree.getRootNode());\n // (once each: the router hands the same nodes over on every insertion. One handed over early is\n // walked by the first mount where it is: the declaration is not needed then)\n if (engine === undefined || (engine.element as Node | null)?.isConnected === false) early.set(subtree as Element, options);\n else mountSubtree(engine, subtree as Element, options?.range);\n}\n\n/**\n * After an engine's first mount, and when a root is back in the page: binds what was handed over\n * too early — to this binder before the mount or while the root was out, or (queued by the\n * protocol) before any binder existed.\n */\nexport function drainBinds(): void {\n // (one that left the document meanwhile is dropped: handed over again if it comes back)\n const waiting = [...early];\n early.clear();\n for (const [subtree, options] of waiting) bind(subtree, options);\n flushPendingBinds();\n}\n\n/** Installs the binder on the protocol's global slot, unless another copy already has it. */\nexport function installBinder(): void {\n const slot = globalThis as Record<symbol, unknown>;\n if (slot[BINDER_KEY] === undefined) slot[BINDER_KEY] = { protocol: \"wcs-binder\", version: 1, bind } satisfies IWcsBinder;\n}\n","import type { Engine } from \"../engine\";\nimport { DIRTY, FAILED, UNSET, type Pattern } from \"../pattern\";\nimport type { StateRow } from \"../list\";\nimport type { Strategy } from \"./types\";\nimport { hooks } from \"../hooks\";\n\n/**\n * Push invalidation: a write walks its dependents immediately, marks their caches\n * DIRTY and queues their bindings. A cache already DIRTY (or never computed) stops the\n * walk — whatever depends on it was reached when it was marked.\n */\nexport class DirtyStrategy implements Strategy {\n readonly name = \"dirty\";\n\n private readonly mark = (g: Pattern, row: StateRow | null): boolean => {\n // UNSET: nobody read it; DIRTY: already reached. FAILED was read (and threw): reach it.\n if (g.depth === 0) {\n const v = g.rootValue;\n if (v === UNSET || v === DIRTY) return false;\n g.rootValue = DIRTY;\n return true;\n }\n const c = row === null ? null : row.cache;\n if (c === null) return false;\n const v = c[g.slot];\n if (v === UNSET || v === DIRTY) return false;\n c[g.slot] = DIRTY;\n return true;\n };\n\n onWrite(engine: Engine, p: Pattern, row: StateRow | null): void {\n // a write through a getter's setter: the written occurrence itself is stale\n if (p.getter !== null) this.mark(p, row);\n engine.enqueueBound(p, row);\n engine.walkDependents(p, row, this.mark);\n }\n\n onIndexChange(engine: Engine, row: StateRow): void {\n const watchers = row.list.pattern.indexWatchers;\n if (watchers === null) return;\n for (const g of watchers) {\n // the row itself (a row getter reading its own index): no closure per moved row\n if (g.depth === row.list.depth) engine.visitGetter(g, row, this.mark);\n else engine.forRowsUnder(row, g, (r) => engine.visitGetter(g, r, this.mark));\n }\n }\n\n invalidate(engine: Engine, g: Pattern, row: StateRow | null): void {\n this.mark(g, row);\n hooks.getterReached?.(engine, g, row);\n engine.enqueueBound(g, row);\n engine.walkDependents(g, row, this.mark);\n }\n\n readGetter(engine: Engine, g: Pattern, row: StateRow | null): unknown {\n const root = g.depth === 0;\n if (!root && row === null) return undefined;\n const c = root ? null : (row!.cache ??= new Array(engine.slotCount).fill(UNSET));\n let v = c === null ? g.rootValue : c[g.slot];\n // a getter made after the row's cache (a recursive family, a mounted key, a binder's subtree) has\n // no entry yet — nor one whose slot lies before a later getter's written past the end (a hole)\n if (v !== UNSET && v !== DIRTY && v !== FAILED && (c === null || g.slot in c)) return v;\n v = FAILED;\n try {\n return (v = engine.evalGetter(g, c === null ? null : row));\n } finally {\n if (c === null) g.rootValue = v;\n else c[g.slot] = v;\n }\n }\n\n resetRow(row: StateRow): void {\n row.cache = null;\n }\n\n dropped(engine: Engine): void {\n // DIRTY says \"its readers were reached\", and they were dropped: FAILED is reached again\n for (const g of engine.patterns.all()) {\n if (g.getter === null) continue;\n if (g.depth === 0) {\n if (g.rootValue === DIRTY) g.rootValue = FAILED;\n } else {\n engine.forAllRows(g.lists[g.depth]!, (r) => {\n const c = r.cache;\n if (c !== null && c[g.slot] === DIRTY) c[g.slot] = FAILED;\n });\n }\n }\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BINDER_KEY","Symbol","for","PENDING_KEY","TAKEN_KEY","early","Map","bind","subtree","options","nodeType","isConnected","engine","engines","get","getRootNode","element","set","mountSubtree","range","drainBinds","waiting","clear","binder","candidate","globalThis","protocol","version","getBinder","queue","globals","pendingQueue","length","pending","splice","taken","WeakSet","takenSet","add","flushPendingBinds","installBinder","slot","DirtyStrategy","constructor","this","name","mark","g","row","depth","v","rootValue","UNSET","DIRTY","c","cache","onWrite","p","getter","enqueueBound","walkDependents","onIndexChange","watchers","list","pattern","indexWatchers","visitGetter","forRowsUnder","r","invalidate","hooks","getterReached","readGetter","root","Array","slotCount","fill","FAILED","evalGetter","resetRow","dropped","patterns","all","forAllRows","lists","E","W","h"],"sources":["../../../src/protocol/binder.ts","../../../src/dom/binder.ts","../../../src/strategy/dirty.ts"],"sourcesContent":["// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/binder.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// binder protocol — how a package that inserts DOM hands those nodes to whoever\n// owns data bindings on the page.\n//\n// The dual of transition-runner: that one hands a *mutation* to whoever animates\n// it, this one hands *new nodes* to whoever binds them.\n//\n// A `data-wcs` binding exists only for nodes @wcstack/state walked when it built\n// its bindings. Nodes that arrive later — the content of a route that was not\n// active at that moment, a <wcs-head> child reflected into <head> — were never\n// walked, so their bindings silently do nothing, however often they are inserted.\n// @wcstack/router must not depend on @wcstack/state (zero runtime dependencies,\n// independently publishable), so state installs a binder on a well-known global\n// symbol and inserters look it up lazily.\n//\n// No binder installed means nothing happens — byte-for-byte the behavior these\n// packages had before the protocol existed.\n//\n// docs/binder-protocol-design.md is the normative description.\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/binder.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/binder.ts). Those copies are generated — do not edit them.\n\n/**\n * Global key the binder installs itself under. `Symbol.for` so independently\n * loaded copies of this file (two CDN bundles on one page) still agree.\n */\nexport const BINDER_KEY = Symbol.for(\"wcstack.binder\");\n\n/**\n * What the caller declares about a subtree it hands over (the second argument of `bind`; additive\n * since version 1 — a binder that predates it ignores it, and leaving it out keeps the old contract).\n */\nexport interface IWcsBindOptions {\n /**\n * The caller carries the range the subtree sits in: on removal it takes everything from its own\n * start mark up to its end mark along — what the binder rendered beside the subtree included, as\n * the rows a structural template handed over at the top of the content renders before its anchor —\n * and puts it all back on reinsertion. Only with this may a binder render such a template: without\n * it, what the binder rendered beside the subtree would be left behind, so @wcstack/state 4.0\n * refuses one (#204). @wcstack/state 3.x ignores the option and renders no structural template\n * handed over itself, with or without it (docs/binder-protocol-design.md §2, §9-5, §9-6).\n */\n readonly range?: boolean;\n}\n\nexport interface IWcsBinder {\n readonly protocol: \"wcs-binder\";\n /** Integer protocol version. All versions >= 1 are participant-compatible. */\n readonly version: number;\n /**\n * Take a subtree that has just entered the document and bind whatever\n * declarations it carries.\n *\n * Contract (docs/binder-protocol-design.md §2):\n * - Synchronous. Initial values are applied before this returns, so the\n * caller never shows one frame of unbound markup.\n * - Idempotent. A subtree that is already bound is left alone, so a caller\n * may hand over the same nodes on every insertion without tracking which\n * ones are new.\n * - Binding survives later relocation, so this need not be called again when\n * the same nodes are moved (measured: design doc §8-3).\n * - Never throws for markup reasons; a subtree with no declarations is a\n * no-op.\n * - `options` (optional) is what the caller declares about the subtree\n * ({@link IWcsBindOptions}).\n */\n bind(subtree: Node, options?: IWcsBindOptions): void;\n}\n\n/**\n * The installed binder, or null when there is none or it speaks a version this\n * reader does not.\n *\n * Looked up on every call rather than cached, for the same reason\n * transition-runner does: the page's composition can change at any point, and a\n * stale cache would keep calling into a binder that is no longer there.\n */\nexport function getBinder(): IWcsBinder | null {\n const candidate = (globalThis as Record<symbol, unknown>)[BINDER_KEY] as IWcsBinder | undefined;\n if (candidate === undefined || candidate === null) return null;\n if (candidate.protocol !== \"wcs-binder\") return null;\n if (typeof candidate.version !== \"number\" || candidate.version < 1) return null;\n if (typeof candidate.bind !== \"function\") return null;\n return candidate;\n}\n\n/**\n * Subtrees offered before a binder existed, and the set of everything a binder\n * has taken. Both live on global symbols so that independently loaded copies of\n * this file — the router's and state's — share one queue.\n *\n * The queue is needed because of load order: the router's auto bundle runs\n * before state's, so `<wcs-head>` reflects its children into `<head>` while\n * there is still nothing to bind them. Offering them to a binder that arrives\n * later is the difference between working and silently blank.\n */\nconst PENDING_KEY = Symbol.for(\"wcstack.binder.pending\");\nconst TAKEN_KEY = Symbol.for(\"wcstack.binder.taken\");\n\nfunction pendingQueue(): Node[] {\n const globals = globalThis as Record<symbol, unknown>;\n let queue = globals[PENDING_KEY] as Node[] | undefined;\n if (queue === undefined) {\n queue = [];\n globals[PENDING_KEY] = queue;\n }\n return queue;\n}\n\nfunction takenSet(): WeakSet<Node> {\n const globals = globalThis as Record<symbol, unknown>;\n let taken = globals[TAKEN_KEY] as WeakSet<Node> | undefined;\n if (taken === undefined) {\n taken = new WeakSet<Node>();\n globals[TAKEN_KEY] = taken;\n }\n return taken;\n}\n\n/**\n * Hand `subtree` to the installed binder, or hold it for one that arrives later.\n *\n * Returns whether a binder took it *now*. A `false` does not yet mean the markup\n * is doomed — check {@link wasBoundBy} once module scripts have run.\n *\n * `options` goes to the binder with the subtree. A subtree held for a later binder\n * is handed over without it: that binder's first walk of the page binds what is\n * still in place there.\n */\nexport function bindSubtree(subtree: Node, options?: IWcsBindOptions): boolean {\n const binder = getBinder();\n if (binder === null) {\n pendingQueue().push(subtree);\n return false;\n }\n takenSet().add(subtree);\n binder.bind(subtree, options);\n return true;\n}\n\n/** Whether any binder has taken this subtree. */\nexport function wasBoundBy(subtree: Node): boolean {\n return takenSet().has(subtree);\n}\n\n/**\n * Bind everything offered before this binder existed. Called by the binder right\n * after it installs itself.\n */\nexport function flushPendingBinds(): void {\n const binder = getBinder();\n if (binder === null) return;\n const queue = pendingQueue();\n if (queue.length === 0) return;\n const pending = queue.splice(0, queue.length);\n const taken = takenSet();\n for (const subtree of pending) {\n taken.add(subtree);\n binder.bind(subtree);\n }\n}\n","import { BINDER_KEY, flushPendingBinds, type IWcsBinder, type IWcsBindOptions } from \"../protocol/binder\";\nimport { engines, mountSubtree } from \"./mount\";\n\n/**\n * The binder protocol's provider (docs/binder-protocol-design.md): a package that inserts\n * DOM after the mount — the router's route content, `<wcs-head>`'s clones in <head> —\n * hands the subtree over, and it is bound to the engine of its root, synchronously.\n * Only what is handed over is bound (no scan of every insertion), and binding twice is a\n * no-op, so the router may hand the same nodes over on every insertion.\n */\n\n/**\n * Subtrees handed over before their root's engine finished its first mount, or while it was out of the\n * page, with what the caller declared (a range: a route's top-level template is rendered then).\n */\nconst early = new Map<Element, IWcsBindOptions | undefined>();\n\nexport function bind(subtree: Node, options?: IWcsBindOptions): void {\n // not in a document (it left, or was replaced, as a chain's `else:` template by its anchor): nothing to bind\n if (subtree.nodeType !== 1 || !subtree.isConnected) return;\n // (a root taken out of the page lets go of its root node: it binds what waited here when it is back.\n // A component's, whose <wcs-state> alone left, is still registered: not one to bind to either)\n const engine = engines.get(subtree.getRootNode());\n // (once each: the router hands the same nodes over on every insertion. One handed over early is\n // walked by the first mount where it is: the declaration is not needed then)\n if (engine === undefined || (engine.element as Node | null)?.isConnected === false) early.set(subtree as Element, options);\n else mountSubtree(engine, subtree as Element, options?.range);\n}\n\n/**\n * After an engine's first mount, and when a root is back in the page: binds what was handed over\n * too early — to this binder before the mount or while the root was out, or (queued by the\n * protocol) before any binder existed.\n */\nexport function drainBinds(): void {\n // (one that left the document meanwhile is dropped: handed over again if it comes back)\n const waiting = [...early];\n early.clear();\n for (const [subtree, options] of waiting) bind(subtree, options);\n flushPendingBinds();\n}\n\n/** Installs the binder on the protocol's global slot, unless another copy already has it. */\nexport function installBinder(): void {\n const slot = globalThis as Record<symbol, unknown>;\n if (slot[BINDER_KEY] === undefined) slot[BINDER_KEY] = { protocol: \"wcs-binder\", version: 1, bind } satisfies IWcsBinder;\n}\n","import type { Engine } from \"../engine\";\nimport { DIRTY, FAILED, UNSET, type Pattern } from \"../pattern\";\nimport type { StateRow } from \"../list\";\nimport type { Strategy } from \"./types\";\nimport { hooks } from \"../hooks\";\n\n/**\n * Push invalidation: a write walks its dependents immediately, marks their caches\n * DIRTY and queues their bindings. A cache already DIRTY (or never computed) stops the\n * walk — whatever depends on it was reached when it was marked.\n */\nexport class DirtyStrategy implements Strategy {\n readonly name = \"dirty\";\n\n private readonly mark = (g: Pattern, row: StateRow | null): boolean => {\n // UNSET: nobody read it; DIRTY: already reached. FAILED was read (and threw): reach it.\n if (g.depth === 0) {\n const v = g.rootValue;\n if (v === UNSET || v === DIRTY) return false;\n g.rootValue = DIRTY;\n return true;\n }\n const c = row === null ? null : row.cache;\n if (c === null) return false;\n const v = c[g.slot];\n if (v === UNSET || v === DIRTY) return false;\n c[g.slot] = DIRTY;\n return true;\n };\n\n onWrite(engine: Engine, p: Pattern, row: StateRow | null): void {\n // a write through a getter's setter: the written occurrence itself is stale\n if (p.getter !== null) this.mark(p, row);\n engine.enqueueBound(p, row);\n engine.walkDependents(p, row, this.mark);\n }\n\n onIndexChange(engine: Engine, row: StateRow): void {\n const watchers = row.list.pattern.indexWatchers;\n if (watchers === null) return;\n for (const g of watchers) {\n // the row itself (a row getter reading its own index): no closure per moved row\n if (g.depth === row.list.depth) engine.visitGetter(g, row, this.mark);\n else engine.forRowsUnder(row, g, (r) => engine.visitGetter(g, r, this.mark));\n }\n }\n\n invalidate(engine: Engine, g: Pattern, row: StateRow | null): void {\n this.mark(g, row);\n hooks.getterReached?.(engine, g, row);\n engine.enqueueBound(g, row);\n engine.walkDependents(g, row, this.mark);\n }\n\n readGetter(engine: Engine, g: Pattern, row: StateRow | null): unknown {\n const root = g.depth === 0;\n if (!root && row === null) return undefined;\n const c = root ? null : (row!.cache ??= new Array(engine.slotCount).fill(UNSET));\n let v = c === null ? g.rootValue : c[g.slot];\n // a getter made after the row's cache (a recursive family, a mounted key, a binder's subtree) has\n // no entry yet — nor one whose slot lies before a later getter's written past the end (a hole)\n if (v !== UNSET && v !== DIRTY && v !== FAILED && (c === null || g.slot in c)) return v;\n v = FAILED;\n try {\n return (v = engine.evalGetter(g, c === null ? null : row));\n } finally {\n if (c === null) g.rootValue = v;\n else c[g.slot] = v;\n }\n }\n\n resetRow(row: StateRow): void {\n row.cache = null;\n }\n\n dropped(engine: Engine): void {\n // DIRTY says \"its readers were reached\", and they were dropped: FAILED is reached again\n for (const g of engine.patterns.all()) {\n if (g.getter === null) continue;\n if (g.depth === 0) {\n if (g.rootValue === DIRTY) g.rootValue = FAILED;\n } else {\n engine.forAllRows(g.lists[g.depth]!, (r) => {\n const c = r.cache;\n if (c !== null && c[g.slot] === DIRTY) c[g.slot] = FAILED;\n });\n }\n }\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{e as t}from"./chunk-JCQTA35B.js";import{b as n}from"./chunk-UE6JK2ZA.js";function r(t){n(26,[t])}function e(t){n(27,[t])}function o(t,r){n(52,[t,r])}function a(t){n(53,[t])}function f(t,r){n(28,[t,r])}function u(t,r){n(29,[t,r])}function i(t){n(30,[t])}function y(t){return!(!t||isNaN(Number(t)))}function c(t,n){return y(t)||e(n),Number(t)}function s(t,n,e){return c(t?.[n]??r(e),e)}function l(t,n){return void 0!==n&&n.length>0?n[0]:t}var m=(t,n)=>({factory:r=>{let e=s(r,0,t);return r=>("number"!=typeof r&&f(t,r),n(r,e))},arity:[1,1]}),b={eq:{factory:(t,n)=>{let o=t?.[0]??r("eq"),a=l(o,n);return t=>"number"==typeof t?"string"!=typeof a?t===a:(y(o)||e("eq"),t===Number(o)):"string"==typeof t?t===o:t===a},arity:[1,1]},ne:{factory:(t,n)=>{let o=t?.[0]??r("ne"),a=l(o,n);return t=>"number"==typeof t?"string"!=typeof a?t!==a:(y(o)||e("ne"),t!==Number(o)):"string"==typeof t?t!==o:t!==a},arity:[1,1]},not:{factory:()=>t=>!t,arity:[0,0]},lt:m("lt",(t,n)=>t<n),le:m("le",(t,n)=>t<=n),gt:m("gt",(t,n)=>t>n),ge:m("ge",(t,n)=>t>=n),falsy:{factory:()=>t=>!t,arity:[0,0]},truthy:{factory:()=>t=>!!t,arity:[0,0]},boolean:{factory:()=>t=>!!t,arity:[0,0]}},g=!1;function p(){g||(g=!0,t(b))}export{r as a,o as b,a as c,f as d,u as e,i as f,c as g,s as h,l as i,m as j,b as k,p as l};
|
|
2
|
+
//# sourceMappingURL=chunk-FFXJVUTT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as t,c as e,d as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as t,c as e,d as s}from"./chunk-65B2K2XD.js";import{p as i,q as n}from"./chunk-IWY3I2DG.js";import{f as o}from"./chunk-GU7IAIWW.js";import{a,b as r}from"./chunk-JCQTA35B.js";import{a as l,b as c}from"./chunk-UE6JK2ZA.js";import{a as h,h as u,i as d,k as m}from"./chunk-SJRJALR4.js";var f=0,p=new WeakMap;function b(t,e=t.getRootNode()){p.set(e,[...p.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function g(t){let e=p.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?p.get(t)!==e?g(t):Promise.reject(i.errors[0]):void 0)}var w=typeof HTMLElement>"u"?class{}:HTMLElement,y=class extends w{constructor(){super(),this.engine=null,this.Wn=!1,this.Ge=!1,this.K=null,this.Je=null,this.loaded=!1,this.un=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.cn=t,this.Ro=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.an=t})}static{this.getBindingsReady=g}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Wn){if(null!==this.Je)return void this.Je.Qe();b(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.To("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Wn=!0;let e=this.getRootNode(),s=h.dt?.(this,e);if(s)return this.Je=s,!s.Ao&&this.parentNode instanceof ShadowRoot&&b(this),void(void 0===s.St?this.Fo():s.St()).then(t=>(this.loaded=!0,s.start(t,()=>this.Oo()))).then(()=>{this.an(),this.cn()},t=>this.Rt(t,s.Ao));this.start(e),b(this)}disconnectedCallback(){if(null!==this.Je)return void this.Je.Mn();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),b(this,e),this.To("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ge&&c(14),this.loaded)this.Je.reset(t);else if(null===this.engine)if(null!==this.un){let e=this.un;this.un=null,e(t)}else this.K=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.Be++;try{e(s.proxy)}finally{"readonly"===t&&s.Be--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Fo(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(globalThis[Symbol.for("wcstack.ssr.resolveModule")]?.(e)??e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++f}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.K?Promise.resolve(this.K):new Promise(t=>{this.un=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Fo(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.K=r,this.Wn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Je)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.Pn(),this.Oo(),await f.$e("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.cn()}catch(t){this.Ge=!this.V,this.Rt(t)}}Oo(){this.V=!0,this.an()}Rt(t,e){this.Ye(this.V?50:49,t),this.an(),e?this.cn():this.Ro(t)}Ye(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);m(e,`[@wcstack/state] ${l(t,[this.localName,...s])}`)}To(t,e,s){(async()=>this.engine.$e(t))().then(s,t=>this.Ye(e,t))}},k=[];function v(){return(k=k.filter(t=>t.deref())).map(t=>t.deref())}function R(t,s){t&&r(t),function(t=customElements){e(),v().includes(t)||k.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends y{}),h.Co?.(t)}(s)}var C=t=>g(t);export{g as a,w as b,v as c,R as d,C as e};
|
|
2
|
+
//# sourceMappingURL=chunk-FT7OW7CG.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as t,d as e,e as i}from"./chunk-MZVF2WEY.js";import{h as s,m as l}from"./chunk-PTFWXISY.js";import{a as n,b as h}from"./chunk-UE6JK2ZA.js";import{a as r,i as o,k as u}from"./chunk-SJRJALR4.js";var f=Symbol.for("wcstack.trustedTypes.policy");function a(){let t=globalThis[f];return null!==t&&"object"==typeof t?t:null}function d(t){globalThis[f]=t}function c(t){return"innerHTML"===t||"outerHTML"===t||"srcdoc"===t}function g(t){if(globalThis.trustedTypes?.isHTML(t))return t;let e=null==t?"":String(t),i=a(),s=i?.createHTML;return"function"==typeof s?s.call(i,e):e}var p=class{constructor(t,e,i){this.vt=null,this.N=null,this.we=null,this._=null,this.u=null,this.w=!0,this.l=t,this.y=e,this.E=i}},y=class{constructor(t,e){this.R=null,this.f=[],this.N=null,this.W=null,this.te=!1,this.Wt=!1,this.kt=!1,this.o=t,this.ce=e,this.n=t.n+1}},v=[],b=class{constructor(t){this.$t=new Set,this.name=t}get size(){return this.$t.size}subscribe(t){return this.$t.add(t),()=>{this.$t.delete(t)}}unsubscribe(t){return this.$t.delete(t)}emit(...t){let e=[];for(let i of this.$t)try{e.push(i(...t))}catch(t){e.push(void 0),u(t,`[@wcstack/state] ${n(17,[this.name])}`)}return e}};function m(t,e,i){if(void 0===t)return[];Array.isArray(t)||h(18,[e]);let s=new Set;for(let l of t)("string"!=typeof l||""===l)&&h(19,[e]),l===i&&h(20,[e,l,i]),s.has(l)&&h(21,[e,l]),s.add(l);return t}var w=Symbol.for("wcstack.transition-runner");function $(t){let e=globalThis[w];return null==e||"wcs-transition-runner"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.run||"function"!=typeof e.accepts||!e.accepts(t)?null:e}function k(t,e,i){let s=$(t);if(null!==s)return s.run(e,{source:t,types:i});e()}var A=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],M=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function O(t){return t.includes("**")&&l(t),t}var j=0,E=32,T=100;function R(t,e,i){let s=t.get(e);return void 0===s&&t.set(e,s=i()),s}var S=()=>new Set,x=()=>[],_=new WeakMap;function G(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function H(t,e){return t===e||t!=t&&e!=e}function W(t,e,i){let s=t._?.get(e);void 0!==s&&s.delete(i)&&0===s.size&&t._.delete(e)}function z(t,e){for(let i=0;i<e.length;i++){if(null==t)return;t=t[e[i]]}return t}function q(t,e){for(;null!==t&&t.l.n>e;)t=t.l.ce;return null!==t&&t.l.n===e?t:null}function N(t,e,i){let s=q(t,i);return null!==s&&s.l.o===e.h[i]?s:null}var B=class{constructor(t,i){this.Le=0,this.d=null,this.Be=0,this.nt=new Set,this.ot=new Map,this.qn=Symbol("wcs.block"),this.element=null,this.Et=[],this.We=null,this.zn=[],this.Ut=0,this.G=null,this.oe=new Map,this.ue=new Map,this.Me=[],this._e=[],this.Ve=[],this.He=!1,this.gn=!1,this.Kt=new WeakMap,this.D=0,this.qt=0,this.yn=0,this.wn=0,this.bn=!1,this.zt=!1,this.Yt=!1,this.Ce=0,this.Yn=()=>{this.D=0,this.bn=!1},this.Gn=()=>{this.Ce--},this.rp=null,this.rr=null,this.Ho=()=>{this.He&&this.Nt()},this.Uo=(t,e)=>t(this.proxy,...e),this.Xn=[],this.Ue=[],this.Jn={$untracked:t=>{let e=this.G;if(null===e)return t();e.be++;try{return t()}finally{e.be--}},$eqIndex:(t,e=1)=>{let i=q(this.d,e);null===i&&h(7,[t]);let s=this.o(t);if(null!==s.getter||s.ae)return this.watchIndex(e),i.y===this.read(s,null);let l=this.G;if(null!==l){let t=l.getter,i=s.je??(s.je=[]);if(!i.some(i=>i.getter===t&&i.Qn===e)){i.push({getter:t,Qn:e});let l=t.h[e];(l.jt??(l.jt=[])).push({source:s,getter:t})}}return i.y===this.v(s,null)},$eq:(t,e)=>this.eq(t,e),$eqPath:(t,e)=>{let i=this.o(e);return this.eq(t,this.v(i,q(this.d,i.n)))},$dependOn:t=>{this.resolve(O(t),this.d),null!==this.G&&0===this.G.be&&this.Zn(this.rp,this.rr,this.G)},$getAll:(t,e)=>this.getAll(t,e),$setAll:(t,e,i,s)=>this.vn(t,e,i,s),$resolve:(...t)=>{let e=O(t[0]),i=t[1]??[],s=this.o(e,!0);this.kn("$resolve",e,s,i,!0);let l=this.eo(s,i,null);if(t.length<3)return this.read(s,l);this.A(s,l,t[2])},$postUpdate:t=>{this.resolve(O(t),this.d);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.E=i.l.R[i.y],_.delete(i.l.R),this.T.Gt(i)),this.Sn(e,i),null!==i&&this.to(i,e,void 0,i.E,!1),0===e.n&&this.no(e,void 0,void 0,!0),this.Xt(e,i,void 0,void 0,!1)}},this.T=i,this.O=new e(t=>{this.Ue.push(t),this.rt(t)}),this.oo(t);let s=this,l={getOwnPropertyDescriptor(t,e){let i=Reflect.getOwnPropertyDescriptor(s.target,e);return i&&(i.configurable=!0),i},get(t,e,i){let l=s.target;if("symbol"==typeof e)return Reflect.get(l,e);if(36===e.charCodeAt(0))return s.it(e);if(e.indexOf(".")<0){let t=s.O.bt(e);if(void 0===t||null===t.getter){let t=l[e];if("function"==typeof t)return i===s.proxy&&s.V?.(t)||t}if(void 0!==t&&0===t.n)return s.read(t,null)}return s.resolve(e,s.d),s.read(s.rp,s.rr)},set:(t,e,i)=>"symbol"==typeof e?Reflect.set(s.target,e,i):(s.resolve(O(e),s.d),s.A(s.rp,s.rr,i),!0)};for(let t of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])l[t]=(e,...i)=>Reflect[t](s.target,...i);this.proxy=new Proxy({},l)}o(t,e){let i=this.O.get(t);return e||(i.pn=!0),i}io(t){let e=new Set;for(let i=t;null!==i&&i!==Object.prototype;i=Object.getPrototypeOf(i))for(let t of Object.getOwnPropertyNames(i)){if(e.has(t))continue;e.add(t);let s=Object.getOwnPropertyDescriptor(i,t);if(void 0===s.get&&void 0===s.set)continue;let l=this.o(t);l.getter=s.get??null,l.se=s.set??null,null!==l.getter&&l.n>0&&(l.F=this.Le++)}for(let t of this.O.all())this.rt(t)}rt(t){t.t.includes("**")&&l(t.t),("__proto__"===t.s||"prototype"===t.s)&&h(120,[t.t]);let e=t.a;t.ae=null!==e&&"*"!==t.s&&e.n===t.n&&(null!==e.getter||e.ae),null===t.getter&&this.Ko(t)}Ko(t){let e=t.t,i=t.s;if(s.test(i))t.getter=function(){return this[i]};else{let s=e.split("."),l=s.findIndex((t,e)=>e>0&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57);if(l<0||s.indexOf("*",l)>=0)return;t.getter=()=>(this.resolve(e,this.d),this.rp!==t?this.read(this.rp,this.rr):this.read(t.a,this.d)?.[i]),t.se=s=>{if(this.resolve(e,this.d),this.rp!==t)return this.A(this.rp,this.rr,s);let l=this.read(t.a,this.d);null==l&&h(4,[e,l]),l[i]=s}}t.hn=!0,t.n>0&&(t.F=this.Le++)}Ke(t,e){let i=null===t?this.oe:t.u??=new Map,s=i.get(e);return void 0===s&&i.set(e,s=new y(e,t)),e.pn=!0,this.X(s),s}so(t){try{this.X(t)}catch(e){this.Jt(e,t.o.t,t.N?.S??null,"for")}}X(t){let e=this.v(t.o,t.ce);if(e===t.R)return;this.lo(t);let i=function(t,e,i){let s=Array.isArray(e)?e:v;if(s===t.R)return null;let l=t.f,n=s.length,h=l.length,r=new Array(n),o=0;for(;o<n&&o<h&&l[o].E===s[o];)r[o]=l[o],o++;let u=h-1,f=n-1;for(;u>=o&&f>=o&&l[u].E===s[f];)r[f]=l[u],u--,f--;if(o>u)for(let e=o;e<=f;e++)r[e]=new p(t,e,s[e]);else if(o>f)for(let t=o;t<=u;t++)i.Mt(l[t]);else{let e=u<f?u:f;for(let t=o;t<=e;t++)l[t].E===s[t]&&(r[t]=l[t]);let n=new Map;for(let t=u;t>=o;t--){let i=l[t];if(t<=e&&r[t]===i)continue;let s=n.get(i.E);void 0===s?n.set(i.E,i):Array.isArray(s)?s.push(i):n.set(i.E,[s,i])}for(let e=o;e<=f;e++){if(void 0!==r[e])continue;let i,l=s[e],h=n.get(l);void 0!==h&&(Array.isArray(h)?(i=h.pop(),0===h.length&&n.delete(l)):(i=h,n.delete(l))),r[e]=i??new p(t,e,l)}for(let t of n.values())if(Array.isArray(t))for(let e of t)i.Mt(e);else i.Mt(t)}for(let t=o;t<n;t++){let e=r[t];e.y!==t&&(e.y=t,i.Mo(e))}return t.f=r,t.R=s,l}(t,e,this);if(null===i)return;if(t.R===e){let i=R(this.Kt,e,x);if(i.push(t),i.length>1)for(let t of i)t.kt=!0}r.Qt?.(this,t,i),(null!==t.N||null!==t.W)&&!t.te&&(t.te=!0,this._e.push(t),this.ve());let s=t.o.jt;if(null!==s)for(let{source:e,getter:l}of s){let s=this.v(e,null),n=i[s],h=t.f[s];n!==h&&(void 0!==n&&n.w&&this.$n(l,n),void 0!==h&&this.$n(l,h))}}Mo(t){this.T.qo(this,t)}Mt(t){t.w=!1;let e=t._;if(null!==e){for(let t of e)W(t.source,t.key,t.sub);t._=null}if(null!==t.u)for(let e of t.u.values()){this.lo(e);for(let t of e.f)this.Mt(t)}}lo(t){let e=this.Kt.get(t.R);void 0!==e&&(e.splice(e.indexOf(t)>>>0,1),t.kt=!1,1===e.length&&(e[0].kt=!1))}resolve(t,e){let s=i(t),l=this.rp=this.o(s.o,!0),n=s.indexes;this.rr=0===l.n?null:null===n?N(e,l,l.n):this.eo(l,n,e,t)}eo(t,e,i,s){let l=null;for(let n,h=1,r=0;h<=t.n;h++){let o=t.h[h],u=this.Ke(l,o),f=e[r++];if(f<0)f=N(i,t,h)?.y??-1;else if(s&&u.R===v&&Object(n=this.v(o,l))===n){let e=t.t.split("."),i=o.t.split(".").length;e[i]=s.split(".")[i],t=this.o(e.join("."),!0),h--;continue}if(l=u.f[f]??null,null===l)break}return this.rp=t,l}st(t,e){return 0===t.n?z(this.target,t.z):null===e?void 0:z(e.E,t.z)}read(t,e){let i=this.G;if(null!==i&&0===i.be&&this.Zn(t,e,i),null!==t.getter)return this.T.zo(this,t,e);if(t.ae){let i=this.read(t.a,e);return i?.[t.s]}return null===t.a&&!(t.s in this.target)&&!this.nt.has(t.s)&&"then"!==t.s&&"toJSON"!==t.s&&h(301,[t.t],t.s,Object.keys(this.target)),this.st(t,e)}v(t,e){let i=this.G;if(null===i)return this.read(t,e);i.be++;try{return this.read(t,e)}finally{i.be--}}Zn(t,e,i){let s=i.getter;t.Hn(s),0===s.n?t.Z!==i.de&&(t.Z=i.de,i.En.push(t)):t.n>0&&q(e,Math.min(t.n,s.n))!==q(i.r,Math.min(t.n,s.n))&&(s.ht??(s.ht=new Set)).add(t)}Yo(t,e){for(let i=0;i<this.Ut;i++){let s=this.zn[i];s.getter===t&&s.r===e&&h(701,[t.t])}this.Ut>=128&&h(801,[t.t]);let i=this.Ut++;this.Be++;let s=this.zn[i]??={getter:t,r:e,be:0,de:0,En:[]};s.getter=t,s.r=e,s.be=0,s.de=++j,s.En.length=0;let l=this.G;this.G=s;let n=this.d;this.d=e;try{let e=t.getter.call(this.proxy);return 0===t.n&&this.Go(t,s),e}finally{this.Be--,this.Ut--,this.G=l,this.d=n,s.r=null}}Go(t,e){let i=e.de;for(let t of e.En)t.Z=i;t.Q=t.Q.filter(e=>e.Z===i||e.n>0||!e.ae&&Array.isArray(null!==e.getter?e.Y:this.st(e,null))||this.ao(e,t))}ao(t,e){return t.Bo(e),this.Ue.push(t),!1}Xo(){for(let t=this.Ue;t.length>0;t=this.Ue){this.Ue=[];let e=new Set;for(let i of t)if(!(i.pn||i.mn||null===i.a||i.u.length>0||i.B.length>0)&&(null===i.getter||i.hn&&i.F<0)&&null===i._){i.mn=!0,this.O.Bt(i),e.add(i.a);for(let t of i.Q)this.ao(t,i)}for(let t of e)(t.u=t.u.filter(t=>!t.mn)).length||this.Ue.push(t)}}watchIndex(t){let e=this.G;if(null!==e&&0===e.be){let i=e.getter,s=i.h[t];if(s){let t=s.Lt??(s.Lt=[]);t.includes(i)||t.push(i)}}}it(t){let e=t.charCodeAt(1);if(e>=48&&e<=57){let i=2===t.length?e-48:s.test(t)?+t.slice(1):0;return(i<1||i>128)&&h(1001,[t]),this.watchIndex(i),q(this.d,i)?.y}let i=this.Jn[t];if(void 0!==i)return i;switch(t){case"$stateElement":return this.element;case"$command":return this.commands}return r.it?.(this,t)}eq(t,e){this.resolve(t,this.d);let i=this.rp,s=this.rr;if(null!==i.getter||i.ae||i.n>0)return H(this.read(i,s),e);let l=this.G;return null!==l&&0===l.be&&this.Jo(i,e,l),H(this.v(i,null),e)}Jo(t,e,i){let s=i.getter,l=i.r,n=null===l?this.Xn:l._??(l._=[]);for(let l=0;l<n.length;l++){let h=n[l];if(h.sub.getter===s&&h.source===t){if(H(h.key,e))return void(h.de=i.de);h.de!==i.de&&(W(t,h.key,h.sub),n.splice(l--,1))}}let h={getter:s,r:l};R(t._??=new Map,e,S).add(h),n.push({source:t,key:e,sub:h,de:i.de})}no(t,e,i,s){this.Zt(t,l=>{let n=l._;if(null===n&&null===l.je)return;let h=l===t?[]:l.t.slice(t.t.length+1).split("."),r=z(e,h),o=z(i,h);if(null!==l.je&&this.Qo(l,r,o,s),null!==n)for(let t of s?n.keys():[r,o]){let e=n.get(t);if(void 0!==e)for(let i of e)null===i.r||i.r.w?this.T.ke(this,i.getter,i.r):W(l,t,i)}})}A(t,e,i,s=!1,l=!1){if(this.Be>0&&h(8),l||this.Ce>0?this.zt=!0:this.Yt=!0,r.Ie?.(this,t,e,i,l))return;if(null!==t.se){try{this.Nn(t.se,e,[i])}finally{this.Xt(t,e,void 0,void 0,!1,l)}return}null!==t.getter&&h(2,[t.t]),t.n>0&&null===e&&h(3,[t.t]);let n=t.ae?this.v(t,e):this.st(t,e);if(s||!this.Vt||!Object.is(n,i)||Object(i)===i){if("*"===t.s){let t=e;t.l.R[t.y]=i,_.delete(t.l.R),t.E=i,this.T.Gt(t)}else{let s=1===t.z.length?0===t.n?this.target:e.E:this.v(t.a,e);null==s&&h(4,[t.t,s]),s[t.s]=i}this.xn(t,e),null!==e&&this.to(e,t,n,i),0===t.n&&this.no(t,n,i),this.Xt(t,e,n,i,!0,l)}}co(t){return(this.Kt.get(t.R)??[]).filter(e=>e.R===t.R&&(null===e.ce||e.ce.w))}to(e,i,s,l,n=!0){let h=e.l,r=i.t.slice(h.o.t.length+2),o=""!==r&&function(t){let e=_.get(t);if(void 0===e){let i=new Set;_.set(t,e=t.some(t=>Object(t)===t&&(i.has(t)||!i.add(t))))}return e}(h.R);if(!o&&!h.kt&&null===h.o.getter&&!h.o.B.length)return;let u=e.E,f=(t,i)=>{if(void 0===i||i===e)return;let h=this.o(`${t.o.t}.*${r}`,!0);""===r&&(i.E=l,this.T.Gt(i)),n?this.xn(h,i):this.Sn(h,i),this.Xt(h,i,s,l,n)};for(let t of this.co(h))if(f(t,t.f[e.y]),o)for(let i of t.f)i.E===u&&i.y!==e.y&&f(t,i);if(""===r)return;let a=new Set([h.R]),d=t=>Array.isArray(t)&&t.includes(u),c=(e,i)=>{if(!a.has(e)&&a.add(e))for(let t of this.Kt.get(e)??[])for(let e of t.f)e.E===u&&f(t,e);for(let s of i){let i=s.Y,l=i===t;l&&(i=this.oe.get(s)?.R),(l||d(i))&&!a.has(s.B)&&a.add(s.B)&&(!l&&i!==e&&this.T.ke(this,s,null),c(i,s.B))}},g=t=>{for(let e of t.Q)if(!a.has(e)&&a.add(e))if(null!==e.getter)g(e);else if(!e.ae){let t=this.st(e,null);d(t)&&c(t,e.B)}};null!==h.o.getter?g(h.o):c(h.R,h.o.B)}Sn(t,e){this.Zo(t,e,t=>{this.X(t);for(let e of t.kt?this.co(t):[t]){let t=this.o(`${e.o.t}.*`);for(let i of e.f)this.xt(t,i),this.Sn(t,i)}})}xn(t,e){let i=null===e?this.oe:e.u;if(null!==i)for(let e of i.values())e.o.ee(t)&&this.X(e)}Zo(t,e,i){let s=null===e?this.oe:e.u;if(null!==s)for(let e of s.values())e.o.ee(t)&&i(e)}Qo(t,e,i,s){for(let{getter:l,Qn:n}of t.je)this.uo(l.h[n],t=>{for(let n of s?t.f.keys():[e,i]){let e="number"==typeof n?t.f[n]:void 0;void 0!==e&&this.$n(l,e)}})}$n(t,e){e.l.n===t.n?this.T.ke(this,t,e):this.en(e,t,e=>this.T.ke(this,t,e))}Xt(t,e,i,s,l,n){r.re?.(this,t,e,i,s,l,n),this.qe(t,e)}qe(t,e){this.T.er(this,t,e),this.ve()}fo(t){let e=this.ot.get(t);if(void 0!==e)return e;let i=Symbol(`wcs.on${t}`);this.ot.set(t,i);let s=this.root,l=this.qn;return s.addEventListener(t,e=>{for(let n=e.target;null!==n&&n!==s;n=n.parentNode){let s=n[i];if(void 0!==s&&(s(e),e.cancelBubble))return;let h=n[l];if(void 0!==h&&h.w&&h.tr(t,e))return}}),i}reset(t){let e=this.target,i=this.nt;for(let t of this.O.all())null===t.a&&null!==t.getter&&i.add(t.s);this.oo(t);for(let t in e)"$"!==t[0]&&i.add(t);for(let e of i)e in t&&i.delete(e);for(let t of this.ue.values())for(let e of t)this.tn(e);for(let t of this.oe.values())this.po(t);this.We=null;try{this.Nt()}finally{this.Pn()}r.element?.(this,"reset")}oo(t){for(let[e,i]of A)void 0!==t[e]&&o(i,e);let e=t.$features;if(void 0!==e){Array.isArray(e)||h(46);for(let t of e)o(t,"$features")}let i=void 0===t.$behavior?{}:t.$behavior;("object"!=typeof i||!i||Array.isArray(i))&&h(44,["state","$behavior"]);for(let t in i)(!M.includes(t)||"boolean"!=typeof i[t])&&h(44,["$behavior",t]);let[s,l,n]=M.map(t=>i[t]??!0);void 0!==this.target&&(s!==this._t||l!==this.Vt||n!==this.Ht)&&h(45);let u=function(t,e){let i={};for(let s of m(t.$commandTokens,"$commandTokens","$command"))i[s]=e?.[s]??new b(s);return Object.freeze(i)}(t,this.commands),f=function(t,e){let i=new Map;for(let e of m(t.$eventTokens,"$eventTokens"))i.set(e,new b(e));let s=t.$on;if(void 0===s)return i;(null===s||"object"!=typeof s)&&h(22);for(let[t,l]of Object.entries(s)){let s=i.get(t);void 0===s&&h(23,[t]),"function"!=typeof l&&h(24,[t]),s.subscribe((...t)=>e(l,t))}return i}(t,this.Uo);this._t=s,this.Vt=l,this.Ht=n,r.fe?.(this,t),this.target=t,this.Le=0;for(let t of this.O.all())t.Wo();this.Xn.length=0,this.io(t),this.commands=u,this.Oe=f}po(t){this.so(t);let e=this.o(`${t.o.t}.*`);for(let i of t.f)if(i.vt=null,i._=null,this.xt(e,i),null!==i.u)for(let t of i.u.values())this.po(t)}H(t){let e=[];for(let i=t;null!==i;i=i.l.ce)e.unshift(i.y);return e}nr(t,e,i){let s=this.Oe.get(t);void 0===s&&h(1301,[t],t,this.Oe.keys()),s.emit(e,...this.H(i))}command(t){let e=this.commands[t];return void 0===e&&h(1302,[t],t,Object.keys(this.commands)),e}or(t,e,i){this.command(t).emit(e,...this.H(i))}ir(t,e,i){let s=t.includes(".")?this.v(this.o(t),null):this.target[t];return"function"!=typeof s&&h(5,[t]),this.Nn(s,i,[e,...this.H(i)])}Nn(t,e,i){let s=this.d;this.d=e;try{return t.apply(this.proxy,i)}finally{this.d=s}}xt(t,e){if(null!==t.getter){let i=null===e?this.oe:e.u;if(null!==i)for(let e of i.values())!e.Wt&&e.o.ee(t)&&(e.Wt=!0,this.Ve.push(e))}if(null===e)return void this.Zt(t,t=>{let e=this.ue.get(t);if(void 0!==e)for(let t of e)this.tn(t)});let i=e.we;if(null!==i)for(let e=0;e<i.length;e++)i[e].o.ee(t)&&this.tn(i[e]);let s=e.N;null!==s&&null!==s.pe&&s.mo(this,t);let l=e.l.W;if(null!==l)for(let i of l){let s=i.map.get(e);void 0!==s&&null!==s.pe&&s.mo(this,t)}}Rn(t,e,i){this.Zt(t,t=>{let s=t.B;for(let l=0;l<s.length;l++){let n=s[l];if(0===n.n)this.at(n,null,i);else if(null===e||0===t.n||n.h[1]!==t.h[1]||null!==n.ht&&n.ht.has(t))this.nn(n.h[n.n],t=>this.at(n,t,i));else if(n.n<=t.n){let t=q(e,n.n);null!==t&&this.at(n,t,i)}else this.en(e,n,t=>this.at(n,t,i))}})}at(t,e,i){i(t,e)&&(r.Se?.(this,t,e),this.xt(t,e),this.Rn(t,e,i))}Zt(t,e){e(t);let i=t.u;for(let t=0;t<i.length;t++)this.Zt(i[t],e)}nn(t,e){this.uo(t,t=>{for(let i of t.f)e(i)})}uo(t,e){if(0===t.n){let i=this.oe.get(t);return void(void 0!==i&&e(i))}this.nn(t.h[t.n],i=>{let s=i.u?.get(t);void 0!==s&&e(s)})}en(t,e,i){if(t.l.n===e.n)return i(t);let s=t.u?.get(e.h[t.l.n+1]);if(void 0!==s)for(let t of s.f)this.en(t,e,i)}sr(t){let e=t.r;null===e?R(this.ue,t.o,S).add(t):(e.we??(e.we=[])).push(t)}Tn(t){let e=t.r;if(null===e)return void this.ue.get(t.o)?.delete(t);let i=e.we;e.w&&null!==i&&i.splice(i.indexOf(t)>>>0,1)}tn(t){t.te||(t.te=!0,this.Me.push(t),this.ve())}ve(){this.He||(this.He=!0,queueMicrotask(this.Ho))}An(){for(let t of this.Me)t.te=!1;for(let t of this._e)t.te=!1;for(let t of this.Ve)t.Wt=!1;this.Me=[],this._e=[],this.Ve=[],this.T.nt(this)}ho(t,e){let i=[...new Set([...this.Me,...this._e,...this.Ve].map(t=>t.o.t))];u(i,`[@wcstack/state] ${n(t)}`),r.ct?.(this,{type:"state:render-chain-limit",maxDepth:e,paths:i}),this.An()}Nt(){this.He=!1;let t=this.qt;this.qt=0;let e=0;if(!this.zt||this.Yt?this.Yn():t>0?e=t:1===(e=++this.D)&&setTimeout(this.Yn,0),this.zt=this.Yt=!1,e>100)101===e?this.ho(41,100):this.An();else{this.gn=!0;try{for(let t=0;this.Me.length>0||this._e.length>0||this.Ve.length>0;t++){if(t>=32){this.bn?this.An():this.ho(11,32),this.bn=!0;break}let i=this.Ve;if(i.length>0){this.Ve=[];for(let t of i)t.Wt=!1,this.so(t)}let s=this._e,l=this.Me;this._e=[],this.Me=[];let n=!1,h=()=>{n=!0;for(let t of s){t.te=!1;for(let e of[t.N,...t.W??[]])if(null!==e&&e.w)try{e.Pt()}catch(i){this.Jt(i,t.o.t,e.S,"for")}}for(let t=0;t<2;t++)for(let e=0;e<l.length;e++){let i=l[e];!i.te||null===i.D==(0===t)||(i.te=!1,(null===i.Fn||i.Fn.w)&&this.ze(i))}if(!this.gn&&(this.Ye(),0===--this.yn&&this.go(),this.He)){this.qt=e+1,this.wn++;try{for(;this.He;)this.Nt()}finally{this.wn--}}},r=(s.length>0||l.some(t=>null!==t.D))&&0===this.wn?k("state",h):h();n||this.yn++,void 0!==r&&r.then(void 0,u)}}finally{this.gn=!1}this.zt=this.Yt=!1,this.Ye(),0===this.yn&&this.go(),t>0&&this.He&&(this.qt=e+1)}}go(){r.me?.(this),this.Xo()}Rt(t,e){this.Et.push([t,e])}Jt(t,e,i,s){this.Rt(t,{o:{t:e},c:i,on:()=>s})}ze(t){try{t.apply()}catch(e){return void this.Et.push([e,t])}null!==this.We&&this.yo(t.o,t.r)}yo(t,e){let i=R(this.We,t.t,x);null!==e&&i.push(this.H(e))}Pn(){this.We="function"==typeof this.target.$renderedCallback?new Map:null}Ye(){let t=this.We;if(null!==t&&t.size>0){this.We=new Map;let e,i=[...t.keys()],s={};for(let[e,i]of t)i.length>0&&(s[e]=i);this.Ce++;try{e=this.$e("$renderedCallback",[i,s])}catch(t){u(t)}G(e)?e.then(this.Gn,t=>{this.Gn(),u(t)}):this.Ce--}if(0===this.Et.length)return;let e=this.Et;this.Et=[];let i=this.target.$errorCallback;for(let[t,s]of e){r.Ge?.(this,t,s);let e=s.o.t,l=s.on();if("function"==typeof i)try{let i=this.$e("$errorCallback",[t,{path:e,bindingType:l,node:s.c}]);G(i)&&i.then(void 0,u)}catch(t){u(t)}else u(t,`[@wcstack/state] ${n(12,s.name?[l,e,s.name,s.i]:[l,e])}`,s.c)}}$e(t,e=[]){let i=this.target[t];return"function"==typeof i?this.Nn(i,null,e):void 0}wo(t,e,i){if(0===t.n)return void i(null,[]);let s=[],l=(n,h)=>{let r=t.h[n];this.read(r,h);let o=this.Ke(h,r),u=e=>{s.push(e.y),n===t.n?i(e,s):l(n+1,e),s.pop()};for(let t of n-1<e.length?[o.f[e[n-1]]]:o.f)void 0!==t&&u(t)};l(1,null)}getAll(t,e){let i=this.o(t,!0);void 0!==e&&this.kn("$getAll",t,i,e,!1);let s=e;if(void 0===s){s=[];let e=this.d;if(null!==e&&i.n>0){for(let t=1;t<=i.n;t++){let l=N(e,i,t);if(null===l)break;s.push(l.y)}0===s.length&&h(6,[t])}}let l=[];return this.wo(i,s,t=>l.push(this.read(i,t))),l}vn(t,e,i,s){Array.isArray(e)||h(9,[t]),this.Be>0&&h(8);let l=this.o(t,!0);this.kn("$setAll",t,l,e,!1);let n=[];this.wo(l,e,(t,e)=>n.push([t,e.slice()]));let r=!0===s?.spread;r&&(!Array.isArray(i)||i.length!==n.length)&&h(10,[t,n.length]);let o=0;for(let t=0;t<n.length;t++){let[e,s]=n[t],h="function"==typeof i?i(this.v(l,e),...s):r?i[t]:i;void 0!==h&&(this.A(l,e,h),o++)}return o}kn(t,e,i,s,l){let n=s.length;(n>i.n||l&&n<i.n)&&h(l?901:902,[t,e,i.n,n])}};export{$ as a,E as b,T as c,G as d,q as e,B as f,f as g,a as h,d as i,c as j,g as k};
|
|
2
|
+
//# sourceMappingURL=chunk-GU7IAIWW.js.map
|