@torpor/view 1.2.5 → 1.2.6
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/{AsyncOptions-ClS1_ERX.d.mts → AsyncOptions-BDtArmeL.d.mts} +2 -8
- package/dist/AsyncOptions-BDtArmeL.d.mts.map +1 -0
- package/dist/{AsyncOptions-BtMe2PAd.d.cts → AsyncOptions-C_7mWR6F.d.cts} +2 -8
- package/dist/AsyncOptions-C_7mWR6F.d.cts.map +1 -0
- package/dist/compile.cjs +13 -21
- package/dist/compile.mjs +13 -21
- package/dist/compile.mjs.map +1 -1
- package/dist/index.cjs +102 -83
- package/dist/index.d.cts +12 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +102 -83
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.cjs +28 -2
- package/dist/ssr.d.cts +22 -2
- package/dist/ssr.d.cts.map +1 -1
- package/dist/ssr.d.mts +22 -2
- package/dist/ssr.d.mts.map +1 -1
- package/dist/ssr.mjs +27 -1
- package/dist/ssr.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/AsyncOptions-BtMe2PAd.d.cts.map +0 -1
- package/dist/AsyncOptions-ClS1_ERX.d.mts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,75 @@ function addEvent(el, type, listener) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
+
//#region src/render/isTextNode.ts
|
|
51
|
+
function isTextNode(node) {
|
|
52
|
+
return node.nodeType === 3;
|
|
53
|
+
}
|
|
54
|
+
const HYDRATION_BREAK_REGEX = /^\^(?:\d+)?$/;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a comment node's data is a branch-break marker (`^`, or `^<index>`
|
|
57
|
+
* when the server recorded the branch it rendered).
|
|
58
|
+
*/
|
|
59
|
+
function isHydrationBreak(data) {
|
|
60
|
+
return HYDRATION_BREAK_REGEX.test(data);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The branch index encoded in a `^<index>` branch-break marker, or `undefined`
|
|
64
|
+
* for a plain `^` marker (e.g. from `@for`, which has no branch index).
|
|
65
|
+
*/
|
|
66
|
+
function hydrationBreakIndex(data) {
|
|
67
|
+
if (!data.startsWith("^") || data.length === 1) return;
|
|
68
|
+
const index = Number(data.slice(1));
|
|
69
|
+
return Number.isNaN(index) ? void 0 : index;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/render/isCommentNode.ts
|
|
73
|
+
function isCommentNode(node) {
|
|
74
|
+
return node.nodeType === 8;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/render/nodeCheckHydrationBreak.ts
|
|
78
|
+
/**
|
|
79
|
+
* When hydrating, removes and skips hydration comments that are inserted at the
|
|
80
|
+
* start of branches and used to split up text nodes that would otherwise be
|
|
81
|
+
* joined in HTML.
|
|
82
|
+
*
|
|
83
|
+
* @param node The node to check and maybe skip.
|
|
84
|
+
* @returns The next node.
|
|
85
|
+
*/
|
|
86
|
+
function nodeCheckHydrationBreak(node) {
|
|
87
|
+
if (node !== null && isCommentNode(node) && isHydrationBreak(node.data)) {
|
|
88
|
+
let comment = node;
|
|
89
|
+
node = node.nextSibling;
|
|
90
|
+
comment.remove();
|
|
91
|
+
}
|
|
92
|
+
context.hydrationNode = node;
|
|
93
|
+
return node;
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/render/nodeNext.ts
|
|
97
|
+
/**
|
|
98
|
+
* Gets the next sibling of a node.
|
|
99
|
+
*
|
|
100
|
+
* When hydrating, sets the hydration node.
|
|
101
|
+
*
|
|
102
|
+
* @param node The node.
|
|
103
|
+
* @param text Whether we require a text node.
|
|
104
|
+
*/
|
|
105
|
+
function nodeNext(node, text = false) {
|
|
106
|
+
if (context.hydrationNode !== null) {
|
|
107
|
+
if (text && isTextNode(node)) return node;
|
|
108
|
+
let next = nodeCheckHydrationBreak(node.nextSibling);
|
|
109
|
+
while (!text && next !== null && isTextNode(next) && next.textContent?.trim() === "") next = nodeCheckHydrationBreak(next.nextSibling);
|
|
110
|
+
if (!text && next !== null && next.nodeName === "TBODY" && next.firstChild && isTextNode(node)) {
|
|
111
|
+
next = next.firstChild;
|
|
112
|
+
context.hydrationNode = next;
|
|
113
|
+
}
|
|
114
|
+
return next;
|
|
115
|
+
}
|
|
116
|
+
return node.nextSibling;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
50
119
|
//#region src/watch/clearSources.ts
|
|
51
120
|
/**
|
|
52
121
|
* Clear unused source subscriptions after each Computed or Effect has been run.
|
|
@@ -840,6 +909,7 @@ function addElement(node, parent, before) {
|
|
|
840
909
|
parent = before?.parentNode ?? parent;
|
|
841
910
|
if (hydrationNode === null) parent.insertBefore(node, before);
|
|
842
911
|
runMountSideEffects(parent, activeRegion, hydrationNode);
|
|
912
|
+
if (hydrationNode !== null) nodeNext(node);
|
|
843
913
|
}
|
|
844
914
|
//#endregion
|
|
845
915
|
//#region src/render/addFragment.ts
|
|
@@ -856,6 +926,7 @@ function addFragment(fragment, parent, before, endNode, startNode) {
|
|
|
856
926
|
parent = before?.parentNode ?? parent;
|
|
857
927
|
if (hydrationNode === null) parent.insertBefore(fragment, before);
|
|
858
928
|
runMountSideEffects(parent, activeRegion, hydrationNode);
|
|
929
|
+
if (hydrationNode !== null && endNode !== void 0) nodeNext(endNode);
|
|
859
930
|
}
|
|
860
931
|
//#endregion
|
|
861
932
|
//#region src/render/applyProps.ts
|
|
@@ -966,19 +1037,6 @@ function releaseRegion(region) {
|
|
|
966
1037
|
region.effects.length = 0;
|
|
967
1038
|
}
|
|
968
1039
|
//#endregion
|
|
969
|
-
//#region src/render/clearLayoutSlot.ts
|
|
970
|
-
/**
|
|
971
|
-
* Clears a region that was created by `fillLayoutSlot`: tears down the
|
|
972
|
-
* rendered content and its effects, leaving the surrounding layout intact
|
|
973
|
-
* so the slot can be refilled.
|
|
974
|
-
*
|
|
975
|
-
* @param region The region to clear
|
|
976
|
-
*/
|
|
977
|
-
function clearLayoutSlot(region) {
|
|
978
|
-
context.previousRegion = region.previousRegion;
|
|
979
|
-
clearRegion(region);
|
|
980
|
-
}
|
|
981
|
-
//#endregion
|
|
982
1040
|
//#region src/render/newRegion.ts
|
|
983
1041
|
function newRegion(name) {
|
|
984
1042
|
return {
|
|
@@ -1018,6 +1076,17 @@ function pushRegion(region, toParent = false) {
|
|
|
1018
1076
|
}
|
|
1019
1077
|
//#endregion
|
|
1020
1078
|
//#region src/render/fillLayoutSlot.ts
|
|
1079
|
+
const refillDepths = /* @__PURE__ */ new WeakMap();
|
|
1080
|
+
/**
|
|
1081
|
+
* Records the depth of a cleared layout-slot region for the fill that replaces
|
|
1082
|
+
* it (see `clearLayoutSlot`).
|
|
1083
|
+
*
|
|
1084
|
+
* @param parent The node the slot renders into
|
|
1085
|
+
* @param depth The cleared region's depth
|
|
1086
|
+
*/
|
|
1087
|
+
function rememberSlotRefillDepth(parent, depth) {
|
|
1088
|
+
refillDepths.set(parent, depth);
|
|
1089
|
+
}
|
|
1021
1090
|
/**
|
|
1022
1091
|
* Renders a component into a persistent layout slot, and returns the region
|
|
1023
1092
|
* it was rendered into. Used by the layout engine during navigation: the
|
|
@@ -1036,12 +1105,31 @@ function pushRegion(region, toParent = false) {
|
|
|
1036
1105
|
function fillLayoutSlot(component, slot, parent, anchor, $props, $context) {
|
|
1037
1106
|
const region = newRegion(require_devContext.devContext.enabled ? "Layout slot" : void 0);
|
|
1038
1107
|
const oldRegion = pushRegion(region, true);
|
|
1039
|
-
|
|
1108
|
+
const refillDepth = refillDepths.get(parent);
|
|
1109
|
+
if (refillDepth !== void 0) {
|
|
1110
|
+
region.depth = refillDepth;
|
|
1111
|
+
refillDepths.delete(parent);
|
|
1112
|
+
}
|
|
1040
1113
|
component(parent, anchor, $props, $context, { _: slot });
|
|
1041
1114
|
popRegion(oldRegion);
|
|
1042
1115
|
return region;
|
|
1043
1116
|
}
|
|
1044
1117
|
//#endregion
|
|
1118
|
+
//#region src/render/clearLayoutSlot.ts
|
|
1119
|
+
/**
|
|
1120
|
+
* Clears a region that was created by `fillLayoutSlot`: tears down the
|
|
1121
|
+
* rendered content and its effects, leaving the surrounding layout intact
|
|
1122
|
+
* so the slot can be refilled.
|
|
1123
|
+
*
|
|
1124
|
+
* @param region The region to clear
|
|
1125
|
+
*/
|
|
1126
|
+
function clearLayoutSlot(region) {
|
|
1127
|
+
context.previousRegion = region.previousRegion;
|
|
1128
|
+
const parent = region.startNode?.parentNode;
|
|
1129
|
+
if (parent) rememberSlotRefillDepth(parent, region.depth);
|
|
1130
|
+
clearRegion(region);
|
|
1131
|
+
}
|
|
1132
|
+
//#endregion
|
|
1045
1133
|
//#region src/render/firstInsideNode.ts
|
|
1046
1134
|
/**
|
|
1047
1135
|
* During hydration, `nodeAnchor` finds the first node inside a hydration
|
|
@@ -1248,75 +1336,6 @@ function takeBranchIndex(anchor) {
|
|
|
1248
1336
|
if (index !== void 0) branchIndexes.delete(anchor);
|
|
1249
1337
|
return index;
|
|
1250
1338
|
}
|
|
1251
|
-
const HYDRATION_BREAK_REGEX = /^\^(?:\d+)?$/;
|
|
1252
|
-
/**
|
|
1253
|
-
* Whether a comment node's data is a branch-break marker (`^`, or `^<index>`
|
|
1254
|
-
* when the server recorded the branch it rendered).
|
|
1255
|
-
*/
|
|
1256
|
-
function isHydrationBreak(data) {
|
|
1257
|
-
return HYDRATION_BREAK_REGEX.test(data);
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* The branch index encoded in a `^<index>` branch-break marker, or `undefined`
|
|
1261
|
-
* for a plain `^` marker (e.g. from `@for`, which has no branch index).
|
|
1262
|
-
*/
|
|
1263
|
-
function hydrationBreakIndex(data) {
|
|
1264
|
-
if (!data.startsWith("^") || data.length === 1) return;
|
|
1265
|
-
const index = Number(data.slice(1));
|
|
1266
|
-
return Number.isNaN(index) ? void 0 : index;
|
|
1267
|
-
}
|
|
1268
|
-
//#endregion
|
|
1269
|
-
//#region src/render/isCommentNode.ts
|
|
1270
|
-
function isCommentNode(node) {
|
|
1271
|
-
return node.nodeType === 8;
|
|
1272
|
-
}
|
|
1273
|
-
//#endregion
|
|
1274
|
-
//#region src/render/isTextNode.ts
|
|
1275
|
-
function isTextNode(node) {
|
|
1276
|
-
return node.nodeType === 3;
|
|
1277
|
-
}
|
|
1278
|
-
//#endregion
|
|
1279
|
-
//#region src/render/nodeCheckHydrationBreak.ts
|
|
1280
|
-
/**
|
|
1281
|
-
* When hydrating, removes and skips hydration comments that are inserted at the
|
|
1282
|
-
* start of branches and used to split up text nodes that would otherwise be
|
|
1283
|
-
* joined in HTML.
|
|
1284
|
-
*
|
|
1285
|
-
* @param node The node to check and maybe skip.
|
|
1286
|
-
* @returns The next node.
|
|
1287
|
-
*/
|
|
1288
|
-
function nodeCheckHydrationBreak(node) {
|
|
1289
|
-
if (node !== null && isCommentNode(node) && isHydrationBreak(node.data)) {
|
|
1290
|
-
let comment = node;
|
|
1291
|
-
node = node.nextSibling;
|
|
1292
|
-
comment.remove();
|
|
1293
|
-
}
|
|
1294
|
-
context.hydrationNode = node;
|
|
1295
|
-
return node;
|
|
1296
|
-
}
|
|
1297
|
-
//#endregion
|
|
1298
|
-
//#region src/render/nodeNext.ts
|
|
1299
|
-
/**
|
|
1300
|
-
* Gets the next sibling of a node.
|
|
1301
|
-
*
|
|
1302
|
-
* When hydrating, sets the hydration node.
|
|
1303
|
-
*
|
|
1304
|
-
* @param node The node.
|
|
1305
|
-
* @param text Whether we require a text node.
|
|
1306
|
-
*/
|
|
1307
|
-
function nodeNext(node, text = false) {
|
|
1308
|
-
if (context.hydrationNode !== null) {
|
|
1309
|
-
if (text && isTextNode(node)) return node;
|
|
1310
|
-
let next = nodeCheckHydrationBreak(node.nextSibling);
|
|
1311
|
-
while (!text && next !== null && isTextNode(next) && next.textContent?.trim() === "") next = nodeCheckHydrationBreak(next.nextSibling);
|
|
1312
|
-
if (!text && next !== null && next.nodeName === "TBODY" && next.firstChild && isTextNode(node)) {
|
|
1313
|
-
next = next.firstChild;
|
|
1314
|
-
context.hydrationNode = next;
|
|
1315
|
-
}
|
|
1316
|
-
return next;
|
|
1317
|
-
}
|
|
1318
|
-
return node.nextSibling;
|
|
1319
|
-
}
|
|
1320
1339
|
//#endregion
|
|
1321
1340
|
//#region src/render/nodeAnchor.ts
|
|
1322
1341
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as SlotRender, t as Component } from "./Component-0MH0zd-m.cjs";
|
|
2
2
|
import { t as Cleanup } from "./Cleanup-D0wvGW5d.cjs";
|
|
3
3
|
import { n as Region, t as Effect } from "./Effect-Dewn7MLc.cjs";
|
|
4
|
-
import { a as StreamSource,
|
|
4
|
+
import { a as StreamSource, i as fromElement, n as fromWebSocket, o as StyleValue, r as fromServer, s as ClassValue, t as AsyncOptions } from "./AsyncOptions-C_7mWR6F.cjs";
|
|
5
5
|
//#region src/types/Animation.d.ts
|
|
6
6
|
interface Animation {
|
|
7
7
|
keyframes: Keyframe[] | PropertyIndexedKeyframes;
|
|
@@ -42,6 +42,12 @@ declare function addFragment(fragment: DocumentFragment, parent: ParentNode, bef
|
|
|
42
42
|
//#region src/render/applyProps.d.ts
|
|
43
43
|
declare function applyProps(el: Element, props: Record<string, any> | undefined, propNamesUsed: string[]): void;
|
|
44
44
|
//#endregion
|
|
45
|
+
//#region src/render/buildClasses.d.ts
|
|
46
|
+
declare function buildClasses(value: ClassValue, styleHash?: string): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/render/buildStyles.d.ts
|
|
49
|
+
declare function buildStyles(value: StyleValue): string;
|
|
50
|
+
//#endregion
|
|
45
51
|
//#region src/render/clearLayoutSlot.d.ts
|
|
46
52
|
/**
|
|
47
53
|
* Clears a region that was created by `fillLayoutSlot`: tears down the
|
|
@@ -167,9 +173,13 @@ declare function unmount(parent: ParentNode): void;
|
|
|
167
173
|
* NOTE: `data` is `any` rather than `Record<string, any>` -- when a `@for`
|
|
168
174
|
* body binds a single loop variable and is proxy-safe, the variable is stored
|
|
169
175
|
* directly (e.g. `data: page` for a number), not as a bag.
|
|
176
|
+
*
|
|
177
|
+
* NOTE: `key` is optional -- the compiler only emits it when the `@for` has
|
|
178
|
+
* an `@key` block; unkeyed loops omit it (a missing key behaves the same as
|
|
179
|
+
* an `undefined` one during reconciliation).
|
|
170
180
|
*/
|
|
171
181
|
interface ListItemSpec {
|
|
172
|
-
key
|
|
182
|
+
key?: any;
|
|
173
183
|
data: any;
|
|
174
184
|
}
|
|
175
185
|
//#endregion
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","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,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","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/buildClasses.ts","../src/render/buildStyles.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/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;;iBCLzE,MACvB,OAAO,OAAO,mBACd,OAAO,OAAO,kCACX;;;;;;;;iBC5BoB,OAAO,GAAG,UAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;iBCcxB,SAAS,UAAU;;;;;;;;;;;iBCdnB,MAAM,GAAG,UAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;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.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as SlotRender, t as Component } from "./Component-0MH0zd-m.mjs";
|
|
2
2
|
import { t as Cleanup } from "./Cleanup-D0wvGW5d.mjs";
|
|
3
3
|
import { n as Region, t as Effect } from "./Effect-DazmAdyC.mjs";
|
|
4
|
-
import { a as StreamSource,
|
|
4
|
+
import { a as StreamSource, i as fromElement, n as fromWebSocket, o as StyleValue, r as fromServer, s as ClassValue, t as AsyncOptions } from "./AsyncOptions-BDtArmeL.mjs";
|
|
5
5
|
//#region src/types/Animation.d.ts
|
|
6
6
|
interface Animation {
|
|
7
7
|
keyframes: Keyframe[] | PropertyIndexedKeyframes;
|
|
@@ -42,6 +42,12 @@ declare function addFragment(fragment: DocumentFragment, parent: ParentNode, bef
|
|
|
42
42
|
//#region src/render/applyProps.d.ts
|
|
43
43
|
declare function applyProps(el: Element, props: Record<string, any> | undefined, propNamesUsed: string[]): void;
|
|
44
44
|
//#endregion
|
|
45
|
+
//#region src/render/buildClasses.d.ts
|
|
46
|
+
declare function buildClasses(value: ClassValue, styleHash?: string): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/render/buildStyles.d.ts
|
|
49
|
+
declare function buildStyles(value: StyleValue): string;
|
|
50
|
+
//#endregion
|
|
45
51
|
//#region src/render/clearLayoutSlot.d.ts
|
|
46
52
|
/**
|
|
47
53
|
* Clears a region that was created by `fillLayoutSlot`: tears down the
|
|
@@ -167,9 +173,13 @@ declare function unmount(parent: ParentNode): void;
|
|
|
167
173
|
* NOTE: `data` is `any` rather than `Record<string, any>` -- when a `@for`
|
|
168
174
|
* body binds a single loop variable and is proxy-safe, the variable is stored
|
|
169
175
|
* directly (e.g. `data: page` for a number), not as a bag.
|
|
176
|
+
*
|
|
177
|
+
* NOTE: `key` is optional -- the compiler only emits it when the `@for` has
|
|
178
|
+
* an `@key` block; unkeyed loops omit it (a missing key behaves the same as
|
|
179
|
+
* an `undefined` one during reconciliation).
|
|
170
180
|
*/
|
|
171
181
|
interface ListItemSpec {
|
|
172
|
-
key
|
|
182
|
+
key?: any;
|
|
173
183
|
data: any;
|
|
174
184
|
}
|
|
175
185
|
//#endregion
|
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/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,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;
|
|
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/buildClasses.ts","../src/render/buildStyles.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,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;iBCkBJ,WAAW,MAAM,SAAS,QAAQ,YAAY,QAAQ;;;iBCnBtD,YACvB,UAAU,kBACV,QAAQ,YACR,QAAQ,aACR,UAAU,WACV,YAAY;;;iBCNW,WACvB,IAAI,SACJ,OAAO,iCACP;;;iBCHuB,aAAa,OAAO,YAAY;;;iBCChC,YAAY,OAAO;;;;;;;;;;iBCQnB,gBAAgB,QAAQ;;;;;;;;;;;;;;;;;;iBC6BxB,eACvB,WAAW,WACX,MAAM,YACN,QAAQ,YACR,QAAQ,aACR,SAAS,OAAO,mBAChB,WAAW,OAAO,oBAChB;;;iBC9CqB,WAAW;;;;;;;;iBCiBX,gBAAgB,QAAQ,YAAY;;;iBCnBpC,YACvB,UAAU,UACV,OAAO,oBACP,eACA,cACA,eACE;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCkBqB,mBACvB,UAAU,UACV,OAAO,WACP,eACA,cACA,eACE;;;;;;;;;iBCfqB,QACvB,QAAQ,YACR,WAAW,WACX,QAAQ,qBACR,QAAQ,eAAe;;;;;;;;;;;;;;;;iBCEA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B,iBAAiB;;;;;;;;;iBCFjB,YAAY,iBAAiB,mBAAmB;;;iBCNhD,aAAa,IAAI,SAAS,cAAc;;;iBCKxC,kBAAkB,IAAI,aAAa,cAAc;;;;;;;;;;;;;;;;;;;KCWpE,SAAS,KAAK;;;;;;;;;iBCNK,OAAO,GAAG,UAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC8BxB,OAAO,GAAG,KAAK,cAAc,MAAM,QAAQ,IAAI,WAAW,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCLzE,MACvB,OAAO,OAAO,mBACd,OAAO,OAAO,kCACX;;;;;;;;iBC5BoB,OAAO,GAAG,UAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;iBCcxB,SAAS,UAAU;;;;;;;;;;;iBCdnB,MAAM,GAAG,UAAU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;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
|
@@ -46,6 +46,75 @@ function addEvent(el, type, listener) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
|
+
//#region src/render/isTextNode.ts
|
|
50
|
+
function isTextNode(node) {
|
|
51
|
+
return node.nodeType === 3;
|
|
52
|
+
}
|
|
53
|
+
const HYDRATION_BREAK_REGEX = /^\^(?:\d+)?$/;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a comment node's data is a branch-break marker (`^`, or `^<index>`
|
|
56
|
+
* when the server recorded the branch it rendered).
|
|
57
|
+
*/
|
|
58
|
+
function isHydrationBreak(data) {
|
|
59
|
+
return HYDRATION_BREAK_REGEX.test(data);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The branch index encoded in a `^<index>` branch-break marker, or `undefined`
|
|
63
|
+
* for a plain `^` marker (e.g. from `@for`, which has no branch index).
|
|
64
|
+
*/
|
|
65
|
+
function hydrationBreakIndex(data) {
|
|
66
|
+
if (!data.startsWith("^") || data.length === 1) return;
|
|
67
|
+
const index = Number(data.slice(1));
|
|
68
|
+
return Number.isNaN(index) ? void 0 : index;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/render/isCommentNode.ts
|
|
72
|
+
function isCommentNode(node) {
|
|
73
|
+
return node.nodeType === 8;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/render/nodeCheckHydrationBreak.ts
|
|
77
|
+
/**
|
|
78
|
+
* When hydrating, removes and skips hydration comments that are inserted at the
|
|
79
|
+
* start of branches and used to split up text nodes that would otherwise be
|
|
80
|
+
* joined in HTML.
|
|
81
|
+
*
|
|
82
|
+
* @param node The node to check and maybe skip.
|
|
83
|
+
* @returns The next node.
|
|
84
|
+
*/
|
|
85
|
+
function nodeCheckHydrationBreak(node) {
|
|
86
|
+
if (node !== null && isCommentNode(node) && isHydrationBreak(node.data)) {
|
|
87
|
+
let comment = node;
|
|
88
|
+
node = node.nextSibling;
|
|
89
|
+
comment.remove();
|
|
90
|
+
}
|
|
91
|
+
context.hydrationNode = node;
|
|
92
|
+
return node;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/render/nodeNext.ts
|
|
96
|
+
/**
|
|
97
|
+
* Gets the next sibling of a node.
|
|
98
|
+
*
|
|
99
|
+
* When hydrating, sets the hydration node.
|
|
100
|
+
*
|
|
101
|
+
* @param node The node.
|
|
102
|
+
* @param text Whether we require a text node.
|
|
103
|
+
*/
|
|
104
|
+
function nodeNext(node, text = false) {
|
|
105
|
+
if (context.hydrationNode !== null) {
|
|
106
|
+
if (text && isTextNode(node)) return node;
|
|
107
|
+
let next = nodeCheckHydrationBreak(node.nextSibling);
|
|
108
|
+
while (!text && next !== null && isTextNode(next) && next.textContent?.trim() === "") next = nodeCheckHydrationBreak(next.nextSibling);
|
|
109
|
+
if (!text && next !== null && next.nodeName === "TBODY" && next.firstChild && isTextNode(node)) {
|
|
110
|
+
next = next.firstChild;
|
|
111
|
+
context.hydrationNode = next;
|
|
112
|
+
}
|
|
113
|
+
return next;
|
|
114
|
+
}
|
|
115
|
+
return node.nextSibling;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
49
118
|
//#region src/watch/clearSources.ts
|
|
50
119
|
/**
|
|
51
120
|
* Clear unused source subscriptions after each Computed or Effect has been run.
|
|
@@ -839,6 +908,7 @@ function addElement(node, parent, before) {
|
|
|
839
908
|
parent = before?.parentNode ?? parent;
|
|
840
909
|
if (hydrationNode === null) parent.insertBefore(node, before);
|
|
841
910
|
runMountSideEffects(parent, activeRegion, hydrationNode);
|
|
911
|
+
if (hydrationNode !== null) nodeNext(node);
|
|
842
912
|
}
|
|
843
913
|
//#endregion
|
|
844
914
|
//#region src/render/addFragment.ts
|
|
@@ -855,6 +925,7 @@ function addFragment(fragment, parent, before, endNode, startNode) {
|
|
|
855
925
|
parent = before?.parentNode ?? parent;
|
|
856
926
|
if (hydrationNode === null) parent.insertBefore(fragment, before);
|
|
857
927
|
runMountSideEffects(parent, activeRegion, hydrationNode);
|
|
928
|
+
if (hydrationNode !== null && endNode !== void 0) nodeNext(endNode);
|
|
858
929
|
}
|
|
859
930
|
//#endregion
|
|
860
931
|
//#region src/render/applyProps.ts
|
|
@@ -965,19 +1036,6 @@ function releaseRegion(region) {
|
|
|
965
1036
|
region.effects.length = 0;
|
|
966
1037
|
}
|
|
967
1038
|
//#endregion
|
|
968
|
-
//#region src/render/clearLayoutSlot.ts
|
|
969
|
-
/**
|
|
970
|
-
* Clears a region that was created by `fillLayoutSlot`: tears down the
|
|
971
|
-
* rendered content and its effects, leaving the surrounding layout intact
|
|
972
|
-
* so the slot can be refilled.
|
|
973
|
-
*
|
|
974
|
-
* @param region The region to clear
|
|
975
|
-
*/
|
|
976
|
-
function clearLayoutSlot(region) {
|
|
977
|
-
context.previousRegion = region.previousRegion;
|
|
978
|
-
clearRegion(region);
|
|
979
|
-
}
|
|
980
|
-
//#endregion
|
|
981
1039
|
//#region src/render/newRegion.ts
|
|
982
1040
|
function newRegion(name) {
|
|
983
1041
|
return {
|
|
@@ -1017,6 +1075,17 @@ function pushRegion(region, toParent = false) {
|
|
|
1017
1075
|
}
|
|
1018
1076
|
//#endregion
|
|
1019
1077
|
//#region src/render/fillLayoutSlot.ts
|
|
1078
|
+
const refillDepths = /* @__PURE__ */ new WeakMap();
|
|
1079
|
+
/**
|
|
1080
|
+
* Records the depth of a cleared layout-slot region for the fill that replaces
|
|
1081
|
+
* it (see `clearLayoutSlot`).
|
|
1082
|
+
*
|
|
1083
|
+
* @param parent The node the slot renders into
|
|
1084
|
+
* @param depth The cleared region's depth
|
|
1085
|
+
*/
|
|
1086
|
+
function rememberSlotRefillDepth(parent, depth) {
|
|
1087
|
+
refillDepths.set(parent, depth);
|
|
1088
|
+
}
|
|
1020
1089
|
/**
|
|
1021
1090
|
* Renders a component into a persistent layout slot, and returns the region
|
|
1022
1091
|
* it was rendered into. Used by the layout engine during navigation: the
|
|
@@ -1035,12 +1104,31 @@ function pushRegion(region, toParent = false) {
|
|
|
1035
1104
|
function fillLayoutSlot(component, slot, parent, anchor, $props, $context) {
|
|
1036
1105
|
const region = newRegion(devContext.enabled ? "Layout slot" : void 0);
|
|
1037
1106
|
const oldRegion = pushRegion(region, true);
|
|
1038
|
-
|
|
1107
|
+
const refillDepth = refillDepths.get(parent);
|
|
1108
|
+
if (refillDepth !== void 0) {
|
|
1109
|
+
region.depth = refillDepth;
|
|
1110
|
+
refillDepths.delete(parent);
|
|
1111
|
+
}
|
|
1039
1112
|
component(parent, anchor, $props, $context, { _: slot });
|
|
1040
1113
|
popRegion(oldRegion);
|
|
1041
1114
|
return region;
|
|
1042
1115
|
}
|
|
1043
1116
|
//#endregion
|
|
1117
|
+
//#region src/render/clearLayoutSlot.ts
|
|
1118
|
+
/**
|
|
1119
|
+
* Clears a region that was created by `fillLayoutSlot`: tears down the
|
|
1120
|
+
* rendered content and its effects, leaving the surrounding layout intact
|
|
1121
|
+
* so the slot can be refilled.
|
|
1122
|
+
*
|
|
1123
|
+
* @param region The region to clear
|
|
1124
|
+
*/
|
|
1125
|
+
function clearLayoutSlot(region) {
|
|
1126
|
+
context.previousRegion = region.previousRegion;
|
|
1127
|
+
const parent = region.startNode?.parentNode;
|
|
1128
|
+
if (parent) rememberSlotRefillDepth(parent, region.depth);
|
|
1129
|
+
clearRegion(region);
|
|
1130
|
+
}
|
|
1131
|
+
//#endregion
|
|
1044
1132
|
//#region src/render/firstInsideNode.ts
|
|
1045
1133
|
/**
|
|
1046
1134
|
* During hydration, `nodeAnchor` finds the first node inside a hydration
|
|
@@ -1247,75 +1335,6 @@ function takeBranchIndex(anchor) {
|
|
|
1247
1335
|
if (index !== void 0) branchIndexes.delete(anchor);
|
|
1248
1336
|
return index;
|
|
1249
1337
|
}
|
|
1250
|
-
const HYDRATION_BREAK_REGEX = /^\^(?:\d+)?$/;
|
|
1251
|
-
/**
|
|
1252
|
-
* Whether a comment node's data is a branch-break marker (`^`, or `^<index>`
|
|
1253
|
-
* when the server recorded the branch it rendered).
|
|
1254
|
-
*/
|
|
1255
|
-
function isHydrationBreak(data) {
|
|
1256
|
-
return HYDRATION_BREAK_REGEX.test(data);
|
|
1257
|
-
}
|
|
1258
|
-
/**
|
|
1259
|
-
* The branch index encoded in a `^<index>` branch-break marker, or `undefined`
|
|
1260
|
-
* for a plain `^` marker (e.g. from `@for`, which has no branch index).
|
|
1261
|
-
*/
|
|
1262
|
-
function hydrationBreakIndex(data) {
|
|
1263
|
-
if (!data.startsWith("^") || data.length === 1) return;
|
|
1264
|
-
const index = Number(data.slice(1));
|
|
1265
|
-
return Number.isNaN(index) ? void 0 : index;
|
|
1266
|
-
}
|
|
1267
|
-
//#endregion
|
|
1268
|
-
//#region src/render/isCommentNode.ts
|
|
1269
|
-
function isCommentNode(node) {
|
|
1270
|
-
return node.nodeType === 8;
|
|
1271
|
-
}
|
|
1272
|
-
//#endregion
|
|
1273
|
-
//#region src/render/isTextNode.ts
|
|
1274
|
-
function isTextNode(node) {
|
|
1275
|
-
return node.nodeType === 3;
|
|
1276
|
-
}
|
|
1277
|
-
//#endregion
|
|
1278
|
-
//#region src/render/nodeCheckHydrationBreak.ts
|
|
1279
|
-
/**
|
|
1280
|
-
* When hydrating, removes and skips hydration comments that are inserted at the
|
|
1281
|
-
* start of branches and used to split up text nodes that would otherwise be
|
|
1282
|
-
* joined in HTML.
|
|
1283
|
-
*
|
|
1284
|
-
* @param node The node to check and maybe skip.
|
|
1285
|
-
* @returns The next node.
|
|
1286
|
-
*/
|
|
1287
|
-
function nodeCheckHydrationBreak(node) {
|
|
1288
|
-
if (node !== null && isCommentNode(node) && isHydrationBreak(node.data)) {
|
|
1289
|
-
let comment = node;
|
|
1290
|
-
node = node.nextSibling;
|
|
1291
|
-
comment.remove();
|
|
1292
|
-
}
|
|
1293
|
-
context.hydrationNode = node;
|
|
1294
|
-
return node;
|
|
1295
|
-
}
|
|
1296
|
-
//#endregion
|
|
1297
|
-
//#region src/render/nodeNext.ts
|
|
1298
|
-
/**
|
|
1299
|
-
* Gets the next sibling of a node.
|
|
1300
|
-
*
|
|
1301
|
-
* When hydrating, sets the hydration node.
|
|
1302
|
-
*
|
|
1303
|
-
* @param node The node.
|
|
1304
|
-
* @param text Whether we require a text node.
|
|
1305
|
-
*/
|
|
1306
|
-
function nodeNext(node, text = false) {
|
|
1307
|
-
if (context.hydrationNode !== null) {
|
|
1308
|
-
if (text && isTextNode(node)) return node;
|
|
1309
|
-
let next = nodeCheckHydrationBreak(node.nextSibling);
|
|
1310
|
-
while (!text && next !== null && isTextNode(next) && next.textContent?.trim() === "") next = nodeCheckHydrationBreak(next.nextSibling);
|
|
1311
|
-
if (!text && next !== null && next.nodeName === "TBODY" && next.firstChild && isTextNode(node)) {
|
|
1312
|
-
next = next.firstChild;
|
|
1313
|
-
context.hydrationNode = next;
|
|
1314
|
-
}
|
|
1315
|
-
return next;
|
|
1316
|
-
}
|
|
1317
|
-
return node.nextSibling;
|
|
1318
|
-
}
|
|
1319
1338
|
//#endregion
|
|
1320
1339
|
//#region src/render/nodeAnchor.ts
|
|
1321
1340
|
/**
|