solid-ctrl-flow 1.0.54 → 1.0.56
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/index.d.ts +7 -16
- package/dist/index.mjs +2 -17
- package/dist/index.umd.js +1 -16
- package/package.json +1 -2
- package/readMe.md +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -14,10 +14,9 @@ declare const BASE_CTOR: new <T>() => Accessor<T>;
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates a one-way binding between two {@link Signal}s.
|
|
17
|
-
* The function uses {@link
|
|
17
|
+
* The function uses {@link createComputed}, which means that:
|
|
18
18
|
* - As soon as the function is done executing the two {@link Signal}s will have the same value
|
|
19
|
-
* - If {@link source} changes, {@link dest}
|
|
20
|
-
* - If the current owner gets disposed before {@link dest} is updated, it never will
|
|
19
|
+
* - If {@link source} changes, {@link dest} will be instantly updated
|
|
21
20
|
* @param source The getter of the source of the binding
|
|
22
21
|
* @param dest The setter of the destination of the binding
|
|
23
22
|
* @param to Conversion function from {@link S} to {@link D}
|
|
@@ -46,29 +45,21 @@ export declare function Case(props: ParentProps<{
|
|
|
46
45
|
}>): JSX.Element;
|
|
47
46
|
|
|
48
47
|
export declare function Case(props: ParentProps<{
|
|
49
|
-
pred
|
|
48
|
+
pred(x: any): unknown;
|
|
50
49
|
}>): JSX.Element;
|
|
51
50
|
|
|
52
51
|
export declare function Case<T>(props: {
|
|
53
|
-
pred
|
|
52
|
+
pred(x: any): T;
|
|
54
53
|
keyed?: false;
|
|
55
|
-
children
|
|
54
|
+
children(x: Accessor<NonNullable<T>>): JSX.Element;
|
|
56
55
|
}): JSX.Element;
|
|
57
56
|
|
|
58
57
|
export declare function Case<T>(props: {
|
|
59
|
-
pred
|
|
58
|
+
pred(x: any): T;
|
|
60
59
|
keyed: true;
|
|
61
|
-
children
|
|
60
|
+
children(x: NonNullable<T>): JSX.Element;
|
|
62
61
|
}): JSX.Element;
|
|
63
62
|
|
|
64
|
-
/**
|
|
65
|
-
* Returns a {@link Signal} that applies the `??=` operator to the input one.
|
|
66
|
-
* If the getter of {@link param0} is like `x`, then the result one is like "(x ??= {@link f}())"
|
|
67
|
-
* @param param0 The {@link Signal} to which to coalesce the getter
|
|
68
|
-
* @param f An {@link Accessor} to the value to use when there's a nullish value
|
|
69
|
-
*/
|
|
70
|
-
export declare function coalesceSignal<T>([get, set]: Signal<T | undefined>, f: Accessor<T>): Signal<T>;
|
|
71
|
-
|
|
72
63
|
/** Conversion function for bindings */
|
|
73
64
|
export declare type Convert<S, D> = (x: S, prev: D) => D;
|
|
74
65
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, Match, mergeProps,
|
|
1
|
+
import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, createEffect, on, createResource, splitProps, Show, onCleanup, For, Match, mergeProps, createComputed, createSignal } from "solid-js";
|
|
2
2
|
import { createMutable } from "solid-js/store";
|
|
3
3
|
const BASE_CTOR = Function;
|
|
4
4
|
class ReactiveContext extends BASE_CTOR {
|
|
@@ -233,7 +233,7 @@ function Case(props) {
|
|
|
233
233
|
}
|
|
234
234
|
const IDENTITY = (x) => x;
|
|
235
235
|
function bind(source, dest, to = IDENTITY, skip = false) {
|
|
236
|
-
const d = createRoot((d2) => (
|
|
236
|
+
const d = createRoot((d2) => (createComputed(on(source, (x) => skip ? skip = false : dest((prev) => to(x, prev)))), d2));
|
|
237
237
|
return onCleanup(d), d;
|
|
238
238
|
}
|
|
239
239
|
function bindTwoWay(source, dest, to, from) {
|
|
@@ -264,20 +264,6 @@ function forceSignal([get, set]) {
|
|
|
264
264
|
}
|
|
265
265
|
];
|
|
266
266
|
}
|
|
267
|
-
function coalesceSignal([get, set], f) {
|
|
268
|
-
return [getter, set];
|
|
269
|
-
function getter() {
|
|
270
|
-
const out = get();
|
|
271
|
-
if (out != null)
|
|
272
|
-
return out;
|
|
273
|
-
const listener = getListener(), { state } = listener;
|
|
274
|
-
try {
|
|
275
|
-
return set(f);
|
|
276
|
-
} finally {
|
|
277
|
-
listener.state = state;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
267
|
const debug = ReactiveContext.create(false, "debug-scope");
|
|
282
268
|
function SameContext(props) {
|
|
283
269
|
return createMemo(() => {
|
|
@@ -294,7 +280,6 @@ export {
|
|
|
294
280
|
Slot,
|
|
295
281
|
bind,
|
|
296
282
|
bindTwoWay,
|
|
297
|
-
coalesceSignal,
|
|
298
283
|
createExtractor,
|
|
299
284
|
createReactiveResource,
|
|
300
285
|
debug,
|
package/dist/index.umd.js
CHANGED
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
}
|
|
236
236
|
const IDENTITY = (x) => x;
|
|
237
237
|
function bind(source, dest, to = IDENTITY, skip = false) {
|
|
238
|
-
const d = solidJs.createRoot((d2) => (solidJs.
|
|
238
|
+
const d = solidJs.createRoot((d2) => (solidJs.createComputed(solidJs.on(source, (x) => skip ? skip = false : dest((prev) => to(x, prev)))), d2));
|
|
239
239
|
return solidJs.onCleanup(d), d;
|
|
240
240
|
}
|
|
241
241
|
function bindTwoWay(source, dest, to, from) {
|
|
@@ -266,20 +266,6 @@
|
|
|
266
266
|
}
|
|
267
267
|
];
|
|
268
268
|
}
|
|
269
|
-
function coalesceSignal([get, set], f) {
|
|
270
|
-
return [getter, set];
|
|
271
|
-
function getter() {
|
|
272
|
-
const out = get();
|
|
273
|
-
if (out != null)
|
|
274
|
-
return out;
|
|
275
|
-
const listener = solidJs.getListener(), { state } = listener;
|
|
276
|
-
try {
|
|
277
|
-
return set(f);
|
|
278
|
-
} finally {
|
|
279
|
-
listener.state = state;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
269
|
const debug = ReactiveContext.create(false, "debug-scope");
|
|
284
270
|
function SameContext(props) {
|
|
285
271
|
return solidJs.createMemo(() => {
|
|
@@ -294,7 +280,6 @@
|
|
|
294
280
|
exports2.SameContext = SameContext;
|
|
295
281
|
exports2.bind = bind;
|
|
296
282
|
exports2.bindTwoWay = bindTwoWay;
|
|
297
|
-
exports2.coalesceSignal = coalesceSignal;
|
|
298
283
|
exports2.createExtractor = createExtractor;
|
|
299
284
|
exports2.createReactiveResource = createReactiveResource;
|
|
300
285
|
exports2.debug = debug;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-ctrl-flow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.56",
|
|
4
4
|
"description": "Control flow components for solid-js",
|
|
5
5
|
"author": "AFatNiBBa",
|
|
6
6
|
"license": "ISC",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^20.6.0",
|
|
19
|
-
"logic-types": "^1.3.2",
|
|
20
19
|
"vite": "^4.4.9",
|
|
21
20
|
"vite-plugin-dts": "^3.5.3",
|
|
22
21
|
"vite-plugin-solid": "^2.7.0"
|
package/readMe.md
CHANGED
|
@@ -182,9 +182,6 @@ Functions that create bindings between `Signal`s
|
|
|
182
182
|
>
|
|
183
183
|
> #### `forceSignal()`
|
|
184
184
|
> Creates a `Signal` that behaves like the input one, with the only difference that each call to the setter will trigger the effects even if the value didn't change
|
|
185
|
-
>
|
|
186
|
-
> #### `coalesceSignal()`
|
|
187
|
-
> Creates a non nullable `Signal` from a nullable one
|
|
188
185
|
|
|
189
186
|
### `ReactiveContext.create()`
|
|
190
187
|
Method that creates a reactive version of a solid `Context` with some additional built-in functionalities
|