@solid-primitives/utils 3.1.0 → 4.0.0

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.cjs CHANGED
@@ -73,40 +73,6 @@ function createProxy(traps) {
73
73
  }
74
74
  );
75
75
  }
76
- var createTrigger = isDev ? () => solidJs.createSignal(void 0, { equals: false, name: "trigger" }) : () => solidJs.createSignal(void 0, { equals: false });
77
- function dirtyTriggerCache(key) {
78
- const trigger = this.get(key);
79
- if (trigger)
80
- trigger[1]();
81
- }
82
- function dirtyAllTriggerCache() {
83
- this.forEach((s) => s[1]());
84
- }
85
- function trackTriggerCache(key) {
86
- if (!solidJs.getListener())
87
- return;
88
- let trigger = this.get(key);
89
- if (!trigger) {
90
- trigger = createTrigger();
91
- this.set(key, trigger);
92
- }
93
- trigger[0]();
94
- }
95
- function createTriggerCache() {
96
- const cache = /* @__PURE__ */ new Map();
97
- return {
98
- dirty: dirtyTriggerCache.bind(cache),
99
- dirtyAll: dirtyAllTriggerCache.bind(cache),
100
- track: trackTriggerCache.bind(cache)
101
- };
102
- }
103
- function createWeakTriggerCache() {
104
- const cache = /* @__PURE__ */ new WeakMap();
105
- return {
106
- dirty: dirtyTriggerCache.bind(cache),
107
- track: trackTriggerCache.bind(cache)
108
- };
109
- }
110
76
  function createStaticStore(init) {
111
77
  const copy = { ...init };
112
78
  const store = {};
@@ -195,9 +161,6 @@ exports.createCallbackStack = createCallbackStack;
195
161
  exports.createMicrotask = createMicrotask;
196
162
  exports.createProxy = createProxy;
197
163
  exports.createStaticStore = createStaticStore;
198
- exports.createTrigger = createTrigger;
199
- exports.createTriggerCache = createTriggerCache;
200
- exports.createWeakTriggerCache = createWeakTriggerCache;
201
164
  exports.entries = entries;
202
165
  exports.forEachEntry = forEachEntry;
203
166
  exports.handleDiffArray = handleDiffArray;
package/dist/index.d.ts CHANGED
@@ -162,61 +162,6 @@ declare function createProxy<T extends Record<string | symbol, any>>(traps: {
162
162
  get: <K extends keyof T>(key: K) => T[K];
163
163
  set?: undefined;
164
164
  }): Readonly<T>;
165
- declare type Trigger = [track: VoidFunction, dirty: VoidFunction];
166
- /**
167
- * Set listeners in reactive computations and then trigger them when you want.
168
- * @returns `[track function, dirty function]`
169
- * @example
170
- * const [track, dirty] = createTrigger()
171
- * createEffect(() => {
172
- * track()
173
- * ...
174
- * })
175
- * // later
176
- * dirty()
177
- */
178
- declare const createTrigger: () => Trigger;
179
- declare type TriggerCache<T> = {
180
- track: (v: T) => void;
181
- dirty: (v: T) => void;
182
- dirtyAll: VoidFunction;
183
- };
184
- /**
185
- * Set listeners in reactive computations and then trigger them when you want. Cache trackers by a `key`.
186
- * @returns `{ track, dirty, dirtyAll }` functions
187
- * `track` and `dirty` are called with a `key` so that each tracker will trigger an update only when his individual `key` would get marked as dirty.
188
- * @example
189
- * const { track, dirty } = createTriggerCache()
190
- * createEffect(() => {
191
- * track(1)
192
- * ...
193
- * })
194
- * // later
195
- * dirty(1)
196
- * // this won't cause an update:
197
- * dirty(2)
198
- */
199
- declare function createTriggerCache<T>(): TriggerCache<T>;
200
- declare type WeakTriggerCache<T extends object> = {
201
- track: (v: T) => void;
202
- dirty: (v: T) => void;
203
- };
204
- /**
205
- * Set listeners in reactive computations and then trigger them when you want. Cache trackers by a `key`.
206
- * @returns `{ track, dirty }` functions
207
- * `track` and `dirty` are called with a `key` so that each tracker will trigger an update only when his individual `key` would get marked as dirty.
208
- * @example
209
- * const { track, dirty } = createWeakTriggerCache()
210
- * createEffect(() => {
211
- * track(1)
212
- * ...
213
- * })
214
- * // later
215
- * dirty(1)
216
- * // this won't cause an update:
217
- * dirty(2)
218
- */
219
- declare function createWeakTriggerCache<T extends object>(): WeakTriggerCache<T>;
220
165
  declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = {
221
166
  (setter: (prev: T) => Partial<T>): T;
222
167
  (state: Partial<T>): T;
@@ -242,4 +187,4 @@ declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [acc
242
187
  declare function handleDiffArray<T>(current: readonly T[], prev: readonly T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void;
243
188
  declare const forEachEntry: <T>(obj: Record<string, T>, fn: (key: string, value: T) => void) => void;
244
189
 
245
- export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, WeakTriggerCache, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, createWeakTriggerCache, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess };
190
+ export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEV, getOwner, onCleanup, createSignal, getListener, untrack, batch } from 'solid-js';
1
+ import { DEV, getOwner, onCleanup, createSignal, untrack, batch } from 'solid-js';
2
2
  import { isServer as isServer$1 } from 'solid-js/web';
3
3
 
4
4
  // src/index.ts
@@ -69,40 +69,6 @@ function createProxy(traps) {
69
69
  }
70
70
  );
71
71
  }
