solid-ctrl-flow 1.0.33 → 1.0.34

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 CHANGED
@@ -7,6 +7,9 @@ import { Resource } from 'solid-js';
7
7
  import { Setter } from 'solid-js';
8
8
  import { Signal } from 'solid-js';
9
9
 
10
+ /** Type hack for making {@link ReactiveContext} implement {@link Accessor} */
11
+ declare const BASE_CTOR: new <T>() => Accessor<T>;
12
+
10
13
  /**
11
14
  * Creates a one-way binding between two {@link Signal}s.
12
15
  * The function uses {@link createRenderEffect}, which means that:
@@ -126,17 +129,8 @@ export declare function createExtractor(name?: string): {
126
129
  */
127
130
  export declare function createReactiveResource<R>(f: EffectFunction<R | undefined, R>): Resource<Awaited<R>>;
128
131
 
129
- /** Creates a scope for the value of {@link Debug.isDebug}, which allows you to display different things in debug mode */
130
- export declare function Debug(props: {
131
- value?: boolean;
132
- children?: JSX.Element;
133
- }): JSX.Element;
134
-
135
- /** Internals of {@link Debug} */
136
- export declare namespace Debug {
137
- /** Returns an {@link Accessor} that tells whether the current {@link Owner} is in debug mode */
138
- const isDebug: Accessor<boolean>;
139
- }
132
+ /** Built-in {@link ReactiveContext} which allows you to display different things in debug mode */
133
+ export declare const debug: ReactiveContext<boolean>;
140
134
 
141
135
  /** Informations about a {@link Source} component */
