@solid-primitives/utils 7.0.0-next.2 → 7.0.0-next.4
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 +17 -1
- package/dist/index.js +20 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -255,6 +255,22 @@ declare function pipe<A, B>(a: (raw: string) => A, b: (a: A) => B): (raw: string
|
|
|
255
255
|
*/
|
|
256
256
|
declare const contains: (wrapper: HTMLElement, target: HTMLElement) => boolean;
|
|
257
257
|
/**
|
|
258
|
+
* Returns a singleton value keyed by `key`, shared across every copy of the calling module that
|
|
259
|
+
* ends up loaded in the same JS realm (a `Symbol.for(key)` slot on `globalThis`, not a module-scope
|
|
260
|
+
* binding). Use this instead of a plain module-scope `let`/`const` for state that must stay
|
|
261
|
+
* consistent (ref-counts, active-instance stacks) even if the app's dependency graph ends up with
|
|
262
|
+
* more than one installed copy of the package — module-scope state would otherwise be split across
|
|
263
|
+
* copies and go out of sync (e.g. a "topmost instance" check disagreeing between copies).
|
|
264
|
+
*
|
|
265
|
+
* ```ts
|
|
266
|
+
* const registry = globalRegistry("@solid-primitives/my-package:my-state", () => ({
|
|
267
|
+
* stack: createSignal<string[]>([], { ownedWrite: true }),
|
|
268
|
+
* nextId: 0,
|
|
269
|
+
* }));
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
declare function globalRegistry<T>(key: string, init: () => T): T;
|
|
273
|
+
/**
|
|
258
274
|
* Wraps a setter function of any signal or store
|
|
259
275
|
*
|
|
260
276
|
* ```ts
|
|
@@ -270,4 +286,4 @@ declare function wrapSetter<T>(store: [Store<T>, StoreSetter<T>], wrapper: (sett
|
|
|
270
286
|
declare function wrapSetter<T, S extends Signal<T> | [Store<T>, StoreSetter<T>] | [...Signal<T>, ...any[]] | [Store<T>, StoreSetter<T>, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S;
|
|
271
287
|
declare function wrapSetter<T, S extends Signal<T> | [Store<T>, StoreSetter<T>] | readonly [...Signal<T>, ...any[]] | readonly [Store<T>, StoreSetter<T>, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S;
|
|
272
288
|
//#endregion
|
|
273
|
-
export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, EQUALS_FALSE_OPTIONS, ExtractIfPossible, Falsy, FalsyValue, INTERNAL_OPTIONS, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, afterPaint, arrayEquals, asAccessor, asArray, chain, clamp, compare, contains, createCallbackStack, createHydratableSignal, createHydrateSignal, createIdGenerator, createMicrotask, defaultEquals, defer, entries, falseFn, filterNonNullable, handleDiffArray, isClient, isDev, isNonNullable, isObject, isProd, isServer, json, keys, lines, ndjson, noop, number, ofClass, pipe, reverseChain, safe, trueFn, tryOnCleanup, withAccess, wrapSetter };
|
|
289
|
+
export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, EQUALS_FALSE_OPTIONS, ExtractIfPossible, Falsy, FalsyValue, INTERNAL_OPTIONS, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, afterPaint, arrayEquals, asAccessor, asArray, chain, clamp, compare, contains, createCallbackStack, createHydratableSignal, createHydrateSignal, createIdGenerator, createMicrotask, defaultEquals, defer, entries, falseFn, filterNonNullable, globalRegistry, handleDiffArray, isClient, isDev, isNonNullable, isObject, isProd, isServer, json, keys, lines, ndjson, noop, number, ofClass, pipe, reverseChain, safe, trueFn, tryOnCleanup, withAccess, wrapSetter };
|
package/dist/index.js
CHANGED
|
@@ -329,6 +329,25 @@ const contains = (wrapper, target) => {
|
|
|
329
329
|
}
|
|
330
330
|
return false;
|
|
331
331
|
};
|
|
332
|
+
/**
|
|
333
|
+
* Returns a singleton value keyed by `key`, shared across every copy of the calling module that
|
|
334
|
+
* ends up loaded in the same JS realm (a `Symbol.for(key)` slot on `globalThis`, not a module-scope
|
|
335
|
+
* binding). Use this instead of a plain module-scope `let`/`const` for state that must stay
|
|
336
|
+
* consistent (ref-counts, active-instance stacks) even if the app's dependency graph ends up with
|
|
337
|
+
* more than one installed copy of the package — module-scope state would otherwise be split across
|
|
338
|
+
* copies and go out of sync (e.g. a "topmost instance" check disagreeing between copies).
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* const registry = globalRegistry("@solid-primitives/my-package:my-state", () => ({
|
|
342
|
+
* stack: createSignal<string[]>([], { ownedWrite: true }),
|
|
343
|
+
* nextId: 0,
|
|
344
|
+
* }));
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
function globalRegistry(key, init) {
|
|
348
|
+
const g = globalThis;
|
|
349
|
+
return g[Symbol.for(key)] ??= init();
|
|
350
|
+
}
|
|
332
351
|
function wrapSetter(signalOrStore, wrapper) {
|
|
333
352
|
return [
|
|
334
353
|
signalOrStore[0],
|
|
@@ -337,4 +356,4 @@ function wrapSetter(signalOrStore, wrapper) {
|
|
|
337
356
|
];
|
|
338
357
|
}
|
|
339
358
|
//#endregion
|
|
340
|
-
export { EQUALS_FALSE_OPTIONS, INTERNAL_OPTIONS, access, accessArray, accessWith, afterPaint, arrayEquals, asAccessor, asArray, chain, clamp, compare, contains, createCallbackStack, createHydratableSignal, createHydrateSignal, createIdGenerator, createMicrotask, defaultEquals, defer, entries, falseFn, filterNonNullable, handleDiffArray, isClient, isDev, isNonNullable, isObject, isProd, isServer, json, keys, lines, ndjson, noop, number, ofClass, pipe, reverseChain, safe, trueFn, tryOnCleanup, withAccess, wrapSetter };
|
|
359
|
+
export { EQUALS_FALSE_OPTIONS, INTERNAL_OPTIONS, access, accessArray, accessWith, afterPaint, arrayEquals, asAccessor, asArray, chain, clamp, compare, contains, createCallbackStack, createHydratableSignal, createHydrateSignal, createIdGenerator, createMicrotask, defaultEquals, defer, entries, falseFn, filterNonNullable, globalRegistry, handleDiffArray, isClient, isDev, isNonNullable, isObject, isProd, isServer, json, keys, lines, ndjson, noop, number, ofClass, pipe, reverseChain, safe, trueFn, tryOnCleanup, withAccess, wrapSetter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.4",
|
|
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
|
"contributors": [
|
|
@@ -134,15 +134,15 @@
|
|
|
134
134
|
"COLOR_INTL_TRANSLATIONS"
|
|
135
135
|
],
|
|
136
136
|
"category": "Utilities",
|
|
137
|
-
"gzip":
|
|
137
|
+
"gzip": 1557
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
|
-
"@solidjs/web": "^2.0.0-
|
|
141
|
-
"solid-js": "^2.0.0-
|
|
140
|
+
"@solidjs/web": "^2.0.0-rc.0",
|
|
141
|
+
"solid-js": "^2.0.0-rc.0"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"@solidjs/web": "2.0.0-
|
|
145
|
-
"solid-js": "2.0.0-
|
|
144
|
+
"@solidjs/web": "2.0.0-rc.0",
|
|
145
|
+
"solid-js": "2.0.0-rc.0"
|
|
146
146
|
},
|
|
147
147
|
"scripts": {
|
|
148
148
|
"dev": "node --import=@nothing-but/node-resolve-ts --experimental-transform-types ../../scripts/dev.ts",
|