72
- var createTrigger = isDev ? () => createSignal(void 0, { equals: false, name: "trigger" }) : () => createSignal(void 0, { equals: false });
73
- function dirtyTriggerCache(key) {
74
- const trigger = this.get(key);
75
- if (trigger)
76
- trigger[1]();
77
- }
78
- function dirtyAllTriggerCache() {
79
- this.forEach((s) => s[1]());
80
- }
81
- function trackTriggerCache(key) {
82
- if (!getListener())
83
- return;
84
- let trigger = this.get(key);
85
- if (!trigger) {
86
- trigger = createTrigger();
87
- this.set(key, trigger);
88
- }
89
- trigger[0]();
90
- }
91
- function createTriggerCache() {
92
- const cache = /* @__PURE__ */ new Map();
93
- return {
94
- dirty: dirtyTriggerCache.bind(cache),
95
- dirtyAll: dirtyAllTriggerCache.bind(cache),
96
- track: trackTriggerCache.bind(cache)
97
- };
98
- }
99
- function createWeakTriggerCache() {
100
- const cache = /* @__PURE__ */ new WeakMap();
101
- return {
102
- dirty: dirtyTriggerCache.bind(cache),
103
- track: trackTriggerCache.bind(cache)
104
- };
105
- }
106
72
  function createStaticStore(init) {
107
73
  const copy = { ...init };
108
74
  const store = {};
@@ -178,4 +144,4 @@ function handleDiffArray(current, prev, handleAdded, handleRemoved) {
178
144
  }
179
145
  var forEachEntry = (obj, fn) => Object.entries(obj).forEach(([key, value]) => fn(key, value));
180
146
 
181
- export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, createWeakTriggerCache, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess };
147
+ export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-primitives/utils",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
5
5
  "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
6
6
  "license": "MIT",
@@ -38,14 +38,14 @@
38
38
  "devDependencies": {
39
39
  "jsdom": "^20.0.0",
40
40
  "prettier": "^2.7.1",
41
- "solid-js": "^1.5.0",
41
+ "solid-js": "^1.6.0",
42
42
  "tslib": "^2.4.0",
43
43
  "tsup": "^6.2.3",
44
44
  "vitest": "^0.24.1"
45
45
  },
46
46
  "browser": {},
47
47
  "peerDependencies": {
48
- "solid-js": "^1.5.0"
48
+ "solid-js": "^1.6.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "jiti ../../scripts/build.ts",