@take-out/helpers 0.2.2 → 0.2.3
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/package.json +1 -1
- package/types/array/getRandomItem.d.ts +0 -3
- package/types/array/getRandomItem.d.ts.map +0 -11
- package/types/array/takeLast.d.ts +0 -3
- package/types/array/takeLast.d.ts.map +0 -11
- package/types/array/uniqBy.d.ts +0 -12
- package/types/array/uniqBy.d.ts.map +0 -11
- package/types/assert.d.ts +0 -6
- package/types/assert.d.ts.map +0 -11
- package/types/async/abortable.d.ts +0 -10
- package/types/async/abortable.d.ts.map +0 -11
- package/types/async/asyncContext.d.ts +0 -8
- package/types/async/asyncContext.d.ts.map +0 -11
- package/types/async/asyncContext.native.d.ts +0 -8
- package/types/async/asyncContext.native.d.ts.map +0 -11
- package/types/async/idle.d.ts +0 -8
- package/types/async/idle.d.ts.map +0 -11
- package/types/async/interval.d.ts +0 -3
- package/types/async/interval.d.ts.map +0 -11
- package/types/async/isAborted.d.ts +0 -3
- package/types/async/isAborted.d.ts.map +0 -11
- package/types/async/sleep.d.ts +0 -3
- package/types/async/sleep.d.ts.map +0 -11
- package/types/async/useAsync.d.ts +0 -3
- package/types/async/useAsync.d.ts.map +0 -11
- package/types/async/useAsyncEffect.d.ts +0 -12
- package/types/async/useAsyncEffect.d.ts.map +0 -11
- package/types/async/useLazyMount.d.ts +0 -9
- package/types/async/useLazyMount.d.ts.map +0 -11
- package/types/async/useLazyValue.d.ts +0 -6
- package/types/async/useLazyValue.d.ts.map +0 -11
- package/types/browser/clearIndexedDB.d.ts +0 -3
- package/types/browser/clearIndexedDB.d.ts.map +0 -11
- package/types/browser/isActiveElementFormField.d.ts +0 -3
- package/types/browser/isActiveElementFormField.d.ts.map +0 -11
- package/types/browser/openPopup.d.ts +0 -3
- package/types/browser/openPopup.d.ts.map +0 -11
- package/types/client-only.d.ts +0 -2
- package/types/client-only.d.ts.map +0 -11
- package/types/clipboard/clipboard.d.ts +0 -3
- package/types/clipboard/clipboard.d.ts.map +0 -11
- package/types/clipboard/clipboard.native.d.ts +0 -3
- package/types/clipboard/clipboard.native.d.ts.map +0 -11
- package/types/color/extractOpacityFromColor.d.ts +0 -3
- package/types/color/extractOpacityFromColor.d.ts.map +0 -11
- package/types/color/generateColors.d.ts +0 -11
- package/types/color/generateColors.d.ts.map +0 -11
- package/types/color/lum.d.ts +0 -3
- package/types/color/lum.d.ts.map +0 -11
- package/types/color/toHex.d.ts +0 -4
- package/types/color/toHex.d.ts.map +0 -11
- package/types/constants.d.ts +0 -10
- package/types/constants.d.ts.map +0 -17
- package/types/debug/debugLog.d.ts +0 -11
- package/types/debug/debugLog.d.ts.map +0 -11
- package/types/debug/debugUseState.d.ts +0 -3
- package/types/debug/debugUseState.d.ts.map +0 -11
- package/types/emitter.d.ts +0 -77
- package/types/emitter.d.ts.map +0 -11
- package/types/ensure/ensure.d.ts +0 -6
- package/types/ensure/ensure.d.ts.map +0 -11
- package/types/ensure/ensureOne.d.ts +0 -3
- package/types/ensure/ensureOne.d.ts.map +0 -11
- package/types/error/errors.d.ts +0 -8
- package/types/error/errors.d.ts.map +0 -11
- package/types/function/emptyFn.d.ts +0 -3
- package/types/function/emptyFn.d.ts.map +0 -11
- package/types/function/identityFn.d.ts +0 -3
- package/types/function/identityFn.d.ts.map +0 -11
- package/types/function/throttle.d.ts +0 -23
- package/types/function/throttle.d.ts.map +0 -11
- package/types/global/globalEffect.d.ts +0 -3
- package/types/global/globalEffect.d.ts.map +0 -11
- package/types/global/globalValue.d.ts +0 -24
- package/types/global/globalValue.d.ts.map +0 -11
- package/types/index.d.ts +0 -78
- package/types/index.d.ts.map +0 -11
- package/types/number/formatNumber.d.ts +0 -13
- package/types/number/formatNumber.d.ts.map +0 -11
- package/types/object/decorateObject.d.ts +0 -3
- package/types/object/decorateObject.d.ts.map +0 -11
- package/types/object/isEqualDeep.d.ts +0 -6
- package/types/object/isEqualDeep.d.ts.map +0 -14
- package/types/object/isEqualIdentity.d.ts +0 -3
- package/types/object/isEqualIdentity.d.ts.map +0 -11
- package/types/object/isEqualJSON.d.ts +0 -3
- package/types/object/isEqualJSON.d.ts.map +0 -11
- package/types/object/isEqualNever.d.ts +0 -3
- package/types/object/isEqualNever.d.ts.map +0 -11
- package/types/object/mapObject.d.ts +0 -6
- package/types/object/mapObject.d.ts.map +0 -11
- package/types/object/object.d.ts +0 -12
- package/types/object/object.d.ts.map +0 -11
- package/types/object/objectUniqueKey.d.ts +0 -3
- package/types/object/objectUniqueKey.d.ts.map +0 -11
- package/types/react/createGlobalContext.d.ts +0 -4
- package/types/react/createGlobalContext.d.ts.map +0 -11
- package/types/react/getCurrentComponentStack.d.ts +0 -3
- package/types/react/getCurrentComponentStack.d.ts.map +0 -11
- package/types/server/ensureEnv.d.ts +0 -3
- package/types/server/ensureEnv.d.ts.map +0 -11
- package/types/server/getHeaders.d.ts +0 -3
- package/types/server/getHeaders.d.ts.map +0 -11
- package/types/server/prettyPrintRequest.d.ts +0 -3
- package/types/server/prettyPrintRequest.d.ts.map +0 -11
- package/types/server/prettyPrintResponse.d.ts +0 -3
- package/types/server/prettyPrintResponse.d.ts.map +0 -11
- package/types/server/streamToString.d.ts +0 -3
- package/types/server/streamToString.d.ts.map +0 -11
- package/types/server-only.d.ts +0 -2
- package/types/server-only.d.ts.map +0 -11
- package/types/storage/createStorage.d.ts +0 -65
- package/types/storage/createStorage.d.ts.map +0 -11
- package/types/storage/driver.d.ts +0 -5
- package/types/storage/driver.d.ts.map +0 -11
- package/types/storage/storage.test.d.ts +0 -3
- package/types/storage/storage.test.d.ts.map +0 -11
- package/types/storage/types.d.ts +0 -8
- package/types/storage/types.d.ts.map +0 -11
- package/types/string/dedent.d.ts +0 -3
- package/types/string/dedent.d.ts.map +0 -11
- package/types/string/ellipsis.d.ts +0 -3
- package/types/string/ellipsis.d.ts.map +0 -11
- package/types/string/hash.d.ts +0 -4
- package/types/string/hash.d.ts.map +0 -11
- package/types/string/insertAtIndex.d.ts +0 -3
- package/types/string/insertAtIndex.d.ts.map +0 -11
- package/types/string/nbspLastWord.d.ts +0 -7
- package/types/string/nbspLastWord.d.ts.map +0 -11
- package/types/string/pickLast.d.ts +0 -3
- package/types/string/pickLast.d.ts.map +0 -11
- package/types/string/pluralize.d.ts +0 -5
- package/types/string/pluralize.d.ts.map +0 -11
- package/types/string/pluralize.native.d.ts +0 -4
- package/types/string/pluralize.native.d.ts.map +0 -13
- package/types/string/randomId.d.ts +0 -3
- package/types/string/randomId.d.ts.map +0 -11
- package/types/string/slugify.d.ts +0 -3
- package/types/string/slugify.d.ts.map +0 -11
- package/types/string/truncateList.d.ts +0 -17
- package/types/string/truncateList.d.ts.map +0 -11
- package/types/time/formatDate.d.ts +0 -5
- package/types/time/formatDate.d.ts.map +0 -11
- package/types/time/formatDateRelative.d.ts +0 -3
- package/types/time/formatDateRelative.d.ts.map +0 -11
- package/types/time/formatDistanceToNow.d.ts +0 -3
- package/types/time/formatDistanceToNow.d.ts.map +0 -11
- package/types/time/time.d.ts +0 -29
- package/types/time/time.d.ts.map +0 -13
- package/types/time/useTimer.d.ts +0 -11
- package/types/time/useTimer.d.ts.map +0 -11
- package/types/types/NullToOptional.d.ts +0 -3
- package/types/types/NullToOptional.d.ts.map +0 -11
- package/types/types/object.d.ts +0 -16
- package/types/types/object.d.ts.map +0 -11
- package/types/types/react.d.ts +0 -3
- package/types/types/react.d.ts.map +0 -11
- package/types/types/timer.d.ts +0 -3
- package/types/types/timer.d.ts.map +0 -11
- package/types/types/tuple.d.ts +0 -3
- package/types/types/tuple.d.ts.map +0 -11
- package/types/url/urlSanitize.d.ts +0 -3
- package/types/url/urlSanitize.d.ts.map +0 -11
- package/types/url/urlValidate.d.ts +0 -3
- package/types/url/urlValidate.d.ts.map +0 -11
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAAA,OAAO,cAAM,gBAAiB,GAAG,OAAO,QAAM",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/array/getRandomItem.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"export const getRandomItem = <T>(items: T[]): T | undefined => {\n if (items.length === 0) return\n const randomIndex = Math.floor(Math.random() * items.length)\n return items[randomIndex]\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/array/uniqBy.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a new array with duplicate elements removed based on a key selector function.
|
|
3
|
-
* @param array The input array to remove duplicates from
|
|
4
|
-
* @param keyFn Function that returns the key to compare elements by
|
|
5
|
-
* @returns A new array with duplicates removed
|
|
6
|
-
*/
|
|
7
|
-
export declare function uniqBy<
|
|
8
|
-
T,
|
|
9
|
-
K
|
|
10
|
-
>(array: T[], keyFn: (item: T) => K): T[];
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=uniqBy.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": ";;;;;;AAOA,OAAO,iBAAS;CAAO;CAAG;EAAG,OAAO,KAAK,QAAQ,MAAM,MAAM,IAAI",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/array/uniqBy.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"/**\n * Returns a new array with duplicate elements removed based on a key selector function.\n * @param array The input array to remove duplicates from\n * @param keyFn Function that returns the key to compare elements by\n * @returns A new array with duplicates removed\n */\n\nexport function uniqBy<T, K>(array: T[], keyFn: (item: T) => K): T[] {\n const seen = new Map<K, T>()\n\n for (const item of array) {\n const key = keyFn(item)\n if (!seen.has(key)) {\n seen.set(key, item)\n }\n }\n\n return Array.from(seen.values())\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/assert.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function assertExists<T>(value: T | undefined | null, msg?: string): T;
|
|
2
|
-
export declare function assert<T>(value: T, msg?: string): Exclude<T, null | undefined | false>;
|
|
3
|
-
export declare function assertError(val: unknown): Error;
|
|
4
|
-
export declare function assertString(val: unknown, name?: string): string;
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=assert.d.ts.map
|
package/types/assert.d.ts.map
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,iBAAS,aAAa,GAAG,OAAO,sBAAsB,eAAW;AAOxE,OAAO,iBAAS,OAAO,GAAG,OAAO,GAAG,eAAW,QAAQ,sBAAsB;AAO7E,OAAO,iBAAS,YAAY,eAAe;AAO3C,OAAO,iBAAS,aAAa,cAAc",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/assert.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { AbortError } from './error/errors'\n\nexport function assertExists<T>(value: T | undefined | null, msg = ''): T {\n if (value === undefined || value === null) {\n throw new AbortError(`Invalid nullish value (${value}): ${msg}`)\n }\n return value\n}\n\nexport function assert<T>(value: T, msg = ''): Exclude<T, null | undefined | false> {\n if (!value) {\n throw new AbortError(`Invalid falsy value (${value}): ${msg}`)\n }\n return value as Exclude<T, null | undefined | false>\n}\n\nexport function assertError(val: unknown): Error {\n if (!(val instanceof Error)) {\n throw val\n }\n return val\n}\n\nexport function assertString(val: unknown, name = '(unnamed)'): string {\n if (typeof val !== 'string') {\n throw new AbortError(`No string ${name}`)\n }\n return val\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type AbortableOptions = {
|
|
2
|
-
message?: string;
|
|
3
|
-
};
|
|
4
|
-
export declare function abortable<T>(cb: () => T, options?: AbortableOptions): T | undefined;
|
|
5
|
-
export declare function abortable<T>(cb: () => Promise<T>, options?: AbortableOptions): Promise<T | undefined>;
|
|
6
|
-
export declare function didAbort(err: unknown, options?: AbortableOptions): boolean;
|
|
7
|
-
export declare function handleAbortError(error: any, debug?: boolean): void;
|
|
8
|
-
export {};
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=abortable.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "KAEK,mBAAmB;CAAE;;AAE1B,OAAO,iBAAS,UAAU,GAAG,UAAU,GAAG,UAAU,mBAAmB;AACvE,OAAO,iBAAS,UAAU,GACxB,UAAU,QAAQ,IAClB,UAAU,mBACT,QAAQ;AA0BX,OAAO,iBAAS,SAAS,cAAc,UAAU;AAUjD,OAAO,iBAAS,iBAAiB,YAAY",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/abortable.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { AbortError, EnsureError } from '../error/errors'\n\ntype AbortableOptions = { message?: string }\n\nexport function abortable<T>(cb: () => T, options?: AbortableOptions): T | undefined\nexport function abortable<T>(\n cb: () => Promise<T>,\n options?: AbortableOptions\n): Promise<T | undefined>\nexport function abortable<T>(\n cb: () => T | Promise<T>,\n options?: AbortableOptions\n): T | undefined | Promise<T | undefined> {\n try {\n const value = cb()\n\n if (value instanceof Promise) {\n return value.catch((err) => {\n if (didAbort(err, options)) {\n return undefined\n }\n throw err\n })\n }\n\n return value\n } catch (err) {\n if (didAbort(err, options)) {\n return undefined\n }\n throw err\n }\n}\n\nexport function didAbort(err: unknown, options?: AbortableOptions): boolean {\n if (err instanceof AbortError || err instanceof EnsureError) {\n if (options?.message) {\n console.warn(`Aborted: ${options.message}`)\n }\n return true\n }\n return false\n}\n\nexport function handleAbortError(error: any, debug?: boolean): void {\n if (error instanceof AbortError || error instanceof EnsureError) {\n if (debug || process.env.DEBUG) {\n console.info(`🐛 useAsyncEffect aborted: ${error.message}`)\n }\n return\n }\n\n // js handles aborting a promise as an error. ignore them since they're\n // a normal part of the expected async workflow\n if (typeof error === 'object' && error.name === 'AbortError') {\n return\n }\n\n throw error\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "UAAU,aAAa,GAAG;CACxB,OAAO;CACP,IAAI,GAAG,OAAO,GAAG,UAAU,IAAI,QAAQ,KAAK,QAAQ;;AA8BtD,OAAO,iBAAS,mBAAmB,MAAM,aAAa",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/asyncContext.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"interface AsyncContext<T> {\n get(): T | undefined\n run<R>(value: T, fn: () => R | Promise<R>): Promise<R>\n}\n\ninterface NodeAsyncLocalStorage<T> {\n getStore(): T | undefined\n run<R>(store: T, callback: () => R): R\n}\n\ninterface AsyncLocalStorageConstructor {\n new <T>(): NodeAsyncLocalStorage<T>\n}\n\nlet nodeAsyncLocalStorageCache: AsyncLocalStorageConstructor | null = null\n\n// hide from vite/esbuild static analysis to avoid browser compat warning\nconst nodeModuleId = ['node', 'async_hooks'].join(':')\n\nasync function getNodeAsyncLocalStorage(): Promise<AsyncLocalStorageConstructor | null> {\n if (!nodeAsyncLocalStorageCache) {\n try {\n const module = await import(/* @vite-ignore */ nodeModuleId)\n nodeAsyncLocalStorageCache =\n module.AsyncLocalStorage as AsyncLocalStorageConstructor\n } catch {\n return null\n }\n }\n return nodeAsyncLocalStorageCache\n}\n\nexport function createAsyncContext<T>(): AsyncContext<T> {\n if (process.env.VITE_ENVIRONMENT === 'ssr') {\n let storage: NodeAsyncLocalStorage<T> | null = null\n\n getNodeAsyncLocalStorage().then((AsyncLocalStorage) => {\n if (AsyncLocalStorage && !storage) {\n storage = new AsyncLocalStorage<T>()\n }\n })\n\n return {\n get(): T | undefined {\n if (!storage) {\n console.warn(`⚠️ called AsyncContext before load!`)\n return\n }\n\n return storage.getStore()\n },\n\n async run<R>(value: T, fn: () => R | Promise<R>): Promise<R> {\n if (!storage) {\n throw new Error(`⚠️ called AsyncContext before load!`)\n }\n return storage.run(value, fn)\n },\n }\n } else {\n // browser implementation using promise patching\n return createBrowserAsyncContext<T>()\n }\n}\n\nfunction createBrowserAsyncContext<T>(): AsyncContext<T> {\n let currentContext: T | undefined\n const contextStack: (T | undefined)[] = []\n\n return {\n get(): T | undefined {\n return currentContext\n },\n async run<R>(value: T, fn: () => R | Promise<R>): Promise<R> {\n const prevContext = currentContext\n currentContext = value\n contextStack.push(prevContext)\n\n // store original Promise methods\n const OriginalPromise = Promise\n const OriginalThen = OriginalPromise.prototype.then\n const OriginalCatch = OriginalPromise.prototype.catch\n const OriginalFinally = OriginalPromise.prototype.finally\n\n function wrapCallback(\n callback: Function | undefined | null,\n context: T | undefined\n ): Function | undefined | null {\n if (!callback) return callback\n return (...args: any[]) => {\n const prevContext = currentContext\n currentContext = context\n try {\n return callback(...args)\n } finally {\n currentContext = prevContext\n }\n }\n }\n\n // patch Promise methods to capture and restore context\n // eslint-disable-next-line no-then-property -- intentional patching for context propagation\n OriginalPromise.prototype.then = function (\n this: Promise<any>,\n onFulfilled?: any,\n onRejected?: any\n ): Promise<any> {\n const context = currentContext\n return OriginalThen.call(\n this,\n wrapCallback(onFulfilled, context) as any,\n wrapCallback(onRejected, context) as any\n )\n }\n\n OriginalPromise.prototype.catch = function (\n this: Promise<any>,\n onRejected?: any\n ): Promise<any> {\n const context = currentContext\n return OriginalCatch.call(this, wrapCallback(onRejected, context) as any)\n }\n\n OriginalPromise.prototype.finally = function (\n this: Promise<any>,\n onFinally?: any\n ): Promise<any> {\n const context = currentContext\n return OriginalFinally.call(this, wrapCallback(onFinally, context) as any)\n }\n\n try {\n const result = await fn()\n return result\n } finally {\n // restore original Promise methods\n // eslint-disable-next-line no-then-property -- restoring original methods\n OriginalPromise.prototype.then = OriginalThen\n OriginalPromise.prototype.catch = OriginalCatch\n OriginalPromise.prototype.finally = OriginalFinally\n\n contextStack.pop()\n currentContext = prevContext\n }\n },\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "UAAU,aAAa,GAAG;CACxB,OAAO;CACP,IAAI,GAAG,OAAO,GAAG,UAAU,IAAI,QAAQ,KAAK,QAAQ;;AAItD,OAAO,iBAAS,mBAAmB,MAAM,aAAa",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/asyncContext.native.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"interface AsyncContext<T> {\n get(): T | undefined\n run<R>(value: T, fn: () => R | Promise<R>): Promise<R>\n}\n\n// react native implementation - no node:async_hooks available\nexport function createAsyncContext<T>(): AsyncContext<T> {\n let currentContext: T | undefined\n const contextStack: (T | undefined)[] = []\n\n return {\n get(): T | undefined {\n return currentContext\n },\n async run<R>(value: T, fn: () => R | Promise<R>): Promise<R> {\n const prevContext = currentContext\n currentContext = value\n contextStack.push(prevContext)\n\n // store original Promise methods\n const OriginalPromise = Promise\n const OriginalThen = OriginalPromise.prototype.then\n const OriginalCatch = OriginalPromise.prototype.catch\n const OriginalFinally = OriginalPromise.prototype.finally\n\n function wrapCallback(\n callback: Function | undefined | null,\n context: T | undefined\n ): Function | undefined | null {\n if (!callback) return callback\n return (...args: any[]) => {\n const prevContext = currentContext\n currentContext = context\n try {\n return callback(...args)\n } finally {\n currentContext = prevContext\n }\n }\n }\n\n // patch Promise methods to capture and restore context\n // eslint-disable-next-line no-then-property -- intentional patching for context propagation\n OriginalPromise.prototype.then = function (\n this: Promise<any>,\n onFulfilled?: any,\n onRejected?: any\n ): Promise<any> {\n const context = currentContext\n return OriginalThen.call(\n this,\n wrapCallback(onFulfilled, context) as any,\n wrapCallback(onRejected, context) as any\n )\n }\n\n OriginalPromise.prototype.catch = function (\n this: Promise<any>,\n onRejected?: any\n ): Promise<any> {\n const context = currentContext\n return OriginalCatch.call(this, wrapCallback(onRejected, context) as any)\n }\n\n OriginalPromise.prototype.finally = function (\n this: Promise<any>,\n onFinally?: any\n ): Promise<any> {\n const context = currentContext\n return OriginalFinally.call(this, wrapCallback(onFinally, context) as any)\n }\n\n try {\n const result = await fn()\n return result\n } finally {\n // restore original Promise methods\n // eslint-disable-next-line no-then-property -- restoring original methods\n OriginalPromise.prototype.then = OriginalThen\n OriginalPromise.prototype.catch = OriginalCatch\n OriginalPromise.prototype.finally = OriginalFinally\n\n contextStack.pop()\n currentContext = prevContext\n }\n },\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/async/idle.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAqBA,YAAY,cAAc;CACxB;CACA;CACA;;AAGF,OAAO,cAAM,OACX,UAAU,aACV,SAAS,gBACR",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/idle.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { AbortError } from '../error/errors'\nimport { sleep } from './sleep'\n\n/**\n * Two helpers wrapping requestIdleCallback in async, abortable.\n */\n\ntype CallbackFn = (...args: any[]) => any | (() => any)\ntype CallbackerFn = (cb: CallbackFn) => void\n\nconst idleCb: CallbackerFn =\n typeof requestIdleCallback === 'undefined'\n ? (cb: CallbackFn) => setTimeout(cb, 1)\n : requestIdleCallback\n\nconst idleAsync = () => {\n return new Promise((res) => {\n idleCb(res)\n })\n}\n\nexport type IdleOptions = {\n max?: number\n min?: number\n fully?: boolean\n}\n\nexport const idle = async (\n options?: IdleOptions,\n signal?: AbortSignal\n): Promise<void> => {\n const { max, min, fully } = options || {}\n\n const idleFn = fully ? fullyIdle : idleAsync\n\n if (max && min && min < max) {\n await Promise.race([Promise.all([idleFn(), sleep(min)]), sleep(max)])\n } else if (max) {\n await Promise.race([idleFn(), sleep(max)])\n } else if (min) {\n await Promise.all([idleFn(), sleep(min)])\n } else {\n await idleFn()\n }\n\n if (signal?.aborted) {\n throw new AbortError()\n }\n}\n\nconst fullyIdle = async (signal?: AbortSignal): Promise<void> => {\n while (true) {\n const startTime = Date.now()\n await idle({}, signal)\n const endTime = Date.now()\n const duration = endTime - startTime\n\n // If idle callback took less than 15ms, consider it truly idle\n if (duration < 15) {\n break\n }\n\n // Check for abort signal after each iteration\n if (signal?.aborted) {\n throw new AbortError()\n }\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,cAAM,WACX,sBACA,YACA,SAAS,gBACR",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/interval.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { sleep } from './sleep'\n\nexport const interval = async (\n callback: () => void,\n ms: number,\n signal?: AbortSignal\n): Promise<never> => {\n while (true) {\n callback()\n await sleep(ms, signal)\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/async/sleep.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,cAAM,QAAe,YAAY,SAAS,gBAAc",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/sleep.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { AbortError } from '../error/errors'\n\nexport const sleep = async (ms: number, signal?: AbortSignal): Promise<void> => {\n await new Promise((res) => setTimeout(res, ms))\n if (signal?.aborted) {\n throw new AbortError()\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,iBAAS,SAAS,GACvB,iBAAiB,QAAQ,IACzB,eACE,GAAG,YAAY,SAAS,SAAS",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/useAsync.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { useState, useEffect } from 'react'\n\nexport function useAsync<T>(\n promiseFn: () => Promise<T>,\n args: any[]\n): [T, 'loading' | 'idle' | 'error', Error | null] {\n const [data, setData] = useState<T | null>(null)\n const [error, setError] = useState<Error | null>(null)\n const [loading, setLoading] = useState<boolean>(true)\n\n useEffect(() => {\n let isMounted = true\n\n const fetchData = async () => {\n try {\n const result = await promiseFn()\n if (isMounted) {\n setData(result)\n setLoading(false)\n }\n } catch (err) {\n if (isMounted) {\n setError(err as Error)\n setLoading(false)\n }\n }\n }\n\n fetchData()\n\n return () => {\n isMounted = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, args)\n\n return [data as T, error ? 'error' : loading ? 'loading' : 'idle', error]\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type Cleanup = () => void;
|
|
2
|
-
type AsyncEffectCallback = (signal: AbortSignal, ...deps: any[]) => Promise<Cleanup | void> | void;
|
|
3
|
-
type AsyncEffectOptions = {
|
|
4
|
-
circuitBreakAfter?: number;
|
|
5
|
-
circuitBreakPeriod?: number;
|
|
6
|
-
debug?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function useAsyncEffect(cb: AsyncEffectCallback, deps?: any[], options?: AsyncEffectOptions): void;
|
|
9
|
-
export declare function useAsyncLayoutEffect(cb: AsyncEffectCallback, deps?: any[], options?: AsyncEffectOptions): void;
|
|
10
|
-
export {};
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=useAsyncEffect.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "KAOK;KAEA,uBACH,QAAQ,aACR,GAAG,gBACA,QAAQ;KAER,qBAAqB;CACxB;CACA;CACA;;AAGF,OAAO,iBAAS,eACd,IAAI,qBACJ,cACA,UAAU;AAKZ,OAAO,iBAAS,qBACd,IAAI,qBACJ,cACA,UAAU",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/useAsyncEffect.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"// adopted from https://github.com/franciscop/use-async/blob/master/src/index.js\n\nimport { useEffect, useId, useLayoutEffect } from 'react'\n\nimport { EMPTY_OBJECT } from '../constants'\nimport { handleAbortError } from './abortable'\n\ntype Cleanup = () => void\n\ntype AsyncEffectCallback = (\n signal: AbortSignal,\n ...deps: any[]\n) => Promise<Cleanup | void> | void\n\ntype AsyncEffectOptions = {\n circuitBreakAfter?: number\n circuitBreakPeriod?: number\n debug?: boolean\n}\n\nexport function useAsyncEffect(\n cb: AsyncEffectCallback,\n deps: any[] = [],\n options?: AsyncEffectOptions\n): void {\n useAsyncEffectImpl(false, cb, deps, options)\n}\n\nexport function useAsyncLayoutEffect(\n cb: AsyncEffectCallback,\n deps: any[] = [],\n options?: AsyncEffectOptions\n): void {\n useAsyncEffectImpl(true, cb, deps, options)\n}\n\nfunction useAsyncEffectImpl(\n isLayoutEffect: boolean,\n cb: AsyncEffectCallback,\n deps: any[] = [],\n options: AsyncEffectOptions = EMPTY_OBJECT\n): void {\n const effectHook = isLayoutEffect ? useLayoutEffect : useEffect\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const effectId = process.env.NODE_ENV === 'development' ? useId() : ''\n\n effectHook(() => {\n // Generate a unique ID for this effect instance for loop detection\n checkEffectLoop(effectId, options.circuitBreakAfter, options.circuitBreakPeriod)\n const controller = new AbortController()\n const signal = controller.signal\n\n // wrap in try in case its not async (for simple use cases)\n try {\n const value = cb(signal, ...deps)\n\n Promise.resolve(value)\n .then(async (res) => {\n if (res && typeof res === 'function') {\n if (signal.aborted) return res()\n signal.addEventListener('abort', res)\n }\n })\n .catch(handleAbortError)\n } catch (error) {\n handleAbortError(error, options.debug)\n }\n\n return () => {\n if (signal.aborted) return\n controller.abort()\n }\n }, deps)\n}\n\n// loop detection in dev mode\nlet effectRunCounts: Map<string, number[]>\nlet checkEffectLoop: (\n effectId: string,\n circuitBreakAfter?: number,\n circuitBreakPeriod?: number\n) => void\n\nif (process.env.NODE_ENV === 'development') {\n effectRunCounts = new Map<string, number[]>()\n\n checkEffectLoop = (\n effectId: string,\n circuitBreakAfter: number = 20,\n circuitBreakPeriod: number = 1000\n ) => {\n const now = Date.now()\n const runs = effectRunCounts.get(effectId) || []\n\n runs.push(now)\n\n // keep only runs from the specified period\n const recentRuns = runs.filter((time) => now - time < circuitBreakPeriod)\n effectRunCounts.set(effectId, recentRuns)\n\n const runCount = recentRuns.length\n\n if (runCount > circuitBreakAfter) {\n const message = `🚨 useAsyncEffect infinite loop detected! Effect ran ${runCount} times in <${circuitBreakPeriod}ms`\n if (process.env.NODE_ENV === 'development') {\n console.error(message)\n // eslint-disable-next-line no-debugger\n debugger\n } else {\n alert(message)\n throw new Error(message)\n }\n } else if (runCount > circuitBreakAfter / 2) {\n console.warn(\n `⚠️ useAsyncEffect potential loop: Effect ran ${runCount} times in <${circuitBreakPeriod}ms`\n )\n }\n }\n} else {\n checkEffectLoop = () => {}\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type IdleOptions } from "./idle";
|
|
2
|
-
import type React from "react";
|
|
3
|
-
export type LazyMountProps = IdleOptions;
|
|
4
|
-
export declare const useLazyMount: (props?: LazyMountProps) => boolean;
|
|
5
|
-
export declare const LazyMount: ({ children,...idleProps }: LazyMountProps & {
|
|
6
|
-
children: any;
|
|
7
|
-
}) => React.ReactNode;
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=useLazyMount.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,cAAoB,mBAAmB;AAGvC,YAAY,WAAW;AAEvB,YAAY,iBAAiB;AAE7B,OAAO,cAAM,eAAgB,QAAO;AAkBpC,OAAO,cAAM,YAAa,EACxB,SACA,GAAG,aACF,iBAAiB;CAAE;MAAkB,MAAM",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/useLazyMount.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { startTransition, useState } from 'react'\n\nimport { idle, type IdleOptions } from './idle'\nimport { useAsyncEffect } from './useAsyncEffect'\n\nimport type React from 'react'\n\nexport type LazyMountProps = IdleOptions\n\nexport const useLazyMount = (props: LazyMountProps = { max: 100 }): boolean => {\n const [mounted, setMounted] = useState(false)\n\n useAsyncEffect(\n async (signal) => {\n await idle(props, signal)\n startTransition(() => {\n setMounted(true)\n })\n },\n [\n // no need for deps it only ever mounts once\n ]\n )\n\n return mounted\n}\n\nexport const LazyMount = ({\n children,\n ...idleProps\n}: LazyMountProps & { children: any }): React.ReactNode => {\n const mounted = useLazyMount(idleProps)\n return mounted ? children : null\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,cAAoB,mBAAmB;AAGvC,OAAO,cAAM,eAAgB,GAC3B,OAAO,GACP,EACE,qBACA,GAAG,gBACF,cAAc;CAAE;MAClB",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/async/useLazyValue.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { startTransition, useState } from 'react'\n\nimport { idle, type IdleOptions } from './idle'\nimport { useAsyncEffect } from './useAsyncEffect'\n\nexport const useLazyValue = <T>(\n value: T,\n {\n immediateFirstUpdate,\n ...idleOptions\n }: IdleOptions & { immediateFirstUpdate?: boolean } = {}\n): T => {\n const [lazyValue, setLazyValue] = useState(value)\n\n // first update to a real value immediate\n if (value && lazyValue === undefined && lazyValue !== value && immediateFirstUpdate) {\n setLazyValue(value)\n }\n\n useAsyncEffect(\n async (signal) => {\n await idle(idleOptions, signal)\n startTransition(() => {\n setLazyValue(value)\n })\n },\n [value]\n )\n\n return lazyValue\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAAA,OAAO,iBAAe,kBAAkB",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/browser/clearIndexedDB.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"export async function clearIndexedDB(): Promise<void> {\n if ('indexedDB' in window) {\n const databases = await indexedDB.databases()\n await Promise.all(\n databases.map((db) => {\n if (db.name) {\n return new Promise<void>((resolve, reject) => {\n const deleteReq = indexedDB.deleteDatabase(db.name!)\n deleteReq.onsuccess = () => resolve()\n deleteReq.onerror = () => reject(deleteReq.error)\n deleteReq.onblocked = () => reject(new Error('database deletion blocked'))\n })\n }\n return Promise.resolve()\n })\n )\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAAA,OAAO,iBAAS",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/browser/isActiveElementFormField.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"export function isActiveElementFormField(): boolean {\n return (\n typeof document !== 'undefined' &&\n document.activeElement !== null &&\n (document.activeElement.tagName === 'INPUT' ||\n document.activeElement.tagName === 'TEXTAREA' ||\n document.activeElement.tagName === 'SELECT' ||\n document.activeElement.tagName === 'FORM')\n )\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,iBAAS,kBACd,aACA,eACA,eACA,iBACC",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/browser/openPopup.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"// note safari enhanced privacy will break this as it reports screen height as smaller\n\nexport function openCenteredPopup(\n url: string,\n title: string,\n width: number,\n height: number\n): Window | null {\n // availWidth/availHeight accounts for taskbars, docks, and other UI elements\n const screenWidth = screen.availWidth || screen.width\n const screenHeight = screen.availHeight || screen.height\n\n const shouldGuess = screenHeight < height\n\n // if we are guessing, at least make it a bit more likely to be centered\n // and not just touching the top which looks broken\n const left = Math.max(0, (screenWidth - width) / 2) + (shouldGuess ? 100 : 0)\n const top = Math.max(150, shouldGuess ? 150 : Math.max(0, (screenHeight - height) / 2))\n\n const windowFeatures = `\n width=${width},\n height=${height},\n left=${left},\n top=${top},\n scrollbars=yes,\n resizable=yes\n `\n\n return window.open(url, title, windowFeatures)\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/client-only.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAAA,OAAO,cAAM,wBAA6B",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/clipboard/clipboard.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"export const getClipboardText = async (): Promise<string | null> => {\n try {\n const text = await navigator.clipboard.readText()\n return text\n } catch {\n return null\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,cAAM,wBAA6B",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/clipboard/clipboard.native.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import * as Clipboard from 'expo-clipboard'\n\nexport const getClipboardText = async (): Promise<string | null> => {\n try {\n const text = await Clipboard.getStringAsync()\n return text\n } catch {\n return null\n }\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAAA,OAAO,iBAAS,wBAAwB",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/color/extractOpacityFromColor.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"export function extractOpacityFromColor(color: string): number {\n if (color === 'transparent') return 0\n\n // Match hex codes like #RRGGBBAA or #RRGGBB\n const hexMatch = color.match(/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/)\n if (hexMatch) {\n const [, _rgb, alphaHex] = hexMatch\n if (alphaHex) {\n const alpha = parseInt(alphaHex, 16)\n return alpha / 255\n }\n return 1 // No alpha specified → fully opaque\n }\n\n // Could expand this to support rgba(), hsl(), etc. if needed\n console.warn(`Unsupported color format: ${color}`)\n return 1\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type ColorGenOptions = {
|
|
2
|
-
numColors?: number;
|
|
3
|
-
minSaturation?: number;
|
|
4
|
-
maxSaturation?: number;
|
|
5
|
-
minLightness?: number;
|
|
6
|
-
maxLightness?: number;
|
|
7
|
-
};
|
|
8
|
-
export declare const generateColors: ({ numColors, minSaturation, maxSaturation, minLightness, maxLightness }?: ColorGenOptions) => string[];
|
|
9
|
-
export {};
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=generateColors.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "KAEK,kBAAkB;CACrB;CACA;CACA;CACA;CACA;;AAwBF,OAAO,cAAM,iBAAkB,EAC7B,WACA,eACA,eACA,cACA,iBACC",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/color/generateColors.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"import { toHex } from './toHex'\n\ntype ColorGenOptions = {\n numColors?: number\n minSaturation?: number\n maxSaturation?: number\n minLightness?: number\n maxLightness?: number\n}\n\n// convert HSL to hex\nfunction hslToHex(h: number, s: number, l: number): string {\n // normalize values\n h = h / 360\n s = s / 100\n l = l / 100\n\n const a = s * Math.min(l, 1 - l)\n const f = (n: number) => {\n const k = (n + h * 12) % 12\n const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)\n return Math.round(255 * color)\n }\n\n const r = f(0)\n const g = f(8)\n const b = f(4)\n\n return toHex((r << 16) | (g << 8) | b)\n}\n\nexport const generateColors = ({\n numColors = 32,\n minSaturation = 45,\n maxSaturation = 85,\n minLightness = 45,\n maxLightness = 65,\n}: ColorGenOptions = {}): string[] => {\n const colors: string[] = []\n\n // Define hue ranges for color groups\n const hueRanges = [\n [0, 30], // reds\n [30, 60], // oranges\n [60, 90], // yellows\n [90, 150], // greens\n [150, 180], // teals\n [180, 240], // blues\n [240, 270], // purples\n [270, 330], // magentas\n [330, 360], // pink-reds\n ]\n\n // Calculate colors per group\n const colorsPerGroup = Math.ceil(numColors / hueRanges.length)\n\n hueRanges.forEach(([start, end]) => {\n const hueStep = (end! - start!) / colorsPerGroup\n\n for (let i = 0; i < colorsPerGroup; i++) {\n if (colors.length >= numColors) break\n\n const hue = start! + hueStep * i\n const saturation = minSaturation + Math.random() * (maxSaturation - minSaturation)\n const lightness = minLightness + Math.random() * (maxLightness - minLightness)\n\n colors.push(hslToHex(hue, saturation, lightness))\n }\n })\n\n return colors\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/color/lum.d.ts
DELETED
package/types/color/lum.d.ts.map
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAGA,OAAO,iBAAS,IAAI,eAAe",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/color/lum.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"// Helper to ensure color string is valid (simple fallback implementation)\nconst validColor = (color: string) => color\n\nexport function lum(color: string, luminance = 0.5): string {\n // handle hsl/hsla\n if (color.startsWith('hsl')) {\n const match = color.match(/hsla?\\((\\d+),\\s*(\\d+)%,\\s*(\\d+)%(?:,\\s*([\\d.]+))?\\)/)\n if (match) {\n const [, h, s, , a] = match\n const newL = Math.round(luminance * 100)\n if (a) {\n return validColor(`hsla(${h}, ${s}%, ${newL}%, ${a})`)\n }\n return validColor(`hsl(${h}, ${s}%, ${newL}%)`)\n }\n }\n\n // handle hex - convert to hsl and adjust\n if (color.startsWith('#')) {\n let hex = color.slice(1)\n\n // expand shorthand hex\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((c) => c + c)\n .join('')\n }\n\n // convert hex to rgb\n const r = parseInt(hex.slice(0, 2), 16) / 255\n const g = parseInt(hex.slice(2, 4), 16) / 255\n const b = parseInt(hex.slice(4, 6), 16) / 255\n\n // convert rgb to hsl\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n const l = (max + min) / 2\n\n if (max === min) {\n // achromatic\n const newL = Math.round(luminance * 100)\n return validColor(`hsl(0, 0%, ${newL}%)`)\n }\n\n const d = max - min\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n\n let h: number\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6\n break\n case g:\n h = ((b - r) / d + 2) / 6\n break\n case b:\n h = ((r - g) / d + 4) / 6\n break\n default:\n h = 0\n }\n\n const newH = Math.round(h * 360)\n const newS = Math.round(s * 100)\n const newL = Math.round(luminance * 100)\n\n // preserve alpha if present\n if (hex.length === 8) {\n const alpha = parseInt(hex.slice(6, 8), 16) / 255\n return validColor(`hsla(${newH}, ${newS}%, ${newL}%, ${alpha.toFixed(2)})`)\n }\n\n return validColor(`hsl(${newH}, ${newS}%, ${newL}%)`)\n }\n\n return validColor(color)\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/color/toHex.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AACA,OAAO,iBAAS,MAAM;AAMtB,OAAO,iBAAS",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/color/toHex.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"// simple helper to ensure we always get a valid 6-digit hex color from a number\nexport function toHex(value: number): string {\n // ensure we get a 6-digit hex string with leading zeros if needed\n return '#' + value.toString(16).padStart(6, '0')\n}\n\n// generate a random hex color\nexport function randomHex(): string {\n return toHex(Math.floor(Math.random() * 0xffffff))\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|
package/types/constants.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const isTauri: boolean;
|
|
2
|
-
export declare const isNative: boolean;
|
|
3
|
-
export declare const IS_MAC_DESKTOP: boolean;
|
|
4
|
-
export declare const IS_SAFARI: boolean;
|
|
5
|
-
export { isAndroid, isClient, isIos, isServer, isWeb } from "@tamagui/constants";
|
|
6
|
-
export declare const EMPTY_ARRAY: never;
|
|
7
|
-
export declare const EMPTY_OBJECT: never;
|
|
8
|
-
export declare const DEBUG_LEVEL: number;
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/types/constants.d.ts.map
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,cAAMA;AAGb,OAAO,cAAMC;AAIb,OAAO,cAAMC;AAGb,OAAO,cAAMC;AAMb,SAAS,WAAW,UAAU,OAAO,UAAU,aAAa;AAE5D,OAAO,cAAM;AACb,OAAO,cAAM;AAQb,OAAO,cAAMC",
|
|
3
|
-
"names": [
|
|
4
|
-
"isTauri: boolean",
|
|
5
|
-
"isNative: boolean",
|
|
6
|
-
"IS_MAC_DESKTOP: boolean",
|
|
7
|
-
"IS_SAFARI: boolean",
|
|
8
|
-
"DEBUG_LEVEL: number"
|
|
9
|
-
],
|
|
10
|
-
"sources": [
|
|
11
|
-
"src/constants.ts"
|
|
12
|
-
],
|
|
13
|
-
"sourcesContent": [
|
|
14
|
-
"import { isWeb } from '@tamagui/constants'\n\nexport const isTauri: boolean =\n typeof window !== 'undefined' && window['__TAURI__'] !== undefined\n\nexport const isNative: boolean = !isWeb && !isTauri\n\n// TODO move to probably ~/interface/constants\n\nexport const IS_MAC_DESKTOP: boolean =\n typeof navigator !== 'undefined' && /Macintosh|MacIntel/.test(navigator.platform)\n\nexport const IS_SAFARI: boolean =\n isTauri ||\n (typeof navigator !== 'undefined' &&\n /Version\\/[\\d.]+.*Safari/.test(navigator.userAgent) &&\n /Apple Computer/.test(navigator.vendor))\n\nexport { isAndroid, isClient, isIos, isServer, isWeb } from '@tamagui/constants'\n\nexport const EMPTY_ARRAY = [] as never\nexport const EMPTY_OBJECT = {} as never\n\nconst getDebugLevelFromUrl = (): number | null => {\n if (typeof window === 'undefined') return null\n const match = window.location?.search?.match(/debug=(\\d+)/)\n return match?.[1] ? parseInt(match[1], 10) : null\n}\n\nexport const DEBUG_LEVEL: number = process.env.DEBUG_LEVEL\n ? +process.env.DEBUG_LEVEL\n : (getDebugLevelFromUrl() ?? (process.env.NODE_ENV === 'development' ? 1 : 0))\n"
|
|
15
|
-
],
|
|
16
|
-
"version": 3
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Debug utility that logs a value and passes it through unchanged.
|
|
3
|
-
* Useful for debugging chains of operations without breaking the flow.
|
|
4
|
-
*
|
|
5
|
-
* @param value - The value to log and pass through
|
|
6
|
-
* @param label - Optional label to prefix the log output
|
|
7
|
-
* @returns The original value unchanged
|
|
8
|
-
*/
|
|
9
|
-
export declare function debugLog<T>(value: T, label?: string): T;
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=debugLog.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": ";;;;;;;;AAQA,OAAO,iBAAS,SAAS,GAAG,OAAO,GAAG,iBAAiB",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/debug/debugLog.ts"
|
|
6
|
-
],
|
|
7
|
-
"sourcesContent": [
|
|
8
|
-
"/**\n * Debug utility that logs a value and passes it through unchanged.\n * Useful for debugging chains of operations without breaking the flow.\n *\n * @param value - The value to log and pass through\n * @param label - Optional label to prefix the log output\n * @returns The original value unchanged\n */\nexport function debugLog<T>(value: T, label?: string): T {\n const output = label ? `[${label}]` : '[DEBUG]'\n console.info(output, value)\n return value\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"version": 3
|
|
11
|
-
}
|