@take-out/helpers 0.5.0 → 0.6.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.
Files changed (51) hide show
  1. package/dist/cjs/async/asyncContext.cjs +2 -2
  2. package/dist/cjs/constants.cjs +5 -5
  3. package/dist/cjs/constants.native.js +5 -5
  4. package/dist/cjs/constants.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +0 -1
  6. package/dist/cjs/index.native.js +0 -1
  7. package/dist/cjs/index.native.js.map +1 -1
  8. package/dist/cjs/platform.cjs +29 -29
  9. package/dist/cjs/platform.native.js +28 -28
  10. package/dist/cjs/platform.native.js.map +1 -1
  11. package/dist/esm/async/asyncContext.mjs +2 -2
  12. package/dist/esm/async/asyncContext.mjs.map +1 -1
  13. package/dist/esm/constants.mjs +5 -5
  14. package/dist/esm/constants.mjs.map +1 -1
  15. package/dist/esm/constants.native.js +5 -5
  16. package/dist/esm/constants.native.js.map +1 -1
  17. package/dist/esm/index.js +0 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/index.mjs +0 -1
  20. package/dist/esm/index.mjs.map +1 -1
  21. package/dist/esm/index.native.js +0 -1
  22. package/dist/esm/index.native.js.map +1 -1
  23. package/dist/esm/platform.mjs +16 -16
  24. package/dist/esm/platform.mjs.map +1 -1
  25. package/dist/esm/platform.native.js +15 -15
  26. package/dist/esm/platform.native.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/async/asyncContext.ts +2 -2
  29. package/src/constants.ts +4 -4
  30. package/src/index.ts +0 -1
  31. package/src/platform.native.ts +18 -19
  32. package/src/platform.ts +32 -23
  33. package/types/async/asyncContext.d.ts.map +1 -1
  34. package/types/constants.d.ts +2 -2
  35. package/types/constants.d.ts.map +1 -1
  36. package/types/index.d.ts +0 -1
  37. package/types/index.d.ts.map +2 -2
  38. package/types/platform.d.ts +15 -16
  39. package/types/platform.d.ts.map +2 -2
  40. package/types/platform.native.d.ts +15 -16
  41. package/types/platform.native.d.ts.map +2 -2
  42. package/dist/cjs/server/isServerRuntime.cjs +0 -32
  43. package/dist/cjs/server/isServerRuntime.native.js +0 -35
  44. package/dist/cjs/server/isServerRuntime.native.js.map +0 -1
  45. package/dist/esm/server/isServerRuntime.mjs +0 -7
  46. package/dist/esm/server/isServerRuntime.mjs.map +0 -1
  47. package/dist/esm/server/isServerRuntime.native.js +0 -7
  48. package/dist/esm/server/isServerRuntime.native.js.map +0 -1
  49. package/src/server/isServerRuntime.ts +0 -11
  50. package/types/server/isServerRuntime.d.ts +0 -3
  51. package/types/server/isServerRuntime.d.ts.map +0 -11
@@ -1,4 +1,4 @@
1
- import { isServerRuntime } from '../server/isServerRuntime'
1
+ import { IS_SERVER_RUNTIME } from '../platform'
2
2
 
3
3
  interface AsyncContext<T> {
4
4
  get(): T | undefined
@@ -40,7 +40,7 @@ async function getNodeAsyncLocalStorage(): Promise<AsyncLocalStorageConstructor
40
40
  }
41
41
 
