solid-js 1.1.7 → 1.2.2
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 +22 -12
- package/dist/dev.js +22 -12
- package/dist/server.cjs +1 -0
- package/dist/server.js +1 -1
- package/dist/solid.cjs +22 -12
- package/dist/solid.js +22 -12
- package/h/README.md +99 -0
- package/html/README.md +84 -0
- package/html/dist/html.cjs +24 -6
- package/html/dist/html.js +25 -7
- package/package.json +14 -2
- package/store/README.md +23 -0
- package/types/jsx.d.ts +5 -2
- package/types/render/component.d.ts +1 -1
- package/types/server/index.d.ts +1 -1
- package/universal/README.md +102 -0
- package/universal/dist/dev.cjs +258 -0
- package/universal/dist/dev.js +254 -0
- package/universal/dist/universal.cjs +258 -0
- package/universal/dist/universal.js +254 -0
- package/universal/package.json +8 -0
- package/universal/types/index.d.ts +2 -0
- package/universal/types/universal.d.ts +29 -0
- package/web/README.md +7 -0
- package/web/types/client.d.ts +1 -1
package/dist/dev.cjs
CHANGED
|
@@ -455,6 +455,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
455
455
|
Scheduler = scheduler;
|
|
456
456
|
}
|
|
457
457
|
function startTransition(fn, cb) {
|
|
458
|
+
if (Transition && Transition.running) {
|
|
459
|
+
fn();
|
|
460
|
+
cb && Transition.cb.push(cb);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
458
463
|
queueMicrotask(() => {
|
|
459
464
|
if (Scheduler || SuspenseContext) {
|
|
460
465
|
Transition || (Transition = {
|
|
@@ -548,10 +553,11 @@ function getSuspenseContext() {
|
|
|
548
553
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
549
554
|
}
|
|
550
555
|
function readSignal() {
|
|
551
|
-
|
|
556
|
+
const runningTransition = Transition && Transition.running;
|
|
557
|
+
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
552
558
|
const updates = Updates;
|
|
553
559
|
Updates = null;
|
|
554
|
-
this.state === STALE ||
|
|
560
|
+
!runningTransition && this.state === STALE || runningTransition && this.tState === STALE ? updateComputation(this) : lookDownstream(this);
|
|
555
561
|
Updates = updates;
|
|
556
562
|
}
|
|
557
563
|
if (Listener) {
|
|
@@ -571,7 +577,7 @@ function readSignal() {
|
|
|
571
577
|
this.observerSlots.push(Listener.sources.length - 1);
|
|
572
578
|
}
|
|
573
579
|
}
|
|
574
|
-
if (
|
|
580
|
+
if (runningTransition && Transition.sources.has(this)) return this.tValue;
|
|
575
581
|
return this.value;
|
|
576
582
|
}
|
|
577
583
|
function writeSignal(node, value, isComp) {
|
|
@@ -619,7 +625,7 @@ function updateComputation(node) {
|
|
|
619
625
|
listener = Listener,
|
|
620
626
|
time = ExecCount;
|
|
621
627
|
Listener = Owner = node;
|
|
622
|
-
runComputation(node, node.value, time);
|
|
628
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
623
629
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
624
630
|
queueMicrotask(() => {
|
|
625
631
|
runUpdates(() => {
|
|
@@ -684,7 +690,7 @@ function runTop(node) {
|
|
|
684
690
|
const ancestors = [node];
|
|
685
691
|
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
|
|
686
692
|
if (runningTransition && Transition.disposed.has(node)) return;
|
|
687
|
-
if (node.state || runningTransition && node.tState) ancestors.push(node);
|
|
693
|
+
if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
|
|
688
694
|
}
|
|
689
695
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
690
696
|
node = ancestors[i];
|
|
@@ -695,9 +701,9 @@ function runTop(node) {
|
|
|
695
701
|
if (Transition.disposed.has(top)) return;
|
|
696
702
|
}
|
|
697
703
|
}
|
|
698
|
-
if (node.state === STALE || runningTransition && node.tState === STALE) {
|
|
704
|
+
if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
|
|
699
705
|
updateComputation(node);
|
|
700
|
-
} else if (node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
706
|
+
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
701
707
|
const updates = Updates;
|
|
702
708
|
Updates = null;
|
|
703
709
|
lookDownstream(node);
|
|
@@ -801,10 +807,11 @@ function runUserEffects(queue) {
|
|
|
801
807
|
}
|
|
802
808
|
function lookDownstream(node) {
|
|
803
809
|
node.state = 0;
|
|
810
|
+
const runningTransition = Transition && Transition.running;
|
|
804
811
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
805
812
|
const source = node.sources[i];
|
|
806
813
|
if (source.sources) {
|
|
807
|
-
if (source.state === STALE ||
|
|
814
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
|
|
808
815
|
}
|
|
809
816
|
}
|
|
810
817
|
}
|
|
@@ -812,7 +819,7 @@ function markUpstream(node) {
|
|
|
812
819
|
const runningTransition = Transition && Transition.running;
|
|
813
820
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
814
821
|
const o = node.observers[i];
|
|
815
|
-
if (!o.state || runningTransition && !o.tState) {
|
|
822
|
+
if (!runningTransition && !o.state || runningTransition && !o.tState) {
|
|
816
823
|
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
817
824
|
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
818
825
|
o.observers && markUpstream(o);
|
|
@@ -1166,23 +1173,26 @@ const propTraps = {
|
|
|
1166
1173
|
return _.keys();
|
|
1167
1174
|
}
|
|
1168
1175
|
};
|
|
1176
|
+
function resolveSource(s) {
|
|
1177
|
+
return typeof s === "function" ? s() : s;
|
|
1178
|
+
}
|
|
1169
1179
|
function mergeProps(...sources) {
|
|
1170
1180
|
return new Proxy({
|
|
1171
1181
|
get(property) {
|
|
1172
1182
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1173
|
-
const v = sources[i][property];
|
|
1183
|
+
const v = resolveSource(sources[i])[property];
|
|
1174
1184
|
if (v !== undefined) return v;
|
|
1175
1185
|
}
|
|
1176
1186
|
},
|
|
1177
1187
|
has(property) {
|
|
1178
1188
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1179
|
-
if (property in sources[i]) return true;
|
|
1189
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1180
1190
|
}
|
|
1181
1191
|
return false;
|
|
1182
1192
|
},
|
|
1183
1193
|
keys() {
|
|
1184
1194
|
const keys = [];
|
|
1185
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1195
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1186
1196
|
return [...new Set(keys)];
|
|
1187
1197
|
}
|
|
1188
1198
|
}, propTraps);
|
package/dist/dev.js
CHANGED
|
@@ -451,6 +451,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
451
451
|
Scheduler = scheduler;
|
|
452
452
|
}
|
|
453
453
|
function startTransition(fn, cb) {
|
|
454
|
+
if (Transition && Transition.running) {
|
|
455
|
+
fn();
|
|
456
|
+
cb && Transition.cb.push(cb);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
454
459
|
queueMicrotask(() => {
|
|
455
460
|
if (Scheduler || SuspenseContext) {
|
|
456
461
|
Transition || (Transition = {
|
|
@@ -544,10 +549,11 @@ function getSuspenseContext() {
|
|
|
544
549
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
545
550
|
}
|
|
546
551
|
function readSignal() {
|
|
547
|
-
|
|
552
|
+
const runningTransition = Transition && Transition.running;
|
|
553
|
+
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
548
554
|
const updates = Updates;
|
|
549
555
|
Updates = null;
|
|
550
|
-
this.state === STALE ||
|
|
556
|
+
!runningTransition && this.state === STALE || runningTransition && this.tState === STALE ? updateComputation(this) : lookDownstream(this);
|
|
551
557
|
Updates = updates;
|
|
552
558
|
}
|
|
553
559
|
if (Listener) {
|
|
@@ -567,7 +573,7 @@ function readSignal() {
|
|
|
567
573
|
this.observerSlots.push(Listener.sources.length - 1);
|
|
568
574
|
}
|
|
569
575
|
}
|
|
570
|
-
if (
|
|
576
|
+
if (runningTransition && Transition.sources.has(this)) return this.tValue;
|
|
571
577
|
return this.value;
|
|
572
578
|
}
|
|
573
579
|
function writeSignal(node, value, isComp) {
|
|
@@ -615,7 +621,7 @@ function updateComputation(node) {
|
|
|
615
621
|
listener = Listener,
|
|
616
622
|
time = ExecCount;
|
|
617
623
|
Listener = Owner = node;
|
|
618
|
-
runComputation(node, node.value, time);
|
|
624
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
619
625
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
620
626
|
queueMicrotask(() => {
|
|
621
627
|
runUpdates(() => {
|
|
@@ -680,7 +686,7 @@ function runTop(node) {
|
|
|
680
686
|
const ancestors = [node];
|
|
681
687
|
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
|
|
682
688
|
if (runningTransition && Transition.disposed.has(node)) return;
|
|
683
|
-
if (node.state || runningTransition && node.tState) ancestors.push(node);
|
|
689
|
+
if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
|
|
684
690
|
}
|
|
685
691
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
686
692
|
node = ancestors[i];
|
|
@@ -691,9 +697,9 @@ function runTop(node) {
|
|
|
691
697
|
if (Transition.disposed.has(top)) return;
|
|
692
698
|
}
|
|
693
699
|
}
|
|
694
|
-
if (node.state === STALE || runningTransition && node.tState === STALE) {
|
|
700
|
+
if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
|
|
695
701
|
updateComputation(node);
|
|
696
|
-
} else if (node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
702
|
+
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
697
703
|
const updates = Updates;
|
|
698
704
|
Updates = null;
|
|
699
705
|
lookDownstream(node);
|
|
@@ -797,10 +803,11 @@ function runUserEffects(queue) {
|
|
|
797
803
|
}
|
|
798
804
|
function lookDownstream(node) {
|
|
799
805
|
node.state = 0;
|
|
806
|
+
const runningTransition = Transition && Transition.running;
|
|
800
807
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
801
808
|
const source = node.sources[i];
|
|
802
809
|
if (source.sources) {
|
|
803
|
-
if (source.state === STALE ||
|
|
810
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
|
|
804
811
|
}
|
|
805
812
|
}
|
|
806
813
|
}
|
|
@@ -808,7 +815,7 @@ function markUpstream(node) {
|
|
|
808
815
|
const runningTransition = Transition && Transition.running;
|
|
809
816
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
810
817
|
const o = node.observers[i];
|
|
811
|
-
if (!o.state || runningTransition && !o.tState) {
|
|
818
|
+
if (!runningTransition && !o.state || runningTransition && !o.tState) {
|
|
812
819
|
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
813
820
|
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
814
821
|
o.observers && markUpstream(o);
|
|
@@ -1162,23 +1169,26 @@ const propTraps = {
|
|
|
1162
1169
|
return _.keys();
|
|
1163
1170
|
}
|
|
1164
1171
|
};
|
|
1172
|
+
function resolveSource(s) {
|
|
1173
|
+
return typeof s === "function" ? s() : s;
|
|
1174
|
+
}
|
|
1165
1175
|
function mergeProps(...sources) {
|
|
1166
1176
|
return new Proxy({
|
|
1167
1177
|
get(property) {
|
|
1168
1178
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1169
|
-
const v = sources[i][property];
|
|
1179
|
+
const v = resolveSource(sources[i])[property];
|
|
1170
1180
|
if (v !== undefined) return v;
|
|
1171
1181
|
}
|
|
1172
1182
|
},
|
|
1173
1183
|
has(property) {
|
|
1174
1184
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1175
|
-
if (property in sources[i]) return true;
|
|
1185
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1176
1186
|
}
|
|
1177
1187
|
return false;
|
|
1178
1188
|
},
|
|
1179
1189
|
keys() {
|
|
1180
1190
|
const keys = [];
|
|
1181
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1191
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1182
1192
|
return [...new Set(keys)];
|
|
1183
1193
|
}
|
|
1184
1194
|
}, propTraps);
|
package/dist/server.cjs
CHANGED
|
@@ -510,6 +510,7 @@ exports.SuspenseList = SuspenseList;
|
|
|
510
510
|
exports.Switch = Switch;
|
|
511
511
|
exports.awaitSuspense = awaitSuspense;
|
|
512
512
|
exports.batch = batch;
|
|
513
|
+
exports.children = children;
|
|
513
514
|
exports.createComponent = createComponent;
|
|
514
515
|
exports.createComputed = createComputed;
|
|
515
516
|
exports.createContext = createContext;
|
package/dist/server.js
CHANGED
|
@@ -494,4 +494,4 @@ function awaitSuspense(fn) {
|
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
496
|
|
|
497
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, awaitSuspense, batch, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
497
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, awaitSuspense, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/solid.cjs
CHANGED
|
@@ -452,6 +452,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
452
452
|
Scheduler = scheduler;
|
|
453
453
|
}
|
|
454
454
|
function startTransition(fn, cb) {
|
|
455
|
+
if (Transition && Transition.running) {
|
|
456
|
+
fn();
|
|
457
|
+
cb && Transition.cb.push(cb);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
455
460
|
queueMicrotask(() => {
|
|
456
461
|
if (Scheduler || SuspenseContext) {
|
|
457
462
|
Transition || (Transition = {
|
|
@@ -497,10 +502,11 @@ function getSuspenseContext() {
|
|
|
497
502
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
498
503
|
}
|
|
499
504
|
function readSignal() {
|
|
500
|
-
|
|
505
|
+
const runningTransition = Transition && Transition.running;
|
|
506
|
+
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
501
507
|
const updates = Updates;
|
|
502
508
|
Updates = null;
|
|
503
|
-
this.state === STALE ||
|
|
509
|
+
!runningTransition && this.state === STALE || runningTransition && this.tState === STALE ? updateComputation(this) : lookDownstream(this);
|
|
504
510
|
Updates = updates;
|
|
505
511
|
}
|
|
506
512
|
if (Listener) {
|
|
@@ -520,7 +526,7 @@ function readSignal() {
|
|
|
520
526
|
this.observerSlots.push(Listener.sources.length - 1);
|
|
521
527
|
}
|
|
522
528
|
}
|
|
523
|
-
if (
|
|
529
|
+
if (runningTransition && Transition.sources.has(this)) return this.tValue;
|
|
524
530
|
return this.value;
|
|
525
531
|
}
|
|
526
532
|
function writeSignal(node, value, isComp) {
|
|
@@ -568,7 +574,7 @@ function updateComputation(node) {
|
|
|
568
574
|
listener = Listener,
|
|
569
575
|
time = ExecCount;
|
|
570
576
|
Listener = Owner = node;
|
|
571
|
-
runComputation(node, node.value, time);
|
|
577
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
572
578
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
573
579
|
queueMicrotask(() => {
|
|
574
580
|
runUpdates(() => {
|
|
@@ -632,7 +638,7 @@ function runTop(node) {
|
|
|
632
638
|
const ancestors = [node];
|
|
633
639
|
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
|
|
634
640
|
if (runningTransition && Transition.disposed.has(node)) return;
|
|
635
|
-
if (node.state || runningTransition && node.tState) ancestors.push(node);
|
|
641
|
+
if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
|
|
636
642
|
}
|
|
637
643
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
638
644
|
node = ancestors[i];
|
|
@@ -643,9 +649,9 @@ function runTop(node) {
|
|
|
643
649
|
if (Transition.disposed.has(top)) return;
|
|
644
650
|
}
|
|
645
651
|
}
|
|
646
|
-
if (node.state === STALE || runningTransition && node.tState === STALE) {
|
|
652
|
+
if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
|
|
647
653
|
updateComputation(node);
|
|
648
|
-
} else if (node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
654
|
+
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
649
655
|
const updates = Updates;
|
|
650
656
|
Updates = null;
|
|
651
657
|
lookDownstream(node);
|
|
@@ -748,10 +754,11 @@ function runUserEffects(queue) {
|
|
|
748
754
|
}
|
|
749
755
|
function lookDownstream(node) {
|
|
750
756
|
node.state = 0;
|
|
757
|
+
const runningTransition = Transition && Transition.running;
|
|
751
758
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
752
759
|
const source = node.sources[i];
|
|
753
760
|
if (source.sources) {
|
|
754
|
-
if (source.state === STALE ||
|
|
761
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
|
|
755
762
|
}
|
|
756
763
|
}
|
|
757
764
|
}
|
|
@@ -759,7 +766,7 @@ function markUpstream(node) {
|
|
|
759
766
|
const runningTransition = Transition && Transition.running;
|
|
760
767
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
761
768
|
const o = node.observers[i];
|
|
762
|
-
if (!o.state || runningTransition && !o.tState) {
|
|
769
|
+
if (!runningTransition && !o.state || runningTransition && !o.tState) {
|
|
763
770
|
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
764
771
|
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
765
772
|
o.observers && markUpstream(o);
|
|
@@ -1090,23 +1097,26 @@ const propTraps = {
|
|
|
1090
1097
|
return _.keys();
|
|
1091
1098
|
}
|
|
1092
1099
|
};
|
|
1100
|
+
function resolveSource(s) {
|
|
1101
|
+
return typeof s === "function" ? s() : s;
|
|
1102
|
+
}
|
|
1093
1103
|
function mergeProps(...sources) {
|
|
1094
1104
|
return new Proxy({
|
|
1095
1105
|
get(property) {
|
|
1096
1106
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1097
|
-
const v = sources[i][property];
|
|
1107
|
+
const v = resolveSource(sources[i])[property];
|
|
1098
1108
|
if (v !== undefined) return v;
|
|
1099
1109
|
}
|
|
1100
1110
|
},
|
|
1101
1111
|
has(property) {
|
|
1102
1112
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1103
|
-
if (property in sources[i]) return true;
|
|
1113
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1104
1114
|
}
|
|
1105
1115
|
return false;
|
|
1106
1116
|
},
|
|
1107
1117
|
keys() {
|
|
1108
1118
|
const keys = [];
|
|
1109
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1119
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1110
1120
|
return [...new Set(keys)];
|
|
1111
1121
|
}
|
|
1112
1122
|
}, propTraps);
|
package/dist/solid.js
CHANGED
|
@@ -448,6 +448,11 @@ function enableScheduling(scheduler = requestCallback) {
|
|
|
448
448
|
Scheduler = scheduler;
|
|
449
449
|
}
|
|
450
450
|
function startTransition(fn, cb) {
|
|
451
|
+
if (Transition && Transition.running) {
|
|
452
|
+
fn();
|
|
453
|
+
cb && Transition.cb.push(cb);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
451
456
|
queueMicrotask(() => {
|
|
452
457
|
if (Scheduler || SuspenseContext) {
|
|
453
458
|
Transition || (Transition = {
|
|
@@ -493,10 +498,11 @@ function getSuspenseContext() {
|
|
|
493
498
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
494
499
|
}
|
|
495
500
|
function readSignal() {
|
|
496
|
-
|
|
501
|
+
const runningTransition = Transition && Transition.running;
|
|
502
|
+
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
497
503
|
const updates = Updates;
|
|
498
504
|
Updates = null;
|
|
499
|
-
this.state === STALE ||
|
|
505
|
+
!runningTransition && this.state === STALE || runningTransition && this.tState === STALE ? updateComputation(this) : lookDownstream(this);
|
|
500
506
|
Updates = updates;
|
|
501
507
|
}
|
|
502
508
|
if (Listener) {
|
|
@@ -516,7 +522,7 @@ function readSignal() {
|
|
|
516
522
|
this.observerSlots.push(Listener.sources.length - 1);
|
|
517
523
|
}
|
|
518
524
|
}
|
|
519
|
-
if (
|
|
525
|
+
if (runningTransition && Transition.sources.has(this)) return this.tValue;
|
|
520
526
|
return this.value;
|
|
521
527
|
}
|
|
522
528
|
function writeSignal(node, value, isComp) {
|
|
@@ -564,7 +570,7 @@ function updateComputation(node) {
|
|
|
564
570
|
listener = Listener,
|
|
565
571
|
time = ExecCount;
|
|
566
572
|
Listener = Owner = node;
|
|
567
|
-
runComputation(node, node.value, time);
|
|
573
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
568
574
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
569
575
|
queueMicrotask(() => {
|
|
570
576
|
runUpdates(() => {
|
|
@@ -628,7 +634,7 @@ function runTop(node) {
|
|
|
628
634
|
const ancestors = [node];
|
|
629
635
|
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
|
|
630
636
|
if (runningTransition && Transition.disposed.has(node)) return;
|
|
631
|
-
if (node.state || runningTransition && node.tState) ancestors.push(node);
|
|
637
|
+
if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
|
|
632
638
|
}
|
|
633
639
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
634
640
|
node = ancestors[i];
|
|
@@ -639,9 +645,9 @@ function runTop(node) {
|
|
|
639
645
|
if (Transition.disposed.has(top)) return;
|
|
640
646
|
}
|
|
641
647
|
}
|
|
642
|
-
if (node.state === STALE || runningTransition && node.tState === STALE) {
|
|
648
|
+
if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
|
|
643
649
|
updateComputation(node);
|
|
644
|
-
} else if (node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
650
|
+
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
645
651
|
const updates = Updates;
|
|
646
652
|
Updates = null;
|
|
647
653
|
lookDownstream(node);
|
|
@@ -744,10 +750,11 @@ function runUserEffects(queue) {
|
|
|
744
750
|
}
|
|
745
751
|
function lookDownstream(node) {
|
|
746
752
|
node.state = 0;
|
|
753
|
+
const runningTransition = Transition && Transition.running;
|
|
747
754
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
748
755
|
const source = node.sources[i];
|
|
749
756
|
if (source.sources) {
|
|
750
|
-
if (source.state === STALE ||
|
|
757
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
}
|
|
@@ -755,7 +762,7 @@ function markUpstream(node) {
|
|
|
755
762
|
const runningTransition = Transition && Transition.running;
|
|
756
763
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
757
764
|
const o = node.observers[i];
|
|
758
|
-
if (!o.state || runningTransition && !o.tState) {
|
|
765
|
+
if (!runningTransition && !o.state || runningTransition && !o.tState) {
|
|
759
766
|
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
760
767
|
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
761
768
|
o.observers && markUpstream(o);
|
|
@@ -1086,23 +1093,26 @@ const propTraps = {
|
|
|
1086
1093
|
return _.keys();
|
|
1087
1094
|
}
|
|
1088
1095
|
};
|
|
1096
|
+
function resolveSource(s) {
|
|
1097
|
+
return typeof s === "function" ? s() : s;
|
|
1098
|
+
}
|
|
1089
1099
|
function mergeProps(...sources) {
|
|
1090
1100
|
return new Proxy({
|
|
1091
1101
|
get(property) {
|
|
1092
1102
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1093
|
-
const v = sources[i][property];
|
|
1103
|
+
const v = resolveSource(sources[i])[property];
|
|
1094
1104
|
if (v !== undefined) return v;
|
|
1095
1105
|
}
|
|
1096
1106
|
},
|
|
1097
1107
|
has(property) {
|
|
1098
1108
|
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1099
|
-
if (property in sources[i]) return true;
|
|
1109
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1100
1110
|
}
|
|
1101
1111
|
return false;
|
|
1102
1112
|
},
|
|
1103
1113
|
keys() {
|
|
1104
1114
|
const keys = [];
|
|
1105
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(sources[i]));
|
|
1115
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1106
1116
|
return [...new Set(keys)];
|
|
1107
1117
|
}
|
|
1108
1118
|
}, propTraps);
|
package/h/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Solid HyperScript
|
|
2
|
+
|
|
3
|
+
This sub module provides a HyperScript method for Solid. This is useful to use Solid in non-compiled environments or in some environments where you can only use a standard JSX transform. This method can be used as the JSX factory function.
|
|
4
|
+
|
|
5
|
+
HyperScript function takes a few forms. The 2nd props argument is optional. Children may be passed as either an array to the 2nd/3rd argument or as every argument past the 2nd.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
// create an element with a title attribute
|
|
9
|
+
h("button", { title: "My button" }, "Click Me")
|
|
10
|
+
|
|
11
|
+
// create a component with a title prop
|
|
12
|
+
h(Button, { title: "My button" }, "Click Me")
|
|
13
|
+
|
|
14
|
+
// create an element with many children
|
|
15
|
+
h("div", { title: "My button" }, h("span", "1"), h("span", "2"), h("span", "3"))
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This is the least efficient way to use Solid as it requires a slightly larger runtime that isn't treeshakebable, and cannot leverage anything in the way of analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { render } from "solid-js/web";
|
|
24
|
+
import h from "solid-js/h";
|
|
25
|
+
import { createSignal } from "solid-js";
|
|
26
|
+
|
|
27
|
+
function Button(props) {
|
|
28
|
+
return h("button.btn-primary", props)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function Counter() {
|
|
32
|
+
const [count, setCount] = createSignal(0);
|
|
33
|
+
const increment = (e) => setCount(c => c + 1);
|
|
34
|
+
|
|
35
|
+
return h(Button, { type: "button", onClick: increment }, count);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render(Counter, document.getElementById("app"));
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Differences from JSX
|
|
42
|
+
|
|
43
|
+
There are a few differences from Solid's JSX that are important to note. And also apply when attempting use any transformation that would compile to HyperScript.
|
|
44
|
+
|
|
45
|
+
1. Reactive expression must be manually wrapped in functions to be reactive.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// jsx
|
|
49
|
+
<div id={props.id}>{firstName() + lastName()}</div>
|
|
50
|
+
|
|
51
|
+
// hyperscript
|
|
52
|
+
h("div", { id: () => props.id }, () => firstName() + lastName())
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. Merging spreads requires using the merge props helper to keep reactivity
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
// jsx
|
|
59
|
+
<div class={selectedClass()} {...props} />
|
|
60
|
+
|
|
61
|
+
// hyperscript
|
|
62
|
+
import { mergeProps } from "solid-js"
|
|
63
|
+
|
|
64
|
+
h("div", mergeProps({ class: selectedClass }, props))
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
3. Events on components require explicit event in the arguments
|
|
68
|
+
|
|
69
|
+
Solid's HyperScript automatically wraps functions passed to props of components with no arguments in getters so you need to provide one to prevent this. The same applies to render props like in the `<For>` component.
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
// good
|
|
73
|
+
h(Button, { onClick: (e) => console.log("Hi")});
|
|
74
|
+
|
|
75
|
+
// bad
|
|
76
|
+
h(Button, { onClick: () => console.log("Hi")})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
4. All refs are callback form
|
|
80
|
+
|
|
81
|
+
We can't do the compiled assigment trick so only the callback form is supported.
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
let myEl;
|
|
85
|
+
|
|
86
|
+
h(div, { ref: (el) => myEl = el });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
5. There is a shorthand for static id and classes
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
h("div#some-id.my-class")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
6. Fragments are just arrays
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
[h("span", "1"), h("span", "2")]
|
|
99
|
+
```
|
package/html/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Solid Tagged Template Literals
|
|
2
|
+
|
|
3
|
+
This sub module provides a Tagged Template Literal `html` method for Solid. This is useful to use Solid in non-compiled environments. This method can be used as replacement for JSX.
|
|
4
|
+
|
|
5
|
+
`html` uses `${}` to escape into JavaScript expressions. Components are closed with `<//>`
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
// create an element with a title attribute
|
|
9
|
+
html`<button title="My button">Click Me</button>`
|
|
10
|
+
|
|
11
|
+
// create a component with a title prop
|
|
12
|
+
html`<${Button} title="My button">Click me<//>`
|
|
13
|
+
|
|
14
|
+
// create an element with dynamic attribute and spread
|
|
15
|
+
html`<div title=${() => selectedClass()} ...${props} />`
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Using `html` is slightly less efficient than JSX(but more than HyperScript), requires a larger runtime that isn't treeshakebable, and cannot leverage expression analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { render } from "solid-js/web";
|
|
24
|
+
import html from "solid-js/html";
|
|
25
|
+
import { createSignal } from "solid-js";
|
|
26
|
+
|
|
27
|
+
function Button(props) {
|
|
28
|
+
return html`<button class="btn-primary" ...${props} />`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function Counter() {
|
|
32
|
+
const [count, setCount] = createSignal(0);
|
|
33
|
+
const increment = (e) => setCount((c) => c + 1);
|
|
34
|
+
|
|
35
|
+
return html`<${Button} type="button" onClick=${increment}>${count}<//>`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render(Counter, document.getElementById("app"));
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Differences from JSX
|
|
42
|
+
|
|
43
|
+
There are a few differences from Solid's JSX that are important to note.
|
|
44
|
+
|
|
45
|
+
1. Reactive expression must be manually wrapped in functions to be reactive.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// jsx
|
|
49
|
+
<div id={props.id}>{firstName() + lastName()}</div>
|
|
50
|
+
|
|
51
|
+
// hyperscript
|
|
52
|
+
html`<div id=${() => props.id}>${() => firstName() + lastName()}</div>`
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. Events on components require explicit event in the arguments
|
|
56
|
+
|
|
57
|
+
Solid's Tagged Template Literals automatically wraps functions passed to props of components with no arguments in getters so you need to provide one to prevent this. The same applies to render props like in the `<For>` component.
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
// good
|
|
61
|
+
html`<${Button} onClick=${(e) => console.log("Hi")} />`;
|
|
62
|
+
|
|
63
|
+
// bad
|
|
64
|
+
html`<${Button} onClick=${() => console.log("Hi")} />`;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
4. All refs are callback form
|
|
68
|
+
|
|
69
|
+
We can't do the compiled assigment trick so only the callback form is supported.
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
let myEl;
|
|
73
|
+
html`<div ref=${(el) => myEl = el} />`;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
5. There can be multiple top level elements
|
|
77
|
+
|
|
78
|
+
No need for fragments just:
|
|
79
|
+
```js
|
|
80
|
+
html`
|
|
81
|
+
<div>1</div>
|
|
82
|
+
<div>2</div>
|
|
83
|
+
`
|
|
84
|
+
```
|