@manyducks.co/dolla 3.0.0 → 3.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.
@@ -1,31 +1,31 @@
1
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 { a as s, b as c, c as l, d as u, f as d, g as f, i as p, l as m, m as h, n as g, o as _, s as v, t as y, u as b } from "./view-cBN-hn_T.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
3
  //#region src/core/root.ts
4
4
  function x(t, n) {
5
5
  let i = r(t) ? document.querySelector(t) : t;
6
6
  e(i, "Element cannot be null.");
7
7
  let a = h();
8
8
  a.name = "dolla:root";
9
- let s = [], u = [];
10
- a[m] = i, a[l] = !!n?.debug;
11
- let d = null, p = {
12
- plugin: g,
13
- mount: _,
14
- unmount: b
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
15
  };
16
- function g(e) {
17
- return s.push(e), p;
16
+ function p(e) {
17
+ return s.push(e), f;
18
18
  }
19
- async function _(e) {
19
+ async function m(e) {
20
20
  if (a.isMounted) return;
21
21
  let t = await Promise.all(s.map((e) => e(a)));
22
- for (let e of t) o(e) && u.push(e);
23
- d = o(e) ? new y(a, e, {}) : v(e, a), d?.mount(i), f(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
24
  }
25
- async function b() {
26
- a.isMounted && (d?.unmount(!1), d = null, c(a), await Promise.all(u.map((e) => e())), u.length = 0);
25
+ async function y() {
26
+ a.isMounted && (d?.unmount(!1), d = null, _(a), await Promise.all(l.map((e) => e())), l.length = 0);
27
27
  }
28
- return p;
28
+ return f;
29
29
  }
30
30
  //#endregion
31
31
  //#region src/core/debug.ts
@@ -80,8 +80,8 @@ function j(e) {
80
80
  }
81
81
  //#endregion
82
82
  //#region src/core/markup/nodes/portal.ts
83
- var M = class extends d {
84
- #e = s("");
83
+ var M = class extends s {
84
+ #e = p("");
85
85
  #t;
86
86
  #n;
87
87
  #r;
@@ -96,16 +96,16 @@ var M = class extends d {
96
96
  return this.#e.parentNode != null;
97
97
  }
98
98
  mount(e, t) {
99
- this.isMounted() || (g(e, this.#e, t), this.#i ||= v(this.#n, this.#t), this.#i.mount(this.#r));
99
+ this.isMounted() || (d(e, this.#e, t), this.#i ||= c(this.#n, this.#t), this.#i.mount(this.#r));
100
100
  }
101
101
  unmount(e = !1) {
102
102
  this.isMounted() && (e || this.#e.parentNode?.removeChild(this.#e), this.#i?.isMounted() && this.#i.unmount(!1));
103
103
  }
104
104
  move(e, t) {
105
- _(e, this.#e, t);
105
+ f(e, this.#e, t);
106
106
  }
107
- }, N = class extends d {
108
- #e = s("");
107
+ }, N = class extends s {
108
+ #e = p("");
109
109
  #t;
110
110
  #n;
111
111
  #r;
@@ -122,8 +122,8 @@ var M = class extends d {
122
122
  return this.#e.parentNode != null;
123
123
  }
124
124
  mount(e, t) {
125
- this.isMounted() || (g(e, this.#e, t), this.#a = n(this.#n, (e) => {
126
- u(() => {
125
+ this.isMounted() || (d(e, this.#e, t), this.#a = n(this.#n, (e) => {
126
+ y(() => {
127
127
  this._update(Array.from(e));
128
128
  });
129
129
  }));
@@ -149,14 +149,14 @@ var M = class extends d {
149
149
  let a = e[r], o = this.#r(a, r), s = this.#o.get(o);
150
150
  if (s && n.has(o)) s._setItem(a), s._setIndex(r);
151
151
  else {
152
- let [e, t] = i(a), [n, c] = i(r);
152
+ let [e, t] = i(a), [n, l] = i(r);
153
153
  s = {
154
154
  _key: o,
155
- _node: v(this.#i(() => e(), () => n()), this.#t),
155
+ _node: c(this.#i(() => e(), () => n()), this.#t),
156
156
  _item: e,
157
157
  _setItem: t,
158
158
  _index: n,
159
- _setIndex: c
159
+ _setIndex: l
160
160
  };
161
161
  }
162
162
  t.set(o, s);
@@ -172,14 +172,14 @@ var M = class extends d {
172
172
  //#endregion
173
173
  //#region src/core/markup/helpers.ts
174
174
  function P(e, t, n) {
175
- return o(e) ? p(N, { args: [
175
+ return o(e) ? m(N, { args: [
176
176
  e,
177
177
  t,
178
178
  n
179
179
  ] }) : Array.from(e).map((e, t) => n(() => e, () => t));
180
180
  }
181
181
  function F(e, n, r) {
182
- return o(e) ? p(b, { args: [t(() => e() ? n : r)] }) : e ? n : r;
182
+ return o(e) ? m(l, { args: [t(() => e() ? n : r)] }) : e ? n : r;
183
183
  }
184
184
  function I(e, t, n) {
185
185
  return F(e, t, n);
@@ -188,7 +188,7 @@ function L(e, t, n) {
188
188
  return F(e, n, t);
189
189
  }
190
190
  function R(e, t) {
191
- return p(M, { args: [t, e] });
191
+ return m(M, { args: [t, e] });
192
192
  }
193
193
  //#endregion
194
194
  //#region src/core/markup/html.ts
@@ -218,7 +218,7 @@ function B(e, ...t) {
218
218
  let e = o;
219
219
  o = o[0];
220
220
  let t = e[1], n = e[2] || {}, i = e.slice(3);
221
- o.push(p(t, {
221
+ o.push(m(t, {
222
222
  ...n,
223
223
  children: i
224
224
  })), r = z.Slash;
@@ -239,4 +239,4 @@ function V() {
239
239
  //#endregion
240
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
241
 
242
- //# sourceMappingURL=core-BLkJ-xuh.js.map
242
+ //# sourceMappingURL=core-JHktdqjt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-BLkJ-xuh.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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AAQ,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
+ {"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;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"./signals-CMJPGr_M.js";
2
- import { _ as s, h as c, i as l, p as u, s as d, t as f, v as p, y as m } from "./view-cBN-hn_T.js";
3
- import { a as h, c as g, d as _, i as v, l as y, n as b, o as x, r as S, s as C, t as w, u as T } from "./core-BLkJ-xuh.js";
4
- export { f as ViewNode, u as addStore, o as batch, n as compose, i as createAtom, C as createDebug, t as createEffect, l as createMarkup, S as createPortal, w as createRef, _ as createRoot, v as forEach, g as getDebug, c as getStore, h as hideIf, b as html, s as onCleanup, p as onEffect, m as onMount, e as peek, d as render, y as setLogFilter, T as setLogLevel, x as showIf, r as subscribe, a as unwrap };
2
+ import { _ as s, a as c, c as l, d as u, i as d, l as f, m as p, r as m, s as h, t as g } from "./context-B5blupD2.js";
3
+ import { a as _, c as v, d as y, i as b, l as x, n as S, o as C, r as w, s as T, t as E, u as D } from "./core-JHktdqjt.js";
4
+ export { u as ViewNode, g as addStore, o as batch, n as compose, i as createAtom, T as createDebug, t as createEffect, p as createMarkup, w as createPortal, E as createRef, y as createRoot, b as forEach, v as getDebug, m as getNearestViewNode, d as getRootElement, c as getStore, _ as hideIf, S as html, h as onCleanup, l as onEffect, f as onMount, e as peek, s as render, x as setLogFilter, D as setLogLevel, C as showIf, r as subscribe, a as unwrap };
@@ -1,4 +1,4 @@
1
- import { i as e } from "./view-cBN-hn_T.js";
1
+ import { m as e } from "./context-B5blupD2.js";
2
2
  //#region src/jsx-dev-runtime.js
3
3
  var t = ({ children: e }) => e;
4
4
  function n(t, n, r, i, a, o) {
@@ -1,4 +1,4 @@
1
- import { i as e } from "./view-cBN-hn_T.js";
1
+ import { m as e } from "./context-B5blupD2.js";
2
2
  //#region src/jsx-runtime.js
3
3
  var t = ({ children: e }) => e;
4
4
  function n(t, n, r) {
package/dist/router.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as e, c as t, f as n, h as r, l as i, n as a, p as o, r as s, t as c, u as l } from "./signals-CMJPGr_M.js";
2
- import { _ as u, c as d, h as f, i as p, l as m, m as h, p as g, r as _, t as v, u as y, y as b } from "./view-cBN-hn_T.js";
3
- import { c as x } from "./core-BLkJ-xuh.js";
2
+ import { a as u, b as d, d as f, i as p, l as m, m as h, n as g, p as _, s as v, t as y, v as b } from "./context-B5blupD2.js";
3
+ import { c as x } from "./core-JHktdqjt.js";
4
4
  //#region src/router/utils.ts
5
5
  function S(e) {
6
6
  return e.split("/").map((e) => e.trim()).filter(Boolean);
@@ -293,7 +293,7 @@ function R(t) {
293
293
  params: {},
294
294
  query: Object.fromEntries(new URLSearchParams(r.getSearch())),
295
295
  meta: {}
296
- }), [f, S] = s(0), C = O(t.routes), w = /* @__PURE__ */ new Set(), T = h(n);
296
+ }), [u, S] = s(0), C = O(t.routes), w = /* @__PURE__ */ new Set(), T = g(n);
297
297
  T.name = "dolla:router";
298
298
  let D = x(T), [k, M] = s();
299
299
  n[I] = k;
@@ -304,20 +304,20 @@ function R(t) {
304
304
  }, R = [];
305
305
  async function z(u) {
306
306
  i.set(a, window.scrollY);
307
- let f = u ?? r.getPath(), { match: m, journey: h } = await A(C, f);
308
- if (n[d]) for (let e = 0; e < h.length; e++) {
309
- let t = h[e], n = `(update ${e + 1}/${h.length})`;
307
+ let p = u ?? r.getPath(), { match: m, journey: g } = await A(C, p);
308
+ if (n[b]) for (let e = 0; e < g.length; e++) {
309
+ let t = g[e], n = `(update ${e + 1}/${g.length})`;
310
310
  t.kind === "match" ? D.info(`📍 ${n} ${t.message}`) : t.kind === "redirect" ? D.info(`↩️ ${n} ${t.message}`) : D.info(`💀 ${n} ${t.message}`);
311
311
  }
312
- if (!m) throw Error(`Failed to match route '${f}'`);
313
- let { layers: g, params: _ } = m, b = [], x = 0;
314
- for (let e = 0; e < g.length; e++) {
315
- let t = `${g[e].id}:${N(g[e].pattern, _)}`;
316
- b.push(t), x === e && R[e]?.key === t && x++;
312
+ if (!m) throw Error(`Failed to match route '${p}'`);
313
+ let { layers: _, params: v } = m, y = [], x = 0;
314
+ for (let e = 0; e < _.length; e++) {
315
+ let t = `${_[e].id}:${N(_[e].pattern, v)}`;
316
+ y.push(t), x === e && R[e]?.key === t && x++;
317
317
  }
318
318
  let w = [], T = [];
319
- for (let e = x; e < g.length; e++) {
320
- let t = g[e];
319
+ for (let e = x; e < _.length; e++) {
320
+ let t = _[e];
321
321
  t.preload && w.push(Promise.resolve(t.preload(m)).then((t) => {
322
322
  T[e - x] = t;
323
323
  }));
@@ -343,21 +343,21 @@ function R(t) {
343
343
  if (l({
344
344
  ...m,
345
345
  query: Object.fromEntries(j)
346
- }), !(x === g.length && R.length === g.length)) {
346
+ }), !(x === _.length && R.length === _.length)) {
347
347
  R[x] && (R[x].node.unmount(), R.length = x);
348
- for (let e = x; e < g.length; e++) {
349
- let t = g[e], n = R[e - 1] ?? L, [r, i] = s(), a = t.view, o = {
348
+ for (let e = x; e < _.length; e++) {
349
+ let t = _[e], n = R[e - 1] ?? L, [r, i] = s(), a = t.view, o = {
350
350
  data: T[e - x],
351
- children: p(y, { args: [r] })
351
+ children: h(d, { args: [r] })
352
352
  };
353
353
  if (O && e === k) {
354
354
  if (!t.errorView) throw O;
355
355
  a = t.errorView, o = { error: O };
356
356
  }
357
- let c = new v(n.context, a, o);
357
+ let c = new f(n.context, a, o);
358
358
  if (n.setSlot(c), R.push({
359
359
  id: t.id,
360
- key: b[e],
360
+ key: y[e],
361
361
  node: c,
362
362
  context: c.context,
363
363
  slot: r,
@@ -369,15 +369,15 @@ function R(t) {
369
369
  window.scrollTo(0, i.get(r.getKey()) ?? 0), a = r.getKey();
370
370
  });
371
371
  }
372
- let V = g(n, F, {
372
+ let V = y(n, F, {
373
373
  currentMatch: o,
374
374
  setCurrentMatch: l,
375
- progress: f,
375
+ progress: u,
376
376
  history: r,
377
377
  updateRoute: z,
378
378
  guards: w
379
379
  });
380
- b(n, () => {
380
+ m(n, () => {
381
381
  let e = !1, t = !1, i = r.getIndex(), a = _(window, "popstate", async () => {
382
382
  if (e) {
383
383
  e = !1;
@@ -401,8 +401,8 @@ function R(t) {
401
401
  i = n, z();
402
402
  }), o = _(window, "beforeunload", (e) => {
403
403
  w.size > 0 && (e.preventDefault(), e.returnValue = "");
404
- }), s = j(n[m], V.push);
405
- u(n, () => {
404
+ }), s = j(p(n), V.push);
405
+ v(n, () => {
406
406
  a(), o(), s();
407
407
  }), z();
408
408
  });
@@ -411,7 +411,7 @@ function R(t) {
411
411
  function z() {
412
412
  this.name = "dolla:router";
413
413
  let e = this[I];
414
- return t(e != null, "Router plugin not found on root."), new y(this, e);
414
+ return t(e != null, "Router plugin not found on root."), new d(this, e);
415
415
  }
416
416
  var B = class extends Error {
417
417
  constructor(e) {
@@ -421,7 +421,7 @@ var B = class extends Error {
421
421
  //#endregion
422
422
  //#region src/router/index.ts
423
423
  function V(e) {
424
- return f(e, F);
424
+ return u(e, F);
425
425
  }
426
426
  //#endregion
427
427
  export { z as Outlet, B as RedirectError, R as createRouterPlugin, V as getRouter, L as lazy };