42
42
  export function createAsyncContext<T>(): AsyncContext<T> {
43
- if (isServerRuntime()) {
43
+ if (IS_SERVER_RUNTIME) {
44
44
  let storage: NodeAsyncLocalStorage<T> | null = null
45
45
 
46
46
  const storageReady = Promise.resolve(configuredAsyncLocalStorage)
package/src/constants.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { isWeb } from './platform'
1
+ import { IS_WEB } from './platform'
2
2
 
3
- export const isTauri: boolean = typeof window !== 'undefined' && '__TAURI__' in window
3
+ export const IS_TAURI: boolean = typeof window !== 'undefined' && '__TAURI__' in window
4
4
 
5
- export const isNative: boolean = !isWeb && !isTauri
5
+ export const IS_NATIVE: boolean = !IS_WEB && !IS_TAURI
6
6
 
7
7
  // TODO move to probably ~/interface/constants
8
8
 
@@ -10,7 +10,7 @@ export const IS_MAC_DESKTOP: boolean =
10
10
  typeof navigator !== 'undefined' && /Macintosh|MacIntel/.test(navigator.platform)
11
11
 
12
12
  export const IS_SAFARI: boolean =
13
- isTauri ||
13
+ IS_TAURI ||
14
14
  (typeof navigator !== 'undefined' &&
15
15
  /Version\/[\d.]+.*Safari/.test(navigator.userAgent) &&
16
16
  typeof navigator.vendor === 'string' &&
package/src/index.ts CHANGED
@@ -81,7 +81,6 @@ export * from './storage/driver'
81
81
  export type { StorageDriver } from './storage/types'
82
82
 
83
83
  // server
84
- export * from './server/isServerRuntime'
85
84
  export * from './server/ensureEnv'
86
85
  export * from './server/getHeaders'
87
86
  export * from './server/prettyPrintRequest'
@@ -6,32 +6,31 @@
6
6
  import { useLayoutEffect, type useEffect } from 'react'
7
7
  import { Platform } from 'react-native'
8
8
 
9
- export const isWeb: boolean = false
10
- export const isBrowser: boolean = false
11
- export const isServer: boolean = false
12
- export const isClient: boolean = true
13
- /** @deprecated use isBrowser instead */
14
- export const isWindowDefined: boolean = false
9
+ export const IS_WEB: boolean = false
10
+ export const IS_BROWSER: boolean = false
11
+ export const IS_SERVER: boolean = false
12
+ export const IS_SERVER_RUNTIME: boolean = false
13
+ export const IS_CLIENT: boolean = true
15
14
  export const useIsomorphicLayoutEffect: typeof useEffect = useLayoutEffect
16
- export const isChrome: boolean = false
17
- export const isWebTouchable: boolean = false
18
- export const isNativeDesktop: boolean =
15
+ export const IS_CHROME: boolean = false
16
+ export const IS_WEB_TOUCHABLE: boolean = false
17
+ export const IS_NATIVE_DESKTOP: boolean =
19
18
  Platform?.OS === 'macos' || Platform?.OS === 'windows'
20
- export const isTouchable: boolean = !isNativeDesktop
19
+ export const IS_TOUCHABLE: boolean = !IS_NATIVE_DESKTOP
21
20
  // optional chain required: babel extractor loads native.cjs in node where Platform is undefined
22
- // On Android TV: Platform.OS === 'android' per react-native-tvos
23
- export const isAndroid: boolean =
21
+ // on Android TV: Platform.OS === 'android' per react-native-tvos
22
+ export const IS_ANDROID: boolean =
24
23
  Platform?.OS === 'android' ||
25
24
  process.env.TEST_NATIVE_PLATFORM === 'android' ||
26
25
  process.env.TEST_NATIVE_PLATFORM === 'androidtv'
27
- // On tvOS: Platform.OS === 'ios' per react-native-tvos
28
- export const isIos: boolean =
26
+ // on tvOS: Platform.OS === 'ios' per react-native-tvos
27
+ export const IS_IOS: boolean =
29
28
  Platform?.OS === 'ios' ||
30
29
  process.env.TEST_NATIVE_PLATFORM === 'ios' ||
31
30
  process.env.TEST_NATIVE_PLATFORM === 'tvos'
32
- export const supportsDynamicColorIOS: boolean =
33
- isIos || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'
34
- export const isTV: boolean =
31
+ export const SUPPORTS_DYNAMIC_COLOR_IOS: boolean =
32
+ IS_IOS || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'
33
+ export const IS_TV: boolean =
35
34
  Platform?.isTV ||
36
35
  process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||
37
36
  process.env.TEST_NATIVE_PLATFORM === 'tvos'
@@ -50,9 +49,9 @@ const platforms: Partial<Record<typeof Platform.OS, CurrentPlatform>> = {
50
49
  * Reflects Platform.OS. TV platforms are intentionally NOT separate values:
51
50
  * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)
52
51
  * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)
53
- * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.
52
+ * Use `IS_TV` combined with `IS_ANDROID`/`IS_IOS` to detect specific TV platforms.
54
53
  */
55
- export const currentPlatform: CurrentPlatform =
54
+ export const CURRENT_PLATFORM: CurrentPlatform =
56
55
  (Platform?.OS ? platforms[Platform.OS] : undefined) || 'native'
57
56
 
58
57
  // In Metro source mode, TAMAGUI_TARGET may not be set by the build tool.
package/src/platform.ts CHANGED
@@ -4,60 +4,69 @@
4
4
 
5
5
  import { useEffect, useLayoutEffect } from 'react'
6
6
 
7
- export const isWeb: boolean = true
7
+ export const IS_WEB: boolean = true
8
8
 
9
9
  // RN adds fake window and document so its not simple to get this right
10
10
  // check both navigator and location
11
- export const isBrowser: boolean =
12
- typeof navigator !== 'undefined' && typeof location !== 'undefined'
11
+ export const IS_BROWSER: boolean =
12
+ process.env.VITE_ENVIRONMENT === 'client' ||
13
+ (process.env.VITE_ENVIRONMENT !== 'ssr' &&
14
+ typeof navigator !== 'undefined' &&
15
+ typeof location !== 'undefined')
13
16
 
14
- export const isServer: boolean = isWeb && !isBrowser
15
- export const isClient: boolean = isWeb && isBrowser
16
- /** @deprecated use isBrowser instead */
17
- export const isWindowDefined: boolean = isBrowser
17
+ export const IS_SERVER_RUNTIME: boolean =
18
+ process.env.VITE_ENVIRONMENT === 'ssr' ||
19
+ (process.env.VITE_ENVIRONMENT !== 'client' &&
20
+ typeof process !== 'undefined' &&
21
+ !!process.versions &&
22
+ !!(process.versions.node || (process.versions as any).bun))
23
+ export const IS_SERVER: boolean =
24
+ process.env.VITE_ENVIRONMENT === 'ssr' ||
25
+ (process.env.VITE_ENVIRONMENT !== 'client' && IS_WEB && !IS_BROWSER)
26
+ export const IS_CLIENT: boolean = IS_WEB && !IS_SERVER
18
27
 
19
- export const useIsomorphicLayoutEffect: typeof useEffect = isServer
28
+ export const useIsomorphicLayoutEffect: typeof useEffect = IS_SERVER
20
29
  ? useEffect
21
30
  : useLayoutEffect
22
31
 
23
- export const isChrome: boolean =
24
- typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')
32
+ export const IS_CHROME: boolean =
33
+ typeof navigator !== 'undefined' && (navigator.userAgent || '').includes('Chrome')
25
34
 
26
35
  // guard the `window` access: in a web worker `navigator`/`location` exist (so
27
- // isClient is true) but `window` does NOT — touching it throws "window is not
36
+ // IS_CLIENT is true) but `window` does NOT — touching it throws "window is not
28
37
  // defined" and kills the worker. soot bundles @take-out/helpers into its
29
38
  // project-server web worker, so the unguarded form (which @tamagui/constants
30
39
  // also ships, but never loads in a worker) hard-crashes preview bundling.
31
40
  // keep this typeof guard even though it diverges from @tamagui/constants.
32
- export const isWebTouchable: boolean =
33
- isClient &&
41
+ export const IS_WEB_TOUCHABLE: boolean =
42
+ IS_CLIENT &&
34
43
  typeof window !== 'undefined' &&
35
44
  ('ontouchstart' in window || navigator.maxTouchPoints > 0)
36
45
 
37
- export const isNativeDesktop: boolean = false
38
- export const isTouchable: boolean = !isWeb || isWebTouchable
46
+ export const IS_NATIVE_DESKTOP: boolean = false
47
+ export const IS_TOUCHABLE: boolean = !IS_WEB || IS_WEB_TOUCHABLE
39
48
  // set :boolean to avoid inferring type to false
40
- // On web, isAndroid/isIos are always false in production.
49
+ // on web, IS_ANDROID/IS_IOS are always false in production.
41
50
  // TEST_NATIVE_PLATFORM is only set by the test runner (vitest) to simulate native
42
51
  // environments (e.g. androidtv, tvos) from a web/jsdom test context.
43
- export const isAndroid: boolean =
52
+ export const IS_ANDROID: boolean =
44
53
  process.env.TEST_NATIVE_PLATFORM === 'android' ||
45
54
  process.env.TEST_NATIVE_PLATFORM === 'androidtv'
46
- export const isIos: boolean =
55
+ export const IS_IOS: boolean =
47
56
  process.env.TEST_NATIVE_PLATFORM === 'ios' ||
48
57
  process.env.TEST_NATIVE_PLATFORM === 'tvos'
49
- export const supportsDynamicColorIOS: boolean =
50
- isIos || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'
51
- export const isTV: boolean =
58
+ export const SUPPORTS_DYNAMIC_COLOR_IOS: boolean =
59
+ IS_IOS || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'
60
+ export const IS_TV: boolean =
52
61
  process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||
53
62
  process.env.TEST_NATIVE_PLATFORM === 'tvos'
54
63
  /**
55
64
  * Reflects Platform.OS. TV platforms are intentionally NOT separate values:
56
65
  * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)
57
66
  * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)
58
- * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.
67
+ * Use `IS_TV` combined with `IS_ANDROID`/`IS_IOS` to detect specific TV platforms.
59
68
  */
60
- export const currentPlatform: 'web' | 'ios' | 'native' | 'android' = 'web'
69
+ export const CURRENT_PLATFORM: 'web' | 'ios' | 'native' | 'android' = 'web'
61
70
 
62
71
  // In web source mode (Vite/webpack without pre-built dist), TAMAGUI_TARGET may not be set.
63
72
  // Set it here so all process.env.TAMAGUI_TARGET runtime checks work correctly.
@@ -6,6 +6,6 @@
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "import { isServerRuntime } from '../server/isServerRuntime'\n\ninterface 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\nlet configuredAsyncLocalStorage: AsyncLocalStorageConstructor | null = null\n\n// hide from vite/esbuild static analysis to avoid browser compat warning\nconst nodeModuleId = ['node', 'async_hooks'].join(':')\n\nexport function setupAsyncLocalStorage(\n AsyncLocalStorage: AsyncLocalStorageConstructor | null,\n): void {\n configuredAsyncLocalStorage = AsyncLocalStorage\n}\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 (isServerRuntime()) {\n let storage: NodeAsyncLocalStorage<T> | null = null\n\n const storageReady = Promise.resolve(configuredAsyncLocalStorage)\n .then((AsyncLocalStorage) => AsyncLocalStorage || getNodeAsyncLocalStorage())\n .then((AsyncLocalStorage) => {\n if (AsyncLocalStorage && !storage) {\n storage = new AsyncLocalStorage<T>()\n }\n })\n\n return {\n get(): T | undefined {\n if (!storage) {\n throw new Error(`AsyncContext storage not initialized`)\n }\n return storage.getStore()\n },\n\n async run<R>(value: T, fn: () => R | Promise<R>): Promise<R> {\n if (!storage) {\n await storageReady\n }\n if (!storage) {\n throw new Error(`AsyncContext storage unavailable in server runtime`)\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
+ "import { IS_SERVER_RUNTIME } from '../platform'\n\ninterface 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\nlet configuredAsyncLocalStorage: AsyncLocalStorageConstructor | null = null\n\n// hide from vite/esbuild static analysis to avoid browser compat warning\nconst nodeModuleId = ['node', 'async_hooks'].join(':')\n\nexport function setupAsyncLocalStorage(\n AsyncLocalStorage: AsyncLocalStorageConstructor | null,\n): void {\n configuredAsyncLocalStorage = AsyncLocalStorage\n}\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 (IS_SERVER_RUNTIME) {\n let storage: NodeAsyncLocalStorage<T> | null = null\n\n const storageReady = Promise.resolve(configuredAsyncLocalStorage)\n .then((AsyncLocalStorage) => AsyncLocalStorage || getNodeAsyncLocalStorage())\n .then((AsyncLocalStorage) => {\n if (AsyncLocalStorage && !storage) {\n storage = new AsyncLocalStorage<T>()\n }\n })\n\n return {\n get(): T | undefined {\n if (!storage) {\n throw new Error(`AsyncContext storage not initialized`)\n }\n return storage.getStore()\n },\n\n async run<R>(value: T, fn: () => R | Promise<R>): Promise<R> {\n if (!storage) {\n await storageReady\n }\n if (!storage) {\n throw new Error(`AsyncContext storage unavailable in server runtime`)\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"
10
10
  ]
11
11
  }
@@ -1,5 +1,5 @@
1
- export declare const isTauri: boolean;
2
- export declare const isNative: boolean;
1
+ export declare const IS_TAURI: boolean;
2
+ export declare const IS_NATIVE: boolean;
3
3
  export declare const IS_MAC_DESKTOP: boolean;
4
4
  export declare const IS_SAFARI: boolean;
5
5
  export * from "./platform";
@@ -6,6 +6,6 @@
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "import { isWeb } from './platform'\n\nexport const isTauri: boolean = typeof window !== 'undefined' && '__TAURI__' in window\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 typeof navigator.vendor === 'string' &&\n navigator.vendor.includes('Apple Computer'))\n\nexport * from './platform'\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"
9
+ "import { IS_WEB } from './platform'\n\nexport const IS_TAURI: boolean = typeof window !== 'undefined' && '__TAURI__' in window\n\nexport const IS_NATIVE: boolean = !IS_WEB && !IS_TAURI\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 IS_TAURI ||\n (typeof navigator !== 'undefined' &&\n /Version\\/[\\d.]+.*Safari/.test(navigator.userAgent) &&\n typeof navigator.vendor === 'string' &&\n navigator.vendor.includes('Apple Computer'))\n\nexport * from './platform'\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"
10
10
  ]
