solid-js 1.4.1 → 1.4.4
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 +18 -12
- package/dist/dev.js +18 -12
- package/dist/server.cjs +9 -6
- package/dist/server.js +9 -6
- package/dist/solid.cjs +15 -12
- package/dist/solid.js +15 -12
- package/html/dist/html.cjs +34 -17
- package/html/dist/html.js +34 -17
- package/package.json +2 -2
- package/store/README.md +2 -2
- package/store/dist/dev.cjs +31 -16
- package/store/dist/dev.js +31 -16
- package/store/dist/server.cjs +16 -2
- package/store/dist/server.js +16 -2
- package/store/dist/store.cjs +31 -16
- package/store/dist/store.js +31 -16
- package/store/types/modifiers.d.ts +1 -2
- package/store/types/server.d.ts +3 -3
- package/store/types/store.d.ts +12 -5
- package/types/reactive/signal.d.ts +9 -6
- package/types/render/component.d.ts +8 -14
- package/types/render/hydration.d.ts +1 -1
- package/web/dist/dev.cjs +26 -14
- package/web/dist/dev.js +26 -14
- package/web/dist/server.cjs +2 -2
- package/web/dist/server.js +2 -2
- package/web/dist/web.cjs +26 -14
- package/web/dist/web.js +26 -14
- package/web/types/index.d.ts +6 -3
- package/web/types/server-mock.d.ts +1 -1
package/dist/dev.cjs
CHANGED
|
@@ -161,17 +161,21 @@ let rootCount = 0;
|
|
|
161
161
|
function createRoot(fn, detachedOwner) {
|
|
162
162
|
const listener = Listener,
|
|
163
163
|
owner = Owner,
|
|
164
|
-
|
|
164
|
+
unowned = fn.length === 0,
|
|
165
|
+
root = unowned && !"_SOLID_DEV_" ? UNOWNED : {
|
|
165
166
|
owned: null,
|
|
166
167
|
cleanups: null,
|
|
167
168
|
context: null,
|
|
168
169
|
owner: detachedOwner || owner
|
|
169
|
-
}
|
|
170
|
+
},
|
|
171
|
+
updateFn = unowned ? () => fn(() => {
|
|
172
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
173
|
+
}) : () => fn(() => cleanNode(root));
|
|
170
174
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
171
175
|
Owner = root;
|
|
172
176
|
Listener = null;
|
|
173
177
|
try {
|
|
174
|
-
return runUpdates(
|
|
178
|
+
return runUpdates(updateFn, true);
|
|
175
179
|
} finally {
|
|
176
180
|
Listener = listener;
|
|
177
181
|
Owner = owner;
|
|
@@ -946,6 +950,7 @@ function cleanNode(node) {
|
|
|
946
950
|
}
|
|
947
951
|
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
948
952
|
node.context = null;
|
|
953
|
+
delete node.sourceMap;
|
|
949
954
|
}
|
|
950
955
|
function reset(node, top) {
|
|
951
956
|
if (!top) {
|
|
@@ -1415,24 +1420,25 @@ function Match(props) {
|
|
|
1415
1420
|
return props;
|
|
1416
1421
|
}
|
|
1417
1422
|
let Errors;
|
|
1423
|
+
const NoErrors = {};
|
|
1418
1424
|
function resetErrorBoundaries() {
|
|
1419
|
-
Errors && [...Errors].forEach(fn => fn());
|
|
1425
|
+
Errors && [...Errors].forEach(fn => fn(NoErrors));
|
|
1420
1426
|
}
|
|
1421
1427
|
function ErrorBoundary(props) {
|
|
1422
|
-
let err =
|
|
1428
|
+
let err = NoErrors;
|
|
1423
1429
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1424
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1430
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
|
|
1425
1431
|
}
|
|
1426
1432
|
const [errored, setErrored] = createSignal(err);
|
|
1427
1433
|
Errors || (Errors = new Set());
|
|
1428
1434
|
Errors.add(setErrored);
|
|
1429
1435
|
onCleanup(() => Errors.delete(setErrored));
|
|
1430
|
-
let e;
|
|
1431
1436
|
return createMemo(() => {
|
|
1432
|
-
|
|
1437
|
+
let e;
|
|
1438
|
+
if ((e = errored()) !== NoErrors) {
|
|
1433
1439
|
const f = props.fallback;
|
|
1434
1440
|
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1435
|
-
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(
|
|
1441
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
|
|
1436
1442
|
}
|
|
1437
1443
|
onError(setErrored);
|
|
1438
1444
|
return props.children;
|
|
@@ -1527,7 +1533,7 @@ function Suspense(props) {
|
|
|
1527
1533
|
resolved: false
|
|
1528
1534
|
},
|
|
1529
1535
|
owner = getOwner();
|
|
1530
|
-
if (sharedConfig.context) {
|
|
1536
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1531
1537
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1532
1538
|
p = sharedConfig.load(key);
|
|
1533
1539
|
if (p) {
|
|
@@ -1560,7 +1566,7 @@ function Suspense(props) {
|
|
|
1560
1566
|
return flicker = undefined;
|
|
1561
1567
|
}
|
|
1562
1568
|
if (ctx && p === undefined) setHydrateContext();
|
|
1563
|
-
const rendered =
|
|
1569
|
+
const rendered = createMemo(() => props.children);
|
|
1564
1570
|
return createMemo(() => {
|
|
1565
1571
|
const inFallback = store.inFallback(),
|
|
1566
1572
|
visibleContent = showContent ? showContent() : true,
|
|
@@ -1570,7 +1576,7 @@ function Suspense(props) {
|
|
|
1570
1576
|
store.resolved = true;
|
|
1571
1577
|
ctx = p = undefined;
|
|
1572
1578
|
resumeEffects(store.effects);
|
|
1573
|
-
return rendered;
|
|
1579
|
+
return rendered();
|
|
1574
1580
|
}
|
|
1575
1581
|
if (!visibleFallback) return;
|
|
1576
1582
|
return createRoot(disposer => {
|
package/dist/dev.js
CHANGED
|
@@ -157,17 +157,21 @@ let rootCount = 0;
|
|
|
157
157
|
function createRoot(fn, detachedOwner) {
|
|
158
158
|
const listener = Listener,
|
|
159
159
|
owner = Owner,
|
|
160
|
-
|
|
160
|
+
unowned = fn.length === 0,
|
|
161
|
+
root = unowned && !"_SOLID_DEV_" ? UNOWNED : {
|
|
161
162
|
owned: null,
|
|
162
163
|
cleanups: null,
|
|
163
164
|
context: null,
|
|
164
165
|
owner: detachedOwner || owner
|
|
165
|
-
}
|
|
166
|
+
},
|
|
167
|
+
updateFn = unowned ? () => fn(() => {
|
|
168
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
169
|
+
}) : () => fn(() => cleanNode(root));
|
|
166
170
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
167
171
|
Owner = root;
|
|
168
172
|
Listener = null;
|
|
169
173
|
try {
|
|
170
|
-
return runUpdates(
|
|
174
|
+
return runUpdates(updateFn, true);
|
|
171
175
|
} finally {
|
|
172
176
|
Listener = listener;
|
|
173
177
|
Owner = owner;
|
|
@@ -942,6 +946,7 @@ function cleanNode(node) {
|
|
|
942
946
|
}
|
|
943
947
|
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
944
948
|
node.context = null;
|
|
949
|
+
delete node.sourceMap;
|
|
945
950
|
}
|
|
946
951
|
function reset(node, top) {
|
|
947
952
|
if (!top) {
|
|
@@ -1411,24 +1416,25 @@ function Match(props) {
|
|
|
1411
1416
|
return props;
|
|
1412
1417
|
}
|
|
1413
1418
|
let Errors;
|
|
1419
|
+
const NoErrors = {};
|
|
1414
1420
|
function resetErrorBoundaries() {
|
|
1415
|
-
Errors && [...Errors].forEach(fn => fn());
|
|
1421
|
+
Errors && [...Errors].forEach(fn => fn(NoErrors));
|
|
1416
1422
|
}
|
|
1417
1423
|
function ErrorBoundary(props) {
|
|
1418
|
-
let err =
|
|
1424
|
+
let err = NoErrors;
|
|
1419
1425
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1420
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1426
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
|
|
1421
1427
|
}
|
|
1422
1428
|
const [errored, setErrored] = createSignal(err);
|
|
1423
1429
|
Errors || (Errors = new Set());
|
|
1424
1430
|
Errors.add(setErrored);
|
|
1425
1431
|
onCleanup(() => Errors.delete(setErrored));
|
|
1426
|
-
let e;
|
|
1427
1432
|
return createMemo(() => {
|
|
1428
|
-
|
|
1433
|
+
let e;
|
|
1434
|
+
if ((e = errored()) !== NoErrors) {
|
|
1429
1435
|
const f = props.fallback;
|
|
1430
1436
|
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1431
|
-
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(
|
|
1437
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
|
|
1432
1438
|
}
|
|
1433
1439
|
onError(setErrored);
|
|
1434
1440
|
return props.children;
|
|
@@ -1523,7 +1529,7 @@ function Suspense(props) {
|
|
|
1523
1529
|
resolved: false
|
|
1524
1530
|
},
|
|
1525
1531
|
owner = getOwner();
|
|
1526
|
-
if (sharedConfig.context) {
|
|
1532
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1527
1533
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1528
1534
|
p = sharedConfig.load(key);
|
|
1529
1535
|
if (p) {
|
|
@@ -1556,7 +1562,7 @@ function Suspense(props) {
|
|
|
1556
1562
|
return flicker = undefined;
|
|
1557
1563
|
}
|
|
1558
1564
|
if (ctx && p === undefined) setHydrateContext();
|
|
1559
|
-
const rendered =
|
|
1565
|
+
const rendered = createMemo(() => props.children);
|
|
1560
1566
|
return createMemo(() => {
|
|
1561
1567
|
const inFallback = store.inFallback(),
|
|
1562
1568
|
visibleContent = showContent ? showContent() : true,
|
|
@@ -1566,7 +1572,7 @@ function Suspense(props) {
|
|
|
1566
1572
|
store.resolved = true;
|
|
1567
1573
|
ctx = p = undefined;
|
|
1568
1574
|
resumeEffects(store.effects);
|
|
1569
|
-
return rendered;
|
|
1575
|
+
return rendered();
|
|
1570
1576
|
}
|
|
1571
1577
|
if (!visibleFallback) return;
|
|
1572
1578
|
return createRoot(disposer => {
|
package/dist/server.cjs
CHANGED
|
@@ -258,8 +258,9 @@ function createComponent(Comp, props) {
|
|
|
258
258
|
function mergeProps(...sources) {
|
|
259
259
|
const target = {};
|
|
260
260
|
for (let i = 0; i < sources.length; i++) {
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
let source = sources[i];
|
|
262
|
+
if (typeof source === "function") source = source();
|
|
263
|
+
if (source) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
263
264
|
}
|
|
264
265
|
return target;
|
|
265
266
|
}
|
|
@@ -314,14 +315,16 @@ function Switch(props) {
|
|
|
314
315
|
function Match(props) {
|
|
315
316
|
return props;
|
|
316
317
|
}
|
|
318
|
+
const NoErrors = {};
|
|
317
319
|
function resetErrorBoundaries() {}
|
|
318
320
|
function ErrorBoundary(props) {
|
|
319
|
-
let error,
|
|
321
|
+
let error = NoErrors,
|
|
322
|
+
res;
|
|
320
323
|
const ctx = sharedConfig.context;
|
|
321
324
|
const id = ctx.id + ctx.count;
|
|
322
325
|
onError(err => error = err);
|
|
323
326
|
createMemo(() => res = props.children);
|
|
324
|
-
if (error) {
|
|
327
|
+
if (error !== NoErrors) {
|
|
325
328
|
ctx.writeResource(id, error, true);
|
|
326
329
|
setHydrateContext({ ...ctx,
|
|
327
330
|
count: 0
|
|
@@ -360,7 +363,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
360
363
|
const read = () => {
|
|
361
364
|
if (error) throw error;
|
|
362
365
|
if (resourceContext && p) resourceContext.push(p);
|
|
363
|
-
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id]
|
|
366
|
+
const resolved = sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
364
367
|
if (!resolved && read.loading) {
|
|
365
368
|
const ctx = useContext(SuspenseContext);
|
|
366
369
|
if (ctx) {
|
|
@@ -380,7 +383,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
380
383
|
function load() {
|
|
381
384
|
const ctx = sharedConfig.context;
|
|
382
385
|
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
383
|
-
if (ctx.resources && id in ctx.resources && ctx.resources[id]
|
|
386
|
+
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
384
387
|
value = ctx.resources[id].data;
|
|
385
388
|
return;
|
|
386
389
|
}
|
package/dist/server.js
CHANGED
|
@@ -254,8 +254,9 @@ function createComponent(Comp, props) {
|
|
|
254
254
|
function mergeProps(...sources) {
|
|
255
255
|
const target = {};
|
|
256
256
|
for (let i = 0; i < sources.length; i++) {
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
let source = sources[i];
|
|
258
|
+
if (typeof source === "function") source = source();
|
|
259
|
+
if (source) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
259
260
|
}
|
|
260
261
|
return target;
|
|
261
262
|
}
|
|
@@ -310,14 +311,16 @@ function Switch(props) {
|
|
|
310
311
|
function Match(props) {
|
|
311
312
|
return props;
|
|
312
313
|
}
|
|
314
|
+
const NoErrors = {};
|
|
313
315
|
function resetErrorBoundaries() {}
|
|
314
316
|
function ErrorBoundary(props) {
|
|
315
|
-
let error,
|
|
317
|
+
let error = NoErrors,
|
|
318
|
+
res;
|
|
316
319
|
const ctx = sharedConfig.context;
|
|
317
320
|
const id = ctx.id + ctx.count;
|
|
318
321
|
onError(err => error = err);
|
|
319
322
|
createMemo(() => res = props.children);
|
|
320
|
-
if (error) {
|
|
323
|
+
if (error !== NoErrors) {
|
|
321
324
|
ctx.writeResource(id, error, true);
|
|
322
325
|
setHydrateContext({ ...ctx,
|
|
323
326
|
count: 0
|
|
@@ -356,7 +359,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
356
359
|
const read = () => {
|
|
357
360
|
if (error) throw error;
|
|
358
361
|
if (resourceContext && p) resourceContext.push(p);
|
|
359
|
-
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id]
|
|
362
|
+
const resolved = sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
360
363
|
if (!resolved && read.loading) {
|
|
361
364
|
const ctx = useContext(SuspenseContext);
|
|
362
365
|
if (ctx) {
|
|
@@ -376,7 +379,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
376
379
|
function load() {
|
|
377
380
|
const ctx = sharedConfig.context;
|
|
378
381
|
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
379
|
-
if (ctx.resources && id in ctx.resources && ctx.resources[id]
|
|
382
|
+
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
380
383
|
value = ctx.resources[id].data;
|
|
381
384
|
return;
|
|
382
385
|
}
|
package/dist/solid.cjs
CHANGED
|
@@ -160,16 +160,18 @@ let ExecCount = 0;
|
|
|
160
160
|
function createRoot(fn, detachedOwner) {
|
|
161
161
|
const listener = Listener,
|
|
162
162
|
owner = Owner,
|
|
163
|
-
|
|
163
|
+
unowned = fn.length === 0,
|
|
164
|
+
root = unowned && !false ? UNOWNED : {
|
|
164
165
|
owned: null,
|
|
165
166
|
cleanups: null,
|
|
166
167
|
context: null,
|
|
167
168
|
owner: detachedOwner || owner
|
|
168
|
-
}
|
|
169
|
+
},
|
|
170
|
+
updateFn = unowned ? fn : () => fn(() => cleanNode(root));
|
|
169
171
|
Owner = root;
|
|
170
172
|
Listener = null;
|
|
171
173
|
try {
|
|
172
|
-
return runUpdates(
|
|
174
|
+
return runUpdates(updateFn, true);
|
|
173
175
|
} finally {
|
|
174
176
|
Listener = listener;
|
|
175
177
|
Owner = owner;
|
|
@@ -1331,23 +1333,24 @@ function Match(props) {
|
|
|
1331
1333
|
return props;
|
|
1332
1334
|
}
|
|
1333
1335
|
let Errors;
|
|
1336
|
+
const NoErrors = {};
|
|
1334
1337
|
function resetErrorBoundaries() {
|
|
1335
|
-
Errors && [...Errors].forEach(fn => fn());
|
|
1338
|
+
Errors && [...Errors].forEach(fn => fn(NoErrors));
|
|
1336
1339
|
}
|
|
1337
1340
|
function ErrorBoundary(props) {
|
|
1338
|
-
let err =
|
|
1341
|
+
let err = NoErrors;
|
|
1339
1342
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1340
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1343
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
|
|
1341
1344
|
}
|
|
1342
1345
|
const [errored, setErrored] = createSignal(err);
|
|
1343
1346
|
Errors || (Errors = new Set());
|
|
1344
1347
|
Errors.add(setErrored);
|
|
1345
1348
|
onCleanup(() => Errors.delete(setErrored));
|
|
1346
|
-
let e;
|
|
1347
1349
|
return createMemo(() => {
|
|
1348
|
-
|
|
1350
|
+
let e;
|
|
1351
|
+
if ((e = errored()) !== NoErrors) {
|
|
1349
1352
|
const f = props.fallback;
|
|
1350
|
-
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(
|
|
1353
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
|
|
1351
1354
|
}
|
|
1352
1355
|
onError(setErrored);
|
|
1353
1356
|
return props.children;
|
|
@@ -1442,7 +1445,7 @@ function Suspense(props) {
|
|
|
1442
1445
|
resolved: false
|
|
1443
1446
|
},
|
|
1444
1447
|
owner = getOwner();
|
|
1445
|
-
if (sharedConfig.context) {
|
|
1448
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1446
1449
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1447
1450
|
p = sharedConfig.load(key);
|
|
1448
1451
|
if (p) {
|
|
@@ -1475,7 +1478,7 @@ function Suspense(props) {
|
|
|
1475
1478
|
return flicker = undefined;
|
|
1476
1479
|
}
|
|
1477
1480
|
if (ctx && p === undefined) setHydrateContext();
|
|
1478
|
-
const rendered =
|
|
1481
|
+
const rendered = createMemo(() => props.children);
|
|
1479
1482
|
return createMemo(() => {
|
|
1480
1483
|
const inFallback = store.inFallback(),
|
|
1481
1484
|
visibleContent = showContent ? showContent() : true,
|
|
@@ -1485,7 +1488,7 @@ function Suspense(props) {
|
|
|
1485
1488
|
store.resolved = true;
|
|
1486
1489
|
ctx = p = undefined;
|
|
1487
1490
|
resumeEffects(store.effects);
|
|
1488
|
-
return rendered;
|
|
1491
|
+
return rendered();
|
|
1489
1492
|
}
|
|
1490
1493
|
if (!visibleFallback) return;
|
|
1491
1494
|
return createRoot(disposer => {
|
package/dist/solid.js
CHANGED
|
@@ -156,16 +156,18 @@ let ExecCount = 0;
|
|
|
156
156
|
function createRoot(fn, detachedOwner) {
|
|
157
157
|
const listener = Listener,
|
|
158
158
|
owner = Owner,
|
|
159
|
-
|
|
159
|
+
unowned = fn.length === 0,
|
|
160
|
+
root = unowned && !false ? UNOWNED : {
|
|
160
161
|
owned: null,
|
|
161
162
|
cleanups: null,
|
|
162
163
|
context: null,
|
|
163
164
|
owner: detachedOwner || owner
|
|
164
|
-
}
|
|
165
|
+
},
|
|
166
|
+
updateFn = unowned ? fn : () => fn(() => cleanNode(root));
|
|
165
167
|
Owner = root;
|
|
166
168
|
Listener = null;
|
|
167
169
|
try {
|
|
168
|
-
return runUpdates(
|
|
170
|
+
return runUpdates(updateFn, true);
|
|
169
171
|
} finally {
|
|
170
172
|
Listener = listener;
|
|
171
173
|
Owner = owner;
|
|
@@ -1327,23 +1329,24 @@ function Match(props) {
|
|
|
1327
1329
|
return props;
|
|
1328
1330
|
}
|
|
1329
1331
|
let Errors;
|
|
1332
|
+
const NoErrors = {};
|
|
1330
1333
|
function resetErrorBoundaries() {
|
|
1331
|
-
Errors && [...Errors].forEach(fn => fn());
|
|
1334
|
+
Errors && [...Errors].forEach(fn => fn(NoErrors));
|
|
1332
1335
|
}
|
|
1333
1336
|
function ErrorBoundary(props) {
|
|
1334
|
-
let err =
|
|
1337
|
+
let err = NoErrors;
|
|
1335
1338
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1336
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1339
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count) || NoErrors;
|
|
1337
1340
|
}
|
|
1338
1341
|
const [errored, setErrored] = createSignal(err);
|
|
1339
1342
|
Errors || (Errors = new Set());
|
|
1340
1343
|
Errors.add(setErrored);
|
|
1341
1344
|
onCleanup(() => Errors.delete(setErrored));
|
|
1342
|
-
let e;
|
|
1343
1345
|
return createMemo(() => {
|
|
1344
|
-
|
|
1346
|
+
let e;
|
|
1347
|
+
if ((e = errored()) !== NoErrors) {
|
|
1345
1348
|
const f = props.fallback;
|
|
1346
|
-
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(
|
|
1349
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored(NoErrors))) : f;
|
|
1347
1350
|
}
|
|
1348
1351
|
onError(setErrored);
|
|
1349
1352
|
return props.children;
|
|
@@ -1438,7 +1441,7 @@ function Suspense(props) {
|
|
|
1438
1441
|
resolved: false
|
|
1439
1442
|
},
|
|
1440
1443
|
owner = getOwner();
|
|
1441
|
-
if (sharedConfig.context) {
|
|
1444
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1442
1445
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1443
1446
|
p = sharedConfig.load(key);
|
|
1444
1447
|
if (p) {
|
|
@@ -1471,7 +1474,7 @@ function Suspense(props) {
|
|
|
1471
1474
|
return flicker = undefined;
|
|
1472
1475
|
}
|
|
1473
1476
|
if (ctx && p === undefined) setHydrateContext();
|
|
1474
|
-
const rendered =
|
|
1477
|
+
const rendered = createMemo(() => props.children);
|
|
1475
1478
|
return createMemo(() => {
|
|
1476
1479
|
const inFallback = store.inFallback(),
|
|
1477
1480
|
visibleContent = showContent ? showContent() : true,
|
|
@@ -1481,7 +1484,7 @@ function Suspense(props) {
|
|
|
1481
1484
|
store.resolved = true;
|
|
1482
1485
|
ctx = p = undefined;
|
|
1483
1486
|
resumeEffects(store.effects);
|
|
1484
|
-
return rendered;
|
|
1487
|
+
return rendered();
|
|
1485
1488
|
}
|
|
1486
1489
|
if (!visibleFallback) return;
|
|
1487
1490
|
return createRoot(disposer => {
|
package/html/dist/html.cjs
CHANGED
|
@@ -179,15 +179,15 @@ const attrName = "[ " + spaces + "]+" + almostEverything;
|
|
|
179
179
|
const tagName = "<([A-Za-z$#]+[A-Za-z0-9:_-]*)((?:";
|
|
180
180
|
const attrPartials = "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
|
|
181
181
|
const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spaces + "]*/?>)", "g");
|
|
182
|
-
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(['\"(]
|
|
182
|
+
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
|
|
183
183
|
const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
|
|
184
184
|
const marker = "<!--#-->";
|
|
185
185
|
const reservedNameSpaces = new Set(["class", "on", "oncapture", "style", "use", "prop", "attr"]);
|
|
186
186
|
function attrReplacer($0, $1, $2, $3) {
|
|
187
187
|
return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
|
|
188
188
|
}
|
|
189
|
-
function replaceAttributes($0, $1, $2
|
|
190
|
-
return $1 + ($2
|
|
189
|
+
function replaceAttributes($0, $1, $2) {
|
|
190
|
+
return $1 + ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"');
|
|
191
191
|
}
|
|
192
192
|
function fullClosing($0, $1, $2) {
|
|
193
193
|
return VOID_ELEMENTS.test($1) ? $0 : "<" + $1 + $2 + "></" + $1 + ">";
|
|
@@ -236,9 +236,8 @@ function createHTML(r, {
|
|
|
236
236
|
cache.set(statics, templates);
|
|
237
237
|
return templates;
|
|
238
238
|
}
|
|
239
|
-
function parseKeyValue(tag, name, isSVG, isCE, options) {
|
|
240
|
-
let
|
|
241
|
-
expr = `!doNotWrap ? exprs[${count}]() : exprs[${count}]`,
|
|
239
|
+
function parseKeyValue(tag, name, value, isSVG, isCE, options) {
|
|
240
|
+
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(""),
|
|
242
241
|
parts,
|
|
243
242
|
namespace;
|
|
244
243
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
@@ -263,7 +262,7 @@ function createHTML(r, {
|
|
|
263
262
|
if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
|
-
function parseAttribute(tag, name, isSVG, isCE, options) {
|
|
265
|
+
function parseAttribute(tag, name, value, isSVG, isCE, options) {
|
|
267
266
|
if (name.slice(0, 2) === "on") {
|
|
268
267
|
if (!name.includes(":")) {
|
|
269
268
|
const lc = name.slice(2).toLowerCase();
|
|
@@ -281,9 +280,18 @@ function createHTML(r, {
|
|
|
281
280
|
exprs: []
|
|
282
281
|
}),
|
|
283
282
|
count = options.counter;
|
|
284
|
-
parseKeyValue(tag, name, isSVG, isCE, childOptions);
|
|
285
|
-
options.decl.push(`_fn${count} = doNotWrap => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
286
|
-
|
|
283
|
+
parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
|
|
284
|
+
options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
285
|
+
if (value === "###") {
|
|
286
|
+
options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
|
|
287
|
+
} else {
|
|
288
|
+
let check = "";
|
|
289
|
+
for (let i = count; i < childOptions.counter; i++) {
|
|
290
|
+
i !== count && (check += " || ");
|
|
291
|
+
check += `typeof exprs[${i}] === "function"`;
|
|
292
|
+
}
|
|
293
|
+
options.exprs.push(check + ` ? r.effect(_fn${count}) : _fn${count}()`);
|
|
294
|
+
}
|
|
287
295
|
options.counter = childOptions.counter;
|
|
288
296
|
options.wrap = false;
|
|
289
297
|
}
|
|
@@ -322,6 +330,7 @@ function createHTML(r, {
|
|
|
322
330
|
}
|
|
323
331
|
options.counter = childOptions.counter;
|
|
324
332
|
options.templateId = childOptions.templateId;
|
|
333
|
+
options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
|
|
325
334
|
}
|
|
326
335
|
function processComponentProps(propGroups) {
|
|
327
336
|
let result = [];
|
|
@@ -414,16 +423,19 @@ function createHTML(r, {
|
|
|
414
423
|
options.exprs.push(`return [${parts.join(", \n")}]`);
|
|
415
424
|
} else if (node.type === "tag") {
|
|
416
425
|
const tag = `_$el${uuid++}`;
|
|
417
|
-
|
|
426
|
+
const topDecl = !options.decl.length;
|
|
427
|
+
const templateId = options.templateId;
|
|
428
|
+
options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
418
429
|
const keys = Object.keys(node.attrs);
|
|
419
430
|
const isSVG = r.SVGElements.has(node.name);
|
|
420
431
|
const isCE = node.name.includes("-");
|
|
432
|
+
options.hasCustomElement = isCE;
|
|
421
433
|
for (let i = 0; i < keys.length; i++) {
|
|
422
434
|
const name = keys[i],
|
|
423
435
|
value = node.attrs[name];
|
|
424
|
-
if (value
|
|
436
|
+
if (value.includes("###")) {
|
|
425
437
|
delete node.attrs[name];
|
|
426
|
-
parseAttribute(tag, name, isSVG, isCE, options);
|
|
438
|
+
parseAttribute(tag, name, value, isSVG, isCE, options);
|
|
427
439
|
} else if (name === "###") {
|
|
428
440
|
delete node.attrs[name];
|
|
429
441
|
options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
|
|
@@ -432,17 +444,22 @@ function createHTML(r, {
|
|
|
432
444
|
options.path = tag;
|
|
433
445
|
options.first = false;
|
|
434
446
|
processChildren(node, options);
|
|
447
|
+
if (topDecl) {
|
|
448
|
+
options.decl[0] = options.hasCustomElement ? `const ${tag} = document.importNode(tmpls[${templateId}].content.firstChild, true)` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
|
|
449
|
+
}
|
|
435
450
|
} else if (node.type === "text") {
|
|
436
451
|
const tag = `_$el${uuid++}`;
|
|
437
452
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
438
453
|
options.path = tag;
|
|
439
454
|
options.first = false;
|
|
440
|
-
} else if (node.type === "comment"
|
|
455
|
+
} else if (node.type === "comment") {
|
|
441
456
|
const tag = `_$el${uuid++}`;
|
|
442
457
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
443
|
-
if (
|
|
444
|
-
|
|
445
|
-
|
|
458
|
+
if (node.content === "#") {
|
|
459
|
+
if (options.multi) {
|
|
460
|
+
options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
|
|
461
|
+
} else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
|
|
462
|
+
}
|
|
446
463
|
options.path = tag;
|
|
447
464
|
options.first = false;
|
|
448
465
|
}
|