142
136
  declare type Info = {
@@ -157,7 +151,7 @@ export declare function memoProps<T, K extends readonly (keyof T)[] = (keyof T)[
157
151
  * Reactive {@link Context} with some additional built-in functionalities.
158
152
  * The call signature returns the value in the current {@link Owner} (It's like calling {@link read})
159
153
  */
160
- export declare abstract class ReactiveContext<T> extends ReactiveContext_base<T> {
154
+ export declare abstract class ReactiveContext<T> extends BASE_CTOR<T> {
161
155
  /** The actual {@link Context} that contains the reactive {@link Accessor} to the value */
162
156
  abstract ctx: Context<Accessor<T>>;
163
157
  /**
@@ -192,8 +186,6 @@ export declare abstract class ReactiveContext<T> extends ReactiveContext_base<T>
192
186
  static create<T>(defaultValue: T, name?: string): ReactiveContext<T>;
193
187
  }
194
188
 
195
- declare const ReactiveContext_base: new <T_1>() => Accessor<T_1>;
196
-
197
189
  /**
198
190
  * Executes a {@link Ref}.
199
191
  * Throws a {@link ReferenceError} if {@link ref} its not a function at runtime (Which should never be the case thanks to the solid compiler)
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { useContext, createMemo, createComponent, createContext, Match, mergeProps, onCleanup, For, Show, createRoot, createRenderEffect, on, untrack, splitProps, getOwner, createEffect, createResource } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
- class ReactiveContext extends Function {
3
+ const BASE_CTOR = Function;
4
+ class ReactiveContext extends BASE_CTOR {
4
5
  /** The actual {@link Context} that contains the reactive {@link Accessor} to the value */
5
6
  /**
6
7
  * Returns the {@link Accessor} for the value in the current {@link Owner}.
@@ -53,13 +54,13 @@ class ReactiveContext extends Function {
53
54
  return out;
54
55
  }
55
56
  }
56
- const ctx$1 = ReactiveContext.create(void 0, "case-when");
57
- const Case = ctx$1.Provider;
57
+ const ctx = ReactiveContext.create(void 0, "case-when");
58
+ const Case = ctx.Provider;
58
59
  function When(props) {
59
60
  const [mine, other] = splitAndMemoProps(props, ["value", "pred"]);
60
61
  const {
61
62
  read
62
- } = ctx$1;
63
+ } = ctx;
63
64
  const pred = (x) => mine.pred ? mine.pred(x) : x === mine.value;
64
65
  return createComponent(Match, mergeProps({
65
66
  get when() {
@@ -67,22 +68,6 @@ function When(props) {
67
68
  }
68
69
  }, other));
69
70
  }
70
- const ctx = ReactiveContext.create(false, "debug-scope");
71
- function Debug(props) {
72
- return createComponent(ctx.Provider, {
73
- get value() {
74
- return props.value ?? true;
75
- },
76
- get children() {
77
- return props.children;
78
- }
79
- });
80
- }
81
- (function(_Debug) {
82
- Object.defineProperty(Debug, "isDebug", {
83
- get: () => ctx.read
84
- });
85
- })(Debug || (Debug = {}));
86
71
  function createExtractor(name = "extractor") {
87
72
  const ctx2 = createContext(void 0, {
88
73
  name
@@ -226,9 +211,9 @@ function createReactiveResource(f) {
226
211
  }] = createResource(memo);
227
212
  return get;
228
213
  }
214
+ const debug = ReactiveContext.create(false, "debug-scope");
229
215
  export {
230
216
  Case,
231
- Debug,
232
217
  ReactiveContext,
233
218
  When,
234
219
  bind,
@@ -236,6 +221,7 @@ export {
236
221
  coalesceSignal,
237
222
  createExtractor,
238
223
  createReactiveResource,
224
+ debug,
239
225
  memoProps,
240
226
  refCall,
241
227
  runWithContext,
package/dist/index.umd.js CHANGED
@@ -2,7 +2,8 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("solid-js"), require("solid-js/store")) : typeof define === "function" && define.amd ? define(["exports", "solid-js", "solid-js/store"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.solidCtrlFlow = {}, global.solidJs, global.solidJsStore));
3
3
  })(this, function(exports2, solidJs, store) {
4
4
  "use strict";
5
- class ReactiveContext extends Function {
5
+ const BASE_CTOR = Function;
6
+ class ReactiveContext extends BASE_CTOR {
6
7
  /** The actual {@link Context} that contains the reactive {@link Accessor} to the value */
7
8
  /**
8
9
  * Returns the {@link Accessor} for the value in the current {@link Owner}.
@@ -55,13 +56,13 @@
55
56
  return out;
56
57
  }
57
58
  }
58
- const ctx$1 = ReactiveContext.create(void 0, "case-when");
59
- const Case = ctx$1.Provider;
59
+ const ctx = ReactiveContext.create(void 0, "case-when");
60
+ const Case = ctx.Provider;
60
61
  function When(props) {
61
62
  const [mine, other] = splitAndMemoProps(props, ["value", "pred"]);
62
63
  const {
63
64
  read
64
- } = ctx$1;
65
+ } = ctx;
65
66
  const pred = (x) => mine.pred ? mine.pred(x) : x === mine.value;
66
67
  return solidJs.createComponent(solidJs.Match, solidJs.mergeProps({
67
68
  get when() {
@@ -69,22 +70,6 @@
69
70
  }
70
71
  }, other));
71
72
  }
72
- const ctx = ReactiveContext.create(false, "debug-scope");
73
- function Debug(props) {
74
- return solidJs.createComponent(ctx.Provider, {
75
- get value() {
76
- return props.value ?? true;
77
- },
78
- get children() {
79
- return props.children;
80
- }
81
- });
82
- }
83
- (function(_Debug) {
84
- Object.defineProperty(Debug, "isDebug", {
85
- get: () => ctx.read
86
- });
87
- })(Debug || (Debug = {}));
88
73
  function createExtractor(name = "extractor") {
89
74
  const ctx2 = solidJs.createContext(void 0, {
90
75
  name
@@ -228,8 +213,8 @@
228
213
  }] = solidJs.createResource(memo);
229
214
  return get;
230
215
  }
216
+ const debug = ReactiveContext.create(false, "debug-scope");
231
217
  exports2.Case = Case;
232
- exports2.Debug = Debug;
233
218
  exports2.ReactiveContext = ReactiveContext;
234
219
  exports2.When = When;
235
220
  exports2.bind = bind;
@@ -237,6 +222,7 @@
237
222
  exports2.coalesceSignal = coalesceSignal;
238
223
  exports2.createExtractor = createExtractor;
239
224
  exports2.createReactiveResource = createReactiveResource;
225
+ exports2.debug = debug;
240
226
  exports2.memoProps = memoProps;
241
227
  exports2.refCall = refCall;
242
228
  exports2.runWithContext = runWithContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",