diff --git a/modules/solidjs-signals/0.6.3/dist/prod.js b/modules/solidjs-signals/0.6.3/dist/prod.js deleted file mode 100644 index f84d128cc..000000000 --- a/modules/solidjs-signals/0.6.3/dist/prod.js +++ /dev/null @@ -1,2439 +0,0 @@ -// @ts-nocheck -// src/core/error.ts -var NotReadyError = class extends Error { -}; -var NoOwnerError = class extends Error { - constructor() { - super(""); - } -}; -var ContextNotFoundError = class extends Error { - constructor() { - super( - "" - ); - } -}; - -// src/core/constants.ts -var STATE_CLEAN = 0; -var STATE_CHECK = 1; -var STATE_DIRTY = 2; -var STATE_DISPOSED = 3; -var EFFECT_PURE = 0; -var EFFECT_RENDER = 1; -var EFFECT_USER = 2; -var SUPPORTS_PROXY = typeof Proxy === "function"; - -// src/core/flags.ts -var ERROR_OFFSET = 0; -var ERROR_BIT = 1 << ERROR_OFFSET; -var LOADING_OFFSET = 1; -var LOADING_BIT = 1 << LOADING_OFFSET; -var UNINITIALIZED_OFFSET = 2; -var UNINITIALIZED_BIT = 1 << UNINITIALIZED_OFFSET; -var DEFAULT_FLAGS = ERROR_BIT; - -// src/core/scheduler.ts -var clock = 0; -function incrementClock() { - clock++; -} -var ActiveTransition = null; -var Unobserved = []; -var scheduled = false; -function schedule() { - if (scheduled) - return; - scheduled = true; - if (!globalQueue.A) - queueMicrotask(flush); -} -function notifyUnobserved() { - for (let i = 0; i < Unobserved.length; i++) { - const source = Unobserved[i]; - if (!source.b || !source.b.length) - Unobserved[i].ea?.(); - } - Unobserved = []; -} -var pureQueue = []; -var Queue = class { - k = null; - A = false; - g = [[], []]; - f = []; - created = clock; - enqueue(type, fn) { - pureQueue.push(fn); - if (type) - this.g[type - 1].push(fn); - schedule(); - } - run(type) { - if (type === EFFECT_PURE) { - pureQueue.length && runQueue(pureQueue, type); - pureQueue = []; - return; - } else if (this.g[type - 1].length) { - const effects = this.g[type - 1]; - this.g[type - 1] = []; - runQueue(effects, type); - } - for (let i = 0; i < this.f.length; i++) { - this.f[i].run(type); - } - } - flush() { - if (this.A) - return; - this.A = true; - try { - this.run(EFFECT_PURE); - incrementClock(); - scheduled = false; - this.run(EFFECT_RENDER); - this.run(EFFECT_USER); - } finally { - this.A = false; - Unobserved.length && notifyUnobserved(); - } - } - addChild(child) { - if (ActiveTransition && ActiveTransition.r.has(this)) - return ActiveTransition.r.get(this).addChild(child); - this.f.push(child); - child.k = this; - } - removeChild(child) { - if (ActiveTransition && ActiveTransition.r.has(this)) - return ActiveTransition.r.get(this).removeChild(child); - const index = this.f.indexOf(child); - if (index >= 0) { - this.f.splice(index, 1); - child.k = null; - } - } - notify(...args) { - if (this.k) - return this.k.notify(...args); - return false; - } - merge(queue) { - this.g[0].push.apply(this.g[0], queue.g[0]); - this.g[1].push.apply(this.g[1], queue.g[1]); - for (let i = 0; i < queue.f.length; i++) { - const og = this.f.find((c) => c.e === queue.f[i].e); - if (og) - og.merge(queue.f[i]); - else - this.addChild(queue.f[i]); - } - } -}; -var globalQueue = new Queue(); -function flush() { - while (scheduled) { - globalQueue.flush(); - } -} -function removeSourceObservers(node, index) { - let source; - let swap; - for (let i = index; i < node.a.length; i++) { - source = getTransitionSource(node.a[i]); - if (source.b) { - if ((swap = source.b.indexOf(node)) !== -1) { - source.b[swap] = source.b[source.b.length - 1]; - source.b.pop(); - } - if (!source.b.length) - Unobserved.push(source); - } - } -} -function runQueue(queue, type) { - for (let i = 0; i < queue.length; i++) - queue[i](type); -} -var Transition = class _Transition { - a = /* @__PURE__ */ new Map(); - s = /* @__PURE__ */ new Set(); - H = /* @__PURE__ */ new Set(); - W = /* @__PURE__ */ new Set(); - u = false; - g = [[], []]; - r = /* @__PURE__ */ new Map(); - I = []; - f = []; - k = null; - A = false; - X = false; - e = globalQueue; - created = clock; - constructor() { - this.r.set(globalQueue, this); - for (const child of globalQueue.f) { - cloneQueue(child, this, this.r); - } - } - enqueue(type, fn) { - this.I.push(fn); - if (type) - this.g[type - 1].push(fn); - this.schedule(); - } - run(type) { - if (type === EFFECT_PURE) { - this.I.length && runQueue(this.I, type); - this.I = []; - return; - } else if (this.g[type - 1].length) { - const effects = this.g[type - 1]; - this.g[type - 1] = []; - runQueue(effects, type); - } - for (let i = 0; i < this.f.length; i++) { - this.f[i].run(type); - } - } - flush() { - if (this.A) - return; - this.A = true; - let currentTransition = ActiveTransition; - ActiveTransition = this; - try { - this.run(EFFECT_PURE); - incrementClock(); - this.X = false; - ActiveTransition = currentTransition; - finishTransition(this); - } finally { - this.A = false; - ActiveTransition = currentTransition; - } - } - addChild(child) { - this.f.push(child); - child.k = this; - } - removeChild(child) { - const index = this.f.indexOf(child); - if (index >= 0) - this.f.splice(index, 1); - } - notify(node, type, flags) { - if (!(type & LOADING_BIT)) - return false; - if (flags & LOADING_BIT) { - this.s.add(node); - } else { - this.s.delete(node); - } - return true; - } - merge(queue) { - this.g[0].push.apply(this.g[0], queue.g[0]); - this.g[1].push.apply(this.g[1], queue.g[1]); - this.I.push.apply(this.I, queue.I); - for (let i = 0; i < queue.f.length; i++) { - const og = this.f.find((c) => c.e === queue.f[i].e); - if (og) - og.merge(queue.f[i]); - else - this.addChild(queue.f[i]); - } - } - schedule() { - if (this.X) - return; - this.X = true; - if (!this.A) - queueMicrotask(() => this.flush()); - } - runTransition(fn, force = false) { - if (this.u) { - if (this.u instanceof _Transition) - return this.u.runTransition(fn, force); - if (!force) - throw new Error("Transition already completed"); - fn(); - return; - } - ActiveTransition = this; - try { - let result = fn(); - let transition2 = ActiveTransition; - if (result?.next) { - (async function() { - let temp, value; - while (!(temp = result.next(value)).done) { - if (temp.value instanceof Promise) { - transition2.H.add(temp.value); - try { - value = await temp.value; - } finally { - while (transition2.u instanceof _Transition) - transition2 = transition2.u; - transition2.H.delete(temp.value); - } - ActiveTransition = transition2; - } else - value = temp.value; - } - ActiveTransition = null; - finishTransition(transition2); - })(); - } - if (result instanceof Promise) { - transition2.H.add(result); - result.finally(() => { - while (transition2.u instanceof _Transition) - transition2 = transition2.u; - transition2.H.delete(result); - ActiveTransition = null; - finishTransition(transition2); - }); - } - } finally { - const transition2 = ActiveTransition; - ActiveTransition = null; - finishTransition(transition2); - } - } - addOptimistic(fn) { - if (fn.j && fn.j !== this) { - mergeTransitions(fn.j, this); - ActiveTransition = fn.j; - return; - } - fn.j = this; - this.W.add(fn); - } -}; -function transition(fn) { - let t = new Transition(); - queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2)))); -} -function cloneGraph(node) { - if (node.j) { - if (node.j !== ActiveTransition) { - mergeTransitions(node.j, ActiveTransition); - ActiveTransition = node.j; - } - return node.j.a.get(node); - } - const clone = Object.create(Object.getPrototypeOf(node)); - Object.assign(clone, node, { - n: null, - m: null, - b: null, - a: node.a ? [...node.a] : null, - e: node - }); - ActiveTransition.a.set(node, clone); - node.j = ActiveTransition; - if (node.a) { - for (let i = 0; i < node.a.length; i++) - node.a[i].b.push(clone); - } - if (node.b) { - clone.b = []; - for (let i = 0, length = node.b.length; i < length; i++) { - !node.b[i].e && clone.b.push(cloneGraph(node.b[i])); - } - } - return clone; -} -function replaceSourceObservers(node, transition2) { - let source; - let swap; - for (let i = 0; i < node.a.length; i++) { - source = transition2.a.get(node.a[i]) || node.a[i]; - if (source.b && (swap = source.b.indexOf(node)) !== -1) { - const remove = source.b.indexOf(node.e) > -1; - source.b[swap] = !remove ? node.e : source.b[source.b.length - 1]; - remove && source.b.pop(); - } - } -} -function cloneQueue(queue, parent, clonedQueues) { - const clone = Object.create(Object.getPrototypeOf(queue)); - Object.assign(clone, queue, { - e: queue, - k: parent, - f: [], - enqueue(type, fn) { - ActiveTransition?.enqueue(type, fn); - }, - notify(node, type, flags) { - node = node.e || node; - if (!clone.J || type & LOADING_BIT) { - type &= ~LOADING_BIT; - ActiveTransition?.notify(node, LOADING_BIT, flags); - if (!type) - return true; - } - return queue.notify.call(this, node, type, flags); - } - }); - parent.f.push(clone); - clonedQueues.set(queue, clone); - for (const child of queue.f) { - cloneQueue(child, clone, clonedQueues); - } -} -function resolveQueues(children) { - for (const child of children) { - const og = child.e; - if (og) { - const clonedChildren = child.f; - delete child.enqueue; - delete child.notify; - delete child.k; - delete child.f; - Object.assign(og, child); - delete og.e; - resolveQueues(clonedChildren); - } else if (child.k.e) { - child.k.e.addChild(child); - } - } -} -function mergeTransitions(t1, t2) { - t2.a.forEach((value, key) => { - key.j = t1; - t1.a.set(key, value); - }); - t2.W.forEach((c) => { - c.j = t1; - t1.W.add(c); - }); - t2.H.forEach((p) => t1.H.add(p)); - t2.s.forEach((n) => t1.s.add(n)); - t1.merge(t2); - t2.u = t1; -} -function getTransitionSource(input) { - return ActiveTransition && ActiveTransition.a.get(input) || input; -} -function getQueue(node) { - const transition2 = ActiveTransition || node.e?.j; - return transition2 && transition2.r.get(node.B) || node.B; -} -function initialDispose(node) { - let current = node.m; - while (current !== null && current.k === node) { - initialDispose(current); - const clone = ActiveTransition.a.get(current); - if (clone && !clone.Y) - clone.dispose(true); - current = current.m; - } -} -function finishTransition(transition2) { - if (transition2.u || transition2.X || transition2.H.size || transition2.s.size) - return; - globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]); - globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]); - resolveQueues(transition2.f); - for (const [source, clone] of transition2.a) { - if (source === clone || source.j !== transition2) { - delete source.j; - continue; - } - if (clone.a) - replaceSourceObservers(clone, transition2); - if (clone.Y || clone.c === STATE_DISPOSED) { - source.dispose(clone.c === STATE_DISPOSED); - source.emptyDisposal(); - delete clone.Y; - } else { - delete clone.m; - delete clone.n; - } - Object.assign(source, clone); - delete source.e; - let current = clone.m; - if (current?.w === clone) - current.w = source; - while (current?.k === clone) { - current.k = source; - current = current.m; - } - delete source.j; - } - transition2.u = true; - for (const reset of transition2.W) { - delete reset.j; - reset(); - } - globalQueue.flush(); -} - -// src/core/owner.ts -var currentOwner = null; -var defaultContext = {}; -function getOwner() { - return currentOwner; -} -function setOwner(owner) { - const out = currentOwner; - currentOwner = owner; - return out; -} -var Owner = class { - // We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild - // However, the children are actually added in reverse creation order - // See comment at the top of the file for an example of the _nextSibling traversal - k = null; - m = null; - w = null; - c = STATE_CLEAN; - n = null; - x = defaultContext; - B = globalQueue; - fa = 0; - id = null; - constructor(id = null, skipAppend = false) { - this.id = id; - if (currentOwner) { - !skipAppend && currentOwner.append(this); - } - } - append(child) { - child.k = this; - child.w = this; - if (this.m) - this.m.w = child; - child.m = this.m; - this.m = child; - if (this.id != null && child.id == null) - child.id = this.getNextChildId(); - if (child.x !== this.x) { - child.x = { ...this.x, ...child.x }; - } - if (this.B) - child.B = this.B; - } - dispose(self = true) { - if (this.c === STATE_DISPOSED) - return; - let head = self ? this.w || this.k : this, current = this.m, next = null; - while (current && current.k === this) { - current.dispose(true); - next = current.m; - current.m = null; - current = next; - } - this.fa = 0; - if (self) - this.R(); - if (current) - current.w = !self ? this : this.w; - if (head) - head.m = current; - } - R() { - if (this.w) - this.w.m = null; - this.k = null; - this.w = null; - this.x = defaultContext; - this.c = STATE_DISPOSED; - this.emptyDisposal(); - } - emptyDisposal() { - if (!this.n) - return; - if (Array.isArray(this.n)) { - for (let i = 0; i < this.n.length; i++) { - const callable = this.n[i]; - callable.call(callable); - } - } else { - this.n.call(this.n); - } - this.n = null; - } - getNextChildId() { - if (this.id != null) - return formatId(this.id, this.fa++); - throw new Error("Cannot get child id from owner without an id"); - } -}; -function createContext(defaultValue, description) { - return { id: Symbol(description), defaultValue }; -} -function getContext(context, owner = currentOwner) { - if (!owner) { - throw new NoOwnerError(); - } - const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue; - if (isUndefined(value)) { - throw new ContextNotFoundError(); - } - return value; -} -function setContext(context, value, owner = currentOwner) { - if (!owner) { - throw new NoOwnerError(); - } - owner.x = { - ...owner.x, - [context.id]: isUndefined(value) ? context.defaultValue : value - }; -} -function hasContext(context, owner = currentOwner) { - return !isUndefined(owner?.x[context.id]); -} -function onCleanup(fn) { - if (!currentOwner) - return fn; - const node = currentOwner; - if (!node.n) { - node.n = fn; - } else if (Array.isArray(node.n)) { - node.n.push(fn); - } else { - node.n = [node.n, fn]; - } - return fn; -} -function formatId(prefix, id) { - const num = id.toString(36), len = num.length - 1; - return prefix + (len ? String.fromCharCode(64 + len) : "") + num; -} -function isUndefined(value) { - return typeof value === "undefined"; -} - -// src/core/core.ts -var currentObserver = null; -var currentMask = DEFAULT_FLAGS; -var newSources = null; -var newSourcesIndex = 0; -var newFlags = 0; -var notStale = false; -var updateCheck = null; -var staleCheck = null; -function getObserver() { - return currentObserver; -} -var UNCHANGED = Symbol(0); -var Computation = class extends Owner { - a = null; - b = null; - l; - L; - M; - // Used in __DEV__ mode, hopefully removed in production - la; - // Using false is an optimization as an alternative to _equals: () => false - // which could enable more efficient DIRTY notification - aa = isEqual; - ea; - ha = false; - /** Whether the computation is an error or has ancestors that are unresolved */ - h = 0; - /** Which flags raised by sources are handled, vs. being passed through. */ - ba = DEFAULT_FLAGS; - N = -1; - D = false; - j; - e; - constructor(initialValue, compute2, options) { - super(options?.id, compute2 === null); - this.M = compute2; - this.c = compute2 ? STATE_DIRTY : STATE_CLEAN; - this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0; - this.l = initialValue; - if (options?.equals !== void 0) - this.aa = options.equals; - if (options?.pureWrite) - this.ha = true; - if (options?.unobserved) - this.ea = options?.unobserved; - if (ActiveTransition) { - this.j = ActiveTransition; - ActiveTransition.a.set(this, this); - } - } - ga() { - track(this); - newFlags |= this.h & ~currentMask; - if (this.h & ERROR_BIT) { - throw this.L; - } else { - return this.l; - } - } - /** - * Return the current value of this computation - * Automatically re-executes the surrounding computation when the value changes - */ - read() { - if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & (UNINITIALIZED_BIT | ERROR_BIT))) { - const clone = ActiveTransition.a.get(this) || cloneGraph(this); - if (clone !== this) - return clone.read(); - } - if (this.M) { - if (this.h & ERROR_BIT && this.N <= clock) - update(this); - else - this.K(); - } - return this.ga(); - } - /** - * Return the current value of this computation - * Automatically re-executes the surrounding computation when the value changes - * - * If the computation has any unresolved ancestors, this function waits for the value to resolve - * before continuing - */ - wait() { - if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & (UNINITIALIZED_BIT | ERROR_BIT))) { - const clone = ActiveTransition.a.get(this) || cloneGraph(this); - if (clone !== this) - return clone.wait(); - } - if (this.M) { - if (this.h & ERROR_BIT && this.N <= clock) - update(this); - else - this.K(); - } - if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) { - track(this); - throw new NotReadyError(); - } - if (staleCheck && this.h & LOADING_BIT) { - staleCheck.l = true; - } - return this.ga(); - } - /** Update the computation with a new value. */ - write(value, flags = 0, raw = false) { - if (ActiveTransition && !this.e) { - const clone = cloneGraph(this); - if (clone !== this) - return clone.write(value, flags, raw); - } - const newValue = !raw && typeof value === "function" ? value(this.l) : value; - const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags || - this.aa === false || !this.aa(this.l, newValue)); - if (valueChanged) { - this.l = newValue; - this.L = void 0; - } - const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags; - this.h = flags; - this.N = clock + 1; - if (this.b) { - for (let i = 0; i < this.b.length; i++) { - if (valueChanged) { - this.b[i].y(STATE_DIRTY); - } else if (changedFlagsMask) { - this.b[i].Z(changedFlagsMask, changedFlags); - } - } - } - return this.l; - } - /** - * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK - */ - y(state, skipQueue) { - if (this.c >= state && !this.D) - return; - this.D = !!skipQueue; - this.c = state; - if (this.b) { - for (let i = 0; i < this.b.length; i++) { - this.b[i].y(STATE_CHECK, skipQueue); - } - } - } - /** - * Notify the computation that one of its sources has changed flags. - * - * @param mask A bitmask for which flag(s) were changed. - * @param newFlags The source's new flags, masked to just the changed ones. - */ - Z(mask, newFlags2) { - if (this.c >= STATE_DIRTY) - return; - if (mask & this.ba) { - this.y(STATE_DIRTY); - return; - } - if (this.c >= STATE_CHECK && !this.D) - return; - const prevFlags = this.h & mask; - const deltaFlags = prevFlags ^ newFlags2; - if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) { - this.y(STATE_CHECK); - } else { - this.h ^= deltaFlags; - if (this.b) { - for (let i = 0; i < this.b.length; i++) { - this.b[i].Z(mask, newFlags2); - } - } - } - } - E(error) { - if (ActiveTransition && !this.e) { - const clone = cloneGraph(this); - if (clone !== this) - return clone.E(error); - } - this.L = error; - this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT); - } - /** - * This is the core part of the reactivity system, which makes sure that the values are updated - * before they are read. We've also adapted it to return the loading state of the computation, - * so that we can propagate that to the computation's observers. - * - * This function will ensure that the value and states we read from the computation are up to date - */ - K() { - if (!this.M) { - return; - } - if (this.c === STATE_DISPOSED) { - return; - } - if (this.c === STATE_CLEAN) { - return; - } - let observerFlags = 0; - if (this.c === STATE_CHECK) { - for (let i = 0; i < this.a.length; i++) { - const source = getTransitionSource(this.a[i]); - source.K(); - observerFlags |= source.h & ~UNINITIALIZED_BIT; - if (this.c === STATE_DIRTY) { - break; - } - } - } - if (this.c === STATE_DIRTY) { - update(this); - } else { - this.write(UNCHANGED, observerFlags); - this.c = STATE_CLEAN; - } - } - /** - * Remove ourselves from the owner graph and the computation graph - */ - R() { - if (this.c === STATE_DISPOSED) - return; - if (this.a) - removeSourceObservers(this, 0); - super.R(); - } -}; -function track(computation) { - if (ActiveTransition && computation.e) - computation = computation.e; - if (currentObserver) { - if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) { - newSourcesIndex++; - } else if (!newSources) - newSources = [computation]; - else if (computation !== newSources[newSources.length - 1]) { - newSources.push(computation); - } - if (updateCheck) { - updateCheck.l = computation.N > currentObserver.N; - } - } -} -function update(node) { - const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags; - newSources = null; - newSourcesIndex = 0; - newFlags = 0; - try { - if (ActiveTransition && node.e && !node.Y) { - initialDispose(node.e); - node.Y = true; - } - node.dispose(false); - node.emptyDisposal(); - const result = compute(node, node.M, node); - node.write(result, newFlags, true); - } catch (error) { - if (error instanceof NotReadyError) { - node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT); - } else { - node.E(error); - } - } finally { - if (newSources) { - if (node.a) - removeSourceObservers(node, newSourcesIndex); - if (node.a && newSourcesIndex > 0) { - node.a.length = newSourcesIndex + newSources.length; - for (let i = 0; i < newSources.length; i++) { - node.a[newSourcesIndex + i] = newSources[i]; - } - } else { - node.a = newSources; - } - let source; - for (let i = newSourcesIndex; i < node.a.length; i++) { - source = getTransitionSource(node.a[i]); - if (!source.b) - source.b = [node]; - else - source.b.push(node); - } - } else if (node.a && newSourcesIndex < node.a.length) { - removeSourceObservers(node, newSourcesIndex); - node.a.length = newSourcesIndex; - } - newSources = prevSources; - newSourcesIndex = prevSourcesIndex; - newFlags = prevFlags; - node.N = clock + 1; - node.c = STATE_CLEAN; - } -} -function isEqual(a, b) { - return a === b; -} -function untrack(fn) { - if (currentObserver === null) - return fn(); - return compute(getOwner(), fn, null); -} -function hasUpdated(fn) { - const current = updateCheck; - updateCheck = { l: false }; - try { - fn(); - return updateCheck.l; - } finally { - updateCheck = current; - } -} -function pendingCheck(fn, loadingValue) { - const current = staleCheck; - staleCheck = { l: false }; - try { - latest(fn); - return staleCheck.l; - } catch (err) { - if (!(err instanceof NotReadyError)) - return false; - if (loadingValue !== void 0) - return loadingValue; - throw err; - } finally { - staleCheck = current; - } -} -function isPending(fn, loadingValue) { - if (!currentObserver) - return pendingCheck(fn, loadingValue); - const c = new Computation(void 0, () => pendingCheck(fn, loadingValue)); - c.ba |= LOADING_BIT; - return c.read(); -} -function latest(fn, fallback) { - const argLength = arguments.length; - const prevFlags = newFlags; - const prevNotStale = notStale; - notStale = false; - try { - return fn(); - } catch (err) { - if (argLength > 1 && err instanceof NotReadyError) - return fallback; - throw err; - } finally { - newFlags = prevFlags; - notStale = prevNotStale; - } -} -function runWithObserver(observer, run) { - const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags; - newSources = null; - newSourcesIndex = observer.a ? observer.a.length : 0; - newFlags = 0; - try { - return compute(observer, run, observer); - } catch (error) { - if (error instanceof NotReadyError) { - observer.write( - UNCHANGED, - newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT - ); - } else { - observer.E(error); - } - } finally { - if (newSources) { - if (newSourcesIndex > 0) { - observer.a.length = newSourcesIndex + newSources.length; - for (let i = 0; i < newSources.length; i++) { - observer.a[newSourcesIndex + i] = newSources[i]; - } - } else { - observer.a = newSources; - } - let source; - for (let i = newSourcesIndex; i < observer.a.length; i++) { - source = observer.a[i]; - if (!source.b) - source.b = [observer]; - else - source.b.push(observer); - } - } - newSources = prevSources; - newSourcesIndex = prevSourcesIndex; - newFlags = prevFlags; - } -} -function compute(owner, fn, observer) { - const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale; - currentObserver = observer; - currentMask = observer?.ba ?? DEFAULT_FLAGS; - notStale = true; - try { - return fn.call(observer, observer ? observer.l : void 0); - } finally { - setOwner(prevOwner); - currentObserver = prevObserver; - currentMask = prevMask; - notStale = prevNotStale; - } -} - -// src/core/effect.ts -var Effect = class extends Computation { - ca; - _; - O; - da = false; - $; - C; - constructor(initialValue, compute2, effect, error, options) { - super(initialValue, compute2, options); - this.ca = effect; - this._ = error; - this.$ = initialValue; - this.C = options?.render ? EFFECT_RENDER : EFFECT_USER; - if (this.C === EFFECT_RENDER) { - this.M = function(p) { - return !this.e && clock > this.B.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p); - }; - } - this.K(); - !options?.defer && (this.C === EFFECT_USER ? getQueue(this).enqueue(this.C, this.F.bind(this)) : this.F(this.C)); - } - write(value, flags = 0) { - if (this.c == STATE_DIRTY) { - this.h = flags; - if (this.C === EFFECT_RENDER) { - getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.h); - } - } - if (value === UNCHANGED) - return this.l; - this.l = value; - this.da = true; - this.L = void 0; - return value; - } - y(state, skipQueue) { - if (this.c >= state || skipQueue) - return; - if (this.c === STATE_CLEAN) - getQueue(this).enqueue(this.C, this.F.bind(this)); - this.c = state; - } - Z(mask, newFlags2) { - if (this.e) { - if (this.c >= STATE_DIRTY) - return; - if (mask & 3) { - this.y(STATE_DIRTY); - return; - } - } - super.Z(mask, newFlags2); - } - E(error) { - this.L = error; - getQueue(this).notify(this, LOADING_BIT, 0); - this.h = ERROR_BIT; - if (this.C === EFFECT_USER) { - try { - return this._ ? this._(error, () => { - this.O?.(); - this.O = void 0; - }) : console.error(error); - } catch (e) { - error = e; - } - } - if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT)) - throw error; - } - R() { - if (this.c === STATE_DISPOSED) - return; - this.ca = void 0; - this.$ = void 0; - this._ = void 0; - this.O?.(); - this.O = void 0; - getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0); - super.R(); - } - F(type) { - if (type) { - const effect = this.e || this; - if (effect.da && effect.c !== STATE_DISPOSED) { - effect.O?.(); - try { - effect.O = effect.ca(effect.l, effect.$); - } catch (e) { - if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT)) - throw e; - } finally { - effect.$ = effect.l; - effect.da = false; - } - } - } else - this.c !== STATE_CLEAN && runTop(this); - } -}; -var EagerComputation = class extends Computation { - constructor(initialValue, compute2, options) { - super(initialValue, compute2, options); - !options?.defer && this.K(); - } - y(state, skipQueue) { - if (this.c >= state && !this.D) - return; - if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.D)) - getQueue(this).enqueue(EFFECT_PURE, this.F.bind(this)); - super.y(state, skipQueue); - } - F() { - this.c !== STATE_CLEAN && runTop(this); - } -}; -var FirewallComputation = class extends Computation { - firewall = true; - constructor(compute2) { - super(void 0, compute2); - } - y(state, skipQueue) { - if (this.c >= state && !this.D) - return; - if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.D)) - getQueue(this).enqueue(EFFECT_PURE, this.F.bind(this)); - super.y(state, true); - this.D = !!skipQueue; - } - F() { - this.c !== STATE_CLEAN && runTop(this); - } -}; -function runTop(node) { - const ancestors = []; - for (let current = node; current !== null; current = current.k) { - if (ActiveTransition && current.j) - current = ActiveTransition.a.get(current); - if (current.c !== STATE_CLEAN) { - ancestors.push(current); - } - } - for (let i = ancestors.length - 1; i >= 0; i--) { - if (ancestors[i].c !== STATE_DISPOSED) - ancestors[i].K(); - } -} - -// src/store/reconcile.ts -function unwrap(value) { - return value?.[$TARGET]?.[STORE_NODE] ?? value; -} -function getOverrideValue(value, override, key) { - return override && key in override ? override[key] : value[key]; -} -function getAllKeys(value, override, next) { - const keys = getKeys(value, override); - const nextKeys = Object.keys(next); - return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys])); -} -function applyState(next, state, keyFn, all) { - const target = state?.[$TARGET]; - if (!target) - return; - const previous = target[STORE_VALUE]; - const override = target[STORE_OVERRIDE]; - if (next === previous && !override) - return; - (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]); - target[STORE_VALUE] = next; - target[STORE_OVERRIDE] = void 0; - if (Array.isArray(previous)) { - let changed = false; - const prevLength = getOverrideValue(previous, override, "length"); - if (next.length && prevLength && next[0] && keyFn(next[0]) != null) { - let i, j, start, end, newEnd, item, newIndicesNext, keyVal; - for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) { - applyState(next[start], wrap(item, target), keyFn, all); - } - const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map(); - for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) { - temp[newEnd] = item; - } - if (start > newEnd || start > end) { - for (j = start; j <= newEnd; j++) { - changed = true; - target[STORE_NODE][j]?.write(wrap(next[j], target)); - } - for (; j < next.length; j++) { - changed = true; - const wrapped = wrap(temp[j], target); - target[STORE_NODE][j]?.write(wrapped); - applyState(next[j], wrapped, keyFn, all); - } - changed && target[STORE_NODE][$TRACK]?.write(void 0); - prevLength !== next.length && target[STORE_NODE].length?.write(next.length); - return; - } - newIndicesNext = new Array(newEnd + 1); - for (j = newEnd; j >= start; j--) { - item = next[j]; - keyVal = item ? keyFn(item) : item; - i = newIndices.get(keyVal); - newIndicesNext[j] = i === void 0 ? -1 : i; - newIndices.set(keyVal, j); - } - for (i = start; i <= end; i++) { - item = getOverrideValue(previous, override, i); - keyVal = item ? keyFn(item) : item; - j = newIndices.get(keyVal); - if (j !== void 0 && j !== -1) { - temp[j] = item; - j = newIndicesNext[j]; - newIndices.set(keyVal, j); - } - } - for (j = start; j < next.length; j++) { - if (j in temp) { - const wrapped = wrap(temp[j], target); - target[STORE_NODE][j]?.write(wrapped); - applyState(next[j], wrapped, keyFn, all); - } else - target[STORE_NODE][j]?.write(wrap(next[j], target)); - } - if (start < next.length) - changed = true; - } else if (prevLength && next.length) { - for (let i = 0, len = next.length; i < len; i++) { - const item = getOverrideValue(previous, override, i); - isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all); - } - } - if (prevLength !== next.length) { - changed = true; - target[STORE_NODE].length?.write(next.length); - } - changed && target[STORE_NODE][$TRACK]?.write(void 0); - return; - } - let nodes = target[STORE_NODE]; - if (nodes) { - const tracked = nodes[$TRACK]; - const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes); - for (let i = 0, len = keys.length; i < len; i++) { - const key = keys[i]; - const node = nodes[key]; - const previousValue = unwrap(getOverrideValue(previous, override, key)); - let nextValue = unwrap(next[key]); - if (previousValue === nextValue) - continue; - if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) { - tracked?.write(void 0); - node?.write(isWrappable(nextValue) ? wrap(nextValue, target) : nextValue); - } else - applyState(nextValue, wrap(previousValue, target), keyFn, all); - } - } - if (nodes = target[STORE_HAS]) { - const keys = Object.keys(nodes); - for (let i = 0, len = keys.length; i < len; i++) { - nodes[keys[i]].write(keys[i] in next); - } - } -} -function reconcile(value, key, all = false) { - return (state) => { - if (state == null) - throw new Error("Cannot reconcile null or undefined state"); - const keyFn = typeof key === "string" ? (item) => item[key] : key; - const eq = keyFn(state); - if (eq !== void 0 && keyFn(value) !== keyFn(state)) - throw new Error("Cannot reconcile states with different identity"); - applyState(value, state, keyFn, all); - }; -} - -// src/store/projection.ts -function createProjection(fn, initialValue = {}, options) { - let wrappedStore; - const node = new FirewallComputation(() => { - storeSetter(wrappedStore, (s) => { - const value = fn(s); - if (value !== s && value !== void 0) { - reconcile(value, options?.key || "id", options?.all)(s); - } - }); - }); - const wrappedMap = /* @__PURE__ */ new WeakMap(); - const traps = { - ...storeTraps, - get(target, property, receiver) { - const o = getOwner(); - const n = getTransitionSource(node); - (!o || o !== n) && n.wait(); - return storeTraps.get(target, property, receiver); - } - }; - function wrapProjection(source) { - if (wrappedMap.has(source)) - return wrappedMap.get(source); - if (source[$TARGET]?.[STORE_WRAP] === wrapProjection) - return source; - const wrapped = createStoreProxy(source, traps, { - [STORE_WRAP]: wrapProjection, - [STORE_LOOKUP]: wrappedMap - }); - wrappedMap.set(source, wrapped); - return wrapped; - } - return wrappedStore = wrapProjection(initialValue); -} - -// src/store/store.ts -var $TRACK = Symbol(0); -var $DEEP = Symbol(0); -var $TARGET = Symbol(0); -var $PROXY = Symbol(0); -var $DELETED = Symbol(0); -var PARENTS = /* @__PURE__ */ new WeakMap(); -var STORE_VALUE = "v"; -var STORE_OVERRIDE = "o"; -var STORE_NODE = "n"; -var STORE_HAS = "h"; -var STORE_WRAP = "w"; -var STORE_LOOKUP = "l"; -function createStoreProxy(value, traps = storeTraps, extend) { - let newTarget; - if (Array.isArray(value)) { - newTarget = []; - newTarget.v = value; - } else - newTarget = { v: value }; - extend && Object.assign(newTarget, extend); - return newTarget[$PROXY] = new Proxy(newTarget, traps); -} -var storeLookup = /* @__PURE__ */ new WeakMap(); -function wrap(value, target) { - if (target?.[STORE_WRAP]) - return target[STORE_WRAP](value, target); - let p = value[$PROXY] || storeLookup.get(value); - if (!p) - storeLookup.set(value, p = createStoreProxy(value)); - return p; -} -function isWrappable(obj) { - return obj != null && typeof obj === "object" && !Object.isFrozen(obj); -} -function getNodes(target, type) { - let nodes = target[type]; - if (!nodes) - target[type] = nodes = /* @__PURE__ */ Object.create(null); - return nodes; -} -function getNode(nodes, property, value, equals = isEqual) { - if (nodes[property]) - return nodes[property]; - return nodes[property] = new Computation(value, null, { - equals, - unobserved() { - delete nodes[property]; - } - }); -} -function trackSelf(target, symbol = $TRACK) { - getObserver() && getNode(getNodes(target, STORE_NODE), symbol, void 0, false).read(); -} -function getKeys(source, override, enumerable = true) { - const baseKeys = untrack(() => enumerable ? Object.keys(source) : Reflect.ownKeys(source)); - if (!override) - return baseKeys; - const keys = new Set(baseKeys); - const overrides = Reflect.ownKeys(override); - for (const key of overrides) { - if (override[key] !== $DELETED) - keys.add(key); - else - keys.delete(key); - } - return Array.from(keys); -} -function getPropertyDescriptor(source, override, property) { - let value = source; - if (override && property in override) { - if (value[property] === $DELETED) - return void 0; - if (!(property in value)) - value = override; - } - return Reflect.getOwnPropertyDescriptor(value, property); -} -var Writing = null; -var storeTraps = { - get(target, property, receiver) { - if (property === $TARGET) - return target; - if (property === $PROXY) - return receiver; - if (property === $TRACK || property === $DEEP) { - trackSelf(target, property); - return receiver; - } - const nodes = getNodes(target, STORE_NODE); - const tracked = nodes[property]; - const overridden = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]; - const proxySource = !!target[STORE_VALUE][$TARGET]; - const storeValue = overridden ? target[STORE_OVERRIDE] : target[STORE_VALUE]; - if (!tracked) { - const desc = Object.getOwnPropertyDescriptor(storeValue, property); - if (desc && desc.get) - return desc.get.call(receiver); - } - if (Writing?.has(receiver)) { - let value2 = tracked && (overridden || !proxySource) ? tracked.l : storeValue[property]; - value2 === $DELETED && (value2 = void 0); - if (!isWrappable(value2)) - return value2; - const wrapped = wrap(value2, target); - Writing.add(wrapped); - return wrapped; - } - let value = tracked ? overridden || !proxySource ? nodes[property].read() : (nodes[property].read(), storeValue[property]) : storeValue[property]; - value === $DELETED && (value = void 0); - if (!tracked) { - if (!overridden && typeof value === "function" && !storeValue.hasOwnProperty(property)) { - let proto; - return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value; - } else if (getObserver()) { - return getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value).read(); - } - } - return isWrappable(value) ? wrap(value, target) : value; - }, - has(target, property) { - if (property === $PROXY || property === $TRACK || property === "__proto__") - return true; - const has = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] !== $DELETED : property in target[STORE_VALUE]; - getObserver() && getNode(getNodes(target, STORE_HAS), property, has).read(); - return has; - }, - set(target, property, rawValue) { - const store = target[$PROXY]; - if (Writing?.has(target[$PROXY])) { - untrack(() => { - const state = target[STORE_VALUE]; - const base = state[property]; - const prev = target[STORE_OVERRIDE]?.[property] || base; - const value = rawValue?.[$TARGET]?.[STORE_VALUE] ?? rawValue; - if (prev === value) - return true; - const len = target[STORE_OVERRIDE]?.length || state.length; - if (value !== void 0 && value === base) - delete target[STORE_OVERRIDE][property]; - else - (target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = value; - const wrappable = isWrappable(value); - if (isWrappable(prev)) { - const parents = PARENTS.get(prev); - parents && (parents instanceof Set ? parents.delete(store) : PARENTS.delete(prev)); - } - if (recursivelyNotify(store, storeLookup) && wrappable) - recursivelyAddParent(value, store); - target[STORE_HAS]?.[property]?.write(true); - const nodes = getNodes(target, STORE_NODE); - nodes[property]?.write(wrappable ? wrap(value, target) : value); - if (Array.isArray(state)) { - const index = parseInt(property) + 1; - if (index > len) - nodes.length?.write(index); - } - nodes[$TRACK]?.write(void 0); - }); - } - return true; - }, - deleteProperty(target, property) { - if (Writing?.has(target[$PROXY]) && target[STORE_OVERRIDE]?.[property] !== $DELETED) { - untrack(() => { - const prev = target[STORE_OVERRIDE]?.[property] || target[STORE_VALUE][property]; - if (property in target[STORE_VALUE]) { - (target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = $DELETED; - } else if (target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]) { - delete target[STORE_OVERRIDE][property]; - } else - return true; - if (isWrappable(prev)) { - const parents = PARENTS.get(prev); - parents && (parents instanceof Set ? parents.delete(target) : PARENTS.delete(prev)); - } - target[STORE_HAS]?.[property]?.write(false); - const nodes = getNodes(target, STORE_NODE); - nodes[property]?.write(void 0); - nodes[$TRACK]?.write(void 0); - }); - } - return true; - }, - ownKeys(target) { - trackSelf(target); - return getKeys(target[STORE_VALUE], target[STORE_OVERRIDE], false); - }, - getOwnPropertyDescriptor(target, property) { - if (property === $PROXY) - return { value: target[$PROXY], writable: true, configurable: true }; - return getPropertyDescriptor(target[STORE_VALUE], target[STORE_OVERRIDE], property); - }, - getPrototypeOf(target) { - return Object.getPrototypeOf(target[STORE_VALUE]); - } -}; -function storeSetter(store, fn) { - const prevWriting = Writing; - Writing = /* @__PURE__ */ new Set(); - Writing.add(store); - try { - const value = fn(store); - if (value !== store && value !== void 0) { - if (Array.isArray(value)) { - for (let i = 0, len = value.length; i < len; i++) - store[i] = value[i]; - store.length = value.length; - } else { - const keys = /* @__PURE__ */ new Set([...Object.keys(store), ...Object.keys(value)]); - keys.forEach((key) => { - if (key in value) - store[key] = value[key]; - else - delete store[key]; - }); - } - } - } finally { - Writing.clear(); - Writing = prevWriting; - } -} -function createStore(first, second, options) { - const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second, options) : wrap(first); - return [wrappedStore, (fn) => storeSetter(wrappedStore, fn)]; -} -function recursivelyNotify(state, lookup) { - let target = state[$TARGET] || lookup?.get(state)?.[$TARGET]; - let notified = false; - if (target) { - const deep2 = getNodes(target, STORE_NODE)[$DEEP]; - if (deep2) { - deep2.write(void 0); - notified = true; - } - lookup = target[STORE_LOOKUP] || lookup; - } - const parents = PARENTS.get(target?.[STORE_VALUE] || state); - if (!parents) - return notified; - if (parents instanceof Set) { - for (let parent of parents) - notified = recursivelyNotify(parent, lookup) || notified; - } else - notified = recursivelyNotify(parents, lookup) || notified; - return notified; -} -function recursivelyAddParent(state, parent) { - let override; - const target = state[$TARGET]; - if (target) { - override = target[STORE_OVERRIDE]; - state = target[STORE_VALUE]; - } - if (parent) { - let parents = PARENTS.get(state); - if (!parents) - PARENTS.set(state, parent); - else if (parents !== parent) { - if (!(parents instanceof Set)) - PARENTS.set(state, parents = /* @__PURE__ */ new Set([parents])); - else if (parents.has(parent)) - return; - parents.add(parent); - } else - return; - } - if (Array.isArray(state)) { - const len = override?.length || state.length; - for (let i = 0; i < len; i++) { - const item = override && i in override ? override[i] : state[i]; - isWrappable(item) && recursivelyAddParent(item, state); - } - } else { - const keys = getKeys(state, override); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const item = override && key in override ? override[key] : state[key]; - isWrappable(item) && recursivelyAddParent(item, state); - } - } -} -function deep(store) { - recursivelyAddParent(store); - return store[$DEEP]; -} - -// src/store/utils.ts -function snapshot(item, map, lookup) { - let target, isArray, override, result, unwrapped, v; - if (!isWrappable(item)) - return item; - if (map && map.has(item)) - return map.get(item); - if (!map) - map = /* @__PURE__ */ new Map(); - if (target = item[$TARGET] || lookup?.get(item)?.[$TARGET]) { - override = target[STORE_OVERRIDE]; - isArray = Array.isArray(target[STORE_VALUE]); - map.set( - item, - override ? result = isArray ? [] : Object.create(Object.getPrototypeOf(target[STORE_VALUE])) : target[STORE_VALUE] - ); - item = target[STORE_VALUE]; - lookup = storeLookup; - } else { - isArray = Array.isArray(item); - map.set(item, item); - } - if (isArray) { - const len = override?.length || item.length; - for (let i = 0; i < len; i++) { - v = override && i in override ? override[i] : item[i]; - if (v === $DELETED) - continue; - if ((unwrapped = snapshot(v, map, lookup)) !== v || result) { - if (!result) - map.set(item, result = [...item]); - result[i] = unwrapped; - } - } - } else { - const keys = getKeys(item, override); - for (let i = 0, l = keys.length; i < l; i++) { - let prop = keys[i]; - const desc = getPropertyDescriptor(item, override, prop); - if (desc.get) - continue; - v = override && prop in override ? override[prop] : item[prop]; - if ((unwrapped = snapshot(v, map, lookup)) !== item[prop] || result) { - if (!result) { - result = Object.create(Object.getPrototypeOf(item)); - Object.assign(result, item); - } - result[prop] = unwrapped; - } - } - } - return result || item; -} -function trueFn() { - return true; -} -var propTraps = { - get(_, property, receiver) { - if (property === $PROXY) - return receiver; - return _.get(property); - }, - has(_, property) { - if (property === $PROXY) - return true; - return _.has(property); - }, - set: trueFn, - deleteProperty: trueFn, - getOwnPropertyDescriptor(_, property) { - return { - configurable: true, - enumerable: true, - get() { - return _.get(property); - }, - set: trueFn, - deleteProperty: trueFn - }; - }, - ownKeys(_) { - return _.keys(); - } -}; -function resolveSource(s) { - return !(s = typeof s === "function" ? s() : s) ? {} : s; -} -var $SOURCES = Symbol(0); -function merge(...sources) { - if (sources.length === 1 && typeof sources[0] !== "function") - return sources[0]; - let proxy = false; - const flattened = []; - for (let i = 0; i < sources.length; i++) { - const s = sources[i]; - proxy = proxy || !!s && $PROXY in s; - const childSources = !!s && s[$SOURCES]; - if (childSources) - flattened.push(...childSources); - else - flattened.push( - typeof s === "function" ? (proxy = true, createMemo(s)) : s - ); - } - if (SUPPORTS_PROXY && proxy) { - return new Proxy( - { - get(property) { - if (property === $SOURCES) - return flattened; - for (let i = flattened.length - 1; i >= 0; i--) { - const s = resolveSource(flattened[i]); - if (property in s) - return s[property]; - } - }, - has(property) { - for (let i = flattened.length - 1; i >= 0; i--) { - if (property in resolveSource(flattened[i])) - return true; - } - return false; - }, - keys() { - const keys = []; - for (let i = 0; i < flattened.length; i++) - keys.push(...Object.keys(resolveSource(flattened[i]))); - return [...new Set(keys)]; - } - }, - propTraps - ); - } - const defined = /* @__PURE__ */ Object.create(null); - let nonTargetKey = false; - let lastIndex = flattened.length - 1; - for (let i = lastIndex; i >= 0; i--) { - const source = flattened[i]; - if (!source) { - i === lastIndex && lastIndex--; - continue; - } - const sourceKeys = Object.getOwnPropertyNames(source); - for (let j = sourceKeys.length - 1; j >= 0; j--) { - const key = sourceKeys[j]; - if (key === "__proto__" || key === "constructor") - continue; - if (!defined[key]) { - nonTargetKey = nonTargetKey || i !== lastIndex; - const desc = Object.getOwnPropertyDescriptor(source, key); - defined[key] = desc.get ? { - enumerable: true, - configurable: true, - get: desc.get.bind(source) - } : desc; - } - } - } - if (!nonTargetKey) - return flattened[lastIndex]; - const target = {}; - const definedKeys = Object.keys(defined); - for (let i = definedKeys.length - 1; i >= 0; i--) { - const key = definedKeys[i], desc = defined[key]; - if (desc.get) - Object.defineProperty(target, key, desc); - else - target[key] = desc.value; - } - target[$SOURCES] = flattened; - return target; -} -function omit(props, ...keys) { - const blocked = new Set(keys); - if (SUPPORTS_PROXY && $PROXY in props) { - return new Proxy( - { - get(property) { - return blocked.has(property) ? void 0 : props[property]; - }, - has(property) { - return !blocked.has(property) && property in props; - }, - keys() { - return Object.keys(props).filter((k) => !blocked.has(k)); - } - }, - propTraps - ); - } - const result = {}; - for (const propName of Object.getOwnPropertyNames(props)) { - if (!blocked.has(propName)) { - const desc = Object.getOwnPropertyDescriptor(props, propName); - !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable ? result[propName] = desc.value : Object.defineProperty(result, propName, desc); - } - } - return result; -} - -// src/signals.ts -function createSignal(first, second, third) { - if (typeof first === "function") { - const memo = createMemo((p) => { - const node2 = new Computation( - first(p ? untrack(p[0]) : second), - null, - third - ); - return [node2.read.bind(node2), node2.write.bind(node2)]; - }); - return [() => memo()[0](), (value) => memo()[1](value)]; - } - const o = getOwner(); - const needsId = o?.id != null; - const node = new Computation( - first, - null, - needsId ? { id: o.getNextChildId(), ...second } : second - ); - return [node.read.bind(node), node.write.bind(node)]; -} -function createMemo(compute2, value, options) { - let node = new Computation( - value, - compute2, - options - ); - let resolvedValue; - return () => { - if (node) { - if (node.c === STATE_DISPOSED) { - node = void 0; - return resolvedValue; - } - resolvedValue = node.wait(); - if (!node.a?.length && node.m?.k !== node && !(node.h & UNINITIALIZED_BIT)) { - node.dispose(); - node = void 0; - } - } - return resolvedValue; - }; -} -function createAsync(compute2, value, options) { - let refreshing = false; - const node = new EagerComputation( - value, - (p) => { - const source = compute2(p, refreshing); - refreshing = false; - const isPromise = source instanceof Promise; - const iterator = source[Symbol.asyncIterator]; - if (!isPromise && !iterator) { - return source; - } - let abort = false; - onCleanup(() => abort = true); - let transition2 = ActiveTransition; - if (isPromise) { - source.then( - (value3) => { - if (abort) - return; - if (transition2) - return transition2.runTransition(() => { - node.write(value3, 0, true); - }, true); - node.write(value3, 0, true); - }, - (error) => { - if (abort) - return; - if (transition2) - return transition2.runTransition(() => node.E(error), true); - node.E(error); - } - ); - } else { - (async () => { - try { - for await (let value3 of source) { - if (abort) - return; - if (transition2) - return transition2.runTransition(() => { - node.write(value3, 0, true); - transition2 = null; - }, true); - node.write(value3, 0, true); - } - } catch (error) { - if (abort) - return; - if (transition2) - return transition2.runTransition(() => { - node.E(error); - transition2 = null; - }, true); - node.E(error); - } - })(); - } - throw new NotReadyError(); - }, - options - ); - const read = node.wait.bind(node); - read.refresh = () => { - let n = node; - if (ActiveTransition && !node.e) { - n = cloneGraph(node); - } - n.c = STATE_DIRTY; - refreshing = true; - n.K(); - }; - return read; -} -function createEffect(compute2, effect, value, options) { - void new Effect( - value, - compute2, - effect.effect ? effect.effect : effect, - effect.error, - options - ); -} -function createRenderEffect(compute2, effect, value, options) { - void new Effect(value, compute2, effect, void 0, { - render: true, - ...options - }); -} -function createRoot(init, options) { - const owner = new Owner(options?.id); - return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null); -} -function runWithOwner(owner, run) { - return compute(owner, run, null); -} -function resolve(fn) { - return new Promise((res, rej) => { - createRoot((dispose) => { - new EagerComputation(void 0, () => { - try { - res(fn()); - } catch (err) { - if (err instanceof NotReadyError) - throw err; - rej(err); - } - dispose(); - }); - }); - }); -} -function createPending() { - const node = new Computation(false, null); - const reset = () => node.write(false); - function write() { - if (!ActiveTransition) - return false; - ActiveTransition.addOptimistic(reset); - queueMicrotask(() => reset.j && node.write(true)); - } - function read() { - const v = node.read(); - return ActiveTransition ? false : v; - } - return [read, write]; -} -function useTransition() { - const [pending, setPending] = createPending(); - function start(fn) { - transition((resume) => { - setPending(true); - return fn(resume); - }); - } - return [pending, start]; -} -function createOptimistic(first, second, options) { - let store, setStore; - if (typeof first === "function") { - [store, setStore] = createStore((s) => { - const value = first(s); - if (!ActiveTransition) - return value; - ActiveTransition.addOptimistic(reset); - }, {}); - } else - [store, setStore] = createStore(first); - const reset = () => setStore( - reconcile( - typeof first === "function" ? first(second) : first, - options?.key || "id", - options?.all - ) - ); - function write(v) { - if (!ActiveTransition) - throw new Error("createOptimistic can only be updated inside a transition"); - ActiveTransition.addOptimistic(reset); - queueMicrotask(() => reset.j && setStore(v)); - } - return [store, write]; -} - -// src/map.ts -function mapArray(list, map, options) { - const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0; - return updateKeyedMap.bind({ - S: new Owner(), - o: 0, - ia: list, - G: [], - P: map, - i: [], - d: [], - Q: keyFn, - p: keyFn || options?.keyed === false ? [] : void 0, - q: map.length > 1 ? [] : void 0, - T: options?.fallback - }); -} -var pureOptions = { pureWrite: true }; -function updateKeyedMap() { - const newItems = this.ia() || [], newLen = newItems.length; - newItems[$TRACK]; - runWithOwner(this.S, () => { - let i, j, mapper = this.p ? () => { - this.p[j] = new Computation(newItems[j], null, pureOptions); - this.q && (this.q[j] = new Computation(j, null, pureOptions)); - return this.P( - Computation.prototype.read.bind(this.p[j]), - this.q ? Computation.prototype.read.bind(this.q[j]) : void 0 - ); - } : this.q ? () => { - const item = newItems[j]; - this.q[j] = new Computation(j, null, pureOptions); - return this.P(() => item, Computation.prototype.read.bind(this.q[j])); - } : () => { - const item = newItems[j]; - return this.P(() => item); - }; - if (newLen === 0) { - if (this.o !== 0) { - this.S.dispose(false); - this.d = []; - this.G = []; - this.i = []; - this.o = 0; - this.p && (this.p = []); - this.q && (this.q = []); - } - if (this.T && !this.i[0]) { - this.i[0] = compute( - this.d[0] = new Owner(), - this.T, - null - ); - } - } else if (this.o === 0) { - if (this.d[0]) - this.d[0].dispose(); - this.i = new Array(newLen); - for (j = 0; j < newLen; j++) { - this.G[j] = newItems[j]; - this.i[j] = compute(this.d[j] = new Owner(), mapper, null); - } - this.o = newLen; - } else { - let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0; - for (start = 0, end = Math.min(this.o, newLen); start < end && (this.G[start] === newItems[start] || this.p && compare(this.Q, this.G[start], newItems[start])); start++) { - if (this.p) - this.p[start].write(newItems[start]); - } - for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.p && compare(this.Q, this.G[end], newItems[newEnd])); end--, newEnd--) { - temp[newEnd] = this.i[end]; - tempNodes[newEnd] = this.d[end]; - tempRows && (tempRows[newEnd] = this.p[end]); - tempIndexes && (tempIndexes[newEnd] = this.q[end]); - } - newIndices = /* @__PURE__ */ new Map(); - newIndicesNext = new Array(newEnd + 1); - for (j = newEnd; j >= start; j--) { - item = newItems[j]; - key = this.Q ? this.Q(item) : item; - i = newIndices.get(key); - newIndicesNext[j] = i === void 0 ? -1 : i; - newIndices.set(key, j); - } - for (i = start; i <= end; i++) { - item = this.G[i]; - key = this.Q ? this.Q(item) : item; - j = newIndices.get(key); - if (j !== void 0 && j !== -1) { - temp[j] = this.i[i]; - tempNodes[j] = this.d[i]; - tempRows && (tempRows[j] = this.p[i]); - tempIndexes && (tempIndexes[j] = this.q[i]); - j = newIndicesNext[j]; - newIndices.set(key, j); - } else - this.d[i].dispose(); - } - for (j = start; j < newLen; j++) { - if (j in temp) { - this.i[j] = temp[j]; - this.d[j] = tempNodes[j]; - if (tempRows) { - this.p[j] = tempRows[j]; - this.p[j].write(newItems[j]); - } - if (tempIndexes) { - this.q[j] = tempIndexes[j]; - this.q[j].write(j); - } - } else { - this.i[j] = compute(this.d[j] = new Owner(), mapper, null); - } - } - this.i = this.i.slice(0, this.o = newLen); - this.G = newItems.slice(0); - } - }); - return this.i; -} -function repeat(count, map, options) { - return updateRepeat.bind({ - S: new Owner(), - o: 0, - z: 0, - ja: count, - P: map, - d: [], - i: [], - ka: options?.from, - T: options?.fallback - }); -} -function updateRepeat() { - const newLen = this.ja(); - const from = this.ka?.() || 0; - runWithOwner(this.S, () => { - if (newLen === 0) { - if (this.o !== 0) { - this.S.dispose(false); - this.d = []; - this.i = []; - this.o = 0; - } - if (this.T && !this.i[0]) { - this.i[0] = compute( - this.d[0] = new Owner(), - this.T, - null - ); - } - return; - } - const to = from + newLen; - const prevTo = this.z + this.o; - if (this.o === 0 && this.d[0]) - this.d[0].dispose(); - for (let i = to; i < prevTo; i++) - this.d[i - this.z].dispose(); - if (this.z < from) { - let i = this.z; - while (i < from && i < this.o) - this.d[i++].dispose(); - this.d.splice(0, from - this.z); - this.i.splice(0, from - this.z); - } else if (this.z > from) { - let i = prevTo - this.z - 1; - let difference = this.z - from; - this.d.length = this.i.length = newLen; - while (i >= difference) { - this.d[i] = this.d[i - difference]; - this.i[i] = this.i[i - difference]; - i--; - } - for (let i2 = 0; i2 < difference; i2++) { - this.i[i2] = compute( - this.d[i2] = new Owner(), - () => this.P(i2 + from), - null - ); - } - } - for (let i = prevTo; i < to; i++) { - this.i[i - from] = compute( - this.d[i - from] = new Owner(), - () => this.P(i), - null - ); - } - this.i = this.i.slice(0, newLen); - this.z = from; - this.o = newLen; - }); - return this.i; -} -function compare(key, a, b) { - return key ? key(a) === key(b) : true; -} - -// src/boundaries.ts -var BoundaryComputation = class extends EagerComputation { - U; - constructor(compute2, propagationMask) { - super(void 0, compute2, { defer: true }); - this.U = propagationMask; - } - write(value, flags) { - super.write(value, flags & ~this.U); - if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT || ActiveTransition)) { - flags &= ~LOADING_BIT; - } - getQueue(this).notify(this, this.U, flags); - return this.l; - } -}; -function createBoundChildren(owner, fn, queue, mask) { - const parentQueue = owner.B; - parentQueue.addChild(owner.B = queue); - onCleanup(() => parentQueue.removeChild(owner.B)); - return compute( - owner, - () => { - const c = new Computation(void 0, fn); - return new BoundaryComputation(() => flatten(c.wait()), mask); - }, - null - ); -} -var ConditionalQueue = class extends Queue { - t; - V = /* @__PURE__ */ new Set(); - s = /* @__PURE__ */ new Set(); - constructor(disabled) { - super(); - this.t = disabled; - } - run(type) { - if (!type || this.t.read()) - return; - return super.run(type); - } - notify(node, type, flags) { - if (ActiveTransition && ActiveTransition.r.has(this)) - return ActiveTransition.r.get(this).notify(node, type, flags); - if (this.t.read()) { - if (type & LOADING_BIT) { - if (flags & LOADING_BIT) { - this.s.add(node); - type &= ~LOADING_BIT; - } else if (this.s.delete(node)) - type &= ~LOADING_BIT; - } - if (type & ERROR_BIT) { - if (flags & ERROR_BIT) { - this.V.add(node); - type &= ~ERROR_BIT; - } else if (this.V.delete(node)) - type &= ~ERROR_BIT; - } - } - return type ? super.notify(node, type, flags) : true; - } - merge(queue) { - queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT)); - queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT)); - super.merge(queue); - } -}; -var CollectionQueue = class extends Queue { - J; - d = /* @__PURE__ */ new Set(); - t = new Computation(false, null, { pureWrite: true }); - constructor(type) { - super(); - this.J = type; - } - run(type) { - if (!type || this.t.read()) - return; - return super.run(type); - } - notify(node, type, flags) { - if (ActiveTransition && ActiveTransition.r.has(this)) - return ActiveTransition.r.get(this).notify(node, type, flags); - if (!(type & this.J)) - return super.notify(node, type, flags); - if (flags & this.J) { - this.d.add(node); - if (this.d.size === 1) - this.t.write(true); - } else if (this.d.size > 0) { - this.d.delete(node); - if (this.d.size === 0) - this.t.write(false); - } - type &= ~this.J; - return type ? super.notify(node, type, flags) : true; - } - merge(queue) { - queue.d.forEach((n) => this.notify(n, this.J, this.J)); - super.merge(queue); - } -}; -function createBoundary(fn, condition) { - const owner = new Owner(); - const queue = new ConditionalQueue( - new Computation(void 0, () => condition() === "hidden" /* HIDDEN */) - ); - const tree = createBoundChildren(owner, fn, queue, 0); - new EagerComputation(void 0, () => { - const disabled = queue.t.read(); - tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0; - if (!disabled) { - queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT)); - queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT)); - queue.s.clear(); - queue.V.clear(); - } - }); - return () => queue.t.read() ? void 0 : tree.read(); -} -function createCollectionBoundary(type, fn, fallback) { - const owner = new Owner(); - const queue = new CollectionQueue(type); - const tree = createBoundChildren(owner, fn, queue, type); - const decision = new Computation(void 0, () => { - if (!queue.t.read()) { - const resolved = tree.read(); - if (!untrack(() => queue.t.read())) - return resolved; - } - return fallback(queue); - }); - return decision.read.bind(decision); -} -function createSuspense(fn, fallback) { - return createCollectionBoundary(LOADING_BIT, fn, () => fallback()); -} -function createErrorBoundary(fn, fallback) { - return createCollectionBoundary(ERROR_BIT, fn, (queue) => { - let node = getTransitionSource(queue.d.values().next().value); - return fallback(node.L, () => { - incrementClock(); - for (let node2 of queue.d) { - if (ActiveTransition && !node2.e) - node2 = cloneGraph(node2); - node2.c = STATE_DIRTY; - getQueue(node2).enqueue(node2.C, node2.F.bind(node2)); - } - }); - }); -} -function flatten(children, options) { - if (typeof children === "function" && !children.length) { - if (options?.doNotUnwrap) - return children; - do { - children = children(); - } while (typeof children === "function" && !children.length); - } - if (options?.skipNonRendered && (children == null || children === true || children === false || children === "")) - return; - if (Array.isArray(children)) { - let results = []; - if (flattenArray(children, results, options)) { - return () => { - let nested = []; - flattenArray(results, nested, { ...options, doNotUnwrap: false }); - return nested; - }; - } - return results; - } - return children; -} -function flattenArray(children, results = [], options) { - let notReady = null; - let needsUnwrap = false; - for (let i = 0; i < children.length; i++) { - try { - let child = children[i]; - if (typeof child === "function" && !child.length) { - if (options?.doNotUnwrap) { - results.push(child); - needsUnwrap = true; - continue; - } - do { - child = child(); - } while (typeof child === "function" && !child.length); - } - if (Array.isArray(child)) { - needsUnwrap = flattenArray(child, results, options); - } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) { - } else - results.push(child); - } catch (e) { - if (!(e instanceof NotReadyError)) - throw e; - notReady = e; - } - } - if (notReady) - throw notReady; - return needsUnwrap; -} - -export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithObserver, runWithOwner, setContext, snapshot, transition, untrack, useTransition }; diff --git a/modules/solidjs-signals/0.6.3/dist/types/boundaries.d.ts b/modules/solidjs-signals/0.6.3/dist/types/boundaries.d.ts deleted file mode 100644 index e2256a3b6..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/boundaries.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Computation, Queue } from "./core/index.js"; -import type { Effect } from "./core/index.js"; -export declare class CollectionQueue extends Queue { - _collectionType: number; - _nodes: Set; - _disabled: Computation; - constructor(type: number); - run(type: number): void; - notify(node: Effect, type: number, flags: number): any; - merge(queue: CollectionQueue): void; -} -export declare enum BoundaryMode { - VISIBLE = "visible", - HIDDEN = "hidden" -} -export declare function createBoundary(fn: () => T, condition: () => BoundaryMode): () => T | undefined; -export declare function createSuspense(fn: () => any, fallback: () => any): () => any; -export declare function createErrorBoundary(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => any; -export declare function flatten(children: any, options?: { - skipNonRendered?: boolean; - doNotUnwrap?: boolean; -}): any; diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/constants.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/constants.d.ts deleted file mode 100644 index 34e31ee8e..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/constants.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * See https://dev.to/modderme123/super-charging-fine-grained-reactive-performance-47ph - * State clean corresponds to a node where all the sources are fully up to date - * State check corresponds to a node where some sources (including grandparents) may have changed - * State dirty corresponds to a node where the direct parents of a node has changed - */ -export declare const STATE_CLEAN = 0; -export declare const STATE_CHECK = 1; -export declare const STATE_DIRTY = 2; -export declare const STATE_DISPOSED = 3; -export declare const EFFECT_PURE = 0; -export declare const EFFECT_RENDER = 1; -export declare const EFFECT_USER = 2; -export declare const SUPPORTS_PROXY: boolean; diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/core.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/core.d.ts deleted file mode 100644 index 7010389f5..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/core.d.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Nodes for constructing a graph of reactive values and reactive computations. - * - * - The graph is acyclic. - * - The user inputs new values into the graph by calling .write() on one more computation nodes. - * - The user retrieves computed results from the graph by calling .read() on one or more computation nodes. - * - The library is responsible for running any necessary computations so that .read() is up to date - * with all prior .write() calls anywhere in the graph. - * - We call the input nodes 'roots' and the output nodes 'leaves' of the graph here. - * - Changes flow from roots to leaves. It would be effective but inefficient to immediately - * propagate all changes from a root through the graph to descendant leaves. Instead, we defer - * change most change propagation computation until a leaf is accessed. This allows us to - * coalesce computations and skip altogether recalculating unused sections of the graph. - * - Each computation node tracks its sources and its observers (observers are other - * elements that have this node as a source). Source and observer links are updated automatically - * as observer computations re-evaluate and call get() on their sources. - * - Each node stores a cache state (clean/check/dirty) to support the change propagation algorithm: - * - * In general, execution proceeds in three passes: - * - * 1. write() propagates changes down the graph to the leaves - * direct children are marked as dirty and their deeper descendants marked as check - * (no computations are evaluated) - * 2. read() requests that parent nodes updateIfNecessary(), which proceeds recursively up the tree - * to decide whether the node is clean (parents unchanged) or dirty (parents changed) - * 3. updateIfNecessary() evaluates the computation if the node is dirty (the computations are - * executed in root to leaf order) - */ -import { type Flags } from "./flags.js"; -import { Owner } from "./owner.js"; -import { type Transition } from "./scheduler.js"; -export interface SignalOptions { - id?: string; - name?: string; - equals?: ((prev: T, next: T) => boolean) | false; - pureWrite?: boolean; - unobserved?: () => void; -} -export interface SourceType { - _observers: ObserverType[] | null; - _unobserved?: () => void; - _updateIfNecessary: () => void; - _stateFlags: Flags; - _time: number; - _transition?: Transition; - _cloned?: Computation; -} -export interface ObserverType { - _sources: SourceType[] | null; - _notify: (state: number, skipQueue?: boolean) => void; - _handlerMask: Flags; - _notifyFlags: (mask: Flags, newFlags: Flags) => void; - _time: number; - _cloned?: Computation; -} -/** - * Returns the current observer. - */ -export declare function getObserver(): Computation | null; -export declare const UNCHANGED: unique symbol; -export type UNCHANGED = typeof UNCHANGED; -export declare class Computation extends Owner implements SourceType, ObserverType { - _sources: SourceType[] | null; - _observers: ObserverType[] | null; - _value: T | undefined; - _error: unknown; - _compute: null | ((p?: T) => T); - _name: string | undefined; - _equals: false | ((a: T, b: T) => boolean); - _unobserved: (() => void) | undefined; - _pureWrite: boolean; - /** Whether the computation is an error or has ancestors that are unresolved */ - _stateFlags: number; - /** Which flags raised by sources are handled, vs. being passed through. */ - _handlerMask: number; - _time: number; - _forceNotify: boolean; - _transition?: Transition | undefined; - _cloned?: Computation; - constructor(initialValue: T | undefined, compute: null | ((p?: T) => T), options?: SignalOptions); - _read(): T; - /** - * Return the current value of this computation - * Automatically re-executes the surrounding computation when the value changes - */ - read(): T; - /** - * Return the current value of this computation - * Automatically re-executes the surrounding computation when the value changes - * - * If the computation has any unresolved ancestors, this function waits for the value to resolve - * before continuing - */ - wait(): T; - /** Update the computation with a new value. */ - write(value: T | ((currentValue: T) => T) | UNCHANGED, flags?: number, raw?: boolean): T; - /** - * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK - */ - _notify(state: number, skipQueue?: boolean): void; - /** - * Notify the computation that one of its sources has changed flags. - * - * @param mask A bitmask for which flag(s) were changed. - * @param newFlags The source's new flags, masked to just the changed ones. - */ - _notifyFlags(mask: Flags, newFlags: Flags): void; - _setError(error: unknown): void; - /** - * This is the core part of the reactivity system, which makes sure that the values are updated - * before they are read. We've also adapted it to return the loading state of the computation, - * so that we can propagate that to the computation's observers. - * - * This function will ensure that the value and states we read from the computation are up to date - */ - _updateIfNecessary(): void; - /** - * Remove ourselves from the owner graph and the computation graph - */ - _disposeNode(): void; -} -/** - * Reruns a computation's _compute function, producing a new value and keeping track of dependencies. - * - * It handles the updating of sources and observers, disposal of previous executions, - * and error handling if the _compute function throws. It also sets the node as loading - * if it reads any parents that are currently loading. - */ -export declare function update(node: Computation): void; -export declare function isEqual(a: T, b: T): boolean; -/** - * Returns the current value stored inside the given compute function without triggering any - * dependencies. Use `untrack` if you want to also disable owner tracking. - */ -export declare function untrack(fn: () => T): T; -/** - * Returns true if the given functinon contains signals that have been updated since the last time - * the parent computation was run. - */ -export declare function hasUpdated(fn: () => any): boolean; -/** - * Returns an accessor that is true if the given function contains async signals that are out of date. - */ -export declare function isPending(fn: () => any): boolean; -export declare function isPending(fn: () => any, loadingValue: boolean): boolean; -/** - * Attempts to resolve value of expression synchronously returning the last resolved value for any async computation. - */ -export declare function latest(fn: () => T): T; -export declare function latest(fn: () => T, fallback: U): T | U; -/** - * Runs the given function in the given observer. - * - * Warning: Usually there are simpler ways of modeling a problem that avoid using this function - */ -export declare function runWithObserver(observer: Computation, run: () => T): T | undefined; -/** - * A convenient wrapper that calls `compute` with the `owner` and `observer` and is guaranteed - * to reset the global context after the computation is finished even if an error is thrown. - */ -export declare function compute(owner: Owner | null, fn: (val: T) => T, observer: Computation): T; -export declare function compute(owner: Owner | null, fn: (val: undefined) => T, observer: null): T; diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/effect.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/effect.d.ts deleted file mode 100644 index fef147c10..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/effect.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { EFFECT_RENDER, EFFECT_USER } from "./constants.js"; -import { Computation, type SignalOptions } from "./core.js"; -import { type Flags } from "./flags.js"; -/** - * Effects are the leaf nodes of our reactive graph. When their sources change, they are - * automatically added to the queue of effects to re-execute, which will cause them to fetch their - * sources and recompute - */ -export declare class Effect extends Computation { - _effect: (val: T, prev: T | undefined) => void | (() => void); - _onerror: ((err: unknown, cleanup: () => void) => void) | undefined; - _cleanup: (() => void) | undefined; - _modified: boolean; - _prevValue: T | undefined; - _type: typeof EFFECT_RENDER | typeof EFFECT_USER; - constructor(initialValue: T, compute: (val?: T) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown) => void | (() => void), options?: SignalOptions & { - render?: boolean; - defer?: boolean; - }); - write(value: T, flags?: number): T; - _notify(state: number, skipQueue?: boolean): void; - _notifyFlags(mask: Flags, newFlags: Flags): void; - _setError(error: unknown): void; - _disposeNode(): void; - _run(type: number): void; -} -export declare class EagerComputation extends Computation { - constructor(initialValue: T, compute: () => T, options?: SignalOptions & { - defer?: boolean; - }); - _notify(state: number, skipQueue?: boolean): void; - _run(): void; -} -export declare class FirewallComputation extends Computation { - firewall: boolean; - constructor(compute: () => void); - _notify(state: number, skipQueue?: boolean): void; - _run(): void; -} diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/error.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/error.d.ts deleted file mode 100644 index eea675ff9..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/error.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export declare class NotReadyError extends Error { -} -export declare class NoOwnerError extends Error { - constructor(); -} -export declare class ContextNotFoundError extends Error { - constructor(); -} diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/flags.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/flags.d.ts deleted file mode 100644 index b63bff2e2..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/flags.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type Flags = number; -export declare const ERROR_OFFSET = 0; -export declare const ERROR_BIT: number; -export declare const ERROR: unique symbol; -export declare const LOADING_OFFSET = 1; -export declare const LOADING_BIT: number; -export declare const LOADING: unique symbol; -export declare const UNINITIALIZED_OFFSET = 2; -export declare const UNINITIALIZED_BIT: number; -export declare const UNINITIALIZED: unique symbol; -export declare const DEFAULT_FLAGS: number; diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/index.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/index.d.ts deleted file mode 100644 index a7f9c9efc..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js"; -export { Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, type Context, type ContextRecord, type Disposable } from "./owner.js"; -export { Computation, getObserver, isEqual, untrack, hasUpdated, isPending, latest, UNCHANGED, compute, runWithObserver, type SignalOptions } from "./core.js"; -export { Effect, EagerComputation } from "./effect.js"; -export { flush, Queue, incrementClock, transition, ActiveTransition, type IQueue } from "./scheduler.js"; -export * from "./constants.js"; -export * from "./flags.js"; diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/owner.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/owner.d.ts deleted file mode 100644 index 83f9c4301..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/owner.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Owner tracking is used to enable nested tracking scopes with automatic cleanup. - * We also use owners to also keep track of which error handling context we are in. - * - * If you write the following - * - * const a = createOwner(() => { - * const b = createOwner(() => {}); - * - * const c = createOwner(() => { - * const d = createOwner(() => {}); - * }); - * - * const e = createOwner(() => {}); - * }); - * - * The owner tree will look like this: - * - * a - * /|\ - * b-c-e - * | - * d - * - * Following the _nextSibling pointers of each owner will first give you its children, and then its siblings (in reverse). - * a -> e -> c -> d -> b - * - * Note that the owner tree is largely orthogonal to the reactivity tree, and is much closer to the component tree. - */ -import { type IQueue } from "./scheduler.js"; -export type ContextRecord = Record; -export interface Disposable { - (): void; -} -/** - * Returns the currently executing parent owner. - */ -export declare function getOwner(): Owner | null; -export declare function setOwner(owner: Owner | null): Owner | null; -export declare class Owner { - _parent: Owner | null; - _nextSibling: Owner | null; - _prevSibling: Owner | null; - _state: number; - _disposal: Disposable | Disposable[] | null; - _context: ContextRecord; - _queue: IQueue; - _childCount: number; - id: string | null; - constructor(id?: string | null, skipAppend?: boolean); - append(child: Owner): void; - dispose(this: Owner, self?: boolean): void; - _disposeNode(): void; - emptyDisposal(): void; - getNextChildId(): string; -} -export interface Context { - readonly id: symbol; - readonly defaultValue: T | undefined; -} -/** - * Context provides a form of dependency injection. It is used to save from needing to pass - * data as props through intermediate components. This function creates a new context object - * that can be used with `getContext` and `setContext`. - * - * A default value can be provided here which will be used when a specific value is not provided - * via a `setContext` call. - */ -export declare function createContext(defaultValue?: T, description?: string): Context; -/** - * Attempts to get a context value for the given key. - * - * @throws `NoOwnerError` if there's no owner at the time of call. - * @throws `ContextNotFoundError` if a context value has not been set yet. - */ -export declare function getContext(context: Context, owner?: Owner | null): T; -/** - * Attempts to set a context value on the parent scope with the given key. - * - * @throws `NoOwnerError` if there's no owner at the time of call. - */ -export declare function setContext(context: Context, value?: T, owner?: Owner | null): void; -/** - * Whether the given context is currently defined. - */ -export declare function hasContext(context: Context, owner?: Owner | null): boolean; -/** - * Runs an effect once before the reactive scope is disposed - * @param fn an effect that should run only once on cleanup - * - * @returns the same {@link fn} function that was passed in - * - * @description https://docs.solidjs.com/reference/lifecycle/on-cleanup - */ -export declare function onCleanup(fn: Disposable): Disposable; diff --git a/modules/solidjs-signals/0.6.3/dist/types/core/scheduler.d.ts b/modules/solidjs-signals/0.6.3/dist/types/core/scheduler.d.ts deleted file mode 100644 index f9bce8bc8..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/core/scheduler.d.ts +++ /dev/null @@ -1,86 +0,0 @@ -import type { Computation, ObserverType, SourceType } from "./core.js"; -import type { Effect } from "./effect.js"; -export declare let clock: number; -export declare function incrementClock(): void; -export declare let ActiveTransition: Transition | null; -export declare let Unobserved: SourceType[]; -export type QueueCallback = (type: number) => void; -export interface IQueue { - enqueue(type: number, fn: QueueCallback): void; - run(type: number): boolean | void; - flush(): void; - addChild(child: IQueue): void; - removeChild(child: IQueue): void; - created: number; - notify(...args: any[]): boolean; - merge(queue: IQueue): void; - _parent: IQueue | null; - _cloned?: IQueue | undefined; -} -export declare class Queue implements IQueue { - _parent: IQueue | null; - _running: boolean; - _queues: [QueueCallback[], QueueCallback[]]; - _children: IQueue[]; - created: number; - enqueue(type: number, fn: QueueCallback): void; - run(type: number): void; - flush(): void; - addChild(child: IQueue): any; - removeChild(child: IQueue): any; - notify(...args: any[]): boolean; - merge(queue: Queue): void; -} -export declare const globalQueue: Queue; -/** - * By default, changes are batched on the microtask queue which is an async process. You can flush - * the queue synchronously to get the latest updates by calling `flush()`. - */ -export declare function flush(): void; -export declare function removeSourceObservers(node: ObserverType, index: number): void; -export declare class Transition implements IQueue { - _sources: Map; - _pendingNodes: Set; - _promises: Set>; - _optimistic: Set<(() => void) & { - _transition?: Transition; - }>; - _done: Transition | boolean; - _queues: [QueueCallback[], QueueCallback[]]; - _clonedQueues: Map; - _pureQueue: QueueCallback[]; - _children: IQueue[]; - _parent: IQueue | null; - _running: boolean; - _scheduled: boolean; - _cloned: Queue; - created: number; - constructor(); - enqueue(type: number, fn: QueueCallback): void; - run(type: number): void; - flush(): void; - addChild(child: IQueue): void; - removeChild(child: IQueue): void; - notify(node: Effect, type: number, flags: number): boolean; - merge(queue: Transition): void; - schedule(): void; - runTransition(fn: () => any | Promise, force?: boolean): void; - addOptimistic(fn: (() => void) & { - _transition?: Transition; - }): void; -} -/** - * Runs the given function in a transition scope, allowing for batch updates and optimizations. - * This is useful for grouping multiple state updates together to avoid unnecessary re-renders. - * - * @param fn A function that receives a resume function to continue the transition. - * The resume function can be called with another function to continue the transition. - * - * @description https://docs.solidjs.com/reference/advanced-reactivity/transition - */ -export declare function transition(fn: (resume: (fn: () => any | Promise) => void) => any | Promise | Iterable): void; -export declare function cloneGraph(node: Computation): Computation; -export declare function getOGSource(input: T): T; -export declare function getTransitionSource(input: T): T; -export declare function getQueue(node: Computation): IQueue; -export declare function initialDispose(node: any): void; diff --git a/modules/solidjs-signals/0.6.3/dist/types/index.d.ts b/modules/solidjs-signals/0.6.3/dist/types/index.d.ts deleted file mode 100644 index b797d264c..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flush, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated, isPending, latest, runWithObserver, transition, SUPPORTS_PROXY } from "./core/index.js"; -export type { SignalOptions, Context, ContextRecord, Disposable, IQueue } from "./core/index.js"; -export { mapArray, repeat, type Maybe } from "./map.js"; -export * from "./signals.js"; -export * from "./store/index.js"; -export { createSuspense, createErrorBoundary, createBoundary, flatten, type BoundaryMode } from "./boundaries.js"; diff --git a/modules/solidjs-signals/0.6.3/dist/types/map.d.ts b/modules/solidjs-signals/0.6.3/dist/types/map.d.ts deleted file mode 100644 index 74ed53672..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/map.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Accessor } from "./signals.js"; -export type Maybe = T | void | null | undefined | false; -/** - * Reactively transforms an array with a callback function - underlying helper for the `` control flow - * - * similar to `Array.prototype.map`, but gets the value and index as accessors, transforms only values that changed and returns an accessor and reactively tracks changes to the list. - * - * @description https://docs.solidjs.com/reference/reactive-utilities/map-array - */ -export declare function mapArray(list: Accessor>, map: (value: Accessor, index: Accessor) => MappedItem, options?: { - keyed?: boolean | ((item: Item) => any); - fallback?: Accessor; -}): Accessor; -/** - * Reactively repeats a callback function the count provided - underlying helper for the `` control flow - * - * @description https://docs.solidjs.com/reference/reactive-utilities/repeat - */ -export declare function repeat(count: Accessor, map: (index: number) => any, options?: { - from?: Accessor; - fallback?: Accessor; -}): Accessor; diff --git a/modules/solidjs-signals/0.6.3/dist/types/signals.d.ts b/modules/solidjs-signals/0.6.3/dist/types/signals.d.ts deleted file mode 100644 index 528a0de98..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/signals.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -import type { SignalOptions } from "./core/index.js"; -import { Owner } from "./core/index.js"; -import { type Store, type StoreSetter } from "./store/index.js"; -export type Accessor = () => T; -export type Setter = { - (...args: undefined extends T ? [] : [value: Exclude | ((prev: T) => U)]): undefined extends T ? undefined : U; - (value: (prev: T) => U): U; - (value: Exclude): U; - (value: Exclude | ((prev: T) => U)): U; -}; -export type Signal = [get: Accessor, set: Setter]; -export type ComputeFunction = (v: Prev) => Next; -export type EffectFunction = (v: Next, p?: Prev) => (() => void) | void; -export type EffectBundle = { - effect: EffectFunction; - error: (err: unknown, cleanup: () => void) => void; -}; -export interface EffectOptions { - name?: string; - defer?: boolean; -} -export interface MemoOptions { - name?: string; - equals?: false | ((prev: T, next: T) => boolean); -} -export type NoInfer = [T][T extends any ? 0 : never]; -/** - * Creates a simple reactive state with a getter and setter - * ```typescript - * const [state: Accessor, setState: Setter] = createSignal( - * value: T, - * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) } - * ) - * ``` - * @param value initial value of the state; if empty, the state's type will automatically extended with undefined; otherwise you need to extend the type manually if you want setting to undefined not be an error - * @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity - * - * @returns ```typescript - * [state: Accessor, setState: Setter] - * ``` - * * the Accessor is a function that returns the current value and registers each call to the reactive root - * * the Setter is a function that allows directly setting or mutating the value: - * ```typescript - * const [count, setCount] = createSignal(0); - * setCount(count => count + 1); - * ``` - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-signal - */ -export declare function createSignal(): Signal; -export declare function createSignal(value: Exclude, options?: SignalOptions): Signal; -export declare function createSignal(fn: ComputeFunction, initialValue?: T, options?: SignalOptions): Signal; -/** - * Creates a readonly derived reactive memoized signal - * ```typescript - * export function createMemo( - * compute: (v: T) => T, - * value?: T, - * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) } - * ): () => T; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo - */ -export declare function createMemo(compute: ComputeFunction, Next>): Accessor; -export declare function createMemo(compute: ComputeFunction, value: Init, options?: MemoOptions): Accessor; -/** - * Creates a readonly derived async reactive memoized signal - * ```typescript - * export function createAsync( - * compute: (v: T) => Promise | T, - * value?: T, - * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) } - * ): () => T; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-async - */ -export declare function createAsync(compute: (prev: T | undefined, refreshing: boolean) => Promise | AsyncIterable | T, value?: T, options?: MemoOptions): Accessor & { - refresh: () => void; -}; -/** - * Creates a reactive effect that runs after the render phase - * ```typescript - * export function createEffect( - * compute: (prev: T) => T, - * effect: (v: T, prev: T) => (() => void) | void, - * value?: T, - * options?: { name?: string } - * ): void; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param effect a function that receives the new value and is used to perform side effects, return a cleanup function to run on disposal - * @param error an optional function that receives an error if thrown during the computation - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-effect - */ -export declare function createEffect(compute: ComputeFunction, Next>, effect: EffectFunction, Next> | EffectBundle, Next>): void; -export declare function createEffect(compute: ComputeFunction, effect: EffectFunction | EffectBundle, value: Init, options?: EffectOptions): void; -/** - * Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected - * ```typescript - * export function createRenderEffect( - * compute: (prev: T) => T, - * effect: (v: T, prev: T) => (() => void) | void, - * value?: T, - * options?: { name?: string } - * ): void; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param effect a function that receives the new value and is used to perform side effects - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes - * - * @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect - */ -export declare function createRenderEffect(compute: ComputeFunction, Next>, effect: EffectFunction, Next>): void; -export declare function createRenderEffect(compute: ComputeFunction, effect: EffectFunction, value: Init, options?: EffectOptions): void; -/** - * Creates a new non-tracked reactive context with manual disposal - * - * @param fn a function in which the reactive state is scoped - * @returns the output of `fn`. - * - * @description https://docs.solidjs.com/reference/reactive-utilities/create-root - */ -export declare function createRoot(init: ((dispose: () => void) => T) | (() => T), options?: { - id: string; -}): T; -/** - * Runs the given function in the given owner to move ownership of nested primitives and cleanups. - * This method untracks the current scope. - * - * Warning: Usually there are simpler ways of modeling a problem that avoid using this function - */ -export declare function runWithOwner(owner: Owner | null, run: () => T): T; -/** - * Returns a promise of the resolved value of a reactive expression - * @param fn a reactive expression to resolve - */ -export declare function resolve(fn: () => T): Promise; -/** Allows the user to mark a state change as non-urgent. - * - * @see {@link https://docs.solidjs.com/reference/advanced-reactivity/transition} - * - * @returns A tuple containing an accessor for the pending state and a function to start a transition. - */ -export declare function useTransition(): [ - get: Accessor, - start: (fn: (resume: (fn: () => any | Promise) => void) => any | Promise | Iterable) => void -]; -/** - * Creates an optimistic store that can be used to optimistically update a value - * and then revert it back to the previous value at end of transition. - * ```typescript - * export function createOptimistic( - * fn: (store: T) => void, - * initial: T, - * options?: { key?: string | ((item: NonNullable) => any); all?: boolean } - * ): [get: Store, set: StoreSetter]; - * ``` - * @param fn a function that receives the current store and can be used to mutate it directly inside a transition - * @param initial The initial value of the signal. - * @param options Optional signal options. - * - * @returns A tuple containing an accessor for the current value and a setter function to apply changes. - */ -export declare function createOptimistic(initial: T | Store): [get: Store, set: StoreSetter]; -export declare function createOptimistic(fn: (store: T) => void, initial: T | Store, options?: { - key?: string | ((item: NonNullable) => any); - all?: boolean; -}): [get: Store, set: StoreSetter]; diff --git a/modules/solidjs-signals/0.6.3/dist/types/store/index.d.ts b/modules/solidjs-signals/0.6.3/dist/types/store/index.d.ts deleted file mode 100644 index faa557495..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/store/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type { Store, StoreSetter, StoreNode, NotWrappable, SolidStore } from "./store.js"; -export type { Merge, Omit } from "./utils.js"; -export { isWrappable, createStore, deep, $TRACK, $PROXY, $TARGET } from "./store.js"; -export { createProjection } from "./projection.js"; -export { reconcile } from "./reconcile.js"; -export { snapshot, merge, omit } from "./utils.js"; diff --git a/modules/solidjs-signals/0.6.3/dist/types/store/projection.d.ts b/modules/solidjs-signals/0.6.3/dist/types/store/projection.d.ts deleted file mode 100644 index 188db4455..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/store/projection.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { type Store, type StoreOptions } from "./store.js"; -/** - * Creates a mutable derived value - * - * @see {@link https://github.com/solidjs/x-reactivity#createprojection} - */ -export declare function createProjection(fn: (draft: T) => void | T, initialValue?: T, options?: StoreOptions): Store; diff --git a/modules/solidjs-signals/0.6.3/dist/types/store/reconcile.d.ts b/modules/solidjs-signals/0.6.3/dist/types/store/reconcile.d.ts deleted file mode 100644 index 01effdba8..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/store/reconcile.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function reconcile(value: T, key: string | ((item: NonNullable) => any), all?: boolean): (state: U) => void; diff --git a/modules/solidjs-signals/0.6.3/dist/types/store/store.d.ts b/modules/solidjs-signals/0.6.3/dist/types/store/store.d.ts deleted file mode 100644 index 69e129368..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/store/store.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Computation } from "../core/index.js"; -export type Store = Readonly; -export type StoreSetter = (fn: (state: T) => T | void) => void; -export type StoreOptions = { - key?: string | ((item: NonNullable) => any); - all?: boolean; -}; -type DataNode = Computation; -type DataNodes = Record; -export declare const $TRACK: unique symbol, $DEEP: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol; -export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l"; -export type StoreNode = { - [$PROXY]: any; - [STORE_VALUE]: Record; - [STORE_OVERRIDE]?: Record; - [STORE_NODE]?: DataNodes; - [STORE_HAS]?: DataNodes; - [STORE_WRAP]?: (value: any, target?: StoreNode) => any; - [STORE_LOOKUP]?: WeakMap; -}; -export declare namespace SolidStore { - interface Unwrappable { - } -} -export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable]; -export declare function createStoreProxy(value: T, traps?: ProxyHandler, extend?: Record): any; -export declare const storeLookup: WeakMap; -export declare function wrap>(value: T, target?: StoreNode): T; -export declare function isWrappable(obj: T | NotWrappable): obj is T; -export declare function getKeys(source: Record, override: Record | undefined, enumerable?: boolean): PropertyKey[]; -export declare function getPropertyDescriptor(source: Record, override: Record | undefined, property: PropertyKey): PropertyDescriptor | undefined; -export declare const storeTraps: ProxyHandler; -export declare function storeSetter(store: Store, fn: (draft: T) => T | void): void; -export declare function createStore(store: T | Store): [get: Store, set: StoreSetter]; -export declare function createStore(fn: (store: T) => void, store: T | Store, options?: StoreOptions): [get: Store, set: StoreSetter]; -export declare function deep(store: Store): Store; -export {}; diff --git a/modules/solidjs-signals/0.6.3/dist/types/store/utils.d.ts b/modules/solidjs-signals/0.6.3/dist/types/store/utils.d.ts deleted file mode 100644 index 42e497e15..000000000 --- a/modules/solidjs-signals/0.6.3/dist/types/store/utils.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Returns a non reactive copy of the store object. - * It will attempt to preserver the original reference unless the value has been modified. - * @param item store proxy object - */ -export declare function snapshot(item: T): T; -export declare function snapshot(item: T, map?: Map, lookup?: WeakMap): T; -type DistributeOverride = T extends undefined ? F : T; -type Override = T extends any ? U extends any ? { - [K in keyof T]: K extends keyof U ? DistributeOverride : T[K]; -} & { - [K in keyof U]: K extends keyof T ? DistributeOverride : U[K]; -} : T & U : T & U; -type OverrideSpread = T extends any ? { - [K in keyof ({ - [K in keyof T]: any; - } & { - [K in keyof U]?: any; - } & { - [K in U extends any ? keyof U : keyof U]?: any; - })]: K extends keyof T ? Exclude | T[K] : U extends any ? U[K & keyof U] : never; -} : T & U; -type Simplify = T extends any ? { - [K in keyof T]: T[K]; -} : T; -type _Merge = T extends [ - infer Next | (() => infer Next), - ...infer Rest -] ? _Merge> : T extends [...infer Rest, infer Next | (() => infer Next)] ? Override<_Merge, Next> : T extends [] ? Curr : T extends (infer I | (() => infer I))[] ? OverrideSpread : Curr; -export type Merge = Simplify<_Merge>; -export declare function merge(...sources: T): Merge; -export type Omit = { - [P in keyof T as Exclude]: T[P]; -}; -export declare function omit, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit; -export {}; diff --git a/modules/solidjs-signals/0.9.2/dist/prod.js b/modules/solidjs-signals/0.9.2/dist/prod.js deleted file mode 100644 index 6994d1c4b..000000000 --- a/modules/solidjs-signals/0.9.2/dist/prod.js +++ /dev/null @@ -1,2132 +0,0 @@ -// @ts-nocheck -class NotReadyError extends Error { - cause; - constructor(e) { - super(); - this.cause = e; - } -} -class NoOwnerError extends Error { - constructor() { - super(""); - } -} -class ContextNotFoundError extends Error { - constructor() { - super(""); - } -} -const REACTIVE_NONE = 0; -const REACTIVE_CHECK = 1 << 0; -const REACTIVE_DIRTY = 1 << 1; -const REACTIVE_RECOMPUTING_DEPS = 1 << 2; -const REACTIVE_IN_HEAP = 1 << 3; -const REACTIVE_IN_HEAP_HEIGHT = 1 << 4; -const REACTIVE_ZOMBIE = 1 << 5; -const REACTIVE_DISPOSED = 1 << 6; -const STATUS_NONE = 0; -const STATUS_PENDING = 1 << 0; -const STATUS_ERROR = 1 << 1; -const STATUS_UNINITIALIZED = 1 << 2; -const EFFECT_RENDER = 1; -const EFFECT_USER = 2; -const NOT_PENDING = {}; -const SUPPORTS_PROXY = typeof Proxy === "function"; -const defaultContext = {}; -function actualInsertIntoHeap(e, t) { - const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1; - if (n >= e.o) e.o = n + 1; - const i = e.o; - const r = t.l[i]; - if (r === undefined) t.l[i] = e; - else { - const t = r.T; - t.R = e; - e.T = t; - r.T = e; - } - if (i > t.h) t.h = i; -} -function insertIntoHeap(e, t) { - let n = e.S; - if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS)) return; - if (n & REACTIVE_CHECK) { - e.S = (n & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP; - } else e.S = n | REACTIVE_IN_HEAP; - if (!(n & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t); -} -function insertIntoHeapHeight(e, t) { - let n = e.S; - if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT)) return; - e.S = n | REACTIVE_IN_HEAP_HEIGHT; - actualInsertIntoHeap(e, t); -} -function deleteFromHeap(e, t) { - const n = e.S; - if (!(n & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return; - e.S = n & -25; - const i = e.o; - if (e.T === e) t.l[i] = undefined; - else { - const n = e.R; - const r = t.l[i]; - const s = n ?? r; - if (e === r) t.l[i] = n; - else e.T.R = n; - s.T = e.T; - } - e.T = e; - e.R = undefined; -} -function markHeap(e) { - if (e._) return; - e._ = true; - for (let t = 0; t <= e.h; t++) { - for (let n = e.l[t]; n !== undefined; n = n.R) { - if (n.S & REACTIVE_IN_HEAP) markNode(n); - } - } -} -function markNode(e, t = REACTIVE_DIRTY) { - const n = e.S; - if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return; - e.S = (n & -4) | t; - for (let t = e.O; t !== null; t = t.p) { - markNode(t.A, REACTIVE_CHECK); - } - if (e.N !== null) { - for (let t = e.N; t !== null; t = t.I) { - for (let e = t.O; e !== null; e = e.p) { - markNode(e.A, REACTIVE_CHECK); - } - } - } -} -function runHeap(e, t) { - e._ = false; - for (e.C = 0; e.C <= e.h; e.C++) { - let n = e.l[e.C]; - while (n !== undefined) { - if (n.S & REACTIVE_IN_HEAP) t(n); - else adjustHeight(n, e); - n = e.l[e.C]; - } - } - e.h = 0; -} -function adjustHeight(e, t) { - deleteFromHeap(e, t); - let n = e.o; - for (let t = e.D; t; t = t.P) { - const e = t.V; - const i = e.m || e; - if (i.U && i.o >= n) n = i.o + 1; - } - if (e.o !== n) { - e.o = n; - for (let n = e.O; n !== null; n = n.p) { - insertIntoHeapHeight(n.A, t); - } - } -} -const transitions = new Set(); -let optimisticRun = false; -const dirtyQueue = { l: new Array(2e3).fill(undefined), _: false, C: 0, h: 0 }; -const zombieQueue = { l: new Array(2e3).fill(undefined), _: false, C: 0, h: 0 }; -let clock = 0; -let activeTransition = null; -let scheduled = false; -function schedule() { - if (scheduled) return; - scheduled = true; - if (!globalQueue.k) queueMicrotask(flush); -} -class Queue { - i = null; - G = [[], []]; - H = []; - created = clock; - addChild(e) { - this.H.push(e); - e.i = this; - } - removeChild(e) { - const t = this.H.indexOf(e); - if (t >= 0) { - this.H.splice(t, 1); - e.i = null; - } - } - notify(e, t, n) { - if (this.i) return this.i.notify(e, t, n); - return false; - } - run(e) { - if (this.G[e - 1].length) { - const t = this.G[e - 1]; - this.G[e - 1] = []; - runQueue(t, e); - } - for (let t = 0; t < this.H.length; t++) { - this.H[t].run(e); - } - } - enqueue(e, t) { - if (e) this.G[e - 1].push(t); - schedule(); - } - stashQueues(e) { - e.G[0].push(...this.G[0]); - e.G[1].push(...this.G[1]); - this.G = [[], []]; - for (let t = 0; t < this.H.length; t++) { - let n = this.H[t]; - let i = e.H[t]; - if (!i) { - i = { G: [[], []], H: [] }; - e.H[t] = i; - } - n.stashQueues(i); - } - } - restoreQueues(e) { - this.G[0].push(...e.G[0]); - this.G[1].push(...e.G[1]); - for (let t = 0; t < e.H.length; t++) { - const n = e.H[t]; - let i = this.H[t]; - if (i) i.restoreQueues(n); - } - } -} -class GlobalQueue extends Queue { - k = false; - $ = []; - L = []; - static F; - static W; - flush() { - if (this.k) return; - this.k = true; - try { - runHeap(dirtyQueue, GlobalQueue.F); - if (activeTransition) { - if (!transitionComplete(activeTransition)) { - let e = activeTransition; - runHeap(zombieQueue, GlobalQueue.F); - this.$ = []; - this.stashQueues(activeTransition.queueStash); - clock++; - scheduled = false; - runTransitionPending(activeTransition.pendingNodes, true); - activeTransition = null; - runOptimistic(e); - return; - } - this.$.push(...activeTransition.pendingNodes); - this.restoreQueues(activeTransition.queueStash); - transitions.delete(activeTransition); - activeTransition = null; - runTransitionPending(this.$, false); - } else if (transitions.size) runHeap(zombieQueue, GlobalQueue.F); - runOptimistic(); - clock++; - scheduled = false; - this.run(EFFECT_RENDER); - this.run(EFFECT_USER); - } finally { - this.k = false; - } - } - notify(e, t, n) { - if (t & STATUS_PENDING) { - if (n & STATUS_PENDING) { - if (activeTransition && !activeTransition.asyncNodes.includes(e.j.cause)) { - activeTransition.asyncNodes.push(e.j.cause); - schedule(); - } - } - return true; - } - return false; - } - initTransition(e) { - if (activeTransition && activeTransition.time === clock) return; - if (!activeTransition) { - activeTransition = e.K ?? { - time: clock, - pendingNodes: [], - asyncNodes: [], - optimisticNodes: [], - queueStash: { G: [[], []], H: [] }, - done: false - }; - } - transitions.add(activeTransition); - activeTransition.time = clock; - for (let e = 0; e < this.$.length; e++) { - const t = this.$[e]; - t.K = activeTransition; - activeTransition.pendingNodes.push(t); - } - for (let e = 0; e < this.L.length; e++) { - const t = this.L[e]; - t.K = activeTransition; - activeTransition.optimisticNodes.push(t); - } - this.$ = activeTransition.pendingNodes; - this.L = activeTransition.optimisticNodes; - } -} -function notifySubs(e) { - for (let t = e.O; t !== null; t = t.p) { - const e = t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue; - if (e.C > t.A.o) e.C = t.A.o; - insertIntoHeap(t.A, e); - } -} -function runOptimistic(e = null) { - let t = !e; - const n = globalQueue.L; - optimisticRun = true; - for (let t = 0; t < n.length; t++) { - const i = n[t]; - if (!e && (!i.K || i.K.done) && i.M !== NOT_PENDING) { - i.Y = i.M; - i.M = NOT_PENDING; - } - i.K = e; - notifySubs(i); - } - globalQueue.L = []; - if (dirtyQueue.h >= dirtyQueue.C) { - t = true; - runHeap(dirtyQueue, GlobalQueue.F); - } - optimisticRun = false; - t && runPending(globalQueue.$); -} -function runPending(e) { - for (let t = 0; t < e.length; t++) { - const n = e[t]; - if (n.M !== NOT_PENDING) { - n.Y = n.M; - n.M = NOT_PENDING; - if (n.B) n.X = true; - } - if (n.U) GlobalQueue.W(n, false, true); - } - e.length = 0; -} -function runTransitionPending(e, t) { - const n = e.slice(); - for (let e = 0; e < n.length; e++) { - const i = n[e]; - i.K = activeTransition; - if (i.q) i.q.Z(t); - } -} -const globalQueue = new GlobalQueue(); -function flush() { - while (scheduled) { - globalQueue.flush(); - } -} -function runQueue(e, t) { - for (let n = 0; n < e.length; n++) e[n](t); -} -function transitionComplete(e) { - if (e.done) return true; - let t = true; - for (let n = 0; n < e.asyncNodes.length; n++) { - if (e.asyncNodes[n].J & STATUS_PENDING) { - t = false; - break; - } - } - t && (e.done = true); - return t; -} -function runInTransition(e, t) { - const n = activeTransition; - activeTransition = e.K; - t(e); - activeTransition = n; -} -GlobalQueue.F = recompute; -GlobalQueue.W = disposeChildren; -let tracking = false; -let stale = false; -let pendingValueCheck = false; -let pendingCheck = null; -let refreshing = false; -let context = null; -function recompute(e, t = false) { - const n = e.B && e.K != activeTransition; - if (!t) { - if (e.K && activeTransition !== e.K && !n) globalQueue.initTransition(e); - deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue); - if (e.K) disposeChildren(e); - else { - markDisposal(e); - e.ee = e.te; - e.ne = e.ie; - e.te = null; - e.ie = null; - } - } - const i = context; - context = e; - e.re = null; - e.S = REACTIVE_RECOMPUTING_DEPS; - e.se = clock; - let r = e.M === NOT_PENDING || (e.oe && e.K) ? e.Y : e.M; - let s = e.o; - let o = e.J; - let u = e.j; - let l = tracking; - setStatusFlags(e, STATUS_NONE | (o & STATUS_UNINITIALIZED)); - tracking = true; - try { - r = handleAsync(e, e.U(r)); - e.J &= ~STATUS_UNINITIALIZED; - } catch (t) { - if (t instanceof NotReadyError) { - if (t.cause !== e) link(t.cause, e); - setStatusFlags(e, (o & ~STATUS_ERROR) | STATUS_PENDING, t); - } else setStatusFlags(e, STATUS_ERROR, t); - } finally { - tracking = l; - } - e.S = REACTIVE_NONE; - context = i; - if (!(e.J & STATUS_PENDING)) { - const t = e.re; - let n = t !== null ? t.P : e.D; - if (n !== null) { - do { - n = unlinkSubs(n); - } while (n !== null); - if (t !== null) t.P = null; - else e.D = null; - } - } - const c = !e.ue || !e.ue(e.M === NOT_PENDING || e.oe || n ? e.Y : e.M, r); - const a = e.J !== o || e.j !== u; - e.le?.(a, o); - if (c || a) { - if (c) { - if (t || e.oe || n) e.Y = r; - else e.M = r; - if (e.ce) setSignal(e.ce, r); - } - (!e.oe || optimisticRun) && notifySubs(e); - } else if (e.o != s) { - for (let t = e.O; t !== null; t = t.p) { - insertIntoHeapHeight(t.A, t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue); - } - } - e.oe && !optimisticRun && globalQueue.L.push(e); - (!t || e.J & STATUS_PENDING) && !e.K && globalQueue.$.push(e); - e.K && n && runInTransition(e, recompute); -} -function handleAsync(e, t, n) { - const i = typeof t === "object" && t !== null; - const r = i && t instanceof Promise; - const s = i && untrack(() => t[Symbol.asyncIterator]); - if (!r && !s) { - e.ae = null; - return t; - } - e.ae = t; - if (r) { - t.then(i => { - if (e.ae !== t) return; - globalQueue.initTransition(e); - n?.(i) ?? setSignal(e, () => i); - flush(); - }).catch(n => { - if (e.ae !== t) return; - globalQueue.initTransition(e); - setStatusFlags(e, STATUS_ERROR, n); - e.se = clock; - notifySubs(e); - schedule(); - flush(); - }); - } else { - (async () => { - try { - for await (let i of t) { - if (e.ae !== t) return; - globalQueue.initTransition(e); - n?.(i) ?? setSignal(e, () => i); - flush(); - } - } catch (n) { - if (e.ae !== t) return; - globalQueue.initTransition(e); - setStatusFlags(e, STATUS_ERROR, n); - e.se = clock; - notifySubs(e); - schedule(); - flush(); - } - })(); - } - globalQueue.initTransition(e); - throw new NotReadyError(context); -} -function updateIfNecessary(e) { - if (e.S & REACTIVE_CHECK) { - for (let t = e.D; t; t = t.P) { - const n = t.V; - const i = n.m || n; - if (i.U) { - updateIfNecessary(i); - } - if (e.S & REACTIVE_DIRTY) { - break; - } - } - } - if (e.S & REACTIVE_DIRTY) { - recompute(e); - } - e.S = REACTIVE_NONE; -} -function unlinkSubs(e) { - const t = e.V; - const n = e.P; - const i = e.p; - const r = e.fe; - if (i !== null) i.fe = r; - else t.Ee = r; - if (r !== null) r.p = i; - else { - t.O = i; - if (i === null) { - t.de?.(); - t.U && !t.Te && unobserved(t); - } - } - return n; -} -function unobserved(e) { - deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue); - let t = e.D; - while (t !== null) { - t = unlinkSubs(t); - } - e.D = null; - disposeChildren(e, true); -} -function link(e, t) { - const n = t.re; - if (n !== null && n.V === e) return; - let i = null; - const r = t.S & REACTIVE_RECOMPUTING_DEPS; - if (r) { - i = n !== null ? n.P : t.D; - if (i !== null && i.V === e) { - t.re = i; - return; - } - } - const s = e.Ee; - if (s !== null && s.A === t && (!r || isValidLink(s, t))) return; - const o = (t.re = e.Ee = { V: e, A: t, P: i, fe: s, p: null }); - if (n !== null) n.P = o; - else t.D = o; - if (s !== null) s.p = o; - else e.O = o; -} -function isValidLink(e, t) { - const n = t.re; - if (n !== null) { - let i = t.D; - do { - if (i === e) return true; - if (i === n) break; - i = i.P; - } while (i !== null); - } - return false; -} -function setStatusFlags(e, t, n = null) { - e.J = t; - e.j = n; -} -function markDisposal(e) { - let t = e.ie; - while (t) { - t.S |= REACTIVE_ZOMBIE; - if (t.S & REACTIVE_IN_HEAP) { - deleteFromHeap(t, dirtyQueue); - insertIntoHeap(t, zombieQueue); - } - markDisposal(t); - t = t.Re; - } -} -function dispose(e) { - let t = e.D || null; - do { - t = unlinkSubs(t); - } while (t !== null); - e.D = null; - e.re = null; - disposeChildren(e, true); -} -function disposeChildren(e, t = false, n) { - if (e.S & REACTIVE_DISPOSED) return; - if (t) e.S = REACTIVE_DISPOSED; - let i = n ? e.ne : e.ie; - while (i) { - const e = i.Re; - if (i.D) { - const e = i; - deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue); - let t = e.D; - do { - t = unlinkSubs(t); - } while (t !== null); - e.D = null; - e.re = null; - } - disposeChildren(i, true); - i = e; - } - if (n) { - e.ne = null; - } else { - e.ie = null; - e.Re = null; - } - runDisposal(e, n); -} -function runDisposal(e, t) { - let n = t ? e.ee : e.te; - if (!n) return; - if (Array.isArray(n)) { - for (let e = 0; e < n.length; e++) { - const t = n[e]; - t.call(t); - } - } else { - n.call(n); - } - t ? (e.ee = null) : (e.te = null); -} -function getNextChildId(e) { - if (e.id != null) return formatId(e.id, e.he++); - throw new Error("Cannot get child id from owner without an id"); -} -function formatId(e, t) { - const n = t.toString(36), - i = n.length - 1; - return e + (i ? String.fromCharCode(64 + i) : "") + n; -} -function computed(e, t, n) { - const i = { - id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined), - ue: n?.equals != null ? n.equals : isEqual, - Se: !!n?.pureWrite, - de: n?.unobserved, - te: null, - _e: context?._e ?? globalQueue, - Oe: context?.Oe ?? defaultContext, - he: 0, - U: e, - Y: t, - o: 0, - N: null, - R: undefined, - T: null, - D: null, - re: null, - O: null, - Ee: null, - i: context, - Re: null, - ie: null, - S: REACTIVE_NONE, - J: STATUS_UNINITIALIZED, - se: clock, - M: NOT_PENDING, - ee: null, - ne: null, - ae: null, - K: null - }; - if (n?.pe) Object.assign(i, n.pe); - i.T = i; - const r = context?.t ? context.u : context; - if (context) { - const e = context.ie; - if (e === null) { - context.ie = i; - } else { - i.Re = e; - context.ie = i; - } - } - if (r) i.o = r.o + 1; - !n?.lazy && recompute(i, true); - return i; -} -function signal(e, t, n = null) { - const i = { - id: t?.id ?? (context?.id != null ? getNextChildId(context) : undefined), - ue: t?.equals != null ? t.equals : isEqual, - Se: !!t?.pureWrite, - de: t?.unobserved, - Y: e, - O: null, - Ee: null, - J: STATUS_NONE, - se: clock, - m: n, - I: n?.N || null, - M: NOT_PENDING - }; - n && (n.N = i); - return i; -} -function isEqual(e, t) { - return e === t; -} -function untrack(e) { - if (!tracking) return e(); - tracking = false; - try { - return e(); - } finally { - tracking = true; - } -} -function read(e) { - let t = context; - if (t?.t) t = t.u; - if (refreshing && e.U) recompute(e); - if (t && tracking && !pendingCheck && !pendingValueCheck) { - if (e.U && e.S & REACTIVE_DISPOSED) recompute(e); - link(e, t); - const n = e.m || e; - if (n.U) { - const i = e.S & REACTIVE_ZOMBIE; - if (n.o >= (i ? zombieQueue.C : dirtyQueue.C)) { - markNode(t); - markHeap(i ? zombieQueue : dirtyQueue); - updateIfNecessary(n); - } - const r = n.o; - if (r >= t.o && e.i !== t) { - t.o = r + 1; - } - } - } - if (pendingCheck) { - if (!e.q) { - e.q = signal(false); - e.q.oe = true; - e.q.Z = t => setSignal(e.q, t); - } - const t = pendingCheck; - pendingCheck = null; - t.Y = read(e.q) || t.Y; - pendingCheck = t; - } - if (pendingValueCheck) { - if (!e.ce) { - e.ce = signal(e.Y); - e.ce.oe = true; - } - pendingValueCheck = false; - try { - return read(e.ce); - } finally { - pendingValueCheck = true; - } - } - if (e.J & STATUS_PENDING && !pendingCheck) { - if ((t && !stale) || e.J & STATUS_UNINITIALIZED) throw e.j; - else if (t && stale) { - setStatusFlags(t, t.J | 1, e.j); - } - } - if (e.J & STATUS_ERROR) { - if (e.se < clock) { - recompute(e, true); - return read(e); - } else { - throw e.j; - } - } - return !t || - e.oe || - e.M === NOT_PENDING || - (stale && !pendingCheck && (t.oe || (e.K && activeTransition !== e.K))) - ? e.Y - : e.M; -} -function setSignal(e, t) { - if (typeof t === "function") { - t = t(e.M === NOT_PENDING || (e.oe && e.K) ? e.Y : e.M); - } - const n = !e.ue || !e.ue(e.M === NOT_PENDING || e.oe ? e.Y : e.M, t); - if (!n && !e.J) return t; - if (n) { - if (e.oe) e.Y = t; - else { - if (e.M === NOT_PENDING) globalQueue.$.push(e); - e.M = t; - } - if (e.ce) setSignal(e.ce, t); - } - setStatusFlags(e, STATUS_NONE); - e.se = clock; - e.oe && !optimisticRun ? globalQueue.L.push(e) : notifySubs(e); - schedule(); - return t; -} -function getObserver() { - return tracking ? context : null; -} -function getOwner() { - return context; -} -function onCleanup(e) { - if (!context) return e; - const t = context; - if (!t.te) { - t.te = e; - } else if (Array.isArray(t.te)) { - t.te.push(e); - } else { - t.te = [t.te, e]; - } - return e; -} -function createOwner(e) { - const t = context; - const n = { - t: true, - u: t?.t ? t.u : t, - ie: null, - Re: null, - te: null, - id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined), - _e: t?._e ?? globalQueue, - Oe: t?.Oe || defaultContext, - he: 0, - ee: null, - ne: null, - i: t, - dispose(e = true) { - disposeChildren(n, e); - } - }; - if (t) { - const e = t.ie; - if (e === null) { - t.ie = n; - } else { - n.Re = e; - t.ie = n; - } - } - return n; -} -function createRoot(e, t) { - const n = createOwner(t); - return runWithOwner(n, () => e(n.dispose)); -} -function runWithOwner(e, t) { - const n = context; - context = e; - try { - return t(); - } finally { - context = n; - } -} -function staleValues(e, t = true) { - const n = stale; - stale = t; - try { - return e(); - } finally { - stale = n; - } -} -function pending(e) { - const t = pendingValueCheck; - pendingValueCheck = true; - try { - return staleValues(e, false); - } finally { - pendingValueCheck = t; - } -} -function isPending(e) { - const t = pendingCheck; - pendingCheck = { Y: false }; - try { - staleValues(e); - return pendingCheck.Y; - } catch (e) { - if (!(e instanceof NotReadyError)) return false; - throw e; - } finally { - pendingCheck = t; - } -} -function refresh(e) { - let t = refreshing; - refreshing = true; - try { - return untrack(e); - } finally { - refreshing = t; - if (!t) { - schedule(); - flush(); - } - } -} -function isRefreshing() { - return refreshing; -} -function createContext(e, t) { - return { id: Symbol(t), defaultValue: e }; -} -function getContext(e, t = getOwner()) { - if (!t) { - throw new NoOwnerError(); - } - const n = hasContext(e, t) ? t.Oe[e.id] : e.defaultValue; - if (isUndefined(n)) { - throw new ContextNotFoundError(); - } - return n; -} -function setContext(e, t, n = getOwner()) { - if (!n) { - throw new NoOwnerError(); - } - n.Oe = { ...n.Oe, [e.id]: isUndefined(t) ? e.defaultValue : t }; -} -function hasContext(e, t) { - return !isUndefined(t?.Oe[e.id]); -} -function isUndefined(e) { - return typeof e === "undefined"; -} -function effect(e, t, n, i, r) { - let s = false; - const o = computed(e, i, { - ...r, - pe: { - X: true, - Ae: i, - ge: t, - Ne: n, - Ie: undefined, - B: r?.render ? EFFECT_RENDER : EFFECT_USER, - le(e, t) { - if (s) { - const n = this.J && this.J === t && e; - this.X = !(this.J & STATUS_ERROR) && !(this.J & STATUS_PENDING & ~t) && !n; - if (this.X) this._e.enqueue(this.B, runEffect.bind(this)); - } - if (this.J & STATUS_ERROR) { - let e = this.j; - this._e.notify(this, STATUS_PENDING, 0); - if (this.B === EFFECT_USER) { - try { - return this.Ne - ? this.Ne(e, () => { - this.Ie?.(); - this.Ie = undefined; - }) - : console.error(e); - } catch (t) { - e = t; - } - } - if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e; - } else if (this.B === EFFECT_RENDER) { - this._e.notify(this, STATUS_PENDING | STATUS_ERROR, this.J); - } - } - } - }); - s = true; - if (o.B === EFFECT_RENDER) o.U = t => staleValues(() => e(t)); - !r?.defer && - !(o.J & (STATUS_ERROR | STATUS_PENDING)) && - (o.B === EFFECT_USER ? o._e.enqueue(o.B, runEffect.bind(o)) : runEffect.call(o)); - onCleanup(() => o.Ie?.()); -} -function runEffect() { - if (!this.X || this.S & REACTIVE_DISPOSED) return; - this.Ie?.(); - this.Ie = undefined; - try { - this.Ie = this.ge(this.Y, this.Ae); - } catch (e) { - if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e; - } finally { - this.Ae = this.Y; - this.X = false; - } -} -function createSignal(e, t, n) { - if (typeof e === "function") { - const i = computed(e, t, n); - return [read.bind(null, i), setSignal.bind(null, i)]; - } - const i = getOwner(); - const r = i?.id != null; - const s = signal(e, r ? { id: getNextChildId(i), ...t } : t); - return [read.bind(null, s), setSignal.bind(null, s)]; -} -function createMemo(e, t, n) { - let i = computed(e, t, n); - return read.bind(null, i); -} -function createEffect(e, t, n, i) { - void effect(e, t.effect || t, t.error, n, i); -} -function createRenderEffect(e, t, n, i) { - void effect(e, t, undefined, n, { render: true, ...i }); -} -function createTrackedEffect(e, t) {} -function createReaction(e, t) { - let n = undefined; - onCleanup(() => n?.()); - const i = getOwner(); - return r => { - runWithOwner(i, () => { - effect( - () => (r(), getOwner()), - t => { - n?.(); - n = (e.effect || e)?.(); - dispose(t); - }, - e.error, - undefined, - { defer: true, ...(false ? { ...t, name: t?.name ?? "effect" } : t) } - ); - }); - }; -} -function resolve(e) { - return new Promise((t, n) => { - createRoot(i => { - computed(() => { - try { - t(e()); - } catch (e) { - if (e instanceof NotReadyError) throw e; - n(e); - } - i(); - }); - }); - }); -} -function createOptimistic(e, t, n) { - if (typeof e === "function") { - const i = computed( - t => { - let n = i || getOwner(); - n.M = e(t); - return t; - }, - t, - n - ); - i.oe = true; - return [read.bind(null, i), setSignal.bind(null, i)]; - } - const i = getOwner(); - const r = i?.id != null; - const s = signal(e, r ? { id: getNextChildId(i), ...t } : t); - s.oe = true; - return [ - read.bind(null, s), - t => { - s.M = e; - return setSignal(s, t); - } - ]; -} -function onSettled(e) { - let t; - const n = getOwner(); - if (n) onCleanup(() => t?.()); - globalQueue.enqueue(EFFECT_USER, () => { - t = e(); - !n && t?.(); - }); -} -function unwrap(e) { - return e?.[$TARGET]?.[STORE_NODE] ?? e; -} -function getOverrideValue(e, t, n, i) { - return n && i in n ? read(n[i]) : t && i in t ? t[i] : e[i]; -} -function getAllKeys(e, t, n) { - const i = getKeys(e, t); - const r = Object.keys(n); - return Array.from(new Set([...i, ...r])); -} -function applyState(e, t, n, i) { - const r = t?.[$TARGET]; - if (!r) return; - const s = r[STORE_VALUE]; - const o = r[STORE_OVERRIDE]; - let u = r[STORE_NODE]; - if (e === s && !o) return; - (r[STORE_LOOKUP] || storeLookup).set(e, r[$PROXY]); - r[STORE_VALUE] = e; - r[STORE_OVERRIDE] = undefined; - if (Array.isArray(s)) { - let t = false; - const l = getOverrideValue(s, o, u, "length"); - if (e.length && l && e[0] && n(e[0]) != null) { - let c, a, f, E, d, T, R, h; - for ( - f = 0, E = Math.min(l, e.length); - f < E && ((T = getOverrideValue(s, o, u, f)) === e[f] || (T && e[f] && n(T) === n(e[f]))); - f++ - ) { - applyState(e[f], wrap(T, r), n, i); - } - const S = new Array(e.length), - _ = new Map(); - for ( - E = l - 1, d = e.length - 1; - E >= f && - d >= f && - ((T = getOverrideValue(s, o, u, E)) === e[d] || (T && e[d] && n(T) === n(e[d]))); - E--, d-- - ) { - S[d] = T; - } - if (f > d || f > E) { - for (a = f; a <= d; a++) { - t = true; - r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r)); - } - for (; a < e.length; a++) { - t = true; - const s = wrap(S[a], r); - r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], s); - applyState(e[a], s, n, i); - } - t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0); - l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length); - return; - } - R = new Array(d + 1); - for (a = d; a >= f; a--) { - T = e[a]; - h = T ? n(T) : T; - c = _.get(h); - R[a] = c === undefined ? -1 : c; - _.set(h, a); - } - for (c = f; c <= E; c++) { - T = getOverrideValue(s, o, u, c); - h = T ? n(T) : T; - a = _.get(h); - if (a !== undefined && a !== -1) { - S[a] = T; - a = R[a]; - _.set(h, a); - } - } - for (a = f; a < e.length; a++) { - if (a in S) { - const t = wrap(S[a], r); - r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], t); - applyState(e[a], t, n, i); - } else r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r)); - } - if (f < e.length) t = true; - } else if (l && e.length) { - for (let t = 0, l = e.length; t < l; t++) { - const l = getOverrideValue(s, o, u, t); - isWrappable(l) && applyState(e[t], wrap(l, r), n, i); - } - } - if (l !== e.length) { - t = true; - r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length); - } - t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0); - return; - } - if (u) { - const t = u[$TRACK]; - const l = t || i ? getAllKeys(s, o, e) : Object.keys(u); - for (let c = 0, a = l.length; c < a; c++) { - const a = l[c]; - const f = u[a]; - const E = unwrap(getOverrideValue(s, o, u, a)); - let d = unwrap(e[a]); - if (E === d) continue; - if (!E || !isWrappable(E) || (n(E) != null && n(E) !== n(d))) { - t && setSignal(t, void 0); - f && setSignal(f, isWrappable(d) ? wrap(d, r) : d); - } else applyState(d, wrap(E, r), n, i); - } - } - if ((u = r[STORE_HAS])) { - const t = Object.keys(u); - for (let n = 0, i = t.length; n < i; n++) { - const i = t[n]; - setSignal(u[i], i in e); - } - } -} -function reconcile(e, t, n = false) { - return i => { - if (i == null) throw new Error("Cannot reconcile null or undefined state"); - const r = typeof t === "string" ? e => e[t] : t; - const s = r(i); - if (s !== undefined && r(e) !== r(i)) - throw new Error("Cannot reconcile states with different identity"); - applyState(e, i, r, n); - }; -} -function createProjectionInternal(e, t = {}, n) { - let i; - const r = new WeakMap(); - const wrapProjection = e => { - if (r.has(e)) return r.get(e); - if (e[$TARGET]?.[STORE_WRAP] === wrapProjection) return e; - const t = createStoreProxy(e, storeTraps, { - [STORE_WRAP]: wrapProjection, - [STORE_LOOKUP]: r, - [STORE_FIREWALL]() { - return i; - } - }); - r.set(e, t); - return t; - }; - const s = wrapProjection(t); - i = computed(() => { - const t = i || getOwner(); - storeSetter(s, i => { - const r = handleAsync(t, e(i), e => { - e !== i && e !== undefined && storeSetter(s, reconcile(e, n?.key || "id", n?.all)); - }); - r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(i); - }); - }); - return { store: s, node: i }; -} -function createProjection(e, t = {}, n) { - return createProjectionInternal(e, t, n).store; -} -const $TRACK = Symbol(0), - $DEEP = Symbol(0), - $TARGET = Symbol(0), - $PROXY = Symbol(0), - $DELETED = Symbol(0); -const PARENTS = new WeakMap(); -const STORE_VALUE = "v", - STORE_OVERRIDE = "o", - STORE_NODE = "n", - STORE_HAS = "h", - STORE_WRAP = "w", - STORE_LOOKUP = "l", - STORE_FIREWALL = "f"; -function createStoreProxy(e, t = storeTraps, n) { - let i; - if (Array.isArray(e)) { - i = []; - i.v = e; - } else i = { v: e }; - n && Object.assign(i, n); - return (i[$PROXY] = new Proxy(i, t)); -} -const storeLookup = new WeakMap(); -function wrap(e, t) { - if (t?.[STORE_WRAP]) return t[STORE_WRAP](e, t); - let n = e[$PROXY] || storeLookup.get(e); - if (!n) storeLookup.set(e, (n = createStoreProxy(e))); - return n; -} -function isWrappable(e) { - return e != null && typeof e === "object" && !Object.isFrozen(e); -} -function getNodes(e, t) { - let n = e[t]; - if (!n) e[t] = n = Object.create(null); - return n; -} -function getNode(e, t, n, i, r = isEqual) { - if (e[t]) return e[t]; - return (e[t] = signal( - n, - { - equals: r, - unobserved() { - delete e[t]; - } - }, - i - )); -} -function trackSelf(e, t = $TRACK) { - getObserver() && - read(getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL]?.(), false)); -} -function getKeys(e, t, n = true) { - const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e))); - if (!t) return i; - const r = new Set(i); - const s = Reflect.ownKeys(t); - for (const e of s) { - if (t[e] !== $DELETED) r.add(e); - else r.delete(e); - } - return Array.from(r); -} -function getPropertyDescriptor(e, t, n) { - let i = e; - if (t && n in t) { - if (i[n] === $DELETED) return void 0; - if (!(n in i)) i = t; - } - return Reflect.getOwnPropertyDescriptor(i, n); -} -let Writing = null; -const storeTraps = { - get(e, t, n) { - if (t === $TARGET) return e; - if (t === $PROXY) return n; - if (t === $TRACK || t === $DEEP) { - trackSelf(e, t); - return n; - } - const i = getNodes(e, STORE_NODE); - const r = i[t]; - const s = e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]; - const o = !!e[STORE_VALUE][$TARGET]; - const u = s ? e[STORE_OVERRIDE] : e[STORE_VALUE]; - if (!r) { - const e = Object.getOwnPropertyDescriptor(u, t); - if (e && e.get) return e.get.call(n); - } - if (Writing?.has(n)) { - let n = r && (s || !o) ? (r.M !== NOT_PENDING ? r.M : r.Y) : u[t]; - n === $DELETED && (n = undefined); - if (!isWrappable(n)) return n; - const i = wrap(n, e); - Writing.add(i); - return i; - } - let l = r ? (s || !o ? read(i[t]) : (read(i[t]), u[t])) : u[t]; - l === $DELETED && (l = undefined); - if (!r) { - if (!s && typeof l === "function" && !u.hasOwnProperty(t)) { - let t; - return !Array.isArray(e[STORE_VALUE]) && - (t = Object.getPrototypeOf(e[STORE_VALUE])) && - t !== Object.prototype - ? l.bind(u) - : l; - } else if (getObserver()) { - return read(getNode(i, t, isWrappable(l) ? wrap(l, e) : l, e[STORE_FIREWALL]?.())); - } - } - return isWrappable(l) ? wrap(l, e) : l; - }, - has(e, t) { - if (t === $PROXY || t === $TRACK || t === "__proto__") return true; - const n = - e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE] - ? e[STORE_OVERRIDE][t] !== $DELETED - : t in e[STORE_VALUE]; - getObserver() && read(getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL]?.())); - return n; - }, - set(e, t, n) { - const i = e[$PROXY]; - if (Writing?.has(e[$PROXY])) { - untrack(() => { - const r = e[STORE_VALUE]; - const s = r[t]; - const o = e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE] ? e[STORE_OVERRIDE][t] : s; - const u = n?.[$TARGET]?.[STORE_VALUE] ?? n; - if (o === u) return true; - const l = e[STORE_OVERRIDE]?.length || r.length; - if (u !== undefined && u === s) delete e[STORE_OVERRIDE][t]; - else (e[STORE_OVERRIDE] || (e[STORE_OVERRIDE] = Object.create(null)))[t] = u; - const c = isWrappable(u); - if (isWrappable(o)) { - const e = PARENTS.get(o); - e && (e instanceof Set ? e.delete(i) : PARENTS.delete(o)); - } - if (recursivelyNotify(i, storeLookup) && c) recursivelyAddParent(u, i); - e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true); - const a = getNodes(e, STORE_NODE); - a[t] && setSignal(a[t], () => (c ? wrap(u, e) : u)); - if (Array.isArray(r)) { - const e = parseInt(t) + 1; - if (e > l) a.length && setSignal(a.length, e); - } - a[$TRACK] && setSignal(a[$TRACK], undefined); - }); - } - return true; - }, - deleteProperty(e, t) { - if (Writing?.has(e[$PROXY]) && e[STORE_OVERRIDE]?.[t] !== $DELETED) { - untrack(() => { - const n = - e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE] ? e[STORE_OVERRIDE][t] : e[STORE_VALUE][t]; - if (t in e[STORE_VALUE]) { - (e[STORE_OVERRIDE] || (e[STORE_OVERRIDE] = Object.create(null)))[t] = $DELETED; - } else if (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]) { - delete e[STORE_OVERRIDE][t]; - } else return true; - if (isWrappable(n)) { - const t = PARENTS.get(n); - t && (t instanceof Set ? t.delete(e) : PARENTS.delete(n)); - } - if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false); - const i = getNodes(e, STORE_NODE); - i[t] && setSignal(i[t], undefined); - i[$TRACK] && setSignal(i[$TRACK], undefined); - }); - } - return true; - }, - ownKeys(e) { - trackSelf(e); - return getKeys(e[STORE_VALUE], e[STORE_OVERRIDE], false); - }, - getOwnPropertyDescriptor(e, t) { - if (t === $PROXY) return { value: e[$PROXY], writable: true, configurable: true }; - return getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t); - }, - getPrototypeOf(e) { - return Object.getPrototypeOf(e[STORE_VALUE]); - } -}; -function storeSetter(e, t) { - const n = Writing; - Writing = new Set(); - Writing.add(e); - try { - const n = t(e); - if (n !== e && n !== undefined) { - if (Array.isArray(n)) { - for (let t = 0, i = n.length; t < i; t++) e[t] = n[t]; - e.length = n.length; - } else { - const t = new Set([...Object.keys(e), ...Object.keys(n)]); - t.forEach(t => { - if (t in n) e[t] = n[t]; - else delete e[t]; - }); - } - } - } finally { - Writing.clear(); - Writing = n; - } -} -function createStore(e, t, n) { - const i = typeof e === "function", - r = i ? createProjectionInternal(e, t, n).store : wrap(e); - return [r, e => storeSetter(r, e)]; -} -function recursivelyNotify(e, t) { - let n = e[$TARGET] || t?.get(e)?.[$TARGET]; - let i = false; - if (n) { - const e = getNodes(n, STORE_NODE)[$DEEP]; - if (e) { - setSignal(e, undefined); - i = true; - } - t = n[STORE_LOOKUP] || t; - } - const r = PARENTS.get(n?.[STORE_VALUE] || e); - if (!r) return i; - if (r instanceof Set) { - for (let e of r) i = recursivelyNotify(e, t) || i; - } else i = recursivelyNotify(r, t) || i; - return i; -} -function recursivelyAddParent(e, t) { - let n; - const i = e[$TARGET]; - if (i) { - n = i[STORE_OVERRIDE]; - e = i[STORE_VALUE]; - } - if (t) { - let n = PARENTS.get(e); - if (!n) PARENTS.set(e, t); - else if (n !== t) { - if (!(n instanceof Set)) PARENTS.set(e, (n = new Set([n]))); - else if (n.has(t)) return; - n.add(t); - } else return; - } - if (Array.isArray(e)) { - const t = n?.length || e.length; - for (let i = 0; i < t; i++) { - const t = n && i in n ? n[i] : e[i]; - isWrappable(t) && recursivelyAddParent(t, e); - } - } else { - const t = getKeys(e, n); - for (let i = 0; i < t.length; i++) { - const r = t[i]; - const s = n && r in n ? n[r] : e[r]; - isWrappable(s) && recursivelyAddParent(s, e); - } - } -} -function deep(e) { - recursivelyAddParent(e); - return e[$DEEP]; -} -function createOptimisticStore(e, t, n) { - return []; -} -function snapshot(e, t, n) { - let i, r, s, o, u, l; - if (!isWrappable(e)) return e; - if (t && t.has(e)) return t.get(e); - if (!t) t = new Map(); - if ((i = e[$TARGET] || n?.get(e)?.[$TARGET])) { - s = i[STORE_OVERRIDE]; - r = Array.isArray(i[STORE_VALUE]); - t.set( - e, - s ? (o = r ? [] : Object.create(Object.getPrototypeOf(i[STORE_VALUE]))) : i[STORE_VALUE] - ); - e = i[STORE_VALUE]; - n = storeLookup; - } else { - r = Array.isArray(e); - t.set(e, e); - } - if (r) { - const i = s?.length || e.length; - for (let r = 0; r < i; r++) { - l = s && r in s ? s[r] : e[r]; - if (l === $DELETED) continue; - if ((u = snapshot(l, t, n)) !== l || o) { - if (!o) t.set(e, (o = [...e])); - o[r] = u; - } - } - } else { - const i = getKeys(e, s); - for (let r = 0, c = i.length; r < c; r++) { - let c = i[r]; - const a = getPropertyDescriptor(e, s, c); - if (a.get) continue; - l = s && c in s ? s[c] : e[c]; - if ((u = snapshot(l, t, n)) !== e[c] || o) { - if (!o) { - o = Object.create(Object.getPrototypeOf(e)); - Object.assign(o, e); - } - o[c] = u; - } - } - } - return o || e; -} -function trueFn() { - return true; -} -const propTraps = { - get(e, t, n) { - if (t === $PROXY) return n; - return e.get(t); - }, - has(e, t) { - if (t === $PROXY) return true; - return e.has(t); - }, - set: trueFn, - deleteProperty: trueFn, - getOwnPropertyDescriptor(e, t) { - return { - configurable: true, - enumerable: true, - get() { - return e.get(t); - }, - set: trueFn, - deleteProperty: trueFn - }; - }, - ownKeys(e) { - return e.keys(); - } -}; -function resolveSource(e) { - return !(e = typeof e === "function" ? e() : e) ? {} : e; -} -const $SOURCES = Symbol(0); -function merge(...e) { - if (e.length === 1 && typeof e[0] !== "function") return e[0]; - let t = false; - const n = []; - for (let i = 0; i < e.length; i++) { - const r = e[i]; - t = t || (!!r && $PROXY in r); - const s = !!r && r[$SOURCES]; - if (s) n.push(...s); - else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r); - } - if (SUPPORTS_PROXY && t) { - return new Proxy( - { - get(e) { - if (e === $SOURCES) return n; - for (let t = n.length - 1; t >= 0; t--) { - const i = resolveSource(n[t]); - if (e in i) return i[e]; - } - }, - has(e) { - for (let t = n.length - 1; t >= 0; t--) { - if (e in resolveSource(n[t])) return true; - } - return false; - }, - keys() { - const e = []; - for (let t = 0; t < n.length; t++) e.push(...Object.keys(resolveSource(n[t]))); - return [...new Set(e)]; - } - }, - propTraps - ); - } - const i = Object.create(null); - let r = false; - let s = n.length - 1; - for (let e = s; e >= 0; e--) { - const t = n[e]; - if (!t) { - e === s && s--; - continue; - } - const o = Object.getOwnPropertyNames(t); - for (let n = o.length - 1; n >= 0; n--) { - const u = o[n]; - if (u === "__proto__" || u === "constructor") continue; - if (!i[u]) { - r = r || e !== s; - const n = Object.getOwnPropertyDescriptor(t, u); - i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n; - } - } - } - if (!r) return n[s]; - const o = {}; - const u = Object.keys(i); - for (let e = u.length - 1; e >= 0; e--) { - const t = u[e], - n = i[t]; - if (n.get) Object.defineProperty(o, t, n); - else o[t] = n.value; - } - o[$SOURCES] = n; - return o; -} -function omit(e, ...t) { - const n = new Set(t); - if (SUPPORTS_PROXY && $PROXY in e) { - return new Proxy( - { - get(t) { - return n.has(t) ? undefined : e[t]; - }, - has(t) { - return !n.has(t) && t in e; - }, - keys() { - return Object.keys(e).filter(e => !n.has(e)); - } - }, - propTraps - ); - } - const i = {}; - for (const t of Object.getOwnPropertyNames(e)) { - if (!n.has(t)) { - const n = Object.getOwnPropertyDescriptor(e, t); - !n.get && !n.set && n.enumerable && n.writable && n.configurable - ? (i[t] = n.value) - : Object.defineProperty(i, t, n); - } - } - return i; -} -function mapArray(e, t, n) { - const i = typeof n?.keyed === "function" ? n.keyed : undefined; - return createMemo( - updateKeyedMap.bind({ - ye: createOwner(), - Ce: 0, - De: e, - Pe: [], - we: t, - be: [], - Ve: [], - me: i, - Ue: i || n?.keyed === false ? [] : undefined, - ke: t.length > 1 ? [] : undefined, - ve: n?.fallback - }) - ); -} -const pureOptions = { pureWrite: true }; -function updateKeyedMap() { - const e = this.De() || [], - t = e.length; - e[$TRACK]; - runWithOwner(this.ye, () => { - let n, - i, - r = this.Ue - ? () => { - this.Ue[i] = signal(e[i], pureOptions); - this.ke && (this.ke[i] = signal(i, pureOptions)); - return this.we( - read.bind(null, this.Ue[i]), - this.ke ? read.bind(null, this.ke[i]) : undefined - ); - } - : this.ke - ? () => { - const t = e[i]; - this.ke[i] = signal(i, pureOptions); - return this.we(() => t, read.bind(null, this.ke[i])); - } - : () => { - const t = e[i]; - return this.we(() => t); - }; - if (t === 0) { - if (this.Ce !== 0) { - this.ye.dispose(false); - this.Ve = []; - this.Pe = []; - this.be = []; - this.Ce = 0; - this.Ue && (this.Ue = []); - this.ke && (this.ke = []); - } - if (this.ve && !this.be[0]) { - this.be[0] = runWithOwner((this.Ve[0] = createOwner()), this.ve); - } - } else if (this.Ce === 0) { - if (this.Ve[0]) this.Ve[0].dispose(); - this.be = new Array(t); - for (i = 0; i < t; i++) { - this.Pe[i] = e[i]; - this.be[i] = runWithOwner((this.Ve[i] = createOwner()), r); - } - this.Ce = t; - } else { - let s, - o, - u, - l, - c, - a, - f, - E = new Array(t), - d = new Array(t), - T = this.Ue ? new Array(t) : undefined, - R = this.ke ? new Array(t) : undefined; - for ( - s = 0, o = Math.min(this.Ce, t); - s < o && (this.Pe[s] === e[s] || (this.Ue && compare(this.me, this.Pe[s], e[s]))); - s++ - ) { - if (this.Ue) setSignal(this.Ue[s], e[s]); - } - for ( - o = this.Ce - 1, u = t - 1; - o >= s && - u >= s && - (this.Pe[o] === e[u] || (this.Ue && compare(this.me, this.Pe[o], e[u]))); - o--, u-- - ) { - E[u] = this.be[o]; - d[u] = this.Ve[o]; - T && (T[u] = this.Ue[o]); - R && (R[u] = this.ke[o]); - } - a = new Map(); - f = new Array(u + 1); - for (i = u; i >= s; i--) { - l = e[i]; - c = this.me ? this.me(l) : l; - n = a.get(c); - f[i] = n === undefined ? -1 : n; - a.set(c, i); - } - for (n = s; n <= o; n++) { - l = this.Pe[n]; - c = this.me ? this.me(l) : l; - i = a.get(c); - if (i !== undefined && i !== -1) { - E[i] = this.be[n]; - d[i] = this.Ve[n]; - T && (T[i] = this.Ue[n]); - R && (R[i] = this.ke[n]); - i = f[i]; - a.set(c, i); - } else this.Ve[n].dispose(); - } - for (i = s; i < t; i++) { - if (i in E) { - this.be[i] = E[i]; - this.Ve[i] = d[i]; - if (T) { - this.Ue[i] = T[i]; - setSignal(this.Ue[i], e[i]); - } - if (R) { - this.ke[i] = R[i]; - setSignal(this.ke[i], i); - } - } else { - this.be[i] = runWithOwner((this.Ve[i] = createOwner()), r); - } - } - this.be = this.be.slice(0, (this.Ce = t)); - this.Pe = e.slice(0); - } - }); - return this.be; -} -function repeat(e, t, n) { - return updateRepeat.bind({ - ye: createOwner(), - Ce: 0, - xe: 0, - Ge: e, - we: t, - Ve: [], - be: [], - He: n?.from, - ve: n?.fallback - }); -} -function updateRepeat() { - const e = this.Ge(); - const t = this.He?.() || 0; - runWithOwner(this.ye, () => { - if (e === 0) { - if (this.Ce !== 0) { - this.ye.dispose(false); - this.Ve = []; - this.be = []; - this.Ce = 0; - } - if (this.ve && !this.be[0]) { - this.be[0] = runWithOwner((this.Ve[0] = createOwner()), this.ve); - } - return; - } - const n = t + e; - const i = this.xe + this.Ce; - if (this.Ce === 0 && this.Ve[0]) this.Ve[0].dispose(); - for (let e = n; e < i; e++) this.Ve[e - this.xe].dispose(); - if (this.xe < t) { - let e = this.xe; - while (e < t && e < this.Ce) this.Ve[e++].dispose(); - this.Ve.splice(0, t - this.xe); - this.be.splice(0, t - this.xe); - } else if (this.xe > t) { - let n = i - this.xe - 1; - let r = this.xe - t; - this.Ve.length = this.be.length = e; - while (n >= r) { - this.Ve[n] = this.Ve[n - r]; - this.be[n] = this.be[n - r]; - n--; - } - for (let e = 0; e < r; e++) { - this.be[e] = runWithOwner((this.Ve[e] = createOwner()), () => this.we(e + t)); - } - } - for (let e = i; e < n; e++) { - this.be[e - t] = runWithOwner((this.Ve[e - t] = createOwner()), () => this.we(e)); - } - this.be = this.be.slice(0, e); - this.xe = t; - this.Ce = e; - }); - return this.be; -} -function compare(e, t, n) { - return e ? e(t) === e(n) : true; -} -function boundaryComputed(e, t) { - const n = computed(e, undefined, { - pe: { - le() { - let e = this.J; - this.J &= ~this.Qe; - if (this.Qe & STATUS_PENDING && !(this.J & STATUS_UNINITIALIZED)) { - e &= ~STATUS_PENDING; - } - this._e.notify(this, this.Qe, e); - }, - Qe: t - } - }); - n.Qe = t; - n.Te = true; - return n; -} -function createBoundChildren(e, t, n, i) { - const r = e._e; - r.addChild((e._e = n)); - onCleanup(() => r.removeChild(e._e)); - return runWithOwner(e, () => { - const e = computed(t); - return boundaryComputed(() => staleValues(() => flatten(read(e))), i); - }); -} -class ConditionalQueue extends Queue { - $e; - Le = new Set(); - $ = new Set(); - constructor(e) { - super(); - this.$e = e; - } - run(e) { - if (!e || read(this.$e)) return; - return super.run(e); - } - notify(e, t, n) { - if (read(this.$e)) { - if (t & STATUS_PENDING) { - if (n & STATUS_PENDING) { - this.$.add(e); - t &= ~STATUS_PENDING; - } else if (this.$.delete(e)) t &= ~STATUS_PENDING; - } - if (t & STATUS_ERROR) { - if (n & STATUS_ERROR) { - this.Le.add(e); - t &= ~STATUS_ERROR; - } else if (this.Le.delete(e)) t &= ~STATUS_ERROR; - } - } - return t ? super.notify(e, t, n) : true; - } -} -class CollectionQueue extends Queue { - Fe; - Ve = new Set(); - $e = signal(false, { pureWrite: true }); - We = false; - constructor(e) { - super(); - this.Fe = e; - } - run(e) { - if (!e || read(this.$e)) return; - return super.run(e); - } - notify(e, t, n) { - if (!(t & this.Fe) || (this.Fe & STATUS_PENDING && this.We)) return super.notify(e, t, n); - if (n & this.Fe) { - this.Ve.add(e); - if (this.Ve.size === 1) setSignal(this.$e, true); - } else if (this.Ve.size > 0) { - this.Ve.delete(e); - if (this.Ve.size === 0) setSignal(this.$e, false); - } - t &= ~this.Fe; - return t ? super.notify(e, t, n) : true; - } -} -var BoundaryMode; -(function (e) { - e["VISIBLE"] = "visible"; - e["HIDDEN"] = "hidden"; -})(BoundaryMode || (BoundaryMode = {})); -function createBoundary(e, t) { - const n = createOwner(); - const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN)); - const r = createBoundChildren(n, e, i, 0); - computed(() => { - const e = read(i.$e); - r.Qe = e ? STATUS_ERROR | STATUS_PENDING : 0; - if (!e) { - i.$.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING)); - i.Le.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR)); - i.$.clear(); - i.Le.clear(); - } - }); - return () => (read(i.$e) ? undefined : read(r)); -} -function createCollectionBoundary(e, t, n) { - const i = createOwner(); - const r = new CollectionQueue(e); - const s = createBoundChildren(i, t, r, e); - const o = computed(() => { - if (!read(r.$e)) { - const e = read(s); - if (!untrack(() => read(r.$e))) r.We = true; - return e; - } - return n(r); - }); - return read.bind(null, o); -} -function createLoadBoundary(e, t) { - return createCollectionBoundary(STATUS_PENDING, e, () => t()); -} -function collectErrorSources(e, t) { - let n = true; - let i = e.D; - while (i !== null) { - const e = i.V; - if (e.D && e.J & STATUS_ERROR) { - n = false; - collectErrorSources(e, t); - } - i = i.P; - } - n && t.push(e); -} -function createErrorBoundary(e, t) { - return createCollectionBoundary(STATUS_ERROR, e, e => { - let n = e.Ve.values().next().value; - return t(n.j, () => { - const t = []; - for (const n of e.Ve) collectErrorSources(n, t); - for (const e of t) recompute(e); - schedule(); - }); - }); -} -function flatten(e, t) { - if (typeof e === "function" && !e.length) { - if (t?.doNotUnwrap) return e; - do { - e = e(); - } while (typeof e === "function" && !e.length); - } - if (t?.skipNonRendered && (e == null || e === true || e === false || e === "")) return; - if (Array.isArray(e)) { - let n = []; - if (flattenArray(e, n, t)) { - return () => { - let e = []; - flattenArray(n, e, { ...t, doNotUnwrap: false }); - return e; - }; - } - return n; - } - return e; -} -function flattenArray(e, t = [], n) { - let i = null; - let r = false; - for (let s = 0; s < e.length; s++) { - try { - let i = e[s]; - if (typeof i === "function" && !i.length) { - if (n?.doNotUnwrap) { - t.push(i); - r = true; - continue; - } - do { - i = i(); - } while (typeof i === "function" && !i.length); - } - if (Array.isArray(i)) { - r = flattenArray(i, t, n); - } else if (n?.skipNonRendered && (i == null || i === true || i === false || i === "")) { - } else t.push(i); - } catch (e) { - if (!(e instanceof NotReadyError)) throw e; - i = e; - } - } - if (i) throw i; - return r; -} -export { - $PROXY, - $TARGET, - $TRACK, - ContextNotFoundError, - NoOwnerError, - NotReadyError, - SUPPORTS_PROXY, - createBoundary, - createContext, - createEffect, - createErrorBoundary, - createLoadBoundary, - createMemo, - createOptimistic, - createOptimisticStore, - createProjection, - createReaction, - createRenderEffect, - createRoot, - createSignal, - createStore, - createTrackedEffect, - deep, - flatten, - flush, - getContext, - getNextChildId, - getObserver, - getOwner, - isEqual, - isPending, - isRefreshing, - isWrappable, - mapArray, - merge, - omit, - onCleanup, - onSettled, - pending, - reconcile, - refresh, - repeat, - resolve, - runWithOwner, - setContext, - snapshot, - untrack -}; diff --git a/modules/solidjs-signals/0.9.2/dist/types/boundaries.d.ts b/modules/solidjs-signals/0.9.2/dist/types/boundaries.d.ts deleted file mode 100644 index a9a3e763a..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/boundaries.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Queue, type Computed, type Effect } from "./core/index.js"; -import type { Signal } from "./core/index.js"; -export interface BoundaryComputed extends Computed { - _propagationMask: number; -} -export declare class CollectionQueue extends Queue { - _collectionType: number; - _nodes: Set>; - _disabled: Signal; - _initialized: boolean; - constructor(type: number); - run(type: number): void; - notify(node: Effect, type: number, flags: number): boolean; -} -export declare const enum BoundaryMode { - VISIBLE = "visible", - HIDDEN = "hidden" -} -export declare function createBoundary(fn: () => T, condition: () => BoundaryMode): () => T | undefined; -export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown; -export declare function createErrorBoundary(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown; -export declare function flatten(children: any, options?: { - skipNonRendered?: boolean; - doNotUnwrap?: boolean; -}): any; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/constants.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/constants.d.ts deleted file mode 100644 index 6212cb9d1..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/constants.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export declare const REACTIVE_NONE = 0; -export declare const REACTIVE_CHECK: number; -export declare const REACTIVE_DIRTY: number; -export declare const REACTIVE_RECOMPUTING_DEPS: number; -export declare const REACTIVE_IN_HEAP: number; -export declare const REACTIVE_IN_HEAP_HEIGHT: number; -export declare const REACTIVE_ZOMBIE: number; -export declare const REACTIVE_DISPOSED: number; -export declare const STATUS_NONE = 0; -export declare const STATUS_PENDING: number; -export declare const STATUS_ERROR: number; -export declare const STATUS_UNINITIALIZED: number; -export declare const EFFECT_PURE = 0; -export declare const EFFECT_RENDER = 1; -export declare const EFFECT_USER = 2; -export declare const NOT_PENDING: {}; -export declare const SUPPORTS_PROXY: boolean; -export declare const defaultContext: {}; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/context.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/context.d.ts deleted file mode 100644 index 879aae3c5..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/context.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { type Owner } from "./core.js"; -export interface Context { - readonly id: symbol; - readonly defaultValue: T | undefined; -} -export type ContextRecord = Record; -/** - * Context provides a form of dependency injection. It is used to save from needing to pass - * data as props through intermediate components. This function creates a new context object - * that can be used with `getContext` and `setContext`. - * - * A default value can be provided here which will be used when a specific value is not provided - * via a `setContext` call. - */ -export declare function createContext(defaultValue?: T, description?: string): Context; -/** - * Attempts to get a context value for the given key. - * - * @throws `NoOwnerError` if there's no owner at the time of call. - * @throws `ContextNotFoundError` if a context value has not been set yet. - */ -export declare function getContext(context: Context, owner?: Owner | null): T; -/** - * Attempts to set a context value on the parent scope with the given key. - * - * @throws `NoOwnerError` if there's no owner at the time of call. - */ -export declare function setContext(context: Context, value?: T, owner?: Owner | null): void; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/core.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/core.d.ts deleted file mode 100644 index 39013d971..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/core.d.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { NOT_PENDING } from "./constants.js"; -import { type IQueue, type Transition } from "./scheduler.js"; -export interface Disposable { - (): void; -} -export interface Link { - _dep: Signal | Computed; - _sub: Computed; - _nextDep: Link | null; - _prevSub: Link | null; - _nextSub: Link | null; -} -export interface SignalOptions { - id?: string; - name?: string; - equals?: ((prev: T, next: T) => boolean) | false; - pureWrite?: boolean; - unobserved?: () => void; - lazy?: boolean; -} -export interface RawSignal { - id?: string; - _subs: Link | null; - _subsTail: Link | null; - _value: T; - _error?: unknown; - _statusFlags: number; - _name?: string; - _equals: false | ((a: T, b: T) => boolean); - _pureWrite?: boolean; - _unobserved?: () => void; - _time: number; - _transition: Transition | null; - _pendingValue: T | typeof NOT_PENDING; - _pendingCheck?: Signal & { - _set: (v: boolean) => void; - }; - _pendingSignal?: Signal & { - _set: (v: T) => void; - }; - _optimistic?: boolean; -} -export interface FirewallSignal extends RawSignal { - _firewall: Computed; - _nextChild: FirewallSignal | null; -} -export type Signal = RawSignal | FirewallSignal; -export interface Owner { - id?: string; - _disposal: Disposable | Disposable[] | null; - _parent: Owner | null; - _context: Record; - _childCount: number; - _queue: IQueue; - _firstChild: Owner | null; - _nextSibling: Owner | null; - _pendingDisposal: Disposable | Disposable[] | null; - _pendingFirstChild: Owner | null; -} -export interface Computed extends RawSignal, Owner { - _deps: Link | null; - _depsTail: Link | null; - _flags: number; - _height: number; - _nextHeap: Computed | undefined; - _prevHeap: Computed; - _fn: (prev?: T) => T; - _inFlight: Promise | AsyncIterable | null; - _child: FirewallSignal | null; - _notifyQueue?: (statusFlagsChanged: boolean, prevStatusFlags: number) => void; -} -export interface Root extends Owner { - _root: true; - _parentComputed: Computed | null; - dispose(self?: boolean): void; -} -export declare let context: Owner | null; -export declare function recompute(el: Computed, create?: boolean): void; -export declare function handleAsync(el: Computed, result: T | Promise | AsyncIterable, setter?: (value: T) => void): T; -export declare function dispose(node: Computed): void; -export declare function getNextChildId(owner: Owner): string; -export declare function computed(fn: (prev?: T) => T | Promise | AsyncIterable): Computed; -export declare function computed(fn: (prev: T) => T | Promise | AsyncIterable, initialValue?: T, options?: SignalOptions): Computed; -export declare function signal(v: T, options?: SignalOptions): Signal; -export declare function signal(v: T, options?: SignalOptions, firewall?: Computed): FirewallSignal; -export declare function isEqual(a: T, b: T): boolean; -/** - * Returns the current value stored inside the given compute function without triggering any - * dependencies. Use `untrack` if you want to also disable owner tracking. - */ -export declare function untrack(fn: () => T): T; -export declare function read(el: Signal | Computed): T; -export declare function setSignal(el: Signal | Computed, v: T | ((prev: T) => T)): T; -export declare function getObserver(): Owner | null; -export declare function getOwner(): Owner | null; -export declare function onCleanup(fn: Disposable): Disposable; -export declare function createOwner(options?: { - id: string; -}): Root; -/** - * Creates a new non-tracked reactive context with manual disposal - * - * @param fn a function in which the reactive state is scoped - * @returns the output of `fn`. - * - * @description https://docs.solidjs.com/reference/reactive-utilities/create-root - */ -export declare function createRoot(init: ((dispose: () => void) => T) | (() => T), options?: { - id: string; -}): T; -/** - * Runs the given function in the given owner to move ownership of nested primitives and cleanups. - * This method untracks the current scope. - * - * Warning: Usually there are simpler ways of modeling a problem that avoid using this function - */ -export declare function runWithOwner(owner: Owner | null, fn: () => T): T; -export declare function staleValues(fn: () => T, set?: boolean): T; -export declare function pending(fn: () => T): T; -export declare function isPending(fn: () => any): boolean; -export declare function refresh(fn: () => T): T; -export declare function isRefreshing(): boolean; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/effect.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/effect.d.ts deleted file mode 100644 index bddf01c27..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/effect.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { type Computed, type Owner, type SignalOptions } from "./core.js"; -export interface Effect extends Computed, Owner { - _effectFn: (val: T, prev: T | undefined) => void | (() => void); - _errorFn?: (err: unknown, cleanup: () => void) => void; - _cleanup?: () => void; - _modified: boolean; - _prevValue: T | undefined; - _type: number; -} -/** - * Effects are the leaf nodes of our reactive graph. When their sources change, they are - * automatically added to the queue of effects to re-execute, which will cause them to fetch their - * sources and recompute - */ -export declare function effect(compute: (prev: T | undefined) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown, cleanup: () => void) => void | (() => void), initialValue?: T, options?: SignalOptions & { - render?: boolean; - defer?: boolean; -}): void; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/error.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/error.d.ts deleted file mode 100644 index 1aaaf1263..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/error.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export declare class NotReadyError extends Error { - cause: any; - constructor(cause: any); -} -export declare class NoOwnerError extends Error { - constructor(); -} -export declare class ContextNotFoundError extends Error { - constructor(); -} diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/heap.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/heap.d.ts deleted file mode 100644 index 4ab61af3b..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/heap.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { Computed } from "./core.js"; -export interface Heap { - _heap: (Computed | undefined)[]; - _marked: boolean; - _min: number; - _max: number; -} -export declare function increaseHeapSize(n: number, heap: Heap): void; -export declare function insertIntoHeap(n: Computed, heap: Heap): void; -export declare function insertIntoHeapHeight(n: Computed, heap: Heap): void; -export declare function deleteFromHeap(n: Computed, heap: Heap): void; -export declare function markHeap(heap: Heap): void; -export declare function markNode(el: Computed, newState?: number): void; -export declare function runHeap(heap: Heap, recompute: (el: Computed) => void): void; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/index.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/index.d.ts deleted file mode 100644 index 280023719..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js"; -export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js"; -export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, dispose, signal, read, setSignal, onCleanup, getNextChildId, isPending, pending, refresh, isRefreshing, staleValues, handleAsync, type Owner, type Computed, type Root, type Signal, type SignalOptions } from "./core.js"; -export { effect, type Effect } from "./effect.js"; -export { flush, Queue, type IQueue, type QueueCallback } from "./scheduler.js"; -export * from "./constants.js"; diff --git a/modules/solidjs-signals/0.9.2/dist/types/core/scheduler.d.ts b/modules/solidjs-signals/0.9.2/dist/types/core/scheduler.d.ts deleted file mode 100644 index 427a051f8..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/core/scheduler.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -import type { Computed, Signal } from "./core.js"; -import { type Heap } from "./heap.js"; -export declare let optimisticRun: boolean; -export declare const dirtyQueue: Heap; -export declare const zombieQueue: Heap; -export declare let clock: number; -export declare let activeTransition: Transition | null; -export type QueueCallback = (type: number) => void; -type QueueStub = { - _queues: [QueueCallback[], QueueCallback[]]; - _children: QueueStub[]; -}; -export interface Transition { - time: number; - asyncNodes: Computed[]; - pendingNodes: Signal[]; - optimisticNodes: Signal[]; - queueStash: QueueStub; - done: boolean; -} -export declare function schedule(): void; -export interface IQueue { - enqueue(type: number, fn: QueueCallback): void; - run(type: number): boolean | void; - addChild(child: IQueue): void; - removeChild(child: IQueue): void; - created: number; - notify(node: Computed, mask: number, flags: number): boolean; - stashQueues(stub: QueueStub): void; - restoreQueues(stub: QueueStub): void; - _parent: IQueue | null; -} -export declare class Queue implements IQueue { - _parent: IQueue | null; - _queues: [QueueCallback[], QueueCallback[]]; - _children: IQueue[]; - created: number; - addChild(child: IQueue): void; - removeChild(child: IQueue): void; - notify(node: Computed, mask: number, flags: number): boolean; - run(type: number): void; - enqueue(type: number, fn: QueueCallback): void; - stashQueues(stub: QueueStub): void; - restoreQueues(stub: QueueStub): void; -} -export declare class GlobalQueue extends Queue { - _running: boolean; - _pendingNodes: Signal[]; - _optimisticNodes: Signal[]; - static _update: (el: Computed) => void; - static _dispose: (el: Computed, self: boolean, zombie: boolean) => void; - flush(): void; - notify(node: Computed, mask: number, flags: number): boolean; - initTransition(node: Computed): void; -} -export declare function notifySubs(node: Signal | Computed): void; -export declare function runOptimistic(activeTransition?: Transition | null): void; -export declare const globalQueue: GlobalQueue; -/** - * By default, changes are batched on the microtask queue which is an async process. You can flush - * the queue synchronously to get the latest updates by calling `flush()`. - */ -export declare function flush(): void; -export declare function runInTransition(el: Computed, recompute: (el: Computed) => void): void; -export {}; diff --git a/modules/solidjs-signals/0.9.2/dist/types/index.d.ts b/modules/solidjs-signals/0.9.2/dist/types/index.d.ts deleted file mode 100644 index 0add900cf..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { ContextNotFoundError, NoOwnerError, NotReadyError, createContext, createRoot, runWithOwner, flush, getNextChildId, getContext, setContext, getOwner, onCleanup, getObserver, isEqual, untrack, isPending, pending, isRefreshing, refresh, SUPPORTS_PROXY } from "./core/index.js"; -export type { Owner, SignalOptions, Context, ContextRecord, IQueue } from "./core/index.js"; -export * from "./signals.js"; -export { mapArray, repeat, type Maybe } from "./map.js"; -export * from "./store/index.js"; -export { createLoadBoundary, createErrorBoundary, createBoundary, flatten, type BoundaryMode } from "./boundaries.js"; diff --git a/modules/solidjs-signals/0.9.2/dist/types/map.d.ts b/modules/solidjs-signals/0.9.2/dist/types/map.d.ts deleted file mode 100644 index 07751ce20..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/map.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { type Accessor } from "./signals.js"; -export type Maybe = T | void | null | undefined | false; -/** - * Reactively transforms an array with a callback function - underlying helper for the `` control flow - * - * similar to `Array.prototype.map`, but gets the value and index as accessors, transforms only values that changed and returns an accessor and reactively tracks changes to the list. - * - * @description https://docs.solidjs.com/reference/reactive-utilities/map-array - */ -export declare function mapArray(list: Accessor>, map: (value: Accessor, index: Accessor) => MappedItem, options?: { - keyed?: boolean | ((item: Item) => any); - fallback?: Accessor; -}): Accessor; -/** - * Reactively repeats a callback function the count provided - underlying helper for the `` control flow - * - * @description https://docs.solidjs.com/reference/reactive-utilities/repeat - */ -export declare function repeat(count: Accessor, map: (index: number) => any, options?: { - from?: Accessor; - fallback?: Accessor; -}): Accessor; diff --git a/modules/solidjs-signals/0.9.2/dist/types/signals.d.ts b/modules/solidjs-signals/0.9.2/dist/types/signals.d.ts deleted file mode 100644 index a5098002a..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/signals.d.ts +++ /dev/null @@ -1,143 +0,0 @@ -import type { SignalOptions } from "./core/index.js"; -export type Accessor = () => T; -export type Setter = { - (...args: undefined extends T ? [] : [value: Exclude | ((prev: T) => U)]): undefined extends T ? undefined : U; - (value: (prev: T) => U): U; - (value: Exclude): U; - (value: Exclude | ((prev: T) => U)): U; -}; -export type Signal = [get: Accessor, set: Setter]; -export type ComputeFunction = (v: Prev) => Promise | AsyncIterable | Next; -export type EffectFunction = (v: Next, p?: Prev) => (() => void) | void; -export type EffectBundle = { - effect: EffectFunction; - error: (err: unknown, cleanup: () => void) => void; -}; -export interface EffectOptions { - name?: string; - defer?: boolean; -} -export interface MemoOptions { - name?: string; - equals?: false | ((prev: T, next: T) => boolean); -} -export type NoInfer = [T][T extends any ? 0 : never]; -/** - * Creates a simple reactive state with a getter and setter - * ```typescript - * const [state: Accessor, setState: Setter] = createSignal( - * value: T, - * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) } - * ) - * ``` - * @param value initial value of the state; if empty, the state's type will automatically extended with undefined; otherwise you need to extend the type manually if you want setting to undefined not be an error - * @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity - * - * @returns ```typescript - * [state: Accessor, setState: Setter] - * ``` - * * the Accessor is a function that returns the current value and registers each call to the reactive root - * * the Setter is a function that allows directly setting or mutating the value: - * ```typescript - * const [count, setCount] = createSignal(0); - * setCount(count => count + 1); - * ``` - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-signal - */ -export declare function createSignal(): Signal; -export declare function createSignal(value: Exclude, options?: SignalOptions): Signal; -export declare function createSignal(fn: ComputeFunction, initialValue?: T, options?: SignalOptions): Signal; -/** - * Creates a readonly derived reactive memoized signal - * ```typescript - * export function createMemo( - * compute: (v: T) => T, - * value?: T, - * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) } - * ): () => T; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo - */ -export declare function createMemo(compute: ComputeFunction, Next>): Accessor; -export declare function createMemo(compute: ComputeFunction, value: Init, options?: MemoOptions): Accessor; -/** - * Creates a reactive effect that runs after the render phase - * ```typescript - * export function createEffect( - * compute: (prev: T) => T, - * effect: (v: T, prev: T) => (() => void) | void, - * value?: T, - * options?: { name?: string } - * ): void; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param effect a function that receives the new value and is used to perform side effects, return a cleanup function to run on disposal - * @param error an optional function that receives an error if thrown during the computation - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes - * - * @description https://docs.solidjs.com/reference/basic-reactivity/create-effect - */ -export declare function createEffect(compute: ComputeFunction, Next>, effectFn: EffectFunction, Next> | EffectBundle, Next>): void; -export declare function createEffect(compute: ComputeFunction, effect: EffectFunction | EffectBundle, value: Init, options?: EffectOptions): void; -/** - * Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected - * ```typescript - * export function createRenderEffect( - * compute: (prev: T) => T, - * effect: (v: T, prev: T) => (() => void) | void, - * value?: T, - * options?: { name?: string } - * ): void; - * ``` - * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation - * @param effect a function that receives the new value and is used to perform side effects - * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument - * @param options allows to set a name in dev mode for debugging purposes - * - * @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect - */ -export declare function createRenderEffect(compute: ComputeFunction, Next>, effectFn: EffectFunction, Next>): void; -export declare function createRenderEffect(compute: ComputeFunction, effectFn: EffectFunction, value: Init, options?: EffectOptions): void; -/** - * Creates a tracked reactive effect that only tracks dependencies inside the effect itself - * ```typescript - * export function createTrackedEffect( - * compute: () => (() => void) | void, - * options?: { name?: string, defer?: boolean } - * ): void; - * ``` - * @param compute a function that contains reactive reads to track and returns an optional cleanup function to run on disposal or before next execution - * @param options allows to set a name in dev mode for debugging purposes - * - * @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect - */ -export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void; -/** - * Creates a reactive computation that runs after the render phase with flexible tracking - * ```typescript - * export function createReaction( - * onInvalidate: () => void, - * options?: { name?: string } - * ): (fn: () => void) => void; - * ``` - * @param invalidated a function that is called when tracked function is invalidated. - * @param options allows to set a name in dev mode for debugging purposes - * - * @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction - */ -export declare function createReaction(effectFn: EffectFunction | EffectBundle, options?: EffectOptions): (tracking: () => void) => void; -/** - * Returns a promise of the resolved value of a reactive expression - * @param fn a reactive expression to resolve - */ -export declare function resolve(fn: () => T): Promise; -export declare function createOptimistic(): Signal; -export declare function createOptimistic(value: Exclude, options?: SignalOptions): Signal; -export declare function createOptimistic(fn: ComputeFunction, initialValue?: T, options?: SignalOptions): Signal; -export declare function onSettled(callback: () => void | (() => void)): void; diff --git a/modules/solidjs-signals/0.9.2/dist/types/store/index.d.ts b/modules/solidjs-signals/0.9.2/dist/types/store/index.d.ts deleted file mode 100644 index c0f1eb41e..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/store/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type { Store, StoreSetter, StoreNode, NotWrappable, SolidStore } from "./store.js"; -export type { Merge, Omit } from "./utils.js"; -export { isWrappable, createStore, deep, $TRACK, $PROXY, $TARGET } from "./store.js"; -export { createProjection } from "./projection.js"; -export { createOptimisticStore } from "./optimistic.js"; -export { reconcile } from "./reconcile.js"; -export { snapshot, merge, omit } from "./utils.js"; diff --git a/modules/solidjs-signals/0.9.2/dist/types/store/optimistic.d.ts b/modules/solidjs-signals/0.9.2/dist/types/store/optimistic.d.ts deleted file mode 100644 index 9c1c15df6..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/store/optimistic.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { type Store, type StoreSetter } from "./store.js"; -/** - * Creates an optimistic store that can be used to optimistically update a value - * and then revert it back to the previous value at end of transition. - * ```typescript - * export function createOptimistic( - * fn: (store: T) => void, - * initial: T, - * options?: { key?: string | ((item: NonNullable) => any); all?: boolean } - * ): [get: Store, set: StoreSetter]; - * ``` - * @param fn a function that receives the current store and can be used to mutate it directly inside a transition - * @param initial The initial value of the signal. - * @param options Optional signal options. - * - * @returns A tuple containing an accessor for the current value and a setter function to apply changes. - */ -export declare function createOptimisticStore(initial: T | Store): [get: Store, set: StoreSetter]; -export declare function createOptimisticStore(fn: (store: T) => T | void, initial: T | Store, options?: { - key?: string | ((item: NonNullable) => any); - all?: boolean; -}): [get: Store, set: StoreSetter]; diff --git a/modules/solidjs-signals/0.9.2/dist/types/store/projection.d.ts b/modules/solidjs-signals/0.9.2/dist/types/store/projection.d.ts deleted file mode 100644 index 127f48571..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/store/projection.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { type Store, type StoreOptions } from "./store.js"; -export declare function createProjectionInternal(fn: (draft: T) => void | T | Promise | AsyncIterable, initialValue?: T, options?: StoreOptions): { - store: Readonly; - node: any; -}; -/** - * Creates a mutable derived value - * - * @see {@link https://github.com/solidjs/x-reactivity#createprojection} - */ -export declare function createProjection(fn: (draft: T) => void | T | Promise | AsyncIterable, initialValue?: T, options?: StoreOptions): Store; diff --git a/modules/solidjs-signals/0.9.2/dist/types/store/reconcile.d.ts b/modules/solidjs-signals/0.9.2/dist/types/store/reconcile.d.ts deleted file mode 100644 index 01effdba8..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/store/reconcile.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function reconcile(value: T, key: string | ((item: NonNullable) => any), all?: boolean): (state: U) => void; diff --git a/modules/solidjs-signals/0.9.2/dist/types/store/store.d.ts b/modules/solidjs-signals/0.9.2/dist/types/store/store.d.ts deleted file mode 100644 index b1e23d62a..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/store/store.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { type Computed, type Signal } from "../core/index.js"; -export type Store = Readonly; -export type StoreSetter = (fn: (state: T) => T | void) => void; -export type StoreOptions = { - key?: string | ((item: NonNullable) => any); - all?: boolean; -}; -type DataNode = Signal; -type DataNodes = Record; -export declare const $TRACK: unique symbol, $DEEP: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol; -export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f"; -export type StoreNode = { - [$PROXY]: any; - [STORE_VALUE]: Record; - [STORE_OVERRIDE]?: Record; - [STORE_NODE]?: DataNodes; - [STORE_HAS]?: DataNodes; - [STORE_WRAP]?: (value: any, target?: StoreNode) => any; - [STORE_LOOKUP]?: WeakMap; - [STORE_FIREWALL]?: () => Computed; -}; -export declare namespace SolidStore { - interface Unwrappable { - } -} -export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable]; -export declare function createStoreProxy(value: T, traps?: ProxyHandler, extend?: Record): any; -export declare const storeLookup: WeakMap; -export declare function wrap>(value: T, target?: StoreNode): T; -export declare function isWrappable(obj: T | NotWrappable): obj is T; -export declare function getKeys(source: Record, override: Record | undefined, enumerable?: boolean): PropertyKey[]; -export declare function getPropertyDescriptor(source: Record, override: Record | undefined, property: PropertyKey): PropertyDescriptor | undefined; -export declare const storeTraps: ProxyHandler; -export declare function storeSetter(store: Store, fn: (draft: T) => T | void): void; -export declare function createStore(store: T | Store): [get: Store, set: StoreSetter]; -export declare function createStore(fn: (store: T) => void | T | Promise | AsyncIterable, store: T | Store, options?: StoreOptions): [get: Store, set: StoreSetter]; -export declare function deep(store: Store): Store; -export {}; diff --git a/modules/solidjs-signals/0.9.2/dist/types/store/utils.d.ts b/modules/solidjs-signals/0.9.2/dist/types/store/utils.d.ts deleted file mode 100644 index 42e497e15..000000000 --- a/modules/solidjs-signals/0.9.2/dist/types/store/utils.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Returns a non reactive copy of the store object. - * It will attempt to preserver the original reference unless the value has been modified. - * @param item store proxy object - */ -export declare function snapshot(item: T): T; -export declare function snapshot(item: T, map?: Map, lookup?: WeakMap): T; -type DistributeOverride = T extends undefined ? F : T; -type Override = T extends any ? U extends any ? { - [K in keyof T]: K extends keyof U ? DistributeOverride : T[K]; -} & { - [K in keyof U]: K extends keyof T ? DistributeOverride : U[K]; -} : T & U : T & U; -type OverrideSpread = T extends any ? { - [K in keyof ({ - [K in keyof T]: any; - } & { - [K in keyof U]?: any; - } & { - [K in U extends any ? keyof U : keyof U]?: any; - })]: K extends keyof T ? Exclude | T[K] : U extends any ? U[K & keyof U] : never; -} : T & U; -type Simplify = T extends any ? { - [K in keyof T]: T[K]; -} : T; -type _Merge = T extends [ - infer Next | (() => infer Next), - ...infer Rest -] ? _Merge> : T extends [...infer Rest, infer Next | (() => infer Next)] ? Override<_Merge, Next> : T extends [] ? Curr : T extends (infer I | (() => infer I))[] ? OverrideSpread : Curr; -export type Merge = Simplify<_Merge>; -export declare function merge(...sources: T): Merge; -export type Omit = { - [P in keyof T as Exclude]: T[P]; -}; -export declare function omit, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit; -export {}; diff --git a/modules/unpkg.sh b/modules/unpkg.sh index 85d17dd6a..081fced87 100755 --- a/modules/unpkg.sh +++ b/modules/unpkg.sh @@ -405,7 +405,6 @@ main() { # Run the main function with all arguments # main "$@" -main "@solidjs/signals" main "@leeoniya/ufuzzy" main "lean-qr" main "lightweight-charts" diff --git a/website/scripts/entry.js b/website/scripts/entry.js index e337cb194..8420ae894 100644 --- a/website/scripts/entry.js +++ b/website/scripts/entry.js @@ -3,12 +3,10 @@ * * @import { IChartApi, ISeriesApi as _ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData, BaselineData as _BaselineData, HistogramData as _HistogramData, SeriesType as LCSeriesType, IPaneApi, LineSeriesPartialOptions as _LineSeriesPartialOptions, HistogramSeriesPartialOptions as _HistogramSeriesPartialOptions, BaselineSeriesPartialOptions as _BaselineSeriesPartialOptions, CandlestickSeriesPartialOptions as _CandlestickSeriesPartialOptions, WhitespaceData, DeepPartial, ChartOptions, Time, LineData as _LineData, createChart as CreateLCChart, LineStyle, createSeriesMarkers as CreateSeriesMarkers, SeriesMarker, ISeriesMarkersPluginApi } from './modules/lightweight-charts/5.1.0/dist/typings.js' * - * @import { Signal, Signals, Accessor } from "./signals.js"; - * * @import * as Brk from "./modules/brk-client/index.js" * @import { BrkClient, Index, Metric, MetricData } from "./modules/brk-client/index.js" * - * @import { Resources, MetricResource } from './resources.js' + * @import { Options } from './options/full.js' * * @import { PersistedValue } from './utils/persisted.js' * diff --git a/website/scripts/main.js b/website/scripts/main.js index e5a0dbd60..6955acd90 100644 --- a/website/scripts/main.js +++ b/website/scripts/main.js @@ -1,11 +1,13 @@ import { webSockets } from "./utils/ws.js"; import * as formatters from "./utils/format.js"; import { onFirstIntersection, getElementById, isHidden } from "./utils/dom.js"; -import signals from "./signals.js"; import { BrkClient } from "./modules/brk-client/index.js"; import { initOptions } from "./options/full.js"; -import ufuzzy from "./modules/leeoniya-ufuzzy/1.0.19/dist/uFuzzy.mjs"; -import { init as initChart } from "./panes/chart.js"; +import { + init as initChart, + setOption as setChartOption, +} from "./panes/chart.js"; +import { initSearch } from "./panes/search.js"; import { next } from "./utils/timing.js"; import { replaceHistory } from "./utils/url.js"; import { removeStored, writeToStorage } from "./utils/storage.js"; @@ -19,8 +21,6 @@ import { navElement, navLabelElement, searchElement, - searchInput, - searchResultsElement, style, } from "./utils/elements.js"; @@ -106,427 +106,223 @@ function initFrameSelectors() { } initFrameSelectors(); -signals.createRoot(() => { - const brk = new BrkClient("https://next.bitview.space"); - // const brk = new BrkClient("/"); - const owner = signals.getOwner(); +const brk = new BrkClient("https://next.bitview.space"); +// const brk = new BrkClient("/"); - console.log(`VERSION = ${brk.VERSION}`); +console.log(`VERSION = ${brk.VERSION}`); - webSockets.kraken1dCandle.onLatest((latest) => { - console.log("close:", latest.close); - window.document.title = `${latest.close.toLocaleString("en-us")} | ${window.location.host}`; - }); +webSockets.kraken1dCandle.onLatest((latest) => { + console.log("close:", latest.close); + window.document.title = `${latest.close.toLocaleString("en-us")} | ${window.location.host}`; +}); - // function createLastHeightResource() { - // const lastHeight = signals.createSignal(0); - // function fetchLastHeight() { - // utils.api.fetchLast( - // (h) => { - // lastHeight.set(h); - // }, - // /** @satisfies {Height} */ (5), - // "height", - // ); - // } - // fetchLastHeight(); - // setInterval(fetchLastHeight, 10_000); - // return lastHeight; - // } - // const lastHeight = createLastHeightResource(); +const options = initOptions(brk); - const options = initOptions({ - signals, - brk, - }); +window.addEventListener("popstate", (_event) => { + const path = window.document.location.pathname.split("/").filter((v) => v); + let folder = options.tree; - window.addEventListener("popstate", (_event) => { - const path = window.document.location.pathname.split("/").filter((v) => v); - let folder = options.tree; - - while (path.length) { - const id = path.shift(); - const res = folder.find((v) => id === formatters.stringToId(v.name)); - if (!res) throw "Option not found"; - if (path.length >= 1) { - if (!("tree" in res)) { - throw "Unreachable"; - } - folder = res.tree; - } else { - if ("tree" in res) { - throw "Unreachable"; - } - options.selected.set(res); + while (path.length) { + const id = path.shift(); + const res = folder.find((v) => id === formatters.stringToId(v.name)); + if (!res) throw "Option not found"; + if (path.length >= 1) { + if (!("tree" in res)) { + throw "Unreachable"; } + folder = res.tree; + } else { + if ("tree" in res) { + throw "Unreachable"; + } + options.selected.set(res); } - }); - - function initSelected() { - let firstRun = true; - function initSelectedFrame() { - if (!firstRun) throw Error("Unreachable"); - firstRun = false; - - const owner = signals.getOwner(); - - const chartOption = signals.createSignal( - /** @type {ChartOption | null} */ (null), - ); - - let previousElement = /** @type {HTMLElement | undefined} */ (undefined); - let firstTimeLoadingChart = true; - - signals.createScopedEffect(options.selected, (option) => { - /** @type {HTMLElement | undefined} */ - let element; - - switch (option.kind) { - case "chart": { - element = chartElement; - - chartOption.set(option); - - if (firstTimeLoadingChart) { - signals.runWithOwner(owner, () => - initChart({ - option: /** @type {Accessor} */ (chartOption), - brk, - }), - ); - } - firstTimeLoadingChart = false; - - break; - } - case "link": { - return; - } - } - - if (!element) throw "Element should be set"; - - if (element !== previousElement) { - if (previousElement) previousElement.hidden = true; - element.hidden = false; - } - - if (!previousElement) { - replaceHistory({ pathname: option.path }); - } - - previousElement = element; - }); - } - - function createMobileSwitchEffect() { - let firstRun = true; - signals.createEffect(options.selected, () => { - if (!firstRun && !isHidden(asideLabelElement)) { - asideLabelElement.click(); - } - firstRun = false; - }); - } - createMobileSwitchEffect(); - - onFirstIntersection(asideElement, () => - signals.runWithOwner(owner, initSelectedFrame), - ); } - initSelected(); +}); - onFirstIntersection(navElement, async () => { - options.parent.set(navElement); +function initSelected() { + let firstRun = true; + function initSelectedFrame() { + if (!firstRun) throw Error("Unreachable"); + firstRun = false; - const option = options.selected(); - if (!option) throw "Selected should be set by now"; - const path = [...option.path]; + let previousElement = /** @type {HTMLElement | undefined} */ (undefined); + let firstTimeLoadingChart = true; - /** @type {HTMLUListElement | null} */ - let ul = /** @type {any} */ (null); - async function getFirstChild() { - try { - ul = /** @type {HTMLUListElement} */ (navElement.firstElementChild); - await next(); - if (!ul) { - await getFirstChild(); + options.selected.onChange((option) => { + /** @type {HTMLElement | undefined} */ + let element; + + switch (option.kind) { + case "chart": { + element = chartElement; + + if (firstTimeLoadingChart) { + initChart(brk); + } + firstTimeLoadingChart = false; + + setChartOption(option); + + break; } - } catch (_) { - await next(); - await getFirstChild(); - } - } - await getFirstChild(); - if (!ul) throw Error("Unreachable"); - - while (path.length > 1) { - const name = path.shift(); - if (!name) throw "Unreachable"; - /** @type {HTMLDetailsElement[]} */ - let detailsList = []; - while (!detailsList.length) { - detailsList = Array.from(ul.querySelectorAll(":scope > li > details")); - if (!detailsList.length) { - await next(); - } - } - const details = detailsList.find((s) => s.dataset.name == name); - if (!details) return; - details.open = true; - ul = null; - while (!ul) { - const uls = /** @type {HTMLUListElement[]} */ ( - Array.from(details.querySelectorAll(":scope > ul")) - ); - if (!uls.length) { - await next(); - } else if (uls.length > 1) { - throw "Shouldn't be possible"; - } else { - ul = /** @type {HTMLUListElement} */ (uls.pop()); - } - } - } - /** @type {HTMLAnchorElement[]} */ - let anchors = []; - while (!anchors.length) { - anchors = Array.from(ul.querySelectorAll(":scope > li > a")); - if (!anchors.length) { - await next(); - } - } - anchors - .find((a) => a.getAttribute("href") == window.document.location.pathname) - ?.scrollIntoView({ - behavior: "instant", - block: "center", - }); - }); - - onFirstIntersection(searchElement, () => { - console.log("search: init"); - - const haystack = options.list.map((option) => option.title); - - const RESULTS_PER_PAGE = 100; - - /** - * @param {uFuzzy.SearchResult} searchResult - * @param {number} pageIndex - */ - function computeResultPage(searchResult, pageIndex) { - /** @type {{ option: Option, title: string }[]} */ - let list = []; - - let [indexes, _info, order] = searchResult || [null, null, null]; - - const minIndex = pageIndex * RESULTS_PER_PAGE; - - if (indexes?.length) { - const maxIndex = Math.min( - (order || indexes).length - 1, - minIndex + RESULTS_PER_PAGE - 1, - ); - - list = Array(maxIndex - minIndex + 1); - - for (let i = minIndex; i <= maxIndex; i++) { - let index = indexes[i]; - - const title = haystack[index]; - - list[i % 100] = { - option: options.list[index], - title, - }; - } - } - - return list; - } - - /** @type {uFuzzy.Options} */ - const config = { - intraIns: Infinity, - intraChars: `[a-z\d' ]`, - }; - - const fuzzyMultiInsert = /** @type {uFuzzy} */ ( - ufuzzy({ - intraIns: 1, - }) - ); - const fuzzyMultiInsertFuzzier = /** @type {uFuzzy} */ (ufuzzy(config)); - const fuzzySingleError = /** @type {uFuzzy} */ ( - ufuzzy({ - intraMode: 1, - ...config, - }) - ); - const fuzzySingleErrorFuzzier = /** @type {uFuzzy} */ ( - ufuzzy({ - intraMode: 1, - ...config, - }) - ); - - /** @type {VoidFunction | undefined} */ - let dispose; - - function inputEvent() { - signals.createRoot((_dispose) => { - const needle = /** @type {string} */ (searchInput.value); - - dispose?.(); - - dispose = _dispose; - - searchResultsElement.scrollTo({ - top: 0, - }); - - if (!needle) { - searchResultsElement.innerHTML = ""; + case "link": { return; } + } - const outOfOrder = 5; - const infoThresh = 5_000; + if (!element) throw "Element should be set"; - let result = fuzzyMultiInsert?.search( - haystack, - needle, - undefined, - infoThresh, - ); + if (element !== previousElement) { + if (previousElement) previousElement.hidden = true; + element.hidden = false; + } - if (!result?.[0]?.length || !result?.[1]) { - result = fuzzyMultiInsert?.search( - haystack, - needle, - outOfOrder, - infoThresh, - ); - } + if (!previousElement) { + replaceHistory({ pathname: option.path }); + } - if (!result?.[0]?.length || !result?.[1]) { - result = fuzzySingleError?.search( - haystack, - needle, - outOfOrder, - infoThresh, - ); - } + previousElement = element; + }); + } - if (!result?.[0]?.length || !result?.[1]) { - result = fuzzySingleErrorFuzzier?.search( - haystack, - needle, - outOfOrder, - infoThresh, - ); - } - - if (!result?.[0]?.length || !result?.[1]) { - result = fuzzyMultiInsertFuzzier?.search( - haystack, - needle, - undefined, - infoThresh, - ); - } - - if (!result?.[0]?.length || !result?.[1]) { - result = fuzzyMultiInsertFuzzier?.search( - haystack, - needle, - outOfOrder, - infoThresh, - ); - } - - searchResultsElement.innerHTML = ""; - - const list = computeResultPage(result, 0); - - list.forEach(({ option, title }) => { - const li = window.document.createElement("li"); - searchResultsElement.appendChild(li); - - const element = options.createOptionElement({ - option, - name: title, - }); - - if (element) { - li.append(element); - } - }); - }); + let firstMobileSwitch = true; + options.selected.onChange(() => { + if (!firstMobileSwitch && !isHidden(asideLabelElement)) { + asideLabelElement.click(); } - - if (searchInput.value) { - inputEvent(); - } - - searchInput.addEventListener("input", inputEvent); + firstMobileSwitch = false; }); - function initDesktopResizeBar() { - const resizeBar = getElementById("resize-bar"); - let resize = false; - let startingWidth = 0; - let startingClientX = 0; + onFirstIntersection(asideElement, initSelectedFrame); +} +initSelected(); - const barWidthLocalStorageKey = "bar-width"; +onFirstIntersection(navElement, async () => { + options.setParent(navElement); - /** - * @param {number | null} width - */ - function setBarWidth(width) { - // TODO: Check if should be a signal ?? - try { - if (typeof width === "number") { - mainElement.style.width = `${width}px`; - writeToStorage(barWidthLocalStorageKey, String(width)); - } else { - mainElement.style.width = style.getPropertyValue( - "--default-main-width", - ); - removeStored(barWidthLocalStorageKey); - } - } catch (_) {} + const option = options.selected.value; + if (!option) throw "Selected should be set by now"; + const path = [...option.path]; + + /** @type {HTMLUListElement | null} */ + let ul = /** @type {any} */ (null); + async function getFirstChild() { + try { + ul = /** @type {HTMLUListElement} */ (navElement.firstElementChild); + await next(); + if (!ul) { + await getFirstChild(); + } + } catch (_) { + await next(); + await getFirstChild(); } + } + await getFirstChild(); + if (!ul) throw Error("Unreachable"); - /** - * @param {MouseEvent} event - */ - function mouseMoveEvent(event) { - if (resize) { - setBarWidth(startingWidth + (event.clientX - startingClientX)); + while (path.length > 1) { + const name = path.shift(); + if (!name) throw "Unreachable"; + /** @type {HTMLDetailsElement[]} */ + let detailsList = []; + while (!detailsList.length) { + detailsList = Array.from(ul.querySelectorAll(":scope > li > details")); + if (!detailsList.length) { + await next(); + } + } + const details = detailsList.find((s) => s.dataset.name == name); + if (!details) return; + details.open = true; + ul = null; + while (!ul) { + const uls = /** @type {HTMLUListElement[]} */ ( + Array.from(details.querySelectorAll(":scope > ul")) + ); + if (!uls.length) { + await next(); + } else if (uls.length > 1) { + throw "Shouldn't be possible"; + } else { + ul = /** @type {HTMLUListElement} */ (uls.pop()); } } - - resizeBar.addEventListener("mousedown", (event) => { - startingClientX = event.clientX; - startingWidth = mainElement.clientWidth; - resize = true; - window.document.documentElement.dataset.resize = ""; - window.addEventListener("mousemove", mouseMoveEvent); - }); - - resizeBar.addEventListener("dblclick", () => { - setBarWidth(null); - }); - - const setResizeFalse = () => { - resize = false; - delete window.document.documentElement.dataset.resize; - window.removeEventListener("mousemove", mouseMoveEvent); - }; - window.addEventListener("mouseup", setResizeFalse); - window.addEventListener("mouseleave", setResizeFalse); } - initDesktopResizeBar(); + /** @type {HTMLAnchorElement[]} */ + let anchors = []; + while (!anchors.length) { + anchors = Array.from(ul.querySelectorAll(":scope > li > a")); + if (!anchors.length) { + await next(); + } + } + anchors + .find((a) => a.getAttribute("href") == window.document.location.pathname) + ?.scrollIntoView({ + behavior: "instant", + block: "center", + }); }); + +onFirstIntersection(searchElement, () => { + initSearch(options); +}); + +function initDesktopResizeBar() { + const resizeBar = getElementById("resize-bar"); + let resize = false; + let startingWidth = 0; + let startingClientX = 0; + + const barWidthLocalStorageKey = "bar-width"; + + /** + * @param {number | null} width + */ + function setBarWidth(width) { + // TODO: Check if should be a signal ?? + try { + if (typeof width === "number") { + mainElement.style.width = `${width}px`; + writeToStorage(barWidthLocalStorageKey, String(width)); + } else { + mainElement.style.width = style.getPropertyValue( + "--default-main-width", + ); + removeStored(barWidthLocalStorageKey); + } + } catch (_) {} + } + + /** + * @param {MouseEvent} event + */ + function mouseMoveEvent(event) { + if (resize) { + setBarWidth(startingWidth + (event.clientX - startingClientX)); + } + } + + resizeBar.addEventListener("mousedown", (event) => { + startingClientX = event.clientX; + startingWidth = mainElement.clientWidth; + resize = true; + window.document.documentElement.dataset.resize = ""; + window.addEventListener("mousemove", mouseMoveEvent); + }); + + resizeBar.addEventListener("dblclick", () => { + setBarWidth(null); + }); + + const setResizeFalse = () => { + resize = false; + delete window.document.documentElement.dataset.resize; + window.removeEventListener("mousemove", mouseMoveEvent); + }; + window.addEventListener("mouseup", setResizeFalse); + window.addEventListener("mouseleave", setResizeFalse); +} +initDesktopResizeBar(); diff --git a/website/scripts/options/full.js b/website/scripts/options/full.js index 84218ad87..456db07ed 100644 --- a/website/scripts/options/full.js +++ b/website/scripts/options/full.js @@ -7,11 +7,9 @@ import { collect, markUsed, logUnused } from "./unused.js"; import { setQr } from "../panes/share.js"; /** - * @param {Object} args - * @param {Signals} args.signals - * @param {BrkClient} args.brk + * @param {BrkClient} brk */ -export function initOptions({ signals, brk }) { +export function initOptions(brk) { collect(brk.metrics); const LS_SELECTED_KEY = `selected_path`; @@ -25,9 +23,6 @@ export function initOptions({ signals, brk }) { ).filter((v) => v); console.log(savedPath); - /** @type {Signal