solid-ctrl-flow 1.0.60 → 1.0.61

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
@@ -4,53 +4,6 @@ import { JSX } from 'solid-js';
4
4
  import { MemoOptions } from 'solid-js';
5
5
  import { Owner } from 'solid-js';
6
6
  import { ParentProps } from 'solid-js';
7
- import { Signal } from 'solid-js';
8
-
9
- /** Reactive atomic value without the inconveniences of {@link Signal} */
10
- export declare class Atom<T> {
11
- get: Accessor<T>;
12
- set: (x: T) => void;
13
- get value(): T;
14
- set value(v: T);
15
- constructor(get: Accessor<T>, set: (x: T) => void);
16
- /**
17
- * Allows you to set the current {@link Atom} based on its current value.
18
- * The current value gets read through {@link untrack} to mimic the {@link Setter} behaviour
19
- * @param f Function that creates a new value based on the current one
20
- */
21
- update<V extends T>(f: (prev: T) => V): V;
22
- /**
23
- * Creates a new {@link Atom} that applies a conversion to the current one
24
- * @param to Conversion function from {@link S} to {@link D}
25
- * @param from Conversion function from {@link D} to {@link S}
26
- */
27
- convert<R>(to: (x: T) => R, from: (x: R) => T): Atom<R>;
28
- /**
29
- * Creates an {@link Atom} that forwards an {@link Accessor} to another {@link Atom}
30
- * @param f The reactive {@link Accessor} to the {@link Atom} to forward
31
- */
32
- static unwrap<T>(f: Accessor<Atom<T>>): Atom<T>;
33
- /**
34
- * Creates an {@link Atom} based on a {@link Signal}
35
- * @param param0 The {@link Signal} to forward
36
- */
37
- static from<T>([get, set]: Signal<T>): Atom<T>;
38
- /**
39
- * Creates an {@link Atom} based on an object property.
40
- * The result of {@link k} will be memoized, while {@link obj}'s one won't
41
- * @param obj The object containing the property
42
- * @param k A function that returns the key of the property and will be passed to {@link nameOf}
43
- */
44
- static prop<T, K extends keyof T>(obj: Accessor<T>, k: (x: NamesOf<T>) => K): Atom<T[K]>;
45
- /**
46
- * Creates a bindable data source.
47
- * If {@link bind} returns an {@link Atom} it gets wrapped, otherwise it creates a {@link Signal} using {@link f} and uses it to store the value until {@link bind}'s value changes
48
- * @param bind The bound {@link Atom}
49
- * @param f The function that will create the actual {@link Signal} that will store the {@link Atom}'s data in case that {@link bind} doesn't return anything
50
- */
51
- static source<T>(bind: Accessor<Atom<T> | undefined>): Atom<T | undefined>;
52
- static source<T>(bind: Accessor<Atom<T> | undefined>, f: Accessor<Signal<T>>): Atom<T>;
53
- }
54
7
 
55
8
  /** Type hack for making {@link ReactiveContext} implement {@link Accessor} */
56
9
  declare const BASE_CTOR: new <T>() => Accessor<T>;
@@ -156,19 +109,6 @@ export declare function memoProps<T>(obj: T, keys?: undefined, equals?: Equals):
156
109
 
157
110
  export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, keys: K, equals?: Equals): Pick<T, K[number]>;
158
111
 
