solid-js 1.6.7 → 1.6.9
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/dev.cjs +140 -127
- package/dist/dev.js +140 -127
- package/dist/server.cjs +35 -40
- package/dist/server.js +35 -40
- package/dist/solid.cjs +126 -115
- package/dist/solid.js +126 -115
- package/h/dist/h.cjs +4 -4
- package/h/dist/h.js +4 -4
- package/h/types/hyperscript.d.ts +3 -3
- package/html/dist/html.cjs +34 -35
- package/html/dist/html.js +34 -35
- package/html/types/lit.d.ts +2 -2
- package/package.json +1 -1
- package/store/dist/dev.cjs +16 -16
- package/store/dist/dev.js +16 -16
- package/store/dist/server.cjs +3 -3
- package/store/dist/server.js +3 -3
- package/store/dist/store.cjs +16 -16
- package/store/dist/store.js +16 -16
- package/types/reactive/signal.d.ts +9 -8
- package/types/server/rendering.d.ts +1 -0
- package/universal/dist/dev.cjs +10 -10
- package/universal/dist/dev.js +10 -10
- package/universal/dist/universal.cjs +10 -10
- package/universal/dist/universal.js +10 -10
- package/web/dist/dev.cjs +29 -22
- package/web/dist/dev.js +29 -22
- package/web/dist/server.cjs +14 -20
- package/web/dist/server.js +14 -20
- package/web/dist/web.cjs +29 -22
- package/web/dist/web.js +29 -22
package/dist/solid.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
let taskIdCounter = 1,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
isCallbackScheduled = false,
|
|
3
|
+
isPerformingWork = false,
|
|
4
|
+
taskQueue = [],
|
|
5
|
+
currentTask = null,
|
|
6
|
+
shouldYieldToHost = null,
|
|
7
|
+
yieldInterval = 5,
|
|
8
|
+
deadline = 0,
|
|
9
|
+
maxYieldInterval = 300,
|
|
10
|
+
scheduleCallback = null,
|
|
11
|
+
scheduledCallback = null;
|
|
12
12
|
const maxSigned31BitInt = 1073741823;
|
|
13
13
|
function setupScheduler() {
|
|
14
14
|
const channel = new MessageChannel(),
|
|
15
|
-
|
|
15
|
+
port = channel.port2;
|
|
16
16
|
scheduleCallback = () => port.postMessage(null);
|
|
17
17
|
channel.port1.onmessage = () => {
|
|
18
18
|
if (scheduledCallback !== null) {
|
|
@@ -63,7 +63,7 @@ function enqueue(taskQueue, task) {
|
|
|
63
63
|
function requestCallback(fn, options) {
|
|
64
64
|
if (!scheduleCallback) setupScheduler();
|
|
65
65
|
let startTime = performance.now(),
|
|
66
|
-
|
|
66
|
+
timeout = maxSigned31BitInt;
|
|
67
67
|
if (options && options.timeout) timeout = options.timeout;
|
|
68
68
|
const newTask = {
|
|
69
69
|
id: taskIdCounter++,
|
|
@@ -119,7 +119,8 @@ function setHydrateContext(context) {
|
|
|
119
119
|
sharedConfig.context = context;
|
|
120
120
|
}
|
|
121
121
|
function nextHydrateContext() {
|
|
122
|
-
return {
|
|
122
|
+
return {
|
|
123
|
+
...sharedConfig.context,
|
|
123
124
|
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
124
125
|
count: 0
|
|
125
126
|
};
|
|
@@ -154,15 +155,15 @@ let ExecCount = 0;
|
|
|
154
155
|
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
155
156
|
function createRoot(fn, detachedOwner) {
|
|
156
157
|
const listener = Listener,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
owner = Owner,
|
|
159
|
+
unowned = fn.length === 0,
|
|
160
|
+
root = unowned ? UNOWNED : {
|
|
161
|
+
owned: null,
|
|
162
|
+
cleanups: null,
|
|
163
|
+
context: null,
|
|
164
|
+
owner: detachedOwner || owner
|
|
165
|
+
},
|
|
166
|
+
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
166
167
|
Owner = root;
|
|
167
168
|
Listener = null;
|
|
168
169
|
try {
|
|
@@ -199,7 +200,7 @@ function createRenderEffect(fn, value, options) {
|
|
|
199
200
|
function createEffect(fn, value, options) {
|
|
200
201
|
runEffects = runUserEffects;
|
|
201
202
|
const c = createComputation(fn, value, false, STALE),
|
|
202
|
-
|
|
203
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
203
204
|
if (s) c.suspense = s;
|
|
204
205
|
c.user = true;
|
|
205
206
|
Effects ? Effects.push(c) : updateComputation(c);
|
|
@@ -207,10 +208,10 @@ function createEffect(fn, value, options) {
|
|
|
207
208
|
function createReaction(onInvalidate, options) {
|
|
208
209
|
let fn;
|
|
209
210
|
const c = createComputation(() => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
fn ? fn() : untrack(onInvalidate);
|
|
212
|
+
fn = undefined;
|
|
213
|
+
}, undefined, false, 0),
|
|
214
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
214
215
|
if (s) c.suspense = s;
|
|
215
216
|
c.user = true;
|
|
216
217
|
return tracking => {
|
|
@@ -244,19 +245,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
244
245
|
options = pOptions || {};
|
|
245
246
|
}
|
|
246
247
|
let pr = null,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
initP = NO_INIT,
|
|
249
|
+
id = null,
|
|
250
|
+
loadedUnderTransition = false,
|
|
251
|
+
scheduled = false,
|
|
252
|
+
resolved = ("initialValue" in options),
|
|
253
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
253
254
|
const contexts = new Set(),
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
255
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
256
|
+
[error, setError] = createSignal(undefined),
|
|
257
|
+
[track, trigger] = createSignal(undefined, {
|
|
258
|
+
equals: false
|
|
259
|
+
}),
|
|
260
|
+
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
260
261
|
if (sharedConfig.context) {
|
|
261
262
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
262
263
|
let v;
|
|
@@ -292,8 +293,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
292
293
|
}
|
|
293
294
|
function read() {
|
|
294
295
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
295
|
-
|
|
296
|
-
|
|
296
|
+
v = value(),
|
|
297
|
+
err = error();
|
|
297
298
|
if (err && !pr) throw err;
|
|
298
299
|
if (Listener && !Listener.user && c) {
|
|
299
300
|
createComputed(() => {
|
|
@@ -365,7 +366,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
365
366
|
}
|
|
366
367
|
function createDeferred(source, options) {
|
|
367
368
|
let t,
|
|
368
|
-
|
|
369
|
+
timeout = options ? options.timeoutMs : undefined;
|
|
369
370
|
const node = createComputation(() => {
|
|
370
371
|
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
371
372
|
timeout
|
|
@@ -612,8 +613,8 @@ function updateComputation(node) {
|
|
|
612
613
|
if (!node.fn) return;
|
|
613
614
|
cleanNode(node);
|
|
614
615
|
const owner = Owner,
|
|
615
|
-
|
|
616
|
-
|
|
616
|
+
listener = Listener,
|
|
617
|
+
time = ExecCount;
|
|
617
618
|
Listener = Owner = node;
|
|
618
619
|
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
619
620
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
@@ -634,7 +635,17 @@ function runComputation(node, value, time) {
|
|
|
634
635
|
try {
|
|
635
636
|
nextValue = node.fn(value);
|
|
636
637
|
} catch (err) {
|
|
637
|
-
if (node.pure)
|
|
638
|
+
if (node.pure) {
|
|
639
|
+
if (Transition && Transition.running) {
|
|
640
|
+
node.tState = STALE;
|
|
641
|
+
node.tOwned && node.tOwned.forEach(cleanNode);
|
|
642
|
+
node.tOwned = undefined;
|
|
643
|
+
} else {
|
|
644
|
+
node.state = STALE;
|
|
645
|
+
node.owned && node.owned.forEach(cleanNode);
|
|
646
|
+
node.owned = null;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
638
649
|
handleError(err);
|
|
639
650
|
}
|
|
640
651
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
@@ -701,7 +712,7 @@ function runTop(node) {
|
|
|
701
712
|
node = ancestors[i];
|
|
702
713
|
if (runningTransition) {
|
|
703
714
|
let top = node,
|
|
704
|
-
|
|
715
|
+
prev = ancestors[i + 1];
|
|
705
716
|
while ((top = top.owner) && top !== prev) {
|
|
706
717
|
if (Transition.disposed.has(top)) return;
|
|
707
718
|
}
|
|
@@ -798,7 +809,7 @@ function scheduleQueue(queue) {
|
|
|
798
809
|
}
|
|
799
810
|
function runUserEffects(queue) {
|
|
800
811
|
let i,
|
|
801
|
-
|
|
812
|
+
userLength = 0;
|
|
802
813
|
for (i = 0; i < queue.length; i++) {
|
|
803
814
|
const e = queue[i];
|
|
804
815
|
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
@@ -834,11 +845,11 @@ function cleanNode(node) {
|
|
|
834
845
|
if (node.sources) {
|
|
835
846
|
while (node.sources.length) {
|
|
836
847
|
const source = node.sources.pop(),
|
|
837
|
-
|
|
838
|
-
|
|
848
|
+
index = node.sourceSlots.pop(),
|
|
849
|
+
obs = source.observers;
|
|
839
850
|
if (obs && obs.length) {
|
|
840
851
|
const n = obs.pop(),
|
|
841
|
-
|
|
852
|
+
s = source.observerSlots.pop();
|
|
842
853
|
if (index < obs.length) {
|
|
843
854
|
n.sourceSlots[s] = index;
|
|
844
855
|
obs[index] = n;
|
|
@@ -962,27 +973,27 @@ function dispose(d) {
|
|
|
962
973
|
}
|
|
963
974
|
function mapArray(list, mapFn, options = {}) {
|
|
964
975
|
let items = [],
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
976
|
+
mapped = [],
|
|
977
|
+
disposers = [],
|
|
978
|
+
len = 0,
|
|
979
|
+
indexes = mapFn.length > 1 ? [] : null;
|
|
969
980
|
onCleanup(() => dispose(disposers));
|
|
970
981
|
return () => {
|
|
971
982
|
let newItems = list() || [],
|
|
972
|
-
|
|
973
|
-
|
|
983
|
+
i,
|
|
984
|
+
j;
|
|
974
985
|
newItems[$TRACK];
|
|
975
986
|
return untrack(() => {
|
|
976
987
|
let newLen = newItems.length,
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
988
|
+
newIndices,
|
|
989
|
+
newIndicesNext,
|
|
990
|
+
temp,
|
|
991
|
+
tempdisposers,
|
|
992
|
+
tempIndexes,
|
|
993
|
+
start,
|
|
994
|
+
end,
|
|
995
|
+
newEnd,
|
|
996
|
+
item;
|
|
986
997
|
if (newLen === 0) {
|
|
987
998
|
if (len !== 0) {
|
|
988
999
|
dispose(disposers);
|
|
@@ -1065,11 +1076,11 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1065
1076
|
}
|
|
1066
1077
|
function indexArray(list, mapFn, options = {}) {
|
|
1067
1078
|
let items = [],
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1079
|
+
mapped = [],
|
|
1080
|
+
disposers = [],
|
|
1081
|
+
signals = [],
|
|
1082
|
+
len = 0,
|
|
1083
|
+
i;
|
|
1073
1084
|
onCleanup(() => dispose(disposers));
|
|
1074
1085
|
return () => {
|
|
1075
1086
|
const newItems = list() || [];
|
|
@@ -1340,20 +1351,20 @@ function Switch(props) {
|
|
|
1340
1351
|
let keyed = false;
|
|
1341
1352
|
const equals = (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1342
1353
|
const conditions = children(() => props.children),
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1354
|
+
evalConditions = createMemo(() => {
|
|
1355
|
+
let conds = conditions();
|
|
1356
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1357
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1358
|
+
const c = conds[i].when;
|
|
1359
|
+
if (c) {
|
|
1360
|
+
keyed = !!conds[i].keyed;
|
|
1361
|
+
return [i, c, conds[i]];
|
|
1362
|
+
}
|
|
1351
1363
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
});
|
|
1364
|
+
return [-1];
|
|
1365
|
+
}, undefined, {
|
|
1366
|
+
equals
|
|
1367
|
+
});
|
|
1357
1368
|
return createMemo(() => {
|
|
1358
1369
|
const [index, when, cond] = evalConditions();
|
|
1359
1370
|
if (index < 0) return props.fallback;
|
|
@@ -1395,9 +1406,9 @@ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFa
|
|
|
1395
1406
|
const SuspenseListContext = createContext();
|
|
1396
1407
|
function SuspenseList(props) {
|
|
1397
1408
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1409
|
+
inFallback: false
|
|
1410
|
+
})),
|
|
1411
|
+
show;
|
|
1401
1412
|
const listContext = useContext(SuspenseListContext);
|
|
1402
1413
|
const [registry, setRegistry] = createSignal([]);
|
|
1403
1414
|
if (listContext) {
|
|
@@ -1405,13 +1416,13 @@ function SuspenseList(props) {
|
|
|
1405
1416
|
}
|
|
1406
1417
|
const resolved = createMemo(prev => {
|
|
1407
1418
|
const reveal = props.revealOrder,
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1419
|
+
tail = props.tail,
|
|
1420
|
+
{
|
|
1421
|
+
showContent = true,
|
|
1422
|
+
showFallback = true
|
|
1423
|
+
} = show ? show() : {},
|
|
1424
|
+
reg = registry(),
|
|
1425
|
+
reverse = reveal === "backwards";
|
|
1415
1426
|
if (reveal === "together") {
|
|
1416
1427
|
const all = reg.every(inFallback => !inFallback());
|
|
1417
1428
|
const res = reg.map(() => ({
|
|
@@ -1426,7 +1437,7 @@ function SuspenseList(props) {
|
|
|
1426
1437
|
const res = [];
|
|
1427
1438
|
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1428
1439
|
const n = reverse ? len - i - 1 : i,
|
|
1429
|
-
|
|
1440
|
+
s = reg[n]();
|
|
1430
1441
|
if (!stop && !s) {
|
|
1431
1442
|
res[n] = {
|
|
1432
1443
|
showContent,
|
|
@@ -1469,25 +1480,25 @@ function SuspenseList(props) {
|
|
|
1469
1480
|
}
|
|
1470
1481
|
function Suspense(props) {
|
|
1471
1482
|
let counter = 0,
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1483
|
+
show,
|
|
1484
|
+
ctx,
|
|
1485
|
+
p,
|
|
1486
|
+
flicker,
|
|
1487
|
+
error;
|
|
1477
1488
|
const [inFallback, setFallback] = createSignal(false),
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1489
|
+
SuspenseContext = getSuspenseContext(),
|
|
1490
|
+
store = {
|
|
1491
|
+
increment: () => {
|
|
1492
|
+
if (++counter === 1) setFallback(true);
|
|
1493
|
+
},
|
|
1494
|
+
decrement: () => {
|
|
1495
|
+
if (--counter === 0) setFallback(false);
|
|
1496
|
+
},
|
|
1497
|
+
inFallback,
|
|
1498
|
+
effects: [],
|
|
1499
|
+
resolved: false
|
|
1485
1500
|
},
|
|
1486
|
-
|
|
1487
|
-
effects: [],
|
|
1488
|
-
resolved: false
|
|
1489
|
-
},
|
|
1490
|
-
owner = getOwner();
|
|
1501
|
+
owner = getOwner();
|
|
1491
1502
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1492
1503
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1493
1504
|
let ref = sharedConfig.load(key);
|
|
@@ -1527,10 +1538,10 @@ function Suspense(props) {
|
|
|
1527
1538
|
const rendered = createMemo(() => props.children);
|
|
1528
1539
|
return createMemo(prev => {
|
|
1529
1540
|
const inFallback = store.inFallback(),
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1541
|
+
{
|
|
1542
|
+
showContent = true,
|
|
1543
|
+
showFallback = true
|
|
1544
|
+
} = show ? show() : {};
|
|
1534
1545
|
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1535
1546
|
store.resolved = true;
|
|
1536
1547
|
dispose && dispose();
|
package/h/dist/h.cjs
CHANGED
|
@@ -6,8 +6,8 @@ const $ELEMENT = Symbol("hyper-element");
|
|
|
6
6
|
function createHyperScript(r) {
|
|
7
7
|
function h() {
|
|
8
8
|
let args = [].slice.call(arguments),
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
e,
|
|
10
|
+
multiExpression = false;
|
|
11
11
|
while (Array.isArray(args[0])) args = args[0];
|
|
12
12
|
if (args[0][$ELEMENT]) args.unshift(h.Fragment);
|
|
13
13
|
typeof args[0] === "string" && detectMultiExpression(args);
|
|
@@ -40,7 +40,7 @@ function createHyperScript(r) {
|
|
|
40
40
|
} else if ("function" === type) {
|
|
41
41
|
if (!e) {
|
|
42
42
|
let props,
|
|
43
|
-
|
|
43
|
+
next = args[0];
|
|
44
44
|
if (next == null || typeof next === "object" && !Array.isArray(next) && !(next instanceof Element)) props = args.shift();
|
|
45
45
|
props || (props = {});
|
|
46
46
|
if (args.length) {
|
|
@@ -72,7 +72,7 @@ function createHyperScript(r) {
|
|
|
72
72
|
if (/^\.|#/.test(m[1])) e = document.createElement("div");
|
|
73
73
|
for (let i = 0; i < m.length; i++) {
|
|
74
74
|
const v = m[i],
|
|
75
|
-
|
|
75
|
+
s = v.substring(1, v.length);
|
|
76
76
|
if (!v) continue;
|
|
77
77
|
if (!e) e = r.SVGElements.has(v) ? document.createElementNS("http://www.w3.org/2000/svg", v) : document.createElement(v);else if (v[0] === ".") e.classList.add(s);else if (v[0] === "#") e.setAttribute("id", s);
|
|
78
78
|
}
|
package/h/dist/h.js
CHANGED
|
@@ -4,8 +4,8 @@ const $ELEMENT = Symbol("hyper-element");
|
|
|
4
4
|
function createHyperScript(r) {
|
|
5
5
|
function h() {
|
|
6
6
|
let args = [].slice.call(arguments),
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
e,
|
|
8
|
+
multiExpression = false;
|
|
9
9
|
while (Array.isArray(args[0])) args = args[0];
|
|
10
10
|
if (args[0][$ELEMENT]) args.unshift(h.Fragment);
|
|
11
11
|
typeof args[0] === "string" && detectMultiExpression(args);
|
|
@@ -38,7 +38,7 @@ function createHyperScript(r) {
|
|
|
38
38
|
} else if ("function" === type) {
|
|
39
39
|
if (!e) {
|
|
40
40
|
let props,
|
|
41
|
-
|
|
41
|
+
next = args[0];
|
|
42
42
|
if (next == null || typeof next === "object" && !Array.isArray(next) && !(next instanceof Element)) props = args.shift();
|
|
43
43
|
props || (props = {});
|
|
44
44
|
if (args.length) {
|
|
@@ -70,7 +70,7 @@ function createHyperScript(r) {
|
|
|
70
70
|
if (/^\.|#/.test(m[1])) e = document.createElement("div");
|
|
71
71
|
for (let i = 0; i < m.length; i++) {
|
|
72
72
|
const v = m[i],
|
|
73
|
-
|
|
73
|
+
s = v.substring(1, v.length);
|
|
74
74
|
if (!v) continue;
|
|
75
75
|
if (!e) e = r.SVGElements.has(v) ? document.createElementNS("http://www.w3.org/2000/svg", v) : document.createElement(v);else if (v[0] === ".") e.classList.add(s);else if (v[0] === "#") e.setAttribute("id", s);
|
|
76
76
|
}
|
package/h/types/hyperscript.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
2
|
interface Runtime {
|
|
3
3
|
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
4
4
|
spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
@@ -7,10 +7,10 @@ interface Runtime {
|
|
|
7
7
|
dynamicProperty(props: any, key: string): any;
|
|
8
8
|
SVGElements: Set<string>;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
type ExpandableNode = Node & {
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type HyperScript = {
|
|
14
14
|
(...args: any[]): () => ExpandableNode | ExpandableNode[];
|
|
15
15
|
Fragment: (props: {
|
|
16
16
|
children: (() => ExpandableNode) | (() => ExpandableNode)[];
|
package/html/dist/html.cjs
CHANGED
|
@@ -22,8 +22,7 @@ const lookup = {
|
|
|
22
22
|
track: true,
|
|
23
23
|
wbr: true
|
|
24
24
|
};
|
|
25
|
-
function parseTag(
|
|
26
|
-
tag) {
|
|
25
|
+
function parseTag( tag) {
|
|
27
26
|
const res = {
|
|
28
27
|
type: 'tag',
|
|
29
28
|
name: '',
|
|
@@ -183,14 +182,14 @@ function createHTML(r, {
|
|
|
183
182
|
};
|
|
184
183
|
function createTemplate(statics) {
|
|
185
184
|
let i = 0,
|
|
186
|
-
|
|
185
|
+
markup = "";
|
|
187
186
|
for (; i < statics.length - 1; i++) {
|
|
188
187
|
markup = markup + statics[i] + "<!--#-->";
|
|
189
188
|
}
|
|
190
189
|
markup = markup + statics[i];
|
|
191
190
|
markup = markup.replace(selfClosing, fullClosing).replace(/<(<!--#-->)/g, "<###").replace(/\.\.\.(<!--#-->)/g, "###").replace(attrSeeker, attrReplacer).replace(/>\n+\s*/g, ">").replace(/\n+\s*</g, "<").replace(/\s+</g, " <").replace(/>\s+/g, "> ");
|
|
192
191
|
const [html, code] = parseTemplate(parse(markup)),
|
|
193
|
-
|
|
192
|
+
templates = [];
|
|
194
193
|
for (let i = 0; i < html.length; i++) {
|
|
195
194
|
templates.push(document.createElement("template"));
|
|
196
195
|
templates[i].innerHTML = html[i];
|
|
@@ -213,8 +212,8 @@ function createHTML(r, {
|
|
|
213
212
|
}
|
|
214
213
|
function parseKeyValue(tag, name, value, isSVG, isCE, options) {
|
|
215
214
|
let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
parts,
|
|
216
|
+
namespace;
|
|
218
217
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
219
218
|
name = parts[1];
|
|
220
219
|
namespace = parts[0];
|
|
@@ -252,9 +251,9 @@ function createHTML(r, {
|
|
|
252
251
|
options.exprs.push(`exprs[${options.counter++}](${tag})`);
|
|
253
252
|
} else {
|
|
254
253
|
const childOptions = Object.assign({}, options, {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
254
|
+
exprs: []
|
|
255
|
+
}),
|
|
256
|
+
count = options.counter;
|
|
258
257
|
parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
|
|
259
258
|
options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
260
259
|
if (value === "###") {
|
|
@@ -320,11 +319,11 @@ function createHTML(r, {
|
|
|
320
319
|
function processComponent(node, options) {
|
|
321
320
|
let props = [];
|
|
322
321
|
const keys = Object.keys(node.attrs),
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
propGroups = [props],
|
|
323
|
+
componentIdentifier = options.counter++;
|
|
325
324
|
for (let i = 0; i < keys.length; i++) {
|
|
326
325
|
const name = keys[i],
|
|
327
|
-
|
|
326
|
+
value = node.attrs[name];
|
|
328
327
|
if (name === "###") {
|
|
329
328
|
propGroups.push(`exprs[${options.counter++}]`);
|
|
330
329
|
propGroups.push(props = []);
|
|
@@ -336,15 +335,15 @@ function createHTML(r, {
|
|
|
336
335
|
props.push(`children: () => exprs[${options.counter++}]`);
|
|
337
336
|
} else if (node.children.length) {
|
|
338
337
|
const children = {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
338
|
+
type: "fragment",
|
|
339
|
+
children: node.children
|
|
340
|
+
},
|
|
341
|
+
childOptions = Object.assign({}, options, {
|
|
342
|
+
first: true,
|
|
343
|
+
decl: [],
|
|
344
|
+
exprs: [],
|
|
345
|
+
parent: false
|
|
346
|
+
});
|
|
348
347
|
parseNode(children, childOptions);
|
|
349
348
|
props.push(`children: () => { ${childOptions.exprs.join(";\n")}}`);
|
|
350
349
|
options.templateId = childOptions.templateId;
|
|
@@ -410,7 +409,7 @@ function createHTML(r, {
|
|
|
410
409
|
let current = "";
|
|
411
410
|
for (let i = 0; i < keys.length; i++) {
|
|
412
411
|
const name = keys[i],
|
|
413
|
-
|
|
412
|
+
value = node.attrs[name];
|
|
414
413
|
if (value.includes("###")) {
|
|
415
414
|
let count = options.counter++;
|
|
416
415
|
current += `${name}: ${name !== "ref" ? `typeof exprs[${count}] === "function" ? exprs[${count}]() : ` : ""}exprs[${count}],`;
|
|
@@ -429,7 +428,7 @@ function createHTML(r, {
|
|
|
429
428
|
} else {
|
|
430
429
|
for (let i = 0; i < keys.length; i++) {
|
|
431
430
|
const name = keys[i],
|
|
432
|
-
|
|
431
|
+
value = node.attrs[name];
|
|
433
432
|
if (value.includes("###")) {
|
|
434
433
|
delete node.attrs[name];
|
|
435
434
|
parseAttribute(tag, name, value, isSVG, isCE, options);
|
|
@@ -461,18 +460,18 @@ function createHTML(r, {
|
|
|
461
460
|
}
|
|
462
461
|
function parseTemplate(nodes) {
|
|
463
462
|
const options = {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
463
|
+
path: "",
|
|
464
|
+
decl: [],
|
|
465
|
+
exprs: [],
|
|
466
|
+
delegatedEvents: new Set(),
|
|
467
|
+
counter: 0,
|
|
468
|
+
first: true,
|
|
469
|
+
multi: false,
|
|
470
|
+
templateId: 0,
|
|
471
|
+
templateNodes: []
|
|
472
|
+
},
|
|
473
|
+
id = uuid,
|
|
474
|
+
origNodes = nodes;
|
|
476
475
|
let toplevel;
|
|
477
476
|
if (nodes.length > 1) {
|
|
478
477
|
nodes = [{
|