11
11
  }
package/types/index.d.ts CHANGED
@@ -47,7 +47,6 @@ export * from "./react/getCurrentComponentStack";
47
47
  export * from "./storage/createStorage";
48
48
  export * from "./storage/driver";
49
49
  export type { StorageDriver } from "./storage/types";
50
- export * from "./server/isServerRuntime";
51
50
  export * from "./server/ensureEnv";
52
51
  export * from "./server/getHeaders";
53
52
  export * from "./server/prettyPrintRequest";
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAAA,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,SAAS,uBAAuB;AAChC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc,qBAAqB;AAGnC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,mBAAmB;AACnB,mBAAmB;AACnB,mBAAmB;AACnB,mBAAmB;AACnB,mBAAmB;AAGnB,cAAc;AACd,cAAc",
2
+ "mappings": "AAAA,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,SAAS,uBAAuB;AAChC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc,qBAAqB;AAGnC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,mBAAmB;AACnB,mBAAmB;AACnB,mBAAmB;AACnB,mBAAmB;AACnB,mBAAmB;AAGnB,cAAc;AACd,cAAc",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/index.ts"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "export * from './constants'\nexport * from './emitter'\n\n// array\nexport * from './array/getRandomItem'\nexport * from './array/takeLast'\nexport * from './array/uniqBy'\n\n// assert\nexport * from './assert'\n\n// async\nexport * from './async/abortable'\nexport * from './async/asyncContext'\nexport * from './async/idle'\nexport * from './async/interval'\nexport * from './async/isAborted'\nexport * from './async/sleep'\nexport * from './async/useAsync'\nexport * from './async/useAsyncEffect'\nexport * from './async/useLazyMount'\nexport * from './async/useLazyValue'\n\n// browser\nexport * from './browser/clearIndexedDB'\n\n// clipboard\nexport * from './clipboard/clipboard'\n\n// color\nexport * from './color/toHex'\nexport * from './color/generateColors'\nexport * from './color/lum'\nexport * from './color/extractOpacityFromColor'\nexport * from './browser/isActiveElementFormField'\nexport * from './browser/openPopup'\n\n// debug\nexport * from './debug/debugLog'\nexport * from './debug/debugUseState'\n\n// ensure\nexport * from './ensure/ensure'\nexport * from './ensure/ensureOne'\n\n// error\nexport * from './error/errors'\n\n// files\n\n// function\nexport * from './function/emptyFn'\nexport * from './function/identityFn'\nexport * from './function/throttle'\n\n// global\nexport * from './global/globalEffect'\nexport * from './global/globalValue'\n\n// number\nexport * from './number/formatNumber'\n\n// object\nexport * from './object/decorateObject'\nexport * from './object/isEqualDeep'\nexport { isEqualDeepLite } from './object/isEqualDeep'\nexport * from './object/isEqualIdentity'\nexport * from './object/isEqualJSON'\nexport * from './object/isEqualNever'\nexport * from './object/mapObject'\nexport * from './object/object'\nexport * from './object/objectUniqueKey'\n\n// react\nexport * from './react/createGlobalContext'\nexport * from './react/getCurrentComponentStack'\n\n// storage\nexport * from './storage/createStorage'\nexport * from './storage/driver'\nexport type { StorageDriver } from './storage/types'\n\n// server\nexport * from './server/isServerRuntime'\nexport * from './server/ensureEnv'\nexport * from './server/getHeaders'\nexport * from './server/prettyPrintRequest'\nexport * from './server/prettyPrintResponse'\nexport * from './server/streamToString'\n\n// string\nexport * from './string/dedent'\nexport * from './string/ellipsis'\nexport * from './string/hash'\nexport * from './string/insertAtIndex'\nexport * from './string/nbspLastWord'\nexport * from './string/pickLast'\nexport * from './string/pluralize'\nexport * from './string/randomId'\nexport * from './string/slugify'\nexport * from './string/truncateList'\n\n// time\nexport * from './time/formatDate'\nexport * from './time/formatDateRelative'\nexport * from './time/formatDistanceToNow'\nexport * from './time/time'\nexport * from './time/useTimer'\n\n// types\nexport type * from './types/NullToOptional'\nexport type * from './types/object'\nexport type * from './types/react'\nexport type * from './types/timer'\nexport type * from './types/tuple'\n\n// url\nexport * from './url/urlSanitize'\nexport * from './url/urlValidate'\n"
9
+ "export * from './constants'\nexport * from './emitter'\n\n// array\nexport * from './array/getRandomItem'\nexport * from './array/takeLast'\nexport * from './array/uniqBy'\n\n// assert\nexport * from './assert'\n\n// async\nexport * from './async/abortable'\nexport * from './async/asyncContext'\nexport * from './async/idle'\nexport * from './async/interval'\nexport * from './async/isAborted'\nexport * from './async/sleep'\nexport * from './async/useAsync'\nexport * from './async/useAsyncEffect'\nexport * from './async/useLazyMount'\nexport * from './async/useLazyValue'\n\n// browser\nexport * from './browser/clearIndexedDB'\n\n// clipboard\nexport * from './clipboard/clipboard'\n\n// color\nexport * from './color/toHex'\nexport * from './color/generateColors'\nexport * from './color/lum'\nexport * from './color/extractOpacityFromColor'\nexport * from './browser/isActiveElementFormField'\nexport * from './browser/openPopup'\n\n// debug\nexport * from './debug/debugLog'\nexport * from './debug/debugUseState'\n\n// ensure\nexport * from './ensure/ensure'\nexport * from './ensure/ensureOne'\n\n// error\nexport * from './error/errors'\n\n// files\n\n// function\nexport * from './function/emptyFn'\nexport * from './function/identityFn'\nexport * from './function/throttle'\n\n// global\nexport * from './global/globalEffect'\nexport * from './global/globalValue'\n\n// number\nexport * from './number/formatNumber'\n\n// object\nexport * from './object/decorateObject'\nexport * from './object/isEqualDeep'\nexport { isEqualDeepLite } from './object/isEqualDeep'\nexport * from './object/isEqualIdentity'\nexport * from './object/isEqualJSON'\nexport * from './object/isEqualNever'\nexport * from './object/mapObject'\nexport * from './object/object'\nexport * from './object/objectUniqueKey'\n\n// react\nexport * from './react/createGlobalContext'\nexport * from './react/getCurrentComponentStack'\n\n// storage\nexport * from './storage/createStorage'\nexport * from './storage/driver'\nexport type { StorageDriver } from './storage/types'\n\n// server\nexport * from './server/ensureEnv'\nexport * from './server/getHeaders'\nexport * from './server/prettyPrintRequest'\nexport * from './server/prettyPrintResponse'\nexport * from './server/streamToString'\n\n// string\nexport * from './string/dedent'\nexport * from './string/ellipsis'\nexport * from './string/hash'\nexport * from './string/insertAtIndex'\nexport * from './string/nbspLastWord'\nexport * from './string/pickLast'\nexport * from './string/pluralize'\nexport * from './string/randomId'\nexport * from './string/slugify'\nexport * from './string/truncateList'\n\n// time\nexport * from './time/formatDate'\nexport * from './time/formatDateRelative'\nexport * from './time/formatDistanceToNow'\nexport * from './time/time'\nexport * from './time/useTimer'\n\n// types\nexport type * from './types/NullToOptional'\nexport type * from './types/object'\nexport type * from './types/react'\nexport type * from './types/timer'\nexport type * from './types/tuple'\n\n// url\nexport * from './url/urlSanitize'\nexport * from './url/urlValidate'\n"
10
10
  ]