159
- /**
160
- * Function that returns the name of the field accessed inside of {@link f}.
161
- * This function is not meant to be used on its own because it has very poor type inference
162
- * @param f A function that returns a value based on {@link NamesOf}
163
- * @returns The same thing that {@link f} returned
164
- */
165
- export declare const nameOf: <T, const R>(f: (x: NamesOf<T>) => R) => R;
166
-
167
- /** Type that maps each key of {@link T} to itself */
168
- export declare type NamesOf<T> = {
169
- [k in keyof T]: k;
170
- };
171
-
172
112
  /**
173
113
  * Allows the use of {@link Case}s inside of {@link Switch}es.
174
114
  * Example:
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, splitProps, Show, onCleanup, For, Match, mergeProps, on, createSignal } from "solid-js";
1
+ import { useContext, createMemo, createComponent, createContext, createRoot, getOwner, untrack, splitProps, Show, onCleanup, For, Match, mergeProps } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
3
  const BASE_CTOR = Function;
4
4
  class ReactiveContext extends BASE_CTOR {
@@ -67,8 +67,6 @@ function runWithContext(ctx2, value, f) {
67
67
  function untrackCall(f, ...args) {
68
68
  return untrack(() => f.apply(this, args));
69
69
  }
70
- const PROXY_KEYOF = new Proxy({}, { get: (_, k) => k });
71
- const nameOf = (f) => f(PROXY_KEYOF);
72
70
  function memoProps(obj, keys = Object.keys(obj), equals = false) {
73
71
  const out = {};
74
72
  for (const elm of keys)
@@ -226,61 +224,6 @@ function Case(props) {
226
224
  }
227
225
  }, other));
228
226
  }
229
- class Atom {
230
- constructor(get, set) {
231
- this.get = get;
232
- this.set = set;
233
- }
234
- get value() {
235
- return this.get();
236
- }
237
- set value(v) {
238
- this.set(v);
239
- }
240
- /**
241
- * Allows you to set the current {@link Atom} based on its current value.
242
- * The current value gets read through {@link untrack} to mimic the {@link Setter} behaviour
243
- * @param f Function that creates a new value based on the current one
244
- */
245
- update(f) {
246
- return this.value = f(untrack(this.get));
247
- }
248
- /**
249
- * Creates a new {@link Atom} that applies a conversion to the current one
250
- * @param to Conversion function from {@link S} to {@link D}
251
- * @param from Conversion function from {@link D} to {@link S}
252
- */
253
- convert(to, from) {
254
- return new Atom(() => to(this.value), (v) => this.value = from(v));
255
- }
256
- /**
257
- * Creates an {@link Atom} that forwards an {@link Accessor} to another {@link Atom}
258
- * @param f The reactive {@link Accessor} to the {@link Atom} to forward
259
- */
260
- static unwrap(f) {
261
- return new this(() => f().value, (v) => f().value = v);
262
- }
263
- /**
264
- * Creates an {@link Atom} based on a {@link Signal}
265
- * @param param0 The {@link Signal} to forward
266
- */
267
- static from([get, set]) {
268
- return new this(get, (v) => set(() => v));
269
- }
270
- /**
271
- * Creates an {@link Atom} based on an object property.
272
- * The result of {@link k} will be memoized, while {@link obj}'s one won't
273
- * @param obj The object containing the property
274
- * @param k A function that returns the key of the property and will be passed to {@link nameOf}
275
- */
276
- static prop(obj, k) {
277
- const temp = createMemo(() => nameOf(k));
278
- return new this(() => obj()[temp()], (v) => obj()[temp()] = v);
279
- }
280
- static source(bind, f = createSignal) {
281
- return this.unwrap(createMemo(on(bind, (x) => x ?? Atom.from(f()))));
282
- }
283
- }
284
227
  const debug = ReactiveContext.create(false, "debug-scope");
285
228
  function SameContext(props) {
286
229
  return createMemo(() => {
@@ -289,7 +232,6 @@ function SameContext(props) {
289
232
  });
290
233
  }
291
234
  export {
292
- Atom,
293
235
  Case,
294
236
  Enfold,
295
237
  On,
@@ -299,7 +241,6 @@ export {
299
241
  createExtractor,
300
242
  debug,
301
243
  memoProps,
302
- nameOf,
303
244
  runWithContext,
304
245
  splitAndMemoProps,
305
246
  untrackCall,
package/dist/index.umd.js CHANGED
@@ -69,8 +69,6 @@
69
69
  function untrackCall(f, ...args) {
70
70
  return solidJs.untrack(() => f.apply(this, args));
71
71
  }
72
- const PROXY_KEYOF = new Proxy({}, { get: (_, k) => k });
73
- const nameOf = (f) => f(PROXY_KEYOF);
74
72
  function memoProps(obj, keys = Object.keys(obj), equals = false) {
75
73
  const out = {};
76
74
  for (const elm of keys)
@@ -228,61 +226,6 @@
228
226
  }
229
227
  }, other));
230
228
  }
