@torpor/view 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{fromWebSocket-DeB35Q4w.d.cts → AsyncOptions-BtMe2PAd.d.cts} +21 -2
- package/dist/AsyncOptions-BtMe2PAd.d.cts.map +1 -0
- package/dist/{fromWebSocket-B52kN3-W.d.mts → AsyncOptions-ClS1_ERX.d.mts} +21 -2
- package/dist/AsyncOptions-ClS1_ERX.d.mts.map +1 -0
- package/dist/{Effect-BTKurOpr.d.mts → Effect-DazmAdyC.d.mts} +3 -3
- package/dist/{Effect-BTKurOpr.d.mts.map → Effect-DazmAdyC.d.mts.map} +1 -1
- package/dist/{Effect-COl3aRJV.d.cts → Effect-Dewn7MLc.d.cts} +3 -3
- package/dist/{Effect-COl3aRJV.d.cts.map → Effect-Dewn7MLc.d.cts.map} +1 -1
- package/dist/compile.cjs +284 -224
- package/dist/compile.mjs +284 -224
- package/dist/compile.mjs.map +1 -1
- package/dist/dev.d.cts +1 -1
- package/dist/dev.d.mts +1 -1
- package/dist/{fromWebSocket-Dxc_uwm1.mjs → fromWebSocket-CFGoMkV2.mjs} +9 -7
- package/dist/{fromWebSocket-Dxc_uwm1.mjs.map → fromWebSocket-CFGoMkV2.mjs.map} +1 -1
- package/dist/{fromWebSocket-1QOjcrHE.cjs → fromWebSocket-DrN-IduP.cjs} +8 -6
- package/dist/index.cjs +121 -41
- package/dist/index.d.cts +33 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +33 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +121 -42
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.cjs +293 -5
- package/dist/ssr.d.cts +108 -9
- package/dist/ssr.d.cts.map +1 -1
- package/dist/ssr.d.mts +108 -9
- package/dist/ssr.d.mts.map +1 -1
- package/dist/ssr.mjs +292 -6
- package/dist/ssr.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/fromWebSocket-B52kN3-W.d.mts.map +0 -1
- package/dist/fromWebSocket-DeB35Q4w.d.cts.map +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/Animation.ts","../src/render/addAnimation.ts","../src/render/addEvent.ts","../src/render/addElement.ts","../src/render/addFragment.ts","../src/render/applyProps.ts","../src/render/clearLayoutSlot.ts","../src/render/fillLayoutSlot.ts","../src/render/formatText.ts","../src/render/firstInsideNode.ts","../src/render/getFragment.ts","../src/render/getElementFragment.ts","../src/render/hydrate.ts","../src/render/mount.ts","../src/render/unmount.ts","../src/types/ListItemSpec.ts","../src/types/ListItem.ts","../src/render/newListItem.ts","../src/render/newRegion.ts","../src/render/nodeAnchor.ts","../src/render/nodeChild.ts","../src/render/nodeNext.ts","../src/render/nodeRootElement.ts","../src/render/nodeRoot.ts","../src/render/nodeSkip.ts","../src/render/popRegion.ts","../src/render/pushRegion.ts","../src/render/rerunRegionEffects.ts","../src/render/restoreHydration.ts","../src/render/runControl.ts","../src/render/runControlBranch.ts","../src/render/runList.ts","../src/render/runAwait.ts","../src/render/runTry.ts","../src/render/saveHydration.ts","../src/render/setAttribute.ts","../src/render/setDynamicElement.ts","../src/types/Bindable.ts","../src/watch/$batch.ts","../src/watch/$async.ts","../src/watch/$bind.ts","../src/watch/$cache.ts","../src/watch/$onmount.ts","../src/watch/$peek.ts","../src/watch/$pending.ts","../src/watch/$refresh.ts","../src/watch/$run.ts","../src/watch/$stream.ts","../src/watch/$unwrap.ts","../src/types/WatchOptions.ts","../src/watch/$watch.ts"],"mappings":";;;;;UAAyB;EACxB,WAAW,aAAa;EACxB,mBAAmB;;;;iBCCI,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;iBCiBJ,WAAW,MAAM,SAAS,QAAQ,YAAY,QA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MAAM;;;;;;;iBCLvB,WACvB,QAAQ,QACR,QAAQ,aACR,SAAS,QAAQ,sBACjB;;;iBCZuB,iBAAiB,QAAQ,QAAQ,kBAAkB;;;;;;;;;;;;;;;iBCkBnD,QACvB,QAAQ,QACR,QAAQ,YACR,QAAQ,aACR,kBAAkB,gBAClB,SAAS,MAAM,UAAU,QAAQ,sBACjC,SAAS,SAAS,UAAU,SAAS,uBACrC
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/Animation.ts","../src/render/addAnimation.ts","../src/render/addEvent.ts","../src/render/addElement.ts","../src/render/addFragment.ts","../src/render/applyProps.ts","../src/render/clearLayoutSlot.ts","../src/render/fillLayoutSlot.ts","../src/render/formatText.ts","../src/render/firstInsideNode.ts","../src/render/getFragment.ts","../src/render/getElementFragment.ts","../src/render/hydrate.ts","../src/render/mount.ts","../src/render/unmount.ts","../src/types/ListItemSpec.ts","../src/types/ListItem.ts","../src/render/newListItem.ts","../src/render/newRegion.ts","../src/render/nodeAnchor.ts","../src/render/nodeChild.ts","../src/render/nodeNext.ts","../src/render/nodeRootElement.ts","../src/render/nodeRoot.ts","../src/render/nodeSkip.ts","../src/render/popRegion.ts","../src/render/pushRegion.ts","../src/render/rerunRegionEffects.ts","../src/render/restoreHydration.ts","../src/render/runControl.ts","../src/render/runControlBranch.ts","../src/render/runList.ts","../src/render/runAwait.ts","../src/render/runTry.ts","../src/render/saveHydration.ts","../src/render/headElement.ts","../src/render/setAttribute.ts","../src/render/setDynamicElement.ts","../src/types/Bindable.ts","../src/watch/$batch.ts","../src/watch/$async.ts","../src/watch/$bind.ts","../src/watch/$cache.ts","../src/watch/$onmount.ts","../src/watch/$peek.ts","../src/watch/$pending.ts","../src/watch/$refresh.ts","../src/watch/$run.ts","../src/watch/$stream.ts","../src/watch/$unwrap.ts","../src/types/WatchOptions.ts","../src/watch/$watch.ts"],"mappings":";;;;;UAAyB;EACxB,WAAW,aAAa;EACxB,mBAAmB;;;;iBCCI,aA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;;;;;;;;;;;;iBCcvB,SAAS;;;;;;UCZhB;;;;;;;;EAQhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4CuB,SAAS,eAAe,UAAU;;;;;;;;;;iBChDlC,KACvB,UAAU,gBACV,eACA,UAAU,KAAK,0CACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCqBqB,QAAQ,GAC/B,QAAQ,aAAa,IACrB,UAAU,OAAO,YACjB;EAAY;;;;;;;;;iBCrCW,QAAQ,UAAU,OAAO,mBAAmB,QAAQ,IAAI;;;;;;UCJvD;;;;EAIxB;;;;;;;;;;;;;iBCoBuB,OAAO,kBAAkB,QAAQ,GAAG,UAAU,eAAe"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as devContext } from "./devContext-ZNsPyOgB.mjs";
|
|
2
|
-
import { a as buildStyles, c as proxyDataSymbol, i as formatText, n as fromServer, o as buildClasses, r as fromElement, s as $unwrap, t as fromWebSocket } from "./fromWebSocket-
|
|
2
|
+
import { a as buildStyles, c as proxyDataSymbol, i as formatText, n as fromServer, o as buildClasses, r as fromElement, s as $unwrap, t as fromWebSocket } from "./fromWebSocket-CFGoMkV2.mjs";
|
|
3
3
|
//#region src/render/context.ts
|
|
4
4
|
const CONTEXT_SYMBOL = Symbol.for("torp.Context");
|
|
5
5
|
const context = globalThis[CONTEXT_SYMBOL] ??= {
|
|
@@ -23,7 +23,8 @@ const context = globalThis[CONTEXT_SYMBOL] ??= {
|
|
|
23
23
|
mountEffects: [],
|
|
24
24
|
stashedEvents: [],
|
|
25
25
|
stashedAnimations: [],
|
|
26
|
-
hydrationNode: null
|
|
26
|
+
hydrationNode: null,
|
|
27
|
+
serverValues: null
|
|
27
28
|
};
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/render/addAnimation.ts
|
|
@@ -150,9 +151,11 @@ function checkComputed(computed) {
|
|
|
150
151
|
*/
|
|
151
152
|
function checkSources(target) {
|
|
152
153
|
let haveComputed = false;
|
|
153
|
-
for (let sourceSub = target.firstSource; sourceSub !== null; sourceSub = sourceSub.nextSource) if (sourceSub.recalc)
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
for (let sourceSub = target.firstSource; sourceSub !== null; sourceSub = sourceSub.nextSource) if (sourceSub.recalc) {
|
|
155
|
+
if (sourceSub.source.type === 0) return true;
|
|
156
|
+
else if (sourceSub.source.recalc) haveComputed = true;
|
|
157
|
+
else return true;
|
|
158
|
+
}
|
|
156
159
|
if (haveComputed) {
|
|
157
160
|
for (let sourceSub = target.firstSource; sourceSub !== null; sourceSub = sourceSub.nextSource) if (sourceSub.recalc && sourceSub.source.type === 1 && sourceSub.source.recalc) {
|
|
158
161
|
const oldActiveTarget = context.activeTarget;
|
|
@@ -728,13 +731,15 @@ function addFragment(fragment, parent, before, endNode, startNode) {
|
|
|
728
731
|
//#region src/render/applyProps.ts
|
|
729
732
|
function applyProps(el, props, propNamesUsed) {
|
|
730
733
|
if (props !== void 0) {
|
|
731
|
-
for (let [name, value] of Object.entries(props)) if (!propNamesUsed.includes(name))
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
734
|
+
for (let [name, value] of Object.entries(props)) if (!propNamesUsed.includes(name)) {
|
|
735
|
+
if (name.startsWith("on")) {
|
|
736
|
+
const eventName = name.substring(2);
|
|
737
|
+
if (isDelegatedEventType(eventName)) attachDelegatedEvent(el, eventName, value);
|
|
738
|
+
else el.addEventListener(eventName, value);
|
|
739
|
+
} else $run(function setAttribute() {
|
|
740
|
+
el.setAttribute(name, value);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
738
743
|
}
|
|
739
744
|
}
|
|
740
745
|
//#endregion
|
|
@@ -930,16 +935,18 @@ function firstInsideNode(anchor) {
|
|
|
930
935
|
//#endregion
|
|
931
936
|
//#region src/render/getFragment.ts
|
|
932
937
|
function getFragment(document, array, index, html, ns) {
|
|
933
|
-
if (array[index] === void 0)
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
938
|
+
if (array[index] === void 0) {
|
|
939
|
+
if (ns === true) {
|
|
940
|
+
const template = document.createElementNS("http://www.w3.org/2000/svg", "template");
|
|
941
|
+
template.innerHTML = html;
|
|
942
|
+
const fragment = new DocumentFragment();
|
|
943
|
+
fragment.append(...template.childNodes);
|
|
944
|
+
array[index] = fragment;
|
|
945
|
+
} else {
|
|
946
|
+
const template = document.createElement("template");
|
|
947
|
+
template.innerHTML = html;
|
|
948
|
+
array[index] = template.content;
|
|
949
|
+
}
|
|
943
950
|
}
|
|
944
951
|
return array[index].cloneNode(true);
|
|
945
952
|
}
|
|
@@ -970,14 +977,16 @@ function getFragment(document, array, index, html, ns) {
|
|
|
970
977
|
* `firstElementChild` is then an SVG element).
|
|
971
978
|
*/
|
|
972
979
|
function getElementFragment(document, array, index, html, ns) {
|
|
973
|
-
if (array[index] === void 0)
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
980
|
+
if (array[index] === void 0) {
|
|
981
|
+
if (ns === true) {
|
|
982
|
+
const template = document.createElementNS("http://www.w3.org/2000/svg", "template");
|
|
983
|
+
template.innerHTML = html;
|
|
984
|
+
array[index] = template.firstElementChild;
|
|
985
|
+
} else {
|
|
986
|
+
const template = document.createElement("template");
|
|
987
|
+
template.innerHTML = html;
|
|
988
|
+
array[index] = template.content.firstElementChild;
|
|
989
|
+
}
|
|
981
990
|
}
|
|
982
991
|
return array[index].cloneNode(true);
|
|
983
992
|
}
|
|
@@ -1538,7 +1547,7 @@ function trackProxySignal(data, key) {
|
|
|
1538
1547
|
* suspend up the cache chain by tainting the active reader, and notifies the
|
|
1539
1548
|
* nearest `@await` boundary.
|
|
1540
1549
|
*
|
|
1541
|
-
* Return value (
|
|
1550
|
+
* Return value (ASYNC.md → "Stale-while-revalidate"): on a refresh suspend
|
|
1542
1551
|
* (the computed has resolved before) returns the previously resolved value
|
|
1543
1552
|
* held in `staleValue`, so readers keep displaying the old content instead of
|
|
1544
1553
|
* a placeholder — an `@await` boundary thus keeps its content mounted
|
|
@@ -2248,10 +2257,23 @@ function runList(region, parent, anchor, buildItems, create, update, noWatch) {
|
|
|
2248
2257
|
//#endregion
|
|
2249
2258
|
//#region src/render/runAwait.ts
|
|
2250
2259
|
/**
|
|
2260
|
+
* Comment prefix marking the embedded `source: "server"` values that the
|
|
2261
|
+
* server writes after a resolved boundary's anchor (`<!--t-await:[...]-->`,
|
|
2262
|
+
* see ASYNC.md → "Server rendering").
|
|
2263
|
+
*/
|
|
2264
|
+
const SERVER_VALUES_PREFIX = "t-await:";
|
|
2265
|
+
/**
|
|
2251
2266
|
* Renders an `@await` boundary. On the first run, content is rendered
|
|
2252
2267
|
* speculatively; if any read inside suspends (`didSuspend`), the boundary
|
|
2253
2268
|
* discards the partial render and shows the `with` branch instead.
|
|
2254
2269
|
*
|
|
2270
|
+
* Hydration of a server-resolved boundary (ASYNC.md → "Server rendering"): when the server
|
|
2271
|
+
* shipped resolved content, its values ride in a payload comment after the
|
|
2272
|
+
* anchor. The boundary renders the content branch *with* hydration enabled
|
|
2273
|
+
* and `$async` seeds its computeds from the payload, so the server's HTML is
|
|
2274
|
+
* adopted directly — no speculative render, no `with`-branch dance, no
|
|
2275
|
+
* fallback flash.
|
|
2276
|
+
*
|
|
2255
2277
|
* Fine-grained updates: on subsequent runs the boundary only decides whether
|
|
2256
2278
|
* to SWITCH branches. It does so from its `pending` set — the suspended
|
|
2257
2279
|
* computeds recorded by `suspendRead` — dropping entries that resolved and
|
|
@@ -2261,7 +2283,7 @@ function runList(region, parent, anchor, buildItems, create, update, noWatch) {
|
|
|
2261
2283
|
* non-suspend dependency changes inside content are left to the child
|
|
2262
2284
|
* effects that read them — the boundary isn't re-run by them at all.
|
|
2263
2285
|
*
|
|
2264
|
-
* Stale-while-revalidate (ASYNC.md
|
|
2286
|
+
* Stale-while-revalidate (ASYNC.md): once content has been produced
|
|
2265
2287
|
* (`hasContent`), a subsequent suspend during a refresh does NOT switch to
|
|
2266
2288
|
* the `with` branch — the boundary keeps the stale content mounted. `$async`
|
|
2267
2289
|
* retains the previous resolved value (`Computed.staleValue`) and
|
|
@@ -2283,6 +2305,18 @@ function runAwait(region, anchor, renderContent, renderWith, name) {
|
|
|
2283
2305
|
let first = true;
|
|
2284
2306
|
let hasContent = false;
|
|
2285
2307
|
let theEffect = null;
|
|
2308
|
+
let serverValues = null;
|
|
2309
|
+
if (context.hydrationNode !== null && anchor !== null) {
|
|
2310
|
+
const next = anchor.nextSibling;
|
|
2311
|
+
if (next !== null && isCommentNode(next) && next.data.startsWith(SERVER_VALUES_PREFIX)) {
|
|
2312
|
+
try {
|
|
2313
|
+
serverValues = JSON.parse(next.data.substring(8));
|
|
2314
|
+
} catch {
|
|
2315
|
+
serverValues = null;
|
|
2316
|
+
}
|
|
2317
|
+
next.remove();
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2286
2320
|
const gen = region.generation = (region.generation ?? 0) + 1;
|
|
2287
2321
|
$run(function runAwait() {
|
|
2288
2322
|
if (region.generation !== gen) return;
|
|
@@ -2303,9 +2337,15 @@ function runAwait(region, anchor, renderContent, renderWith, name) {
|
|
|
2303
2337
|
context.awaitBoundary = boundary;
|
|
2304
2338
|
boundary.suspended = false;
|
|
2305
2339
|
const savedHydration = context.hydrationNode;
|
|
2306
|
-
|
|
2340
|
+
const savedServerValues = context.serverValues;
|
|
2341
|
+
if (serverValues !== null && savedHydration !== null) context.serverValues = {
|
|
2342
|
+
values: serverValues,
|
|
2343
|
+
index: 0
|
|
2344
|
+
};
|
|
2345
|
+
else if (savedHydration !== null) context.hydrationNode = null;
|
|
2307
2346
|
renderBranch(0, renderContent);
|
|
2308
|
-
|
|
2347
|
+
context.hydrationNode = savedHydration;
|
|
2348
|
+
context.serverValues = savedServerValues;
|
|
2309
2349
|
context.awaitBoundary = oldBoundary;
|
|
2310
2350
|
if (boundary.suspended && renderWith !== null) renderBranch(1, renderWith);
|
|
2311
2351
|
else if (!boundary.suspended) hasContent = true;
|
|
@@ -2320,10 +2360,12 @@ function runAwait(region, anchor, renderContent, renderWith, name) {
|
|
|
2320
2360
|
const targetIndex = suspended ? 1 : 0;
|
|
2321
2361
|
if (targetIndex !== index) {
|
|
2322
2362
|
if (targetIndex === 0) attemptContent();
|
|
2323
|
-
else if (!hasContent)
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2363
|
+
else if (!hasContent) {
|
|
2364
|
+
if (renderWith !== null) renderBranch(1, renderWith);
|
|
2365
|
+
else {
|
|
2366
|
+
runControlBranch(region, index, 1);
|
|
2367
|
+
index = 1;
|
|
2368
|
+
}
|
|
2327
2369
|
}
|
|
2328
2370
|
}
|
|
2329
2371
|
}
|
|
@@ -2445,6 +2487,23 @@ function runTry(region, anchor, renderTry, renderCatch, name) {
|
|
|
2445
2487
|
}, name);
|
|
2446
2488
|
}
|
|
2447
2489
|
//#endregion
|
|
2490
|
+
//#region src/render/headElement.ts
|
|
2491
|
+
/**
|
|
2492
|
+
* Gets an element from the document head matching the selector, creating and
|
|
2493
|
+
* appending a new one if there isn't a match. Used by the code generated for
|
|
2494
|
+
* a @head block, so that elements which were server rendered (or rendered by
|
|
2495
|
+
* a previously visited page) are adopted rather than duplicated.
|
|
2496
|
+
*/
|
|
2497
|
+
function headElement(tagName, selector) {
|
|
2498
|
+
if (selector) {
|
|
2499
|
+
const existing = document.head.querySelector(selector);
|
|
2500
|
+
if (existing) return existing;
|
|
2501
|
+
}
|
|
2502
|
+
const element = document.createElement(tagName);
|
|
2503
|
+
document.head.appendChild(element);
|
|
2504
|
+
return element;
|
|
2505
|
+
}
|
|
2506
|
+
//#endregion
|
|
2448
2507
|
//#region src/render/setAttribute.ts
|
|
2449
2508
|
function setAttribute(el, name, value) {
|
|
2450
2509
|
if (value === false || value === void 0 || value === null) el.removeAttribute(name);
|
|
@@ -2490,10 +2549,20 @@ function $batch(fn) {
|
|
|
2490
2549
|
* over the computed object), so they fire on both the initial run and every
|
|
2491
2550
|
* recalculation — `runComputed` and `checkComputed` are unchanged.
|
|
2492
2551
|
*
|
|
2552
|
+
* Hydration seeding (ASYNC.md → "Server rendering"): while hydrating the content branch of
|
|
2553
|
+
* a boundary whose server HTML embedded resolved `source: "server"` values,
|
|
2554
|
+
* `context.serverValues` is set, and this read consumes the value at the
|
|
2555
|
+
* current position instead of suspending. The thunk still runs — once, in
|
|
2556
|
+
* the background — so the getter's dependencies are tracked and later
|
|
2557
|
+
* dependency changes re-fetch; the embedded value wins the generation race,
|
|
2558
|
+
* so there's no re-fetch wait and no fallback flash.
|
|
2559
|
+
*
|
|
2493
2560
|
* @param fn A thunk returning the Promise to await. Signal reads inside `fn`
|
|
2494
2561
|
* are tracked, so the fetch re-runs when dependencies change.
|
|
2562
|
+
* @param _options Accepted so the same getter source compiles into client and
|
|
2563
|
+
* server builds (`source: "server"` fetches during SSR); ignored here.
|
|
2495
2564
|
*/
|
|
2496
|
-
function $async(fn) {
|
|
2565
|
+
function $async(fn, _options) {
|
|
2497
2566
|
if (context.registerComputed === null) throw new Error("$async must be used in a getter");
|
|
2498
2567
|
const computed = {
|
|
2499
2568
|
type: 1,
|
|
@@ -2546,6 +2615,16 @@ function $async(fn) {
|
|
|
2546
2615
|
};
|
|
2547
2616
|
context.registerComputed(computed);
|
|
2548
2617
|
runComputed(computed);
|
|
2618
|
+
const serverValues = context.serverValues;
|
|
2619
|
+
if (serverValues !== null && serverValues.index < serverValues.values.length) {
|
|
2620
|
+
computed.generation++;
|
|
2621
|
+
computed.didSuspend = false;
|
|
2622
|
+
computed.didError = false;
|
|
2623
|
+
computed.hasResolved = true;
|
|
2624
|
+
computed.lastErrored = false;
|
|
2625
|
+
computed.value = serverValues.values[serverValues.index++];
|
|
2626
|
+
computed.staleValue = computed.value;
|
|
2627
|
+
}
|
|
2549
2628
|
return computed.value;
|
|
2550
2629
|
}
|
|
2551
2630
|
//#endregion
|
|
@@ -2675,7 +2754,7 @@ function $onmount(fn) {
|
|
|
2675
2754
|
* subscription but don't propagate taint or notify a `@await` boundary.
|
|
2676
2755
|
* This lets `$pending` return a plain boolean without itself suspending.
|
|
2677
2756
|
*
|
|
2678
|
-
* Quiet-on-refresh semantics (ASYNC.md
|
|
2757
|
+
* Quiet-on-refresh semantics (ASYNC.md → "Loud vs quiet"): a suspend is *quiet* — and
|
|
2679
2758
|
* therefore `$pending` returns `false` for it — when the computed has resolved
|
|
2680
2759
|
* before and the re-fetch was a *silent* `$refresh(fn, { silent: true })` (a
|
|
2681
2760
|
* bare refresh with no tracked dependency change, used for background
|
|
@@ -2702,7 +2781,7 @@ function $pending(fn) {
|
|
|
2702
2781
|
//#region src/watch/$refresh.ts
|
|
2703
2782
|
/**
|
|
2704
2783
|
* Re-fetches the `$async` getters read inside `fn` without changing a
|
|
2705
|
-
* dependency. A companion to `$pending` (ASYNC.md
|
|
2784
|
+
* dependency. A companion to `$pending` (ASYNC.md): pull-to-refresh,
|
|
2706
2785
|
* refresh buttons, refetch-on-focus, polling, retry-after-error.
|
|
2707
2786
|
*
|
|
2708
2787
|
* `fn` is run in a tracking context that collects every `$async` computed it
|
|
@@ -2841,6 +2920,6 @@ function $stream(source, handler, options) {
|
|
|
2841
2920
|
});
|
|
2842
2921
|
}
|
|
2843
2922
|
//#endregion
|
|
2844
|
-
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, firstInsideNode as t_first_inside, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
2923
|
+
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, firstInsideNode as t_first_inside, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, headElement as t_head_element, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
2845
2924
|
|
|
2846
2925
|
//# sourceMappingURL=index.mjs.map
|