11
11
  }
@@ -1,25 +1,24 @@
1
1
  import { useEffect } from "react";
2
- export declare const isWeb: boolean;
3
- export declare const isBrowser: boolean;
4
- export declare const isServer: boolean;
5
- export declare const isClient: boolean;
6
- /** @deprecated use isBrowser instead */
7
- export declare const isWindowDefined: boolean;
2
+ export declare const IS_WEB: boolean;
3
+ export declare const IS_BROWSER: boolean;
4
+ export declare const IS_SERVER_RUNTIME: boolean;
5
+ export declare const IS_SERVER: boolean;
6
+ export declare const IS_CLIENT: boolean;
8
7
  export declare const useIsomorphicLayoutEffect: typeof useEffect;
9
- export declare const isChrome: boolean;
10
- export declare const isWebTouchable: boolean;
11
- export declare const isNativeDesktop: boolean;
12
- export declare const isTouchable: boolean;
13
- export declare const isAndroid: boolean;
14
- export declare const isIos: boolean;
15
- export declare const supportsDynamicColorIOS: boolean;
16
- export declare const isTV: boolean;
8
+ export declare const IS_CHROME: boolean;
9
+ export declare const IS_WEB_TOUCHABLE: boolean;
10
+ export declare const IS_NATIVE_DESKTOP: boolean;
11
+ export declare const IS_TOUCHABLE: boolean;
12
+ export declare const IS_ANDROID: boolean;
13
+ export declare const IS_IOS: boolean;
14
+ export declare const SUPPORTS_DYNAMIC_COLOR_IOS: boolean;
15
+ export declare const IS_TV: boolean;
17
16
  /**
18
17
  * Reflects Platform.OS. TV platforms are intentionally NOT separate values:
19
18
  * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)
20
19
  * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)
21
- * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.
20
+ * Use `IS_TV` combined with `IS_ANDROID`/`IS_IOS` to detect specific TV platforms.
22
21
  */
