rnwind 0.0.8 → 0.0.10
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/lib/cjs/core/parser/color.cjs +33 -1
- package/lib/cjs/core/parser/color.cjs.map +1 -1
- package/lib/cjs/core/parser/color.d.ts +10 -0
- package/lib/cjs/core/parser/declaration.cjs +121 -9
- package/lib/cjs/core/parser/declaration.cjs.map +1 -1
- package/lib/cjs/core/parser/gradient.cjs +46 -12
- package/lib/cjs/core/parser/gradient.cjs.map +1 -1
- package/lib/cjs/core/parser/gradient.d.ts +2 -1
- package/lib/cjs/core/parser/keyframes.cjs +27 -12
- package/lib/cjs/core/parser/keyframes.cjs.map +1 -1
- package/lib/cjs/core/parser/keyframes.d.ts +11 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs +33 -10
- package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -1
- package/lib/cjs/core/parser/length.cjs +17 -1
- package/lib/cjs/core/parser/length.cjs.map +1 -1
- package/lib/cjs/core/parser/safe-area.cjs +24 -3
- package/lib/cjs/core/parser/safe-area.cjs.map +1 -1
- package/lib/cjs/core/parser/theme-vars.cjs +58 -8
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -1
- package/lib/cjs/core/parser/tokens.cjs +77 -9
- package/lib/cjs/core/parser/tokens.cjs.map +1 -1
- package/lib/cjs/core/parser/tokens.d.ts +9 -0
- package/lib/cjs/core/parser/transform.cjs +18 -9
- package/lib/cjs/core/parser/transform.cjs.map +1 -1
- package/lib/cjs/core/parser/tw-parser.cjs +136 -34
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -1
- package/lib/cjs/core/parser/tw-parser.d.ts +20 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs +19 -1
- package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -1
- package/lib/cjs/core/parser/typography.cjs +15 -18
- package/lib/cjs/core/parser/typography.cjs.map +1 -1
- package/lib/cjs/core/parser/typography.d.ts +5 -5
- package/lib/cjs/core/style-builder/build-style.cjs +12 -3
- package/lib/cjs/core/style-builder/build-style.cjs.map +1 -1
- package/lib/cjs/core/style-builder/build-style.d.ts +3 -1
- package/lib/cjs/core/style-builder/union-builder.cjs +9 -11
- package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -1
- package/lib/cjs/core/style-builder/union-builder.d.ts +7 -8
- package/lib/cjs/metro/dts.cjs +6 -1
- package/lib/cjs/metro/dts.cjs.map +1 -1
- package/lib/cjs/metro/transformer.cjs +42 -77
- package/lib/cjs/metro/transformer.cjs.map +1 -1
- package/lib/cjs/metro/with-config.cjs +9 -29
- package/lib/cjs/metro/with-config.cjs.map +1 -1
- package/lib/cjs/runtime/hooks/use-scheme.cjs +17 -11
- package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -1
- package/lib/cjs/runtime/hooks/use-scheme.d.ts +7 -4
- package/lib/cjs/runtime/index.cjs +2 -1
- package/lib/cjs/runtime/index.cjs.map +1 -1
- package/lib/cjs/runtime/index.d.ts +2 -2
- package/lib/cjs/runtime/lookup-css.cjs +41 -0
- package/lib/cjs/runtime/lookup-css.cjs.map +1 -1
- package/lib/cjs/runtime/lookup-css.d.ts +29 -0
- package/lib/cjs/runtime/resolve.cjs +8 -6
- package/lib/cjs/runtime/resolve.cjs.map +1 -1
- package/lib/cjs/runtime/wrap.cjs +50 -57
- package/lib/cjs/runtime/wrap.cjs.map +1 -1
- package/lib/cjs/runtime/wrap.d.ts +10 -4
- package/lib/cjs/testing/index.cjs +1 -1
- package/lib/cjs/testing/index.cjs.map +1 -1
- package/lib/esm/core/parser/color.d.ts +10 -0
- package/lib/esm/core/parser/color.mjs +34 -3
- package/lib/esm/core/parser/color.mjs.map +1 -1
- package/lib/esm/core/parser/declaration.mjs +122 -10
- package/lib/esm/core/parser/declaration.mjs.map +1 -1
- package/lib/esm/core/parser/gradient.d.ts +2 -1
- package/lib/esm/core/parser/gradient.mjs +45 -11
- package/lib/esm/core/parser/gradient.mjs.map +1 -1
- package/lib/esm/core/parser/keyframes.d.ts +11 -0
- package/lib/esm/core/parser/keyframes.mjs +27 -12
- package/lib/esm/core/parser/keyframes.mjs.map +1 -1
- package/lib/esm/core/parser/layout-dispatcher.mjs +33 -10
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -1
- package/lib/esm/core/parser/length.mjs +17 -1
- package/lib/esm/core/parser/length.mjs.map +1 -1
- package/lib/esm/core/parser/safe-area.mjs +24 -3
- package/lib/esm/core/parser/safe-area.mjs.map +1 -1
- package/lib/esm/core/parser/theme-vars.mjs +58 -8
- package/lib/esm/core/parser/theme-vars.mjs.map +1 -1
- package/lib/esm/core/parser/tokens.d.ts +9 -0
- package/lib/esm/core/parser/tokens.mjs +77 -10
- package/lib/esm/core/parser/tokens.mjs.map +1 -1
- package/lib/esm/core/parser/transform.mjs +18 -9
- package/lib/esm/core/parser/transform.mjs.map +1 -1
- package/lib/esm/core/parser/tw-parser.d.ts +20 -0
- package/lib/esm/core/parser/tw-parser.mjs +138 -36
- package/lib/esm/core/parser/tw-parser.mjs.map +1 -1
- package/lib/esm/core/parser/typography-dispatcher.mjs +19 -1
- package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -1
- package/lib/esm/core/parser/typography.d.ts +5 -5
- package/lib/esm/core/parser/typography.mjs +15 -18
- package/lib/esm/core/parser/typography.mjs.map +1 -1
- package/lib/esm/core/style-builder/build-style.d.ts +3 -1
- package/lib/esm/core/style-builder/build-style.mjs +12 -3
- package/lib/esm/core/style-builder/build-style.mjs.map +1 -1
- package/lib/esm/core/style-builder/union-builder.d.ts +7 -8
- package/lib/esm/core/style-builder/union-builder.mjs +9 -11
- package/lib/esm/core/style-builder/union-builder.mjs.map +1 -1
- package/lib/esm/metro/dts.mjs +6 -1
- package/lib/esm/metro/dts.mjs.map +1 -1
- package/lib/esm/metro/transformer.mjs +42 -77
- package/lib/esm/metro/transformer.mjs.map +1 -1
- package/lib/esm/metro/with-config.mjs +10 -30
- package/lib/esm/metro/with-config.mjs.map +1 -1
- package/lib/esm/runtime/hooks/use-scheme.d.ts +7 -4
- package/lib/esm/runtime/hooks/use-scheme.mjs +17 -11
- package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -1
- package/lib/esm/runtime/index.d.ts +2 -2
- package/lib/esm/runtime/index.mjs +2 -2
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/runtime/lookup-css.d.ts +29 -0
- package/lib/esm/runtime/lookup-css.mjs +39 -1
- package/lib/esm/runtime/lookup-css.mjs.map +1 -1
- package/lib/esm/runtime/resolve.mjs +9 -7
- package/lib/esm/runtime/resolve.mjs.map +1 -1
- package/lib/esm/runtime/wrap.d.ts +10 -4
- package/lib/esm/runtime/wrap.mjs +50 -57
- package/lib/esm/runtime/wrap.mjs.map +1 -1
- package/lib/esm/testing/index.mjs +2 -2
- package/lib/esm/testing/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/parser/color.ts +32 -1
- package/src/core/parser/declaration.ts +119 -10
- package/src/core/parser/gradient.ts +48 -11
- package/src/core/parser/keyframes.ts +31 -3
- package/src/core/parser/layout-dispatcher.ts +32 -9
- package/src/core/parser/length.ts +18 -1
- package/src/core/parser/safe-area.ts +23 -2
- package/src/core/parser/theme-vars.ts +75 -8
- package/src/core/parser/tokens.ts +76 -9
- package/src/core/parser/transform.ts +19 -8
- package/src/core/parser/tw-parser.ts +148 -31
- package/src/core/parser/typography-dispatcher.ts +20 -1
- package/src/core/parser/typography.ts +15 -15
- package/src/core/style-builder/build-style.ts +12 -1
- package/src/core/style-builder/union-builder.ts +10 -12
- package/src/metro/dts.ts +6 -1
- package/src/metro/transformer.ts +42 -78
- package/src/metro/with-config.ts +10 -29
- package/src/runtime/hooks/use-scheme.ts +17 -10
- package/src/runtime/index.ts +2 -1
- package/src/runtime/lookup-css.ts +42 -0
- package/src/runtime/resolve.ts +9 -7
- package/src/runtime/wrap.tsx +57 -61
- package/src/testing/index.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-config.cjs","sources":["../../../../src/metro/with-config.ts"],"sourcesContent":["import { existsSync, mkdirSync, utimesSync, watch as watchFile } from 'node:fs'\nimport path from 'node:path'\nimport { writeDtsFile } from './dts'\nimport { createRnwindResolver, type ResolveRequestFn } from './resolver'\nimport { configureRnwindState, getRnwindState, onThemeChange } from './state'\n\n/** Default cache directory at the project root. Visible for debugging. */\nconst DEFAULT_CACHE_DIR = '.rnwind'\n\n/**\n * Active CSS watcher — replaced (and the prior one closed) when\n * `withRnwindConfig` is called again (Metro restart, repeated init).\n * Only one watcher per process; no stacking.\n */\nlet activeCssWatcher: { cssPath: string; close: () => void } | null = null\n\n/**\n * Watch the theme CSS for edits. On change, rewrite the per-scheme\n * files with the fresh theme AND bump `mtime` on every source file\n * rnwind has transformed so far — Metro's own watcher sees those\n * mtime changes, invalidates the modules, and re-transforms them\n * against the new CSS on the next request. `getCacheKey()` alone is\n * NOT enough: Metro samples the cache key once per worker lifetime,\n * so edits during an already-running dev server don't propagate\n * without this explicit nudge.\n * @param cssPath Absolute path to the theme CSS to watch.\n * @param projectRoot Metro's project root (for `getRnwindState`).\n */\nfunction watchThemeCss(cssPath: string, projectRoot: string): void {\n if (activeCssWatcher?.cssPath === cssPath) return\n activeCssWatcher?.close()\n if (!existsSync(cssPath)) return\n let pending = false\n const watcher = watchFile(cssPath, { persistent: false }, () => {\n // Debounce: editors often emit 2-3 change events per save (atomic\n // rename dance, tmp files). Coalesce to ONE rebuild per microtask.\n if (pending) return\n pending = true\n queueMicrotask(async () => {\n pending = false\n try {\n await onThemeChange(projectRoot)\n touchRecordedFiles(projectRoot)\n } catch {\n // Invalidation is best-effort — never crash the dev server.\n }\n })\n })\n activeCssWatcher = { cssPath, close: () => watcher.close() }\n}\n\n/**\n * Bump the mtime on every file the builder has transformed. Metro's\n * file watcher keys on `mtime`, so this is what makes it invalidate\n * those modules and re-transform them.\n * @param projectRoot Metro's project root.\n */\nfunction touchRecordedFiles(projectRoot: string): void {\n const state = getRnwindState(projectRoot)\n const files = state.builder.recordedFiles()\n const now = new Date()\n for (const file of files) {\n try {\n if (existsSync(file)) utimesSync(file, now, now)\n } catch {\n // One file's stat failure shouldn't stop the others.\n }\n }\n}\n\n/**\n * Where the rnwind babel transformer lives — resolved relative to this\n * module so the path works from both the `src/` tree (tests) and the\n * built `lib/` output. Tries a few extensions because `require.resolve`\n * doesn't auto-find `.cjs` / `.mjs` from a bare specifier.\n * @returns Absolute path to the rnwind transformer module.\n */\nfunction transformerPath(): string {\n for (const candidate of ['./transformer.cjs', './transformer.mjs', './transformer.js', './transformer.ts', './transformer']) {\n try {\n return require.resolve(candidate)\n } catch {\n // try the next extension\n }\n }\n throw new Error('rnwind: could not resolve the metro transformer path')\n}\n\n/**\n * Resolve the effective cache directory, honoring a user override and\n * falling back to `<projectRoot>/.rnwind`.\n * @param projectRoot Anchor for relative paths.\n * @param override User-supplied option.\n * @returns Absolute cache directory.\n */\nfunction resolveCacheDir(projectRoot: string, override: string | undefined): string {\n if (!override || override.length === 0) return path.resolve(projectRoot, DEFAULT_CACHE_DIR)\n return path.isAbsolute(override) ? override : path.resolve(projectRoot, override)\n}\n\n/**\n * Read the theme CSS and extract `@variant <name>` blocks for the .d.ts\n * generator. Forces construction of `getRnwindState`, then reads\n * `parser.declaredSchemes` (populated synchronously at construction).\n * @param cssEntry Absolute path to theme CSS.\n * @param projectRoot\n * @returns Scheme names (empty when the theme has no variants; `'base'` is filtered).\n */\nfunction discoverSchemes(cssEntry: string, projectRoot: string): readonly string[] {\n if (!existsSync(cssEntry)) return []\n try {\n const { parser } = getRnwindState(projectRoot)\n return parser.declaredSchemes.filter((name) => name !== 'base')\n } catch {\n return []\n }\n}\n\n/** User-facing options for `withRnwindConfig`. */\nexport interface RnwindMetroOptions {\n /** Path to the theme CSS (absolute or relative to `projectRoot`). Required. */\n cssEntryFile: string\n /** Where rnwind writes the `.d.ts` file. Set `false` to disable. Defaults to `<projectRoot>/rnwind-types.d.ts`. */\n dtsFile?: string | false\n /** Optional project-root override — defaults to `metroConfig.projectRoot` then `process.cwd()`. */\n projectRoot?: string\n /** Cache directory. Absolute, or relative to `projectRoot`. Default: `.rnwind` at project root. */\n cacheDir?: string\n /**\n * Extra module specifiers whose component exports rnwind should\n * auto-wrap at import sites — `import { View } from 'react-native'`\n * becomes `const View = wrap(_rnw0)` so `<View className=\"…\">` resolves\n * styles at runtime. Merged with the built-in defaults: `react-native`,\n * `react-native-reanimated`, `react-native-svg`,\n * `react-native-gesture-handler`, `react-native-safe-area-context`,\n * `expo-linear-gradient`, `expo-image`, and more.\n *\n * A module NOT in this list keeps its raw imports — the importing\n * component receives `className` as a plain prop and can resolve it\n * via `useCss` / `wrap` itself. Use this to opt your design-system /\n * UI primitive packages into the auto-wrap path.\n */\n wrapModules?: readonly string[]\n}\n\n/** Shape we mutate on Metro's config. Loose so we don't pin Metro's internal types. */\nexport interface MetroConfigLike {\n projectRoot?: string\n watchFolders?: string[]\n transformer?: {\n babelTransformerPath?: string\n [key: string]: unknown\n }\n resolver?: {\n resolveRequest?: ResolveRequestFn | null\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\n/**\n * Wrap a Metro config with rnwind's pipeline:\n * - Install the rnwind babel transformer.\n * - Chain a `resolveRequest` hook that serves\n * `rnwind/__generated/schemes` from `<cacheDir>/schemes.js`.\n * - Write the `.d.ts` so TypeScript accepts `className=` on RN components.\n * - Publish the theme CSS path + cache dir via env so Metro workers\n * can rebuild their local state.\n * - Ensure the cache dir is a watched folder Metro's haste-map indexes.\n *\n * Theme-edit hot reload happens implicitly: every transformed file\n * imports `rnwind/__generated/schemes`, and that module eager-imports\n * `common.style.js`. When the theme changes, the per-scheme files\n * regenerate with new bytes; Metro's content SHA1 dedup detects the\n * change and invalidates every importer automatically.\n * `getCacheKey()` on the transformer covers the per-file transform\n * cache. No file watcher / source-padding hack needed — the dep graph\n * carries the signal.\n * @param metroConfig Config from `getDefaultConfig(__dirname)` or equivalent.\n * @param options rnwind options.\n * @returns The same config, mutated.\n */\nexport function withRnwindConfig<C extends MetroConfigLike>(metroConfig: C, options: RnwindMetroOptions): C {\n const projectRoot = options.projectRoot ?? metroConfig.projectRoot ?? process.cwd()\n const cacheDir = resolveCacheDir(projectRoot, options.cacheDir)\n const cssEntry = path.isAbsolute(options.cssEntryFile) ? options.cssEntryFile : path.resolve(projectRoot, options.cssEntryFile)\n\n mkdirSync(cacheDir, { recursive: true })\n const watchFolders = (metroConfig.watchFolders ?? []).filter((p) => typeof p === 'string' && p.length > 0)\n configureRnwindState(cssEntry, cacheDir, watchFolders, options.wrapModules)\n\n // Warm the state eagerly (in the Metro master process) so oxide's\n // Scanner walks every project source (and every monorepo\n // watch-folder) ONCE and the manifest + scheme files hold the\n // complete union before Metro's resolver tries to SHA1 them on the\n // first transform. Each worker lazy-repeats this scan on its first\n // transform to converge on identical state.\n try {\n void getRnwindState(projectRoot).builder.ensureFilesExist()\n } catch {\n // Any init error surfaces again at the first transform; don't crash Metro boot.\n }\n\n // Install transformer + resolver. Capture the existing\n // babelTransformerPath BEFORE we override it — our worker chains to\n // it (env-passed) so Flow / expo-router / babel-preset-expo etc. all\n // continue to run.\n const existingTransformerPath = metroConfig.transformer?.babelTransformerPath\n if (typeof existingTransformerPath === 'string' && existingTransformerPath.length > 0) {\n process.env.RNWIND_UPSTREAM_TRANSFORMER = existingTransformerPath\n }\n const upstream = metroConfig.resolver?.resolveRequest ?? null\n metroConfig.transformer = { ...metroConfig.transformer, babelTransformerPath: transformerPath() }\n metroConfig.resolver = { ...metroConfig.resolver, resolveRequest: createRnwindResolver(upstream) }\n\n // Metro's haste-map indexes `watchFolders` at startup. Adding the\n // cache dir guarantees scheme style files + manifest get SHA1'd\n // without a \"Failed to get the SHA-1\" race when the first transform\n // writes them.\n const existingWatch = metroConfig.watchFolders ?? []\n metroConfig.watchFolders = existingWatch.includes(cacheDir) ? existingWatch : [...existingWatch, cacheDir]\n\n if (options.dtsFile !== false) {\n const dtsPath = options.dtsFile ?? path.resolve(projectRoot, 'rnwind-types.d.ts')\n const schemes = discoverSchemes(cssEntry, projectRoot)\n writeDtsFile(dtsPath, schemes)\n }\n\n // Watch the theme CSS. On edit, we rewrite scheme files AND touch\n // mtime on every transformed source file so Metro invalidates them\n // and re-transforms — the only reliable way to propagate theme\n // changes to an already-running dev server.\n watchThemeCss(cssEntry, projectRoot)\n\n return metroConfig\n}\n"],"names":["existsSync","watchFile","onThemeChange","state","getRnwindState","utimesSync","mkdirSync","configureRnwindState","createRnwindResolver","writeDtsFile"],"mappings":";;;;;;;;AAMA;AACA,MAAM,iBAAiB,GAAG,SAAS;AAEnC;;;;AAIG;AACH,IAAI,gBAAgB,GAAkD,IAAI;AAE1E;;;;;;;;;;;AAWG;AACH,SAAS,aAAa,CAAC,OAAe,EAAE,WAAmB,EAAA;AACzD,IAAA,IAAI,gBAAgB,EAAE,OAAO,KAAK,OAAO;QAAE;IAC3C,gBAAgB,EAAE,KAAK,EAAE;AACzB,IAAA,IAAI,CAACA,kBAAU,CAAC,OAAO,CAAC;QAAE;IAC1B,IAAI,OAAO,GAAG,KAAK;AACnB,IAAA,MAAM,OAAO,GAAGC,aAAS,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,MAAK;;;AAG7D,QAAA,IAAI,OAAO;YAAE;QACb,OAAO,GAAG,IAAI;QACd,cAAc,CAAC,YAAW;YACxB,OAAO,GAAG,KAAK;AACf,YAAA,IAAI;AACF,gBAAA,MAAMC,mBAAa,CAAC,WAAW,CAAC;gBAChC,kBAAkB,CAAC,WAAW,CAAC;YACjC;AAAE,YAAA,MAAM;;YAER;AACF,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AACF,IAAA,gBAAgB,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,KAAK,EAAE,EAAE;AAC9D;AAEA;;;;;AAKG;AACH,SAAS,kBAAkB,CAAC,WAAmB,EAAA;AAC7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C,GAAG,CAAC,2BAA2B,GAAG,uBAAuB;IACnE;IACA,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,cAAc,IAAI,IAAI;AAC7D,IAAA,WAAW,CAAC,WAAW,GAAG,EAAE,GAAG,WAAW,CAAC,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,EAAE;AACjG,IAAA,WAAW,CAAC,QAAQ,GAAG,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,cAAc,EAAEI,6BAAoB,CAAC,QAAQ,CAAC,EAAE;;;;;AAMlG,IAAA,MAAM,aAAa,GAAG,WAAW,CAAC,YAAY,IAAI,EAAE;IACpD,WAAW,CAAC,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,aAAa,GAAG,CAAC,GAAG,aAAa,EAAE,QAAQ,CAAC;AAE1G,IAAA,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE;AAC7B,QAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,mBAAmB,CAAC;QACjF,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC;AACtD,QAAAC,gBAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IAChC;;;;;AAMA,IAAA,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC;AAEpC,IAAA,OAAO,WAAW;AACpB;;;;"}
|
|
1
|
+
{"version":3,"file":"with-config.cjs","sources":["../../../../src/metro/with-config.ts"],"sourcesContent":["import { existsSync, mkdirSync, watch as watchFile } from 'node:fs'\nimport path from 'node:path'\nimport { writeDtsFile } from './dts'\nimport { createRnwindResolver, type ResolveRequestFn } from './resolver'\nimport { configureRnwindState, getRnwindState, onThemeChange } from './state'\n\n/** Default cache directory at the project root. Visible for debugging. */\nconst DEFAULT_CACHE_DIR = '.rnwind'\n\n/**\n * Active CSS watcher — replaced (and the prior one closed) when\n * `withRnwindConfig` is called again (Metro restart, repeated init).\n * Only one watcher per process; no stacking.\n */\nlet activeCssWatcher: { cssPath: string; close: () => void } | null = null\n\n/**\n * Watch the theme CSS for edits. On change, rebuild state against the fresh\n * CSS and rewrite the per-scheme files (`onThemeChange` → full rescan →\n * `writeSchemes`). That's the entire HMR signal: every transformed source\n * imports `rnwind/__generated/schemes`, which eager-imports\n * `common.style.js`; the rewrite changes its bytes, Metro's content-SHA1\n * dedup notices, and every importer is invalidated + re-bundled with the new\n * style values. The rewritten JSX references atoms by NAME (theme-independent),\n * so no source-file re-transform / mtime nudge is needed — the dep graph\n * carries the signal.\n * @param cssPath Absolute path to the theme CSS to watch.\n * @param projectRoot Metro's project root (for `getRnwindState`).\n */\nfunction watchThemeCss(cssPath: string, projectRoot: string): void {\n if (activeCssWatcher?.cssPath === cssPath) return\n activeCssWatcher?.close()\n if (!existsSync(cssPath)) return\n let pending = false\n const watcher = watchFile(cssPath, { persistent: false }, () => {\n // Debounce: editors often emit 2-3 change events per save (atomic\n // rename dance, tmp files). Coalesce to ONE rebuild per microtask.\n if (pending) return\n pending = true\n queueMicrotask(async () => {\n pending = false\n try {\n await onThemeChange(projectRoot)\n } catch {\n // Invalidation is best-effort — never crash the dev server.\n }\n })\n })\n activeCssWatcher = { cssPath, close: () => watcher.close() }\n}\n\n/**\n * Where the rnwind babel transformer lives — resolved relative to this\n * module so the path works from both the `src/` tree (tests) and the\n * built `lib/` output. Tries a few extensions because `require.resolve`\n * doesn't auto-find `.cjs` / `.mjs` from a bare specifier.\n * @returns Absolute path to the rnwind transformer module.\n */\nfunction transformerPath(): string {\n for (const candidate of ['./transformer.cjs', './transformer.mjs', './transformer.js', './transformer.ts', './transformer']) {\n try {\n return require.resolve(candidate)\n } catch {\n // try the next extension\n }\n }\n throw new Error('rnwind: could not resolve the metro transformer path')\n}\n\n/**\n * Resolve the effective cache directory, honoring a user override and\n * falling back to `<projectRoot>/.rnwind`.\n * @param projectRoot Anchor for relative paths.\n * @param override User-supplied option.\n * @returns Absolute cache directory.\n */\nfunction resolveCacheDir(projectRoot: string, override: string | undefined): string {\n if (!override || override.length === 0) return path.resolve(projectRoot, DEFAULT_CACHE_DIR)\n return path.isAbsolute(override) ? override : path.resolve(projectRoot, override)\n}\n\n/**\n * Read the theme CSS and extract `@variant <name>` blocks for the .d.ts\n * generator. Forces construction of `getRnwindState`, then reads\n * `parser.declaredSchemes` (populated synchronously at construction).\n * @param cssEntry Absolute path to theme CSS.\n * @param projectRoot\n * @returns Scheme names (empty when the theme has no variants; `'base'` is filtered).\n */\nfunction discoverSchemes(cssEntry: string, projectRoot: string): readonly string[] {\n if (!existsSync(cssEntry)) return []\n try {\n const { parser } = getRnwindState(projectRoot)\n return parser.declaredSchemes.filter((name) => name !== 'base')\n } catch {\n return []\n }\n}\n\n/** User-facing options for `withRnwindConfig`. */\nexport interface RnwindMetroOptions {\n /** Path to the theme CSS (absolute or relative to `projectRoot`). Required. */\n cssEntryFile: string\n /** Where rnwind writes the `.d.ts` file. Set `false` to disable. Defaults to `<projectRoot>/rnwind-types.d.ts`. */\n dtsFile?: string | false\n /** Optional project-root override — defaults to `metroConfig.projectRoot` then `process.cwd()`. */\n projectRoot?: string\n /** Cache directory. Absolute, or relative to `projectRoot`. Default: `.rnwind` at project root. */\n cacheDir?: string\n /**\n * Extra module specifiers whose component exports rnwind should\n * auto-wrap at import sites — `import { View } from 'react-native'`\n * becomes `const View = wrap(_rnw0)` so `<View className=\"…\">` resolves\n * styles at runtime. Merged with the built-in defaults: `react-native`,\n * `react-native-reanimated`, `react-native-svg`,\n * `react-native-gesture-handler`, `react-native-safe-area-context`,\n * `expo-linear-gradient`, `expo-image`, and more.\n *\n * A module NOT in this list keeps its raw imports — the importing\n * component receives `className` as a plain prop and can resolve it\n * via `useCss` / `wrap` itself. Use this to opt your design-system /\n * UI primitive packages into the auto-wrap path.\n */\n wrapModules?: readonly string[]\n}\n\n/** Shape we mutate on Metro's config. Loose so we don't pin Metro's internal types. */\nexport interface MetroConfigLike {\n projectRoot?: string\n watchFolders?: string[]\n transformer?: {\n babelTransformerPath?: string\n [key: string]: unknown\n }\n resolver?: {\n resolveRequest?: ResolveRequestFn | null\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\n/**\n * Wrap a Metro config with rnwind's pipeline:\n * - Install the rnwind babel transformer.\n * - Chain a `resolveRequest` hook that serves\n * `rnwind/__generated/schemes` from `<cacheDir>/schemes.js`.\n * - Write the `.d.ts` so TypeScript accepts `className=` on RN components.\n * - Publish the theme CSS path + cache dir via env so Metro workers\n * can rebuild their local state.\n * - Ensure the cache dir is a watched folder Metro's haste-map indexes.\n *\n * Theme-edit hot reload happens implicitly: every transformed file\n * imports `rnwind/__generated/schemes`, and that module eager-imports\n * `common.style.js`. When the theme changes, the per-scheme files\n * regenerate with new bytes; Metro's content SHA1 dedup detects the\n * change and invalidates every importer automatically.\n * `getCacheKey()` on the transformer covers the per-file transform\n * cache. No file watcher / source-padding hack needed — the dep graph\n * carries the signal.\n * @param metroConfig Config from `getDefaultConfig(__dirname)` or equivalent.\n * @param options rnwind options.\n * @returns The same config, mutated.\n */\nexport function withRnwindConfig<C extends MetroConfigLike>(metroConfig: C, options: RnwindMetroOptions): C {\n const projectRoot = options.projectRoot ?? metroConfig.projectRoot ?? process.cwd()\n const cacheDir = resolveCacheDir(projectRoot, options.cacheDir)\n const cssEntry = path.isAbsolute(options.cssEntryFile) ? options.cssEntryFile : path.resolve(projectRoot, options.cssEntryFile)\n\n mkdirSync(cacheDir, { recursive: true })\n const watchFolders = (metroConfig.watchFolders ?? []).filter((p) => typeof p === 'string' && p.length > 0)\n configureRnwindState(cssEntry, cacheDir, watchFolders, options.wrapModules)\n\n // Warm the state eagerly (in the Metro master process) so oxide's\n // Scanner walks every project source (and every monorepo\n // watch-folder) ONCE and the manifest + scheme files hold the\n // complete union before Metro's resolver tries to SHA1 them on the\n // first transform. Each worker lazy-repeats this scan on its first\n // transform to converge on identical state.\n try {\n void getRnwindState(projectRoot).builder.ensureFilesExist()\n } catch {\n // Any init error surfaces again at the first transform; don't crash Metro boot.\n }\n\n // Install transformer + resolver. Capture the existing\n // babelTransformerPath BEFORE we override it — our worker chains to\n // it (env-passed) so Flow / expo-router / babel-preset-expo etc. all\n // continue to run.\n const existingTransformerPath = metroConfig.transformer?.babelTransformerPath\n if (typeof existingTransformerPath === 'string' && existingTransformerPath.length > 0) {\n process.env.RNWIND_UPSTREAM_TRANSFORMER = existingTransformerPath\n }\n const upstream = metroConfig.resolver?.resolveRequest ?? null\n metroConfig.transformer = { ...metroConfig.transformer, babelTransformerPath: transformerPath() }\n metroConfig.resolver = { ...metroConfig.resolver, resolveRequest: createRnwindResolver(upstream) }\n\n // Metro's haste-map indexes `watchFolders` at startup. Adding the\n // cache dir guarantees scheme style files + manifest get SHA1'd\n // without a \"Failed to get the SHA-1\" race when the first transform\n // writes them.\n const existingWatch = metroConfig.watchFolders ?? []\n metroConfig.watchFolders = existingWatch.includes(cacheDir) ? existingWatch : [...existingWatch, cacheDir]\n\n if (options.dtsFile !== false) {\n const dtsPath = options.dtsFile ?? path.resolve(projectRoot, 'rnwind-types.d.ts')\n const schemes = discoverSchemes(cssEntry, projectRoot)\n writeDtsFile(dtsPath, schemes)\n }\n\n // Watch the theme CSS. On edit, we rewrite scheme files AND touch\n // mtime on every transformed source file so Metro invalidates them\n // and re-transforms — the only reliable way to propagate theme\n // changes to an already-running dev server.\n watchThemeCss(cssEntry, projectRoot)\n\n return metroConfig\n}\n"],"names":["existsSync","watchFile","onThemeChange","getRnwindState","mkdirSync","configureRnwindState","createRnwindResolver","writeDtsFile"],"mappings":";;;;;;;;AAMA;AACA,MAAM,iBAAiB,GAAG,SAAS;AAEnC;;;;AAIG;AACH,IAAI,gBAAgB,GAAkD,IAAI;AAE1E;;;;;;;;;;;;AAYG;AACH,SAAS,aAAa,CAAC,OAAe,EAAE,WAAmB,EAAA;AACzD,IAAA,IAAI,gBAAgB,EAAE,OAAO,KAAK,OAAO;QAAE;IAC3C,gBAA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
6
|
/**
|
|
6
7
|
* Synthetic scheme name applied when tokens aren't declared under any
|
|
@@ -20,11 +21,13 @@ const BASE_SCHEME = 'base';
|
|
|
20
21
|
*/
|
|
21
22
|
function useTheme() {
|
|
22
23
|
const { scheme, tables } = rnwindProvider.useRnwind();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
// The build registers token tables on the manifest so `useColor` works out
|
|
25
|
+
// of the box; an explicit `tables` prop layers on top (the prop wins).
|
|
26
|
+
const registered = lookupCss.getThemeTokens();
|
|
27
|
+
const base = { ...registered[BASE_SCHEME], ...tables[BASE_SCHEME] };
|
|
28
|
+
const schemeTable = { ...registered[scheme], ...tables[scheme] };
|
|
29
|
+
// Base tokens apply everywhere (CSS `:root` cascade); the active scheme's
|
|
30
|
+
// own entries override on overlap.
|
|
28
31
|
if (Object.keys(schemeTable).length === 0)
|
|
29
32
|
return base;
|
|
30
33
|
return { ...base, ...schemeTable };
|
|
@@ -42,23 +45,26 @@ function useToken(cssVariable) {
|
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
47
|
* Read a color token by shorthand name — `useColor('primary')` resolves
|
|
45
|
-
* `--color-primary` for the active scheme.
|
|
46
|
-
*
|
|
48
|
+
* `--color-primary` for the active scheme. A fully-qualified name
|
|
49
|
+
* (`--color-primary`) is accepted as-is, so the call doesn't silently miss by
|
|
50
|
+
* double-prefixing into `--color---color-primary`.
|
|
51
|
+
* @param name Token suffix after `--color-`, or the full `--color-*` name.
|
|
47
52
|
* @returns Resolved color string, or undefined when the token is missing
|
|
48
53
|
* or its value isn't a string.
|
|
49
54
|
*/
|
|
50
55
|
function useColor(name) {
|
|
51
|
-
const value = useToken(`--color-${name}`);
|
|
56
|
+
const value = useToken(name.startsWith('--') ? name : `--color-${name}`);
|
|
52
57
|
return typeof value === 'string' ? value : undefined;
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Read a spacing token by shorthand name — `useSize('4')` resolves
|
|
56
|
-
* `--spacing-4` for the active scheme.
|
|
57
|
-
*
|
|
61
|
+
* `--spacing-4` for the active scheme. A fully-qualified `--spacing-*` name is
|
|
62
|
+
* accepted as-is (no double-prefix miss).
|
|
63
|
+
* @param name Token suffix after `--spacing-`, or the full `--spacing-*` name.
|
|
58
64
|
* @returns Resolved spacing value, or undefined when the token is missing.
|
|
59
65
|
*/
|
|
60
66
|
function useSize(name) {
|
|
61
|
-
return useToken(`--spacing-${name}`);
|
|
67
|
+
return useToken(name.startsWith('--') ? name : `--spacing-${name}`);
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
exports.useColor = useColor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-scheme.cjs","sources":["../../../../../src/runtime/hooks/use-scheme.ts"],"sourcesContent":["import type { ThemeTable } from '../../core/types'\nimport { useRnwind } from '../components/rnwind-provider'\n\n/**\n * Synthetic scheme name applied when tokens aren't declared under any\n * `@variant` block — the \"no active variant\" fallback every theme table\n * inherits from.\n */\nconst BASE_SCHEME = 'base'\n\n/**\n * Access the resolved theme table for the active scheme.\n *\n * Tokens declared outside any `@variant` block live in the `base` table and\n * should apply everywhere — just like the CSS cascade treats `:root` as a\n * default for every ancestor-scoped override. We merge `base` under the\n * active scheme so a scheme that doesn't declare a token still sees the\n * base default, while the scheme's own entries win on overlap.\n * @returns Token table for the active scheme.\n */\nexport function useTheme(): ThemeTable {\n const { scheme, tables } = useRnwind()\n const base = tables[BASE_SCHEME]
|
|
1
|
+
{"version":3,"file":"use-scheme.cjs","sources":["../../../../../src/runtime/hooks/use-scheme.ts"],"sourcesContent":["import type { ThemeTable } from '../../core/types'\nimport { useRnwind } from '../components/rnwind-provider'\nimport { getThemeTokens } from '../lookup-css'\n\n/**\n * Synthetic scheme name applied when tokens aren't declared under any\n * `@variant` block — the \"no active variant\" fallback every theme table\n * inherits from.\n */\nconst BASE_SCHEME = 'base'\n\n/**\n * Access the resolved theme table for the active scheme.\n *\n * Tokens declared outside any `@variant` block live in the `base` table and\n * should apply everywhere — just like the CSS cascade treats `:root` as a\n * default for every ancestor-scoped override. We merge `base` under the\n * active scheme so a scheme that doesn't declare a token still sees the\n * base default, while the scheme's own entries win on overlap.\n * @returns Token table for the active scheme.\n */\nexport function useTheme(): ThemeTable {\n const { scheme, tables } = useRnwind()\n // The build registers token tables on the manifest so `useColor` works out\n // of the box; an explicit `tables` prop layers on top (the prop wins).\n const registered = getThemeTokens()\n const base = { ...registered[BASE_SCHEME], ...tables[BASE_SCHEME] }\n const schemeTable = { ...registered[scheme], ...tables[scheme] }\n // Base tokens apply everywhere (CSS `:root` cascade); the active scheme's\n // own entries override on overlap.\n if (Object.keys(schemeTable).length === 0) return base\n return { ...base, ...schemeTable }\n}\n\n/**\n * Read a raw CSS custom property's value for the active scheme. Accepts\n * either `--foo` or the bare `foo` form for convenience.\n * @param cssVariable CSS custom property name (with or without the leading `--`).\n * @returns The resolved value, or undefined when the token is missing.\n */\nexport function useToken(cssVariable: string): string | number | undefined {\n const table = useTheme()\n const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`\n return table[name]\n}\n\n/**\n * Read a color token by shorthand name — `useColor('primary')` resolves\n * `--color-primary` for the active scheme. A fully-qualified name\n * (`--color-primary`) is accepted as-is, so the call doesn't silently miss by\n * double-prefixing into `--color---color-primary`.\n * @param name Token suffix after `--color-`, or the full `--color-*` name.\n * @returns Resolved color string, or undefined when the token is missing\n * or its value isn't a string.\n */\nexport function useColor(name: string): string | undefined {\n const value = useToken(name.startsWith('--') ? name : `--color-${name}`)\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Read a spacing token by shorthand name — `useSize('4')` resolves\n * `--spacing-4` for the active scheme. A fully-qualified `--spacing-*` name is\n * accepted as-is (no double-prefix miss).\n * @param name Token suffix after `--spacing-`, or the full `--spacing-*` name.\n * @returns Resolved spacing value, or undefined when the token is missing.\n */\nexport function useSize(name: string): number | string | undefined {\n return useToken(name.startsWith('--') ? name :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AAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,aAAa,IAAI,CAAA,CAAE,CAAC;AACrE;;;;;;;"}
|
|
@@ -19,16 +19,19 @@ export declare function useTheme(): ThemeTable;
|
|
|
19
19
|
export declare function useToken(cssVariable: string): string | number | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* Read a color token by shorthand name — `useColor('primary')` resolves
|
|
22
|
-
* `--color-primary` for the active scheme.
|
|
23
|
-
*
|
|
22
|
+
* `--color-primary` for the active scheme. A fully-qualified name
|
|
23
|
+
* (`--color-primary`) is accepted as-is, so the call doesn't silently miss by
|
|
24
|
+
* double-prefixing into `--color---color-primary`.
|
|
25
|
+
* @param name Token suffix after `--color-`, or the full `--color-*` name.
|
|
24
26
|
* @returns Resolved color string, or undefined when the token is missing
|
|
25
27
|
* or its value isn't a string.
|
|
26
28
|
*/
|
|
27
29
|
export declare function useColor(name: string): string | undefined;
|
|
28
30
|
/**
|
|
29
31
|
* Read a spacing token by shorthand name — `useSize('4')` resolves
|
|
30
|
-
* `--spacing-4` for the active scheme.
|
|
31
|
-
*
|
|
32
|
+
* `--spacing-4` for the active scheme. A fully-qualified `--spacing-*` name is
|
|
33
|
+
* accepted as-is (no double-prefix miss).
|
|
34
|
+
* @param name Token suffix after `--spacing-`, or the full `--spacing-*` name.
|
|
32
35
|
* @returns Resolved spacing value, or undefined when the token is missing.
|
|
33
36
|
*/
|
|
34
37
|
export declare function useSize(name: string): number | string | undefined;
|
|
@@ -14,7 +14,7 @@ var useScheme = require('./hooks/use-scheme.cjs');
|
|
|
14
14
|
* string when integrating with build tooling that may see multiple rnwind
|
|
15
15
|
* copies (e.g. workspace overrides).
|
|
16
16
|
*/
|
|
17
|
-
const VERSION = '0.0.
|
|
17
|
+
const VERSION = '0.0.8';
|
|
18
18
|
|
|
19
19
|
exports.activeBreakpointFor = lookupCss.activeBreakpointFor;
|
|
20
20
|
exports.getBreakpoints = lookupCss.getBreakpoints;
|
|
@@ -22,6 +22,7 @@ exports.lookupCss = lookupCss.lookupCss;
|
|
|
22
22
|
exports.registerAtoms = lookupCss.registerAtoms;
|
|
23
23
|
exports.registerBreakpoints = lookupCss.registerBreakpoints;
|
|
24
24
|
exports.registerSchemeLoader = lookupCss.registerSchemeLoader;
|
|
25
|
+
exports.registerThemeTokens = lookupCss.registerThemeTokens;
|
|
25
26
|
exports.setWindowHeightProvider = lookupCss.setWindowHeightProvider;
|
|
26
27
|
exports.wrap = wrap.wrap;
|
|
27
28
|
exports.wrapNamespace = wrap.wrapNamespace;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["export {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n} from './lookup-css'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { wrap, wrapNamespace } from './wrap'\nexport { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve'\nexport type { ResolvedCss } from './resolve'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["export {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerThemeTokens,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n} from './lookup-css'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { wrap, wrapNamespace } from './wrap'\nexport { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve'\nexport type { ResolvedCss } from './resolve'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.8' as const\n"],"names":[],"mappings":";;;;;;;;;;;AA0BA;;;;AAIG;AACI,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, } from './lookup-css';
|
|
1
|
+
export { lookupCss, registerAtoms, registerBreakpoints, registerThemeTokens, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, } from './lookup-css';
|
|
2
2
|
export type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css';
|
|
3
3
|
export { wrap, wrapNamespace } from './wrap';
|
|
4
4
|
export { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve';
|
|
@@ -19,4 +19,4 @@ export type { Scheme, RnwindConfig } from './types';
|
|
|
19
19
|
* string when integrating with build tooling that may see multiple rnwind
|
|
20
20
|
* copies (e.g. workspace overrides).
|
|
21
21
|
*/
|
|
22
|
-
export declare const VERSION: "0.0.
|
|
22
|
+
export declare const VERSION: "0.0.8";
|
|
@@ -40,6 +40,8 @@ const cache = {
|
|
|
40
40
|
atoms: Object.create(null),
|
|
41
41
|
breakpoints: Object.create(null),
|
|
42
42
|
breakpointList: [],
|
|
43
|
+
/** Per-scheme theme token tables (`--color-*`, `--spacing-*`, …) the manifest registers for `useColor` / `useToken` / `useSize`. */
|
|
44
|
+
themeTokens: {},
|
|
43
45
|
};
|
|
44
46
|
/**
|
|
45
47
|
* Bumps on every {@link registerAtoms} call. {@link HoistCache} entries
|
|
@@ -253,6 +255,19 @@ function tierFor(windowWidth) {
|
|
|
253
255
|
}
|
|
254
256
|
return tier;
|
|
255
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Public breakpoint-tier for a width — the count of registered breakpoints
|
|
260
|
+
* whose threshold is reached. Used by the runtime resolver as its width
|
|
261
|
+
* cache dimension: the numeric tier is bounded AND exact, unlike the
|
|
262
|
+
* clamped `activeBreakpoint` NAME (which collapses tier-0 into the smallest
|
|
263
|
+
* breakpoint, so widths straddling that threshold would share a cache key
|
|
264
|
+
* and serve a stale style).
|
|
265
|
+
* @param windowWidth Live window width in px.
|
|
266
|
+
* @returns Tier 0..N.
|
|
267
|
+
*/
|
|
268
|
+
function breakpointTier(windowWidth) {
|
|
269
|
+
return tierFor(windowWidth);
|
|
270
|
+
}
|
|
256
271
|
/**
|
|
257
272
|
* Build the style array for a (hoist, scheme, state, width) tuple.
|
|
258
273
|
* Walks the atom list, applies the interact-state and breakpoint
|
|
@@ -450,6 +465,28 @@ function registerBreakpoints(breakpoints) {
|
|
|
450
465
|
function getBreakpoints() {
|
|
451
466
|
return cache.breakpointList;
|
|
452
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Register the per-scheme theme token tables the manifest module emits at
|
|
470
|
+
* load time — the data source for `useColor` / `useToken` / `useSize`. The
|
|
471
|
+
* build lowers `--color-*` tokens to sRGB before registering them, so these
|
|
472
|
+
* are RN-safe. Replaces the prior tables; bumps `atomVersion` so a theme HMR
|
|
473
|
+
* cycle re-resolves. The build registers tokens here so the hooks work out of
|
|
474
|
+
* the box, without the user manually threading a `tables` prop on the provider.
|
|
475
|
+
* @param tables Scheme name → (token name → value) map.
|
|
476
|
+
*/
|
|
477
|
+
function registerThemeTokens(tables) {
|
|
478
|
+
cache.themeTokens = tables;
|
|
479
|
+
atomVersion += 1;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* The manifest-registered theme token tables. The provider merges these under
|
|
483
|
+
* any explicit `tables` prop (the prop wins), so `useColor` resolves from the
|
|
484
|
+
* build by default.
|
|
485
|
+
* @returns Registered per-scheme token tables.
|
|
486
|
+
*/
|
|
487
|
+
function getThemeTokens() {
|
|
488
|
+
return cache.themeTokens;
|
|
489
|
+
}
|
|
453
490
|
/**
|
|
454
491
|
* Sentinel name returned by {@link activeBreakpointFor} ONLY when no
|
|
455
492
|
* breakpoints are registered at all (bundle without rnwind-transformed
|
|
@@ -531,6 +568,7 @@ function __resetLookupCssState() {
|
|
|
531
568
|
for (const key of Object.keys(cache.breakpoints))
|
|
532
569
|
delete cache.breakpoints[key];
|
|
533
570
|
cache.breakpointList = [];
|
|
571
|
+
cache.themeTokens = {};
|
|
534
572
|
windowHeightProvider = null;
|
|
535
573
|
schemeLoader = null;
|
|
536
574
|
WARNED_MISSING_INSETS = false;
|
|
@@ -541,12 +579,15 @@ function __resetLookupCssState() {
|
|
|
541
579
|
exports.BASE_BREAKPOINT = BASE_BREAKPOINT;
|
|
542
580
|
exports.__resetLookupCssState = __resetLookupCssState;
|
|
543
581
|
exports.activeBreakpointFor = activeBreakpointFor;
|
|
582
|
+
exports.breakpointTier = breakpointTier;
|
|
544
583
|
exports.getBreakpoints = getBreakpoints;
|
|
545
584
|
exports.getStyleVersion = getStyleVersion;
|
|
585
|
+
exports.getThemeTokens = getThemeTokens;
|
|
546
586
|
exports.loadScheme = loadScheme;
|
|
547
587
|
exports.lookupCss = lookupCss;
|
|
548
588
|
exports.registerAtoms = registerAtoms;
|
|
549
589
|
exports.registerBreakpoints = registerBreakpoints;
|
|
550
590
|
exports.registerSchemeLoader = registerSchemeLoader;
|
|
591
|
+
exports.registerThemeTokens = registerThemeTokens;
|
|
551
592
|
exports.setWindowHeightProvider = setWindowHeightProvider;
|
|
552
593
|
//# sourceMappingURL=lookup-css.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup-css.cjs","sources":["../../../../src/runtime/lookup-css.ts"],"sourcesContent":["/**\n * Runtime resolver for rnwind-transformed files.\n *\n * Hot path is ONE WeakMap.get + cached-array return for stable atoms\n * (no `active:`/`focus:`/`*-safe` variance beyond what the cache key\n * captures). First call per (hoist, scheme, stateIndex) walks the\n * atoms once, looks each up as\n *\n * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common?.[atom]`\n *\n * and caches the result. `registerAtoms(scheme, record)` bumps a\n * version counter; the next lookup notices the mismatch and rebuilds.\n *\n * Keyframes are inlined directly into atom values via `animationName`\n * at build time — no separate registry.\n */\n\nimport type { RnwindState } from './components/rnwind-provider'\n\n/** Empty sentinel returned when the input is null / undefined / empty. */\nconst EMPTY_STYLES: readonly unknown[] = []\n\n/** Registry key for the always-loaded fallback scheme. */\nconst COMMON_SCHEME = 'common'\n\n/** Atom name prefix marking a press-state-gated atom. */\nconst ACTIVE_PREFIX = 'active:'\n\n/** Atom name prefix marking a focus-state-gated atom. */\nconst FOCUS_PREFIX = 'focus:'\n\n/** Partial record — missing keys resolve to undefined, which the fallback handles. */\ntype SchemeAtomsRecord = Partial<Record<string, unknown>>\n\n/** 0 = idle, 1 = active, 2 = focus, 3 = both. */\ntype StateIndex = 0 | 1 | 2 | 3\n\n/**\n * One entry in the sorted-by-threshold breakpoints array. The runtime\n * derives an atom's threshold by matching its `<prefix>:` against\n * `name`; the array form is preferred over a Map so the hot-path\n * `tierFor(width)` walk is a tight numeric loop.\n */\ninterface BreakpointEntry {\n readonly name: string\n readonly minWidth: number\n}\n\n/**\n * Process-global style cache. Replaced key-by-key by {@link registerAtoms}.\n * Plain record-of-records: `scheme → atom → style`. Active scheme\n * lookup is `cache.atoms[scheme]?.[atom]` — two property reads with\n * an `?? cache.atoms.common[atom]` fallback. No loops over the\n * registry, ever.\n *\n * `breakpoints` mirrors the build-time table the manifest module\n * registers via {@link registerBreakpoints} — `name → px-threshold` for\n * fast prefix-based atom filtering plus the sorted-by-threshold list\n * for cheap tier-index computation in `lookupCss`.\n */\nconst cache = {\n atoms: Object.create(null) as Partial<Record<string, SchemeAtomsRecord>>,\n breakpoints: Object.create(null) as Partial<Record<string, number>>,\n breakpointList: [] as readonly BreakpointEntry[],\n}\n\n/**\n * Bumps on every {@link registerAtoms} call. {@link HoistCache} entries\n * stamp themselves with the current version; a mismatch on read\n * triggers a rebuild so HMR-reloaded atoms propagate without manual\n * invalidation.\n */\nlet atomVersion = 0\n\n/** Optional window-height provider for the `screen-minus-y` marker. */\ntype WindowHeightProvider = () => number\nlet windowHeightProvider: WindowHeightProvider | null = null\n\n/**\n * Optional scheme loader. Registered by the generated manifest module\n * (`rnwind/__generated/schemes`) once at import time. SchemeProvider\n * calls it synchronously on every render with the active scheme name;\n * first call per scheme pulls the scheme's style module in via an\n * inline `require()` — subsequent calls are a no-op through Metro's\n * module cache.\n */\ntype SchemeLoader = (scheme: string) => void\nlet schemeLoader: SchemeLoader | null = null\n\n/** Module-scope flag so the missing-insets warning fires at most once. */\nlet WARNED_MISSING_INSETS = false\n\n/** Atoms we've already dev-warned about — keeps the noise to ONE line per typo per session. */\nconst WARNED_UNKNOWN_ATOMS = new Set<string>()\n\n/**\n * Compute the state-array index from the live interactState. Bit-or\n * encoding: 0 = idle, 1 = active, 2 = focus, 3 = both.\n * @param interactState Snapshot from `useInteract()` (or undefined).\n * @returns 0 / 1 / 2 / 3.\n */\nfunction stateIndexFor(interactState: InteractState | undefined): StateIndex {\n if (!interactState) return 0\n return (((interactState.active ? 1 : 0) | (interactState.focus ? 2 : 0)) as StateIndex)\n}\n\n/**\n * Fetch the px inset for one side. Falls back to 0 when insets is undefined.\n * @param side Compact side tag (`t` / `r` / `b` / `l`).\n * @param insets Active insets.\n * @returns Px value for that side.\n */\nfunction insetOf(side: string, insets: LookupInsets | undefined): number {\n if (!insets) return 0\n if (side === 't') return insets.top\n if (side === 'r') return insets.right\n if (side === 'b') return insets.bottom\n if (side === 'l') return insets.left\n return 0\n}\n\n/**\n * Collapse one safe-area marker into a concrete px number using the\n * active insets.\n * @param spec Marker spec tuple `[cssKey, sideTag, or, offset]`.\n * @param insets Active insets (or undefined → 0).\n * @returns Resolved px number.\n */\nfunction resolveMarker(spec: SafeMarkerSpec, insets: LookupInsets | undefined): number {\n const [, side, or_, offset] = spec\n if (side === 'screen-minus-y') {\n const h = windowHeightProvider ? windowHeightProvider() : 0\n return Math.max(0, h - insetOf('t', insets) - insetOf('b', insets))\n }\n let base = insetOf(side, insets)\n if (or_ !== undefined) base = Math.max(base, or_)\n if (offset !== undefined) base += offset\n return base\n}\n\n/**\n * Emit a one-shot dev warning when a safe-area atom resolves without\n * real insets in scope.\n * @param insets Insets received by the resolver.\n */\nfunction warnMissingInsetsOnce(insets: LookupInsets | undefined): void {\n if (WARNED_MISSING_INSETS) return\n const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__\n if (!isDevelopment) return\n if (insets && (insets.top !== 0 || insets.right !== 0 || insets.bottom !== 0 || insets.left !== 0)) return\n WARNED_MISSING_INSETS = true\n // eslint-disable-next-line no-console\n console.warn(\n 'rnwind: a `*-safe` utility resolved with zero insets. Wire `insets` on <SchemeProvider> ' +\n '(e.g. `insets={useSafeAreaInsets()}` from react-native-safe-area-context).',\n )\n}\n\n/**\n * Resolve precomputed safe-area marker specs into a fresh RN style\n * object. Cannot be cached — insets vary per render with rotation /\n * keyboard.\n * @param specs Array of spec tuples.\n * @param insets Live safe-area insets.\n * @returns Fresh RN style object with concrete numbers.\n */\nfunction resolveSafe(specs: readonly SafeMarkerSpec[], insets: LookupInsets | undefined): Record<string, number> {\n warnMissingInsetsOnce(insets)\n const out: Record<string, number> = {}\n for (const spec of specs) out[spec[0]] = resolveMarker(spec, insets)\n return out\n}\n\n/**\n * Multiply `fontSize` / `lineHeight` in a resolved atom value by the\n * active font scale. Early-returns the original reference for any atom\n * that doesn't carry either property (most of them) — zero allocation\n * on the hot path for non-text atoms.\n * @param value Atom value as registered in the global table.\n * @param fontScale Multiplier from `useWindowDimensions().fontScale`.\n * @returns Scaled style object, or the original when no scaling applied.\n */\nfunction applyFontScale(value: unknown, fontScale: number): unknown {\n if (fontScale === 1) return value\n if (typeof value !== 'object' || value === null) return value\n const record = value as Record<string, unknown>\n const fs = record.fontSize\n const lh = record.lineHeight\n if (typeof fs !== 'number' && typeof lh !== 'number') return value\n const scaled: Record<string, unknown> = { ...record }\n if (typeof fs === 'number') scaled.fontSize = fs * fontScale\n if (typeof lh === 'number') scaled.lineHeight = lh * fontScale\n return scaled\n}\n\n/**\n * Read the precomputed safe-area marker spec list off an atom value.\n * Build-side `envelopeSafeMarkers` wraps safe atoms in\n * `{__safeStyle: [...]}`; this is a single property access.\n * @param value Atom value as registered in the global table.\n * @returns Spec array when the atom is safe-area, else null.\n */\nfunction readSafeSpecs(value: unknown): readonly SafeMarkerSpec[] | null {\n if (typeof value !== 'object' || value === null) return null\n const safe = (value as { __safeStyle?: readonly SafeMarkerSpec[] }).__safeStyle\n return safe ?? null\n}\n\n/**\n * Per-atom lookup. Two property reads: scheme's own table then the\n * common fallback. Returns `undefined` for unknown atoms — the caller\n * skips them.\n * @param scheme Active scheme.\n * @param atom Atom name.\n * @returns Resolved value, or undefined.\n */\nfunction lookupAtom(scheme: string, atom: string): unknown {\n const schemeTable = cache.atoms[scheme]\n if (schemeTable !== undefined) {\n const own = schemeTable[atom]\n if (own !== undefined) return own\n }\n const common = cache.atoms[COMMON_SCHEME]\n return common === undefined ? undefined : common[atom]\n}\n\n/**\n * Whether an atom should participate in a given interact-state index.\n * - idle (0): no `active:` / `focus:` atoms.\n * - active (1): base + `active:`.\n * - focus (2): base + `focus:`.\n * - both (3): base + `active:` + `focus:`.\n * @param atom Atom name.\n * @param stateIndex Encoded state (0/1/2/3).\n * @returns True when the atom should be emitted for this state.\n */\nfunction atomMatchesState(atom: string, stateIndex: StateIndex): boolean {\n // Cheap prefix check — check the first code point before the full\n // `startsWith` so we skip it for any atom whose first letter isn't\n // `a` / `f`.\n const code = atom.codePointAt(0)\n if (code === 97 /* a */ && atom.startsWith(ACTIVE_PREFIX)) return (stateIndex & 1) !== 0\n if (code === 102 /* f */ && atom.startsWith(FOCUS_PREFIX)) return (stateIndex & 2) !== 0\n return true\n}\n\n/**\n * Whether an atom passes the responsive-breakpoint gate for the\n * current `windowWidth`. Atoms without a registered `<prefix>:` are\n * always-on (the common case — `bg-red-500`, `active:bg-blue-700`).\n * Atoms whose first prefix matches a registered breakpoint name pass\n * only when `windowWidth >= threshold`.\n * @param atom Atom name.\n * @param windowWidth Live `useWindowDimensions().width` snapshot.\n * @returns True when the atom should be emitted for this width.\n */\nfunction atomMatchesBreakpoint(atom: string, windowWidth: number): boolean {\n const colon = atom.indexOf(':')\n if (colon === -1) return true\n const prefix = atom.slice(0, colon)\n const threshold = cache.breakpoints[prefix]\n if (threshold === undefined) return true\n return windowWidth >= threshold\n}\n\n/**\n * Tier index — count of registered breakpoints whose threshold is\n * `<= windowWidth`. Bounded by the breakpoint count, so it's a stable\n * cache-key dimension instead of the unbounded raw width. Crossings\n * happen ~5 times across the device-width spectrum, not per-pixel.\n * @param windowWidth Live width.\n * @returns Tier 0..N where N = `cache.breakpointList.length`.\n */\nfunction tierFor(windowWidth: number): number {\n let tier = 0\n for (const entry of cache.breakpointList) {\n if (windowWidth >= entry.minWidth) tier += 1\n else break\n }\n return tier\n}\n\n/**\n * Build the style array for a (hoist, scheme, state, width) tuple.\n * Walks the atom list, applies the interact-state and breakpoint\n * filters, resolves each atom via scheme→common fallback, and\n * envelopes safe values via {@link resolveSafe}.\n * @param atoms Atom name list (build-time constant).\n * @param scheme Active scheme.\n * @param stateIndex Encoded active/focus state.\n * @param insets Live safe-area insets.\n * @param fontScale Font scale multiplier.\n * @param windowWidth Live window width — gates `md:*` / `lg:*` atoms.\n * @returns Fresh style array.\n */\nfunction buildStyleArray(\n atoms: readonly string[],\n scheme: string,\n stateIndex: StateIndex,\n insets: LookupInsets | undefined,\n fontScale: number,\n windowWidth: number,\n): readonly unknown[] {\n const out: unknown[] = []\n for (const atom of atoms) {\n if (!atomMatchesState(atom, stateIndex)) continue\n if (!atomMatchesBreakpoint(atom, windowWidth)) continue\n const value = lookupAtom(scheme, atom)\n if (value === undefined) {\n warnUnknownAtomOnce(atom)\n continue\n }\n const safe = readSafeSpecs(value)\n const resolved = safe === null ? value : resolveSafe(safe, insets)\n out.push(applyFontScale(resolved, fontScale))\n }\n return out\n}\n\n/**\n * Emit a one-shot dev warning when an atom name doesn't resolve in the\n * registry. The two real causes are a typo (`bg-red-501`) or a class\n * the build-time scanner never saw because it lives in a string the\n * oxide tokeniser can't see (e.g. computed at runtime). Either way, a\n * silent empty style is the worst possible UX — surface it.\n *\n * Filters cosmetic non-issues: empty strings, build-time `__safeStyle`\n * envelopes that wandered in, etc.\n * @param atom Class name that didn't resolve.\n */\nfunction warnUnknownAtomOnce(atom: string): void {\n if (atom.length === 0) return\n const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__\n if (!isDevelopment) return\n if (WARNED_UNKNOWN_ATOMS.has(atom)) return\n WARNED_UNKNOWN_ATOMS.add(atom)\n // eslint-disable-next-line no-console\n console.warn(\n `rnwind: unknown class \"${atom}\" — typo, or the class is built dynamically and the build-time ` +\n `scanner never saw it. Static literals + ternaries are scanned automatically; runtime-built ` +\n `strings need to appear somewhere as a literal so oxide can pick them up.`,\n )\n}\n\n/**\n * Per-hoist cache entry. `version` stamps `atomVersion` at build time\n * so HMR reloads (which bump the counter) invalidate cleanly on next\n * read. `hasSafe` prevents caching results whose values depend on\n * per-render insets. `byKey` maps `\"${scheme}|${stateIndex}\"` to the\n * cached result.\n */\ninterface HoistCache {\n version: number\n hasSafe: boolean\n byKey: Partial<Record<string, readonly unknown[]>>\n}\n\n/**\n * Per-atom-list cache keyed on the hoist reference. WeakMap so\n * hoists GC with their host module on HMR.\n */\nconst resultCache = new WeakMap<readonly string[], HoistCache>()\n\n/**\n * Walk the atom list once to detect safe-area atoms — results that\n * vary per render with `insets`. When any atom envelopes safe specs\n * we skip the cache and rebuild every call.\n * @param atoms Hoist atom list.\n * @param scheme Active scheme.\n * @returns Whether the hoist resolves a safe atom under this scheme.\n */\nfunction detectHasSafe(atoms: readonly string[], scheme: string): boolean {\n for (const atom of atoms) {\n const value = lookupAtom(scheme, atom)\n if (readSafeSpecs(value) !== null) return true\n }\n return false\n}\n\n/**\n * Cache-keyed resolution for the common static-schema case. Returns a\n * stable array reference across renders until `atomVersion` bumps.\n * For hoists containing safe atoms — which depend on per-render\n * insets — rebuilds every call.\n *\n * The `tier` dimension keeps the cache bounded under responsive\n * variants: instead of keying on raw `windowWidth` (which would explode\n * the cache to one entry per pixel), we key on the count of registered\n * breakpoints whose threshold is reached. That gives at most\n * `breakpointCount + 1` cache rows per (scheme, state, fontScale).\n * @param atoms Hoist atom list.\n * @param scheme Active scheme.\n * @param stateIndex Encoded interact state.\n * @param insets Live safe-area insets.\n * @param fontScale Font scale multiplier.\n * @param windowWidth Live window width.\n * @returns Style array.\n */\nfunction lookupCached(\n atoms: readonly string[],\n scheme: string,\n stateIndex: StateIndex,\n insets: LookupInsets | undefined,\n fontScale: number,\n windowWidth: number,\n): readonly unknown[] {\n let entry = resultCache.get(atoms)\n if (entry?.version !== atomVersion) {\n entry = { version: atomVersion, hasSafe: detectHasSafe(atoms, scheme), byKey: Object.create(null) }\n resultCache.set(atoms, entry)\n }\n if (entry.hasSafe) return buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth)\n const tier = tierFor(windowWidth)\n const key = `${scheme}|${stateIndex}|${fontScale}|${tier}`\n const cached = entry.byKey[key]\n if (cached !== undefined) return cached\n const fresh = buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth)\n entry.byKey[key] = fresh\n return fresh\n}\n\n/**\n * Per-render snapshot of which interactive states (active, focus) are\n * currently engaged. Forwarded from the `useInteract()` hook the\n * transformer injects.\n */\nexport interface InteractState {\n active?: boolean\n focus?: boolean\n}\n\n/**\n * Safe-area insets bundle the transformer passes to `lookupCss` when a\n * file uses any `*-safe` utility.\n */\nexport interface LookupInsets {\n top: number\n right: number\n bottom: number\n left: number\n}\n\n\n/**\n * Precomputed safe-area marker spec emitted by the build-side\n * `envelopeSafeMarkers`. Tuple form: `[cssKey, sideTag, or, offset]`.\n */\nexport type SafeMarkerSpec = readonly [string, string, number | undefined, number | undefined]\n\n/** Type alias: the atom-list build output the transformer emits. */\nexport type HoistedClassName = readonly string[]\n\n/**\n * Register a window-height provider used by the `screen-minus-y`\n * safe-area variant. When not wired, `h-screen-safe` resolves to `0`.\n * @param provider Callback returning the current window height in px.\n */\nexport function setWindowHeightProvider(provider: WindowHeightProvider | null): void {\n windowHeightProvider = provider\n}\n\n/**\n * Register the scheme-loader function exported by the generated\n * manifest module. Called once at manifest-module evaluation time —\n * subsequent registrations override the previous loader (useful for\n * tests).\n * @param loader Manifest's `ensureSchemeLoaded` function, or null to\n * detach (tests).\n */\nexport function registerSchemeLoader(loader: SchemeLoader | null): void {\n schemeLoader = loader\n}\n\n/**\n * Ensure the given scheme's style module is loaded. Safe to call in\n * render — zero-cost after the first call per scheme thanks to\n * Metro's module cache, and a no-op when no loader is registered\n * (tests, or a bundle without rnwind-transformed sources).\n * @param scheme Active scheme name.\n */\nexport function loadScheme(scheme: string): void {\n if (schemeLoader) schemeLoader(scheme)\n}\n\n/**\n * Register (or re-register) one scheme's atoms in the global registry.\n * Pure property assignment — no iteration, no allocation. The version\n * counter bump invalidates every hoist-level result cache lazily on\n * next read.\n * @param scheme Registry key — `'common'` for the always-loaded\n * fallback, or a variant name (`'dark'`, `'light'`, `'brand'`, ...).\n * @param atoms Plain record keyed by atom name.\n */\nexport function registerAtoms(scheme: string, atoms: Record<string, unknown>): void {\n cache.atoms[scheme] = atoms\n atomVersion += 1\n}\n\n/**\n * Current registry version — bumps on every `registerAtoms` /\n * `registerBreakpoints`. The molecule resolver folds it into its cache\n * key so an HMR atom reload invalidates derived results.\n * @returns Monotonic version counter.\n */\nexport function getStyleVersion(): number {\n return atomVersion\n}\n\n/**\n * Register the responsive-breakpoint table the manifest module emits at\n * load time. Replaces the prior table — calling with `{}` clears it.\n * Bumps `atomVersion` so any cached lookup invalidates on next read,\n * which matters during a theme HMR cycle that adds/removes breakpoints.\n * @param breakpoints Breakpoint name → minimum-width threshold (px).\n */\nexport function registerBreakpoints(breakpoints: Record<string, number>): void {\n const fresh: Partial<Record<string, number>> = Object.create(null)\n const list: BreakpointEntry[] = []\n for (const name of Object.keys(breakpoints)) {\n const minWidth = breakpoints[name]\n if (!Number.isFinite(minWidth) || minWidth <= 0) continue\n fresh[name] = minWidth\n list.push({ name, minWidth })\n }\n list.sort((a, b) => a.minWidth - b.minWidth || a.name.localeCompare(b.name))\n cache.breakpoints = fresh\n cache.breakpointList = list\n atomVersion += 1\n}\n\n/**\n * Snapshot of the registered breakpoints, for callers that want to\n * compute their own derivations (e.g. the provider deriving the active\n * breakpoint name). Returns a fresh array — callers can iterate without\n * worrying about concurrent mutation from a manifest reload.\n * @returns Breakpoints sorted by ascending min-width threshold.\n */\nexport function getBreakpoints(): readonly BreakpointEntry[] {\n return cache.breakpointList\n}\n\n/**\n * Sentinel name returned by {@link activeBreakpointFor} ONLY when no\n * breakpoints are registered at all (bundle without rnwind-transformed\n * sources, fresh test setup). When at least one breakpoint is\n * registered, the function falls back to the smallest registered name\n * instead — so phone-width devices (402 dp on a stock iPhone, well\n * below `sm = 640`) report `activeBreakpoint === 'sm'` rather than the\n * abstract `'base'`. This matches the user expectation that the value\n * is always a real Tailwind breakpoint label they can branch on.\n *\n * Note: this is decoupled from the className filter. `sm:*` atoms\n * still only fire at `windowWidth >= 640` per Tailwind's mobile-first\n * spec — `activeBreakpoint === 'sm'` at 402 means \"I'm in the smallest\n * tier\", not \"`sm:` classes are firing\".\n */\nexport const BASE_BREAKPOINT = 'base'\n\n/**\n * Resolve the currently-active breakpoint name for a width:\n * - `windowWidth >= some threshold` → the highest matching breakpoint name.\n * - below every registered threshold → the smallest registered name.\n * - no breakpoints registered → {@link BASE_BREAKPOINT}.\n * Always returns a string so consumers can branch on it without\n * null-handling.\n * @param windowWidth Live window width in px.\n * @returns Active breakpoint name (never null).\n */\nexport function activeBreakpointFor(windowWidth: number): string {\n const list = cache.breakpointList\n if (list.length === 0) return BASE_BREAKPOINT\n let active: string = list[0]!.name\n for (const entry of list) {\n if (windowWidth >= entry.minWidth) active = entry.name\n else break\n }\n return active\n}\n\n/**\n * Resolve a className input against the active rnwind context. Hot\n * path:\n * - Array input (build hoist): ONE WeakMap.get + ONE record-access\n * + cached array return. No per-render allocation when there's no\n * userStyle and the hoist has no safe atoms.\n * - String input (dynamic `className={expr}`): tokenise + walk.\n * @param input Hoisted atom list or raw className string.\n * @param ctx Rnwind context — `{scheme, fontScale, insets}` (extra\n * fields ignored). Pass the result of `useRnwind()` directly.\n * @param userStyle Optional caller-supplied style appended last.\n * @param interactState Live active/focus flags from `useInteract()`.\n * @returns Style array for React Native's `style` prop.\n */\nexport function lookupCss(\n input: HoistedClassName | string | null | undefined,\n ctx: RnwindState,\n userStyle?: unknown,\n interactState?: InteractState,\n): readonly unknown[] {\n if (input === null || input === undefined) {\n return userStyle === undefined || userStyle === null ? EMPTY_STYLES : [userStyle]\n }\n const { scheme, insets, fontScale, windowWidth } = ctx\n if (typeof input === 'string') {\n const trimmed = input.trim()\n if (trimmed.length === 0) {\n return userStyle === undefined || userStyle === null ? EMPTY_STYLES : [userStyle]\n }\n const atoms = trimmed.split(/\\s+/)\n const out = buildStyleArray(atoms, scheme, stateIndexFor(interactState), insets, fontScale, windowWidth)\n if (userStyle === undefined || userStyle === null) return out\n return [...out, userStyle]\n }\n const base = lookupCached(input, scheme, stateIndexFor(interactState), insets, fontScale, windowWidth)\n if (userStyle === undefined || userStyle === null) return base\n return [...base, userStyle]\n}\n\n/** Test-only — clear the global registry between suites. */\nexport function __resetLookupCssState(): void {\n for (const key of Object.keys(cache.atoms)) delete cache.atoms[key]\n for (const key of Object.keys(cache.breakpoints)) delete cache.breakpoints[key]\n cache.breakpointList = []\n windowHeightProvider = null\n schemeLoader = null\n WARNED_MISSING_INSETS = false\n WARNED_UNKNOWN_ATOMS.clear()\n atomVersion += 1\n}\n\n/**\n * Test-only sugar: accept a single-scheme record and register it as the\n * `common` table.\n * @param record Atom name → value record (registered under `common`).\n */\nexport function __registerAtomsFromRecord(record: Record<string, unknown>): void {\n registerAtoms(COMMON_SCHEME, record)\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;AAeG;AAIH;AACA,MAAM,YAAY,GAAuB,EAAE;AAE3C;AACA,MAAM,aAAa,GAAG,QAAQ;AAE9B;AACA,MAAM,aAAa,GAAG,SAAS;AAE/B;AACA,MAAM,YAAY,GAAG,QAAQ;AAmB7B;;;;;;;;;;;AAWG;AACH,MAAM,KAAK,GAAG;AACZ,IAAA,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAA+C;AACxE,IAAA,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAoC;AACnE,IAAA,cAAc,EAAE,EAAgC;CACjD;AAED;;;;;AAKG;AACH,IAAI,WAAW,GAAG,CAAC;AAInB,IAAI,oBAAoB,GAAgC,IAAI;AAW5D,IAAI,YAAY,GAAwB,IAAI;AAE5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,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC;AACxG,QAAA,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI;AAAE,YAAA,OAAO,GAAG;AAC7D,QAAA,OAAO,CAAC,GAAG,GAAG,EAAE,SAAS,CAAC;IAC5B;AACA,IAAA,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC;AACtG,IAAA,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;AAC9D,IAAA,OAAO,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC;AAC7B;AAEA;SACgB,qBAAqB,GAAA;IACnC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IACnE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC;AAC/E,IAAA,KAAK,CAAC,cAAc,GAAG,EAAE;IACzB,oBAAoB,GAAG,IAAI;IAC3B,YAAY,GAAG,IAAI;IACnB,qBAAqB,GAAG,KAAK;IAC7B,oBAAoB,CAAC,KAAK,EAAE;IAC5B,WAAW,IAAI,CAAC;AAClB;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"lookup-css.cjs","sources":["../../../../src/runtime/lookup-css.ts"],"sourcesContent":["/**\n * Runtime resolver for rnwind-transformed files.\n *\n * Hot path is ONE WeakMap.get + cached-array return for stable atoms\n * (no `active:`/`focus:`/`*-safe` variance beyond what the cache key\n * captures). First call per (hoist, scheme, stateIndex) walks the\n * atoms once, looks each up as\n *\n * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common?.[atom]`\n *\n * and caches the result. `registerAtoms(scheme, record)` bumps a\n * version counter; the next lookup notices the mismatch and rebuilds.\n *\n * Keyframes are inlined directly into atom values via `animationName`\n * at build time — no separate registry.\n */\n\nimport type { RnwindState } from './components/rnwind-provider'\nimport type { ThemeTables } from '../core/types'\n\n/** Empty sentinel returned when the input is null / undefined / empty. */\nconst EMPTY_STYLES: readonly unknown[] = []\n\n/** Registry key for the always-loaded fallback scheme. */\nconst COMMON_SCHEME = 'common'\n\n/** Atom name prefix marking a press-state-gated atom. */\nconst ACTIVE_PREFIX = 'active:'\n\n/** Atom name prefix marking a focus-state-gated atom. */\nconst FOCUS_PREFIX = 'focus:'\n\n/** Partial record — missing keys resolve to undefined, which the fallback handles. */\ntype SchemeAtomsRecord = Partial<Record<string, unknown>>\n\n/** 0 = idle, 1 = active, 2 = focus, 3 = both. */\ntype StateIndex = 0 | 1 | 2 | 3\n\n/**\n * One entry in the sorted-by-threshold breakpoints array. The runtime\n * derives an atom's threshold by matching its `<prefix>:` against\n * `name`; the array form is preferred over a Map so the hot-path\n * `tierFor(width)` walk is a tight numeric loop.\n */\ninterface BreakpointEntry {\n readonly name: string\n readonly minWidth: number\n}\n\n/**\n * Process-global style cache. Replaced key-by-key by {@link registerAtoms}.\n * Plain record-of-records: `scheme → atom → style`. Active scheme\n * lookup is `cache.atoms[scheme]?.[atom]` — two property reads with\n * an `?? cache.atoms.common[atom]` fallback. No loops over the\n * registry, ever.\n *\n * `breakpoints` mirrors the build-time table the manifest module\n * registers via {@link registerBreakpoints} — `name → px-threshold` for\n * fast prefix-based atom filtering plus the sorted-by-threshold list\n * for cheap tier-index computation in `lookupCss`.\n */\nconst cache = {\n atoms: Object.create(null) as Partial<Record<string, SchemeAtomsRecord>>,\n breakpoints: Object.create(null) as Partial<Record<string, number>>,\n breakpointList: [] as readonly BreakpointEntry[],\n /** Per-scheme theme token tables (`--color-*`, `--spacing-*`, …) the manifest registers for `useColor` / `useToken` / `useSize`. */\n themeTokens: {} as ThemeTables,\n}\n\n/**\n * Bumps on every {@link registerAtoms} call. {@link HoistCache} entries\n * stamp themselves with the current version; a mismatch on read\n * triggers a rebuild so HMR-reloaded atoms propagate without manual\n * invalidation.\n */\nlet atomVersion = 0\n\n/** Optional window-height provider for the `screen-minus-y` marker. */\ntype WindowHeightProvider = () => number\nlet windowHeightProvider: WindowHeightProvider | null = null\n\n/**\n * Optional scheme loader. Registered by the generated manifest module\n * (`rnwind/__generated/schemes`) once at import time. SchemeProvider\n * calls it synchronously on every render with the active scheme name;\n * first call per scheme pulls the scheme's style module in via an\n * inline `require()` — subsequent calls are a no-op through Metro's\n * module cache.\n */\ntype SchemeLoader = (scheme: string) => void\nlet schemeLoader: SchemeLoader | null = null\n\n/** Module-scope flag so the missing-insets warning fires at most once. */\nlet WARNED_MISSING_INSETS = false\n\n/** Atoms we've already dev-warned about — keeps the noise to ONE line per typo per session. */\nconst WARNED_UNKNOWN_ATOMS = new Set<string>()\n\n/**\n * Compute the state-array index from the live interactState. Bit-or\n * encoding: 0 = idle, 1 = active, 2 = focus, 3 = both.\n * @param interactState Snapshot from `useInteract()` (or undefined).\n * @returns 0 / 1 / 2 / 3.\n */\nfunction stateIndexFor(interactState: InteractState | undefined): StateIndex {\n if (!interactState) return 0\n return (((interactState.active ? 1 : 0) | (interactState.focus ? 2 : 0)) as StateIndex)\n}\n\n/**\n * Fetch the px inset for one side. Falls back to 0 when insets is undefined.\n * @param side Compact side tag (`t` / `r` / `b` / `l`).\n * @param insets Active insets.\n * @returns Px value for that side.\n */\nfunction insetOf(side: string, insets: LookupInsets | undefined): number {\n if (!insets) return 0\n if (side === 't') return insets.top\n if (side === 'r') return insets.right\n if (side === 'b') return insets.bottom\n if (side === 'l') return insets.left\n return 0\n}\n\n/**\n * Collapse one safe-area marker into a concrete px number using the\n * active insets.\n * @param spec Marker spec tuple `[cssKey, sideTag, or, offset]`.\n * @param insets Active insets (or undefined → 0).\n * @returns Resolved px number.\n */\nfunction resolveMarker(spec: SafeMarkerSpec, insets: LookupInsets | undefined): number {\n const [, side, or_, offset] = spec\n if (side === 'screen-minus-y') {\n const h = windowHeightProvider ? windowHeightProvider() : 0\n return Math.max(0, h - insetOf('t', insets) - insetOf('b', insets))\n }\n let base = insetOf(side, insets)\n if (or_ !== undefined) base = Math.max(base, or_)\n if (offset !== undefined) base += offset\n return base\n}\n\n/**\n * Emit a one-shot dev warning when a safe-area atom resolves without\n * real insets in scope.\n * @param insets Insets received by the resolver.\n */\nfunction warnMissingInsetsOnce(insets: LookupInsets | undefined): void {\n if (WARNED_MISSING_INSETS) return\n const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__\n if (!isDevelopment) return\n if (insets && (insets.top !== 0 || insets.right !== 0 || insets.bottom !== 0 || insets.left !== 0)) return\n WARNED_MISSING_INSETS = true\n // eslint-disable-next-line no-console\n console.warn(\n 'rnwind: a `*-safe` utility resolved with zero insets. Wire `insets` on <SchemeProvider> ' +\n '(e.g. `insets={useSafeAreaInsets()}` from react-native-safe-area-context).',\n )\n}\n\n/**\n * Resolve precomputed safe-area marker specs into a fresh RN style\n * object. Cannot be cached — insets vary per render with rotation /\n * keyboard.\n * @param specs Array of spec tuples.\n * @param insets Live safe-area insets.\n * @returns Fresh RN style object with concrete numbers.\n */\nfunction resolveSafe(specs: readonly SafeMarkerSpec[], insets: LookupInsets | undefined): Record<string, number> {\n warnMissingInsetsOnce(insets)\n const out: Record<string, number> = {}\n for (const spec of specs) out[spec[0]] = resolveMarker(spec, insets)\n return out\n}\n\n/**\n * Multiply `fontSize` / `lineHeight` in a resolved atom value by the\n * active font scale. Early-returns the original reference for any atom\n * that doesn't carry either property (most of them) — zero allocation\n * on the hot path for non-text atoms.\n * @param value Atom value as registered in the global table.\n * @param fontScale Multiplier from `useWindowDimensions().fontScale`.\n * @returns Scaled style object, or the original when no scaling applied.\n */\nfunction applyFontScale(value: unknown, fontScale: number): unknown {\n if (fontScale === 1) return value\n if (typeof value !== 'object' || value === null) return value\n const record = value as Record<string, unknown>\n const fs = record.fontSize\n const lh = record.lineHeight\n if (typeof fs !== 'number' && typeof lh !== 'number') return value\n const scaled: Record<string, unknown> = { ...record }\n if (typeof fs === 'number') scaled.fontSize = fs * fontScale\n if (typeof lh === 'number') scaled.lineHeight = lh * fontScale\n return scaled\n}\n\n/**\n * Read the precomputed safe-area marker spec list off an atom value.\n * Build-side `envelopeSafeMarkers` wraps safe atoms in\n * `{__safeStyle: [...]}`; this is a single property access.\n * @param value Atom value as registered in the global table.\n * @returns Spec array when the atom is safe-area, else null.\n */\nfunction readSafeSpecs(value: unknown): readonly SafeMarkerSpec[] | null {\n if (typeof value !== 'object' || value === null) return null\n const safe = (value as { __safeStyle?: readonly SafeMarkerSpec[] }).__safeStyle\n return safe ?? null\n}\n\n/**\n * Per-atom lookup. Two property reads: scheme's own table then the\n * common fallback. Returns `undefined` for unknown atoms — the caller\n * skips them.\n * @param scheme Active scheme.\n * @param atom Atom name.\n * @returns Resolved value, or undefined.\n */\nfunction lookupAtom(scheme: string, atom: string): unknown {\n const schemeTable = cache.atoms[scheme]\n if (schemeTable !== undefined) {\n const own = schemeTable[atom]\n if (own !== undefined) return own\n }\n const common = cache.atoms[COMMON_SCHEME]\n return common === undefined ? undefined : common[atom]\n}\n\n/**\n * Whether an atom should participate in a given interact-state index.\n * - idle (0): no `active:` / `focus:` atoms.\n * - active (1): base + `active:`.\n * - focus (2): base + `focus:`.\n * - both (3): base + `active:` + `focus:`.\n * @param atom Atom name.\n * @param stateIndex Encoded state (0/1/2/3).\n * @returns True when the atom should be emitted for this state.\n */\nfunction atomMatchesState(atom: string, stateIndex: StateIndex): boolean {\n // Cheap prefix check — check the first code point before the full\n // `startsWith` so we skip it for any atom whose first letter isn't\n // `a` / `f`.\n const code = atom.codePointAt(0)\n if (code === 97 /* a */ && atom.startsWith(ACTIVE_PREFIX)) return (stateIndex & 1) !== 0\n if (code === 102 /* f */ && atom.startsWith(FOCUS_PREFIX)) return (stateIndex & 2) !== 0\n return true\n}\n\n/**\n * Whether an atom passes the responsive-breakpoint gate for the\n * current `windowWidth`. Atoms without a registered `<prefix>:` are\n * always-on (the common case — `bg-red-500`, `active:bg-blue-700`).\n * Atoms whose first prefix matches a registered breakpoint name pass\n * only when `windowWidth >= threshold`.\n * @param atom Atom name.\n * @param windowWidth Live `useWindowDimensions().width` snapshot.\n * @returns True when the atom should be emitted for this width.\n */\nfunction atomMatchesBreakpoint(atom: string, windowWidth: number): boolean {\n const colon = atom.indexOf(':')\n if (colon === -1) return true\n const prefix = atom.slice(0, colon)\n const threshold = cache.breakpoints[prefix]\n if (threshold === undefined) return true\n return windowWidth >= threshold\n}\n\n/**\n * Tier index — count of registered breakpoints whose threshold is\n * `<= windowWidth`. Bounded by the breakpoint count, so it's a stable\n * cache-key dimension instead of the unbounded raw width. Crossings\n * happen ~5 times across the device-width spectrum, not per-pixel.\n * @param windowWidth Live width.\n * @returns Tier 0..N where N = `cache.breakpointList.length`.\n */\nfunction tierFor(windowWidth: number): number {\n let tier = 0\n for (const entry of cache.breakpointList) {\n if (windowWidth >= entry.minWidth) tier += 1\n else break\n }\n return tier\n}\n\n/**\n * Public breakpoint-tier for a width — the count of registered breakpoints\n * whose threshold is reached. Used by the runtime resolver as its width\n * cache dimension: the numeric tier is bounded AND exact, unlike the\n * clamped `activeBreakpoint` NAME (which collapses tier-0 into the smallest\n * breakpoint, so widths straddling that threshold would share a cache key\n * and serve a stale style).\n * @param windowWidth Live window width in px.\n * @returns Tier 0..N.\n */\nexport function breakpointTier(windowWidth: number): number {\n return tierFor(windowWidth)\n}\n\n/**\n * Build the style array for a (hoist, scheme, state, width) tuple.\n * Walks the atom list, applies the interact-state and breakpoint\n * filters, resolves each atom via scheme→common fallback, and\n * envelopes safe values via {@link resolveSafe}.\n * @param atoms Atom name list (build-time constant).\n * @param scheme Active scheme.\n * @param stateIndex Encoded active/focus state.\n * @param insets Live safe-area insets.\n * @param fontScale Font scale multiplier.\n * @param windowWidth Live window width — gates `md:*` / `lg:*` atoms.\n * @returns Fresh style array.\n */\nfunction buildStyleArray(\n atoms: readonly string[],\n scheme: string,\n stateIndex: StateIndex,\n insets: LookupInsets | undefined,\n fontScale: number,\n windowWidth: number,\n): readonly unknown[] {\n const out: unknown[] = []\n for (const atom of atoms) {\n if (!atomMatchesState(atom, stateIndex)) continue\n if (!atomMatchesBreakpoint(atom, windowWidth)) continue\n const value = lookupAtom(scheme, atom)\n if (value === undefined) {\n warnUnknownAtomOnce(atom)\n continue\n }\n const safe = readSafeSpecs(value)\n const resolved = safe === null ? value : resolveSafe(safe, insets)\n out.push(applyFontScale(resolved, fontScale))\n }\n return out\n}\n\n/**\n * Emit a one-shot dev warning when an atom name doesn't resolve in the\n * registry. The two real causes are a typo (`bg-red-501`) or a class\n * the build-time scanner never saw because it lives in a string the\n * oxide tokeniser can't see (e.g. computed at runtime). Either way, a\n * silent empty style is the worst possible UX — surface it.\n *\n * Filters cosmetic non-issues: empty strings, build-time `__safeStyle`\n * envelopes that wandered in, etc.\n * @param atom Class name that didn't resolve.\n */\nfunction warnUnknownAtomOnce(atom: string): void {\n if (atom.length === 0) return\n const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__\n if (!isDevelopment) return\n if (WARNED_UNKNOWN_ATOMS.has(atom)) return\n WARNED_UNKNOWN_ATOMS.add(atom)\n // eslint-disable-next-line no-console\n console.warn(\n `rnwind: unknown class \"${atom}\" — typo, or the class is built dynamically and the build-time ` +\n `scanner never saw it. Static literals + ternaries are scanned automatically; runtime-built ` +\n `strings need to appear somewhere as a literal so oxide can pick them up.`,\n )\n}\n\n/**\n * Per-hoist cache entry. `version` stamps `atomVersion` at build time\n * so HMR reloads (which bump the counter) invalidate cleanly on next\n * read. `hasSafe` prevents caching results whose values depend on\n * per-render insets. `byKey` maps `\"${scheme}|${stateIndex}\"` to the\n * cached result.\n */\ninterface HoistCache {\n version: number\n hasSafe: boolean\n byKey: Partial<Record<string, readonly unknown[]>>\n}\n\n/**\n * Per-atom-list cache keyed on the hoist reference. WeakMap so\n * hoists GC with their host module on HMR.\n */\nconst resultCache = new WeakMap<readonly string[], HoistCache>()\n\n/**\n * Walk the atom list once to detect safe-area atoms — results that\n * vary per render with `insets`. When any atom envelopes safe specs\n * we skip the cache and rebuild every call.\n * @param atoms Hoist atom list.\n * @param scheme Active scheme.\n * @returns Whether the hoist resolves a safe atom under this scheme.\n */\nfunction detectHasSafe(atoms: readonly string[], scheme: string): boolean {\n for (const atom of atoms) {\n const value = lookupAtom(scheme, atom)\n if (readSafeSpecs(value) !== null) return true\n }\n return false\n}\n\n/**\n * Cache-keyed resolution for the common static-schema case. Returns a\n * stable array reference across renders until `atomVersion` bumps.\n * For hoists containing safe atoms — which depend on per-render\n * insets — rebuilds every call.\n *\n * The `tier` dimension keeps the cache bounded under responsive\n * variants: instead of keying on raw `windowWidth` (which would explode\n * the cache to one entry per pixel), we key on the count of registered\n * breakpoints whose threshold is reached. That gives at most\n * `breakpointCount + 1` cache rows per (scheme, state, fontScale).\n * @param atoms Hoist atom list.\n * @param scheme Active scheme.\n * @param stateIndex Encoded interact state.\n * @param insets Live safe-area insets.\n * @param fontScale Font scale multiplier.\n * @param windowWidth Live window width.\n * @returns Style array.\n */\nfunction lookupCached(\n atoms: readonly string[],\n scheme: string,\n stateIndex: StateIndex,\n insets: LookupInsets | undefined,\n fontScale: number,\n windowWidth: number,\n): readonly unknown[] {\n let entry = resultCache.get(atoms)\n if (entry?.version !== atomVersion) {\n entry = { version: atomVersion, hasSafe: detectHasSafe(atoms, scheme), byKey: Object.create(null) }\n resultCache.set(atoms, entry)\n }\n if (entry.hasSafe) return buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth)\n const tier = tierFor(windowWidth)\n const key = `${scheme}|${stateIndex}|${fontScale}|${tier}`\n const cached = entry.byKey[key]\n if (cached !== undefined) return cached\n const fresh = buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth)\n entry.byKey[key] = fresh\n return fresh\n}\n\n/**\n * Per-render snapshot of which interactive states (active, focus) are\n * currently engaged. Forwarded from the `useInteract()` hook the\n * transformer injects.\n */\nexport interface InteractState {\n active?: boolean\n focus?: boolean\n}\n\n/**\n * Safe-area insets bundle the transformer passes to `lookupCss` when a\n * file uses any `*-safe` utility.\n */\nexport interface LookupInsets {\n top: number\n right: number\n bottom: number\n left: number\n}\n\n\n/**\n * Precomputed safe-area marker spec emitted by the build-side\n * `envelopeSafeMarkers`. Tuple form: `[cssKey, sideTag, or, offset]`.\n */\nexport type SafeMarkerSpec = readonly [string, string, number | undefined, number | undefined]\n\n/** Type alias: the atom-list build output the transformer emits. */\nexport type HoistedClassName = readonly string[]\n\n/**\n * Register a window-height provider used by the `screen-minus-y`\n * safe-area variant. When not wired, `h-screen-safe` resolves to `0`.\n * @param provider Callback returning the current window height in px.\n */\nexport function setWindowHeightProvider(provider: WindowHeightProvider | null): void {\n windowHeightProvider = provider\n}\n\n/**\n * Register the scheme-loader function exported by the generated\n * manifest module. Called once at manifest-module evaluation time —\n * subsequent registrations override the previous loader (useful for\n * tests).\n * @param loader Manifest's `ensureSchemeLoaded` function, or null to\n * detach (tests).\n */\nexport function registerSchemeLoader(loader: SchemeLoader | null): void {\n schemeLoader = loader\n}\n\n/**\n * Ensure the given scheme's style module is loaded. Safe to call in\n * render — zero-cost after the first call per scheme thanks to\n * Metro's module cache, and a no-op when no loader is registered\n * (tests, or a bundle without rnwind-transformed sources).\n * @param scheme Active scheme name.\n */\nexport function loadScheme(scheme: string): void {\n if (schemeLoader) schemeLoader(scheme)\n}\n\n/**\n * Register (or re-register) one scheme's atoms in the global registry.\n * Pure property assignment — no iteration, no allocation. The version\n * counter bump invalidates every hoist-level result cache lazily on\n * next read.\n * @param scheme Registry key — `'common'` for the always-loaded\n * fallback, or a variant name (`'dark'`, `'light'`, `'brand'`, ...).\n * @param atoms Plain record keyed by atom name.\n */\nexport function registerAtoms(scheme: string, atoms: Record<string, unknown>): void {\n cache.atoms[scheme] = atoms\n atomVersion += 1\n}\n\n/**\n * Current registry version — bumps on every `registerAtoms` /\n * `registerBreakpoints`. The molecule resolver folds it into its cache\n * key so an HMR atom reload invalidates derived results.\n * @returns Monotonic version counter.\n */\nexport function getStyleVersion(): number {\n return atomVersion\n}\n\n/**\n * Register the responsive-breakpoint table the manifest module emits at\n * load time. Replaces the prior table — calling with `{}` clears it.\n * Bumps `atomVersion` so any cached lookup invalidates on next read,\n * which matters during a theme HMR cycle that adds/removes breakpoints.\n * @param breakpoints Breakpoint name → minimum-width threshold (px).\n */\nexport function registerBreakpoints(breakpoints: Record<string, number>): void {\n const fresh: Partial<Record<string, number>> = Object.create(null)\n const list: BreakpointEntry[] = []\n for (const name of Object.keys(breakpoints)) {\n const minWidth = breakpoints[name]\n if (!Number.isFinite(minWidth) || minWidth <= 0) continue\n fresh[name] = minWidth\n list.push({ name, minWidth })\n }\n list.sort((a, b) => a.minWidth - b.minWidth || a.name.localeCompare(b.name))\n cache.breakpoints = fresh\n cache.breakpointList = list\n atomVersion += 1\n}\n\n/**\n * Snapshot of the registered breakpoints, for callers that want to\n * compute their own derivations (e.g. the provider deriving the active\n * breakpoint name). Returns a fresh array — callers can iterate without\n * worrying about concurrent mutation from a manifest reload.\n * @returns Breakpoints sorted by ascending min-width threshold.\n */\nexport function getBreakpoints(): readonly BreakpointEntry[] {\n return cache.breakpointList\n}\n\n/**\n * Register the per-scheme theme token tables the manifest module emits at\n * load time — the data source for `useColor` / `useToken` / `useSize`. The\n * build lowers `--color-*` tokens to sRGB before registering them, so these\n * are RN-safe. Replaces the prior tables; bumps `atomVersion` so a theme HMR\n * cycle re-resolves. The build registers tokens here so the hooks work out of\n * the box, without the user manually threading a `tables` prop on the provider.\n * @param tables Scheme name → (token name → value) map.\n */\nexport function registerThemeTokens(tables: ThemeTables): void {\n cache.themeTokens = tables\n atomVersion += 1\n}\n\n/**\n * The manifest-registered theme token tables. The provider merges these under\n * any explicit `tables` prop (the prop wins), so `useColor` resolves from the\n * build by default.\n * @returns Registered per-scheme token tables.\n */\nexport function getThemeTokens(): ThemeTables {\n return cache.themeTokens\n}\n\n/**\n * Sentinel name returned by {@link activeBreakpointFor} ONLY when no\n * breakpoints are registered at all (bundle without rnwind-transformed\n * sources, fresh test setup). When at least one breakpoint is\n * registered, the function falls back to the smallest registered name\n * instead — so phone-width devices (402 dp on a stock iPhone, well\n * below `sm = 640`) report `activeBreakpoint === 'sm'` rather than the\n * abstract `'base'`. This matches the user expectation that the value\n * is always a real Tailwind breakpoint label they can branch on.\n *\n * Note: this is decoupled from the className filter. `sm:*` atoms\n * still only fire at `windowWidth >= 640` per Tailwind's mobile-first\n * spec — `activeBreakpoint === 'sm'` at 402 means \"I'm in the smallest\n * tier\", not \"`sm:` classes are firing\".\n */\nexport const BASE_BREAKPOINT = 'base'\n\n/**\n * Resolve the currently-active breakpoint name for a width:\n * - `windowWidth >= some threshold` → the highest matching breakpoint name.\n * - below every registered threshold → the smallest registered name.\n * - no breakpoints registered → {@link BASE_BREAKPOINT}.\n * Always returns a string so consumers can branch on it without\n * null-handling.\n * @param windowWidth Live window width in px.\n * @returns Active breakpoint name (never null).\n */\nexport function activeBreakpointFor(windowWidth: number): string {\n const list = cache.breakpointList\n if (list.length === 0) return BASE_BREAKPOINT\n let active: string = list[0]!.name\n for (const entry of list) {\n if (windowWidth >= entry.minWidth) active = entry.name\n else break\n }\n return active\n}\n\n/**\n * Resolve a className input against the active rnwind context. Hot\n * path:\n * - Array input (build hoist): ONE WeakMap.get + ONE record-access\n * + cached array return. No per-render allocation when there's no\n * userStyle and the hoist has no safe atoms.\n * - String input (dynamic `className={expr}`): tokenise + walk.\n * @param input Hoisted atom list or raw className string.\n * @param ctx Rnwind context — `{scheme, fontScale, insets}` (extra\n * fields ignored). Pass the result of `useRnwind()` directly.\n * @param userStyle Optional caller-supplied style appended last.\n * @param interactState Live active/focus flags from `useInteract()`.\n * @returns Style array for React Native's `style` prop.\n */\nexport function lookupCss(\n input: HoistedClassName | string | null | undefined,\n ctx: RnwindState,\n userStyle?: unknown,\n interactState?: InteractState,\n): readonly unknown[] {\n if (input === null || input === undefined) {\n return userStyle === undefined || userStyle === null ? EMPTY_STYLES : [userStyle]\n }\n const { scheme, insets, fontScale, windowWidth } = ctx\n if (typeof input === 'string') {\n const trimmed = input.trim()\n if (trimmed.length === 0) {\n return userStyle === undefined || userStyle === null ? EMPTY_STYLES : [userStyle]\n }\n const atoms = trimmed.split(/\\s+/)\n const out = buildStyleArray(atoms, scheme, stateIndexFor(interactState), insets, fontScale, windowWidth)\n if (userStyle === undefined || userStyle === null) return out\n return [...out, userStyle]\n }\n const base = lookupCached(input, scheme, stateIndexFor(interactState), insets, fontScale, windowWidth)\n if (userStyle === undefined || userStyle === null) return base\n return [...base, userStyle]\n}\n\n/** Test-only — clear the global registry between suites. */\nexport function __resetLookupCssState(): void {\n for (const key of Object.keys(cache.atoms)) delete cache.atoms[key]\n for (const key of Object.keys(cache.breakpoints)) delete cache.breakpoints[key]\n cache.breakpointList = []\n cache.themeTokens = {}\n windowHeightProvider = null\n schemeLoader = null\n WARNED_MISSING_INSETS = false\n WARNED_UNKNOWN_ATOMS.clear()\n atomVersion += 1\n}\n\n/**\n * Test-only sugar: accept a single-scheme record and register it as the\n * `common` table.\n * @param record Atom name → value record (registered under `common`).\n */\nexport function __registerAtomsFromRecord(record: Record<string, unknown>): void {\n registerAtoms(COMMON_SCHEME, record)\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;AAeG;AAKH;AACA,MAAM,YAAY,GAAuB,EAAE;AAE3C;AACA,MAAM,aAAa,GAAG,QAAQ;AAE9B;AACA,MAAM,aAAa,GAAG,SAAS;AAE/B;AACA,MAAM,YAAY,GAAG,QAAQ;AAmB7B;;;;;;;;;;;AAWG;AACH,MAAM,KAAK,GAAG;AACZ,IAAA,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAA+C;AACxE,IAAA,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAoC;AACnE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C,WAAW,CAAC,GAAG,CAAC;AAC/E,IAAA,KAAK,CAAC,cAAc,GAAG,EAAE;AACzB,IAAA,KAAK,CAAC,WAAW,GAAG,EAAE;IACtB,oBAAoB,GAAG,IAAI;IAC3B,YAAY,GAAG,IAAI;IACnB,qBAAqB,GAAG,KAAK;IAC7B,oBAAoB,CAAC,KAAK,EAAE;IAC5B,WAAW,IAAI,CAAC;AAClB;;;;;;;;;;;;;;;;;"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* at build time — no separate registry.
|
|
16
16
|
*/
|
|
17
17
|
import type { RnwindState } from './components/rnwind-provider';
|
|
18
|
+
import type { ThemeTables } from '../core/types';
|
|
18
19
|
/**
|
|
19
20
|
* One entry in the sorted-by-threshold breakpoints array. The runtime
|
|
20
21
|
* derives an atom's threshold by matching its `<prefix>:` against
|
|
@@ -36,6 +37,17 @@ type WindowHeightProvider = () => number;
|
|
|
36
37
|
* module cache.
|
|
37
38
|
*/
|
|
38
39
|
type SchemeLoader = (scheme: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Public breakpoint-tier for a width — the count of registered breakpoints
|
|
42
|
+
* whose threshold is reached. Used by the runtime resolver as its width
|
|
43
|
+
* cache dimension: the numeric tier is bounded AND exact, unlike the
|
|
44
|
+
* clamped `activeBreakpoint` NAME (which collapses tier-0 into the smallest
|
|
45
|
+
* breakpoint, so widths straddling that threshold would share a cache key
|
|
46
|
+
* and serve a stale style).
|
|
47
|
+
* @param windowWidth Live window width in px.
|
|
48
|
+
* @returns Tier 0..N.
|
|
49
|
+
*/
|
|
50
|
+
export declare function breakpointTier(windowWidth: number): number;
|
|
39
51
|
/**
|
|
40
52
|
* Per-render snapshot of which interactive states (active, focus) are
|
|
41
53
|
* currently engaged. Forwarded from the `useInteract()` hook the
|
|
@@ -118,6 +130,23 @@ export declare function registerBreakpoints(breakpoints: Record<string, number>)
|
|
|
118
130
|
* @returns Breakpoints sorted by ascending min-width threshold.
|
|
119
131
|
*/
|
|
120
132
|
export declare function getBreakpoints(): readonly BreakpointEntry[];
|
|
133
|
+
/**
|
|
134
|
+
* Register the per-scheme theme token tables the manifest module emits at
|
|
135
|
+
* load time — the data source for `useColor` / `useToken` / `useSize`. The
|
|
136
|
+
* build lowers `--color-*` tokens to sRGB before registering them, so these
|
|
137
|
+
* are RN-safe. Replaces the prior tables; bumps `atomVersion` so a theme HMR
|
|
138
|
+
* cycle re-resolves. The build registers tokens here so the hooks work out of
|
|
139
|
+
* the box, without the user manually threading a `tables` prop on the provider.
|
|
140
|
+
* @param tables Scheme name → (token name → value) map.
|
|
141
|
+
*/
|
|
142
|
+
export declare function registerThemeTokens(tables: ThemeTables): void;
|
|
143
|
+
/**
|
|
144
|
+
* The manifest-registered theme token tables. The provider merges these under
|
|
145
|
+
* any explicit `tables` prop (the prop wins), so `useColor` resolves from the
|
|
146
|
+
* build by default.
|
|
147
|
+
* @returns Registered per-scheme token tables.
|
|
148
|
+
*/
|
|
149
|
+
export declare function getThemeTokens(): ThemeTables;
|
|
121
150
|
/**
|
|
122
151
|
* Sentinel name returned by {@link activeBreakpointFor} ONLY when no
|
|
123
152
|
* breakpoints are registered at all (bundle without rnwind-transformed
|
|
@@ -110,17 +110,19 @@ function registerHaptics(map) {
|
|
|
110
110
|
const stateSignatureCache = new WeakMap();
|
|
111
111
|
/**
|
|
112
112
|
* Cache key dimension for the reactive context — everything that can
|
|
113
|
-
* change a resolved style. Uses the breakpoint TIER (
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
113
|
+
* change a resolved style. Uses the numeric breakpoint TIER (count of
|
|
114
|
+
* thresholds reached) from `breakpointTier(windowWidth)`, NOT the
|
|
115
|
+
* `activeBreakpoint` NAME: the name clamps tier-0 into the smallest
|
|
116
|
+
* breakpoint, so widths straddling that threshold (e.g. 320 vs 700 with
|
|
117
|
+
* `sm=640`) would collide on one cache key and serve a stale style. The
|
|
118
|
+
* tier is exact AND bounded — two widths in the same tier gate every
|
|
119
|
+
* `sm:`/`md:`/… atom identically, so they resolve the same.
|
|
118
120
|
* @param state Rnwind context.
|
|
119
121
|
* @returns Compact signature string.
|
|
120
122
|
*/
|
|
121
123
|
function stateSignature(state) {
|
|
122
124
|
const { insets } = state;
|
|
123
|
-
return `${state.scheme}|${insets.top},${insets.right},${insets.bottom},${insets.left}|${state.fontScale}|${state.
|
|
125
|
+
return `${state.scheme}|${insets.top},${insets.right},${insets.bottom},${insets.left}|${state.fontScale}|${lookupCss.breakpointTier(state.windowWidth)}`;
|
|
124
126
|
}
|
|
125
127
|
/**
|
|
126
128
|
* Memoised {@link stateSignature} — one `WeakMap.get` on the hot path
|