123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- let taskIdCounter = 1,
- isCallbackScheduled = false,
- isPerformingWork = false,
- taskQueue = [],
- currentTask = null,
- shouldYieldToHost = null,
- yieldInterval = 5,
- deadline = 0,
- maxYieldInterval = 300,
- scheduleCallback = null,
- scheduledCallback = null;
- const maxSigned31BitInt = 1073741823;
- function setupScheduler() {
- const channel = new MessageChannel(),
- port = channel.port2;
- scheduleCallback = () => port.postMessage(null);
- channel.port1.onmessage = () => {
- if (scheduledCallback !== null) {
- const currentTime = performance.now();
- deadline = currentTime + yieldInterval;
- const hasTimeRemaining = true;
- try {
- const hasMoreWork = scheduledCallback(hasTimeRemaining, currentTime);
- if (!hasMoreWork) {
- scheduledCallback = null;
- } else port.postMessage(null);
- } catch (error) {
- port.postMessage(null);
- throw error;
- }
- }
- };
- if (navigator && navigator.scheduling && navigator.scheduling.isInputPending) {
- const scheduling = navigator.scheduling;
- shouldYieldToHost = () => {
- const currentTime = performance.now();
- if (currentTime >= deadline) {
- if (scheduling.isInputPending()) {
- return true;
- }
- return currentTime >= maxYieldInterval;
- } else {
- return false;
- }
- };
- } else {
- shouldYieldToHost = () => performance.now() >= deadline;
- }
- }
- function enqueue(taskQueue, task) {
- function findIndex() {
- let m = 0;
- let n = taskQueue.length - 1;
- while (m <= n) {
- let k = n + m >> 1;
- let cmp = task.expirationTime - taskQueue[k].expirationTime;
- if (cmp > 0) m = k + 1;else if (cmp < 0) n = k - 1;else return k;
- }
- return m;
- }
- taskQueue.splice(findIndex(), 0, task);
- }
- function requestCallback(fn, options) {
- if (!scheduleCallback) setupScheduler();
- let startTime = performance.now(),
- timeout = maxSigned31BitInt;
- if (options && options.timeout) timeout = options.timeout;
- const newTask = {
- id: taskIdCounter++,
- fn,
- startTime,
- expirationTime: startTime + timeout
- };
- enqueue(taskQueue, newTask);
- if (!isCallbackScheduled && !isPerformingWork) {
- isCallbackScheduled = true;
- scheduledCallback = flushWork;
- scheduleCallback();
- }
- return newTask;
- }
- function cancelCallback(task) {
- task.fn = null;
- }
- function flushWork(hasTimeRemaining, initialTime) {
- isCallbackScheduled = false;
- isPerformingWork = true;
- try {
- return workLoop(hasTimeRemaining, initialTime);
- } finally {
- currentTask = null;
- isPerformingWork = false;
- }
- }
- function workLoop(hasTimeRemaining, initialTime) {
- let currentTime = initialTime;
- currentTask = taskQueue[0] || null;
- while (currentTask !== null) {
- if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
- break;
- }
- const callback = currentTask.fn;
- if (callback !== null) {
- currentTask.fn = null;
- const didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
- callback(didUserCallbackTimeout);
- currentTime = performance.now();
- if (currentTask === taskQueue[0]) {
- taskQueue.shift();
- }
- } else taskQueue.shift();
- currentTask = taskQueue[0] || null;
- }
- return currentTask !== null;
- }
- const sharedConfig = {};
- function setHydrateContext(context) {
- sharedConfig.context = context;
- }
- function nextHydrateContext() {
- return { ...sharedConfig.context,
- id: `${sharedConfig.context.id}${sharedConfig.context.count++}.`,
- count: 0
- };
- }
- const equalFn = (a, b) => a === b;
- const signalOptions = {
- equals: equalFn
- };
- let ERROR = null;
- let runEffects = runQueue;
- const NOTPENDING = {};
- const STALE = 1;
- const PENDING = 2;
- const UNOWNED = {
- owned: null,
- cleanups: null,
- context: null,
- owner: null
- };
- const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
- var Owner = null;
- var Listener = null;
- let Pending = null;
- let Updates = null;
- let Effects = null;
- let Transition = null;
- let ExecCount = 0;
- function createRoot(fn, detachedOwner) {
- detachedOwner && (Owner = detachedOwner);
- const listener = Listener,
- owner = Owner,
- root = fn.length === 0 && !false ? UNOWNED : {
- owned: null,
- cleanups: null,
- context: null,
- owner,
- attached: !!detachedOwner
- };
- Owner = root;
- Listener = null;
- let result;
- try {
- runUpdates(() => result = fn(() => cleanNode(root)), true);
- } finally {
- Listener = listener;
- Owner = owner;
- }
- return result;
- }
- function createSignal(value, options) {
- options = options ? Object.assign({}, signalOptions, options) : signalOptions;
- const s = {
- value,
- observers: null,
- observerSlots: null,
- pending: NOTPENDING,
- comparator: options.equals || undefined
- };
- return [readSignal.bind(s), writeSignal.bind(s)];
- }
- function createComputed(fn, value, options) {
- updateComputation(createComputation(fn, value, true));
- }
- function createRenderEffect(fn, value, options) {
- updateComputation(createComputation(fn, value, false));
- }
- function createEffect(fn, value, options) {
- runEffects = runUserEffects;
- const c = createComputation(fn, value, false),
- s = SuspenseContext && lookup(Owner, SuspenseContext.id);
- if (s) c.suspense = s;
- c.user = true;
- Effects && Effects.push(c);
- }
- function createMemo(fn, value, options) {
- options = options ? Object.assign({}, signalOptions, options) : signalOptions;
- const c = createComputation(fn, value, true);
- c.pending = NOTPENDING;
- c.observers = null;
- c.observerSlots = null;
- c.state = 0;
- c.comparator = options.equals || undefined;
- updateComputation(c);
- return readSignal.bind(c);
- }
- function createResource(source, fetcher, options = {}) {
- if (arguments.length === 2) {
- if (typeof fetcher === "object") {
- options = fetcher;
- fetcher = source;
- source = true;
- }
- } else if (arguments.length === 1) {
- fetcher = source;
- source = true;
- }
- const contexts = new Set(),
- [s, set] = createSignal(options.initialValue),
- [track, trigger] = createSignal(undefined, {
- equals: false
- }),
- [loading, setLoading] = createSignal(false),
- [error, setError] = createSignal();
- let err = undefined,
- pr = null,
- initP = null,
- id = null,
- loadedUnderTransition = false,
- dynamic = typeof source === "function";
- if (sharedConfig.context) {
- id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
- if (sharedConfig.context.loadResource) {
- initP = sharedConfig.context.loadResource(id);
- } else if (sharedConfig.resources && id && id in sharedConfig.resources) {
- initP = sharedConfig.resources[id];
- delete sharedConfig.resources[id];
- }
- }
- function loadEnd(p, v, e) {
- if (pr === p) {
- setError(err = e);
- pr = null;
- if (Transition && p && loadedUnderTransition) {
- Transition.promises.delete(p);
- loadedUnderTransition = false;
- runUpdates(() => {
- Transition.running = true;
- if (!Transition.promises.size) {
- Effects.push.apply(Effects, Transition.effects);
- Transition.effects = [];
- }
- completeLoad(v);
- }, false);
- } else completeLoad(v);
- }
- return v;
- }
- function completeLoad(v) {
- batch(() => {
- set(v);
- setLoading(false);
- for (let c of contexts.keys()) c.decrement();
- contexts.clear();
- });
- }
- function read() {
- const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
- v = s();
- if (err) throw err;
- if (Listener && !Listener.user && c) {
- createComputed(() => {
- track();
- if (pr) {
- if (c.resolved && Transition) Transition.promises.add(pr);else if (!contexts.has(c)) {
- c.increment();
- contexts.add(c);
- }
- }
- });
- }
- return v;
- }
- function load() {
- setError(err = undefined);
- let lookup = dynamic ? source() : source;
- loadedUnderTransition = Transition && Transition.running;
- if (lookup == null || lookup === false) {
- loadEnd(pr, untrack(s));
- return;
- }
- if (Transition && pr) Transition.promises.delete(pr);
- const p = initP || fetcher(lookup, s);
- initP = null;
- if (typeof p !== "object" || !("then" in p)) {
- loadEnd(pr, p);
- return;
- }
- pr = p;
- batch(() => {
- setLoading(true);
- trigger();
- });
- p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
- }
- Object.defineProperties(read, {
- loading: {
- get() {
- return loading();
- }
- },
- error: {
- get() {
- return error();
- }
- }
- });
- if (dynamic) createComputed(load);else load();
- return [read, {
- refetch: load,
- mutate: set
- }];
- }
- function createDeferred(source, options) {
- let t,
- timeout = options ? options.timeoutMs : undefined;
- const node = createComputation(() => {
- if (!t || !t.fn) t = requestCallback(() => setDeferred(node.value), timeout !== undefined ? {
- timeout
- } : undefined);
- return source();
- }, undefined, true);
- const [deferred, setDeferred] = createSignal(node.value, options);
- updateComputation(node);
- setDeferred(node.value);
- return deferred;
- }
- function createSelector(source, fn = equalFn, options) {
- let subs = new Map();
- const node = createComputation(p => {
- const v = source();
- for (const key of subs.keys()) if (fn(key, v) || p !== undefined && fn(key, p)) {
- const l = subs.get(key);
- for (const c of l.values()) {
- c.state = STALE;
- if (c.pure) Updates.push(c);else Effects.push(c);
- }
- }
- return v;
- }, undefined, true);
- updateComputation(node);
- return key => {
- let listener;
- if (listener = Listener) {
- let l;
- if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
- onCleanup(() => {
- l.size > 1 ? l.delete(listener) : subs.delete(key);
- });
- }
- return fn(key, node.value);
- };
- }
- function batch(fn) {
- if (Pending) return fn();
- let result;
- const q = Pending = [];
- try {
- result = fn();
- } finally {
- Pending = null;
- }
- runUpdates(() => {
- for (let i = 0; i < q.length; i += 1) {
- const data = q[i];
- if (data.pending !== NOTPENDING) {
- const pending = data.pending;
- data.pending = NOTPENDING;
- writeSignal.call(data, pending);
- }
- }
- }, false);
- return result;
- }
- function untrack(fn) {
- let result,
- listener = Listener;
- Listener = null;
- result = fn();
- Listener = listener;
- return result;
- }
- function on(deps, fn, options) {
- let isArray = Array.isArray(deps);
- let prev;
- let defer = options && options.defer;
- return prevResult => {
- let value;
- if (isArray) {
- value = [];
- for (let i = 0; i < deps.length; i++) value.push(deps[i]());
- } else value = deps();
- if (defer) {
- defer = false;
- return undefined;
- }
- const result = untrack(() => fn(value, prev, prevResult));
- prev = value;
- return result;
- };
- }
- function onMount(fn) {
- createEffect(() => untrack(fn));
- }
- function onCleanup(fn) {
- if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
- return fn;
- }
- function onError(fn) {
- ERROR || (ERROR = Symbol("error"));
- if (Owner === null) ;else if (Owner.context === null) Owner.context = {
- [ERROR]: [fn]
- };else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
- }
- function getListener() {
- return Listener;
- }
- function getOwner() {
- return Owner;
- }
- function runWithOwner(o, fn) {
- const prev = Owner;
- Owner = o;
- try {
- return fn();
- } finally {
- Owner = prev;
- }
- }
- function useTransition() {
- return [transPending, (fn, cb) => {
- if (SuspenseContext) {
- Transition || (Transition = {
- sources: new Set(),
- effects: [],
- promises: new Set(),
- disposed: new Set(),
- running: true,
- cb: []
- });
- cb && Transition.cb.push(cb);
- Transition.running = true;
- }
- batch(fn);
- if (!SuspenseContext && cb) cb();
- }];
- }
- function resumeEffects(e) {
- Transition && (Transition.running = true);
- Effects.push.apply(Effects, e);
- e.length = 0;
- }
- function createContext(defaultValue) {
- const id = Symbol("context");
- return {
- id,
- Provider: createProvider(id),
- defaultValue
- };
- }
- function useContext(context) {
- return lookup(Owner, context.id) || context.defaultValue;
- }
- function children(fn) {
- const children = createMemo(fn);
- return createMemo(() => resolveChildren(children()));
- }
- let SuspenseContext;
- function getSuspenseContext() {
- return SuspenseContext || (SuspenseContext = createContext({}));
- }
- function readSignal() {
- if (this.state && this.sources) {
- const updates = Updates;
- Updates = null;
- this.state === STALE ? updateComputation(this) : lookDownstream(this);
- Updates = updates;
- }
- if (Listener) {
- const sSlot = this.observers ? this.observers.length : 0;
- if (!Listener.sources) {
- Listener.sources = [this];
- Listener.sourceSlots = [sSlot];
- } else {
- Listener.sources.push(this);
- Listener.sourceSlots.push(sSlot);
- }
- if (!this.observers) {
- this.observers = [Listener];
- this.observerSlots = [Listener.sources.length - 1];
- } else {
- this.observers.push(Listener);
- this.observerSlots.push(Listener.sources.length - 1);
- }
- }
- if (Transition && Transition.running && Transition.sources.has(this)) return this.tValue;
- return this.value;
- }
- function writeSignal(value, isComp) {
- if (this.comparator) {
- if (Transition && Transition.running && Transition.sources.has(this)) {
- if (this.comparator(this.tValue, value)) return value;
- } else if (this.comparator(this.value, value)) return value;
- }
- if (Pending) {
- if (this.pending === NOTPENDING) Pending.push(this);
- this.pending = value;
- return value;
- }
- if (Transition) {
- if (Transition.running || !isComp && Transition.sources.has(this)) {
- Transition.sources.add(this);
- this.tValue = value;
- }
- if (!Transition.running) this.value = value;
- } else this.value = value;
- if (this.observers && (!Updates || this.observers.length)) {
- runUpdates(() => {
- for (let i = 0; i < this.observers.length; i += 1) {
- const o = this.observers[i];
- if (Transition && Transition.running && Transition.disposed.has(o)) continue;
- if (o.observers && o.state !== PENDING) markUpstream(o);
- o.state = STALE;
- if (o.pure) Updates.push(o);else Effects.push(o);
- }
- if (Updates.length > 10e5) {
- Updates = [];
- if (false) ;
- throw new Error();
- }
- }, false);
- }
- return value;
- }
- function updateComputation(node) {
- if (!node.fn) return;
- cleanNode(node);
- const owner = Owner,
- listener = Listener,
- time = ExecCount;
- Listener = Owner = node;
- runComputation(node, node.value, time);
- if (Transition && !Transition.running && Transition.sources.has(node)) {
- Transition.running = true;
- runComputation(node, node.tValue, time);
- Transition.running = false;
- }
- Listener = listener;
- Owner = owner;
- }
- function runComputation(node, value, time) {
- let nextValue;
- try {
- nextValue = node.fn(value);
- } catch (err) {
- handleError(err);
- }
- if (!node.updatedAt || node.updatedAt <= time) {
- if (node.observers && node.observers.length) {
- writeSignal.call(node, nextValue, true);
- } else if (Transition && Transition.running && node.pure) {
- Transition.sources.add(node);
- node.tValue = nextValue;
- } else node.value = nextValue;
- node.updatedAt = time;
- }
- }
- function createComputation(fn, init, pure, options) {
- const c = {
- fn,
- state: STALE,
- updatedAt: null,
- owned: null,
- sources: null,
- sourceSlots: null,
- cleanups: null,
- value: init,
- owner: Owner,
- context: null,
- pure
- };
- if (Owner === null) ;else if (Owner !== UNOWNED) {
- if (Transition && Transition.running && Owner.pure) {
- if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
- } else {
- if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
- }
- }
- return c;
- }
- function runTop(node) {
- let top = node.state === STALE && node,
- pending;
- if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
- const runningTransition = Transition && Transition.running;
- while ((node.fn || runningTransition && node.attached) && (node = node.owner)) {
- if (runningTransition && Transition.disposed.has(node)) return;
- if (node.state === PENDING) pending = node;else if (node.state === STALE) {
- top = node;
- pending = undefined;
- }
- }
- if (pending) {
- const updates = Updates;
- Updates = null;
- lookDownstream(pending);
- Updates = updates;
- if (!top || top.state !== STALE) return;
- if (runningTransition) {
- node = top;
- while ((node.fn || node.attached) && (node = node.owner)) {
- if (Transition.disposed.has(node)) return;
- }
- }
- }
- top && updateComputation(top);
- }
- function runUpdates(fn, init) {
- if (Updates) return fn();
- let wait = false;
- if (!init) Updates = [];
- if (Effects) wait = true;else Effects = [];
- ExecCount++;
- try {
- fn();
- } catch (err) {
- handleError(err);
- } finally {
- completeUpdates(wait);
- }
- }
- function completeUpdates(wait) {
- if (Updates) {
- runQueue(Updates);
- Updates = null;
- }
- if (wait) return;
- let cbs;
- if (Transition && Transition.running) {
- if (Transition.promises.size) {
- Transition.running = false;
- Transition.effects.push.apply(Transition.effects, Effects);
- Effects = null;
- setTransPending(true);
- return;
- }
- const sources = Transition.sources;
- cbs = Transition.cb;
- Transition = null;
- batch(() => {
- sources.forEach(v => {
- v.value = v.tValue;
- if (v.owned) {
- for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]);
- }
- if (v.tOwned) v.owned = v.tOwned;
- delete v.tValue;
- delete v.tOwned;
- });
- setTransPending(false);
- });
- }
- if (Effects.length) batch(() => {
- runEffects(Effects);
- Effects = null;
- });else {
- Effects = null;
- }
- if (cbs) cbs.forEach(cb => cb());
- }
- function runQueue(queue) {
- for (let i = 0; i < queue.length; i++) runTop(queue[i]);
- }
- function runUserEffects(queue) {
- let i,
- userLength = 0;
- for (i = 0; i < queue.length; i++) {
- const e = queue[i];
- if (!e.user) runTop(e);else queue[userLength++] = e;
- }
- const resume = queue.length;
- for (i = 0; i < userLength; i++) runTop(queue[i]);
- for (i = resume; i < queue.length; i++) runTop(queue[i]);
- }
- function lookDownstream(node) {
- node.state = 0;
- for (let i = 0; i < node.sources.length; i += 1) {
- const source = node.sources[i];
- if (source.sources) {
- if (source.state === STALE) runTop(source);else if (source.state === PENDING) lookDownstream(source);
- }
- }
- }
- function markUpstream(node) {
- for (let i = 0; i < node.observers.length; i += 1) {
- const o = node.observers[i];
- if (!o.state) {
- o.state = PENDING;
- o.observers && markUpstream(o);
- }
- }
- }
- function cleanNode(node) {
- let i;
- if (node.sources) {
- while (node.sources.length) {
- const source = node.sources.pop(),
- index = node.sourceSlots.pop(),
- obs = source.observers;
- if (obs && obs.length) {
- const n = obs.pop(),
- s = source.observerSlots.pop();
- if (index < obs.length) {
- n.sourceSlots[s] = index;
- obs[index] = n;
- source.observerSlots[index] = s;
- }
- }
- }
- }
- if (Transition && Transition.running && node.pure) {
- if (node.tOwned) {
- for (i = 0; i < node.tOwned.length; i++) cleanNode(node.tOwned[i]);
- delete node.tOwned;
- }
- reset(node, true);
- } else if (node.owned) {
- for (i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
- node.owned = null;
- }
- if (node.cleanups) {
- for (i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
- node.cleanups = null;
- }
- node.state = 0;
- node.context = null;
- }
- function reset(node, top) {
- if (!top) {
- node.state = 0;
- Transition.disposed.add(node);
- }
- if (node.owned) {
- for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]);
- }
- }
- function handleError(err) {
- const fns = ERROR && lookup(Owner, ERROR);
- if (!fns) throw err;
- fns.forEach(f => f(err));
- }
- function lookup(owner, key) {
- return owner && (owner.context && owner.context[key] || owner.owner && lookup(owner.owner, key));
- }
- function resolveChildren(children) {
- if (typeof children === "function" && !children.length) return resolveChildren(children());
- if (Array.isArray(children)) {
- const results = [];
- for (let i = 0; i < children.length; i++) {
- let result = resolveChildren(children[i]);
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
- }
- return results;
- }
- return children;
- }
- function createProvider(id) {
- return function provider(props) {
- return createMemo(() => {
- Owner.context = {
- [id]: props.value
- };
- return children(() => props.children);
- });
- };
- }
- const $RAW = Symbol("state-raw"),
- $NODE = Symbol("state-node"),
- $PROXY = Symbol("state-proxy"),
- $NAME = Symbol("state-name");
- function wrap$1(value, name) {
- let p = value[$PROXY];
- if (!p) {
- Object.defineProperty(value, $PROXY, {
- value: p = new Proxy(value, proxyTraps$1)
- });
- let keys = Object.keys(value),
- desc = Object.getOwnPropertyDescriptors(value);
- for (let i = 0, l = keys.length; i < l; i++) {
- const prop = keys[i];
- if (desc[prop].get) {
- const get = desc[prop].get.bind(p);
- Object.defineProperty(value, prop, {
- get
- });
- }
- }
- }
- return p;
- }
- function isWrappable(obj) {
- return obj != null && typeof obj === "object" && (!obj.__proto__ || obj.__proto__ === Object.prototype || Array.isArray(obj));
- }
- function unwrap(item, set = new Set()) {
- let result, unwrapped, v, prop;
- if (result = item != null && item[$RAW]) return result;
- if (!isWrappable(item) || set.has(item)) return item;
- if (Array.isArray(item)) {
- if (Object.isFrozen(item)) item = item.slice(0);else set.add(item);
- for (let i = 0, l = item.length; i < l; i++) {
- v = item[i];
- if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
- }
- } else {
- if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);
- let keys = Object.keys(item),
- desc = Object.getOwnPropertyDescriptors(item);
- for (let i = 0, l = keys.length; i < l; i++) {
- prop = keys[i];
- if (desc[prop].get) continue;
- v = item[prop];
- if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
- }
- }
- return item;
- }
- function getDataNodes(target) {
- let nodes = target[$NODE];
- if (!nodes) Object.defineProperty(target, $NODE, {
- value: nodes = {}
- });
- return nodes;
- }
- function proxyDescriptor(target, property) {
- const desc = Reflect.getOwnPropertyDescriptor(target, property);
- if (!desc || desc.get || property === $PROXY || property === $NODE || property === $NAME) return desc;
- delete desc.value;
- delete desc.writable;
- desc.get = () => target[$PROXY][property];
- return desc;
- }
- function createDataNode() {
- const [s, set] = createSignal(undefined, {
- equals: false
- });
- s.set = set;
- return s;
- }
- const proxyTraps$1 = {
- get(target, property, receiver) {
- if (property === $RAW) return target;
- if (property === $PROXY) return receiver;
- const value = target[property];
- if (property === $NODE || property === "__proto__") return value;
- const wrappable = isWrappable(value);
- if (Listener && (typeof value !== "function" || target.hasOwnProperty(property))) {
- let nodes, node;
- if (wrappable && (nodes = getDataNodes(value))) {
- node = nodes._ || (nodes._ = createDataNode());
- node();
- }
- nodes = getDataNodes(target);
- node = nodes[property] || (nodes[property] = createDataNode());
- node();
- }
- return wrappable ? wrap$1(value) : value;
- },
- set() {
- return true;
- },
- deleteProperty() {
- return true;
- },
- getOwnPropertyDescriptor: proxyDescriptor
- };
- function setProperty(state, property, value) {
- if (state[property] === value) return;
- const array = Array.isArray(state);
- const len = state.length;
- const notify = array || !(property in state);
- if (value === undefined) {
- delete state[property];
- } else state[property] = value;
- let nodes = getDataNodes(state),
- node;
- (node = nodes[property]) && node.set();
- if (array && state.length !== len) (node = nodes.length) && node.set();
- notify && (node = nodes._) && node.set();
- }
- function mergeState(state, value) {
- const keys = Object.keys(value);
- for (let i = 0; i < keys.length; i += 1) {
- const key = keys[i];
- setProperty(state, key, value[key]);
- }
- }
- function updatePath(current, path, traversed = []) {
- let part,
- prev = current;
- if (path.length > 1) {
- part = path.shift();
- const partType = typeof part,
- isArray = Array.isArray(current);
- if (Array.isArray(part)) {
- for (let i = 0; i < part.length; i++) {
- updatePath(current, [part[i]].concat(path), [part[i]].concat(traversed));
- }
- return;
- } else if (isArray && partType === "function") {
- for (let i = 0; i < current.length; i++) {
- if (part(current[i], i)) updatePath(current, [i].concat(path), [i].concat(traversed));
- }
- return;
- } else if (isArray && partType === "object") {
- const {
- from = 0,
- to = current.length - 1,
- by = 1
- } = part;
- for (let i = from; i <= to; i += by) {
- updatePath(current, [i].concat(path), [i].concat(traversed));
- }
- return;
- } else if (path.length > 1) {
- updatePath(current[part], path, [part].concat(traversed));
- return;
- }
- prev = current[part];
- traversed = [part].concat(traversed);
- }
- let value = path[0];
- if (typeof value === "function") {
- value = value(prev, traversed);
- if (value === prev) return;
- }
- if (part === undefined && value == undefined) return;
- value = unwrap(value);
- if (part === undefined || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
- mergeState(prev, value);
- } else setProperty(current, part, value);
- }
- function createState(state, options) {
- const unwrappedState = unwrap(state || {});
- const wrappedState = wrap$1(unwrappedState);
- function setState(...args) {
- batch(() => updatePath(unwrappedState, args));
- }
- return [wrappedState, setState];
- }
- const proxyTraps = {
- get(target, property, receiver) {
- if (property === $RAW) return target;
- if (property === $PROXY) return receiver;
- const value = target[property];
- if (property === $NODE || property === "__proto__") return value;
- const wrappable = isWrappable(value);
- if (Listener && (typeof value !== "function" || target.hasOwnProperty(property))) {
- let nodes, node;
- if (wrappable && (nodes = getDataNodes(value))) {
- node = nodes._ || (nodes._ = createDataNode());
- node();
- }
- nodes = getDataNodes(target);
- node = nodes[property] || (nodes[property] = createDataNode());
- node();
- }
- return wrappable ? wrap(value) : value;
- },
- set(target, property, value) {
- setProperty(target, property, unwrap(value));
- return true;
- },
- deleteProperty(target, property) {
- setProperty(target, property, undefined);
- return true;
- },
- getOwnPropertyDescriptor: proxyDescriptor
- };
- function wrap(value, name) {
- let p = value[$PROXY];
- if (!p) {
- Object.defineProperty(value, $PROXY, {
- value: p = new Proxy(value, proxyTraps)
- });
- let keys = Object.keys(value),
- desc = Object.getOwnPropertyDescriptors(value);
- for (let i = 0, l = keys.length; i < l; i++) {
- const prop = keys[i];
- if (desc[prop].get) {
- const get = desc[prop].get.bind(p);
- Object.defineProperty(value, prop, {
- get
- });
- }
- if (desc[prop].set) {
- const og = desc[prop].set,
- set = v => batch(() => og.call(p, v));
- Object.defineProperty(value, prop, {
- set
- });
- }
- }
- }
- return p;
- }
- function createMutable(state, options) {
- const unwrappedState = unwrap(state || {});
- const wrappedState = wrap(unwrappedState);
- return wrappedState;
- }
- function getSymbol() {
- const SymbolCopy = Symbol;
- return SymbolCopy.observable || '@@observable';
- }
- function observable(input) {
- const $$observable = getSymbol();
- return {
- subscribe(observer) {
- if (!(observer instanceof Object) || observer == null) {
- throw new TypeError("Expected the observer to be an object.");
- }
- const handler = "next" in observer ? observer.next : observer;
- let complete = false;
- createComputed(() => {
- if (complete) return;
- const v = input();
- untrack(() => handler(v));
- });
- return {
- unsubscribe() {
- complete = true;
- }
- };
- },
- [$$observable]() {
- return this;
- }
- };
- }
- function applyState(target, parent, property, merge, key) {
- let previous = parent[property];
- if (target === previous) return;
- if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
- target !== previous && setProperty(parent, property, target);
- return;
- }
- if (Array.isArray(target)) {
- if (target.length && previous.length && (!merge || key && target[0][key] != null)) {
- let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
- for (start = 0, end = Math.min(previous.length, target.length); start < end && (previous[start] === target[start] || key && previous[start][key] === target[start][key]); start++) {
- applyState(target[start], previous, start, merge, key);
- }
- const temp = new Array(target.length),
- newIndices = new Map();
- for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
- temp[newEnd] = previous[end];
- }
- if (start > newEnd || start > end) {
- for (j = start; j <= newEnd; j++) setProperty(previous, j, target[j]);
- for (; j < target.length; j++) {
- setProperty(previous, j, temp[j]);
- applyState(target[j], previous, j, merge, key);
- }
- if (previous.length > target.length) setProperty(previous, "length", target.length);
- return;
- }
- newIndicesNext = new Array(newEnd + 1);
- for (j = newEnd; j >= start; j--) {
- item = target[j];
- keyVal = key ? item[key] : item;
- i = newIndices.get(keyVal);
- newIndicesNext[j] = i === undefined ? -1 : i;
- newIndices.set(keyVal, j);
- }
- for (i = start; i <= end; i++) {
- item = previous[i];
- keyVal = key ? item[key] : item;
- j = newIndices.get(keyVal);
- if (j !== undefined && j !== -1) {
- temp[j] = previous[i];
- j = newIndicesNext[j];
- newIndices.set(keyVal, j);
- }
- }
- for (j = start; j < target.length; j++) {
- if (j in temp) {
- setProperty(previous, j, temp[j]);
- applyState(target[j], previous, j, merge, key);
- } else setProperty(previous, j, target[j]);
- }
- } else {
- for (let i = 0, len = target.length; i < len; i++) {
- applyState(target[i], previous, i, merge, key);
- }
- }
- if (previous.length > target.length) setProperty(previous, "length", target.length);
- return;
- }
- const targetKeys = Object.keys(target);
- for (let i = 0, len = targetKeys.length; i < len; i++) {
- applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
- }
- const previousKeys = Object.keys(previous);
- for (let i = 0, len = previousKeys.length; i < len; i++) {
- if (target[previousKeys[i]] === undefined) setProperty(previous, previousKeys[i], undefined);
- }
- }
- function reconcile(value, options = {}) {
- const {
- merge,
- key = "id"
- } = options,
- v = unwrap(value);
- return state => {
- if (!isWrappable(state) || !isWrappable(v)) return v;
- applyState(v, {
- state
- }, "state", merge, key);
- return state;
- };
- }
- const setterTraps = {
- get(target, property) {
- if (property === $RAW) return target;
- const value = target[property];
- return isWrappable(value) ? new Proxy(value, setterTraps) : value;
- },
- set(target, property, value) {
- setProperty(target, property, unwrap(value));
- return true;
- },
- deleteProperty(target, property) {
- setProperty(target, property, undefined);
- return true;
- }
- };
- function produce(fn) {
- return state => {
- if (isWrappable(state)) fn(new Proxy(state, setterTraps));
- return state;
- };
- }
- const FALLBACK = Symbol("fallback");
- function mapArray(list, mapFn, options = {}) {
- let items = [],
- mapped = [],
- disposers = [],
- len = 0,
- indexes = mapFn.length > 1 ? [] : null,
- ctx = Owner;
- onCleanup(() => {
- for (let i = 0, length = disposers.length; i < length; i++) disposers[i]();
- });
- return () => {
- let newItems = list() || [],
- i,
- j;
- return untrack(() => {
- let newLen = newItems.length,
- newIndices,
- newIndicesNext,
- temp,
- tempdisposers,
- tempIndexes,
- start,
- end,
- newEnd,
- item;
- if (newLen === 0) {
- if (len !== 0) {
- for (i = 0; i < len; i++) disposers[i]();
- disposers = [];
- items = [];
- mapped = [];
- len = 0;
- indexes && (indexes = []);
- }
- if (options.fallback) {
- items = [FALLBACK];
- mapped[0] = createRoot(disposer => {
- disposers[0] = disposer;
- return options.fallback();
- }, ctx);
- len = 1;
- }
- }
- else if (len === 0) {
- for (j = 0; j < newLen; j++) {
- items[j] = newItems[j];
- mapped[j] = createRoot(mapper, ctx);
- }
- len = newLen;
- } else {
- temp = new Array(newLen);
- tempdisposers = new Array(newLen);
- indexes && (tempIndexes = new Array(newLen));
- for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
- for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
- temp[newEnd] = mapped[end];
- tempdisposers[newEnd] = disposers[end];
- indexes && (tempIndexes[newEnd] = indexes[end]);
- }
- newIndices = new Map();
- newIndicesNext = new Array(newEnd + 1);
- for (j = newEnd; j >= start; j--) {
- item = newItems[j];
- i = newIndices.get(item);
- newIndicesNext[j] = i === undefined ? -1 : i;
- newIndices.set(item, j);
- }
- for (i = start; i <= end; i++) {
- item = items[i];
- j = newIndices.get(item);
- if (j !== undefined && j !== -1) {
- temp[j] = mapped[i];
- tempdisposers[j] = disposers[i];
- indexes && (tempIndexes[j] = indexes[i]);
- j = newIndicesNext[j];
- newIndices.set(item, j);
- } else disposers[i]();
- }
- for (j = start; j < newLen; j++) {
- if (j in temp) {
- mapped[j] = temp[j];
- disposers[j] = tempdisposers[j];
- if (indexes) {
- indexes[j] = tempIndexes[j];
- indexes[j](j);
- }
- } else mapped[j] = createRoot(mapper, ctx);
- }
- len = mapped.length = newLen;
- items = newItems.slice(0);
- }
- return mapped;
- });
- function mapper(disposer) {
- disposers[j] = disposer;
- if (indexes) {
- const [s, set] = createSignal(j);
- indexes[j] = set;
- return mapFn(newItems[j], s);
- }
- return mapFn(newItems[j]);
- }
- };
- }
- function indexArray(list, mapFn, options = {}) {
- let items = [],
- mapped = [],
- disposers = [],
- signals = [],
- len = 0,
- i,
- ctx = Owner;
- onCleanup(() => {
- for (let i = 0, length = disposers.length; i < length; i++) disposers[i]();
- });
- return () => {
- const newItems = list() || [];
- return untrack(() => {
- if (newItems.length === 0) {
- if (len !== 0) {
- for (i = 0; i < len; i++) disposers[i]();
- disposers = [];
- items = [];
- mapped = [];
- len = 0;
- signals = [];
- }
- if (options.fallback) {
- items = [FALLBACK];
- mapped[0] = createRoot(disposer => {
- disposers[0] = disposer;
- return options.fallback();
- }, ctx);
- len = 1;
- }
- return mapped;
- }
- if (items[0] === FALLBACK) {
- disposers[0]();
- disposers = [];
- items = [];
- mapped = [];
- len = 0;
- }
- for (i = 0; i < newItems.length; i++) {
- if (i < items.length && items[i] !== newItems[i]) {
- signals[i](newItems[i]);
- } else if (i >= items.length) {
- mapped[i] = createRoot(mapper, ctx);
- }
- }
- for (; i < items.length; i++) {
- disposers[i]();
- }
- len = mapped.length = signals.length = disposers.length = newItems.length;
- items = newItems.slice(0);
- return mapped;
- });
- function mapper(disposer) {
- disposers[i] = disposer;
- const [s, set] = createSignal(newItems[i]);
- signals[i] = set;
- return mapFn(s, i);
- }
- };
- }
- function createComponent(Comp, props) {
- if (sharedConfig.context) {
- const c = sharedConfig.context;
- setHydrateContext(nextHydrateContext());
- const r = untrack(() => Comp(props));
- setHydrateContext(c);
- return r;
- }
- return untrack(() => Comp(props));
- }
- function trueFn() {
- return true;
- }
- const propTraps = {
- get(_, property, receiver) {
- if (property === $PROXY) return receiver;
- return _.get(property);
- },
- has(_, property) {
- 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 mergeProps(...sources) {
- return new Proxy({
- get(property) {
- for (let i = sources.length - 1; i >= 0; i--) {
- const v = sources[i][property];
- if (v !== undefined) return v;
- }
- },
- has(property) {
- for (let i = sources.length - 1; i >= 0; i--) {
- if (property in sources[i]) return true;
- }
- return false;
- },
- keys() {
- const keys = [];
- for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
- return [...new Set(keys)];
- }
- }, propTraps);
- }
- function splitProps(props, ...keys) {
- const blocked = new Set(keys.flat());
- const descriptors = Object.getOwnPropertyDescriptors(props);
- const res = keys.map(k => {
- const clone = {};
- for (let i = 0; i < k.length; i++) {
- const key = k[i];
- Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
- get() {
- return props[key];
- }
- });
- }
- return clone;
- });
- res.push(new Proxy({
- get(property) {
- return blocked.has(property) ? undefined : props[property];
- },
- has(property) {
- return blocked.has(property) ? false : property in props;
- },
- keys() {
- return Object.keys(props).filter(k => !blocked.has(k));
- }
- }, propTraps));
- return res;
- }
- function lazy(fn) {
- let p;
- const wrap = props => {
- const ctx = sharedConfig.context;
- let comp;
- if (ctx && sharedConfig.resources) {
- ctx.count++;
- const [s, set] = createSignal();
- (p || (p = fn())).then(mod => {
- setHydrateContext(ctx);
- set(mod.default);
- setHydrateContext(undefined);
- });
- comp = s;
- } else {
- const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
- comp = s;
- }
- let Comp;
- return createMemo(() => (Comp = comp()) && untrack(() => {
- if (!ctx) return Comp(props);
- const c = sharedConfig.context;
- setHydrateContext(ctx);
- const r = Comp(props);
- setHydrateContext(c);
- return r;
- }));
- };
- wrap.preload = () => (p || (p = fn())).then(mod => mod.default);
- return wrap;
- }
- function For(props) {
- const fallback = "fallback" in props && {
- fallback: () => props.fallback
- };
- return createMemo(mapArray(() => props.each, props.children, fallback ? fallback : undefined), undefined, {
- equals: false
- });
- }
- function Index(props) {
- const fallback = "fallback" in props && {
- fallback: () => props.fallback
- };
- return createMemo(indexArray(() => props.each, props.children, fallback ? fallback : undefined), undefined, {
- equals: false
- });
- }
- function Show(props) {
- let strictEqual = false;
- const condition = createMemo(() => props.when, undefined, {
- equals: (a, b) => strictEqual ? a === b : !a === !b
- });
- return createMemo(() => {
- const c = condition();
- if (c) {
- const child = props.children;
- return (strictEqual = typeof child === "function" && child.length > 0) ? untrack(() => child(c)) : child;
- }
- return props.fallback;
- });
- }
- function Switch(props) {
- let strictEqual = false;
- const conditions = children(() => props.children),
- evalConditions = createMemo(() => {
- let conds = conditions();
- if (!Array.isArray(conds)) conds = [conds];
- for (let i = 0; i < conds.length; i++) {
- const c = conds[i].when;
- if (c) return [i, c, conds[i]];
- }
- return [-1];
- }, undefined, {
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
- });
- return createMemo(() => {
- const [index, when, cond] = evalConditions();
- if (index < 0) return props.fallback;
- const c = cond.children;
- return (strictEqual = typeof c === "function" && c.length > 0) ? untrack(() => c(when)) : c;
- });
- }
- function Match(props) {
- return props;
- }
- function ErrorBoundary(props) {
- const [errored, setErrored] = createSignal();
- onError(setErrored);
- let e;
- return createMemo(() => {
- if ((e = errored()) != null) {
- const f = props.fallback;
- return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(null))) : f;
- }
- return props.children;
- });
- }
- const SuspenseListContext = createContext();
- function SuspenseList(props) {
- let index = 0,
- suspenseSetter,
- showContent,
- showFallback;
- const listContext = useContext(SuspenseListContext);
- if (listContext) {
- const [inFallback, setFallback] = createSignal(false);
- suspenseSetter = setFallback;
- [showContent, showFallback] = listContext.register(inFallback);
- }
- const registry = [],
- comp = createComponent(SuspenseListContext.Provider, {
- value: {
- register: inFallback => {
- const [showingContent, showContent] = createSignal(false),
- [showingFallback, showFallback] = createSignal(false);
- registry[index++] = {
- inFallback,
- showContent,
- showFallback
- };
- return [showingContent, showingFallback];
- }
- },
- get children() {
- return props.children;
- }
- });
- createComputed(() => {
- const reveal = props.revealOrder,
- tail = props.tail,
- visibleContent = showContent ? showContent() : true,
- visibleFallback = showFallback ? showFallback() : true,
- reverse = reveal === "backwards";
- if (reveal === "together") {
- const all = registry.every(i => !i.inFallback());
- suspenseSetter && suspenseSetter(!all);
- registry.forEach(i => {
- i.showContent(all && visibleContent);
- i.showFallback(visibleFallback);
- });
- return;
- }
- let stop = false;
- for (let i = 0, len = registry.length; i < len; i++) {
- const n = reverse ? len - i - 1 : i,
- s = registry[n].inFallback();
- if (!stop && !s) {
- registry[n].showContent(visibleContent);
- registry[n].showFallback(visibleFallback);
- } else {
- const next = !stop;
- if (next && suspenseSetter) suspenseSetter(true);
- if (!tail || next && tail === "collapsed") {
- registry[n].showFallback(visibleFallback);
- } else registry[n].showFallback(false);
- stop = true;
- registry[n].showContent(next);
- }
- }
- if (!stop && suspenseSetter) suspenseSetter(false);
- });
- return comp;
- }
- function Suspense(props) {
- let counter = 0,
- showContent,
- showFallback;
- const [inFallback, setFallback] = createSignal(false),
- SuspenseContext = getSuspenseContext(),
- store = {
- increment: () => {
- if (++counter === 1) setFallback(true);
- },
- decrement: () => {
- if (--counter === 0) setFallback(false);
- },
- inFallback,
- effects: [],
- resolved: false
- };
- const listContext = useContext(SuspenseListContext);
- if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
- return createComponent(SuspenseContext.Provider, {
- value: store,
- get children() {
- const rendered = untrack(() => props.children);
- return createMemo(() => {
- const inFallback = store.inFallback(),
- visibleContent = showContent ? showContent() : true,
- visibleFallback = showFallback ? showFallback() : true;
- if (!inFallback && visibleContent) {
- store.resolved = true;
- resumeEffects(store.effects);
- return rendered;
- }
- if (!visibleFallback) return;
- return props.fallback;
- });
- }
- });
- }
- function awaitSuspense() {}
- let DEV;
- exports.$RAW = $RAW;
- exports.DEV = DEV;
- exports.ErrorBoundary = ErrorBoundary;
- exports.For = For;
- exports.Index = Index;
- exports.Match = Match;
- exports.Show = Show;
- exports.Suspense = Suspense;
- exports.SuspenseList = SuspenseList;
- exports.Switch = Switch;
- exports.awaitSuspense = awaitSuspense;
- exports.batch = batch;
- exports.cancelCallback = cancelCallback;
- exports.children = children;
- exports.createComponent = createComponent;
- exports.createComputed = createComputed;
- exports.createContext = createContext;
- exports.createDeferred = createDeferred;
- exports.createEffect = createEffect;
- exports.createMemo = createMemo;
- exports.createMutable = createMutable;
- exports.createRenderEffect = createRenderEffect;
- exports.createResource = createResource;
- exports.createRoot = createRoot;
- exports.createSelector = createSelector;
- exports.createSignal = createSignal;
- exports.createState = createState;
- exports.equalFn = equalFn;
- exports.getListener = getListener;
- exports.getOwner = getOwner;
- exports.indexArray = indexArray;
- exports.lazy = lazy;
- exports.mapArray = mapArray;
- exports.mergeProps = mergeProps;
- exports.observable = observable;
- exports.on = on;
- exports.onCleanup = onCleanup;
- exports.onError = onError;
- exports.onMount = onMount;
- exports.produce = produce;
- exports.reconcile = reconcile;
- exports.requestCallback = requestCallback;
- exports.runWithOwner = runWithOwner;
- exports.sharedConfig = sharedConfig;
- exports.splitProps = splitProps;
- exports.untrack = untrack;
- exports.unwrap = unwrap;
- exports.useContext = useContext;
- exports.useTransition = useTransition;
|