23
- export declare const currentPlatform: "web" | "ios" | "native" | "android";
22
+ export declare const CURRENT_PLATFORM: "web" | "ios" | "native" | "android";
24
23
 
25
24
  //# sourceMappingURL=platform.d.ts.map
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAIA,SAAS,iBAAkC;AAE3C,OAAO,cAAM;AAIb,OAAO,cAAM;AAGb,OAAO,cAAM;AACb,OAAO,cAAM;;AAEb,OAAO,cAAM;AAEb,OAAO,cAAM,kCAAkC;AAI/C,OAAO,cAAM;AASb,OAAO,cAAM;AAKb,OAAO,cAAM;AACb,OAAO,cAAM;AAKb,OAAO,cAAM;AAGb,OAAO,cAAM;AAGb,OAAO,cAAM;AAEb,OAAO,cAAM;;;;;;;AASb,OAAO,cAAM,iBAAiB,QAAQ,QAAQ,WAAW",
2
+ "mappings": "AAIA,SAAS,iBAAkC;AAE3C,OAAO,cAAM;AAIb,OAAO,cAAM;AAMb,OAAO,cAAM;AAMb,OAAO,cAAM;AAGb,OAAO,cAAM;AAEb,OAAO,cAAM,kCAAkC;AAI/C,OAAO,cAAM;AASb,OAAO,cAAM;AAKb,OAAO,cAAM;AACb,OAAO,cAAM;AAKb,OAAO,cAAM;AAGb,OAAO,cAAM;AAGb,OAAO,cAAM;AAEb,OAAO,cAAM;;;;;;;AASb,OAAO,cAAM,kBAAkB,QAAQ,QAAQ,WAAW",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/platform.ts"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "// platform booleans, web/default variant.\n// Re-implemented locally (mirrors @tamagui/constants) so @take-out/helpers carries no @tamagui/* runtime dep.\n// The native values live in platform.native.ts (resolved by metro / the react-native export condition).\n\nimport { useEffect, useLayoutEffect } from 'react'\n\nexport const isWeb: boolean = true\n\n// RN adds fake window and document so its not simple to get this right\n// check both navigator and location\nexport const isBrowser: boolean =\n typeof navigator !== 'undefined' && typeof location !== 'undefined'\n\nexport const isServer: boolean = isWeb && !isBrowser\nexport const isClient: boolean = isWeb && isBrowser\n/** @deprecated use isBrowser instead */\nexport const isWindowDefined: boolean = isBrowser\n\nexport const useIsomorphicLayoutEffect: typeof useEffect = isServer\n ? useEffect\n : useLayoutEffect\n\nexport const isChrome: boolean =\n typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\n\n// guard the `window` access: in a web worker `navigator`/`location` exist (so\n// isClient is true) but `window` does NOT — touching it throws \"window is not\n// defined\" and kills the worker. soot bundles @take-out/helpers into its\n// project-server web worker, so the unguarded form (which @tamagui/constants\n// also ships, but never loads in a worker) hard-crashes preview bundling.\n// keep this typeof guard even though it diverges from @tamagui/constants.\nexport const isWebTouchable: boolean =\n isClient &&\n typeof window !== 'undefined' &&\n ('ontouchstart' in window || navigator.maxTouchPoints > 0)\n\nexport const isNativeDesktop: boolean = false\nexport const isTouchable: boolean = !isWeb || isWebTouchable\n// set :boolean to avoid inferring type to false\n// On web, isAndroid/isIos are always false in production.\n// TEST_NATIVE_PLATFORM is only set by the test runner (vitest) to simulate native\n// environments (e.g. androidtv, tvos) from a web/jsdom test context.\nexport const isAndroid: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv'\nexport const isIos: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\nexport const supportsDynamicColorIOS: boolean =\n isIos || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'\nexport const isTV: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\n/**\n * Reflects Platform.OS. TV platforms are intentionally NOT separate values:\n * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)\n * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)\n * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.\n */\nexport const currentPlatform: 'web' | 'ios' | 'native' | 'android' = 'web'\n\n// In web source mode (Vite/webpack without pre-built dist), TAMAGUI_TARGET may not be set.\n// Set it here so all process.env.TAMAGUI_TARGET runtime checks work correctly.\n// In pre-built dist, the build tool inlines TAMAGUI_TARGET as a literal string,\n// making this block dead code (if (!'web') → never executes).\nif (!process.env.TAMAGUI_TARGET) {\n process.env.TAMAGUI_TARGET = 'web'\n}\n"
9
+ "// platform booleans, web/default variant.\n// Re-implemented locally (mirrors @tamagui/constants) so @take-out/helpers carries no @tamagui/* runtime dep.\n// The native values live in platform.native.ts (resolved by metro / the react-native export condition).\n\nimport { useEffect, useLayoutEffect } from 'react'\n\nexport const IS_WEB: boolean = true\n\n// RN adds fake window and document so its not simple to get this right\n// check both navigator and location\nexport const IS_BROWSER: boolean =\n process.env.VITE_ENVIRONMENT === 'client' ||\n (process.env.VITE_ENVIRONMENT !== 'ssr' &&\n typeof navigator !== 'undefined' &&\n typeof location !== 'undefined')\n\nexport const IS_SERVER_RUNTIME: boolean =\n process.env.VITE_ENVIRONMENT === 'ssr' ||\n (process.env.VITE_ENVIRONMENT !== 'client' &&\n typeof process !== 'undefined' &&\n !!process.versions &&\n !!(process.versions.node || (process.versions as any).bun))\nexport const IS_SERVER: boolean =\n process.env.VITE_ENVIRONMENT === 'ssr' ||\n (process.env.VITE_ENVIRONMENT !== 'client' && IS_WEB && !IS_BROWSER)\nexport const IS_CLIENT: boolean = IS_WEB && !IS_SERVER\n\nexport const useIsomorphicLayoutEffect: typeof useEffect = IS_SERVER\n ? useEffect\n : useLayoutEffect\n\nexport const IS_CHROME: boolean =\n typeof navigator !== 'undefined' && (navigator.userAgent || '').includes('Chrome')\n\n// guard the `window` access: in a web worker `navigator`/`location` exist (so\n// IS_CLIENT is true) but `window` does NOT — touching it throws \"window is not\n// defined\" and kills the worker. soot bundles @take-out/helpers into its\n// project-server web worker, so the unguarded form (which @tamagui/constants\n// also ships, but never loads in a worker) hard-crashes preview bundling.\n// keep this typeof guard even though it diverges from @tamagui/constants.\nexport const IS_WEB_TOUCHABLE: boolean =\n IS_CLIENT &&\n typeof window !== 'undefined' &&\n ('ontouchstart' in window || navigator.maxTouchPoints > 0)\n\nexport const IS_NATIVE_DESKTOP: boolean = false\nexport const IS_TOUCHABLE: boolean = !IS_WEB || IS_WEB_TOUCHABLE\n// set :boolean to avoid inferring type to false\n// on web, IS_ANDROID/IS_IOS are always false in production.\n// TEST_NATIVE_PLATFORM is only set by the test runner (vitest) to simulate native\n// environments (e.g. androidtv, tvos) from a web/jsdom test context.\nexport const IS_ANDROID: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv'\nexport const IS_IOS: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\nexport const SUPPORTS_DYNAMIC_COLOR_IOS: boolean =\n IS_IOS || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'\nexport const IS_TV: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\n/**\n * Reflects Platform.OS. TV platforms are intentionally NOT separate values:\n * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)\n * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)\n * Use `IS_TV` combined with `IS_ANDROID`/`IS_IOS` to detect specific TV platforms.\n */\nexport const CURRENT_PLATFORM: 'web' | 'ios' | 'native' | 'android' = 'web'\n\n// In web source mode (Vite/webpack without pre-built dist), TAMAGUI_TARGET may not be set.\n// Set it here so all process.env.TAMAGUI_TARGET runtime checks work correctly.\n// In pre-built dist, the build tool inlines TAMAGUI_TARGET as a literal string,\n// making this block dead code (if (!'web') → never executes).\nif (!process.env.TAMAGUI_TARGET) {\n process.env.TAMAGUI_TARGET = 'web'\n}\n"
10
10
  ]
