@uasyraf/helm 0.1.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/.claude-plugin/plugin.json +9 -0
- package/.mcp.json +8 -0
- package/LICENSE +21 -0
- package/README.md +114 -0
- package/dashboard/build/client/_app/immutable/assets/0.DPthOi2j.css +1 -0
- package/dashboard/build/client/_app/immutable/assets/0.DPthOi2j.css.br +0 -0
- package/dashboard/build/client/_app/immutable/assets/0.DPthOi2j.css.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/B3NJzl7g.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/B3NJzl7g.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/B3NJzl7g.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/Bvgn0Gys.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/Bvgn0Gys.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/Bvgn0Gys.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/C72aErMY.js +3 -0
- package/dashboard/build/client/_app/immutable/chunks/C72aErMY.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/C72aErMY.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/CjpPs8iz.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/CjpPs8iz.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/CjpPs8iz.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/DNLp8810.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/DNLp8810.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/DNLp8810.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/DYkFpqG7.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/DYkFpqG7.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/DYkFpqG7.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/DsiL0ppy.js +2 -0
- package/dashboard/build/client/_app/immutable/chunks/DsiL0ppy.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/DsiL0ppy.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/bJX5vhEj.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/bJX5vhEj.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/bJX5vhEj.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/chunks/gQDp4_Ul.js +1 -0
- package/dashboard/build/client/_app/immutable/chunks/gQDp4_Ul.js.br +0 -0
- package/dashboard/build/client/_app/immutable/chunks/gQDp4_Ul.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/entry/app.D4j9hUjJ.js +2 -0
- package/dashboard/build/client/_app/immutable/entry/app.D4j9hUjJ.js.br +0 -0
- package/dashboard/build/client/_app/immutable/entry/app.D4j9hUjJ.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/entry/start.D59wIHuS.js +1 -0
- package/dashboard/build/client/_app/immutable/entry/start.D59wIHuS.js.br +2 -0
- package/dashboard/build/client/_app/immutable/entry/start.D59wIHuS.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/0.HocD0HAQ.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/0.HocD0HAQ.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/0.HocD0HAQ.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/1.xo_a-jPh.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/1.xo_a-jPh.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/1.xo_a-jPh.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/2.BwywD4n3.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/2.BwywD4n3.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/2.BwywD4n3.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/3.BGY0bNfC.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/3.BGY0bNfC.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/3.BGY0bNfC.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/4.C7uIivCS.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/4.C7uIivCS.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/4.C7uIivCS.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/5.YszfczJW.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/5.YszfczJW.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/5.YszfczJW.js.gz +0 -0
- package/dashboard/build/client/_app/immutable/nodes/6.7fhKcbBK.js +1 -0
- package/dashboard/build/client/_app/immutable/nodes/6.7fhKcbBK.js.br +0 -0
- package/dashboard/build/client/_app/immutable/nodes/6.7fhKcbBK.js.gz +0 -0
- package/dashboard/build/client/_app/version.json +1 -0
- package/dashboard/build/client/_app/version.json.br +0 -0
- package/dashboard/build/client/_app/version.json.gz +0 -0
- package/dashboard/build/env.js +94 -0
- package/dashboard/build/handler.js +1494 -0
- package/dashboard/build/index.js +345 -0
- package/dashboard/build/server/chunks/0-DUUsxI66.js +40 -0
- package/dashboard/build/server/chunks/0-DUUsxI66.js.map +1 -0
- package/dashboard/build/server/chunks/1-BDkdOGL6.js +9 -0
- package/dashboard/build/server/chunks/1-BDkdOGL6.js.map +1 -0
- package/dashboard/build/server/chunks/2-BLt1vNET.js +51 -0
- package/dashboard/build/server/chunks/2-BLt1vNET.js.map +1 -0
- package/dashboard/build/server/chunks/3-B-4sxMk4.js +41 -0
- package/dashboard/build/server/chunks/3-B-4sxMk4.js.map +1 -0
- package/dashboard/build/server/chunks/4-CRZIwHJO.js +39 -0
- package/dashboard/build/server/chunks/4-CRZIwHJO.js.map +1 -0
- package/dashboard/build/server/chunks/5-CwiVOtz6.js +30 -0
- package/dashboard/build/server/chunks/5-CwiVOtz6.js.map +1 -0
- package/dashboard/build/server/chunks/6-mID2_gX2.js +53 -0
- package/dashboard/build/server/chunks/6-mID2_gX2.js.map +1 -0
- package/dashboard/build/server/chunks/_layout.svelte-DeOKequ-.js +31 -0
- package/dashboard/build/server/chunks/_layout.svelte-DeOKequ-.js.map +1 -0
- package/dashboard/build/server/chunks/_page.svelte-BGS-bwra.js +65 -0
- package/dashboard/build/server/chunks/_page.svelte-BGS-bwra.js.map +1 -0
- package/dashboard/build/server/chunks/_page.svelte-BiRjdIbl.js +35 -0
- package/dashboard/build/server/chunks/_page.svelte-BiRjdIbl.js.map +1 -0
- package/dashboard/build/server/chunks/_page.svelte-C_NO0kPy.js +49 -0
- package/dashboard/build/server/chunks/_page.svelte-C_NO0kPy.js.map +1 -0
- package/dashboard/build/server/chunks/_page.svelte-DvSQBjcA.js +80 -0
- package/dashboard/build/server/chunks/_page.svelte-DvSQBjcA.js.map +1 -0
- package/dashboard/build/server/chunks/_page.svelte-ZUq8J-ew.js +33 -0
- package/dashboard/build/server/chunks/_page.svelte-ZUq8J-ew.js.map +1 -0
- package/dashboard/build/server/chunks/error.svelte-DJ3O9Tia.js +12 -0
- package/dashboard/build/server/chunks/error.svelte-DJ3O9Tia.js.map +1 -0
- package/dashboard/build/server/chunks/exports-BnaAAAnL.js +3262 -0
- package/dashboard/build/server/chunks/exports-BnaAAAnL.js.map +1 -0
- package/dashboard/build/server/chunks/index-DwR_KaNY.js +44 -0
- package/dashboard/build/server/chunks/index-DwR_KaNY.js.map +1 -0
- package/dashboard/build/server/chunks/index-lhTMmBNn.js +207 -0
- package/dashboard/build/server/chunks/index-lhTMmBNn.js.map +1 -0
- package/dashboard/build/server/chunks/queries-DGWi-KlP.js +198 -0
- package/dashboard/build/server/chunks/queries-DGWi-KlP.js.map +1 -0
- package/dashboard/build/server/chunks/renderer-DdMvhZZr.js +1930 -0
- package/dashboard/build/server/chunks/renderer-DdMvhZZr.js.map +1 -0
- package/dashboard/build/server/index.js +5911 -0
- package/dashboard/build/server/index.js.map +1 -0
- package/dashboard/build/server/manifest.js +78 -0
- package/dashboard/build/server/manifest.js.map +1 -0
- package/dashboard/build/shims.js +32 -0
- package/dashboard/package.json +29 -0
- package/dashboard/svelte.config.js +15 -0
- package/dist/bin/helm.d.ts +2 -0
- package/dist/bin/helm.js +167 -0
- package/dist/bin/helm.js.map +1 -0
- package/dist/server/src/banner.d.ts +1 -0
- package/dist/server/src/banner.js +34 -0
- package/dist/server/src/banner.js.map +1 -0
- package/dist/server/src/config/load.d.ts +14 -0
- package/dist/server/src/config/load.js +43 -0
- package/dist/server/src/config/load.js.map +1 -0
- package/dist/server/src/dashboard.d.ts +5 -0
- package/dist/server/src/dashboard.js +79 -0
- package/dist/server/src/dashboard.js.map +1 -0
- package/dist/server/src/db/bootstrap.d.ts +2 -0
- package/dist/server/src/db/bootstrap.js +106 -0
- package/dist/server/src/db/bootstrap.js.map +1 -0
- package/dist/server/src/db/client.d.ts +14 -0
- package/dist/server/src/db/client.js +32 -0
- package/dist/server/src/db/client.js.map +1 -0
- package/dist/server/src/db/open-project.d.ts +17 -0
- package/dist/server/src/db/open-project.js +27 -0
- package/dist/server/src/db/open-project.js.map +1 -0
- package/dist/server/src/db/open-repo.d.ts +8 -0
- package/dist/server/src/db/open-repo.js +45 -0
- package/dist/server/src/db/open-repo.js.map +1 -0
- package/dist/server/src/db/pg-bootstrap.d.ts +4 -0
- package/dist/server/src/db/pg-bootstrap.js +106 -0
- package/dist/server/src/db/pg-bootstrap.js.map +1 -0
- package/dist/server/src/db/pg-client.d.ts +10 -0
- package/dist/server/src/db/pg-client.js +42 -0
- package/dist/server/src/db/pg-client.js.map +1 -0
- package/dist/server/src/db/repo-pg.d.ts +3 -0
- package/dist/server/src/db/repo-pg.js +245 -0
- package/dist/server/src/db/repo-pg.js.map +1 -0
- package/dist/server/src/db/repo-sqlite.d.ts +3 -0
- package/dist/server/src/db/repo-sqlite.js +224 -0
- package/dist/server/src/db/repo-sqlite.js.map +1 -0
- package/dist/server/src/db/repo.d.ts +54 -0
- package/dist/server/src/db/repo.js +2 -0
- package/dist/server/src/db/repo.js.map +1 -0
- package/dist/server/src/db/schema-pg.d.ts +2712 -0
- package/dist/server/src/db/schema-pg.js +107 -0
- package/dist/server/src/db/schema-pg.js.map +1 -0
- package/dist/server/src/db/schema.d.ts +2721 -0
- package/dist/server/src/db/schema.js +107 -0
- package/dist/server/src/db/schema.js.map +1 -0
- package/dist/server/src/events/emit.d.ts +21 -0
- package/dist/server/src/events/emit.js +17 -0
- package/dist/server/src/events/emit.js.map +1 -0
- package/dist/server/src/http/server.d.ts +10 -0
- package/dist/server/src/http/server.js +119 -0
- package/dist/server/src/http/server.js.map +1 -0
- package/dist/server/src/index.d.ts +2 -0
- package/dist/server/src/index.js +13 -0
- package/dist/server/src/index.js.map +1 -0
- package/dist/server/src/init.d.ts +12 -0
- package/dist/server/src/init.js +59 -0
- package/dist/server/src/init.js.map +1 -0
- package/dist/server/src/install.d.ts +8 -0
- package/dist/server/src/install.js +100 -0
- package/dist/server/src/install.js.map +1 -0
- package/dist/server/src/project/bootstrap.d.ts +9 -0
- package/dist/server/src/project/bootstrap.js +83 -0
- package/dist/server/src/project/bootstrap.js.map +1 -0
- package/dist/server/src/project/detect.d.ts +10 -0
- package/dist/server/src/project/detect.js +82 -0
- package/dist/server/src/project/detect.js.map +1 -0
- package/dist/server/src/project/identity.d.ts +8 -0
- package/dist/server/src/project/identity.js +42 -0
- package/dist/server/src/project/identity.js.map +1 -0
- package/dist/server/src/server.d.ts +8 -0
- package/dist/server/src/server.js +22 -0
- package/dist/server/src/server.js.map +1 -0
- package/dist/server/src/tools/debt.d.ts +2 -0
- package/dist/server/src/tools/debt.js +88 -0
- package/dist/server/src/tools/debt.js.map +1 -0
- package/dist/server/src/tools/decision.d.ts +2 -0
- package/dist/server/src/tools/decision.js +39 -0
- package/dist/server/src/tools/decision.js.map +1 -0
- package/dist/server/src/tools/epic.d.ts +2 -0
- package/dist/server/src/tools/epic.js +95 -0
- package/dist/server/src/tools/epic.js.map +1 -0
- package/dist/server/src/tools/index.d.ts +3 -0
- package/dist/server/src/tools/index.js +21 -0
- package/dist/server/src/tools/index.js.map +1 -0
- package/dist/server/src/tools/nelson.d.ts +2 -0
- package/dist/server/src/tools/nelson.js +28 -0
- package/dist/server/src/tools/nelson.js.map +1 -0
- package/dist/server/src/tools/progress.d.ts +2 -0
- package/dist/server/src/tools/progress.js +45 -0
- package/dist/server/src/tools/progress.js.map +1 -0
- package/dist/server/src/tools/sprint.d.ts +2 -0
- package/dist/server/src/tools/sprint.js +98 -0
- package/dist/server/src/tools/sprint.js.map +1 -0
- package/dist/server/src/tools/status.d.ts +2 -0
- package/dist/server/src/tools/status.js +31 -0
- package/dist/server/src/tools/status.js.map +1 -0
- package/dist/server/src/tools/story.d.ts +2 -0
- package/dist/server/src/tools/story.js +155 -0
- package/dist/server/src/tools/story.js.map +1 -0
- package/dist/server/src/tools/task.d.ts +2 -0
- package/dist/server/src/tools/task.js +90 -0
- package/dist/server/src/tools/task.js.map +1 -0
- package/dist/server/src/tools/types.d.ts +15 -0
- package/dist/server/src/tools/types.js +11 -0
- package/dist/server/src/tools/types.js.map +1 -0
- package/dist/server/src/util/git.d.ts +8 -0
- package/dist/server/src/util/git.js +51 -0
- package/dist/server/src/util/git.js.map +1 -0
- package/dist/server/src/util/ids.d.ts +2 -0
- package/dist/server/src/util/ids.js +8 -0
- package/dist/server/src/util/ids.js.map +1 -0
- package/dist/server/src/util/paths.d.ts +2 -0
- package/dist/server/src/util/paths.js +9 -0
- package/dist/server/src/util/paths.js.map +1 -0
- package/dist/server/src/worker/client.d.ts +12 -0
- package/dist/server/src/worker/client.js +89 -0
- package/dist/server/src/worker/client.js.map +1 -0
- package/dist/server/src/worker/hook.d.ts +1 -0
- package/dist/server/src/worker/hook.js +36 -0
- package/dist/server/src/worker/hook.js.map +1 -0
- package/dist/server/src/worker/ingest.d.ts +14 -0
- package/dist/server/src/worker/ingest.js +86 -0
- package/dist/server/src/worker/ingest.js.map +1 -0
- package/dist/server/src/worker/markers/any-type.d.ts +6 -0
- package/dist/server/src/worker/markers/any-type.js +19 -0
- package/dist/server/src/worker/markers/any-type.js.map +1 -0
- package/dist/server/src/worker/markers/debt.d.ts +11 -0
- package/dist/server/src/worker/markers/debt.js +53 -0
- package/dist/server/src/worker/markers/debt.js.map +1 -0
- package/dist/server/src/worker/markers/file-size.d.ts +5 -0
- package/dist/server/src/worker/markers/file-size.js +32 -0
- package/dist/server/src/worker/markers/file-size.js.map +1 -0
- package/dist/server/src/worker/scanner.d.ts +23 -0
- package/dist/server/src/worker/scanner.js +23 -0
- package/dist/server/src/worker/scanner.js.map +1 -0
- package/dist/server/src/worker/server.d.ts +1 -0
- package/dist/server/src/worker/server.js +137 -0
- package/dist/server/src/worker/server.js.map +1 -0
- package/dist/server/src/worker/socket.d.ts +3 -0
- package/dist/server/src/worker/socket.js +12 -0
- package/dist/server/src/worker/socket.js.map +1 -0
- package/hooks/hooks.json +33 -0
- package/package.json +56 -0
- package/skills/backlog/SKILL.md +18 -0
- package/skills/debt/SKILL.md +39 -0
- package/skills/epic/SKILL.md +22 -0
- package/skills/nelson-integration/SKILL.md +44 -0
- package/skills/project-tracker/SKILL.md +60 -0
- package/skills/review/SKILL.md +27 -0
- package/skills/sprint/SKILL.md +23 -0
- package/skills/story/SKILL.md +29 -0
|
@@ -0,0 +1,3262 @@
|
|
|
1
|
+
import { al as render, L as LEGACY_PROPS, a1 as define_property, f as CONNECTED, y as REACTION_RAN, n as ERROR_VALUE, e as COMMENT_NODE, r as HYDRATION_START, q as HYDRATION_ERROR, J as STATE_SYMBOL, ak as object_prototype, X as array_prototype, O as UNINITIALIZED, a7 as get_descriptor, D as DERIVED, i as DIRTY, v as MAYBE_DIRTY, ad as is_extensible, C as CLASS_CACHE, a as ATTRIBUTES_CACHE, K as STYLE_CACHE, T as TEXT_CACHE, a8 as get_prototype_of, ac as is_array, d as CLEAN, I as INERT, k as EFFECT, B as BLOCK_EFFECT, A as ASYNC, g as DESTROYED, E as EAGER_EFFECT, a0 as deferred, z as RENDER_EFFECT, M as MANAGED_EFFECT, F as ROOT_EFFECT, c as BRANCH_EFFECT, W as WAS_MARKED, R as REACTION_IS_UPDATING, am as run_all, aa as includes, l as EFFECT_PRESERVED, m as EFFECT_TRANSPARENT, H as HEAD_EFFECT, h as DESTROYING, b as BOUNDARY_EFFECT, ab as index_of, G as STALE_REACTION, aj as noop, V as array_from, ae as is_passive_event, an as setContext, a2 as derived, p as HYDRATION_END, s as HYDRATION_START_ELSE, t as HYDRATION_START_FAILED, Q as USER_EFFECT } from './renderer-DdMvhZZr.js';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line n/prefer-global/process
|
|
4
|
+
const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
|
|
5
|
+
|
|
6
|
+
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
7
|
+
/** @import { RequestStore } from 'types' */
|
|
8
|
+
/** @import { AsyncLocalStorage } from 'node:async_hooks' */
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/** @type {RequestStore | null} */
|
|
12
|
+
let sync_store = null;
|
|
13
|
+
|
|
14
|
+
/** @type {AsyncLocalStorage<RequestStore | null> | null} */
|
|
15
|
+
let als;
|
|
16
|
+
|
|
17
|
+
import('node:async_hooks')
|
|
18
|
+
.then((hooks) => (als = new hooks.AsyncLocalStorage()))
|
|
19
|
+
.catch(() => {
|
|
20
|
+
// can't use AsyncLocalStorage, but can still call getRequestEvent synchronously.
|
|
21
|
+
// this isn't behind `supports` because it's basically just StackBlitz (i.e.
|
|
22
|
+
// in-browser usage) that doesn't support it AFAICT
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @template T
|
|
27
|
+
* @param {RequestStore | null} store
|
|
28
|
+
* @param {() => T} fn
|
|
29
|
+
*/
|
|
30
|
+
function with_request_store(store, fn) {
|
|
31
|
+
try {
|
|
32
|
+
sync_store = store;
|
|
33
|
+
return als ? als.run(store, fn) : fn();
|
|
34
|
+
} finally {
|
|
35
|
+
// Since AsyncLocalStorage is not working in webcontainers, we don't reset `sync_store`
|
|
36
|
+
// and handle only one request at a time in `src/runtime/server/index.js`.
|
|
37
|
+
if (!IN_WEBCONTAINER) {
|
|
38
|
+
sync_store = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const text_encoder = new TextEncoder();
|
|
44
|
+
function get_relative_path(from, to) {
|
|
45
|
+
const from_parts = from.split(/[/\\]/);
|
|
46
|
+
const to_parts = to.split(/[/\\]/);
|
|
47
|
+
from_parts.pop();
|
|
48
|
+
while (from_parts[0] === to_parts[0]) {
|
|
49
|
+
from_parts.shift();
|
|
50
|
+
to_parts.shift();
|
|
51
|
+
}
|
|
52
|
+
let i = from_parts.length;
|
|
53
|
+
while (i--) from_parts[i] = "..";
|
|
54
|
+
return from_parts.concat(to_parts).join("/");
|
|
55
|
+
}
|
|
56
|
+
function base64_encode(bytes) {
|
|
57
|
+
if (globalThis.Buffer) {
|
|
58
|
+
return globalThis.Buffer.from(bytes).toString("base64");
|
|
59
|
+
}
|
|
60
|
+
let binary = "";
|
|
61
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
62
|
+
binary += String.fromCharCode(bytes[i]);
|
|
63
|
+
}
|
|
64
|
+
return btoa(binary);
|
|
65
|
+
}
|
|
66
|
+
function base64_decode(encoded) {
|
|
67
|
+
if (globalThis.Buffer) {
|
|
68
|
+
const buffer = globalThis.Buffer.from(encoded, "base64");
|
|
69
|
+
return new Uint8Array(buffer);
|
|
70
|
+
}
|
|
71
|
+
const binary = atob(encoded);
|
|
72
|
+
const bytes = new Uint8Array(binary.length);
|
|
73
|
+
for (let i = 0; i < binary.length; i++) {
|
|
74
|
+
bytes[i] = binary.charCodeAt(i);
|
|
75
|
+
}
|
|
76
|
+
return bytes;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const BROWSER = false;
|
|
80
|
+
|
|
81
|
+
let tracing_mode_flag = false;
|
|
82
|
+
function effect_update_depth_exceeded() {
|
|
83
|
+
{
|
|
84
|
+
throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function hydration_failed() {
|
|
88
|
+
{
|
|
89
|
+
throw new Error(`https://svelte.dev/e/hydration_failed`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function state_descriptors_fixed() {
|
|
93
|
+
{
|
|
94
|
+
throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function state_prototype_fixed() {
|
|
98
|
+
{
|
|
99
|
+
throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function state_unsafe_mutation() {
|
|
103
|
+
{
|
|
104
|
+
throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function svelte_boundary_reset_onerror() {
|
|
108
|
+
{
|
|
109
|
+
throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function derived_inert() {
|
|
113
|
+
{
|
|
114
|
+
console.warn(`https://svelte.dev/e/derived_inert`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function hydration_mismatch(location) {
|
|
118
|
+
{
|
|
119
|
+
console.warn(`https://svelte.dev/e/hydration_mismatch`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function svelte_boundary_reset_noop() {
|
|
123
|
+
{
|
|
124
|
+
console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let hydrating = false;
|
|
128
|
+
function set_hydrating(value) {
|
|
129
|
+
hydrating = value;
|
|
130
|
+
}
|
|
131
|
+
let hydrate_node;
|
|
132
|
+
function set_hydrate_node(node) {
|
|
133
|
+
if (node === null) {
|
|
134
|
+
hydration_mismatch();
|
|
135
|
+
throw HYDRATION_ERROR;
|
|
136
|
+
}
|
|
137
|
+
return hydrate_node = node;
|
|
138
|
+
}
|
|
139
|
+
function hydrate_next() {
|
|
140
|
+
return set_hydrate_node(/* @__PURE__ */ get_next_sibling(hydrate_node));
|
|
141
|
+
}
|
|
142
|
+
function next(count = 1) {
|
|
143
|
+
if (hydrating) {
|
|
144
|
+
var i = count;
|
|
145
|
+
var node = hydrate_node;
|
|
146
|
+
while (i--) {
|
|
147
|
+
node = /** @type {TemplateNode} */
|
|
148
|
+
/* @__PURE__ */ get_next_sibling(node);
|
|
149
|
+
}
|
|
150
|
+
hydrate_node = node;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function skip_nodes(remove = true) {
|
|
154
|
+
var depth = 0;
|
|
155
|
+
var node = hydrate_node;
|
|
156
|
+
while (true) {
|
|
157
|
+
if (node.nodeType === COMMENT_NODE) {
|
|
158
|
+
var data = (
|
|
159
|
+
/** @type {Comment} */
|
|
160
|
+
node.data
|
|
161
|
+
);
|
|
162
|
+
if (data === HYDRATION_END) {
|
|
163
|
+
if (depth === 0) return node;
|
|
164
|
+
depth -= 1;
|
|
165
|
+
} else if (data === HYDRATION_START || data === HYDRATION_START_ELSE || // "[1", "[2", etc. for if blocks
|
|
166
|
+
data[0] === "[" && !isNaN(Number(data.slice(1)))) {
|
|
167
|
+
depth += 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
var next2 = (
|
|
171
|
+
/** @type {TemplateNode} */
|
|
172
|
+
/* @__PURE__ */ get_next_sibling(node)
|
|
173
|
+
);
|
|
174
|
+
if (remove) node.remove();
|
|
175
|
+
node = next2;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function equals(value) {
|
|
179
|
+
return value === this.v;
|
|
180
|
+
}
|
|
181
|
+
function safe_not_equal(a, b) {
|
|
182
|
+
return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
|
|
183
|
+
}
|
|
184
|
+
function safe_equals(value) {
|
|
185
|
+
return !safe_not_equal(value, this.v);
|
|
186
|
+
}
|
|
187
|
+
let component_context = null;
|
|
188
|
+
function set_component_context(context) {
|
|
189
|
+
component_context = context;
|
|
190
|
+
}
|
|
191
|
+
function push(props, runes = false, fn) {
|
|
192
|
+
component_context = {
|
|
193
|
+
p: component_context,
|
|
194
|
+
i: false,
|
|
195
|
+
c: null,
|
|
196
|
+
e: null,
|
|
197
|
+
s: props,
|
|
198
|
+
x: null,
|
|
199
|
+
r: (
|
|
200
|
+
/** @type {Effect} */
|
|
201
|
+
active_effect
|
|
202
|
+
),
|
|
203
|
+
l: null
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function pop(component) {
|
|
207
|
+
var context = (
|
|
208
|
+
/** @type {ComponentContext} */
|
|
209
|
+
component_context
|
|
210
|
+
);
|
|
211
|
+
var effects = context.e;
|
|
212
|
+
if (effects !== null) {
|
|
213
|
+
context.e = null;
|
|
214
|
+
for (var fn of effects) {
|
|
215
|
+
create_user_effect(fn);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
context.i = true;
|
|
219
|
+
component_context = context.p;
|
|
220
|
+
return (
|
|
221
|
+
/** @type {T} */
|
|
222
|
+
{}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
function is_runes() {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
let micro_tasks = [];
|
|
229
|
+
function run_micro_tasks() {
|
|
230
|
+
var tasks = micro_tasks;
|
|
231
|
+
micro_tasks = [];
|
|
232
|
+
run_all(tasks);
|
|
233
|
+
}
|
|
234
|
+
function queue_micro_task(fn) {
|
|
235
|
+
if (micro_tasks.length === 0 && !is_flushing_sync) {
|
|
236
|
+
var tasks = micro_tasks;
|
|
237
|
+
queueMicrotask(() => {
|
|
238
|
+
if (tasks === micro_tasks) run_micro_tasks();
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
micro_tasks.push(fn);
|
|
242
|
+
}
|
|
243
|
+
function flush_tasks() {
|
|
244
|
+
while (micro_tasks.length > 0) {
|
|
245
|
+
run_micro_tasks();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function handle_error(error) {
|
|
249
|
+
var effect = active_effect;
|
|
250
|
+
if (effect === null) {
|
|
251
|
+
active_reaction.f |= ERROR_VALUE;
|
|
252
|
+
return error;
|
|
253
|
+
}
|
|
254
|
+
if ((effect.f & REACTION_RAN) === 0 && (effect.f & EFFECT) === 0) {
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
invoke_error_boundary(error, effect);
|
|
258
|
+
}
|
|
259
|
+
function invoke_error_boundary(error, effect) {
|
|
260
|
+
while (effect !== null) {
|
|
261
|
+
if ((effect.f & BOUNDARY_EFFECT) !== 0) {
|
|
262
|
+
if ((effect.f & REACTION_RAN) === 0) {
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
effect.b.error(error);
|
|
267
|
+
return;
|
|
268
|
+
} catch (e) {
|
|
269
|
+
error = e;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
effect = effect.parent;
|
|
273
|
+
}
|
|
274
|
+
throw error;
|
|
275
|
+
}
|
|
276
|
+
const STATUS_MASK = -7169;
|
|
277
|
+
function set_signal_status(signal, status) {
|
|
278
|
+
signal.f = signal.f & STATUS_MASK | status;
|
|
279
|
+
}
|
|
280
|
+
function update_derived_status(derived2) {
|
|
281
|
+
if ((derived2.f & CONNECTED) !== 0 || derived2.deps === null) {
|
|
282
|
+
set_signal_status(derived2, CLEAN);
|
|
283
|
+
} else {
|
|
284
|
+
set_signal_status(derived2, MAYBE_DIRTY);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function clear_marked(deps) {
|
|
288
|
+
if (deps === null) return;
|
|
289
|
+
for (const dep of deps) {
|
|
290
|
+
if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
dep.f ^= WAS_MARKED;
|
|
294
|
+
clear_marked(
|
|
295
|
+
/** @type {Derived} */
|
|
296
|
+
dep.deps
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
|
|
301
|
+
if ((effect.f & DIRTY) !== 0) {
|
|
302
|
+
dirty_effects.add(effect);
|
|
303
|
+
} else if ((effect.f & MAYBE_DIRTY) !== 0) {
|
|
304
|
+
maybe_dirty_effects.add(effect);
|
|
305
|
+
}
|
|
306
|
+
clear_marked(effect.deps);
|
|
307
|
+
set_signal_status(effect, CLEAN);
|
|
308
|
+
}
|
|
309
|
+
let first_batch = null;
|
|
310
|
+
let last_batch = null;
|
|
311
|
+
let current_batch = null;
|
|
312
|
+
let previous_batch = null;
|
|
313
|
+
let batch_values = null;
|
|
314
|
+
let last_scheduled_effect = null;
|
|
315
|
+
let is_flushing_sync = false;
|
|
316
|
+
let is_processing = false;
|
|
317
|
+
let collected_effects = null;
|
|
318
|
+
let legacy_updates = null;
|
|
319
|
+
var flush_count = 0;
|
|
320
|
+
let uid = 1;
|
|
321
|
+
class Batch {
|
|
322
|
+
id = uid++;
|
|
323
|
+
/** True as soon as `#process` was called */
|
|
324
|
+
#started = false;
|
|
325
|
+
linked = true;
|
|
326
|
+
/** @type {Batch | null} */
|
|
327
|
+
#prev = null;
|
|
328
|
+
/** @type {Batch | null} */
|
|
329
|
+
#next = null;
|
|
330
|
+
/** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
|
|
331
|
+
async_deriveds = /* @__PURE__ */ new Map();
|
|
332
|
+
/**
|
|
333
|
+
* The current values of any signals that are updated in this batch.
|
|
334
|
+
* Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
|
|
335
|
+
* They keys of this map are identical to `this.#previous`
|
|
336
|
+
* @type {Map<Value, [any, boolean]>}
|
|
337
|
+
*/
|
|
338
|
+
current = /* @__PURE__ */ new Map();
|
|
339
|
+
/**
|
|
340
|
+
* The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
|
|
341
|
+
* They keys of this map are identical to `this.#current`
|
|
342
|
+
* @type {Map<Value, any>}
|
|
343
|
+
*/
|
|
344
|
+
previous = /* @__PURE__ */ new Map();
|
|
345
|
+
/**
|
|
346
|
+
* Async effects which this batch doesn't take into account anymore when calculating blockers,
|
|
347
|
+
* as it has a value for it already.
|
|
348
|
+
* @type {Set<Effect>}
|
|
349
|
+
*/
|
|
350
|
+
unblocked = /* @__PURE__ */ new Set();
|
|
351
|
+
/**
|
|
352
|
+
* When the batch is committed (and the DOM is updated), we need to remove old branches
|
|
353
|
+
* and append new ones by calling the functions added inside (if/each/key/etc) blocks
|
|
354
|
+
* @type {Set<(batch: Batch) => void>}
|
|
355
|
+
*/
|
|
356
|
+
#commit_callbacks = /* @__PURE__ */ new Set();
|
|
357
|
+
/**
|
|
358
|
+
* If a fork is discarded, we need to destroy any effects that are no longer needed
|
|
359
|
+
* @type {Set<(batch: Batch) => void>}
|
|
360
|
+
*/
|
|
361
|
+
#discard_callbacks = /* @__PURE__ */ new Set();
|
|
362
|
+
/**
|
|
363
|
+
* Callbacks that should run only when a fork is committed.
|
|
364
|
+
* @type {Set<(batch: Batch) => void>}
|
|
365
|
+
*/
|
|
366
|
+
#fork_commit_callbacks = /* @__PURE__ */ new Set();
|
|
367
|
+
/**
|
|
368
|
+
* The number of async effects that are currently in flight
|
|
369
|
+
*/
|
|
370
|
+
#pending = 0;
|
|
371
|
+
/**
|
|
372
|
+
* Async effects that are currently in flight, _not_ inside a pending boundary
|
|
373
|
+
* @type {Map<Effect, number>}
|
|
374
|
+
*/
|
|
375
|
+
#blocking_pending = /* @__PURE__ */ new Map();
|
|
376
|
+
/**
|
|
377
|
+
* A deferred that resolves when the batch is committed, used with `settled()`
|
|
378
|
+
* TODO replace with Promise.withResolvers once supported widely enough
|
|
379
|
+
* @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
|
|
380
|
+
*/
|
|
381
|
+
#deferred = null;
|
|
382
|
+
/**
|
|
383
|
+
* The root effects that need to be flushed
|
|
384
|
+
* @type {Effect[]}
|
|
385
|
+
*/
|
|
386
|
+
#roots = [];
|
|
387
|
+
/**
|
|
388
|
+
* Effects created while this batch was active.
|
|
389
|
+
* @type {Effect[]}
|
|
390
|
+
*/
|
|
391
|
+
#new_effects = [];
|
|
392
|
+
/**
|
|
393
|
+
* Deferred effects (which run after async work has completed) that are DIRTY
|
|
394
|
+
* @type {Set<Effect>}
|
|
395
|
+
*/
|
|
396
|
+
#dirty_effects = /* @__PURE__ */ new Set();
|
|
397
|
+
/**
|
|
398
|
+
* Deferred effects that are MAYBE_DIRTY
|
|
399
|
+
* @type {Set<Effect>}
|
|
400
|
+
*/
|
|
401
|
+
#maybe_dirty_effects = /* @__PURE__ */ new Set();
|
|
402
|
+
/**
|
|
403
|
+
* A map of branches that still exist, but will be destroyed when this batch
|
|
404
|
+
* is committed — we skip over these during `process`.
|
|
405
|
+
* The value contains child effects that were dirty/maybe_dirty before being reset,
|
|
406
|
+
* so they can be rescheduled if the branch survives.
|
|
407
|
+
* @type {Map<Effect, { d: Effect[], m: Effect[] }>}
|
|
408
|
+
*/
|
|
409
|
+
#skipped_branches = /* @__PURE__ */ new Map();
|
|
410
|
+
/**
|
|
411
|
+
* Inverse of #skipped_branches which we need to tell prior batches to unskip them when committing
|
|
412
|
+
* @type {Set<Effect>}
|
|
413
|
+
*/
|
|
414
|
+
#unskipped_branches = /* @__PURE__ */ new Set();
|
|
415
|
+
is_fork = false;
|
|
416
|
+
#decrement_queued = false;
|
|
417
|
+
#is_deferred() {
|
|
418
|
+
if (this.is_fork) return true;
|
|
419
|
+
for (const effect of this.#blocking_pending.keys()) {
|
|
420
|
+
var e = effect;
|
|
421
|
+
var skipped = false;
|
|
422
|
+
while (e.parent !== null) {
|
|
423
|
+
if (this.#skipped_branches.has(e)) {
|
|
424
|
+
skipped = true;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
e = e.parent;
|
|
428
|
+
}
|
|
429
|
+
if (!skipped) {
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Add an effect to the #skipped_branches map and reset its children
|
|
437
|
+
* @param {Effect} effect
|
|
438
|
+
*/
|
|
439
|
+
skip_effect(effect) {
|
|
440
|
+
if (!this.#skipped_branches.has(effect)) {
|
|
441
|
+
this.#skipped_branches.set(effect, { d: [], m: [] });
|
|
442
|
+
}
|
|
443
|
+
this.#unskipped_branches.delete(effect);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Remove an effect from the #skipped_branches map and reschedule
|
|
447
|
+
* any tracked dirty/maybe_dirty child effects
|
|
448
|
+
* @param {Effect} effect
|
|
449
|
+
* @param {(e: Effect) => void} callback
|
|
450
|
+
*/
|
|
451
|
+
unskip_effect(effect, callback = (e) => this.schedule(e)) {
|
|
452
|
+
var tracked = this.#skipped_branches.get(effect);
|
|
453
|
+
if (tracked) {
|
|
454
|
+
this.#skipped_branches.delete(effect);
|
|
455
|
+
for (var e of tracked.d) {
|
|
456
|
+
set_signal_status(e, DIRTY);
|
|
457
|
+
callback(e);
|
|
458
|
+
}
|
|
459
|
+
for (e of tracked.m) {
|
|
460
|
+
set_signal_status(e, MAYBE_DIRTY);
|
|
461
|
+
callback(e);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
this.#unskipped_branches.add(effect);
|
|
465
|
+
}
|
|
466
|
+
#process() {
|
|
467
|
+
this.#started = true;
|
|
468
|
+
if (flush_count++ > 1e3) {
|
|
469
|
+
this.#unlink();
|
|
470
|
+
infinite_loop_guard();
|
|
471
|
+
}
|
|
472
|
+
if (!this.#is_deferred()) {
|
|
473
|
+
for (const e of this.#dirty_effects) {
|
|
474
|
+
this.#maybe_dirty_effects.delete(e);
|
|
475
|
+
set_signal_status(e, DIRTY);
|
|
476
|
+
this.schedule(e);
|
|
477
|
+
}
|
|
478
|
+
for (const e of this.#maybe_dirty_effects) {
|
|
479
|
+
set_signal_status(e, MAYBE_DIRTY);
|
|
480
|
+
this.schedule(e);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
const roots = this.#roots;
|
|
484
|
+
this.#roots = [];
|
|
485
|
+
this.apply();
|
|
486
|
+
var effects = collected_effects = [];
|
|
487
|
+
var render_effects = [];
|
|
488
|
+
var updates = legacy_updates = [];
|
|
489
|
+
for (const root2 of roots) {
|
|
490
|
+
try {
|
|
491
|
+
this.#traverse(root2, effects, render_effects);
|
|
492
|
+
} catch (e) {
|
|
493
|
+
reset_all(root2);
|
|
494
|
+
throw e;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
current_batch = null;
|
|
498
|
+
if (updates.length > 0) {
|
|
499
|
+
var batch = Batch.ensure();
|
|
500
|
+
for (const e of updates) {
|
|
501
|
+
batch.schedule(e);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
collected_effects = null;
|
|
505
|
+
legacy_updates = null;
|
|
506
|
+
if (this.#is_deferred()) {
|
|
507
|
+
this.#defer_effects(render_effects);
|
|
508
|
+
this.#defer_effects(effects);
|
|
509
|
+
for (const [e, t] of this.#skipped_branches) {
|
|
510
|
+
reset_branch(e, t);
|
|
511
|
+
}
|
|
512
|
+
if (updates.length > 0) {
|
|
513
|
+
/** @type {unknown} */
|
|
514
|
+
current_batch.#process();
|
|
515
|
+
}
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const earlier_batch = this.#find_earlier_batch();
|
|
519
|
+
if (earlier_batch) {
|
|
520
|
+
earlier_batch.#merge(this);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
this.#dirty_effects.clear();
|
|
524
|
+
this.#maybe_dirty_effects.clear();
|
|
525
|
+
for (const fn of this.#commit_callbacks) fn(this);
|
|
526
|
+
this.#commit_callbacks.clear();
|
|
527
|
+
previous_batch = this;
|
|
528
|
+
flush_queued_effects(render_effects);
|
|
529
|
+
flush_queued_effects(effects);
|
|
530
|
+
previous_batch = null;
|
|
531
|
+
this.#deferred?.resolve();
|
|
532
|
+
var next_batch = (
|
|
533
|
+
/** @type {Batch | null} */
|
|
534
|
+
/** @type {unknown} */
|
|
535
|
+
current_batch
|
|
536
|
+
);
|
|
537
|
+
if (this.linked && this.#pending === 0) {
|
|
538
|
+
this.#unlink();
|
|
539
|
+
}
|
|
540
|
+
if (this.#roots.length > 0) {
|
|
541
|
+
if (next_batch === null) {
|
|
542
|
+
next_batch = this;
|
|
543
|
+
this.#link();
|
|
544
|
+
}
|
|
545
|
+
const batch2 = next_batch;
|
|
546
|
+
batch2.#roots.push(...this.#roots.filter((r) => !batch2.#roots.includes(r)));
|
|
547
|
+
}
|
|
548
|
+
if (next_batch !== null) {
|
|
549
|
+
next_batch.#process();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Traverse the effect tree, executing effects or stashing
|
|
554
|
+
* them for later execution as appropriate
|
|
555
|
+
* @param {Effect} root
|
|
556
|
+
* @param {Effect[]} effects
|
|
557
|
+
* @param {Effect[]} render_effects
|
|
558
|
+
*/
|
|
559
|
+
#traverse(root2, effects, render_effects) {
|
|
560
|
+
root2.f ^= CLEAN;
|
|
561
|
+
var effect = root2.first;
|
|
562
|
+
while (effect !== null) {
|
|
563
|
+
var flags2 = effect.f;
|
|
564
|
+
var is_branch = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
|
|
565
|
+
var is_skippable_branch = is_branch && (flags2 & CLEAN) !== 0;
|
|
566
|
+
var skip = is_skippable_branch || (flags2 & INERT) !== 0 || this.#skipped_branches.has(effect);
|
|
567
|
+
if (!skip && effect.fn !== null) {
|
|
568
|
+
if (is_branch) {
|
|
569
|
+
effect.f ^= CLEAN;
|
|
570
|
+
} else if ((flags2 & EFFECT) !== 0) {
|
|
571
|
+
effects.push(effect);
|
|
572
|
+
} else if (is_dirty(effect)) {
|
|
573
|
+
if ((flags2 & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
|
|
574
|
+
update_effect(effect);
|
|
575
|
+
}
|
|
576
|
+
var child = effect.first;
|
|
577
|
+
if (child !== null) {
|
|
578
|
+
effect = child;
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
while (effect !== null) {
|
|
583
|
+
var next2 = effect.next;
|
|
584
|
+
if (next2 !== null) {
|
|
585
|
+
effect = next2;
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
effect = effect.parent;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
#find_earlier_batch() {
|
|
593
|
+
var batch = this.#prev;
|
|
594
|
+
while (batch !== null) {
|
|
595
|
+
if (!batch.is_fork) {
|
|
596
|
+
for (const [value, [, is_derived]] of this.current) {
|
|
597
|
+
if (batch.current.has(value) && !is_derived) {
|
|
598
|
+
return batch;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
batch = batch.#prev;
|
|
603
|
+
}
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* @param {Batch} batch
|
|
608
|
+
*/
|
|
609
|
+
#merge(batch) {
|
|
610
|
+
for (const [source2, value] of batch.current) {
|
|
611
|
+
if (!this.previous.has(source2) && batch.previous.has(source2)) {
|
|
612
|
+
this.previous.set(source2, batch.previous.get(source2));
|
|
613
|
+
}
|
|
614
|
+
this.current.set(source2, value);
|
|
615
|
+
}
|
|
616
|
+
for (const [effect, deferred2] of batch.async_deriveds) {
|
|
617
|
+
const d = this.async_deriveds.get(effect);
|
|
618
|
+
if (d) deferred2.promise.then(d.resolve);
|
|
619
|
+
}
|
|
620
|
+
const mark = (value) => {
|
|
621
|
+
var reactions = value.reactions;
|
|
622
|
+
if (reactions === null) return;
|
|
623
|
+
for (const reaction of reactions) {
|
|
624
|
+
var flags2 = reaction.f;
|
|
625
|
+
if ((flags2 & DERIVED) !== 0) {
|
|
626
|
+
mark(
|
|
627
|
+
/** @type {Derived} */
|
|
628
|
+
reaction
|
|
629
|
+
);
|
|
630
|
+
} else {
|
|
631
|
+
var effect = (
|
|
632
|
+
/** @type {Effect} */
|
|
633
|
+
reaction
|
|
634
|
+
);
|
|
635
|
+
if (flags2 & (ASYNC | BLOCK_EFFECT) && !this.async_deriveds.has(effect)) {
|
|
636
|
+
this.#maybe_dirty_effects.delete(effect);
|
|
637
|
+
set_signal_status(effect, DIRTY);
|
|
638
|
+
this.schedule(effect);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
for (const source2 of this.current.keys()) {
|
|
644
|
+
mark(source2);
|
|
645
|
+
}
|
|
646
|
+
this.oncommit(() => batch.discard());
|
|
647
|
+
batch.#unlink();
|
|
648
|
+
current_batch = this;
|
|
649
|
+
this.#process();
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* @param {Effect[]} effects
|
|
653
|
+
*/
|
|
654
|
+
#defer_effects(effects) {
|
|
655
|
+
for (var i = 0; i < effects.length; i += 1) {
|
|
656
|
+
defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Associate a change to a given source with the current
|
|
661
|
+
* batch, noting its previous and current values
|
|
662
|
+
* @param {Value} source
|
|
663
|
+
* @param {any} value
|
|
664
|
+
* @param {boolean} [is_derived]
|
|
665
|
+
*/
|
|
666
|
+
capture(source2, value, is_derived = false) {
|
|
667
|
+
if (source2.v !== UNINITIALIZED && !this.previous.has(source2)) {
|
|
668
|
+
this.previous.set(source2, source2.v);
|
|
669
|
+
}
|
|
670
|
+
if ((source2.f & ERROR_VALUE) === 0) {
|
|
671
|
+
this.current.set(source2, [value, is_derived]);
|
|
672
|
+
batch_values?.set(source2, value);
|
|
673
|
+
}
|
|
674
|
+
if (!this.is_fork) {
|
|
675
|
+
source2.v = value;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
activate() {
|
|
679
|
+
current_batch = this;
|
|
680
|
+
}
|
|
681
|
+
deactivate() {
|
|
682
|
+
current_batch = null;
|
|
683
|
+
batch_values = null;
|
|
684
|
+
}
|
|
685
|
+
flush() {
|
|
686
|
+
try {
|
|
687
|
+
if (BROWSER) ;
|
|
688
|
+
is_processing = true;
|
|
689
|
+
current_batch = this;
|
|
690
|
+
this.#process();
|
|
691
|
+
} finally {
|
|
692
|
+
flush_count = 0;
|
|
693
|
+
last_scheduled_effect = null;
|
|
694
|
+
collected_effects = null;
|
|
695
|
+
legacy_updates = null;
|
|
696
|
+
is_processing = false;
|
|
697
|
+
current_batch = null;
|
|
698
|
+
batch_values = null;
|
|
699
|
+
old_values.clear();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
discard() {
|
|
703
|
+
for (const fn of this.#discard_callbacks) fn(this);
|
|
704
|
+
this.#discard_callbacks.clear();
|
|
705
|
+
this.#fork_commit_callbacks.clear();
|
|
706
|
+
this.#unlink();
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* @param {Effect} effect
|
|
710
|
+
*/
|
|
711
|
+
register_created_effect(effect) {
|
|
712
|
+
this.#new_effects.push(effect);
|
|
713
|
+
}
|
|
714
|
+
#commit() {
|
|
715
|
+
this.#unlink();
|
|
716
|
+
for (let batch = first_batch; batch !== null; batch = batch.#next) {
|
|
717
|
+
var is_earlier = batch.id < this.id;
|
|
718
|
+
var sources = [];
|
|
719
|
+
for (const [source3, [value, is_derived]] of this.current) {
|
|
720
|
+
if (batch.current.has(source3)) {
|
|
721
|
+
var batch_value = (
|
|
722
|
+
/** @type {[any, boolean]} */
|
|
723
|
+
batch.current.get(source3)[0]
|
|
724
|
+
);
|
|
725
|
+
if (is_earlier && value !== batch_value) {
|
|
726
|
+
batch.current.set(source3, [value, is_derived]);
|
|
727
|
+
} else {
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
sources.push(source3);
|
|
732
|
+
}
|
|
733
|
+
if (is_earlier) {
|
|
734
|
+
for (const [effect, deferred2] of this.async_deriveds) {
|
|
735
|
+
const d = batch.async_deriveds.get(effect);
|
|
736
|
+
if (d) deferred2.promise.then(d.resolve);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (!batch.#started) continue;
|
|
740
|
+
var others = [...batch.current.keys()].filter((s) => !this.current.has(s));
|
|
741
|
+
if (others.length === 0) {
|
|
742
|
+
if (is_earlier) {
|
|
743
|
+
batch.discard();
|
|
744
|
+
}
|
|
745
|
+
} else if (sources.length > 0) {
|
|
746
|
+
if (is_earlier) {
|
|
747
|
+
for (const unskipped of this.#unskipped_branches) {
|
|
748
|
+
batch.unskip_effect(unskipped, (e) => {
|
|
749
|
+
if ((e.f & (BLOCK_EFFECT | ASYNC)) !== 0) {
|
|
750
|
+
batch.schedule(e);
|
|
751
|
+
} else {
|
|
752
|
+
batch.#defer_effects([e]);
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
batch.activate();
|
|
758
|
+
var marked = /* @__PURE__ */ new Set();
|
|
759
|
+
var checked = /* @__PURE__ */ new Map();
|
|
760
|
+
for (var source2 of sources) {
|
|
761
|
+
mark_effects(source2, others, marked, checked);
|
|
762
|
+
}
|
|
763
|
+
checked = /* @__PURE__ */ new Map();
|
|
764
|
+
var current_unequal = [...batch.current.keys()].filter(
|
|
765
|
+
(c) => this.current.has(c) ? (
|
|
766
|
+
/** @type {[any, boolean]} */
|
|
767
|
+
this.current.get(c)[0] !== c.v
|
|
768
|
+
) : true
|
|
769
|
+
);
|
|
770
|
+
if (current_unequal.length > 0) {
|
|
771
|
+
for (const effect of this.#new_effects) {
|
|
772
|
+
if ((effect.f & (DESTROYED | INERT | EAGER_EFFECT)) === 0 && depends_on(effect, current_unequal, checked)) {
|
|
773
|
+
if ((effect.f & (ASYNC | BLOCK_EFFECT)) !== 0) {
|
|
774
|
+
set_signal_status(effect, DIRTY);
|
|
775
|
+
batch.schedule(effect);
|
|
776
|
+
} else {
|
|
777
|
+
batch.#dirty_effects.add(effect);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (batch.#roots.length > 0) {
|
|
783
|
+
batch.apply();
|
|
784
|
+
for (var root2 of batch.#roots) {
|
|
785
|
+
batch.#traverse(root2, [], []);
|
|
786
|
+
}
|
|
787
|
+
batch.#roots = [];
|
|
788
|
+
}
|
|
789
|
+
batch.deactivate();
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* @param {boolean} blocking
|
|
795
|
+
* @param {Effect} effect
|
|
796
|
+
*/
|
|
797
|
+
increment(blocking, effect) {
|
|
798
|
+
this.#pending += 1;
|
|
799
|
+
if (blocking) {
|
|
800
|
+
let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
|
|
801
|
+
this.#blocking_pending.set(effect, blocking_pending_count + 1);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* @param {boolean} blocking
|
|
806
|
+
* @param {Effect} effect
|
|
807
|
+
*/
|
|
808
|
+
decrement(blocking, effect) {
|
|
809
|
+
this.#pending -= 1;
|
|
810
|
+
if (blocking) {
|
|
811
|
+
let blocking_pending_count = this.#blocking_pending.get(effect) ?? 0;
|
|
812
|
+
if (blocking_pending_count === 1) {
|
|
813
|
+
this.#blocking_pending.delete(effect);
|
|
814
|
+
} else {
|
|
815
|
+
this.#blocking_pending.set(effect, blocking_pending_count - 1);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if (this.#decrement_queued) return;
|
|
819
|
+
this.#decrement_queued = true;
|
|
820
|
+
queue_micro_task(() => {
|
|
821
|
+
this.#decrement_queued = false;
|
|
822
|
+
if (this.linked) {
|
|
823
|
+
this.flush();
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* @param {Set<Effect>} dirty_effects
|
|
829
|
+
* @param {Set<Effect>} maybe_dirty_effects
|
|
830
|
+
*/
|
|
831
|
+
transfer_effects(dirty_effects, maybe_dirty_effects) {
|
|
832
|
+
for (const e of dirty_effects) {
|
|
833
|
+
this.#dirty_effects.add(e);
|
|
834
|
+
}
|
|
835
|
+
for (const e of maybe_dirty_effects) {
|
|
836
|
+
this.#maybe_dirty_effects.add(e);
|
|
837
|
+
}
|
|
838
|
+
dirty_effects.clear();
|
|
839
|
+
maybe_dirty_effects.clear();
|
|
840
|
+
}
|
|
841
|
+
/** @param {(batch: Batch) => void} fn */
|
|
842
|
+
oncommit(fn) {
|
|
843
|
+
this.#commit_callbacks.add(fn);
|
|
844
|
+
}
|
|
845
|
+
/** @param {(batch: Batch) => void} fn */
|
|
846
|
+
ondiscard(fn) {
|
|
847
|
+
this.#discard_callbacks.add(fn);
|
|
848
|
+
}
|
|
849
|
+
/** @param {(batch: Batch) => void} fn */
|
|
850
|
+
on_fork_commit(fn) {
|
|
851
|
+
this.#fork_commit_callbacks.add(fn);
|
|
852
|
+
}
|
|
853
|
+
run_fork_commit_callbacks() {
|
|
854
|
+
for (const fn of this.#fork_commit_callbacks) fn(this);
|
|
855
|
+
this.#fork_commit_callbacks.clear();
|
|
856
|
+
}
|
|
857
|
+
settled() {
|
|
858
|
+
return (this.#deferred ??= deferred()).promise;
|
|
859
|
+
}
|
|
860
|
+
static ensure() {
|
|
861
|
+
if (current_batch === null) {
|
|
862
|
+
const batch = current_batch = new Batch();
|
|
863
|
+
batch.#link();
|
|
864
|
+
if (!is_processing && !is_flushing_sync) {
|
|
865
|
+
queue_micro_task(() => {
|
|
866
|
+
if (!batch.#started) {
|
|
867
|
+
batch.flush();
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return current_batch;
|
|
873
|
+
}
|
|
874
|
+
apply() {
|
|
875
|
+
{
|
|
876
|
+
batch_values = null;
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
*
|
|
882
|
+
* @param {Effect} effect
|
|
883
|
+
*/
|
|
884
|
+
schedule(effect) {
|
|
885
|
+
last_scheduled_effect = effect;
|
|
886
|
+
if (effect.b?.is_pending && (effect.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && (effect.f & REACTION_RAN) === 0) {
|
|
887
|
+
effect.b.defer_effect(effect);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
var e = effect;
|
|
891
|
+
while (e.parent !== null) {
|
|
892
|
+
e = e.parent;
|
|
893
|
+
var flags2 = e.f;
|
|
894
|
+
if (collected_effects !== null && e === active_effect) {
|
|
895
|
+
if ((active_reaction === null || (active_reaction.f & DERIVED) === 0) && true) {
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
if ((flags2 & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
|
|
900
|
+
if ((flags2 & CLEAN) === 0) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
e.f ^= CLEAN;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
this.#roots.push(e);
|
|
907
|
+
}
|
|
908
|
+
#link() {
|
|
909
|
+
if (last_batch === null) {
|
|
910
|
+
first_batch = last_batch = this;
|
|
911
|
+
} else {
|
|
912
|
+
last_batch.#next = this;
|
|
913
|
+
this.#prev = last_batch;
|
|
914
|
+
}
|
|
915
|
+
last_batch = this;
|
|
916
|
+
}
|
|
917
|
+
#unlink() {
|
|
918
|
+
var prev = this.#prev;
|
|
919
|
+
var next2 = this.#next;
|
|
920
|
+
if (prev === null) {
|
|
921
|
+
first_batch = next2;
|
|
922
|
+
} else {
|
|
923
|
+
prev.#next = next2;
|
|
924
|
+
}
|
|
925
|
+
if (next2 === null) {
|
|
926
|
+
last_batch = prev;
|
|
927
|
+
} else {
|
|
928
|
+
next2.#prev = prev;
|
|
929
|
+
}
|
|
930
|
+
this.linked = false;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
function flushSync(fn) {
|
|
934
|
+
var was_flushing_sync = is_flushing_sync;
|
|
935
|
+
is_flushing_sync = true;
|
|
936
|
+
try {
|
|
937
|
+
var result;
|
|
938
|
+
if (fn) ;
|
|
939
|
+
while (true) {
|
|
940
|
+
flush_tasks();
|
|
941
|
+
if (current_batch === null) {
|
|
942
|
+
return (
|
|
943
|
+
/** @type {T} */
|
|
944
|
+
result
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
current_batch.flush();
|
|
948
|
+
}
|
|
949
|
+
} finally {
|
|
950
|
+
is_flushing_sync = was_flushing_sync;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function infinite_loop_guard() {
|
|
954
|
+
try {
|
|
955
|
+
effect_update_depth_exceeded();
|
|
956
|
+
} catch (error) {
|
|
957
|
+
invoke_error_boundary(error, last_scheduled_effect);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
let eager_block_effects = null;
|
|
961
|
+
function flush_queued_effects(effects) {
|
|
962
|
+
var length = effects.length;
|
|
963
|
+
if (length === 0) return;
|
|
964
|
+
var i = 0;
|
|
965
|
+
while (i < length) {
|
|
966
|
+
var effect = effects[i++];
|
|
967
|
+
if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
|
|
968
|
+
eager_block_effects = /* @__PURE__ */ new Set();
|
|
969
|
+
update_effect(effect);
|
|
970
|
+
if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) {
|
|
971
|
+
unlink_effect(effect);
|
|
972
|
+
}
|
|
973
|
+
if (eager_block_effects?.size > 0) {
|
|
974
|
+
old_values.clear();
|
|
975
|
+
for (const e of eager_block_effects) {
|
|
976
|
+
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
|
|
977
|
+
const ordered_effects = [e];
|
|
978
|
+
let ancestor = e.parent;
|
|
979
|
+
while (ancestor !== null) {
|
|
980
|
+
if (eager_block_effects.has(ancestor)) {
|
|
981
|
+
eager_block_effects.delete(ancestor);
|
|
982
|
+
ordered_effects.push(ancestor);
|
|
983
|
+
}
|
|
984
|
+
ancestor = ancestor.parent;
|
|
985
|
+
}
|
|
986
|
+
for (let j = ordered_effects.length - 1; j >= 0; j--) {
|
|
987
|
+
const e2 = ordered_effects[j];
|
|
988
|
+
if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
|
|
989
|
+
update_effect(e2);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
eager_block_effects.clear();
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
eager_block_effects = null;
|
|
997
|
+
}
|
|
998
|
+
function mark_effects(value, sources, marked, checked) {
|
|
999
|
+
if (marked.has(value)) return;
|
|
1000
|
+
marked.add(value);
|
|
1001
|
+
if (value.reactions !== null) {
|
|
1002
|
+
for (const reaction of value.reactions) {
|
|
1003
|
+
const flags2 = reaction.f;
|
|
1004
|
+
if ((flags2 & DERIVED) !== 0) {
|
|
1005
|
+
mark_effects(
|
|
1006
|
+
/** @type {Derived} */
|
|
1007
|
+
reaction,
|
|
1008
|
+
sources,
|
|
1009
|
+
marked,
|
|
1010
|
+
checked
|
|
1011
|
+
);
|
|
1012
|
+
} else if ((flags2 & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags2 & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
|
|
1013
|
+
set_signal_status(reaction, DIRTY);
|
|
1014
|
+
schedule_effect(
|
|
1015
|
+
/** @type {Effect} */
|
|
1016
|
+
reaction
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
function depends_on(reaction, sources, checked) {
|
|
1023
|
+
const depends = checked.get(reaction);
|
|
1024
|
+
if (depends !== void 0) return depends;
|
|
1025
|
+
if (reaction.deps !== null) {
|
|
1026
|
+
for (const dep of reaction.deps) {
|
|
1027
|
+
if (includes.call(sources, dep)) {
|
|
1028
|
+
return true;
|
|
1029
|
+
}
|
|
1030
|
+
if ((dep.f & DERIVED) !== 0 && depends_on(
|
|
1031
|
+
/** @type {Derived} */
|
|
1032
|
+
dep,
|
|
1033
|
+
sources,
|
|
1034
|
+
checked
|
|
1035
|
+
)) {
|
|
1036
|
+
checked.set(
|
|
1037
|
+
/** @type {Derived} */
|
|
1038
|
+
dep,
|
|
1039
|
+
true
|
|
1040
|
+
);
|
|
1041
|
+
return true;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
checked.set(reaction, false);
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
function schedule_effect(effect) {
|
|
1049
|
+
current_batch.schedule(effect);
|
|
1050
|
+
}
|
|
1051
|
+
function reset_branch(effect, tracked) {
|
|
1052
|
+
if ((effect.f & BRANCH_EFFECT) !== 0 && (effect.f & CLEAN) !== 0) {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
if ((effect.f & DIRTY) !== 0) {
|
|
1056
|
+
tracked.d.push(effect);
|
|
1057
|
+
} else if ((effect.f & MAYBE_DIRTY) !== 0) {
|
|
1058
|
+
tracked.m.push(effect);
|
|
1059
|
+
}
|
|
1060
|
+
set_signal_status(effect, CLEAN);
|
|
1061
|
+
var e = effect.first;
|
|
1062
|
+
while (e !== null) {
|
|
1063
|
+
reset_branch(e, tracked);
|
|
1064
|
+
e = e.next;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function reset_all(effect) {
|
|
1068
|
+
set_signal_status(effect, CLEAN);
|
|
1069
|
+
var e = effect.first;
|
|
1070
|
+
while (e !== null) {
|
|
1071
|
+
reset_all(e);
|
|
1072
|
+
e = e.next;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
function createSubscriber(start) {
|
|
1076
|
+
let subscribers = 0;
|
|
1077
|
+
let version = source(0);
|
|
1078
|
+
let stop;
|
|
1079
|
+
return () => {
|
|
1080
|
+
if (effect_tracking()) {
|
|
1081
|
+
get(version);
|
|
1082
|
+
render_effect(() => {
|
|
1083
|
+
if (subscribers === 0) {
|
|
1084
|
+
stop = untrack(() => start(() => increment(version)));
|
|
1085
|
+
}
|
|
1086
|
+
subscribers += 1;
|
|
1087
|
+
return () => {
|
|
1088
|
+
queue_micro_task(() => {
|
|
1089
|
+
subscribers -= 1;
|
|
1090
|
+
if (subscribers === 0) {
|
|
1091
|
+
stop?.();
|
|
1092
|
+
stop = void 0;
|
|
1093
|
+
increment(version);
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
};
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
|
|
1102
|
+
function boundary(node, props, children, transform_error) {
|
|
1103
|
+
new Boundary(node, props, children, transform_error);
|
|
1104
|
+
}
|
|
1105
|
+
class Boundary {
|
|
1106
|
+
/** @type {Boundary | null} */
|
|
1107
|
+
parent;
|
|
1108
|
+
is_pending = false;
|
|
1109
|
+
/**
|
|
1110
|
+
* API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
|
|
1111
|
+
* Inherited from parent boundary, or defaults to identity.
|
|
1112
|
+
* @type {(error: unknown) => unknown}
|
|
1113
|
+
*/
|
|
1114
|
+
transform_error;
|
|
1115
|
+
/** @type {TemplateNode} */
|
|
1116
|
+
#anchor;
|
|
1117
|
+
/** @type {TemplateNode | null} */
|
|
1118
|
+
#hydrate_open = hydrating ? hydrate_node : null;
|
|
1119
|
+
/** @type {BoundaryProps} */
|
|
1120
|
+
#props;
|
|
1121
|
+
/** @type {((anchor: Node) => void)} */
|
|
1122
|
+
#children;
|
|
1123
|
+
/** @type {Effect} */
|
|
1124
|
+
#effect;
|
|
1125
|
+
/** @type {Effect | null} */
|
|
1126
|
+
#main_effect = null;
|
|
1127
|
+
/** @type {Effect | null} */
|
|
1128
|
+
#pending_effect = null;
|
|
1129
|
+
/** @type {Effect | null} */
|
|
1130
|
+
#failed_effect = null;
|
|
1131
|
+
/** @type {DocumentFragment | null} */
|
|
1132
|
+
#offscreen_fragment = null;
|
|
1133
|
+
#local_pending_count = 0;
|
|
1134
|
+
#pending_count = 0;
|
|
1135
|
+
#pending_count_update_queued = false;
|
|
1136
|
+
/** @type {Set<Effect>} */
|
|
1137
|
+
#dirty_effects = /* @__PURE__ */ new Set();
|
|
1138
|
+
/** @type {Set<Effect>} */
|
|
1139
|
+
#maybe_dirty_effects = /* @__PURE__ */ new Set();
|
|
1140
|
+
/**
|
|
1141
|
+
* A source containing the number of pending async deriveds/expressions.
|
|
1142
|
+
* Only created if `$effect.pending()` is used inside the boundary,
|
|
1143
|
+
* otherwise updating the source results in needless `Batch.ensure()`
|
|
1144
|
+
* calls followed by no-op flushes
|
|
1145
|
+
* @type {Source<number> | null}
|
|
1146
|
+
*/
|
|
1147
|
+
#effect_pending = null;
|
|
1148
|
+
#effect_pending_subscriber = createSubscriber(() => {
|
|
1149
|
+
this.#effect_pending = source(this.#local_pending_count);
|
|
1150
|
+
return () => {
|
|
1151
|
+
this.#effect_pending = null;
|
|
1152
|
+
};
|
|
1153
|
+
});
|
|
1154
|
+
/**
|
|
1155
|
+
* @param {TemplateNode} node
|
|
1156
|
+
* @param {BoundaryProps} props
|
|
1157
|
+
* @param {((anchor: Node) => void)} children
|
|
1158
|
+
* @param {((error: unknown) => unknown) | undefined} [transform_error]
|
|
1159
|
+
*/
|
|
1160
|
+
constructor(node, props, children, transform_error) {
|
|
1161
|
+
this.#anchor = node;
|
|
1162
|
+
this.#props = props;
|
|
1163
|
+
this.#children = (anchor) => {
|
|
1164
|
+
var effect = (
|
|
1165
|
+
/** @type {Effect} */
|
|
1166
|
+
active_effect
|
|
1167
|
+
);
|
|
1168
|
+
effect.b = this;
|
|
1169
|
+
effect.f |= BOUNDARY_EFFECT;
|
|
1170
|
+
children(anchor);
|
|
1171
|
+
};
|
|
1172
|
+
this.parent = /** @type {Effect} */
|
|
1173
|
+
active_effect.b;
|
|
1174
|
+
this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
|
|
1175
|
+
this.#effect = block(() => {
|
|
1176
|
+
if (hydrating) {
|
|
1177
|
+
const comment = (
|
|
1178
|
+
/** @type {Comment} */
|
|
1179
|
+
this.#hydrate_open
|
|
1180
|
+
);
|
|
1181
|
+
hydrate_next();
|
|
1182
|
+
const server_rendered_pending = comment.data === HYDRATION_START_ELSE;
|
|
1183
|
+
const server_rendered_failed = comment.data.startsWith(HYDRATION_START_FAILED);
|
|
1184
|
+
if (server_rendered_failed) {
|
|
1185
|
+
const serialized_error = JSON.parse(comment.data.slice(HYDRATION_START_FAILED.length));
|
|
1186
|
+
this.#hydrate_failed_content(serialized_error);
|
|
1187
|
+
} else if (server_rendered_pending) {
|
|
1188
|
+
this.#hydrate_pending_content();
|
|
1189
|
+
} else {
|
|
1190
|
+
this.#hydrate_resolved_content();
|
|
1191
|
+
}
|
|
1192
|
+
} else {
|
|
1193
|
+
this.#render();
|
|
1194
|
+
}
|
|
1195
|
+
}, flags);
|
|
1196
|
+
if (hydrating) {
|
|
1197
|
+
this.#anchor = hydrate_node;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
#hydrate_resolved_content() {
|
|
1201
|
+
try {
|
|
1202
|
+
this.#main_effect = branch(() => this.#children(this.#anchor));
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
this.error(error);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* @param {unknown} error The deserialized error from the server's hydration comment
|
|
1209
|
+
*/
|
|
1210
|
+
#hydrate_failed_content(error) {
|
|
1211
|
+
const failed = this.#props.failed;
|
|
1212
|
+
if (!failed) return;
|
|
1213
|
+
this.#failed_effect = branch(() => {
|
|
1214
|
+
failed(
|
|
1215
|
+
this.#anchor,
|
|
1216
|
+
() => error,
|
|
1217
|
+
() => () => {
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
#hydrate_pending_content() {
|
|
1223
|
+
const pending = this.#props.pending;
|
|
1224
|
+
if (!pending) return;
|
|
1225
|
+
this.is_pending = true;
|
|
1226
|
+
this.#pending_effect = branch(() => pending(this.#anchor));
|
|
1227
|
+
queue_micro_task(() => {
|
|
1228
|
+
var fragment = this.#offscreen_fragment = document.createDocumentFragment();
|
|
1229
|
+
var anchor = create_text();
|
|
1230
|
+
fragment.append(anchor);
|
|
1231
|
+
this.#main_effect = this.#run(() => {
|
|
1232
|
+
return branch(() => this.#children(anchor));
|
|
1233
|
+
});
|
|
1234
|
+
if (this.#pending_count === 0) {
|
|
1235
|
+
this.#anchor.before(fragment);
|
|
1236
|
+
this.#offscreen_fragment = null;
|
|
1237
|
+
pause_effect(
|
|
1238
|
+
/** @type {Effect} */
|
|
1239
|
+
this.#pending_effect,
|
|
1240
|
+
() => {
|
|
1241
|
+
this.#pending_effect = null;
|
|
1242
|
+
}
|
|
1243
|
+
);
|
|
1244
|
+
this.#resolve(
|
|
1245
|
+
/** @type {Batch} */
|
|
1246
|
+
current_batch
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
#render() {
|
|
1252
|
+
try {
|
|
1253
|
+
this.is_pending = this.has_pending_snippet();
|
|
1254
|
+
this.#pending_count = 0;
|
|
1255
|
+
this.#local_pending_count = 0;
|
|
1256
|
+
this.#main_effect = branch(() => {
|
|
1257
|
+
this.#children(this.#anchor);
|
|
1258
|
+
});
|
|
1259
|
+
if (this.#pending_count > 0) {
|
|
1260
|
+
var fragment = this.#offscreen_fragment = document.createDocumentFragment();
|
|
1261
|
+
move_effect(this.#main_effect, fragment);
|
|
1262
|
+
const pending = (
|
|
1263
|
+
/** @type {(anchor: Node) => void} */
|
|
1264
|
+
this.#props.pending
|
|
1265
|
+
);
|
|
1266
|
+
this.#pending_effect = branch(() => pending(this.#anchor));
|
|
1267
|
+
} else {
|
|
1268
|
+
this.#resolve(
|
|
1269
|
+
/** @type {Batch} */
|
|
1270
|
+
current_batch
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
} catch (error) {
|
|
1274
|
+
this.error(error);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* @param {Batch} batch
|
|
1279
|
+
*/
|
|
1280
|
+
#resolve(batch) {
|
|
1281
|
+
this.is_pending = false;
|
|
1282
|
+
batch.transfer_effects(this.#dirty_effects, this.#maybe_dirty_effects);
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Defer an effect inside a pending boundary until the boundary resolves
|
|
1286
|
+
* @param {Effect} effect
|
|
1287
|
+
*/
|
|
1288
|
+
defer_effect(effect) {
|
|
1289
|
+
defer_effect(effect, this.#dirty_effects, this.#maybe_dirty_effects);
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Returns `false` if the effect exists inside a boundary whose pending snippet is shown
|
|
1293
|
+
* @returns {boolean}
|
|
1294
|
+
*/
|
|
1295
|
+
is_rendered() {
|
|
1296
|
+
return !this.is_pending && (!this.parent || this.parent.is_rendered());
|
|
1297
|
+
}
|
|
1298
|
+
has_pending_snippet() {
|
|
1299
|
+
return !!this.#props.pending;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* @template T
|
|
1303
|
+
* @param {() => T} fn
|
|
1304
|
+
*/
|
|
1305
|
+
#run(fn) {
|
|
1306
|
+
var previous_effect = active_effect;
|
|
1307
|
+
var previous_reaction = active_reaction;
|
|
1308
|
+
var previous_ctx = component_context;
|
|
1309
|
+
set_active_effect(this.#effect);
|
|
1310
|
+
set_active_reaction(this.#effect);
|
|
1311
|
+
set_component_context(this.#effect.ctx);
|
|
1312
|
+
try {
|
|
1313
|
+
Batch.ensure();
|
|
1314
|
+
return fn();
|
|
1315
|
+
} catch (e) {
|
|
1316
|
+
handle_error(e);
|
|
1317
|
+
return null;
|
|
1318
|
+
} finally {
|
|
1319
|
+
set_active_effect(previous_effect);
|
|
1320
|
+
set_active_reaction(previous_reaction);
|
|
1321
|
+
set_component_context(previous_ctx);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Updates the pending count associated with the currently visible pending snippet,
|
|
1326
|
+
* if any, such that we can replace the snippet with content once work is done
|
|
1327
|
+
* @param {1 | -1} d
|
|
1328
|
+
* @param {Batch} batch
|
|
1329
|
+
*/
|
|
1330
|
+
#update_pending_count(d, batch) {
|
|
1331
|
+
if (!this.has_pending_snippet()) {
|
|
1332
|
+
if (this.parent) {
|
|
1333
|
+
this.parent.#update_pending_count(d, batch);
|
|
1334
|
+
}
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
this.#pending_count += d;
|
|
1338
|
+
if (this.#pending_count === 0) {
|
|
1339
|
+
this.#resolve(batch);
|
|
1340
|
+
if (this.#pending_effect) {
|
|
1341
|
+
pause_effect(this.#pending_effect, () => {
|
|
1342
|
+
this.#pending_effect = null;
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
if (this.#offscreen_fragment) {
|
|
1346
|
+
this.#anchor.before(this.#offscreen_fragment);
|
|
1347
|
+
this.#offscreen_fragment = null;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Update the source that powers `$effect.pending()` inside this boundary,
|
|
1353
|
+
* and controls when the current `pending` snippet (if any) is removed.
|
|
1354
|
+
* Do not call from inside the class
|
|
1355
|
+
* @param {1 | -1} d
|
|
1356
|
+
* @param {Batch} batch
|
|
1357
|
+
*/
|
|
1358
|
+
update_pending_count(d, batch) {
|
|
1359
|
+
this.#update_pending_count(d, batch);
|
|
1360
|
+
this.#local_pending_count += d;
|
|
1361
|
+
if (!this.#effect_pending || this.#pending_count_update_queued) return;
|
|
1362
|
+
this.#pending_count_update_queued = true;
|
|
1363
|
+
queue_micro_task(() => {
|
|
1364
|
+
this.#pending_count_update_queued = false;
|
|
1365
|
+
if (this.#effect_pending) {
|
|
1366
|
+
internal_set(this.#effect_pending, this.#local_pending_count);
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
get_effect_pending() {
|
|
1371
|
+
this.#effect_pending_subscriber();
|
|
1372
|
+
return get(
|
|
1373
|
+
/** @type {Source<number>} */
|
|
1374
|
+
this.#effect_pending
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
/** @param {unknown} error */
|
|
1378
|
+
error(error) {
|
|
1379
|
+
if (!this.#props.onerror && !this.#props.failed) {
|
|
1380
|
+
throw error;
|
|
1381
|
+
}
|
|
1382
|
+
if (current_batch?.is_fork) {
|
|
1383
|
+
if (this.#main_effect) current_batch.skip_effect(this.#main_effect);
|
|
1384
|
+
if (this.#pending_effect) current_batch.skip_effect(this.#pending_effect);
|
|
1385
|
+
if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect);
|
|
1386
|
+
current_batch.on_fork_commit(() => {
|
|
1387
|
+
this.#handle_error(error);
|
|
1388
|
+
});
|
|
1389
|
+
} else {
|
|
1390
|
+
this.#handle_error(error);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* @param {unknown} error
|
|
1395
|
+
*/
|
|
1396
|
+
#handle_error(error) {
|
|
1397
|
+
if (this.#main_effect) {
|
|
1398
|
+
destroy_effect(this.#main_effect);
|
|
1399
|
+
this.#main_effect = null;
|
|
1400
|
+
}
|
|
1401
|
+
if (this.#pending_effect) {
|
|
1402
|
+
destroy_effect(this.#pending_effect);
|
|
1403
|
+
this.#pending_effect = null;
|
|
1404
|
+
}
|
|
1405
|
+
if (this.#failed_effect) {
|
|
1406
|
+
destroy_effect(this.#failed_effect);
|
|
1407
|
+
this.#failed_effect = null;
|
|
1408
|
+
}
|
|
1409
|
+
if (hydrating) {
|
|
1410
|
+
set_hydrate_node(
|
|
1411
|
+
/** @type {TemplateNode} */
|
|
1412
|
+
this.#hydrate_open
|
|
1413
|
+
);
|
|
1414
|
+
next();
|
|
1415
|
+
set_hydrate_node(skip_nodes());
|
|
1416
|
+
}
|
|
1417
|
+
var onerror = this.#props.onerror;
|
|
1418
|
+
let failed = this.#props.failed;
|
|
1419
|
+
var did_reset = false;
|
|
1420
|
+
var calling_on_error = false;
|
|
1421
|
+
const reset = () => {
|
|
1422
|
+
if (did_reset) {
|
|
1423
|
+
svelte_boundary_reset_noop();
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
did_reset = true;
|
|
1427
|
+
if (calling_on_error) {
|
|
1428
|
+
svelte_boundary_reset_onerror();
|
|
1429
|
+
}
|
|
1430
|
+
if (this.#failed_effect !== null) {
|
|
1431
|
+
pause_effect(this.#failed_effect, () => {
|
|
1432
|
+
this.#failed_effect = null;
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
this.#run(() => {
|
|
1436
|
+
this.#render();
|
|
1437
|
+
});
|
|
1438
|
+
};
|
|
1439
|
+
const handle_error_result = (transformed_error) => {
|
|
1440
|
+
try {
|
|
1441
|
+
calling_on_error = true;
|
|
1442
|
+
onerror?.(transformed_error, reset);
|
|
1443
|
+
calling_on_error = false;
|
|
1444
|
+
} catch (error2) {
|
|
1445
|
+
invoke_error_boundary(error2, this.#effect && this.#effect.parent);
|
|
1446
|
+
}
|
|
1447
|
+
if (failed) {
|
|
1448
|
+
this.#failed_effect = this.#run(() => {
|
|
1449
|
+
try {
|
|
1450
|
+
return branch(() => {
|
|
1451
|
+
var effect = (
|
|
1452
|
+
/** @type {Effect} */
|
|
1453
|
+
active_effect
|
|
1454
|
+
);
|
|
1455
|
+
effect.b = this;
|
|
1456
|
+
effect.f |= BOUNDARY_EFFECT;
|
|
1457
|
+
failed(
|
|
1458
|
+
this.#anchor,
|
|
1459
|
+
() => transformed_error,
|
|
1460
|
+
() => reset
|
|
1461
|
+
);
|
|
1462
|
+
});
|
|
1463
|
+
} catch (error2) {
|
|
1464
|
+
invoke_error_boundary(
|
|
1465
|
+
error2,
|
|
1466
|
+
/** @type {Effect} */
|
|
1467
|
+
this.#effect.parent
|
|
1468
|
+
);
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
queue_micro_task(() => {
|
|
1475
|
+
var result;
|
|
1476
|
+
try {
|
|
1477
|
+
result = this.transform_error(error);
|
|
1478
|
+
} catch (e) {
|
|
1479
|
+
invoke_error_boundary(e, this.#effect && this.#effect.parent);
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
if (result !== null && typeof result === "object" && typeof /** @type {any} */
|
|
1483
|
+
result.then === "function") {
|
|
1484
|
+
result.then(
|
|
1485
|
+
handle_error_result,
|
|
1486
|
+
/** @param {unknown} e */
|
|
1487
|
+
(e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
|
|
1488
|
+
);
|
|
1489
|
+
} else {
|
|
1490
|
+
handle_error_result(result);
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
function destroy_derived_effects(derived2) {
|
|
1496
|
+
var effects = derived2.effects;
|
|
1497
|
+
if (effects !== null) {
|
|
1498
|
+
derived2.effects = null;
|
|
1499
|
+
for (var i = 0; i < effects.length; i += 1) {
|
|
1500
|
+
destroy_effect(
|
|
1501
|
+
/** @type {Effect} */
|
|
1502
|
+
effects[i]
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function execute_derived(derived2) {
|
|
1508
|
+
var value;
|
|
1509
|
+
var prev_active_effect = active_effect;
|
|
1510
|
+
var parent = derived2.parent;
|
|
1511
|
+
if (!is_destroying_effect && parent !== null && (parent.f & (DESTROYED | INERT)) !== 0) {
|
|
1512
|
+
derived_inert();
|
|
1513
|
+
return derived2.v;
|
|
1514
|
+
}
|
|
1515
|
+
set_active_effect(parent);
|
|
1516
|
+
{
|
|
1517
|
+
try {
|
|
1518
|
+
derived2.f &= ~WAS_MARKED;
|
|
1519
|
+
destroy_derived_effects(derived2);
|
|
1520
|
+
value = update_reaction(derived2);
|
|
1521
|
+
} finally {
|
|
1522
|
+
set_active_effect(prev_active_effect);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return value;
|
|
1526
|
+
}
|
|
1527
|
+
function update_derived(derived2) {
|
|
1528
|
+
var value = execute_derived(derived2);
|
|
1529
|
+
if (!derived2.equals(value)) {
|
|
1530
|
+
derived2.wv = increment_write_version();
|
|
1531
|
+
if (!current_batch?.is_fork || derived2.deps === null) {
|
|
1532
|
+
if (current_batch !== null) {
|
|
1533
|
+
current_batch.capture(derived2, value, true);
|
|
1534
|
+
previous_batch?.capture(derived2, value, true);
|
|
1535
|
+
} else {
|
|
1536
|
+
derived2.v = value;
|
|
1537
|
+
}
|
|
1538
|
+
if (derived2.deps === null) {
|
|
1539
|
+
set_signal_status(derived2, CLEAN);
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
if (is_destroying_effect) {
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
if (batch_values !== null) {
|
|
1548
|
+
if (effect_tracking() || current_batch?.is_fork) {
|
|
1549
|
+
batch_values.set(derived2, value);
|
|
1550
|
+
}
|
|
1551
|
+
} else {
|
|
1552
|
+
update_derived_status(derived2);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function freeze_derived_effects(derived2) {
|
|
1556
|
+
if (derived2.effects === null) return;
|
|
1557
|
+
for (const e of derived2.effects) {
|
|
1558
|
+
if (e.teardown || e.ac) {
|
|
1559
|
+
e.teardown?.();
|
|
1560
|
+
e.ac?.abort(STALE_REACTION);
|
|
1561
|
+
e.teardown = noop;
|
|
1562
|
+
e.ac = null;
|
|
1563
|
+
remove_reactions(e, 0);
|
|
1564
|
+
destroy_effect_children(e);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
function unfreeze_derived_effects(derived2) {
|
|
1569
|
+
if (derived2.effects === null) return;
|
|
1570
|
+
for (const e of derived2.effects) {
|
|
1571
|
+
if (e.teardown) {
|
|
1572
|
+
update_effect(e);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
let eager_effects = /* @__PURE__ */ new Set();
|
|
1577
|
+
const old_values = /* @__PURE__ */ new Map();
|
|
1578
|
+
let eager_effects_deferred = false;
|
|
1579
|
+
function source(v, stack) {
|
|
1580
|
+
var signal = {
|
|
1581
|
+
f: 0,
|
|
1582
|
+
// TODO ideally we could skip this altogether, but it causes type errors
|
|
1583
|
+
v,
|
|
1584
|
+
reactions: null,
|
|
1585
|
+
equals,
|
|
1586
|
+
rv: 0,
|
|
1587
|
+
wv: 0
|
|
1588
|
+
};
|
|
1589
|
+
return signal;
|
|
1590
|
+
}
|
|
1591
|
+
// @__NO_SIDE_EFFECTS__
|
|
1592
|
+
function state(v, stack) {
|
|
1593
|
+
const s = source(v);
|
|
1594
|
+
push_reaction_value(s);
|
|
1595
|
+
return s;
|
|
1596
|
+
}
|
|
1597
|
+
// @__NO_SIDE_EFFECTS__
|
|
1598
|
+
function mutable_source(initial_value, immutable = false, trackable = true) {
|
|
1599
|
+
const s = source(initial_value);
|
|
1600
|
+
if (!immutable) {
|
|
1601
|
+
s.equals = safe_equals;
|
|
1602
|
+
}
|
|
1603
|
+
return s;
|
|
1604
|
+
}
|
|
1605
|
+
function set(source2, value, should_proxy = false) {
|
|
1606
|
+
if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
|
|
1607
|
+
// to ensure we error if state is set inside an inspect effect
|
|
1608
|
+
(!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) {
|
|
1609
|
+
state_unsafe_mutation();
|
|
1610
|
+
}
|
|
1611
|
+
let new_value = should_proxy ? proxy(value) : value;
|
|
1612
|
+
return internal_set(source2, new_value, legacy_updates);
|
|
1613
|
+
}
|
|
1614
|
+
function internal_set(source2, value, updated_during_traversal = null) {
|
|
1615
|
+
if (!source2.equals(value)) {
|
|
1616
|
+
old_values.set(source2, is_destroying_effect ? value : source2.v);
|
|
1617
|
+
var batch = Batch.ensure();
|
|
1618
|
+
batch.capture(source2, value);
|
|
1619
|
+
if ((source2.f & DERIVED) !== 0) {
|
|
1620
|
+
const derived2 = (
|
|
1621
|
+
/** @type {Derived} */
|
|
1622
|
+
source2
|
|
1623
|
+
);
|
|
1624
|
+
if ((source2.f & DIRTY) !== 0) {
|
|
1625
|
+
execute_derived(derived2);
|
|
1626
|
+
}
|
|
1627
|
+
if (batch_values === null) {
|
|
1628
|
+
update_derived_status(derived2);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
source2.wv = increment_write_version();
|
|
1632
|
+
mark_reactions(source2, DIRTY, updated_during_traversal);
|
|
1633
|
+
if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
|
|
1634
|
+
if (untracked_writes === null) {
|
|
1635
|
+
set_untracked_writes([source2]);
|
|
1636
|
+
} else {
|
|
1637
|
+
untracked_writes.push(source2);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
|
|
1641
|
+
flush_eager_effects();
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return value;
|
|
1645
|
+
}
|
|
1646
|
+
function flush_eager_effects() {
|
|
1647
|
+
eager_effects_deferred = false;
|
|
1648
|
+
for (const effect of eager_effects) {
|
|
1649
|
+
if ((effect.f & CLEAN) !== 0) {
|
|
1650
|
+
set_signal_status(effect, MAYBE_DIRTY);
|
|
1651
|
+
}
|
|
1652
|
+
let dirty;
|
|
1653
|
+
try {
|
|
1654
|
+
dirty = is_dirty(effect);
|
|
1655
|
+
} catch {
|
|
1656
|
+
dirty = true;
|
|
1657
|
+
}
|
|
1658
|
+
if (dirty) {
|
|
1659
|
+
update_effect(effect);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
eager_effects.clear();
|
|
1663
|
+
}
|
|
1664
|
+
function increment(source2) {
|
|
1665
|
+
set(source2, source2.v + 1);
|
|
1666
|
+
}
|
|
1667
|
+
function mark_reactions(signal, status, updated_during_traversal) {
|
|
1668
|
+
var reactions = signal.reactions;
|
|
1669
|
+
if (reactions === null) return;
|
|
1670
|
+
var length = reactions.length;
|
|
1671
|
+
for (var i = 0; i < length; i++) {
|
|
1672
|
+
var reaction = reactions[i];
|
|
1673
|
+
var flags2 = reaction.f;
|
|
1674
|
+
var not_dirty = (flags2 & DIRTY) === 0;
|
|
1675
|
+
if (not_dirty) {
|
|
1676
|
+
set_signal_status(reaction, status);
|
|
1677
|
+
}
|
|
1678
|
+
if ((flags2 & EAGER_EFFECT) !== 0) {
|
|
1679
|
+
eager_effects.add(
|
|
1680
|
+
/** @type {Effect} */
|
|
1681
|
+
reaction
|
|
1682
|
+
);
|
|
1683
|
+
} else if ((flags2 & DERIVED) !== 0) {
|
|
1684
|
+
var derived2 = (
|
|
1685
|
+
/** @type {Derived} */
|
|
1686
|
+
reaction
|
|
1687
|
+
);
|
|
1688
|
+
batch_values?.delete(derived2);
|
|
1689
|
+
if ((flags2 & WAS_MARKED) === 0) {
|
|
1690
|
+
if (flags2 & CONNECTED && (active_effect === null || (active_effect.f & REACTION_IS_UPDATING) === 0)) {
|
|
1691
|
+
reaction.f |= WAS_MARKED;
|
|
1692
|
+
}
|
|
1693
|
+
mark_reactions(derived2, MAYBE_DIRTY, updated_during_traversal);
|
|
1694
|
+
}
|
|
1695
|
+
} else if (not_dirty) {
|
|
1696
|
+
var effect = (
|
|
1697
|
+
/** @type {Effect} */
|
|
1698
|
+
reaction
|
|
1699
|
+
);
|
|
1700
|
+
if ((flags2 & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
|
|
1701
|
+
eager_block_effects.add(effect);
|
|
1702
|
+
}
|
|
1703
|
+
if (updated_during_traversal !== null) {
|
|
1704
|
+
updated_during_traversal.push(effect);
|
|
1705
|
+
} else {
|
|
1706
|
+
schedule_effect(effect);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
function proxy(value) {
|
|
1712
|
+
if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
|
|
1713
|
+
return value;
|
|
1714
|
+
}
|
|
1715
|
+
const prototype = get_prototype_of(value);
|
|
1716
|
+
if (prototype !== object_prototype && prototype !== array_prototype) {
|
|
1717
|
+
return value;
|
|
1718
|
+
}
|
|
1719
|
+
var sources = /* @__PURE__ */ new Map();
|
|
1720
|
+
var is_proxied_array = is_array(value);
|
|
1721
|
+
var version = /* @__PURE__ */ state(0);
|
|
1722
|
+
var parent_version = update_version;
|
|
1723
|
+
var with_parent = (fn) => {
|
|
1724
|
+
if (update_version === parent_version) {
|
|
1725
|
+
return fn();
|
|
1726
|
+
}
|
|
1727
|
+
var reaction = active_reaction;
|
|
1728
|
+
var version2 = update_version;
|
|
1729
|
+
set_active_reaction(null);
|
|
1730
|
+
set_update_version(parent_version);
|
|
1731
|
+
var result = fn();
|
|
1732
|
+
set_active_reaction(reaction);
|
|
1733
|
+
set_update_version(version2);
|
|
1734
|
+
return result;
|
|
1735
|
+
};
|
|
1736
|
+
if (is_proxied_array) {
|
|
1737
|
+
sources.set("length", /* @__PURE__ */ state(
|
|
1738
|
+
/** @type {any[]} */
|
|
1739
|
+
value.length
|
|
1740
|
+
));
|
|
1741
|
+
}
|
|
1742
|
+
return new Proxy(
|
|
1743
|
+
/** @type {any} */
|
|
1744
|
+
value,
|
|
1745
|
+
{
|
|
1746
|
+
defineProperty(_, prop, descriptor) {
|
|
1747
|
+
if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
|
|
1748
|
+
state_descriptors_fixed();
|
|
1749
|
+
}
|
|
1750
|
+
var s = sources.get(prop);
|
|
1751
|
+
if (s === void 0) {
|
|
1752
|
+
with_parent(() => {
|
|
1753
|
+
var s2 = /* @__PURE__ */ state(descriptor.value);
|
|
1754
|
+
sources.set(prop, s2);
|
|
1755
|
+
return s2;
|
|
1756
|
+
});
|
|
1757
|
+
} else {
|
|
1758
|
+
set(s, descriptor.value, true);
|
|
1759
|
+
}
|
|
1760
|
+
return true;
|
|
1761
|
+
},
|
|
1762
|
+
deleteProperty(target, prop) {
|
|
1763
|
+
var s = sources.get(prop);
|
|
1764
|
+
if (s === void 0) {
|
|
1765
|
+
if (prop in target) {
|
|
1766
|
+
const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
|
|
1767
|
+
sources.set(prop, s2);
|
|
1768
|
+
increment(version);
|
|
1769
|
+
}
|
|
1770
|
+
} else {
|
|
1771
|
+
set(s, UNINITIALIZED);
|
|
1772
|
+
increment(version);
|
|
1773
|
+
}
|
|
1774
|
+
return true;
|
|
1775
|
+
},
|
|
1776
|
+
get(target, prop, receiver) {
|
|
1777
|
+
if (prop === STATE_SYMBOL) {
|
|
1778
|
+
return value;
|
|
1779
|
+
}
|
|
1780
|
+
var s = sources.get(prop);
|
|
1781
|
+
var exists = prop in target;
|
|
1782
|
+
if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
|
|
1783
|
+
s = with_parent(() => {
|
|
1784
|
+
var p = proxy(exists ? target[prop] : UNINITIALIZED);
|
|
1785
|
+
var s2 = /* @__PURE__ */ state(p);
|
|
1786
|
+
return s2;
|
|
1787
|
+
});
|
|
1788
|
+
sources.set(prop, s);
|
|
1789
|
+
}
|
|
1790
|
+
if (s !== void 0) {
|
|
1791
|
+
var v = get(s);
|
|
1792
|
+
return v === UNINITIALIZED ? void 0 : v;
|
|
1793
|
+
}
|
|
1794
|
+
return Reflect.get(target, prop, receiver);
|
|
1795
|
+
},
|
|
1796
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
1797
|
+
var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1798
|
+
if (descriptor && "value" in descriptor) {
|
|
1799
|
+
var s = sources.get(prop);
|
|
1800
|
+
if (s) descriptor.value = get(s);
|
|
1801
|
+
} else if (descriptor === void 0) {
|
|
1802
|
+
var source2 = sources.get(prop);
|
|
1803
|
+
var value2 = source2?.v;
|
|
1804
|
+
if (source2 !== void 0 && value2 !== UNINITIALIZED) {
|
|
1805
|
+
return {
|
|
1806
|
+
enumerable: true,
|
|
1807
|
+
configurable: true,
|
|
1808
|
+
value: value2,
|
|
1809
|
+
writable: true
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
return descriptor;
|
|
1814
|
+
},
|
|
1815
|
+
has(target, prop) {
|
|
1816
|
+
if (prop === STATE_SYMBOL) {
|
|
1817
|
+
return true;
|
|
1818
|
+
}
|
|
1819
|
+
var s = sources.get(prop);
|
|
1820
|
+
var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
|
|
1821
|
+
if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
|
|
1822
|
+
if (s === void 0) {
|
|
1823
|
+
s = with_parent(() => {
|
|
1824
|
+
var p = has ? proxy(target[prop]) : UNINITIALIZED;
|
|
1825
|
+
var s2 = /* @__PURE__ */ state(p);
|
|
1826
|
+
return s2;
|
|
1827
|
+
});
|
|
1828
|
+
sources.set(prop, s);
|
|
1829
|
+
}
|
|
1830
|
+
var value2 = get(s);
|
|
1831
|
+
if (value2 === UNINITIALIZED) {
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
return has;
|
|
1836
|
+
},
|
|
1837
|
+
set(target, prop, value2, receiver) {
|
|
1838
|
+
var s = sources.get(prop);
|
|
1839
|
+
var has = prop in target;
|
|
1840
|
+
if (is_proxied_array && prop === "length") {
|
|
1841
|
+
for (var i = value2; i < /** @type {Source<number>} */
|
|
1842
|
+
s.v; i += 1) {
|
|
1843
|
+
var other_s = sources.get(i + "");
|
|
1844
|
+
if (other_s !== void 0) {
|
|
1845
|
+
set(other_s, UNINITIALIZED);
|
|
1846
|
+
} else if (i in target) {
|
|
1847
|
+
other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
|
|
1848
|
+
sources.set(i + "", other_s);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
if (s === void 0) {
|
|
1853
|
+
if (!has || get_descriptor(target, prop)?.writable) {
|
|
1854
|
+
s = with_parent(() => /* @__PURE__ */ state(void 0));
|
|
1855
|
+
set(s, proxy(value2));
|
|
1856
|
+
sources.set(prop, s);
|
|
1857
|
+
}
|
|
1858
|
+
} else {
|
|
1859
|
+
has = s.v !== UNINITIALIZED;
|
|
1860
|
+
var p = with_parent(() => proxy(value2));
|
|
1861
|
+
set(s, p);
|
|
1862
|
+
}
|
|
1863
|
+
var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1864
|
+
if (descriptor?.set) {
|
|
1865
|
+
descriptor.set.call(receiver, value2);
|
|
1866
|
+
}
|
|
1867
|
+
if (!has) {
|
|
1868
|
+
if (is_proxied_array && typeof prop === "string") {
|
|
1869
|
+
var ls = (
|
|
1870
|
+
/** @type {Source<number>} */
|
|
1871
|
+
sources.get("length")
|
|
1872
|
+
);
|
|
1873
|
+
var n = Number(prop);
|
|
1874
|
+
if (Number.isInteger(n) && n >= ls.v) {
|
|
1875
|
+
set(ls, n + 1);
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
increment(version);
|
|
1879
|
+
}
|
|
1880
|
+
return true;
|
|
1881
|
+
},
|
|
1882
|
+
ownKeys(target) {
|
|
1883
|
+
get(version);
|
|
1884
|
+
var own_keys = Reflect.ownKeys(target).filter((key2) => {
|
|
1885
|
+
var source3 = sources.get(key2);
|
|
1886
|
+
return source3 === void 0 || source3.v !== UNINITIALIZED;
|
|
1887
|
+
});
|
|
1888
|
+
for (var [key, source2] of sources) {
|
|
1889
|
+
if (source2.v !== UNINITIALIZED && !(key in target)) {
|
|
1890
|
+
own_keys.push(key);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
return own_keys;
|
|
1894
|
+
},
|
|
1895
|
+
setPrototypeOf() {
|
|
1896
|
+
state_prototype_fixed();
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
var $window;
|
|
1902
|
+
var first_child_getter;
|
|
1903
|
+
var next_sibling_getter;
|
|
1904
|
+
function init_operations() {
|
|
1905
|
+
if ($window !== void 0) {
|
|
1906
|
+
return;
|
|
1907
|
+
}
|
|
1908
|
+
$window = window;
|
|
1909
|
+
var element_prototype = Element.prototype;
|
|
1910
|
+
var node_prototype = Node.prototype;
|
|
1911
|
+
var text_prototype = Text.prototype;
|
|
1912
|
+
first_child_getter = get_descriptor(node_prototype, "firstChild").get;
|
|
1913
|
+
next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
|
|
1914
|
+
if (is_extensible(element_prototype)) {
|
|
1915
|
+
element_prototype[CLASS_CACHE] = void 0;
|
|
1916
|
+
element_prototype[ATTRIBUTES_CACHE] = null;
|
|
1917
|
+
element_prototype[STYLE_CACHE] = void 0;
|
|
1918
|
+
element_prototype.__e = void 0;
|
|
1919
|
+
}
|
|
1920
|
+
if (is_extensible(text_prototype)) {
|
|
1921
|
+
text_prototype[TEXT_CACHE] = void 0;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
function create_text(value = "") {
|
|
1925
|
+
return document.createTextNode(value);
|
|
1926
|
+
}
|
|
1927
|
+
// @__NO_SIDE_EFFECTS__
|
|
1928
|
+
function get_first_child(node) {
|
|
1929
|
+
return (
|
|
1930
|
+
/** @type {TemplateNode | null} */
|
|
1931
|
+
first_child_getter.call(node)
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
// @__NO_SIDE_EFFECTS__
|
|
1935
|
+
function get_next_sibling(node) {
|
|
1936
|
+
return (
|
|
1937
|
+
/** @type {TemplateNode | null} */
|
|
1938
|
+
next_sibling_getter.call(node)
|
|
1939
|
+
);
|
|
1940
|
+
}
|
|
1941
|
+
function clear_text_content(node) {
|
|
1942
|
+
node.textContent = "";
|
|
1943
|
+
}
|
|
1944
|
+
function without_reactive_context(fn) {
|
|
1945
|
+
var previous_reaction = active_reaction;
|
|
1946
|
+
var previous_effect = active_effect;
|
|
1947
|
+
set_active_reaction(null);
|
|
1948
|
+
set_active_effect(null);
|
|
1949
|
+
try {
|
|
1950
|
+
return fn();
|
|
1951
|
+
} finally {
|
|
1952
|
+
set_active_reaction(previous_reaction);
|
|
1953
|
+
set_active_effect(previous_effect);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
function push_effect(effect, parent_effect) {
|
|
1957
|
+
var parent_last = parent_effect.last;
|
|
1958
|
+
if (parent_last === null) {
|
|
1959
|
+
parent_effect.last = parent_effect.first = effect;
|
|
1960
|
+
} else {
|
|
1961
|
+
parent_last.next = effect;
|
|
1962
|
+
effect.prev = parent_last;
|
|
1963
|
+
parent_effect.last = effect;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
function create_effect(type, fn) {
|
|
1967
|
+
var parent = active_effect;
|
|
1968
|
+
if (parent !== null && (parent.f & INERT) !== 0) {
|
|
1969
|
+
type |= INERT;
|
|
1970
|
+
}
|
|
1971
|
+
var effect = {
|
|
1972
|
+
ctx: component_context,
|
|
1973
|
+
deps: null,
|
|
1974
|
+
nodes: null,
|
|
1975
|
+
f: type | DIRTY | CONNECTED,
|
|
1976
|
+
first: null,
|
|
1977
|
+
fn,
|
|
1978
|
+
last: null,
|
|
1979
|
+
next: null,
|
|
1980
|
+
parent,
|
|
1981
|
+
b: parent && parent.b,
|
|
1982
|
+
prev: null,
|
|
1983
|
+
teardown: null,
|
|
1984
|
+
wv: 0,
|
|
1985
|
+
ac: null
|
|
1986
|
+
};
|
|
1987
|
+
current_batch?.register_created_effect(effect);
|
|
1988
|
+
var e = effect;
|
|
1989
|
+
if ((type & EFFECT) !== 0) {
|
|
1990
|
+
if (collected_effects !== null) {
|
|
1991
|
+
collected_effects.push(effect);
|
|
1992
|
+
} else {
|
|
1993
|
+
Batch.ensure().schedule(effect);
|
|
1994
|
+
}
|
|
1995
|
+
} else if (fn !== null) {
|
|
1996
|
+
try {
|
|
1997
|
+
update_effect(effect);
|
|
1998
|
+
} catch (e2) {
|
|
1999
|
+
destroy_effect(effect);
|
|
2000
|
+
throw e2;
|
|
2001
|
+
}
|
|
2002
|
+
if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
|
|
2003
|
+
(e.f & EFFECT_PRESERVED) === 0) {
|
|
2004
|
+
e = e.first;
|
|
2005
|
+
if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
|
|
2006
|
+
e.f |= EFFECT_TRANSPARENT;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
if (e !== null) {
|
|
2011
|
+
e.parent = parent;
|
|
2012
|
+
if (parent !== null) {
|
|
2013
|
+
push_effect(e, parent);
|
|
2014
|
+
}
|
|
2015
|
+
if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
|
|
2016
|
+
var derived2 = (
|
|
2017
|
+
/** @type {Derived} */
|
|
2018
|
+
active_reaction
|
|
2019
|
+
);
|
|
2020
|
+
(derived2.effects ??= []).push(e);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
return effect;
|
|
2024
|
+
}
|
|
2025
|
+
function effect_tracking() {
|
|
2026
|
+
return active_reaction !== null && !untracking;
|
|
2027
|
+
}
|
|
2028
|
+
function create_user_effect(fn) {
|
|
2029
|
+
return create_effect(EFFECT | USER_EFFECT, fn);
|
|
2030
|
+
}
|
|
2031
|
+
function component_root(fn) {
|
|
2032
|
+
Batch.ensure();
|
|
2033
|
+
const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn);
|
|
2034
|
+
return (options = {}) => {
|
|
2035
|
+
return new Promise((fulfil) => {
|
|
2036
|
+
if (options.outro) {
|
|
2037
|
+
pause_effect(effect, () => {
|
|
2038
|
+
destroy_effect(effect);
|
|
2039
|
+
fulfil(void 0);
|
|
2040
|
+
});
|
|
2041
|
+
} else {
|
|
2042
|
+
destroy_effect(effect);
|
|
2043
|
+
fulfil(void 0);
|
|
2044
|
+
}
|
|
2045
|
+
});
|
|
2046
|
+
};
|
|
2047
|
+
}
|
|
2048
|
+
function render_effect(fn, flags2 = 0) {
|
|
2049
|
+
return create_effect(RENDER_EFFECT | flags2, fn);
|
|
2050
|
+
}
|
|
2051
|
+
function block(fn, flags2 = 0) {
|
|
2052
|
+
var effect = create_effect(BLOCK_EFFECT | flags2, fn);
|
|
2053
|
+
return effect;
|
|
2054
|
+
}
|
|
2055
|
+
function branch(fn) {
|
|
2056
|
+
return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn);
|
|
2057
|
+
}
|
|
2058
|
+
function execute_effect_teardown(effect) {
|
|
2059
|
+
var teardown = effect.teardown;
|
|
2060
|
+
if (teardown !== null) {
|
|
2061
|
+
const previously_destroying_effect = is_destroying_effect;
|
|
2062
|
+
const previous_reaction = active_reaction;
|
|
2063
|
+
set_is_destroying_effect(true);
|
|
2064
|
+
set_active_reaction(null);
|
|
2065
|
+
try {
|
|
2066
|
+
teardown.call(null);
|
|
2067
|
+
} finally {
|
|
2068
|
+
set_is_destroying_effect(previously_destroying_effect);
|
|
2069
|
+
set_active_reaction(previous_reaction);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
function destroy_effect_children(signal, remove_dom = false) {
|
|
2074
|
+
var effect = signal.first;
|
|
2075
|
+
signal.first = signal.last = null;
|
|
2076
|
+
while (effect !== null) {
|
|
2077
|
+
const controller = effect.ac;
|
|
2078
|
+
if (controller !== null) {
|
|
2079
|
+
without_reactive_context(() => {
|
|
2080
|
+
controller.abort(STALE_REACTION);
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
var next2 = effect.next;
|
|
2084
|
+
if ((effect.f & ROOT_EFFECT) !== 0) {
|
|
2085
|
+
effect.parent = null;
|
|
2086
|
+
} else {
|
|
2087
|
+
destroy_effect(effect, remove_dom);
|
|
2088
|
+
}
|
|
2089
|
+
effect = next2;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
function destroy_block_effect_children(signal) {
|
|
2093
|
+
var effect = signal.first;
|
|
2094
|
+
while (effect !== null) {
|
|
2095
|
+
var next2 = effect.next;
|
|
2096
|
+
if ((effect.f & BRANCH_EFFECT) === 0) {
|
|
2097
|
+
destroy_effect(effect);
|
|
2098
|
+
}
|
|
2099
|
+
effect = next2;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
function destroy_effect(effect, remove_dom = true) {
|
|
2103
|
+
var removed = false;
|
|
2104
|
+
if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
|
|
2105
|
+
remove_effect_dom(
|
|
2106
|
+
effect.nodes.start,
|
|
2107
|
+
/** @type {TemplateNode} */
|
|
2108
|
+
effect.nodes.end
|
|
2109
|
+
);
|
|
2110
|
+
removed = true;
|
|
2111
|
+
}
|
|
2112
|
+
set_signal_status(effect, DESTROYING);
|
|
2113
|
+
destroy_effect_children(effect, remove_dom && !removed);
|
|
2114
|
+
remove_reactions(effect, 0);
|
|
2115
|
+
var transitions = effect.nodes && effect.nodes.t;
|
|
2116
|
+
if (transitions !== null) {
|
|
2117
|
+
for (const transition of transitions) {
|
|
2118
|
+
transition.stop();
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
execute_effect_teardown(effect);
|
|
2122
|
+
effect.f ^= DESTROYING;
|
|
2123
|
+
effect.f |= DESTROYED;
|
|
2124
|
+
var parent = effect.parent;
|
|
2125
|
+
if (parent !== null && parent.first !== null) {
|
|
2126
|
+
unlink_effect(effect);
|
|
2127
|
+
}
|
|
2128
|
+
effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = effect.b = null;
|
|
2129
|
+
}
|
|
2130
|
+
function remove_effect_dom(node, end) {
|
|
2131
|
+
while (node !== null) {
|
|
2132
|
+
var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
|
|
2133
|
+
node.remove();
|
|
2134
|
+
node = next2;
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
function unlink_effect(effect) {
|
|
2138
|
+
var parent = effect.parent;
|
|
2139
|
+
var prev = effect.prev;
|
|
2140
|
+
var next2 = effect.next;
|
|
2141
|
+
if (prev !== null) prev.next = next2;
|
|
2142
|
+
if (next2 !== null) next2.prev = prev;
|
|
2143
|
+
if (parent !== null) {
|
|
2144
|
+
if (parent.first === effect) parent.first = next2;
|
|
2145
|
+
if (parent.last === effect) parent.last = prev;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
function pause_effect(effect, callback, destroy = true) {
|
|
2149
|
+
var transitions = [];
|
|
2150
|
+
pause_children(effect, transitions, true);
|
|
2151
|
+
var fn = () => {
|
|
2152
|
+
if (destroy) destroy_effect(effect);
|
|
2153
|
+
if (callback) callback();
|
|
2154
|
+
};
|
|
2155
|
+
var remaining = transitions.length;
|
|
2156
|
+
if (remaining > 0) {
|
|
2157
|
+
var check = () => --remaining || fn();
|
|
2158
|
+
for (var transition of transitions) {
|
|
2159
|
+
transition.out(check);
|
|
2160
|
+
}
|
|
2161
|
+
} else {
|
|
2162
|
+
fn();
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
function pause_children(effect, transitions, local) {
|
|
2166
|
+
if ((effect.f & INERT) !== 0) return;
|
|
2167
|
+
effect.f ^= INERT;
|
|
2168
|
+
var t = effect.nodes && effect.nodes.t;
|
|
2169
|
+
if (t !== null) {
|
|
2170
|
+
for (const transition of t) {
|
|
2171
|
+
if (transition.is_global || local) {
|
|
2172
|
+
transitions.push(transition);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
var child = effect.first;
|
|
2177
|
+
while (child !== null) {
|
|
2178
|
+
var sibling = child.next;
|
|
2179
|
+
if ((child.f & ROOT_EFFECT) === 0) {
|
|
2180
|
+
var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
|
|
2181
|
+
// it means the parent block effect was pruned. In that case,
|
|
2182
|
+
// transparency information was transferred to the branch effect.
|
|
2183
|
+
(child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
|
|
2184
|
+
pause_children(child, transitions, transparent ? local : false);
|
|
2185
|
+
}
|
|
2186
|
+
child = sibling;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
function move_effect(effect, fragment) {
|
|
2190
|
+
if (!effect.nodes) return;
|
|
2191
|
+
var node = effect.nodes.start;
|
|
2192
|
+
var end = effect.nodes.end;
|
|
2193
|
+
while (node !== null) {
|
|
2194
|
+
var next2 = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
|
|
2195
|
+
fragment.append(node);
|
|
2196
|
+
node = next2;
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
let is_updating_effect = false;
|
|
2200
|
+
let is_destroying_effect = false;
|
|
2201
|
+
function set_is_destroying_effect(value) {
|
|
2202
|
+
is_destroying_effect = value;
|
|
2203
|
+
}
|
|
2204
|
+
let active_reaction = null;
|
|
2205
|
+
let untracking = false;
|
|
2206
|
+
function set_active_reaction(reaction) {
|
|
2207
|
+
active_reaction = reaction;
|
|
2208
|
+
}
|
|
2209
|
+
let active_effect = null;
|
|
2210
|
+
function set_active_effect(effect) {
|
|
2211
|
+
active_effect = effect;
|
|
2212
|
+
}
|
|
2213
|
+
let current_sources = null;
|
|
2214
|
+
function push_reaction_value(value) {
|
|
2215
|
+
if (active_reaction !== null && true) {
|
|
2216
|
+
if (current_sources === null) {
|
|
2217
|
+
current_sources = [value];
|
|
2218
|
+
} else {
|
|
2219
|
+
current_sources.push(value);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
let new_deps = null;
|
|
2224
|
+
let skipped_deps = 0;
|
|
2225
|
+
let untracked_writes = null;
|
|
2226
|
+
function set_untracked_writes(value) {
|
|
2227
|
+
untracked_writes = value;
|
|
2228
|
+
}
|
|
2229
|
+
let write_version = 1;
|
|
2230
|
+
let read_version = 0;
|
|
2231
|
+
let update_version = read_version;
|
|
2232
|
+
function set_update_version(value) {
|
|
2233
|
+
update_version = value;
|
|
2234
|
+
}
|
|
2235
|
+
function increment_write_version() {
|
|
2236
|
+
return ++write_version;
|
|
2237
|
+
}
|
|
2238
|
+
function is_dirty(reaction) {
|
|
2239
|
+
var flags2 = reaction.f;
|
|
2240
|
+
if ((flags2 & DIRTY) !== 0) {
|
|
2241
|
+
return true;
|
|
2242
|
+
}
|
|
2243
|
+
if (flags2 & DERIVED) {
|
|
2244
|
+
reaction.f &= ~WAS_MARKED;
|
|
2245
|
+
}
|
|
2246
|
+
if ((flags2 & MAYBE_DIRTY) !== 0) {
|
|
2247
|
+
var dependencies = (
|
|
2248
|
+
/** @type {Value[]} */
|
|
2249
|
+
reaction.deps
|
|
2250
|
+
);
|
|
2251
|
+
var length = dependencies.length;
|
|
2252
|
+
for (var i = 0; i < length; i++) {
|
|
2253
|
+
var dependency = dependencies[i];
|
|
2254
|
+
if (is_dirty(
|
|
2255
|
+
/** @type {Derived} */
|
|
2256
|
+
dependency
|
|
2257
|
+
)) {
|
|
2258
|
+
update_derived(
|
|
2259
|
+
/** @type {Derived} */
|
|
2260
|
+
dependency
|
|
2261
|
+
);
|
|
2262
|
+
}
|
|
2263
|
+
if (dependency.wv > reaction.wv) {
|
|
2264
|
+
return true;
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
if ((flags2 & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that
|
|
2268
|
+
// traversal of the graph in the other batches still happens
|
|
2269
|
+
batch_values === null) {
|
|
2270
|
+
set_signal_status(reaction, CLEAN);
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
return false;
|
|
2274
|
+
}
|
|
2275
|
+
function schedule_possible_effect_self_invalidation(signal, effect, root2 = true) {
|
|
2276
|
+
var reactions = signal.reactions;
|
|
2277
|
+
if (reactions === null) return;
|
|
2278
|
+
if (current_sources !== null && includes.call(current_sources, signal)) {
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
for (var i = 0; i < reactions.length; i++) {
|
|
2282
|
+
var reaction = reactions[i];
|
|
2283
|
+
if ((reaction.f & DERIVED) !== 0) {
|
|
2284
|
+
schedule_possible_effect_self_invalidation(
|
|
2285
|
+
/** @type {Derived} */
|
|
2286
|
+
reaction,
|
|
2287
|
+
effect,
|
|
2288
|
+
false
|
|
2289
|
+
);
|
|
2290
|
+
} else if (effect === reaction) {
|
|
2291
|
+
if (root2) {
|
|
2292
|
+
set_signal_status(reaction, DIRTY);
|
|
2293
|
+
} else if ((reaction.f & CLEAN) !== 0) {
|
|
2294
|
+
set_signal_status(reaction, MAYBE_DIRTY);
|
|
2295
|
+
}
|
|
2296
|
+
schedule_effect(
|
|
2297
|
+
/** @type {Effect} */
|
|
2298
|
+
reaction
|
|
2299
|
+
);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
function update_reaction(reaction) {
|
|
2304
|
+
var previous_deps = new_deps;
|
|
2305
|
+
var previous_skipped_deps = skipped_deps;
|
|
2306
|
+
var previous_untracked_writes = untracked_writes;
|
|
2307
|
+
var previous_reaction = active_reaction;
|
|
2308
|
+
var previous_sources = current_sources;
|
|
2309
|
+
var previous_component_context = component_context;
|
|
2310
|
+
var previous_untracking = untracking;
|
|
2311
|
+
var previous_update_version = update_version;
|
|
2312
|
+
var flags2 = reaction.f;
|
|
2313
|
+
new_deps = /** @type {null | Value[]} */
|
|
2314
|
+
null;
|
|
2315
|
+
skipped_deps = 0;
|
|
2316
|
+
untracked_writes = null;
|
|
2317
|
+
active_reaction = (flags2 & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
|
|
2318
|
+
current_sources = null;
|
|
2319
|
+
set_component_context(reaction.ctx);
|
|
2320
|
+
untracking = false;
|
|
2321
|
+
update_version = ++read_version;
|
|
2322
|
+
if (reaction.ac !== null) {
|
|
2323
|
+
without_reactive_context(() => {
|
|
2324
|
+
reaction.ac.abort(STALE_REACTION);
|
|
2325
|
+
});
|
|
2326
|
+
reaction.ac = null;
|
|
2327
|
+
}
|
|
2328
|
+
try {
|
|
2329
|
+
reaction.f |= REACTION_IS_UPDATING;
|
|
2330
|
+
var fn = (
|
|
2331
|
+
/** @type {Function} */
|
|
2332
|
+
reaction.fn
|
|
2333
|
+
);
|
|
2334
|
+
var result = fn();
|
|
2335
|
+
reaction.f |= REACTION_RAN;
|
|
2336
|
+
var deps = reaction.deps;
|
|
2337
|
+
var is_fork = current_batch?.is_fork;
|
|
2338
|
+
if (new_deps !== null) {
|
|
2339
|
+
var i;
|
|
2340
|
+
if (!is_fork) {
|
|
2341
|
+
remove_reactions(reaction, skipped_deps);
|
|
2342
|
+
}
|
|
2343
|
+
if (deps !== null && skipped_deps > 0) {
|
|
2344
|
+
deps.length = skipped_deps + new_deps.length;
|
|
2345
|
+
for (i = 0; i < new_deps.length; i++) {
|
|
2346
|
+
deps[skipped_deps + i] = new_deps[i];
|
|
2347
|
+
}
|
|
2348
|
+
} else {
|
|
2349
|
+
reaction.deps = deps = new_deps;
|
|
2350
|
+
}
|
|
2351
|
+
if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
|
|
2352
|
+
for (i = skipped_deps; i < deps.length; i++) {
|
|
2353
|
+
(deps[i].reactions ??= []).push(reaction);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
} else if (!is_fork && deps !== null && skipped_deps < deps.length) {
|
|
2357
|
+
remove_reactions(reaction, skipped_deps);
|
|
2358
|
+
deps.length = skipped_deps;
|
|
2359
|
+
}
|
|
2360
|
+
if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
|
|
2361
|
+
for (i = 0; i < /** @type {Source[]} */
|
|
2362
|
+
untracked_writes.length; i++) {
|
|
2363
|
+
schedule_possible_effect_self_invalidation(
|
|
2364
|
+
untracked_writes[i],
|
|
2365
|
+
/** @type {Effect} */
|
|
2366
|
+
reaction
|
|
2367
|
+
);
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
if (previous_reaction !== null && previous_reaction !== reaction) {
|
|
2371
|
+
read_version++;
|
|
2372
|
+
if (previous_reaction.deps !== null) {
|
|
2373
|
+
for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) {
|
|
2374
|
+
previous_reaction.deps[i2].rv = read_version;
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
if (previous_deps !== null) {
|
|
2378
|
+
for (const dep of previous_deps) {
|
|
2379
|
+
dep.rv = read_version;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
if (untracked_writes !== null) {
|
|
2383
|
+
if (previous_untracked_writes === null) {
|
|
2384
|
+
previous_untracked_writes = untracked_writes;
|
|
2385
|
+
} else {
|
|
2386
|
+
previous_untracked_writes.push(.../** @type {Source[]} */
|
|
2387
|
+
untracked_writes);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
if ((reaction.f & ERROR_VALUE) !== 0) {
|
|
2392
|
+
reaction.f ^= ERROR_VALUE;
|
|
2393
|
+
}
|
|
2394
|
+
return result;
|
|
2395
|
+
} catch (error) {
|
|
2396
|
+
return handle_error(error);
|
|
2397
|
+
} finally {
|
|
2398
|
+
reaction.f ^= REACTION_IS_UPDATING;
|
|
2399
|
+
new_deps = previous_deps;
|
|
2400
|
+
skipped_deps = previous_skipped_deps;
|
|
2401
|
+
untracked_writes = previous_untracked_writes;
|
|
2402
|
+
active_reaction = previous_reaction;
|
|
2403
|
+
current_sources = previous_sources;
|
|
2404
|
+
set_component_context(previous_component_context);
|
|
2405
|
+
untracking = previous_untracking;
|
|
2406
|
+
update_version = previous_update_version;
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
function remove_reaction(signal, dependency) {
|
|
2410
|
+
let reactions = dependency.reactions;
|
|
2411
|
+
if (reactions !== null) {
|
|
2412
|
+
var index = index_of.call(reactions, signal);
|
|
2413
|
+
if (index !== -1) {
|
|
2414
|
+
var new_length = reactions.length - 1;
|
|
2415
|
+
if (new_length === 0) {
|
|
2416
|
+
reactions = dependency.reactions = null;
|
|
2417
|
+
} else {
|
|
2418
|
+
reactions[index] = reactions[new_length];
|
|
2419
|
+
reactions.pop();
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
|
|
2424
|
+
// to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
|
|
2425
|
+
// allows us to skip the expensive work of disconnecting and immediately reconnecting it
|
|
2426
|
+
(new_deps === null || !includes.call(new_deps, dependency))) {
|
|
2427
|
+
var derived2 = (
|
|
2428
|
+
/** @type {Derived} */
|
|
2429
|
+
dependency
|
|
2430
|
+
);
|
|
2431
|
+
if ((derived2.f & CONNECTED) !== 0) {
|
|
2432
|
+
derived2.f ^= CONNECTED;
|
|
2433
|
+
derived2.f &= ~WAS_MARKED;
|
|
2434
|
+
}
|
|
2435
|
+
if (derived2.v !== UNINITIALIZED) {
|
|
2436
|
+
update_derived_status(derived2);
|
|
2437
|
+
}
|
|
2438
|
+
freeze_derived_effects(derived2);
|
|
2439
|
+
remove_reactions(derived2, 0);
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
function remove_reactions(signal, start_index) {
|
|
2443
|
+
var dependencies = signal.deps;
|
|
2444
|
+
if (dependencies === null) return;
|
|
2445
|
+
for (var i = start_index; i < dependencies.length; i++) {
|
|
2446
|
+
remove_reaction(signal, dependencies[i]);
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
function update_effect(effect) {
|
|
2450
|
+
var flags2 = effect.f;
|
|
2451
|
+
if ((flags2 & DESTROYED) !== 0) {
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
set_signal_status(effect, CLEAN);
|
|
2455
|
+
var previous_effect = active_effect;
|
|
2456
|
+
var was_updating_effect = is_updating_effect;
|
|
2457
|
+
active_effect = effect;
|
|
2458
|
+
is_updating_effect = true;
|
|
2459
|
+
try {
|
|
2460
|
+
if ((flags2 & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
|
|
2461
|
+
destroy_block_effect_children(effect);
|
|
2462
|
+
} else {
|
|
2463
|
+
destroy_effect_children(effect);
|
|
2464
|
+
}
|
|
2465
|
+
execute_effect_teardown(effect);
|
|
2466
|
+
var teardown = update_reaction(effect);
|
|
2467
|
+
effect.teardown = typeof teardown === "function" ? teardown : null;
|
|
2468
|
+
effect.wv = write_version;
|
|
2469
|
+
var dep;
|
|
2470
|
+
if (BROWSER && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ;
|
|
2471
|
+
} finally {
|
|
2472
|
+
is_updating_effect = was_updating_effect;
|
|
2473
|
+
active_effect = previous_effect;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
function get(signal) {
|
|
2477
|
+
var flags2 = signal.f;
|
|
2478
|
+
var is_derived = (flags2 & DERIVED) !== 0;
|
|
2479
|
+
if (active_reaction !== null && !untracking) {
|
|
2480
|
+
var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
|
|
2481
|
+
if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
|
|
2482
|
+
var deps = active_reaction.deps;
|
|
2483
|
+
if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
|
|
2484
|
+
if (signal.rv < read_version) {
|
|
2485
|
+
signal.rv = read_version;
|
|
2486
|
+
if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
|
|
2487
|
+
skipped_deps++;
|
|
2488
|
+
} else if (new_deps === null) {
|
|
2489
|
+
new_deps = [signal];
|
|
2490
|
+
} else {
|
|
2491
|
+
new_deps.push(signal);
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
} else {
|
|
2495
|
+
(active_reaction.deps ??= []).push(signal);
|
|
2496
|
+
var reactions = signal.reactions;
|
|
2497
|
+
if (reactions === null) {
|
|
2498
|
+
signal.reactions = [active_reaction];
|
|
2499
|
+
} else if (!includes.call(reactions, active_reaction)) {
|
|
2500
|
+
reactions.push(active_reaction);
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
if (is_destroying_effect && old_values.has(signal)) {
|
|
2506
|
+
return old_values.get(signal);
|
|
2507
|
+
}
|
|
2508
|
+
if (is_derived) {
|
|
2509
|
+
var derived2 = (
|
|
2510
|
+
/** @type {Derived} */
|
|
2511
|
+
signal
|
|
2512
|
+
);
|
|
2513
|
+
if (is_destroying_effect) {
|
|
2514
|
+
var value = derived2.v;
|
|
2515
|
+
if ((derived2.f & CLEAN) === 0 && derived2.reactions !== null || depends_on_old_values(derived2)) {
|
|
2516
|
+
value = execute_derived(derived2);
|
|
2517
|
+
}
|
|
2518
|
+
old_values.set(derived2, value);
|
|
2519
|
+
return value;
|
|
2520
|
+
}
|
|
2521
|
+
var should_connect = (derived2.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
|
|
2522
|
+
var is_new = (derived2.f & REACTION_RAN) === 0;
|
|
2523
|
+
if (is_dirty(derived2)) {
|
|
2524
|
+
if (should_connect) {
|
|
2525
|
+
derived2.f |= CONNECTED;
|
|
2526
|
+
}
|
|
2527
|
+
update_derived(derived2);
|
|
2528
|
+
}
|
|
2529
|
+
if (should_connect && !is_new) {
|
|
2530
|
+
unfreeze_derived_effects(derived2);
|
|
2531
|
+
reconnect(derived2);
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
if (batch_values?.has(signal)) {
|
|
2535
|
+
return batch_values.get(signal);
|
|
2536
|
+
}
|
|
2537
|
+
if ((signal.f & ERROR_VALUE) !== 0) {
|
|
2538
|
+
throw signal.v;
|
|
2539
|
+
}
|
|
2540
|
+
return signal.v;
|
|
2541
|
+
}
|
|
2542
|
+
function reconnect(derived2) {
|
|
2543
|
+
derived2.f |= CONNECTED;
|
|
2544
|
+
if (derived2.deps === null) return;
|
|
2545
|
+
for (const dep of derived2.deps) {
|
|
2546
|
+
(dep.reactions ??= []).push(derived2);
|
|
2547
|
+
if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) {
|
|
2548
|
+
unfreeze_derived_effects(
|
|
2549
|
+
/** @type {Derived} */
|
|
2550
|
+
dep
|
|
2551
|
+
);
|
|
2552
|
+
reconnect(
|
|
2553
|
+
/** @type {Derived} */
|
|
2554
|
+
dep
|
|
2555
|
+
);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
function depends_on_old_values(derived2) {
|
|
2560
|
+
if (derived2.v === UNINITIALIZED) return true;
|
|
2561
|
+
if (derived2.deps === null) return false;
|
|
2562
|
+
for (const dep of derived2.deps) {
|
|
2563
|
+
if (old_values.has(dep)) {
|
|
2564
|
+
return true;
|
|
2565
|
+
}
|
|
2566
|
+
if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
|
|
2567
|
+
/** @type {Derived} */
|
|
2568
|
+
dep
|
|
2569
|
+
)) {
|
|
2570
|
+
return true;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
return false;
|
|
2574
|
+
}
|
|
2575
|
+
function untrack(fn) {
|
|
2576
|
+
var previous_untracking = untracking;
|
|
2577
|
+
try {
|
|
2578
|
+
untracking = true;
|
|
2579
|
+
return fn();
|
|
2580
|
+
} finally {
|
|
2581
|
+
untracking = previous_untracking;
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
const event_symbol = Symbol("events");
|
|
2585
|
+
const all_registered_events = /* @__PURE__ */ new Set();
|
|
2586
|
+
const root_event_handles = /* @__PURE__ */ new Set();
|
|
2587
|
+
let last_propagated_event = null;
|
|
2588
|
+
function handle_event_propagation(event) {
|
|
2589
|
+
var handler_element = this;
|
|
2590
|
+
var owner_document = (
|
|
2591
|
+
/** @type {Node} */
|
|
2592
|
+
handler_element.ownerDocument
|
|
2593
|
+
);
|
|
2594
|
+
var event_name = event.type;
|
|
2595
|
+
var path = event.composedPath?.() || [];
|
|
2596
|
+
var current_target = (
|
|
2597
|
+
/** @type {null | Element} */
|
|
2598
|
+
path[0] || event.target
|
|
2599
|
+
);
|
|
2600
|
+
last_propagated_event = event;
|
|
2601
|
+
var path_idx = 0;
|
|
2602
|
+
var handled_at = last_propagated_event === event && event[event_symbol];
|
|
2603
|
+
if (handled_at) {
|
|
2604
|
+
var at_idx = path.indexOf(handled_at);
|
|
2605
|
+
if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
|
|
2606
|
+
window)) {
|
|
2607
|
+
event[event_symbol] = handler_element;
|
|
2608
|
+
return;
|
|
2609
|
+
}
|
|
2610
|
+
var handler_idx = path.indexOf(handler_element);
|
|
2611
|
+
if (handler_idx === -1) {
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2614
|
+
if (at_idx <= handler_idx) {
|
|
2615
|
+
path_idx = at_idx;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
current_target = /** @type {Element} */
|
|
2619
|
+
path[path_idx] || event.target;
|
|
2620
|
+
if (current_target === handler_element) return;
|
|
2621
|
+
define_property(event, "currentTarget", {
|
|
2622
|
+
configurable: true,
|
|
2623
|
+
get() {
|
|
2624
|
+
return current_target || owner_document;
|
|
2625
|
+
}
|
|
2626
|
+
});
|
|
2627
|
+
var previous_reaction = active_reaction;
|
|
2628
|
+
var previous_effect = active_effect;
|
|
2629
|
+
set_active_reaction(null);
|
|
2630
|
+
set_active_effect(null);
|
|
2631
|
+
try {
|
|
2632
|
+
var throw_error;
|
|
2633
|
+
var other_errors = [];
|
|
2634
|
+
while (current_target !== null) {
|
|
2635
|
+
var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
|
|
2636
|
+
current_target.host || null;
|
|
2637
|
+
try {
|
|
2638
|
+
var delegated = current_target[event_symbol]?.[event_name];
|
|
2639
|
+
if (delegated != null && (!/** @type {any} */
|
|
2640
|
+
current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
|
|
2641
|
+
// -> the target could not have been disabled because it emits the event in the first place
|
|
2642
|
+
event.target === current_target)) {
|
|
2643
|
+
delegated.call(current_target, event);
|
|
2644
|
+
}
|
|
2645
|
+
} catch (error) {
|
|
2646
|
+
if (throw_error) {
|
|
2647
|
+
other_errors.push(error);
|
|
2648
|
+
} else {
|
|
2649
|
+
throw_error = error;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
if (event.cancelBubble || parent_element === handler_element || parent_element === null) {
|
|
2653
|
+
break;
|
|
2654
|
+
}
|
|
2655
|
+
current_target = parent_element;
|
|
2656
|
+
}
|
|
2657
|
+
if (throw_error) {
|
|
2658
|
+
for (let error of other_errors) {
|
|
2659
|
+
queueMicrotask(() => {
|
|
2660
|
+
throw error;
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
throw throw_error;
|
|
2664
|
+
}
|
|
2665
|
+
} finally {
|
|
2666
|
+
event[event_symbol] = handler_element;
|
|
2667
|
+
delete event.currentTarget;
|
|
2668
|
+
set_active_reaction(previous_reaction);
|
|
2669
|
+
set_active_effect(previous_effect);
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
function assign_nodes(start, end) {
|
|
2673
|
+
var effect = (
|
|
2674
|
+
/** @type {Effect} */
|
|
2675
|
+
active_effect
|
|
2676
|
+
);
|
|
2677
|
+
if (effect.nodes === null) {
|
|
2678
|
+
effect.nodes = { start, end, a: null, t: null };
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
function mount(component, options) {
|
|
2682
|
+
return _mount(component, options);
|
|
2683
|
+
}
|
|
2684
|
+
function hydrate(component, options) {
|
|
2685
|
+
init_operations();
|
|
2686
|
+
options.intro = options.intro ?? false;
|
|
2687
|
+
const target = options.target;
|
|
2688
|
+
const was_hydrating = hydrating;
|
|
2689
|
+
const previous_hydrate_node = hydrate_node;
|
|
2690
|
+
try {
|
|
2691
|
+
var anchor = /* @__PURE__ */ get_first_child(target);
|
|
2692
|
+
while (anchor && (anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */
|
|
2693
|
+
anchor.data !== HYDRATION_START)) {
|
|
2694
|
+
anchor = /* @__PURE__ */ get_next_sibling(anchor);
|
|
2695
|
+
}
|
|
2696
|
+
if (!anchor) {
|
|
2697
|
+
throw HYDRATION_ERROR;
|
|
2698
|
+
}
|
|
2699
|
+
set_hydrating(true);
|
|
2700
|
+
set_hydrate_node(
|
|
2701
|
+
/** @type {Comment} */
|
|
2702
|
+
anchor
|
|
2703
|
+
);
|
|
2704
|
+
const instance = _mount(component, { ...options, anchor });
|
|
2705
|
+
set_hydrating(false);
|
|
2706
|
+
return (
|
|
2707
|
+
/** @type {Exports} */
|
|
2708
|
+
instance
|
|
2709
|
+
);
|
|
2710
|
+
} catch (error) {
|
|
2711
|
+
if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) {
|
|
2712
|
+
throw error;
|
|
2713
|
+
}
|
|
2714
|
+
if (error !== HYDRATION_ERROR) {
|
|
2715
|
+
console.warn("Failed to hydrate: ", error);
|
|
2716
|
+
}
|
|
2717
|
+
if (options.recover === false) {
|
|
2718
|
+
hydration_failed();
|
|
2719
|
+
}
|
|
2720
|
+
init_operations();
|
|
2721
|
+
clear_text_content(target);
|
|
2722
|
+
set_hydrating(false);
|
|
2723
|
+
return mount(component, options);
|
|
2724
|
+
} finally {
|
|
2725
|
+
set_hydrating(was_hydrating);
|
|
2726
|
+
set_hydrate_node(previous_hydrate_node);
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
2730
|
+
function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
|
|
2731
|
+
init_operations();
|
|
2732
|
+
var component = void 0;
|
|
2733
|
+
var unmount2 = component_root(() => {
|
|
2734
|
+
var anchor_node = anchor ?? target.appendChild(create_text());
|
|
2735
|
+
boundary(
|
|
2736
|
+
/** @type {TemplateNode} */
|
|
2737
|
+
anchor_node,
|
|
2738
|
+
{
|
|
2739
|
+
pending: () => {
|
|
2740
|
+
}
|
|
2741
|
+
},
|
|
2742
|
+
(anchor_node2) => {
|
|
2743
|
+
push({});
|
|
2744
|
+
var ctx = (
|
|
2745
|
+
/** @type {ComponentContext} */
|
|
2746
|
+
component_context
|
|
2747
|
+
);
|
|
2748
|
+
if (context) ctx.c = context;
|
|
2749
|
+
if (events) {
|
|
2750
|
+
props.$$events = events;
|
|
2751
|
+
}
|
|
2752
|
+
if (hydrating) {
|
|
2753
|
+
assign_nodes(
|
|
2754
|
+
/** @type {TemplateNode} */
|
|
2755
|
+
anchor_node2,
|
|
2756
|
+
null
|
|
2757
|
+
);
|
|
2758
|
+
}
|
|
2759
|
+
component = Component(anchor_node2, props) || {};
|
|
2760
|
+
if (hydrating) {
|
|
2761
|
+
active_effect.nodes.end = hydrate_node;
|
|
2762
|
+
if (hydrate_node === null || hydrate_node.nodeType !== COMMENT_NODE || /** @type {Comment} */
|
|
2763
|
+
hydrate_node.data !== HYDRATION_END) {
|
|
2764
|
+
hydration_mismatch();
|
|
2765
|
+
throw HYDRATION_ERROR;
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
pop();
|
|
2769
|
+
},
|
|
2770
|
+
transformError
|
|
2771
|
+
);
|
|
2772
|
+
var registered_events = /* @__PURE__ */ new Set();
|
|
2773
|
+
var event_handle = (events2) => {
|
|
2774
|
+
for (var i = 0; i < events2.length; i++) {
|
|
2775
|
+
var event_name = events2[i];
|
|
2776
|
+
if (registered_events.has(event_name)) continue;
|
|
2777
|
+
registered_events.add(event_name);
|
|
2778
|
+
var passive = is_passive_event(event_name);
|
|
2779
|
+
for (const node of [target, document]) {
|
|
2780
|
+
var counts = listeners.get(node);
|
|
2781
|
+
if (counts === void 0) {
|
|
2782
|
+
counts = /* @__PURE__ */ new Map();
|
|
2783
|
+
listeners.set(node, counts);
|
|
2784
|
+
}
|
|
2785
|
+
var count = counts.get(event_name);
|
|
2786
|
+
if (count === void 0) {
|
|
2787
|
+
node.addEventListener(event_name, handle_event_propagation, { passive });
|
|
2788
|
+
counts.set(event_name, 1);
|
|
2789
|
+
} else {
|
|
2790
|
+
counts.set(event_name, count + 1);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
event_handle(array_from(all_registered_events));
|
|
2796
|
+
root_event_handles.add(event_handle);
|
|
2797
|
+
return () => {
|
|
2798
|
+
for (var event_name of registered_events) {
|
|
2799
|
+
for (const node of [target, document]) {
|
|
2800
|
+
var counts = (
|
|
2801
|
+
/** @type {Map<string, number>} */
|
|
2802
|
+
listeners.get(node)
|
|
2803
|
+
);
|
|
2804
|
+
var count = (
|
|
2805
|
+
/** @type {number} */
|
|
2806
|
+
counts.get(event_name)
|
|
2807
|
+
);
|
|
2808
|
+
if (--count == 0) {
|
|
2809
|
+
node.removeEventListener(event_name, handle_event_propagation);
|
|
2810
|
+
counts.delete(event_name);
|
|
2811
|
+
if (counts.size === 0) {
|
|
2812
|
+
listeners.delete(node);
|
|
2813
|
+
}
|
|
2814
|
+
} else {
|
|
2815
|
+
counts.set(event_name, count);
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
root_event_handles.delete(event_handle);
|
|
2820
|
+
if (anchor_node !== anchor) {
|
|
2821
|
+
anchor_node.parentNode?.removeChild(anchor_node);
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
});
|
|
2825
|
+
mounted_components.set(component, unmount2);
|
|
2826
|
+
return component;
|
|
2827
|
+
}
|
|
2828
|
+
let mounted_components = /* @__PURE__ */ new WeakMap();
|
|
2829
|
+
function unmount(component, options) {
|
|
2830
|
+
const fn = mounted_components.get(component);
|
|
2831
|
+
if (fn) {
|
|
2832
|
+
mounted_components.delete(component);
|
|
2833
|
+
return fn(options);
|
|
2834
|
+
}
|
|
2835
|
+
return Promise.resolve();
|
|
2836
|
+
}
|
|
2837
|
+
function asClassComponent$1(component) {
|
|
2838
|
+
return class extends Svelte4Component {
|
|
2839
|
+
/** @param {any} options */
|
|
2840
|
+
constructor(options) {
|
|
2841
|
+
super({
|
|
2842
|
+
component,
|
|
2843
|
+
...options
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
class Svelte4Component {
|
|
2849
|
+
/** @type {any} */
|
|
2850
|
+
#events;
|
|
2851
|
+
/** @type {Record<string, any>} */
|
|
2852
|
+
#instance;
|
|
2853
|
+
/**
|
|
2854
|
+
* @param {ComponentConstructorOptions & {
|
|
2855
|
+
* component: any;
|
|
2856
|
+
* }} options
|
|
2857
|
+
*/
|
|
2858
|
+
constructor(options) {
|
|
2859
|
+
var sources = /* @__PURE__ */ new Map();
|
|
2860
|
+
var add_source = (key, value) => {
|
|
2861
|
+
var s = /* @__PURE__ */ mutable_source(value, false, false);
|
|
2862
|
+
sources.set(key, s);
|
|
2863
|
+
return s;
|
|
2864
|
+
};
|
|
2865
|
+
const props = new Proxy(
|
|
2866
|
+
{ ...options.props || {}, $$events: {} },
|
|
2867
|
+
{
|
|
2868
|
+
get(target, prop) {
|
|
2869
|
+
return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
2870
|
+
},
|
|
2871
|
+
has(target, prop) {
|
|
2872
|
+
if (prop === LEGACY_PROPS) return true;
|
|
2873
|
+
get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
2874
|
+
return Reflect.has(target, prop);
|
|
2875
|
+
},
|
|
2876
|
+
set(target, prop, value) {
|
|
2877
|
+
set(sources.get(prop) ?? add_source(prop, value), value);
|
|
2878
|
+
return Reflect.set(target, prop, value);
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
);
|
|
2882
|
+
this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
|
|
2883
|
+
target: options.target,
|
|
2884
|
+
anchor: options.anchor,
|
|
2885
|
+
props,
|
|
2886
|
+
context: options.context,
|
|
2887
|
+
intro: options.intro ?? false,
|
|
2888
|
+
recover: options.recover,
|
|
2889
|
+
transformError: options.transformError
|
|
2890
|
+
});
|
|
2891
|
+
if (!options?.props?.$$host || options.sync === false) {
|
|
2892
|
+
flushSync();
|
|
2893
|
+
}
|
|
2894
|
+
this.#events = props.$$events;
|
|
2895
|
+
for (const key of Object.keys(this.#instance)) {
|
|
2896
|
+
if (key === "$set" || key === "$destroy" || key === "$on") continue;
|
|
2897
|
+
define_property(this, key, {
|
|
2898
|
+
get() {
|
|
2899
|
+
return this.#instance[key];
|
|
2900
|
+
},
|
|
2901
|
+
/** @param {any} value */
|
|
2902
|
+
set(value) {
|
|
2903
|
+
this.#instance[key] = value;
|
|
2904
|
+
},
|
|
2905
|
+
enumerable: true
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
this.#instance.$set = /** @param {Record<string, any>} next */
|
|
2909
|
+
(next2) => {
|
|
2910
|
+
Object.assign(props, next2);
|
|
2911
|
+
};
|
|
2912
|
+
this.#instance.$destroy = () => {
|
|
2913
|
+
unmount(this.#instance);
|
|
2914
|
+
};
|
|
2915
|
+
}
|
|
2916
|
+
/** @param {Record<string, any>} props */
|
|
2917
|
+
$set(props) {
|
|
2918
|
+
this.#instance.$set(props);
|
|
2919
|
+
}
|
|
2920
|
+
/**
|
|
2921
|
+
* @param {string} event
|
|
2922
|
+
* @param {(...args: any[]) => any} callback
|
|
2923
|
+
* @returns {any}
|
|
2924
|
+
*/
|
|
2925
|
+
$on(event, callback) {
|
|
2926
|
+
this.#events[event] = this.#events[event] || [];
|
|
2927
|
+
const cb = (...args) => callback.call(this, ...args);
|
|
2928
|
+
this.#events[event].push(cb);
|
|
2929
|
+
return () => {
|
|
2930
|
+
this.#events[event] = this.#events[event].filter(
|
|
2931
|
+
/** @param {any} fn */
|
|
2932
|
+
(fn) => fn !== cb
|
|
2933
|
+
);
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
$destroy() {
|
|
2937
|
+
this.#instance.$destroy();
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
function asClassComponent(component) {
|
|
2941
|
+
const component_constructor = asClassComponent$1(component);
|
|
2942
|
+
const _render = (props, { context, csp, transformError } = {}) => {
|
|
2943
|
+
const result = render(component, { props, context, csp, transformError });
|
|
2944
|
+
const munged = Object.defineProperties(
|
|
2945
|
+
/** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */
|
|
2946
|
+
{},
|
|
2947
|
+
{
|
|
2948
|
+
css: {
|
|
2949
|
+
value: { code: "", map: null }
|
|
2950
|
+
},
|
|
2951
|
+
head: {
|
|
2952
|
+
get: () => result.head
|
|
2953
|
+
},
|
|
2954
|
+
html: {
|
|
2955
|
+
get: () => result.body
|
|
2956
|
+
},
|
|
2957
|
+
then: {
|
|
2958
|
+
/**
|
|
2959
|
+
* this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
|
|
2960
|
+
*
|
|
2961
|
+
* @template TResult1
|
|
2962
|
+
* @template [TResult2=never]
|
|
2963
|
+
* @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
|
|
2964
|
+
* @param { (reason: unknown) => TResult2 } onrejected
|
|
2965
|
+
*/
|
|
2966
|
+
value: (onfulfilled, onrejected) => {
|
|
2967
|
+
{
|
|
2968
|
+
const user_result = onfulfilled({
|
|
2969
|
+
css: munged.css,
|
|
2970
|
+
head: munged.head,
|
|
2971
|
+
html: munged.html
|
|
2972
|
+
});
|
|
2973
|
+
return Promise.resolve(user_result);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
);
|
|
2979
|
+
return munged;
|
|
2980
|
+
};
|
|
2981
|
+
component_constructor.render = _render;
|
|
2982
|
+
return component_constructor;
|
|
2983
|
+
}
|
|
2984
|
+
function Root($$renderer, $$props) {
|
|
2985
|
+
$$renderer.component(($$renderer2) => {
|
|
2986
|
+
let {
|
|
2987
|
+
stores,
|
|
2988
|
+
page,
|
|
2989
|
+
constructors,
|
|
2990
|
+
components = [],
|
|
2991
|
+
form,
|
|
2992
|
+
data_0 = null,
|
|
2993
|
+
data_1 = null
|
|
2994
|
+
} = $$props;
|
|
2995
|
+
{
|
|
2996
|
+
setContext("__svelte__", stores);
|
|
2997
|
+
}
|
|
2998
|
+
{
|
|
2999
|
+
stores.page.set(page);
|
|
3000
|
+
}
|
|
3001
|
+
const Pyramid_1 = derived(() => constructors[1]);
|
|
3002
|
+
if (constructors[1]) {
|
|
3003
|
+
$$renderer2.push("<!--[0-->");
|
|
3004
|
+
const Pyramid_0 = constructors[0];
|
|
3005
|
+
if (Pyramid_0) {
|
|
3006
|
+
$$renderer2.push("<!--[-->");
|
|
3007
|
+
Pyramid_0($$renderer2, {
|
|
3008
|
+
data: data_0,
|
|
3009
|
+
form,
|
|
3010
|
+
params: page.params,
|
|
3011
|
+
children: ($$renderer3) => {
|
|
3012
|
+
if (Pyramid_1()) {
|
|
3013
|
+
$$renderer3.push("<!--[-->");
|
|
3014
|
+
Pyramid_1()($$renderer3, { data: data_1, form, params: page.params });
|
|
3015
|
+
$$renderer3.push("<!--]-->");
|
|
3016
|
+
} else {
|
|
3017
|
+
$$renderer3.push("<!--[!-->");
|
|
3018
|
+
$$renderer3.push("<!--]-->");
|
|
3019
|
+
}
|
|
3020
|
+
},
|
|
3021
|
+
$$slots: { default: true }
|
|
3022
|
+
});
|
|
3023
|
+
$$renderer2.push("<!--]-->");
|
|
3024
|
+
} else {
|
|
3025
|
+
$$renderer2.push("<!--[!-->");
|
|
3026
|
+
$$renderer2.push("<!--]-->");
|
|
3027
|
+
}
|
|
3028
|
+
} else {
|
|
3029
|
+
$$renderer2.push("<!--[-1-->");
|
|
3030
|
+
const Pyramid_0 = constructors[0];
|
|
3031
|
+
if (Pyramid_0) {
|
|
3032
|
+
$$renderer2.push("<!--[-->");
|
|
3033
|
+
Pyramid_0($$renderer2, { data: data_0, form, params: page.params });
|
|
3034
|
+
$$renderer2.push("<!--]-->");
|
|
3035
|
+
} else {
|
|
3036
|
+
$$renderer2.push("<!--[!-->");
|
|
3037
|
+
$$renderer2.push("<!--]-->");
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
$$renderer2.push(`<!--]--> `);
|
|
3041
|
+
{
|
|
3042
|
+
$$renderer2.push("<!--[-1-->");
|
|
3043
|
+
}
|
|
3044
|
+
$$renderer2.push(`<!--]-->`);
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
const root = asClassComponent(Root);
|
|
3048
|
+
|
|
3049
|
+
const internal = new URL("sveltekit-internal://");
|
|
3050
|
+
function resolve(base, path) {
|
|
3051
|
+
if (path[0] === "/" && path[1] === "/") return path;
|
|
3052
|
+
let url = new URL(base, internal);
|
|
3053
|
+
url = new URL(path, url);
|
|
3054
|
+
return url.protocol === internal.protocol ? url.pathname + url.search + url.hash : url.href;
|
|
3055
|
+
}
|
|
3056
|
+
function normalize_path(path, trailing_slash) {
|
|
3057
|
+
if (path === "/" || trailing_slash === "ignore") return path;
|
|
3058
|
+
if (trailing_slash === "never") {
|
|
3059
|
+
return path.endsWith("/") ? path.slice(0, -1) : path;
|
|
3060
|
+
} else if (trailing_slash === "always" && !path.endsWith("/")) {
|
|
3061
|
+
return path + "/";
|
|
3062
|
+
}
|
|
3063
|
+
return path;
|
|
3064
|
+
}
|
|
3065
|
+
function decode_pathname(pathname) {
|
|
3066
|
+
return pathname.split("%25").map(decodeURI).join("%25");
|
|
3067
|
+
}
|
|
3068
|
+
function decode_params(params) {
|
|
3069
|
+
for (const key in params) {
|
|
3070
|
+
params[key] = decodeURIComponent(params[key]);
|
|
3071
|
+
}
|
|
3072
|
+
return params;
|
|
3073
|
+
}
|
|
3074
|
+
function make_trackable(url, callback, search_params_callback, allow_hash = false) {
|
|
3075
|
+
const tracked = new URL(url);
|
|
3076
|
+
Object.defineProperty(tracked, "searchParams", {
|
|
3077
|
+
value: new Proxy(tracked.searchParams, {
|
|
3078
|
+
get(obj, key) {
|
|
3079
|
+
if (key === "get" || key === "getAll" || key === "has") {
|
|
3080
|
+
return (param, ...rest) => {
|
|
3081
|
+
search_params_callback(param);
|
|
3082
|
+
return obj[key](param, ...rest);
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
callback();
|
|
3086
|
+
const value = Reflect.get(obj, key);
|
|
3087
|
+
return typeof value === "function" ? value.bind(obj) : value;
|
|
3088
|
+
}
|
|
3089
|
+
}),
|
|
3090
|
+
enumerable: true,
|
|
3091
|
+
configurable: true
|
|
3092
|
+
});
|
|
3093
|
+
const tracked_url_properties = ["href", "pathname", "search", "toString", "toJSON"];
|
|
3094
|
+
if (allow_hash) tracked_url_properties.push("hash");
|
|
3095
|
+
for (const property of tracked_url_properties) {
|
|
3096
|
+
Object.defineProperty(tracked, property, {
|
|
3097
|
+
get() {
|
|
3098
|
+
callback();
|
|
3099
|
+
return url[property];
|
|
3100
|
+
},
|
|
3101
|
+
enumerable: true,
|
|
3102
|
+
configurable: true
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
{
|
|
3106
|
+
tracked[Symbol.for("nodejs.util.inspect.custom")] = (_depth, opts, inspect) => {
|
|
3107
|
+
return inspect(url, opts);
|
|
3108
|
+
};
|
|
3109
|
+
tracked.searchParams[Symbol.for("nodejs.util.inspect.custom")] = (_depth, opts, inspect) => {
|
|
3110
|
+
return inspect(url.searchParams, opts);
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3113
|
+
if (!allow_hash) {
|
|
3114
|
+
disable_hash(tracked);
|
|
3115
|
+
}
|
|
3116
|
+
return tracked;
|
|
3117
|
+
}
|
|
3118
|
+
function disable_hash(url) {
|
|
3119
|
+
allow_nodejs_console_log(url);
|
|
3120
|
+
Object.defineProperty(url, "hash", {
|
|
3121
|
+
get() {
|
|
3122
|
+
throw new Error(
|
|
3123
|
+
"Cannot access event.url.hash. Consider using `page.url.hash` inside a component instead"
|
|
3124
|
+
);
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
function disable_search(url) {
|
|
3129
|
+
allow_nodejs_console_log(url);
|
|
3130
|
+
for (const property of ["search", "searchParams"]) {
|
|
3131
|
+
Object.defineProperty(url, property, {
|
|
3132
|
+
get() {
|
|
3133
|
+
throw new Error(`Cannot access url.${property} on a page with prerendering enabled`);
|
|
3134
|
+
}
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
function allow_nodejs_console_log(url) {
|
|
3139
|
+
{
|
|
3140
|
+
url[Symbol.for("nodejs.util.inspect.custom")] = (_depth, opts, inspect) => {
|
|
3141
|
+
return inspect(new URL(url), opts);
|
|
3142
|
+
};
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
const subscriber_queue = [];
|
|
3146
|
+
function readable(value, start) {
|
|
3147
|
+
return {
|
|
3148
|
+
subscribe: writable(value, start).subscribe
|
|
3149
|
+
};
|
|
3150
|
+
}
|
|
3151
|
+
function writable(value, start = noop) {
|
|
3152
|
+
let stop = null;
|
|
3153
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
3154
|
+
function set(new_value) {
|
|
3155
|
+
if (safe_not_equal(value, new_value)) {
|
|
3156
|
+
value = new_value;
|
|
3157
|
+
if (stop) {
|
|
3158
|
+
const run_queue = !subscriber_queue.length;
|
|
3159
|
+
for (const subscriber of subscribers) {
|
|
3160
|
+
subscriber[1]();
|
|
3161
|
+
subscriber_queue.push(subscriber, value);
|
|
3162
|
+
}
|
|
3163
|
+
if (run_queue) {
|
|
3164
|
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
|
3165
|
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
|
3166
|
+
}
|
|
3167
|
+
subscriber_queue.length = 0;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
function update(fn) {
|
|
3173
|
+
set(fn(
|
|
3174
|
+
/** @type {T} */
|
|
3175
|
+
value
|
|
3176
|
+
));
|
|
3177
|
+
}
|
|
3178
|
+
function subscribe(run, invalidate = noop) {
|
|
3179
|
+
const subscriber = [run, invalidate];
|
|
3180
|
+
subscribers.add(subscriber);
|
|
3181
|
+
if (subscribers.size === 1) {
|
|
3182
|
+
stop = start(set, update) || noop;
|
|
3183
|
+
}
|
|
3184
|
+
run(
|
|
3185
|
+
/** @type {T} */
|
|
3186
|
+
value
|
|
3187
|
+
);
|
|
3188
|
+
return () => {
|
|
3189
|
+
subscribers.delete(subscriber);
|
|
3190
|
+
if (subscribers.size === 0 && stop) {
|
|
3191
|
+
stop();
|
|
3192
|
+
stop = null;
|
|
3193
|
+
}
|
|
3194
|
+
};
|
|
3195
|
+
}
|
|
3196
|
+
return { set, update, subscribe };
|
|
3197
|
+
}
|
|
3198
|
+
function validator(expected) {
|
|
3199
|
+
function validate(module, file) {
|
|
3200
|
+
if (!module) return;
|
|
3201
|
+
for (const key in module) {
|
|
3202
|
+
if (key[0] === "_" || expected.has(key)) continue;
|
|
3203
|
+
const values = [...expected.values()];
|
|
3204
|
+
const hint = hint_for_supported_files(key, file?.slice(file.lastIndexOf("."))) ?? `valid exports are ${values.join(", ")}, or anything with a '_' prefix`;
|
|
3205
|
+
throw new Error(`Invalid export '${key}'${file ? ` in ${file}` : ""} (${hint})`);
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
return validate;
|
|
3209
|
+
}
|
|
3210
|
+
function hint_for_supported_files(key, ext = ".js") {
|
|
3211
|
+
const supported_files = [];
|
|
3212
|
+
if (valid_layout_exports.has(key)) {
|
|
3213
|
+
supported_files.push(`+layout${ext}`);
|
|
3214
|
+
}
|
|
3215
|
+
if (valid_page_exports.has(key)) {
|
|
3216
|
+
supported_files.push(`+page${ext}`);
|
|
3217
|
+
}
|
|
3218
|
+
if (valid_layout_server_exports.has(key)) {
|
|
3219
|
+
supported_files.push(`+layout.server${ext}`);
|
|
3220
|
+
}
|
|
3221
|
+
if (valid_page_server_exports.has(key)) {
|
|
3222
|
+
supported_files.push(`+page.server${ext}`);
|
|
3223
|
+
}
|
|
3224
|
+
if (valid_server_exports.has(key)) {
|
|
3225
|
+
supported_files.push(`+server${ext}`);
|
|
3226
|
+
}
|
|
3227
|
+
if (supported_files.length > 0) {
|
|
3228
|
+
return `'${key}' is a valid export in ${supported_files.slice(0, -1).join(", ")}${supported_files.length > 1 ? " or " : ""}${supported_files.at(-1)}`;
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
const valid_layout_exports = /* @__PURE__ */ new Set([
|
|
3232
|
+
"load",
|
|
3233
|
+
"prerender",
|
|
3234
|
+
"csr",
|
|
3235
|
+
"ssr",
|
|
3236
|
+
"trailingSlash",
|
|
3237
|
+
"config"
|
|
3238
|
+
]);
|
|
3239
|
+
const valid_page_exports = /* @__PURE__ */ new Set([...valid_layout_exports, "entries"]);
|
|
3240
|
+
const valid_layout_server_exports = /* @__PURE__ */ new Set([...valid_layout_exports]);
|
|
3241
|
+
const valid_page_server_exports = /* @__PURE__ */ new Set([...valid_layout_server_exports, "actions", "entries"]);
|
|
3242
|
+
const valid_server_exports = /* @__PURE__ */ new Set([
|
|
3243
|
+
"GET",
|
|
3244
|
+
"POST",
|
|
3245
|
+
"PATCH",
|
|
3246
|
+
"PUT",
|
|
3247
|
+
"DELETE",
|
|
3248
|
+
"OPTIONS",
|
|
3249
|
+
"HEAD",
|
|
3250
|
+
"fallback",
|
|
3251
|
+
"prerender",
|
|
3252
|
+
"trailingSlash",
|
|
3253
|
+
"config",
|
|
3254
|
+
"entries"
|
|
3255
|
+
]);
|
|
3256
|
+
const validate_layout_exports = validator(valid_layout_exports);
|
|
3257
|
+
const validate_page_exports = validator(valid_page_exports);
|
|
3258
|
+
const validate_layout_server_exports = validator(valid_layout_server_exports);
|
|
3259
|
+
const validate_page_server_exports = validator(valid_page_server_exports);
|
|
3260
|
+
|
|
3261
|
+
export { BROWSER as B, base64_encode as a, base64_decode as b, decode_pathname as c, decode_params as d, disable_search as e, resolve as f, get_relative_path as g, root as h, validate_layout_server_exports as i, validate_page_exports as j, validate_page_server_exports as k, writable as l, make_trackable as m, normalize_path as n, readable as r, text_encoder as t, validate_layout_exports as v, with_request_store as w };
|
|
3262
|
+
//# sourceMappingURL=exports-BnaAAAnL.js.map
|