231
- class Atom {
232
- constructor(get, set) {
233
- this.get = get;
234
- this.set = set;
235
- }
236
- get value() {
237
- return this.get();
238
- }
239
- set value(v) {
240
- this.set(v);
241
- }
242
- /**
243
- * Allows you to set the current {@link Atom} based on its current value.
244
- * The current value gets read through {@link untrack} to mimic the {@link Setter} behaviour
245
- * @param f Function that creates a new value based on the current one
246
- */
247
- update(f) {
248
- return this.value = f(solidJs.untrack(this.get));
249
- }
250
- /**
251
- * Creates a new {@link Atom} that applies a conversion to the current one
252
- * @param to Conversion function from {@link S} to {@link D}
253
- * @param from Conversion function from {@link D} to {@link S}
254
- */
255
- convert(to, from) {
256
- return new Atom(() => to(this.value), (v) => this.value = from(v));
257
- }
258
- /**
259
- * Creates an {@link Atom} that forwards an {@link Accessor} to another {@link Atom}
260
- * @param f The reactive {@link Accessor} to the {@link Atom} to forward
261
- */
262
- static unwrap(f) {
263
- return new this(() => f().value, (v) => f().value = v);
264
- }
265
- /**
266
- * Creates an {@link Atom} based on a {@link Signal}
267
- * @param param0 The {@link Signal} to forward
268
- */
269
- static from([get, set]) {
270
- return new this(get, (v) => set(() => v));
271
- }
272
- /**
273
- * Creates an {@link Atom} based on an object property.
274
- * The result of {@link k} will be memoized, while {@link obj}'s one won't
275
- * @param obj The object containing the property
276
- * @param k A function that returns the key of the property and will be passed to {@link nameOf}
277
- */
278
- static prop(obj, k) {
279
- const temp = solidJs.createMemo(() => nameOf(k));
280
- return new this(() => obj()[temp()], (v) => obj()[temp()] = v);
281
- }
282
- static source(bind, f = solidJs.createSignal) {
283
- return this.unwrap(solidJs.createMemo(solidJs.on(bind, (x) => x ?? Atom.from(f()))));
284
- }
285
- }
286
229
  const debug = ReactiveContext.create(false, "debug-scope");
287
230
  function SameContext(props) {
288
231
  return solidJs.createMemo(() => {
@@ -290,7 +233,6 @@
290
233
  return props.children;
291
234
  });
292
235
  }
293
- exports2.Atom = Atom;
294
236
  exports2.Case = Case;
295
237
  exports2.Enfold = Enfold;
296
238
  exports2.On = On;
@@ -299,7 +241,6 @@
299
241
  exports2.createExtractor = createExtractor;
300
242
  exports2.debug = debug;
301
243
  exports2.memoProps = memoProps;
302
- exports2.nameOf = nameOf;
303
244
  exports2.runWithContext = runWithContext;
304
245
  exports2.splitAndMemoProps = splitAndMemoProps;
305
246
  exports2.untrackCall = untrackCall;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",
package/readMe.md CHANGED
@@ -162,30 +162,6 @@ return <>
162
162
 
163
163
  ## Utility
164
164
 
165
- ### `Atom`s
166
- Customizable and simplified wrappers for reactive states
167
-
168
- > #### `new Atom()`
169
- > Creates an `Atom` with custom getter and setter
170
- >
171
- > #### `Atom.update()`
172
- > Like the `Setter` overload of a `Signal` that takes a function with the previous value
173
- >
174
- > #### `Atom.convert()`
175
- > Creates a new `Atom` that applies a conversion to the current one
176
- >
177
- > #### `Atom.unwrap()`
178
- > An `Atom`-specific (optimized) version of `unwrap()` that allows the destructuring of its result
179
- >
180
- > #### `Atom.from()`
181
- > Creates an `Atom` based on a `Signal`
182
- >
183
- > #### `Atom.prop()`
184
- > Creates an `Atom` based on an object property
185
- >
186
- > #### `Atom.source()`
187
- > Similiar to `Atom.unwrap()`, but if the `Accessor` doesn't return anything it automatically creates an internal `Signal` in which to store the value
188
-
189
165
  ### `ReactiveContext.create()`
190
166
  Method that creates a reactive version of a solid `Context` with some additional built-in functionalities
191
167
  ```ts
@@ -218,9 +194,6 @@ return <>
218
194
  ### `untrackCall()`
219
195
  Calls a function untracking what happens inside of it but not what gets passed as its argument
220
196
 
221
- ### `nameOf()`
222
- Utility function that powers `Atom.prop()`
223
-
224
197
  ### `memoProps()`
225
198
  Creates a partial version of an object with memoized remaining properties
226
199