11
11
  }
@@ -1,27 +1,26 @@
1
1
  import { type useEffect } from "react";
2
- export declare const isWeb: boolean;
3
- export declare const isBrowser: boolean;
4
- export declare const isServer: boolean;
5
- export declare const isClient: boolean;
6
- /** @deprecated use isBrowser instead */
7
- export declare const isWindowDefined: boolean;
2
+ export declare const IS_WEB: boolean;
3
+ export declare const IS_BROWSER: boolean;
4
+ export declare const IS_SERVER: boolean;
5
+ export declare const IS_SERVER_RUNTIME: boolean;
6
+ export declare const IS_CLIENT: boolean;
8
7
  export declare const useIsomorphicLayoutEffect: typeof useEffect;
9
- export declare const isChrome: boolean;
10
- export declare const isWebTouchable: boolean;
11
- export declare const isNativeDesktop: boolean;
12
- export declare const isTouchable: boolean;
13
- export declare const isAndroid: boolean;
14
- export declare const isIos: boolean;
15
- export declare const supportsDynamicColorIOS: boolean;
16
- export declare const isTV: boolean;
8
+ export declare const IS_CHROME: boolean;
9
+ export declare const IS_WEB_TOUCHABLE: boolean;
10
+ export declare const IS_NATIVE_DESKTOP: boolean;
11
+ export declare const IS_TOUCHABLE: boolean;
12
+ export declare const IS_ANDROID: boolean;
13
+ export declare const IS_IOS: boolean;
14
+ export declare const SUPPORTS_DYNAMIC_COLOR_IOS: boolean;
15
+ export declare const IS_TV: boolean;
17
16
  type CurrentPlatform = "web" | "ios" | "native" | "android" | "macos" | "windows";
