@manyducks.co/dolla 3.1.0 → 3.3.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.
@@ -1,242 +0,0 @@
1
- import { c as e, n as t, o as n, p as r, r as i, t as a, u as o } from "./signals-CMJPGr_M.js";
2
- import { S as s, _ as c, b as l, d as u, f as d, g as f, h as p, m, n as h, o as g, u as _, v, x as y, y as b } from "./context-B5blupD2.js";
3
- //#region src/core/root.ts
4
- function x(t, n) {
5
- let i = r(t) ? document.querySelector(t) : t;
6
- e(i, "Element cannot be null.");
7
- let a = h();
8
- a.name = "dolla:root";
9
- let s = [], l = [];
10
- a[b] = i, a[v] = !!n?.debug;
11
- let d = null, f = {
12
- plugin: p,
13
- mount: m,
14
- unmount: y
15
- };
16
- function p(e) {
17
- return s.push(e), f;
18
- }
19
- async function m(e) {
20
- if (a.isMounted) return;
21
- let t = await Promise.all(s.map((e) => e(a)));
22
- for (let e of t) o(e) && l.push(e);
23
- d = o(e) ? new u(a, e, {}) : c(e, a), d?.mount(i), g(a);
24
- }
25
- async function y() {
26
- a.isMounted && (d?.unmount(!1), d = null, _(a), await Promise.all(l.map((e) => e())), l.length = 0);
27
- }
28
- return f;
29
- }
30
- //#endregion
31
- //#region src/core/debug.ts
32
- var S = () => {}, C = {
33
- trace: 1,
34
- info: 1,
35
- log: 2,
36
- warn: 3,
37
- error: 4,
38
- silent: 5
39
- }, w = 1, T = (e) => !e.startsWith("dolla:"), E = (e) => {
40
- w = C[e] || 1;
41
- }, D = (e) => {
42
- T = e;
43
- }, O = globalThis.console || {};
44
- function k(e, ...t) {
45
- let n = e.name, r, i = (e, i) => {
46
- if (i < w || !T(n) || !O[e]) return S;
47
- if (!r) {
48
- let e = "%c" + n, i = [`color:${j(n)};font-weight:bold`];
49
- for (let [n, r] of t) e += `%c[${n}: %c${r}%c]`, i.push("color:#777", "color:#aaa", "color:#777");
50
- r = [e, ...i];
51
- }
52
- return O[e].bind(O, ...r);
53
- };
54
- return {
55
- get info() {
56
- return i("info", 1);
57
- },
58
- get trace() {
59
- return i("trace", 1);
60
- },
61
- get log() {
62
- return i("log", 2);
63
- },
64
- get warn() {
65
- return i("warn", 3);
66
- },
67
- get error() {
68
- return i("error", 4);
69
- }
70
- };
71
- }
72
- function A(e, ...t) {
73
- let n = h();
74
- return n.name = e, k(n, ...t);
75
- }
76
- function j(e) {
77
- let t = 0;
78
- for (let n = 0; n < e.length; n++) t = (t + e.charCodeAt(n) * 10) % 360;
79
- return `oklch(0.68 0.15 ${t}deg)`;
80
- }
81
- //#endregion
82
- //#region src/core/markup/nodes/portal.ts
83
- var M = class extends s {
84
- #e = p("");
85
- #t;
86
- #n;
87
- #r;
88
- #i;
89
- constructor(e, t, n) {
90
- super(), this.#t = e, this.#n = t, this.#r = n;
91
- }
92
- getRoot() {
93
- return this.#e;
94
- }
95
- isMounted() {
96
- return this.#e.parentNode != null;
97
- }
98
- mount(e, t) {
99
- this.isMounted() || (d(e, this.#e, t), this.#i ||= c(this.#n, this.#t), this.#i.mount(this.#r));
100
- }
101
- unmount(e = !1) {
102
- this.isMounted() && (e || this.#e.parentNode?.removeChild(this.#e), this.#i?.isMounted() && this.#i.unmount(!1));
103
- }
104
- move(e, t) {
105
- f(e, this.#e, t);
106
- }
107
- }, N = class extends s {
108
- #e = p("");
109
- #t;
110
- #n;
111
- #r;
112
- #i;
113
- #a = null;
114
- #o = /* @__PURE__ */ new Map();
115
- constructor(e, t, n, r) {
116
- super(), this.#t = e, this.#n = t, this.#r = n, this.#i = r;
117
- }
118
- getRoot() {
119
- return this.#e;
120
- }
121
- isMounted() {
122
- return this.#e.parentNode != null;
123
- }
124
- mount(e, t) {
125
- this.isMounted() || (d(e, this.#e, t), this.#a = n(this.#n, (e) => {
126
- y(() => {
127
- this._update(Array.from(e));
128
- });
129
- }));
130
- }
131
- unmount(e = !1) {
132
- this.#a &&= (this.#a(), null), !e && this.isMounted() && this.#e.parentNode?.removeChild(this.#e), this._cleanup(e);
133
- }
134
- move(e, t) {
135
- return this.mount(e, t);
136
- }
137
- _cleanup(e) {
138
- for (let t of this.#o.values()) t._node.unmount(e);
139
- this.#o.clear();
140
- }
141
- _update(e) {
142
- if (!this.isMounted()) return;
143
- if (e.length === 0) return this._cleanup(!1);
144
- let t = /* @__PURE__ */ new Map();
145
- a(() => {
146
- let n = new Set(e.map((e, t) => this.#r(e, t)));
147
- for (let [e, t] of this.#o.entries()) n.has(e) || t._node.unmount(!1);
148
- for (let r = 0; r < e.length; r++) {
149
- let a = e[r], o = this.#r(a, r), s = this.#o.get(o);
150
- if (s && n.has(o)) s._setItem(a), s._setIndex(r);
151
- else {
152
- let [e, t] = i(a), [n, l] = i(r);
153
- s = {
154
- _key: o,
155
- _node: c(this.#i(() => e(), () => n()), this.#t),
156
- _item: e,
157
- _setItem: t,
158
- _index: n,
159
- _setIndex: l
160
- };
161
- }
162
- t.set(o, s);
163
- }
164
- }), this.#o = t;
165
- let n = this.#e.parentElement, r = this.#e;
166
- for (let e of this.#o.values()) {
167
- let t = r.nextSibling;
168
- e._node.isMounted() ? e._node.getRoot() !== t && e._node.move(n, r) : e._node.mount(n, r), r = e._node.getRoot();
169
- }
170
- }
171
- };
172
- //#endregion
173
- //#region src/core/markup/helpers.ts
174
- function P(e, t, n) {
175
- return o(e) ? m(N, { args: [
176
- e,
177
- t,
178
- n
179
- ] }) : Array.from(e).map((e, t) => n(() => e, () => t));
180
- }
181
- function F(e, n, r) {
182
- return o(e) ? m(l, { args: [t(() => e() ? n : r)] }) : e ? n : r;
183
- }
184
- function I(e, t, n) {
185
- return F(e, t, n);
186
- }
187
- function L(e, t, n) {
188
- return F(e, n, t);
189
- }
190
- function R(e, t) {
191
- return m(M, { args: [t, e] });
192
- }
193
- //#endregion
194
- //#region src/core/markup/html.ts
195
- var z = /* @__PURE__ */ function(e) {
196
- return e[e.Slash = 0] = "Slash", e[e.Text = 1] = "Text", e[e.Whitespace = 2] = "Whitespace", e[e.TagName = 3] = "TagName", e[e.Comment = 4] = "Comment", e[e.PropSet = 5] = "PropSet", e[e.PropAppend = 6] = "PropAppend", e;
197
- }(z || {});
198
- function B(e, ...t) {
199
- let n = [e, ...t], r = z.Text, i = "", a = "", o = [0], s = "", c = (e) => {
200
- r === z.Text && (e || (i = i.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? o.push(e ? n[e] : i) : r === z.TagName && (e || i) ? (o[1] = e ? n[e] : i, r = z.Whitespace) : r === z.Whitespace && i === "..." && e ? o[2] = Object.assign(o[2] || {}, n[e]) : r === z.Whitespace && i && !e ? (o[2] = o[2] || {})[i] = !0 : r >= z.PropSet && (r === z.PropSet ? ((o[2] = o[2] || {})[s] = e ? i ? i + n[e] : n[e] : i, r = z.PropAppend) : (e || i) && (o[2][s] += e ? i + n[e] : i)), i = "";
201
- };
202
- for (let t = 0; t < e.length; t++) {
203
- t && (r === z.Text && c(), c(t));
204
- for (let n = 0; n < e[t].length; n++) {
205
- let l = e[t][n];
206
- if (r === z.Text) l === "<" ? (c(), o = [
207
- o,
208
- "",
209
- null
210
- ], r = z.TagName) : i += l;
211
- else if (r === z.Comment) i === "--" && l === ">" ? (r = z.Text, i = "") : i = l + i[0];
212
- else if (a) l === a ? a = "" : i += l;
213
- else if (l === "\"" || l === "'") a = l;
214
- else if (l === ">") c(), r = z.Text;
215
- else if (r) if (l === "=") r = z.PropSet, s = i, i = "";
216
- else if (l === "/" && (r < z.PropSet || e[t][n + 1] === ">")) {
217
- c(), r === z.TagName && (o = o[0]);
218
- let e = o;
219
- o = o[0];
220
- let t = e[1], n = e[2] || {}, i = e.slice(3);
221
- o.push(m(t, {
222
- ...n,
223
- children: i
224
- })), r = z.Slash;
225
- } else l === " " || l === " " || l === "\n" || l === "\r" ? (c(), r = z.Whitespace) : i += l;
226
- r === z.TagName && i === "!--" && (r = z.Comment, o = o[0]);
227
- }
228
- }
229
- return c(), o.length > 2 ? o.slice(1) : o[1];
230
- }
231
- //#endregion
232
- //#region src/core/ref.ts
233
- function V() {
234
- let e;
235
- return ((...t) => t.length ? (e = t[0], () => {
236
- e = void 0;
237
- }) : e);
238
- }
239
- //#endregion
240
- export { L as a, k as c, x as d, P as i, D as l, B as n, I as o, R as r, A as s, V as t, E as u };
241
-
242
- //# sourceMappingURL=core-JHktdqjt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-JHktdqjt.js","names":["#context","#value","#parent","#anchor","#childNode","#context","#items","#key","#render","#root","#unsubscribe","#connectedItems"],"sources":["../src/core/root.ts","../src/core/debug.ts","../src/core/markup/nodes/portal.ts","../src/core/markup/nodes/repeat.ts","../src/core/markup/helpers.ts","../src/core/markup/html.ts","../src/core/ref.ts"],"sourcesContent":["import type { Renderable, View } from \"../types.js\";\nimport { assert, isFunction, isString } from \"../utils.js\";\nimport { type Context, createContext, mountContext, unmountContext } from \"./context.js\";\nimport { ViewNode } from \"./markup/nodes/view.js\";\nimport { type MarkupNode } from \"./markup/types.js\";\nimport { render } from \"./markup/utils.js\";\nimport { DEBUG, PARENT_ELEMENT } from \"./symbols.js\";\n\nexport type CleanupCallback = () => void | Promise<void>;\n\n/**\n * Plugins run before the app is mounted. If they return a promise, mounting will be delayed until the promise resolves.\n * If a cleanup function is returned, it will be called before the app is unmounted. The cleanup function's promise will delay unmounting.\n *\n * Hooks can be used inside plugins.\n */\nexport type DollaPlugin = (context: Context) => Promise<CleanupCallback | void> | CleanupCallback | void;\n\nexport interface DollaRootOptions {\n /**\n * Adds additional view info to the DOM to help with debugging.\n */\n debug?: boolean;\n}\n\nexport interface DollaRoot {\n /**\n * Registers a plugin to be added before `mount`.\n */\n plugin(plugin: DollaPlugin): DollaRoot;\n\n /**\n * Mounts a `view` to this root.\n */\n mount(view: View<{}>): Promise<void>;\n\n /**\n * Mounts any renderable content to this root.\n */\n mount(content: Renderable): Promise<void>;\n\n /**\n * Unmounts the currently mounted content.\n */\n unmount(): void;\n}\n\nexport function createRoot(selector: string, options?: DollaRootOptions): DollaRoot;\nexport function createRoot(element: Element, options?: DollaRootOptions): DollaRoot;\nexport function createRoot(target: string | Element, options?: DollaRootOptions) {\n const element = isString(target) ? document.querySelector(target) : target;\n assert(element, \"Element cannot be null.\");\n\n const context = createContext();\n context.name = \"dolla:root\";\n\n const plugins: DollaPlugin[] = [];\n const cleanup: CleanupCallback[] = [];\n\n context[PARENT_ELEMENT] = element;\n context[DEBUG] = Boolean(options?.debug);\n\n let rootNode: MarkupNode | null = null;\n\n const self: DollaRoot = { plugin, mount, unmount };\n\n function plugin(plugin: DollaPlugin) {\n plugins.push(plugin);\n return self;\n }\n\n async function mount(content: View<{}> | Renderable) {\n if (context.isMounted) return;\n\n const results = await Promise.all(plugins.map((fn) => fn(context)));\n for (const result of results) {\n if (isFunction<CleanupCallback>(result)) {\n cleanup.push(result);\n }\n }\n\n rootNode = isFunction<View<{}>>(content) ? new ViewNode(context, content, {}) : render(content, context);\n rootNode?.mount(element!);\n\n mountContext(context);\n }\n\n async function unmount() {\n if (!context.isMounted) return;\n\n rootNode?.unmount(false);\n rootNode = null;\n\n unmountContext(context);\n\n await Promise.all(cleanup.map((callback) => callback()));\n cleanup.length = 0;\n }\n\n return self;\n}\n","import { Context, createContext } from \"./context.js\";\n\nexport const noOp = () => {};\n\nexport type LogLevel = \"info\" | \"log\" | \"warn\" | \"error\" | \"silent\";\nconst LEVELS: Record<string, number> = { trace: 1, info: 1, log: 2, warn: 3, error: 4, silent: 5 };\n\nlet logLevel = 1;\nlet logFilter = (name: string) => !name.startsWith(\"dolla:\");\n\n// 3. Extracted configuration setters (replacing static class methods)\nexport const setLogLevel = (level: LogLevel) => {\n logLevel = LEVELS[level] || 1;\n};\nexport const setLogFilter = (filter: (name: string) => boolean) => {\n logFilter = filter;\n};\n\nconst c: any = globalThis.console || {};\n\nexport function getDebug(context: Context, ...tags: [string, any][]) {\n const name = context.name;\n let args: any[];\n\n const make = (method: string, level: number): ((...args: any[]) => void) => {\n if (level < logLevel || !logFilter(name) || !c[method]) return noOp;\n\n // Build and cache the console arguments on the first valid log\n if (!args) {\n let p = \"%c\" + name;\n let s = [`color:${okhash(name)};font-weight:bold`];\n for (const [k, v] of tags) {\n p += `%c[${k}: %c${v}%c]`;\n s.push(\"color:#777\", \"color:#aaa\", \"color:#777\");\n }\n args = [p, ...s];\n }\n\n return c[method].bind(c, ...args);\n };\n\n return {\n get info() {\n return make(\"info\", 1);\n },\n get trace() {\n return make(\"trace\", 1);\n },\n get log() {\n return make(\"log\", 2);\n },\n get warn() {\n return make(\"warn\", 3);\n },\n get error() {\n return make(\"error\", 4);\n },\n };\n}\n\nexport function createDebug(name: string, ...tags: [string, any][]) {\n const context = createContext();\n context.name = name;\n return getDebug(context, ...tags);\n}\n\n/**\n * Takes any string and returns an OKLCH color.\n */\nfunction okhash(value: string) {\n let hue = 0;\n for (let i = 0; i < value.length; i++) {\n hue = (hue + value.charCodeAt(i) * 10) % 360;\n }\n return `oklch(0.68 0.15 ${hue}deg)`;\n}\n","import type { Renderable } from \"../../../types.js\";\nimport { Context } from \"../../context.js\";\nimport { MarkupNode, MountTarget } from \"../types.js\";\nimport { addChild, createTextNode, moveAfter, render } from \"../utils.js\";\n\n/**\n * Renders content into a specified parent node.\n */\nexport class PortalNode extends MarkupNode {\n // Acts as a physical placeholder in the logical DOM tree\n #anchor = createTextNode(\"\");\n\n #context: Context;\n #value: Renderable;\n #parent: MountTarget;\n #childNode?: MarkupNode;\n\n constructor(context: Context, value: Renderable, parent: MountTarget) {\n super();\n this.#context = context;\n this.#value = value;\n this.#parent = parent;\n }\n\n override getRoot() {\n // Return the anchor, allowing siblings to mount correctly around it\n return this.#anchor;\n }\n\n override isMounted() {\n return this.#anchor.parentNode != null;\n }\n\n override mount(logicalParent: MountTarget, after?: Node) {\n if (!this.isMounted()) {\n // Mount the anchor in the standard document flow\n addChild(logicalParent, this.#anchor, after);\n\n // Render the content and mount it to the portal target\n if (!this.#childNode) {\n this.#childNode = render(this.#value, this.#context);\n }\n this.#childNode.mount(this.#parent);\n }\n }\n\n override unmount(skipDOM = false) {\n if (this.isMounted()) {\n if (!skipDOM) {\n this.#anchor.parentNode?.removeChild(this.#anchor);\n }\n\n // Portals always force unmount the DOM of their children\n if (this.#childNode?.isMounted()) {\n this.#childNode.unmount(false);\n }\n }\n }\n\n override move(logicalParent: MountTarget, after?: Node) {\n moveAfter(logicalParent, this.#anchor, after);\n }\n}\n","import type { Renderable } from \"../../../types.js\";\nimport type { Context } from \"../../context.js\";\nimport { batch, type Getter, createAtom, subscribe, type Setter } from \"../../signals.js\";\nimport { scheduleUpdate } from \"../scheduler.js\";\nimport { MarkupNode } from \"../types.js\";\nimport { addChild, createTextNode, render } from \"../utils.js\";\n\n// ----- Types ----- //\n\nexport type Key = any;\n\nexport type KeyFn<T> = (item: T, index: number) => Key;\nexport type RenderFn<T> = (item: Getter<T>, index: Getter<number>) => Renderable;\n\ntype ConnectedItem<T> = {\n _key: Key;\n _item: Getter<T>;\n _setItem: Setter<T>;\n _index: Getter<number>;\n _setIndex: Setter<number>;\n _node: MarkupNode;\n};\n\n// ----- Code ----- //\n\n/**\n * Renders a list of items.\n */\nexport class RepeatNode<T> extends MarkupNode {\n #root = createTextNode(\"\");\n\n #context;\n\n #items: Getter<Iterable<T>>;\n #key: KeyFn<T>;\n #render: RenderFn<T>;\n\n #unsubscribe: (() => void) | null = null;\n #connectedItems: Map<Key, ConnectedItem<T>> = new Map();\n\n constructor(context: Context, items: Getter<Iterable<T>>, key: KeyFn<T>, render: RenderFn<T>) {\n super();\n this.#context = context;\n\n this.#items = items;\n this.#key = key;\n this.#render = render;\n }\n\n override getRoot() {\n return this.#root;\n }\n\n override isMounted() {\n return this.#root.parentNode != null;\n }\n\n override mount(parent: Element, after?: Node) {\n if (!this.isMounted()) {\n addChild(parent, this.#root, after);\n\n this.#unsubscribe = subscribe(this.#items, (items) => {\n scheduleUpdate(() => {\n this._update(Array.from(items));\n });\n });\n }\n }\n\n override unmount(skipDOM = false) {\n if (this.#unsubscribe) {\n this.#unsubscribe();\n this.#unsubscribe = null;\n }\n\n if (!skipDOM && this.isMounted()) {\n this.#root.parentNode?.removeChild(this.#root);\n }\n\n this._cleanup(skipDOM);\n }\n\n override move(parent: Element, after?: Node) {\n // TODO: Implement move\n return this.mount(parent, after);\n }\n\n private _cleanup(skipDOM: boolean) {\n for (const item of this.#connectedItems.values()) {\n item._node.unmount(skipDOM);\n }\n this.#connectedItems.clear();\n }\n\n private _update(value: T[]) {\n if (!this.isMounted()) return;\n\n if (value.length === 0) {\n return this._cleanup(false);\n }\n\n const nextItems = new Map<Key, ConnectedItem<T>>();\n\n batch(() => {\n // Track keys for the incoming list\n const nextKeys = new Set(value.map((item, index) => this.#key(item, index)));\n\n // Unmount deleted items immediately.\n // This collapses the DOM tree so surviving items sit adjacent to each other.\n for (const [key, connected] of this.#connectedItems.entries()) {\n if (!nextKeys.has(key)) {\n connected._node.unmount(false);\n }\n }\n\n // Prepare state and allocate new nodes.\n for (let i = 0; i < value.length; i++) {\n const itemVal = value[i];\n const key = this.#key(itemVal, i);\n let connected = this.#connectedItems.get(key);\n\n if (connected && nextKeys.has(key)) {\n connected._setItem(itemVal);\n connected._setIndex(i);\n } else {\n const [_item, _setItem] = createAtom(itemVal);\n const [_index, _setIndex] = createAtom(i);\n\n const renderContent = this.#render(\n () => _item(),\n () => _index(),\n );\n const _node = render(renderContent, this.#context);\n\n connected = {\n _key: key,\n _node,\n _item,\n _setItem,\n _index,\n _setIndex,\n };\n }\n nextItems.set(key, connected);\n }\n });\n\n this.#connectedItems = nextItems;\n\n // Forward pass to insert or move nodes.\n const parent = this.#root.parentElement!;\n let referenceNode: Node = this.#root;\n\n for (const connected of this.#connectedItems.values()) {\n const expectedNext = referenceNode.nextSibling;\n\n if (!connected._node.isMounted()) {\n // Node is new. Mount it exactly at the current cursor.\n connected._node.mount(parent, referenceNode);\n } else if (connected._node.getRoot() !== expectedNext) {\n // Node is out of order. Move it.\n connected._node.move(parent, referenceNode);\n }\n\n // Advance the cursor.\n referenceNode = connected._node.getRoot()!;\n }\n }\n}\n","import { createMarkup, Renderable } from \"..\";\nimport { isFunction } from \"../../utils\";\nimport { type Getter, compose } from \"../signals\";\nimport { DynamicNode } from \"./nodes/dynamic\";\nimport { PortalNode } from \"./nodes/portal\";\nimport { KeyFn, RenderFn, RepeatNode } from \"./nodes/repeat\";\n\n/**\n * Displays a dynamic list. Items will be added and removed as the list is updated.\n *\n * @param items - List items. Can be reactive.\n * @param keyFn - Takes (item, index) as plain values and returns a unique key to identify that item (usually the item's ID).\n * @param renderFn - Takes (item, index) as Reactive values and returns content to display for that item.\n */\nexport function forEach<T>(\n items: Getter<Iterable<T>> | Iterable<T>,\n keyFn: KeyFn<T>,\n renderFn: RenderFn<T>,\n): Renderable {\n if (isFunction(items)) {\n return createMarkup(RepeatNode<T>, { args: [items, keyFn, renderFn] });\n } else {\n return Array.from(items).map((item, index) =>\n renderFn(\n () => item,\n () => index,\n ),\n );\n }\n}\n\n/**\n * Displays content conditionally. When `condition` is truthy, display `content`. When `condition` is falsy, display `fallback`.\n *\n * @param condition - Condition to hide or show content on. Can be reactive.\n * @param whenTruthy - Content to display when condition is truthy.\n * @param whenFalsy - Content to display when condition is falsy.\n */\nfunction _conditional(condition: any, whenTruthy?: Renderable, whenFalsy?: Renderable): Renderable {\n if (isFunction(condition)) {\n return createMarkup(DynamicNode, {\n args: [compose(() => (condition() ? whenTruthy : whenFalsy))],\n });\n } else if (condition) {\n return whenTruthy;\n } else {\n return whenFalsy;\n }\n}\n\n/**\n * Shows content only when `condition` is truthy.\n * It can be a plain value or a Getter to track dynamically.\n *\n * @param condition - Condition to hide or show content on.\n * @param content - Content to display when condition is truthy.\n * @param fallback - Content to display when condition is falsy.\n */\nexport function showIf(condition: any, content: Renderable, fallback?: Renderable): Renderable {\n return _conditional(condition, content, fallback);\n}\n\n/**\n * Shows content only when `condition` is falsy.\n * It can be a plain value or a Getter to track dynamically.\n *\n * @param condition - Condition to hide or show content on.\n * @param content - Content to display when condition is falsy.\n * @param fallback - Content to display when condition is truthy.\n */\nexport function hideIf(condition: any, content: Renderable, fallback?: Renderable): Renderable {\n return _conditional(condition, fallback, content);\n}\n\n/**\n * Creates a portal that renders `content` into another element on the page.\n **/\nexport function createPortal(parent: Element, content: Renderable) {\n return createMarkup(PortalNode, { args: [content, parent] });\n}\n","// This file is a heavily modified version of the 'htm' library.\n// Original source: https://github.com/developit/htm\n//\n// --- Original htm License ---\n// Copyright 2018 Jason Miller\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { Markup } from \"./types.js\";\nimport { createMarkup } from \"./utils.js\";\n\nexport type Template = Markup | Markup[];\n\nconst enum Mode {\n Slash = 0,\n Text = 1,\n Whitespace = 2,\n TagName = 3,\n Comment = 4,\n PropSet = 5,\n PropAppend = 6,\n}\n\nexport function html(statics: TemplateStringsArray, ...args: any[]): Template {\n const fields = [statics, ...args];\n\n let mode = Mode.Text;\n let buffer = \"\";\n let quote = \"\";\n let current: any[] = [0];\n let propName = \"\";\n\n const commit = (field?: number) => {\n if (mode === Mode.Text && (field || (buffer = buffer.replace(/^\\s*\\n\\s*|\\s*\\n\\s*$/g, \"\")))) {\n current.push(field ? fields[field] : buffer);\n } else if (mode === Mode.TagName && (field || buffer)) {\n current[1] = field ? fields[field] : buffer;\n mode = Mode.Whitespace;\n } else if (mode === Mode.Whitespace && buffer === \"...\" && field) {\n current[2] = Object.assign(current[2] || {}, fields[field]);\n } else if (mode === Mode.Whitespace && buffer && !field) {\n (current[2] = current[2] || {})[buffer] = true;\n } else if (mode >= Mode.PropSet) {\n if (mode === Mode.PropSet) {\n (current[2] = current[2] || {})[propName] = field ? (buffer ? buffer + fields[field] : fields[field]) : buffer;\n mode = Mode.PropAppend;\n } else if (field || buffer) {\n current[2][propName] += field ? buffer + fields[field] : buffer;\n }\n }\n\n buffer = \"\";\n };\n\n for (let i = 0; i < statics.length; i++) {\n if (i) {\n if (mode === Mode.Text) commit();\n commit(i);\n }\n\n for (let j = 0; j < statics[i].length; j++) {\n const char = statics[i][j];\n\n if (mode === Mode.Text) {\n if (char === \"<\") {\n // commit buffer\n commit();\n current = [current, \"\", null];\n mode = Mode.TagName;\n } else {\n buffer += char;\n }\n } else if (mode === Mode.Comment) {\n // Ignore everything until the last three characters are '-', '-' and '>'\n if (buffer === \"--\" && char === \">\") {\n mode = Mode.Text;\n buffer = \"\";\n } else {\n buffer = char + buffer[0];\n }\n } else if (quote) {\n if (char === quote) {\n quote = \"\";\n } else {\n buffer += char;\n }\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \">\") {\n commit();\n mode = Mode.Text;\n } else if (!mode) {\n // Ignore everything until the tag ends\n } else if (char === \"=\") {\n mode = Mode.PropSet;\n propName = buffer;\n buffer = \"\";\n } else if (char === \"/\" && (mode < Mode.PropSet || statics[i][j + 1] === \">\")) {\n commit();\n if (mode === Mode.TagName) {\n current = current[0];\n }\n const node = current;\n current = current[0];\n\n const type = node[1];\n const props = node[2] || {};\n const children = node.slice(3);\n\n current.push(createMarkup(type, { ...props, children }));\n\n mode = Mode.Slash;\n } else if (char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\r\") {\n // <a disabled>\n commit();\n mode = Mode.Whitespace;\n } else {\n buffer += char;\n }\n\n if (mode === Mode.TagName && buffer === \"!--\") {\n mode = Mode.Comment;\n current = current[0];\n }\n }\n }\n commit();\n\n return current.length > 2 ? current.slice(1) : current[1];\n}\n","import { assert } from \"../utils\";\n\nexport interface Ref<T> {\n /**\n * Call with no arguments to get the stored value.\n * Throws an error if the ref is empty (this means you forgot to pass it or it was called after teardown).\n */\n (): T;\n\n /**\n * Call with an argument to initialize the value. Returns a cleanup function.\n * The cleanup function should clear any references to the DOM node.\n */\n (value: T): () => void;\n}\n\nexport function createRef<T = HTMLElement>(): Ref<T> {\n let currentValue: T | undefined;\n\n return ((...args: [T]) => {\n if (args.length) {\n currentValue = args[0];\n return () => {\n currentValue = undefined;\n };\n } else {\n // assert(currentValue !== undefined, \"Empty ref!\");\n return currentValue;\n }\n }) as Ref<T>;\n}\n"],"mappings":";;;AAiDA,SAAgB,EAAW,GAA0B,GAA4B;CAC/E,IAAM,IAAU,EAAS,EAAO,GAAG,SAAS,cAAc,EAAO,GAAG;AACpE,GAAO,GAAS,0BAA0B;CAE1C,IAAM,IAAU,GAAe;AAC/B,GAAQ,OAAO;CAEf,IAAM,IAAyB,EAAE,EAC3B,IAA6B,EAAE;AAGrC,CADA,EAAQ,KAAkB,GAC1B,EAAQ,KAAS,EAAQ,GAAS;CAElC,IAAI,IAA8B,MAE5B,IAAkB;EAAE;EAAQ;EAAO;EAAS;CAElD,SAAS,EAAO,GAAqB;AAEnC,SADA,EAAQ,KAAK,EAAO,EACb;;CAGT,eAAe,EAAM,GAAgC;AACnD,MAAI,EAAQ,UAAW;EAEvB,IAAM,IAAU,MAAM,QAAQ,IAAI,EAAQ,KAAK,MAAO,EAAG,EAAQ,CAAC,CAAC;AACnE,OAAK,IAAM,KAAU,EACnB,CAAI,EAA4B,EAAO,IACrC,EAAQ,KAAK,EAAO;AAOxB,EAHA,IAAW,EAAqB,EAAQ,GAAG,IAAI,EAAS,GAAS,GAAS,EAAE,CAAC,GAAG,EAAO,GAAS,EAAQ,EACxG,GAAU,MAAM,EAAS,EAEzB,EAAa,EAAQ;;CAGvB,eAAe,IAAU;AAClB,IAAQ,cAEb,GAAU,QAAQ,GAAM,EACxB,IAAW,MAEX,EAAe,EAAQ,EAEvB,MAAM,QAAQ,IAAI,EAAQ,KAAK,MAAa,GAAU,CAAC,CAAC,EACxD,EAAQ,SAAS;;AAGnB,QAAO;;;;ACjGT,IAAa,UAAa,IAGpB,IAAiC;CAAE,OAAO;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S,IAAO,EAAO;YAEhB,EACT,CAAI,MAAS,IACX,IAAQ,KAER,KAAU;YAEH,MAAS,QAAO,MAAS,IAClC,KAAQ;YACC,MAAS,IAElB,CADA,GAAQ,EACR,IAAO,EAAK;YACF,EAAM,KAEP,MAAS,IAGlB,CAFA,IAAO,EAAK,SACZ,IAAW,GACX,IAAS;YACA,MAAS,QAAQ,IAAO,EAAK,WAAW,EAAQ,GAAG,IAAI,OAAO,MAAM;AAE7E,IADA,GAAQ,EACJ,MAAS,EAAK,YAChB,IAAU,EAAQ;IAEpB,IAAM,IAAO;AACb,QAAU,EAAQ;IAElB,IAAM,IAAO,EAAK,IACZ,IAAQ,EAAK,MAAM,EAAE,EACrB,IAAW,EAAK,MAAM,EAAE;AAI9B,IAFA,EAAQ,KAAK,EAAa,GAAM;KAAE,GAAG;KAAO;KAAU,CAAC,CAAC,EAExD,IAAO,EAAK;UACH,MAAS,OAAO,MAAS,OAAQ,MAAS,QAAQ,MAAS,QAEpE,GAAQ,EACR,IAAO,EAAK,cAEZ,KAAU;AAGZ,GAAI,MAAS,EAAK,WAAW,MAAW,UACtC,IAAO,EAAK,SACZ,IAAU,EAAQ;;;AAMxB,QAFA,GAAQ,EAED,EAAQ,SAAS,IAAI,EAAQ,MAAM,EAAE,GAAG,EAAQ;;;;ACtHzD,SAAgB,IAAqC;CACnD,IAAI;AAEJ,UAAS,GAAG,MACN,EAAK,UACP,IAAe,EAAK,UACP;AACX,MAAe,KAAA;MAIV"}
@@ -1,354 +0,0 @@
1
- //#region src/utils.ts
2
- var e = 0;
3
- function t() {
4
- return (e++).toString(36);
5
- }
6
- function n(e, t) {
7
- let n = {};
8
- for (let r in t) e.includes(r) || (n[r] = t[r]);
9
- return n;
10
- }
11
- function r(e, t) {
12
- if (!e) throw TypeError(t);
13
- }
14
- function i(e) {
15
- return Array.isArray(e);
16
- }
17
- function a(e) {
18
- return typeof e == "string";
19
- }
20
- function o(e) {
21
- return typeof e == "function" && !s(e);
22
- }
23
- function s(e) {
24
- return /^\s*class\s+/.test(String(e));
25
- }
26
- function c(e) {
27
- return typeof e == "number" && !isNaN(e);
28
- }
29
- function l(e) {
30
- return typeof e == "object" && !!e && !i(e);
31
- }
32
- //#endregion
33
- //#region src/core/signals.ts
34
- var u = /* @__PURE__ */ function(e) {
35
- return e[e.None = 0] = "None", e[e.Mutable = 1] = "Mutable", e[e.Watching = 2] = "Watching", e[e.RecursedCheck = 4] = "RecursedCheck", e[e.Recursed = 8] = "Recursed", e[e.Dirty = 16] = "Dirty", e[e.Pending = 32] = "Pending", e;
36
- }(u || {}), d = 0, f = 0, p = 0, m = 0, h, g = [];
37
- function _(e, t, n) {
38
- let r = t._depsTail;
39
- if (r !== void 0 && r._dep === e) return;
40
- let i = r === void 0 ? t._deps : r._nextDep;
41
- if (i !== void 0 && i._dep === e) {
42
- i._version = n, t._depsTail = i;
43
- return;
44
- }
45
- let a = e._subsTail;
46
- if (a !== void 0 && a._version === n && a._sub === t) return;
47
- let o = t._depsTail = e._subsTail = {
48
- _version: n,
49
- _dep: e,
50
- _sub: t,
51
- _prevDep: r,
52
- _nextDep: i,
53
- _prevSub: a,
54
- _nextSub: void 0
55
- };
56
- i !== void 0 && (i._prevDep = o), r === void 0 ? t._deps = o : r._nextDep = o, a === void 0 ? e._subs = o : a._nextSub = o;
57
- }
58
- function v(e) {
59
- e._flags & u.Mutable ? e._depsTail !== void 0 && (e._depsTail = void 0, e._flags = u.Mutable | u.Dirty, j(e)) : L.call(e);
60
- }
61
- function y(e, t = e._sub) {
62
- let n = e._dep, r = e._prevDep, i = e._nextDep, a = e._nextSub, o = e._prevSub;
63
- return i === void 0 ? t._depsTail = r : i._prevDep = r, r === void 0 ? t._deps = i : r._nextDep = i, a === void 0 ? n._subsTail = o : a._prevSub = o, o === void 0 ? (n._subs = a) === void 0 && v(n) : o._nextSub = a, i;
64
- }
65
- function b(e) {
66
- let t = m, n = t;
67
- do
68
- if (g[t++] = e, e._flags &= ~u.Watching, e = e._subs?._sub, e === void 0 || !(e._flags & u.Watching)) break;
69
- while (!0);
70
- for (m = t; n < --t;) {
71
- let e = g[n];
72
- g[n++] = g[t], g[t] = e;
73
- }
74
- }
75
- function x(e) {
76
- return e._depsTail === void 0 ? O(e) : D(e);
77
- }
78
- function S(e) {
79
- let t = e._nextSub, n;
80
- top: do {
81
- let r = e._sub, i = r._flags;
82
- if (i & (u.RecursedCheck | u.Recursed | u.Dirty | u.Pending) ? i & (u.RecursedCheck | u.Recursed) ? i & u.RecursedCheck ? !(i & (u.Dirty | u.Pending)) && T(e, r) ? (r._flags = i | (u.Recursed | u.Pending), i &= u.Mutable) : i = u.None : r._flags = i & ~u.Recursed | u.Pending : i = u.None : r._flags = i | u.Pending, i & u.Watching && b(r), i & u.Mutable) {
83
- let i = r._subs;
84
- if (i !== void 0) {
85
- let r = (e = i)._nextSub;
86
- r !== void 0 && (n = {
87
- _value: t,
88
- _prev: n
89
- }, t = r);
90
- continue;
91
- }
92
- }
93
- if ((e = t) !== void 0) {
94
- t = e._nextSub;
95
- continue;
96
- }
97
- for (; n !== void 0;) if (e = n._value, n = n._prev, e !== void 0) {
98
- t = e._nextSub;
99
- continue top;
100
- }
101
- break;
102
- } while (!0);
103
- }
104
- function C(e, t) {
105
- let n, r = 0, i = !1;
106
- top: do {
107
- let a = e._dep, o = a._flags;
108
- if (t._flags & u.Dirty) i = !0;
109
- else if ((o & (u.Mutable | u.Dirty)) === (u.Mutable | u.Dirty)) {
110
- if (x(a)) {
111
- let e = a._subs;
112
- e._nextSub !== void 0 && w(e), i = !0;
113
- }
114
- } else if ((o & (u.Mutable | u.Pending)) === (u.Mutable | u.Pending)) {
115
- (e._nextSub !== void 0 || e._prevSub !== void 0) && (n = {
116
- _value: e,
117
- _prev: n
118
- }), e = a._deps, t = a, ++r;
119
- continue;
120
- }
121
- if (!i) {
122
- let t = e._nextDep;
123
- if (t !== void 0) {
124
- e = t;
125
- continue;
126
- }
127
- }
128
- for (; r--;) {
129
- let r = t._subs, a = r._nextSub !== void 0;
130
- if (a ? (e = n._value, n = n._prev) : e = r, i) {
131
- if (x(t)) {
132
- a && w(r), t = e._sub;
133
- continue;
134
- }
135
- i = !1;
136
- } else t._flags &= ~u.Pending;
137
- t = e._sub;
138
- let o = e._nextDep;
139
- if (o !== void 0) {
140
- e = o;
141
- continue top;
142
- }
143
- }
144
- return i;
145
- } while (!0);
146
- }
147
- function w(e) {
148
- do {
149
- let t = e._sub, n = t._flags;
150
- (n & (u.Pending | u.Dirty)) === u.Pending && (t._flags = n | u.Dirty, (n & (u.Watching | u.RecursedCheck)) === u.Watching && b(t));
151
- } while ((e = e._nextSub) !== void 0);
152
- }
153
- function T(e, t) {
154
- let n = t._depsTail;
155
- for (; n !== void 0;) {
156
- if (n === e) return !0;
157
- n = n._prevDep;
158
- }
159
- return !1;
160
- }
161
- function E(e) {
162
- let t = h;
163
- return h = e, t;
164
- }
165
- function D(e) {
166
- ++d, e._depsTail = void 0, e._flags = u.Mutable | u.RecursedCheck;
167
- let t = E(e);
168
- try {
169
- let t = e._value;
170
- return t !== (e._value = e._getter(t));
171
- } finally {
172
- h = t, e._flags &= ~u.RecursedCheck, j(e);
173
- }
174
- }
175
- function O(e) {
176
- return e._flags = u.Mutable, e._currentValue !== (e._currentValue = e._pendingValue);
177
- }
178
- function k(e) {
179
- let t = e._flags;
180
- if (t & u.Dirty || t & u.Pending && C(e._deps, e)) {
181
- ++d, e._depsTail = void 0, e._flags = u.Watching | u.RecursedCheck;
182
- let t = E(e);
183
- try {
184
- e._cleanup?.(), e._cleanup = void 0;
185
- let t = e._fn();
186
- o(t) && (e._cleanup = t);
187
- } finally {
188
- h = t, e._flags &= ~u.RecursedCheck, j(e);
189
- }
190
- } else e._flags = u.Watching;
191
- }
192
- function A() {
193
- try {
194
- for (; p < m;) {
195
- let e = g[p];
196
- g[p++] = void 0, k(e);
197
- }
198
- } finally {
199
- for (; p < m;) {
200
- let e = g[p];
201
- g[p++] = void 0, e._flags |= u.Watching | u.Recursed;
202
- }
203
- p = 0, m = 0;
204
- }
205
- }
206
- function j(e) {
207
- let t = e._depsTail, n = t === void 0 ? e._deps : t._nextDep;
208
- for (; n !== void 0;) n = y(n, e);
209
- }
210
- function M(e, t) {
211
- return o(e) ? H(() => e(t)) : e;
212
- }
213
- function N() {
214
- let e = this._flags;
215
- if (e & u.Dirty || e & u.Pending && (C(this._deps, this) || (this._flags = e & ~u.Pending, !1))) {
216
- if (D(this)) {
217
- let e = this._subs;
218
- e !== void 0 && w(e);
219
- }
220
- } else if (!e) {
221
- this._flags = u.Mutable | u.RecursedCheck;
222
- let e = E(this);
223
- try {
224
- this._value = V(this._getter());
225
- } finally {
226
- h = e, this._flags &= ~u.RecursedCheck;
227
- }
228
- }
229
- let t = h;
230
- return t !== void 0 && _(this, t, d), this._value;
231
- }
232
- function P(e) {
233
- let t = M(e, this._value);
234
- if (this._value !== t) {
235
- this._value = t, this._flags &= ~(u.Dirty | u.Pending);
236
- let e = this._subs;
237
- for (; e !== void 0;) {
238
- let t = e._sub, n = t._flags;
239
- (n & (u.Dirty | u.Pending)) === 0 && (t._flags = n | u.Dirty, b(t)), e = e._nextSub;
240
- }
241
- f || A();
242
- }
243
- return t;
244
- }
245
- function F() {
246
- if (this._flags & u.Dirty && O(this)) {
247
- let e = this._subs;
248
- e !== void 0 && w(e);
249
- }
250
- let e = h;
251
- for (; e !== void 0;) {
252
- if (e._flags & (u.Mutable | u.Watching)) {
253
- _(this, e, d);
254
- break;
255
- }
256
- e = e._subs?._sub;
257
- }
258
- return this._currentValue;
259
- }
260
- function I(e) {
261
- let t = M(e, this._pendingValue);
262
- if (this._pendingValue !== (this._pendingValue = t)) {
263
- this._flags = u.Mutable | u.Dirty;
264
- let e = this._subs;
265
- e !== void 0 && (S(e), f || A());
266
- }
267
- }
268
- function L() {
269
- this._depsTail = void 0, this._flags = u.None, j(this);
270
- let e = this._subs;
271
- e !== void 0 && y(e), this._cleanup?.(), this._cleanup = void 0;
272
- }
273
- function R(e) {
274
- if (o(e)) {
275
- let t = {
276
- _value: void 0,
277
- _subs: void 0,
278
- _subsTail: void 0,
279
- _deps: void 0,
280
- _depsTail: void 0,
281
- _flags: u.None,
282
- _getter: e
283
- };
284
- return [N.bind(t), P.bind(t)];
285
- } else {
286
- let t = {
287
- _currentValue: e,
288
- _pendingValue: e,
289
- _subs: void 0,
290
- _subsTail: void 0,
291
- _flags: u.Mutable
292
- };
293
- return [F.bind(t), I.bind(t)];
294
- }
295
- }
296
- function z(e) {
297
- return N.bind({
298
- _value: void 0,
299
- _subs: void 0,
300
- _subsTail: void 0,
301
- _deps: void 0,
302
- _depsTail: void 0,
303
- _flags: u.None,
304
- _getter: e
305
- });
306
- }
307
- function B(e) {
308
- let t = {
309
- _fn: e,
310
- _cleanup: void 0,
311
- _subs: void 0,
312
- _subsTail: void 0,
313
- _deps: void 0,
314
- _depsTail: void 0,
315
- _flags: u.Watching | u.RecursedCheck
316
- }, n = E(t);
317
- n !== void 0 && _(t, n, 0);
318
- try {
319
- let e = t._fn();
320
- o(e) && (t._cleanup = e);
321
- } finally {
322
- h = n, t._flags &= ~u.RecursedCheck;
323
- }
324
- return L.bind(t);
325
- }
326
- function V(e) {
327
- return o(e) ? e() : e;
328
- }
329
- function H(e) {
330
- let t = E(void 0);
331
- try {
332
- return V(e);
333
- } finally {
334
- E(t);
335
- }
336
- }
337
- function U(e) {
338
- ++f;
339
- try {
340
- e();
341
- } finally {
342
- --f || A();
343
- }
344
- }
345
- function W(e, t) {
346
- return B(() => {
347
- let n = e();
348
- H(() => t(n));
349
- });
350
- }
351
- //#endregion
352
- export { H as a, r as c, c as d, l as f, t as h, B as i, i as l, n as m, z as n, W as o, a as p, R as r, V as s, U as t, o as u };
353
-
354
- //# sourceMappingURL=signals-CMJPGr_M.js.map