18
17
  /**
19
18
  * Reflects Platform.OS. TV platforms are intentionally NOT separate values:
20
19
  * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)
21
20
  * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)
22
- * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.
21
+ * Use `IS_TV` combined with `IS_ANDROID`/`IS_IOS` to detect specific TV platforms.
23
22
  */
24
- export declare const currentPlatform: CurrentPlatform;
23
+ export declare const CURRENT_PLATFORM: CurrentPlatform;
25
24
  export {};
26
25
 
27
26
  //# sourceMappingURL=platform.native.d.ts.map
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAKA,cAA+B,iBAAiB;AAGhD,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;;AAEb,OAAO,cAAM;AACb,OAAO,cAAM,kCAAkC;AAC/C,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AAEb,OAAO,cAAM;AAGb,OAAO,cAAM;AAKb,OAAO,cAAM;AAIb,OAAO,cAAM;AAEb,OAAO,cAAM;KAKR,kBAAkB,QAAQ,QAAQ,WAAW,YAAY,UAAU;;;;;;;AAgBxE,OAAO,cAAM,iBAAiB",
2
+ "mappings": "AAKA,cAA+B,iBAAiB;AAGhD,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM,kCAAkC;AAC/C,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AAEb,OAAO,cAAM;AAGb,OAAO,cAAM;AAKb,OAAO,cAAM;AAIb,OAAO,cAAM;AAEb,OAAO,cAAM;KAKR,kBAAkB,QAAQ,QAAQ,WAAW,YAAY,UAAU;;;;;;;AAgBxE,OAAO,cAAM,kBAAkB",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/platform.native.ts"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "// platform booleans, react-native variant.\n// Mirrors @tamagui/constants (native) so @take-out/helpers carries no @tamagui/* runtime dep.\n// react-native is an optional peer dep and is always present in the native runtime\n// where this file is loaded, so importing it here is safe.\n\nimport { useLayoutEffect, type useEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isWeb: boolean = false\nexport const isBrowser: boolean = false\nexport const isServer: boolean = false\nexport const isClient: boolean = true\n/** @deprecated use isBrowser instead */\nexport const isWindowDefined: boolean = false\nexport const useIsomorphicLayoutEffect: typeof useEffect = useLayoutEffect\nexport const isChrome: boolean = false\nexport const isWebTouchable: boolean = false\nexport const isNativeDesktop: boolean =\n Platform?.OS === 'macos' || Platform?.OS === 'windows'\nexport const isTouchable: boolean = !isNativeDesktop\n// optional chain required: babel extractor loads native.cjs in node where Platform is undefined\n// On Android TV: Platform.OS === 'android' per react-native-tvos\nexport const isAndroid: boolean =\n Platform?.OS === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv'\n// On tvOS: Platform.OS === 'ios' per react-native-tvos\nexport const isIos: boolean =\n Platform?.OS === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\nexport const supportsDynamicColorIOS: boolean =\n isIos || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'\nexport const isTV: boolean =\n Platform?.isTV ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\n\ntype CurrentPlatform = 'web' | 'ios' | 'native' | 'android' | 'macos' | 'windows'\n\n// Platform.OS includes 'web' in its type (PlatformOSType) but never at native runtime,\n// so the map is partial — any unmapped OS falls through to 'native'.\nconst platforms: Partial<Record<typeof Platform.OS, CurrentPlatform>> = {\n ios: 'ios',\n android: 'android',\n macos: 'macos',\n windows: 'windows',\n}\n/**\n * Reflects Platform.OS. TV platforms are intentionally NOT separate values:\n * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)\n * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)\n * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.\n */\nexport const currentPlatform: CurrentPlatform =\n (Platform?.OS ? platforms[Platform.OS] : undefined) || 'native'\n\n// In Metro source mode, TAMAGUI_TARGET may not be set by the build tool.\n// Set it here so all process.env.TAMAGUI_TARGET runtime checks work correctly.\n// In pre-built dist, the build tool inlines TAMAGUI_TARGET as a literal string,\n// making this block dead code (if (!'native') → never executes).\nif (!process.env.TAMAGUI_TARGET) {\n process.env.TAMAGUI_TARGET = 'native'\n}\n"
9
+ "// platform booleans, react-native variant.\n// Mirrors @tamagui/constants (native) so @take-out/helpers carries no @tamagui/* runtime dep.\n// react-native is an optional peer dep and is always present in the native runtime\n// where this file is loaded, so importing it here is safe.\n\nimport { useLayoutEffect, type useEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const IS_WEB: boolean = false\nexport const IS_BROWSER: boolean = false\nexport const IS_SERVER: boolean = false\nexport const IS_SERVER_RUNTIME: boolean = false\nexport const IS_CLIENT: boolean = true\nexport const useIsomorphicLayoutEffect: typeof useEffect = useLayoutEffect\nexport const IS_CHROME: boolean = false\nexport const IS_WEB_TOUCHABLE: boolean = false\nexport const IS_NATIVE_DESKTOP: boolean =\n Platform?.OS === 'macos' || Platform?.OS === 'windows'\nexport const IS_TOUCHABLE: boolean = !IS_NATIVE_DESKTOP\n// optional chain required: babel extractor loads native.cjs in node where Platform is undefined\n// on Android TV: Platform.OS === 'android' per react-native-tvos\nexport const IS_ANDROID: boolean =\n Platform?.OS === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv'\n// on tvOS: Platform.OS === 'ios' per react-native-tvos\nexport const IS_IOS: boolean =\n Platform?.OS === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\nexport const SUPPORTS_DYNAMIC_COLOR_IOS: boolean =\n IS_IOS || process.env.TAMAGUI_DYNAMIC_COLOR_IOS === '1'\nexport const IS_TV: boolean =\n Platform?.isTV ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\n\ntype CurrentPlatform = 'web' | 'ios' | 'native' | 'android' | 'macos' | 'windows'\n\n// Platform.OS includes 'web' in its type (PlatformOSType) but never at native runtime,\n// so the map is partial — any unmapped OS falls through to 'native'.\nconst platforms: Partial<Record<typeof Platform.OS, CurrentPlatform>> = {\n ios: 'ios',\n android: 'android',\n macos: 'macos',\n windows: 'windows',\n}\n/**\n * Reflects Platform.OS. TV platforms are intentionally NOT separate values:\n * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)\n * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)\n * Use `IS_TV` combined with `IS_ANDROID`/`IS_IOS` to detect specific TV platforms.\n */\nexport const CURRENT_PLATFORM: CurrentPlatform =\n (Platform?.OS ? platforms[Platform.OS] : undefined) || 'native'\n\n// In Metro source mode, TAMAGUI_TARGET may not be set by the build tool.\n// Set it here so all process.env.TAMAGUI_TARGET runtime checks work correctly.\n// In pre-built dist, the build tool inlines TAMAGUI_TARGET as a literal string,\n// making this block dead code (if (!'native') → never executes).\nif (!process.env.TAMAGUI_TARGET) {\n process.env.TAMAGUI_TARGET = 'native'\n}\n"
10
10
  ]
11
11
  }
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var isServerRuntime_exports = {};
24
- __export(isServerRuntime_exports, {
25
- isServerRuntime: () => isServerRuntime
26
- });
27
- module.exports = __toCommonJS(isServerRuntime_exports);
28
- function isServerRuntime() {
29
- if (process.env.VITE_ENVIRONMENT === "ssr") return true;
30
- if (process.env.VITE_ENVIRONMENT === "client") return false;
31
- return typeof process !== "undefined" && !!process.versions && !!(process.versions.node || process.versions.bun);
32
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
25
- var isServerRuntime_exports = {};
26
- __export(isServerRuntime_exports, {
27
- isServerRuntime: () => isServerRuntime
28
- });
29
- module.exports = __toCommonJS(isServerRuntime_exports);
30
- function isServerRuntime() {
31
- if (process.env.VITE_ENVIRONMENT === "ssr") return true;
32
- if (process.env.VITE_ENVIRONMENT === "client") return false;
33
- return typeof process !== "undefined" && !!process.versions && !!(process.versions.node || process.versions.bun);
34
- }
35
- //# sourceMappingURL=isServerRuntime.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","isServerRuntime_exports","__export","isServerRuntime","module","exports","process","env","VITE_ENVIRONMENT","versions","node","bun"],"sources":["../../../src/server/isServerRuntime.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAA,CAAAC,OAAS,GAAAT,YAA2B,CAAAK,uBAAA;AAEzC,SAAIE,eAAYA,CAAA;EAChB,IAAIG,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB,cAAU,IAAO;EAEtD,IAAAF,OACE,CAAAC,GAAO,CAAAC,gBAAY,aACjB,SAAQ;EAGd,cAAAF,OAAA,sBAAAA,OAAA,CAAAG,QAAA,OAAAH,OAAA,CAAAG,QAAA,CAAAC,IAAA,IAAAJ,OAAA,CAAAG,QAAA,CAAAE,GAAA","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- function isServerRuntime() {
2
- if (process.env.VITE_ENVIRONMENT === "ssr") return true;
3
- if (process.env.VITE_ENVIRONMENT === "client") return false;
4
- return typeof process !== "undefined" && !!process.versions && !!(process.versions.node || process.versions.bun);
5
- }
6
- export { isServerRuntime };
7
- //# sourceMappingURL=isServerRuntime.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isServerRuntime","process","env","VITE_ENVIRONMENT","versions","node","bun"],"sources":["../../../src/server/isServerRuntime.ts"],"sourcesContent":[null],"mappings":"AAAO,SAASA,gBAAA,EAA2B;EAEzC,IAAIC,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB,OAAO,OAAO;EACnD,IAAIF,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB,UAAU,OAAO;EAEtD,OACE,OAAOF,OAAA,KAAY,eACnB,CAAC,CAACA,OAAA,CAAQG,QAAA,IACV,CAAC,EAAEH,OAAA,CAAQG,QAAA,CAASC,IAAA,IAASJ,OAAA,CAAQG,QAAA,CAAiBE,GAAA;AAE1D","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- function isServerRuntime() {
2
- if (process.env.VITE_ENVIRONMENT === "ssr") return true;
3
- if (process.env.VITE_ENVIRONMENT === "client") return false;
4
- return typeof process !== "undefined" && !!process.versions && !!(process.versions.node || process.versions.bun);
5
- }
6
- export { isServerRuntime };
7
- //# sourceMappingURL=isServerRuntime.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isServerRuntime","process","env","VITE_ENVIRONMENT","versions","node","bun"],"sources":["../../../src/server/isServerRuntime.ts"],"sourcesContent":[null],"mappings":"AAAO,SAASA,gBAAA,EAA2B;EAEzC,IAAIC,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB,OAAO,OAAO;EACnD,IAAIF,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB,UAAU,OAAO;EAEtD,OACE,OAAOF,OAAA,KAAY,eACnB,CAAC,CAACA,OAAA,CAAQG,QAAA,IACV,CAAC,EAAEH,OAAA,CAAQG,QAAA,CAASC,IAAA,IAASJ,OAAA,CAAQG,QAAA,CAAiBE,GAAA;AAE1D","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- export function isServerRuntime(): boolean {
2
- // explicit env override (vite replaces at build time, enabling DCE)
3
- if (process.env.VITE_ENVIRONMENT === 'ssr') return true
4
- if (process.env.VITE_ENVIRONMENT === 'client') return false
5
- // auto-detect node/bun server runtime
6
- return (
7
- typeof process !== 'undefined' &&
8
- !!process.versions &&
9
- !!(process.versions.node || (process.versions as any).bun)
10
- )
11
- }
@@ -1,3 +0,0 @@
1
- export declare function isServerRuntime(): boolean;
2
-
3
- //# sourceMappingURL=isServerRuntime.d.ts.map
@@ -1,11 +0,0 @@
1
- {
2
- "mappings": "AAAA,OAAO,iBAAS",
3
- "names": [],
4
- "sources": [
5
- "src/server/isServerRuntime.ts"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "export function isServerRuntime(): boolean {\n // explicit env override (vite replaces at build time, enabling DCE)\n if (process.env.VITE_ENVIRONMENT === 'ssr') return true\n if (process.env.VITE_ENVIRONMENT === 'client') return false\n // auto-detect node/bun server runtime\n return (\n typeof process !== 'undefined' &&\n !!process.versions &&\n !!(process.versions.node || (process.versions as any).bun)\n )\n}\n"
10
- ]
11
- }