react-native-webrtc-kaleidoscope 2.2.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +42 -3
  2. package/android/src/main/java/com/simiancraft/kaleidoscope/gpu/ShadersGenerated.kt +354 -0
  3. package/catalog/shaders/aurora-silk/aurora-silk.form.tsx +35 -0
  4. package/catalog/shaders/aurora-silk/aurora-silk.frag +106 -0
  5. package/catalog/shaders/aurora-silk/aurora-silk.ts +92 -0
  6. package/catalog/shaders/halftone-waves/halftone-waves.form.tsx +35 -0
  7. package/catalog/shaders/halftone-waves/halftone-waves.frag +84 -0
  8. package/catalog/shaders/halftone-waves/halftone-waves.ts +100 -0
  9. package/catalog/shaders/index.ts +16 -0
  10. package/catalog/shaders/kaleidoscope/kaleidoscope.form.tsx +35 -0
  11. package/catalog/shaders/kaleidoscope/kaleidoscope.frag +93 -0
  12. package/catalog/shaders/kaleidoscope/kaleidoscope.ts +81 -0
  13. package/catalog/shaders/neo-memphis/neo-memphis.form.tsx +35 -0
  14. package/catalog/shaders/neo-memphis/neo-memphis.frag +152 -0
  15. package/catalog/shaders/neo-memphis/neo-memphis.ts +84 -0
  16. package/dist/catalog/shaders/aurora-silk/aurora-silk.d.ts +26 -0
  17. package/dist/catalog/shaders/aurora-silk/aurora-silk.d.ts.map +1 -0
  18. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.d.ts +3 -0
  19. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.d.ts.map +1 -0
  20. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.js +13 -0
  21. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.js.map +1 -0
  22. package/dist/catalog/shaders/aurora-silk/aurora-silk.js +70 -0
  23. package/dist/catalog/shaders/aurora-silk/aurora-silk.js.map +1 -0
  24. package/dist/catalog/shaders/halftone-waves/halftone-waves.d.ts +26 -0
  25. package/dist/catalog/shaders/halftone-waves/halftone-waves.d.ts.map +1 -0
  26. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.d.ts +3 -0
  27. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.d.ts.map +1 -0
  28. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.js +13 -0
  29. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.js.map +1 -0
  30. package/dist/catalog/shaders/halftone-waves/halftone-waves.js +78 -0
  31. package/dist/catalog/shaders/halftone-waves/halftone-waves.js.map +1 -0
  32. package/dist/catalog/shaders/index.d.ts +16 -0
  33. package/dist/catalog/shaders/index.d.ts.map +1 -1
  34. package/dist/catalog/shaders/index.js +9 -1
  35. package/dist/catalog/shaders/index.js.map +1 -1
  36. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.d.ts +24 -0
  37. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.d.ts.map +1 -0
  38. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.d.ts +3 -0
  39. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.d.ts.map +1 -0
  40. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js +14 -0
  41. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js.map +1 -0
  42. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.js +61 -0
  43. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.js.map +1 -0
  44. package/dist/catalog/shaders/neo-memphis/neo-memphis.d.ts +26 -0
  45. package/dist/catalog/shaders/neo-memphis/neo-memphis.d.ts.map +1 -0
  46. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.d.ts +3 -0
  47. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.d.ts.map +1 -0
  48. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.js +13 -0
  49. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.js.map +1 -0
  50. package/dist/catalog/shaders/neo-memphis/neo-memphis.js +62 -0
  51. package/dist/catalog/shaders/neo-memphis/neo-memphis.js.map +1 -0
  52. package/dist/src/components/preset-control-panel/preset-control-panel.d.ts +9 -1
  53. package/dist/src/components/preset-control-panel/preset-control-panel.d.ts.map +1 -1
  54. package/dist/src/components/preset-control-panel/preset-control-panel.js +7 -3
  55. package/dist/src/components/preset-control-panel/preset-control-panel.js.map +1 -1
  56. package/dist/src/kaleidoscope/controls.d.ts.map +1 -1
  57. package/dist/src/kaleidoscope/controls.js +6 -3
  58. package/dist/src/kaleidoscope/controls.js.map +1 -1
  59. package/dist/src/kaleidoscope/shader-to-spec.d.ts +15 -1
  60. package/dist/src/kaleidoscope/shader-to-spec.d.ts.map +1 -1
  61. package/dist/src/kaleidoscope/shader-to-spec.js +23 -4
  62. package/dist/src/kaleidoscope/shader-to-spec.js.map +1 -1
  63. package/dist/src/kaleidoscope/types.d.ts +3 -1
  64. package/dist/src/kaleidoscope/types.d.ts.map +1 -1
  65. package/dist/src/kaleidoscope/types.js.map +1 -1
  66. package/dist/src/persistence/async-storage-store.d.ts +3 -0
  67. package/dist/src/persistence/async-storage-store.d.ts.map +1 -0
  68. package/dist/src/persistence/async-storage-store.js +26 -0
  69. package/dist/src/persistence/async-storage-store.js.map +1 -0
  70. package/dist/src/persistence/index.d.ts +4 -0
  71. package/dist/src/persistence/index.d.ts.map +1 -0
  72. package/dist/src/persistence/index.js +22 -0
  73. package/dist/src/persistence/index.js.map +1 -0
  74. package/dist/src/persistence/provider.d.ts +38 -0
  75. package/dist/src/persistence/provider.d.ts.map +1 -0
  76. package/dist/src/persistence/provider.js +96 -0
  77. package/dist/src/persistence/provider.js.map +1 -0
  78. package/dist/src/persistence/state.d.ts +54 -0
  79. package/dist/src/persistence/state.d.ts.map +1 -0
  80. package/dist/src/persistence/state.js +126 -0
  81. package/dist/src/persistence/state.js.map +1 -0
  82. package/dist/web-driver/shaders.generated.d.ts +4 -0
  83. package/dist/web-driver/shaders.generated.d.ts.map +1 -1
  84. package/dist/web-driver/shaders.generated.js +351 -1
  85. package/dist/web-driver/shaders.generated.js.map +1 -1
  86. package/ios/KaleidoscopeModule/shaders/GENERATIVE.txt +4 -0
  87. package/ios/KaleidoscopeModule/shaders/SHADERS.txt +4 -0
  88. package/ios/KaleidoscopeModule/shaders/aurora-silk.metalsrc +51 -0
  89. package/ios/KaleidoscopeModule/shaders/halftone-waves.metalsrc +41 -0
  90. package/ios/KaleidoscopeModule/shaders/kaleidoscope.metalsrc +45 -0
  91. package/ios/KaleidoscopeModule/shaders/neo-memphis.metalsrc +181 -0
  92. package/package.json +43 -3
  93. package/src/components/preset-control-panel/preset-control-panel.tsx +15 -2
  94. package/src/kaleidoscope/controls.ts +6 -3
  95. package/src/kaleidoscope/shader-to-spec.ts +32 -5
  96. package/src/kaleidoscope/types.ts +3 -1
  97. package/src/persistence/async-storage-store.ts +33 -0
  98. package/src/persistence/index.ts +28 -0
  99. package/src/persistence/provider.tsx +165 -0
  100. package/src/persistence/state.ts +167 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/kaleidoscope/types.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,mEAAmE;AACnE,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,kDAAkD;AAClD,kFAAkF;AAClF,kFAAkF;AAClF,EAAE;AACF,6EAA6E;AAC7E,uEAAuE;AACvE,+EAA+E;AAC/E,8EAA8E","sourcesContent":["// The three-verb surface: types.\n//\n// Bind a track and a preset book once; get three typed verbs back:\n// - kaleidoscope(cmd, patches?) the art axis: which composite (layer stack)\n// fills the frame. cmd is a preset id from the book (narrowed), or null to\n// clear. patches optionally merge per-layer uniform overrides (addressed by\n// layer id); patching the currently-active preset routes through the live\n// no-rebuild channel, so sliders stay smooth.\n// - transform(t?) the geometry axis: absolute flips + 90° rotation.\n// - mask(m) the segmentation edge shared by every art effect.\n//\n// Shaders live in the library; consumers add presets (composites) over them,\n// never new shaders. Per shader-world convention, numeric uniforms are\n// normalized 0..1 where practical; ranges are documented in JSDoc as hints for\n// IntelliSense and tooling, not enforced at runtime (validation is userland).\n\nimport type { PatchableShaderName, ShaderUniformsMap } from '../../catalog/shaders';\nimport type { KaleidoscopePresetBook } from '../kaleidoscope.preset-book.types';\n\n/**\n * A live per-layer uniform override for ONE layer, derived from the layer's own\n * type: `id` is the layer's id, `uniforms` is `Partial` of the shader's uniform\n * type (re-indexed from `ShaderUniformsMap` by the layer's literal `shader`).\n * Non-tunable layers (`image`, `direct`) distribute to `never`, so they cannot be\n * patched. The runtime resolves by `id`; the shader is never sent on the wire.\n */\nexport type PatchFor<L> = L extends {\n readonly id: infer I extends string;\n readonly shader: infer S extends PatchableShaderName;\n}\n ? { readonly id: I; readonly uniforms: Partial<ShaderUniformsMap[S]> }\n : never;\n\n/**\n * The patches `kaleidoscope` accepts for preset `K` in book `P`: per-layer\n * overrides, each addressed by one of that preset's tunable layer ids and typed\n * by that layer's shader. At a literal `cmd` call site this narrows to the\n * preset's ids/uniforms; with a variable `cmd` it widens to the book-wide union\n * and is runtime-checked by id.\n */\nexport type PatchesFor<P extends KaleidoscopePresetBook, K extends keyof P> = ReadonlyArray<\n PatchFor<P[K]['layers'][number]>\n>;\n\n/**\n * Absolute, stateless geometric transform. Every call is the full desired state\n * from the identity orientation: re-passing is the caller's responsibility, and\n * `transform()` (or `transform({})`) resets to identity. Rotation snaps to the\n * nearest 90°; arbitrary angles and offset are a later step.\n */\nexport type TransformInput = {\n /** Mirror flips about each axis. */\n readonly flip?: { readonly x?: boolean; readonly y?: boolean };\n /** Clockwise rotation in degrees; snapped to the nearest 90 (0/90/180/270). */\n readonly rotate?: number;\n};\n\n/** The segmentation mask edge, shared by every art effect (not transforms). */\nexport type MaskInput = {\n /** Edge hardness, 0..1. 0 = soft halo, 1 = near-step. */\n readonly hardness: number;\n /** Edge threshold, 0..1. Higher rejects low-confidence (chair-edge) pixels. */\n readonly threshold: number;\n};\n\nexport type KaleidoscopeBindOptions<P extends KaleidoscopePresetBook> = {\n /** The consumer's preset book. Declare it `as const satisfies KaleidoscopePresetBook`. */\n readonly presets: P;\n /**\n * Called with the live output track after every art/transform command. On web\n * each command yields a NEW MediaStreamTrack (the pipeline is rebuilt); on\n * native the same track is mutated in place and passed back.\n */\n readonly onTrack?: (track: MediaStreamTrack) => void;\n};\n\n/**\n * The art verb: select a composite by id (rebuilding the pipeline), or clear it\n * with `null`. When `cmd` is the currently-active preset id and `patches` is\n * given, the patches merge through the live no-rebuild uniform channel (keyed by\n * layer id) instead of rebuilding, so a slider drag stays smooth.\n */\ntype KaleidoscopeCommand<P extends KaleidoscopePresetBook> = <K extends keyof P>(\n cmd: K | null,\n patches?: PatchesFor<P, K>,\n) => void;\n\n/**\n * The three verbs for one bound track and book, plus the live track and a\n * teardown. `kaleidoscope` (preset switch) and `transform` rebuild the composite\n * (web yields a new track via onTrack); a `kaleidoscope` patch of the active\n * preset and `mask` both update what the running composite reads each frame, so\n * they need no rebuild.\n */\nexport interface KaleidoscopeBinding<P extends KaleidoscopePresetBook> {\n readonly kaleidoscope: KaleidoscopeCommand<P>;\n readonly transform: (t?: TransformInput) => void;\n readonly mask: (m: MaskInput) => void;\n readonly track: MediaStreamTrack;\n readonly dispose: () => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/kaleidoscope/types.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,mEAAmE;AACnE,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,kDAAkD;AAClD,kFAAkF;AAClF,kFAAkF;AAClF,EAAE;AACF,6EAA6E;AAC7E,uEAAuE;AACvE,+EAA+E;AAC/E,8EAA8E","sourcesContent":["// The three-verb surface: types.\n//\n// Bind a track and a preset book once; get three typed verbs back:\n// - kaleidoscope(cmd, patches?) the art axis: which composite (layer stack)\n// fills the frame. cmd is a preset id from the book (narrowed), or null to\n// clear. patches optionally merge per-layer uniform overrides (addressed by\n// layer id); patching the currently-active preset routes through the live\n// no-rebuild channel, so sliders stay smooth.\n// - transform(t?) the geometry axis: absolute flips + 90° rotation.\n// - mask(m) the segmentation edge shared by every art effect.\n//\n// Shaders live in the library; consumers add presets (composites) over them,\n// never new shaders. Per shader-world convention, numeric uniforms are\n// normalized 0..1 where practical; ranges are documented in JSDoc as hints for\n// IntelliSense and tooling, not enforced at runtime (validation is userland).\n\nimport type { PatchableShaderName, ShaderUniformsMap } from '../../catalog/shaders';\nimport type { KaleidoscopePresetBook } from '../kaleidoscope.preset-book.types';\n\n/**\n * A live per-layer uniform override for ONE layer, derived from the layer's own\n * type: `id` is the layer's id, `uniforms` is `Partial` of the shader's uniform\n * type (re-indexed from `ShaderUniformsMap` by the layer's literal `shader`).\n * Non-tunable layers (`image`, `direct`) distribute to `never`, so they cannot be\n * patched. The runtime resolves by `id`; the shader is never sent on the wire.\n */\nexport type PatchFor<L> = L extends {\n readonly id: infer I extends string;\n readonly shader: infer S extends PatchableShaderName;\n}\n ? { readonly id: I; readonly uniforms: Partial<ShaderUniformsMap[S]> }\n : never;\n\n/**\n * The patches `kaleidoscope` accepts for preset `K` in book `P`: per-layer\n * overrides, each addressed by one of that preset's tunable layer ids and typed\n * by that layer's shader. At a literal `cmd` call site this narrows to the\n * preset's ids/uniforms; with a variable `cmd` it widens to the book-wide union\n * and is runtime-checked by id.\n */\nexport type PatchesFor<P extends KaleidoscopePresetBook, K extends keyof P> = ReadonlyArray<\n PatchFor<P[K]['layers'][number]>\n>;\n\n/**\n * Absolute, stateless geometric transform. Every call is the full desired state\n * from the identity orientation: re-passing is the caller's responsibility, and\n * `transform()` (or `transform({})`) resets to identity. Rotation snaps to the\n * nearest 90°; arbitrary angles and offset are a later step.\n */\nexport type TransformInput = {\n /** Mirror flips about each axis. */\n readonly flip?: { readonly x?: boolean; readonly y?: boolean };\n /** Clockwise rotation in degrees; snapped to the nearest 90 (0/90/180/270). */\n readonly rotate?: number;\n};\n\n/** The segmentation mask edge, shared by every art effect (not transforms). */\nexport type MaskInput = {\n /** Edge hardness, 0..1. 0 = soft halo, 1 = near-step. */\n readonly hardness: number;\n /** Edge threshold, 0..1. Higher rejects low-confidence (chair-edge) pixels. */\n readonly threshold: number;\n};\n\nexport type KaleidoscopeBindOptions<P extends KaleidoscopePresetBook> = {\n /** The consumer's preset book. Declare it `as const satisfies KaleidoscopePresetBook`. */\n readonly presets: P;\n /**\n * Called with the live output track after every art/transform command. On web\n * each command yields a NEW MediaStreamTrack (the pipeline is rebuilt); on\n * native the same track is mutated in place and passed back.\n */\n readonly onTrack?: (track: MediaStreamTrack) => void;\n};\n\n/**\n * The art verb: select a composite by id (rebuilding the pipeline), or clear it\n * with `null`. When `cmd` is the currently-active preset id and `patches` is\n * given, the patches merge through the live no-rebuild uniform channel (keyed by\n * layer id) instead of rebuilding, so a slider drag stays smooth. On a preset\n * SWITCH, patches merge into the rebuilt layer stack itself, so a restored\n * selection lands tuned on every platform, native included.\n */\ntype KaleidoscopeCommand<P extends KaleidoscopePresetBook> = <K extends keyof P>(\n cmd: K | null,\n patches?: PatchesFor<P, K>,\n) => void;\n\n/**\n * The three verbs for one bound track and book, plus the live track and a\n * teardown. `kaleidoscope` (preset switch) and `transform` rebuild the composite\n * (web yields a new track via onTrack); a `kaleidoscope` patch of the active\n * preset and `mask` both update what the running composite reads each frame, so\n * they need no rebuild.\n */\nexport interface KaleidoscopeBinding<P extends KaleidoscopePresetBook> {\n readonly kaleidoscope: KaleidoscopeCommand<P>;\n readonly transform: (t?: TransformInput) => void;\n readonly mask: (m: MaskInput) => void;\n readonly track: MediaStreamTrack;\n readonly dispose: () => void;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { type KaleidoscopeStateStore } from './state';
2
+ export declare const kaleidoscopeAsyncStorageStore: KaleidoscopeStateStore;
3
+ //# sourceMappingURL=async-storage-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-storage-store.d.ts","sourceRoot":"","sources":["../../../src/persistence/async-storage-store.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,6BAA6B,EAAE,sBAe3C,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // The default backing store: AsyncStorage under the canonical key. Works on
3
+ // every platform (the web build is localStorage-backed).
4
+ //
5
+ // `@react-native-async-storage/async-storage` is an OPTIONAL peer dependency of
6
+ // the package: only the `/persistence` subpath touches it, and Metro resolves
7
+ // it at bundle time for any app that imports this subpath (even with a custom
8
+ // `store`; bundlers do not tree-shake the default away).
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.kaleidoscopeAsyncStorageStore = void 0;
14
+ const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
15
+ const state_1 = require("./state");
16
+ exports.kaleidoscopeAsyncStorageStore = {
17
+ load() {
18
+ return async_storage_1.default.getItem(state_1.KALEIDOSCOPE_STATE_KEY).then(state_1.parseStoredKaleidoscopeState, () => null);
19
+ },
20
+ save(state) {
21
+ return async_storage_1.default.setItem(state_1.KALEIDOSCOPE_STATE_KEY, (0, state_1.serializeKaleidoscopeState)(state)).then(() => undefined, (error) => {
22
+ console.warn('kaleidoscope: preset persistence save failed', error);
23
+ });
24
+ },
25
+ };
26
+ //# sourceMappingURL=async-storage-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-storage-store.js","sourceRoot":"","sources":["../../../src/persistence/async-storage-store.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,yDAAyD;AACzD,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,yDAAyD;;;;;;AAEzD,8FAAqE;AACrE,mCAMiB;AAEJ,QAAA,6BAA6B,GAA2B;IACnE,IAAI;QACF,OAAO,uBAAY,CAAC,OAAO,CAAC,8BAAsB,CAAC,CAAC,IAAI,CACtD,oCAA4B,EAC5B,GAAG,EAAE,CAAC,IAAI,CACX,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,KAA8B;QACjC,OAAO,uBAAY,CAAC,OAAO,CAAC,8BAAsB,EAAE,IAAA,kCAA0B,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CACzF,GAAG,EAAE,CAAC,SAAS,EACf,CAAC,KAAK,EAAE,EAAE;YACR,OAAO,CAAC,IAAI,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;QACtE,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["// The default backing store: AsyncStorage under the canonical key. Works on\n// every platform (the web build is localStorage-backed).\n//\n// `@react-native-async-storage/async-storage` is an OPTIONAL peer dependency of\n// the package: only the `/persistence` subpath touches it, and Metro resolves\n// it at bundle time for any app that imports this subpath (even with a custom\n// `store`; bundlers do not tree-shake the default away).\n\nimport AsyncStorage from '@react-native-async-storage/async-storage';\nimport {\n KALEIDOSCOPE_STATE_KEY,\n type KaleidoscopeStateStore,\n parseStoredKaleidoscopeState,\n type StoredKaleidoscopeState,\n serializeKaleidoscopeState,\n} from './state';\n\nexport const kaleidoscopeAsyncStorageStore: KaleidoscopeStateStore = {\n load(): Promise<StoredKaleidoscopeState | null> {\n return AsyncStorage.getItem(KALEIDOSCOPE_STATE_KEY).then(\n parseStoredKaleidoscopeState,\n () => null,\n );\n },\n save(state: StoredKaleidoscopeState): Promise<void> {\n return AsyncStorage.setItem(KALEIDOSCOPE_STATE_KEY, serializeKaleidoscopeState(state)).then(\n () => undefined,\n (error) => {\n console.warn('kaleidoscope: preset persistence save failed', error);\n },\n );\n },\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export { kaleidoscopeAsyncStorageStore } from './async-storage-store';
2
+ export { KaleidoscopeStateProvider, type KaleidoscopeStateProviderProps, type KaleidoscopeStateValue, useKaleidoscopeState, } from './provider';
3
+ export { DEFAULT_MASK, KALEIDOSCOPE_STATE_KEY, type KaleidoscopeStateStore, parseStoredKaleidoscopeState, pruneStoredState, type StoredKaleidoscopeState, type StoredLayerUniforms, type StoredPatch, type StoredPatches, type StoredPatchMap, serializeKaleidoscopeState, } from './state';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/persistence/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EACL,yBAAyB,EACzB,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,0BAA0B,GAC3B,MAAM,SAAS,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // Subpath entry: react-native-webrtc-kaleidoscope/persistence
3
+ //
4
+ // The persisted-selection convenience: a provider + hook that keep the last
5
+ // applied preset, its control-panel patches, and the mask across launches.
6
+ // Storage-agnostic via `KaleidoscopeStateStore`; defaults to AsyncStorage
7
+ // (`@react-native-async-storage/async-storage`, an optional peer dependency
8
+ // required only by apps that use the default store).
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.serializeKaleidoscopeState = exports.pruneStoredState = exports.parseStoredKaleidoscopeState = exports.KALEIDOSCOPE_STATE_KEY = exports.DEFAULT_MASK = exports.useKaleidoscopeState = exports.KaleidoscopeStateProvider = exports.kaleidoscopeAsyncStorageStore = void 0;
11
+ var async_storage_store_1 = require("./async-storage-store");
12
+ Object.defineProperty(exports, "kaleidoscopeAsyncStorageStore", { enumerable: true, get: function () { return async_storage_store_1.kaleidoscopeAsyncStorageStore; } });
13
+ var provider_1 = require("./provider");
14
+ Object.defineProperty(exports, "KaleidoscopeStateProvider", { enumerable: true, get: function () { return provider_1.KaleidoscopeStateProvider; } });
15
+ Object.defineProperty(exports, "useKaleidoscopeState", { enumerable: true, get: function () { return provider_1.useKaleidoscopeState; } });
16
+ var state_1 = require("./state");
17
+ Object.defineProperty(exports, "DEFAULT_MASK", { enumerable: true, get: function () { return state_1.DEFAULT_MASK; } });
18
+ Object.defineProperty(exports, "KALEIDOSCOPE_STATE_KEY", { enumerable: true, get: function () { return state_1.KALEIDOSCOPE_STATE_KEY; } });
19
+ Object.defineProperty(exports, "parseStoredKaleidoscopeState", { enumerable: true, get: function () { return state_1.parseStoredKaleidoscopeState; } });
20
+ Object.defineProperty(exports, "pruneStoredState", { enumerable: true, get: function () { return state_1.pruneStoredState; } });
21
+ Object.defineProperty(exports, "serializeKaleidoscopeState", { enumerable: true, get: function () { return state_1.serializeKaleidoscopeState; } });
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/persistence/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,qDAAqD;;;AAErD,6DAAsE;AAA7D,oIAAA,6BAA6B,OAAA;AACtC,uCAKoB;AAJlB,qHAAA,yBAAyB,OAAA;AAGzB,gHAAA,oBAAoB,OAAA;AAEtB,iCAYiB;AAXf,qGAAA,YAAY,OAAA;AACZ,+GAAA,sBAAsB,OAAA;AAEtB,qHAAA,4BAA4B,OAAA;AAC5B,yGAAA,gBAAgB,OAAA;AAMhB,mHAAA,0BAA0B,OAAA","sourcesContent":["// Subpath entry: react-native-webrtc-kaleidoscope/persistence\n//\n// The persisted-selection convenience: a provider + hook that keep the last\n// applied preset, its control-panel patches, and the mask across launches.\n// Storage-agnostic via `KaleidoscopeStateStore`; defaults to AsyncStorage\n// (`@react-native-async-storage/async-storage`, an optional peer dependency\n// required only by apps that use the default store).\n\nexport { kaleidoscopeAsyncStorageStore } from './async-storage-store';\nexport {\n KaleidoscopeStateProvider,\n type KaleidoscopeStateProviderProps,\n type KaleidoscopeStateValue,\n useKaleidoscopeState,\n} from './provider';\nexport {\n DEFAULT_MASK,\n KALEIDOSCOPE_STATE_KEY,\n type KaleidoscopeStateStore,\n parseStoredKaleidoscopeState,\n pruneStoredState,\n type StoredKaleidoscopeState,\n type StoredLayerUniforms,\n type StoredPatch,\n type StoredPatches,\n type StoredPatchMap,\n serializeKaleidoscopeState,\n} from './state';\n"]}
@@ -0,0 +1,38 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import type { MaskInput, PatchesFor } from '../kaleidoscope/types';
3
+ import type { KaleidoscopePresetBook } from '../kaleidoscope.preset-book.types';
4
+ import { type KaleidoscopeStateStore, type StoredPatch, type StoredPatches } from './state';
5
+ export type KaleidoscopeStateValue<P extends KaleidoscopePresetBook = KaleidoscopePresetBook> = {
6
+ /** False until the persisted selection has been read; apply no effects before then. */
7
+ readonly hydrated: boolean;
8
+ /** The selected preset id, or null when nothing is selected. */
9
+ readonly presetId: (keyof P & string) | null;
10
+ /** The shared segmentation edge. */
11
+ readonly mask: MaskInput;
12
+ /** Every preset's stored per-layer overrides (keyed by preset id, then layer id). */
13
+ readonly patches: StoredPatches;
14
+ readonly setPreset: (presetId: (keyof P & string) | null) => void;
15
+ readonly setMask: (mask: MaskInput) => void;
16
+ /** Record one control-panel patch against a preset (and persist it). */
17
+ readonly setPatch: (presetId: keyof P & string, patch: StoredPatch) => void;
18
+ /** A preset's stored overrides in the array shape `kaleidoscope(id, patches)` takes. */
19
+ readonly patchesFor: <K extends keyof P & string>(presetId: K) => PatchesFor<P, K>;
20
+ /** Clear the stored selection back to defaults (and persist the cleared state). */
21
+ readonly reset: () => void;
22
+ };
23
+ export type KaleidoscopeStateProviderProps<P extends KaleidoscopePresetBook> = {
24
+ /** The consumer's preset book; stored state is pruned against it at hydrate. */
25
+ readonly presets: P;
26
+ /** The backing store. Defaults to the AsyncStorage store (lazily loaded). */
27
+ readonly store?: KaleidoscopeStateStore;
28
+ /** The mask used before hydration and after `reset`. Defaults to 0.5/0.5. */
29
+ readonly defaultMask?: MaskInput;
30
+ readonly children: ReactNode;
31
+ };
32
+ export declare function KaleidoscopeStateProvider<P extends KaleidoscopePresetBook>({ presets, store, defaultMask, children, }: KaleidoscopeStateProviderProps<P>): ReactElement;
33
+ /**
34
+ * The persisted selection plus its setters. Typed by the consumer's book:
35
+ * `useKaleidoscopeState<typeof presets>()`. Throws outside the provider.
36
+ */
37
+ export declare function useKaleidoscopeState<P extends KaleidoscopePresetBook = KaleidoscopePresetBook>(): KaleidoscopeStateValue<P>;
38
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/persistence/provider.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,EAEL,KAAK,sBAAsB,EAI3B,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB,IAAI;IAC9F,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;IAC7C,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC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ateProvider = KaleidoscopeStateProvider;
4
+ exports.useKaleidoscopeState = useKaleidoscopeState;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ // Persistence: the React surface. `KaleidoscopeStateProvider` hydrates the
7
+ // stored selection once at mount and writes through on every change;
8
+ // `useKaleidoscopeState` hands the host the hydrated values plus the setters.
9
+ //
10
+ // The provider owns STORAGE state only; it never binds a track or calls the
11
+ // verbs. The host applies the restored selection itself (gated on `hydrated`,
12
+ // so a stored preset is not flashed over by the default):
13
+ //
14
+ // const { hydrated, presetId, patchesFor, mask, ... } = useKaleidoscopeState<typeof presets>();
15
+ // useEffect(() => {
16
+ // if (!hydrated || !controls) return;
17
+ // if (presetId) controls.kaleidoscope(presetId, patchesFor(presetId));
18
+ // else controls.kaleidoscope(null);
19
+ // }, [hydrated, controls, presetId]);
20
+ //
21
+ // The backing store defaults to AsyncStorage; pass any `KaleidoscopeStateStore`
22
+ // to swap it. Importing this subpath is what brings the optional
23
+ // `@react-native-async-storage/async-storage` peer onto your bundle path
24
+ // (Metro resolves it at bundle time either way, so there is no lazy escape).
25
+ const react_1 = require("react");
26
+ const async_storage_store_1 = require("./async-storage-store");
27
+ const state_1 = require("./state");
28
+ const KaleidoscopeStateContext = (0, react_1.createContext)(null);
29
+ function KaleidoscopeStateProvider({ presets, store, defaultMask = state_1.DEFAULT_MASK, children, }) {
30
+ const [hydrated, setHydrated] = (0, react_1.useState)(false);
31
+ const [selection, setSelection] = (0, react_1.useState)({
32
+ presetId: null,
33
+ mask: defaultMask,
34
+ patches: {},
35
+ });
36
+ // A write before hydration wins over the stored value (the person acted; do
37
+ // not clobber their fresh choice with yesterday's).
38
+ const dirty = (0, react_1.useRef)(false);
39
+ // Pinned for the provider's lifetime: hydrate and every write-through go to
40
+ // the same store the first render saw.
41
+ const storeRef = (0, react_1.useRef)(store ?? async_storage_store_1.kaleidoscopeAsyncStorageStore);
42
+ // biome-ignore lint/correctness/useExhaustiveDependencies: hydrate exactly once; the book and store are bind-time constants.
43
+ (0, react_1.useEffect)(() => {
44
+ let cancelled = false;
45
+ storeRef.current.load().then((stored) => {
46
+ if (cancelled)
47
+ return;
48
+ if (stored && !dirty.current) {
49
+ const pruned = (0, state_1.pruneStoredState)(stored, presets);
50
+ setSelection({ presetId: pruned.presetId, mask: pruned.mask, patches: pruned.patches });
51
+ }
52
+ setHydrated(true);
53
+ }, () => {
54
+ if (!cancelled)
55
+ setHydrated(true);
56
+ });
57
+ return () => {
58
+ cancelled = true;
59
+ };
60
+ }, []);
61
+ const commit = (next) => {
62
+ dirty.current = true;
63
+ setSelection(next);
64
+ void storeRef.current.save({ version: 1, ...next });
65
+ };
66
+ const value = {
67
+ hydrated,
68
+ presetId: selection.presetId,
69
+ mask: selection.mask,
70
+ patches: selection.patches,
71
+ setPreset: (presetId) => commit({ ...selection, presetId }),
72
+ setMask: (mask) => commit({ ...selection, mask }),
73
+ setPatch: (presetId, patch) => commit({ ...selection, patches: (0, state_1.mergePatch)(selection.patches, presetId, patch) }),
74
+ // The stored wire shape is book-agnostic; the typed view is recovered at the
75
+ // hook (`useKaleidoscopeState<typeof presets>()`), so the cast is the seam.
76
+ patchesFor: ((presetId) => (0, state_1.patchListFor)(selection.patches, presetId)),
77
+ reset: () => commit({ presetId: null, mask: defaultMask, patches: {} }),
78
+ };
79
+ return ((0, jsx_runtime_1.jsx)(KaleidoscopeStateContext.Provider, { value: value, children: children }));
80
+ }
81
+ /**
82
+ * The persisted selection plus its setters. Typed by the consumer's book:
83
+ * `useKaleidoscopeState<typeof presets>()`. Throws outside the provider.
84
+ */
85
+ function useKaleidoscopeState() {
86
+ const value = (0, react_1.useContext)(KaleidoscopeStateContext);
87
+ if (value === null) {
88
+ throw new Error('useKaleidoscopeState: no <KaleidoscopeStateProvider> above this component. ' +
89
+ 'Wrap your app (or the screen using the picker) in the provider from ' +
90
+ "'react-native-webrtc-kaleidoscope/persistence'.");
91
+ }
92
+ // Safe by construction: the provider pruned ids against the same book the
93
+ // consumer parameterizes with; the runtime shapes are identical.
94
+ return value;
95
+ }
96
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/persistence/provider.tsx"],"names":[],"mappings":";;;;;AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,8EAA8E;AAC9E,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,0DAA0D;AAC1D,EAAE;AACF,kGAAkG;AAClG,sBAAsB;AACtB,0CAA0C;AAC1C,2EAA2E;AAC3E,wCAAwC;AACxC,wCAAwC;AACxC,EAAE;AACF,gFAAgF;AAChF,iEAAiE;AACjE,yEAAyE;AACzE,6EAA6E;AAE7E,iCAQe;AAGf,+DAAsE;AACtE,mCAQiB;AAqBjB,MAAM,wBAAwB,GAAG,IAAA,qBAAa,EAAgC,IAAI,CAAC,CAAC;AAkBpF,mCAA4E,EAC1E,OAAO,EACP,KAAK,EACL,WAAW,GAAG,oBAAY,EAC1B,QAAQ,GAC0B;IAClC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAY;QACpD,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,EAAE;KACZ,CAAC,CAAC;IACH,4EAA4E;IAC5E,oDAAoD;IACpD,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAC5B,4EAA4E;IAC5E,uCAAuC;IACvC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,KAAK,IAAI,mDAA6B,CAAC,CAAC;IAEhE,6HAA6H;IAC7H,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAC1B,CAAC,MAAM,EAAE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,EAAE,KAAK,EAAE,EAAE,CAC5B,MAAM,CAAC,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,IAAA,kBAAU,EAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;QACnF,6EAA6E;QAC7E,4EAA4E;QAC5E,UAAU,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAChC,IAAA,oBAAY,EAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAyC;QACpF,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;KACxE,CAAC;IAEF,OAAO,CACL,uBAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAqC,CAChG,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH;IAGE,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAC;IACnD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,6EAA6E;YAC3E,sEAAsE;YACtE,iDAAiD,CACpD,CAAC;IACJ,CAAC;IACD,0EAA0E;IAC1E,iEAAiE;IACjE,OAAO,KAA6C,CAAC;AACvD,CAAC","sourcesContent":["// Persistence: the React surface. `KaleidoscopeStateProvider` hydrates the\n// stored selection once at mount and writes through on every change;\n// `useKaleidoscopeState` hands the host the hydrated values plus the setters.\n//\n// The provider owns STORAGE state only; it never binds a track or calls the\n// verbs. The host applies the restored selection itself (gated on `hydrated`,\n// so a stored preset is not flashed over by the default):\n//\n// const { hydrated, presetId, patchesFor, mask, ... } = useKaleidoscopeState<typeof presets>();\n// useEffect(() => {\n// if (!hydrated || !controls) return;\n// if (presetId) controls.kaleidoscope(presetId, patchesFor(presetId));\n// else controls.kaleidoscope(null);\n// }, [hydrated, controls, presetId]);\n//\n// The backing store defaults to AsyncStorage; pass any `KaleidoscopeStateStore`\n// to swap it. Importing this subpath is what brings the optional\n// `@react-native-async-storage/async-storage` peer onto your bundle path\n// (Metro resolves it at bundle time either way, so there is no lazy escape).\n\nimport {\n createContext,\n type ReactElement,\n type ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type { MaskInput, PatchesFor } from '../kaleidoscope/types';\nimport type { KaleidoscopePresetBook } from '../kaleidoscope.preset-book.types';\nimport { kaleidoscopeAsyncStorageStore } from './async-storage-store';\nimport {\n DEFAULT_MASK,\n type KaleidoscopeStateStore,\n mergePatch,\n patchListFor,\n pruneStoredState,\n type StoredPatch,\n type StoredPatches,\n} from './state';\n\nexport type KaleidoscopeStateValue<P extends KaleidoscopePresetBook = KaleidoscopePresetBook> = {\n /** False until the persisted selection has been read; apply no effects before then. */\n readonly hydrated: boolean;\n /** The selected preset id, or null when nothing is selected. */\n readonly presetId: (keyof P & string) | null;\n /** The shared segmentation edge. */\n readonly mask: MaskInput;\n /** Every preset's stored per-layer overrides (keyed by preset id, then layer id). */\n readonly patches: StoredPatches;\n readonly setPreset: (presetId: (keyof P & string) | null) => void;\n readonly setMask: (mask: MaskInput) => void;\n /** Record one control-panel patch against a preset (and persist it). */\n readonly setPatch: (presetId: keyof P & string, patch: StoredPatch) => void;\n /** A preset's stored overrides in the array shape `kaleidoscope(id, patches)` takes. */\n readonly patchesFor: <K extends keyof P & string>(presetId: K) => PatchesFor<P, K>;\n /** Clear the stored selection back to defaults (and persist the cleared state). */\n readonly reset: () => void;\n};\n\nconst KaleidoscopeStateContext = createContext<KaleidoscopeStateValue | null>(null);\n\nexport type KaleidoscopeStateProviderProps<P extends KaleidoscopePresetBook> = {\n /** The consumer's preset book; stored state is pruned against it at hydrate. */\n readonly presets: P;\n /** The backing store. Defaults to the AsyncStorage store (lazily loaded). */\n readonly store?: KaleidoscopeStateStore;\n /** The mask used before hydration and after `reset`. Defaults to 0.5/0.5. */\n readonly defaultMask?: MaskInput;\n readonly children: ReactNode;\n};\n\ntype Selection = {\n readonly presetId: string | null;\n readonly mask: MaskInput;\n readonly patches: StoredPatches;\n};\n\nexport function KaleidoscopeStateProvider<P extends KaleidoscopePresetBook>({\n presets,\n store,\n defaultMask = DEFAULT_MASK,\n children,\n}: KaleidoscopeStateProviderProps<P>): ReactElement {\n const [hydrated, setHydrated] = useState(false);\n const [selection, setSelection] = useState<Selection>({\n presetId: null,\n mask: defaultMask,\n patches: {},\n });\n // A write before hydration wins over the stored value (the person acted; do\n // not clobber their fresh choice with yesterday's).\n const dirty = useRef(false);\n // Pinned for the provider's lifetime: hydrate and every write-through go to\n // the same store the first render saw.\n const storeRef = useRef(store ?? kaleidoscopeAsyncStorageStore);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: hydrate exactly once; the book and store are bind-time constants.\n useEffect(() => {\n let cancelled = false;\n storeRef.current.load().then(\n (stored) => {\n if (cancelled) return;\n if (stored && !dirty.current) {\n const pruned = pruneStoredState(stored, presets);\n setSelection({ presetId: pruned.presetId, mask: pruned.mask, patches: pruned.patches });\n }\n setHydrated(true);\n },\n () => {\n if (!cancelled) setHydrated(true);\n },\n );\n return () => {\n cancelled = true;\n };\n }, []);\n\n const commit = (next: Selection): void => {\n dirty.current = true;\n setSelection(next);\n void storeRef.current.save({ version: 1, ...next });\n };\n\n const value: KaleidoscopeStateValue = {\n hydrated,\n presetId: selection.presetId,\n mask: selection.mask,\n patches: selection.patches,\n setPreset: (presetId) => commit({ ...selection, presetId }),\n setMask: (mask) => commit({ ...selection, mask }),\n setPatch: (presetId, patch) =>\n commit({ ...selection, patches: mergePatch(selection.patches, presetId, patch) }),\n // The stored wire shape is book-agnostic; the typed view is recovered at the\n // hook (`useKaleidoscopeState<typeof presets>()`), so the cast is the seam.\n patchesFor: ((presetId: string) =>\n patchListFor(selection.patches, presetId)) as KaleidoscopeStateValue['patchesFor'],\n reset: () => commit({ presetId: null, mask: defaultMask, patches: {} }),\n };\n\n return (\n <KaleidoscopeStateContext.Provider value={value}>{children}</KaleidoscopeStateContext.Provider>\n );\n}\n\n/**\n * The persisted selection plus its setters. Typed by the consumer's book:\n * `useKaleidoscopeState<typeof presets>()`. Throws outside the provider.\n */\nexport function useKaleidoscopeState<\n P extends KaleidoscopePresetBook = KaleidoscopePresetBook,\n>(): KaleidoscopeStateValue<P> {\n const value = useContext(KaleidoscopeStateContext);\n if (value === null) {\n throw new Error(\n 'useKaleidoscopeState: no <KaleidoscopeStateProvider> above this component. ' +\n 'Wrap your app (or the screen using the picker) in the provider from ' +\n \"'react-native-webrtc-kaleidoscope/persistence'.\",\n );\n }\n // Safe by construction: the provider pruned ids against the same book the\n // consumer parameterizes with; the runtime shapes are identical.\n return value as unknown as KaleidoscopeStateValue<P>;\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { MaskInput } from '../kaleidoscope/types';
2
+ import type { KaleidoscopePresetBook } from '../kaleidoscope.preset-book.types';
3
+ /** One layer's stored uniform overrides (the wire shape `onPatch` emits). */
4
+ export type StoredLayerUniforms = Readonly<Record<string, number | readonly number[]>>;
5
+ /** A preset's stored overrides, keyed by layer id. */
6
+ export type StoredPatchMap = Readonly<Record<string, StoredLayerUniforms>>;
7
+ /** Every preset's stored overrides, keyed by preset id. */
8
+ export type StoredPatches = Readonly<Record<string, StoredPatchMap>>;
9
+ /** The single live-patch shape, identical to `KaleidoscopeControls['onPatch']`'s argument. */
10
+ export type StoredPatch = {
11
+ readonly id: string;
12
+ readonly uniforms: StoredLayerUniforms;
13
+ };
14
+ export type StoredKaleidoscopeState = {
15
+ readonly version: 1;
16
+ /** The last-applied preset id, or null when nothing was selected. */
17
+ readonly presetId: string | null;
18
+ /** The shared segmentation edge. */
19
+ readonly mask: MaskInput;
20
+ /** Per-preset, per-layer uniform overrides from the control panels. */
21
+ readonly patches: StoredPatches;
22
+ };
23
+ /**
24
+ * The backing store. `load` resolves null when nothing (or nothing readable) is
25
+ * stored; `save` swallows its own failures (persistence is a convenience, never
26
+ * a crash).
27
+ */
28
+ export interface KaleidoscopeStateStore {
29
+ load(): Promise<StoredKaleidoscopeState | null>;
30
+ save(state: StoredKaleidoscopeState): Promise<void>;
31
+ }
32
+ export declare const KALEIDOSCOPE_STATE_KEY = "kaleidoscope.state.v1";
33
+ export declare const DEFAULT_MASK: MaskInput;
34
+ export declare const serializeKaleidoscopeState: (state: StoredKaleidoscopeState) => string;
35
+ /**
36
+ * Tolerant parse: any malformed or wrong-version payload reads as null, and a
37
+ * malformed `patches` subtree degrades to the valid subset rather than killing
38
+ * the whole state. Mask values clamp to 0..1 (the verbs' documented range).
39
+ */
40
+ export declare const parseStoredKaleidoscopeState: (raw: string | null) => StoredKaleidoscopeState | null;
41
+ /**
42
+ * Reconcile stored state against the consumer's current book: a preset that no
43
+ * longer exists reads as "none", a patch for a vanished preset or layer is
44
+ * dropped. Stale state degrades silently; it never crashes the picker.
45
+ */
46
+ export declare const pruneStoredState: (state: StoredKaleidoscopeState, book: KaleidoscopePresetBook) => StoredKaleidoscopeState;
47
+ /** Merge one live patch into a preset's stored overrides (immutably). */
48
+ export declare const mergePatch: (patches: StoredPatches, presetId: string, patch: StoredPatch) => StoredPatches;
49
+ /**
50
+ * Project a preset's stored overrides into the array shape the `kaleidoscope`
51
+ * verb takes as `patches`.
52
+ */
53
+ export declare const patchListFor: (patches: StoredPatches, presetId: string) => ReadonlyArray<StoredPatch>;
54
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/persistence/state.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAA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AAW,KACjB,aAMD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,YAAY,YACd,aAAa,YACZ,MAAM,KACf,aAAa,CAAC,WAAW,CACyD,CAAC"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ // Persistence: the pure state module. The stored shape, its key, the tolerant
3
+ // parse, and the pure helpers the provider uses to prune, merge, and project
4
+ // stored state. No React, no storage; the store interface is the only boundary
5
+ // (a consumer may back it with AsyncStorage, localStorage, MMKV, anything
6
+ // promise-shaped). Everything here is unit-testable in plain Node.
7
+ //
8
+ // What persists is the person's selection: the preset id they last applied, the
9
+ // per-layer uniform patches they dialed in through the control panels (keyed by
10
+ // preset, so tweaks to several presets all survive), and the shared mask edge.
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.patchListFor = exports.mergePatch = exports.pruneStoredState = exports.parseStoredKaleidoscopeState = exports.serializeKaleidoscopeState = exports.DEFAULT_MASK = exports.KALEIDOSCOPE_STATE_KEY = void 0;
13
+ exports.KALEIDOSCOPE_STATE_KEY = 'kaleidoscope.state.v1';
14
+ exports.DEFAULT_MASK = { hardness: 0.5, threshold: 0.5 };
15
+ const serializeKaleidoscopeState = (state) => JSON.stringify(state);
16
+ exports.serializeKaleidoscopeState = serializeKaleidoscopeState;
17
+ const clamp01 = (value) => Math.min(1, Math.max(0, value));
18
+ const isUniformValue = (value) => typeof value === 'number' ||
19
+ (Array.isArray(value) && value.every((entry) => typeof entry === 'number'));
20
+ // A patch map (layer id -> uniforms) with every malformed entry dropped.
21
+ const parsePatchMap = (raw) => {
22
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
23
+ return null;
24
+ const out = {};
25
+ for (const [layerId, uniforms] of Object.entries(raw)) {
26
+ if (typeof uniforms !== 'object' || uniforms === null || Array.isArray(uniforms))
27
+ continue;
28
+ const kept = {};
29
+ for (const [key, value] of Object.entries(uniforms)) {
30
+ if (isUniformValue(value))
31
+ kept[key] = value;
32
+ }
33
+ if (Object.keys(kept).length > 0)
34
+ out[layerId] = kept;
35
+ }
36
+ return out;
37
+ };
38
+ /**
39
+ * Tolerant parse: any malformed or wrong-version payload reads as null, and a
40
+ * malformed `patches` subtree degrades to the valid subset rather than killing
41
+ * the whole state. Mask values clamp to 0..1 (the verbs' documented range).
42
+ */
43
+ const parseStoredKaleidoscopeState = (raw) => {
44
+ if (!raw)
45
+ return null;
46
+ let parsed;
47
+ try {
48
+ parsed = JSON.parse(raw);
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ if (typeof parsed !== 'object' || parsed === null)
54
+ return null;
55
+ const candidate = parsed;
56
+ if (candidate.version !== 1)
57
+ return null;
58
+ if (candidate.presetId !== null && typeof candidate.presetId !== 'string')
59
+ return null;
60
+ const mask = candidate.mask;
61
+ if (!mask || typeof mask.hardness !== 'number' || typeof mask.threshold !== 'number') {
62
+ return null;
63
+ }
64
+ const patches = {};
65
+ if (typeof candidate.patches === 'object' && candidate.patches !== null) {
66
+ for (const [presetId, rawMap] of Object.entries(candidate.patches)) {
67
+ const map = parsePatchMap(rawMap);
68
+ if (map && Object.keys(map).length > 0)
69
+ patches[presetId] = map;
70
+ }
71
+ }
72
+ return {
73
+ version: 1,
74
+ presetId: candidate.presetId,
75
+ mask: { hardness: clamp01(mask.hardness), threshold: clamp01(mask.threshold) },
76
+ patches,
77
+ };
78
+ };
79
+ exports.parseStoredKaleidoscopeState = parseStoredKaleidoscopeState;
80
+ // The layer ids a preset can be patched on: the layers that carry uniforms
81
+ // (`image` and `direct` layers have none and cannot be patched).
82
+ const tunableLayerIds = (book, presetId) => {
83
+ const preset = book[presetId];
84
+ if (!preset)
85
+ return new Set();
86
+ return new Set(preset.layers.filter((layer) => 'uniforms' in layer).map((layer) => layer.id));
87
+ };
88
+ /**
89
+ * Reconcile stored state against the consumer's current book: a preset that no
90
+ * longer exists reads as "none", a patch for a vanished preset or layer is
91
+ * dropped. Stale state degrades silently; it never crashes the picker.
92
+ */
93
+ const pruneStoredState = (state, book) => {
94
+ const presetId = state.presetId !== null && state.presetId in book ? state.presetId : null;
95
+ const patches = {};
96
+ for (const [id, map] of Object.entries(state.patches)) {
97
+ if (!(id in book))
98
+ continue;
99
+ const tunable = tunableLayerIds(book, id);
100
+ const kept = {};
101
+ for (const [layerId, uniforms] of Object.entries(map)) {
102
+ if (tunable.has(layerId))
103
+ kept[layerId] = uniforms;
104
+ }
105
+ if (Object.keys(kept).length > 0)
106
+ patches[id] = kept;
107
+ }
108
+ return { version: 1, presetId, mask: state.mask, patches };
109
+ };
110
+ exports.pruneStoredState = pruneStoredState;
111
+ /** Merge one live patch into a preset's stored overrides (immutably). */
112
+ const mergePatch = (patches, presetId, patch) => ({
113
+ ...patches,
114
+ [presetId]: {
115
+ ...patches[presetId],
116
+ [patch.id]: { ...patches[presetId]?.[patch.id], ...patch.uniforms },
117
+ },
118
+ });
119
+ exports.mergePatch = mergePatch;
120
+ /**
121
+ * Project a preset's stored overrides into the array shape the `kaleidoscope`
122
+ * verb takes as `patches`.
123
+ */
124
+ const patchListFor = (patches, presetId) => Object.entries(patches[presetId] ?? {}).map(([id, uniforms]) => ({ id, uniforms }));
125
+ exports.patchListFor = patchListFor;
126
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/persistence/state.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;;;AAwClE,QAAA,sBAAsB,GAAG,uBAAuB,CAAC;AAEjD,QAAA,YAAY,GAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;AAElE,MAAM,0BAA0B,GAAG,CAAC,KAA8B,EAAU,EAAE,CACnF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AADX,QAAA,0BAA0B,GAA1B,0BAA0B,CACf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AE,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AAJzE,QAAA,YAAY,GAAZ,YAAY,CAI6D","sourcesContent":["// Persistence: the pure state module. The stored shape, its key, the tolerant\n// parse, and the pure helpers the provider uses to prune, merge, and project\n// stored state. No React, no storage; the store interface is the only boundary\n// (a consumer may back it with AsyncStorage, localStorage, MMKV, anything\n// promise-shaped). Everything here is unit-testable in plain Node.\n//\n// What persists is the person's selection: the preset id they last applied, the\n// per-layer uniform patches they dialed in through the control panels (keyed by\n// preset, so tweaks to several presets all survive), and the shared mask edge.\n\nimport type { MaskInput } from '../kaleidoscope/types';\nimport type { KaleidoscopePresetBook } from '../kaleidoscope.preset-book.types';\n\n/** One layer's stored uniform overrides (the wire shape `onPatch` emits). */\nexport type StoredLayerUniforms = Readonly<Record<string, number | readonly number[]>>;\n\n/** A preset's stored overrides, keyed by layer id. */\nexport type StoredPatchMap = Readonly<Record<string, StoredLayerUniforms>>;\n\n/** Every preset's stored overrides, keyed by preset id. */\nexport type StoredPatches = Readonly<Record<string, StoredPatchMap>>;\n\n/** The single live-patch shape, identical to `KaleidoscopeControls['onPatch']`'s argument. */\nexport type StoredPatch = {\n readonly id: string;\n readonly uniforms: StoredLayerUniforms;\n};\n\nexport type StoredKaleidoscopeState = {\n readonly version: 1;\n /** The last-applied preset id, or null when nothing was selected. */\n readonly presetId: string | null;\n /** The shared segmentation edge. */\n readonly mask: MaskInput;\n /** Per-preset, per-layer uniform overrides from the control panels. */\n readonly patches: StoredPatches;\n};\n\n/**\n * The backing store. `load` resolves null when nothing (or nothing readable) is\n * stored; `save` swallows its own failures (persistence is a convenience, never\n * a crash).\n */\nexport interface KaleidoscopeStateStore {\n load(): Promise<StoredKaleidoscopeState | null>;\n save(state: StoredKaleidoscopeState): Promise<void>;\n}\n\nexport const KALEIDOSCOPE_STATE_KEY = 'kaleidoscope.state.v1';\n\nexport const DEFAULT_MASK: MaskInput = { hardness: 0.5, threshold: 0.5 };\n\nexport const serializeKaleidoscopeState = (state: StoredKaleidoscopeState): string =>\n JSON.stringify(state);\n\nconst clamp01 = (value: number): number => Math.min(1, Math.max(0, value));\n\nconst isUniformValue = (value: unknown): value is number | readonly number[] =>\n typeof value === 'number' ||\n (Array.isArray(value) && value.every((entry) => typeof entry === 'number'));\n\n// A patch map (layer id -> uniforms) with every malformed entry dropped.\nconst parsePatchMap = (raw: unknown): StoredPatchMap | null => {\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return null;\n const out: Record<string, StoredLayerUniforms> = {};\n for (const [layerId, uniforms] of Object.entries(raw)) {\n if (typeof uniforms !== 'object' || uniforms === null || Array.isArray(uniforms)) continue;\n const kept: Record<string, number | readonly number[]> = {};\n for (const [key, value] of Object.entries(uniforms)) {\n if (isUniformValue(value)) kept[key] = value;\n }\n if (Object.keys(kept).length > 0) out[layerId] = kept;\n }\n return out;\n};\n\n/**\n * Tolerant parse: any malformed or wrong-version payload reads as null, and a\n * malformed `patches` subtree degrades to the valid subset rather than killing\n * the whole state. Mask values clamp to 0..1 (the verbs' documented range).\n */\nexport const parseStoredKaleidoscopeState = (\n raw: string | null,\n): StoredKaleidoscopeState | null => {\n if (!raw) return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return null;\n }\n if (typeof parsed !== 'object' || parsed === null) return null;\n const candidate = parsed as Record<string, unknown>;\n if (candidate.version !== 1) return null;\n if (candidate.presetId !== null && typeof candidate.presetId !== 'string') return null;\n const mask = candidate.mask as Record<string, unknown> | null | undefined;\n if (!mask || typeof mask.hardness !== 'number' || typeof mask.threshold !== 'number') {\n return null;\n }\n const patches: Record<string, StoredPatchMap> = {};\n if (typeof candidate.patches === 'object' && candidate.patches !== null) {\n for (const [presetId, rawMap] of Object.entries(candidate.patches)) {\n const map = parsePatchMap(rawMap);\n if (map && Object.keys(map).length > 0) patches[presetId] = map;\n }\n }\n return {\n version: 1,\n presetId: candidate.presetId as string | null,\n mask: { hardness: clamp01(mask.hardness), threshold: clamp01(mask.threshold) },\n patches,\n };\n};\n\n// The layer ids a preset can be patched on: the layers that carry uniforms\n// (`image` and `direct` layers have none and cannot be patched).\nconst tunableLayerIds = (book: KaleidoscopePresetBook, presetId: string): ReadonlySet<string> => {\n const preset = book[presetId];\n if (!preset) return new Set();\n return new Set(preset.layers.filter((layer) => 'uniforms' in layer).map((layer) => layer.id));\n};\n\n/**\n * Reconcile stored state against the consumer's current book: a preset that no\n * longer exists reads as \"none\", a patch for a vanished preset or layer is\n * dropped. Stale state degrades silently; it never crashes the picker.\n */\nexport const pruneStoredState = (\n state: StoredKaleidoscopeState,\n book: KaleidoscopePresetBook,\n): StoredKaleidoscopeState => {\n const presetId = state.presetId !== null && state.presetId in book ? state.presetId : null;\n const patches: Record<string, StoredPatchMap> = {};\n for (const [id, map] of Object.entries(state.patches)) {\n if (!(id in book)) continue;\n const tunable = tunableLayerIds(book, id);\n const kept: Record<string, StoredLayerUniforms> = {};\n for (const [layerId, uniforms] of Object.entries(map)) {\n if (tunable.has(layerId)) kept[layerId] = uniforms;\n }\n if (Object.keys(kept).length > 0) patches[id] = kept;\n }\n return { version: 1, presetId, mask: state.mask, patches };\n};\n\n/** Merge one live patch into a preset's stored overrides (immutably). */\nexport const mergePatch = (\n patches: StoredPatches,\n presetId: string,\n patch: StoredPatch,\n): StoredPatches => ({\n ...patches,\n [presetId]: {\n ...patches[presetId],\n [patch.id]: { ...patches[presetId]?.[patch.id], ...patch.uniforms },\n },\n});\n\n/**\n * Project a preset's stored overrides into the array shape the `kaleidoscope`\n * verb takes as `patches`.\n */\nexport const patchListFor = (\n patches: StoredPatches,\n presetId: string,\n): ReadonlyArray<StoredPatch> =>\n Object.entries(patches[presetId] ?? {}).map(([id, uniforms]) => ({ id, uniforms }));\n"]}
@@ -5,6 +5,10 @@ export declare const COMPOSITE_IMAGE_FRAG_SRC = "#version 300 es\nprecision high
5
5
  export declare const COMPOSITE_SUBJECT_FRAG_SRC = "#version 300 es\nprecision highp float;\nuniform sampler2D uCamera;\nuniform sampler2D uMask;\nuniform vec2 uMaskUvScale;\nuniform vec2 uMaskUvOffset;\nuniform float uMaskLo;\nuniform float uMaskHi;\nin highp vec2 vUv;\nout vec4 oColor;\nvoid main() {\n vec3 cam = texture(uCamera, vUv).rgb;\n float raw = texture(uMask, vUv * uMaskUvScale + uMaskUvOffset).r;\n float safeHi = max(uMaskHi, uMaskLo + 0.001);\n float a = clamp(smoothstep(uMaskLo, safeHi, raw), 0.0, 1.0);\n oColor = vec4(cam * a, a);\n}\n";
6
6
  export declare const COMPOSITE_MASKED_FRAG_SRC = "#version 300 es\nprecision highp float;\nuniform sampler2D uTex;\nuniform sampler2D uMask;\nuniform vec2 uMaskUvScale;\nuniform vec2 uMaskUvOffset;\nuniform float uMaskLo;\nuniform float uMaskHi;\nin highp vec2 vUv;\nout vec4 oColor;\nvoid main() {\n vec4 c = texture(uTex, vUv);\n float raw = texture(uMask, vUv * uMaskUvScale + uMaskUvOffset).r;\n float safeHi = max(uMaskHi, uMaskLo + 0.001);\n float a = clamp(smoothstep(uMaskLo, safeHi, raw), 0.0, 1.0);\n oColor = c * a;\n}\n";
7
7
  export declare const PLASMA_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing; range [0, inf)\nuniform vec2 uResolution; // framebuffer size in pixels; both components > 0\nuniform vec3 uColorA; // first palette color, linear-ish RGB in [0, 1]\nuniform vec3 uColorB; // second palette color, linear-ish RGB in [0, 1]\nuniform float uSpeed; // animation rate multiplier; 0 freezes the field\nuniform float uScale; // spatial frequency; higher = more, tighter cells\n\nin highp vec2 vUv;\nout vec4 oColor;\n\nvoid main() {\n // Aspect-correct, screen-centered coordinates (matches nebula.frag): divide\n // by the height so uScale reads the same regardless of aspect ratio.\n vec2 fragCoord = vUv * uResolution;\n vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y;\n\n float t = uTime * uSpeed;\n\n // Classic demoscene plasma: a few sines of position and time. The radial\n // term (length(uv)) gives the field an organic, non-grid-aligned drift.\n float v = sin(uv.x * uScale + t);\n v += sin(uv.y * uScale + t * 0.8);\n v += sin((uv.x + uv.y) * uScale * 0.7 + t * 1.3);\n v += sin(length(uv) * uScale * 1.2 - t);\n\n // v ranges roughly [-4, 4]; fold through sin to a smooth [0, 1] mix factor.\n float mixT = 0.5 + 0.5 * sin(v);\n\n // Opaque procedural background; the person is composited over it downstream.\n oColor = vec4(mix(uColorA, uColorB, mixT), 1.0);\n}\n";
8
+ export declare const KALEIDOSCOPE_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing; range [0, inf)\nuniform vec2 uResolution; // framebuffer size in pixels; both components > 0\nuniform vec3 uColorA; // base palette color (also the calm midpoint pole)\nuniform vec3 uColorB; // second palette color\nuniform vec3 uColorC; // accent color, layered over the A/B field\nuniform float uSegments; // mirror segment count; floor()ed, clamped >= 3\nuniform float uSpeed; // source-field drift rate; 0 freezes the pattern\nuniform float uRotate; // whole-field rotation rate; sign sets direction\nuniform float uZoom; // pattern scale; higher = more rings of detail\nuniform float uCalm; // 0..1 eases contrast at frame center (face zone)\n\nin highp vec2 vUv;\nout vec4 oColor;\n\nconst float TAU = 6.28318530718;\n\nvoid main() {\n // Aspect-correct, screen-centered coordinates (matches plasma/nebula).\n vec2 fragCoord = vUv * uResolution;\n vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y;\n float centerDist = length(uv);\n\n // Whole-field rotation: the slow \"turning the scope\" motion.\n float ra = uTime * uRotate;\n float cs = cos(ra);\n float sn = sin(ra);\n uv = mat2(cs, -sn, sn, cs) * uv;\n\n // Mirrored polar fold. The 1e-5 nudge keeps atan() off the undefined (0,0)\n // input under Metal; it is far below one pixel at any resolution.\n float r = centerDist * uZoom * (1.0 + 0.06 * sin(uTime * 0.23));\n float seg = TAU / max(3.0, floor(uSegments));\n float a = atan(uv.y, uv.x + 1e-5);\n a = mod(a, seg);\n a = abs(a - seg * 0.5);\n vec2 p = r * vec2(cos(a), sin(a));\n\n float t = uTime * uSpeed;\n\n // Drifting source field, plasma-class: a few sines of folded position and\n // time. The off-axis moving center in the length() term keeps the pattern\n // evolving (non-repeating) rather than pulsing in place.\n float f1 = sin(p.x * 6.0 + t)\n + sin((p.x + p.y) * 4.2 - t * 0.7)\n + sin(length(p - vec2(0.9 + 0.25 * sin(t * 0.31), 0.0)) * 7.0 + t * 1.1);\n float f2 = sin(p.y * 5.0 - t * 0.9 + sin(p.x * 3.1 + t * 0.4));\n float m1 = 0.5 + 0.5 * sin(f1);\n float m2 = smoothstep(0.25, 0.9, 0.5 + 0.5 * sin(f2 + f1 * 0.5));\n\n vec3 color = mix(uColorA, uColorB, m1);\n color = mix(color, uColorC, m2 * 0.65);\n\n // Thin darkening along both mirror lines sells the cut-glass facets.\n float seam = smoothstep(0.035, 0.0, abs(a - seg * 0.5)) + smoothstep(0.035, 0.0, a);\n color *= 1.0 - 0.18 * seam;\n\n // uCalm: ease toward the palette midpoint near frame center. Spatial-only\n // (never scales time per pixel, which would shear the field across the\n // falloff ring).\n vec3 mid = 0.5 * (uColorA + uColorB);\n float calm = uCalm * (1.0 - smoothstep(0.15, 0.62, centerDist));\n color = mix(color, mid, calm * 0.6);\n\n // Opaque procedural background; the person is composited over it downstream.\n oColor = vec4(color, 1.0);\n}\n";
9
+ export declare const NEO_MEMPHIS_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing; range [0, inf)\nuniform vec2 uResolution; // framebuffer size in pixels; both components > 0\nuniform vec3 uBgColor; // field color behind the shapes\nuniform vec3 uColorA; // shape palette color 1\nuniform vec3 uColorB; // shape palette color 2\nuniform vec3 uColorC; // shape palette color 3\nuniform float uScale; // hero-grid cells across frame height\nuniform float uDensity; // probability a cell draws its shape, 0..1\nuniform float uOutline; // probability a shape renders outlined, 0..1\nuniform float uDrift; // scroll + rotation rate; 0 freezes\nuniform float uCalm; // 0..1 fades shapes near frame center (face zone)\n\nin highp vec2 vUv;\nout vec4 oColor;\n\nconst float TAU = 6.28318530718;\n// Antialias half-width in cell units; ~1px at the default pitch.\nconst float AA = 0.012;\n\nfloat hash21(vec2 p) {\n p = fract(p * vec2(234.34, 435.345));\n p += dot(p, p + 34.23);\n return fract(p.x * p.y);\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p) - b;\n return length(max(d, vec2(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\n// iq's equilateral triangle, point up, circumradius r.\nfloat sdTriangle(vec2 p, float r) {\n const float k = 1.7320508;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2(p.x - k * p.y, -k * p.x - p.y) * 0.5;\n }\n p.x -= clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\n// One cell layer: returns the shape coverage and writes its color.\n// luv is the layer's scrolled cell-space coordinate; backfill restricts the\n// shape menu to dots and crosses and draws smaller.\nfloat memphisCell(vec2 luv, float seed, float backfill, float t, out vec3 shapeColor) {\n vec2 id = floor(luv);\n vec2 gv = fract(luv) - 0.5;\n float h = hash21(id + seed);\n shapeColor = uBgColor;\n // Density gate: empty cells cost one hash.\n if (h > uDensity) return 0.0;\n\n float h2 = fract(h * 57.31);\n float h3 = fract(h * 113.77);\n float h4 = fract(h * 431.13);\n float h5 = fract(h * 891.71);\n\n // Per-cell slow spin and a small bob; both bounded so the shape stays\n // inside its cell (max extent 0.34 + 0.04 < 0.5).\n float ang = h2 * TAU + t * (h3 - 0.5) * 0.8;\n float cs = cos(ang);\n float sn = sin(ang);\n gv -= 0.04 * vec2(sin(t * 0.6 + h * TAU), cos(t * 0.8 + h * TAU));\n gv = mat2(cs, -sn, sn, cs) * gv;\n\n float r = mix(0.14, 0.30, h3) * mix(1.0, 0.6, backfill);\n float pick = h4 * 6.0;\n float d;\n if (backfill > 0.5) {\n // Backfill texture: dots and crosses only.\n d = (pick < 3.0)\n ? length(gv) - r * 0.45\n : min(sdBox(gv, vec2(r, r * 0.22)), sdBox(gv, vec2(r * 0.22, r)));\n } else if (pick < 1.0) {\n d = length(gv) - r; // disc\n } else if (pick < 2.0) {\n d = abs(length(gv) - r * 0.8) - r * 0.18; // ring\n } else if (pick < 3.0) {\n d = sdTriangle(gv, r); // triangle\n } else if (pick < 4.0) {\n d = min(sdBox(gv, vec2(r, r * 0.24)), sdBox(gv, vec2(r * 0.24, r))); // cross\n } else if (pick < 5.0) {\n d = sdBox(gv, vec2(r * 0.78, r * 0.78)); // box\n } else {\n // Squiggle: a sine-displaced band, clipped to its run length.\n d = max(abs(gv.y - 0.4 * r * sin(gv.x / r * 6.5)) - r * 0.17, abs(gv.x) - r);\n }\n\n float fill = smoothstep(AA, -AA, d);\n float ring = smoothstep(AA, -AA, abs(d + r * 0.06) - r * 0.09);\n float m = (h5 < uOutline) ? ring : fill;\n\n float colorPick = fract(h * 769.23) * 3.0;\n shapeColor = (colorPick < 1.0) ? uColorA : (colorPick < 2.0) ? uColorB : uColorC;\n return m;\n}\n\nvoid main() {\n // Aspect-correct, screen-centered coordinates (matches plasma/nebula).\n vec2 fragCoord = vUv * uResolution;\n vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y;\n float centerDist = length(uv);\n\n float t = uTime * uDrift;\n vec3 color = uBgColor;\n vec3 shapeColor;\n\n // Backfill layer first (under the hero shapes): smaller, denser, dimmer.\n vec2 luv1 = uv * uScale * 2.3 + vec2(t * 0.045, t * -0.03) + 51.7;\n float m1 = memphisCell(luv1, 7.0, 1.0, t, shapeColor);\n color = mix(color, mix(uBgColor, shapeColor, 0.55), m1);\n\n // Hero layer: the big shapes, scrolling the other way.\n vec2 luv0 = uv * uScale + vec2(t * -0.06, t * 0.04);\n float m0 = memphisCell(luv0, 0.0, 0.0, t, shapeColor);\n\n // uCalm: fade shapes (not the field) near frame center.\n float calm = 1.0 - uCalm * (1.0 - smoothstep(0.15, 0.62, centerDist));\n color = mix(color, shapeColor, m0 * calm);\n\n // Opaque procedural background; the person is composited over it downstream.\n oColor = vec4(color, 1.0);\n}\n";
10
+ export declare const HALFTONE_WAVES_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing; range [0, inf)\nuniform vec2 uResolution; // framebuffer size in pixels; both components > 0\nuniform vec3 uPaper; // field color (behind the dots)\nuniform vec3 uInk; // dot color\nuniform float uPitch; // dot-grid cells across frame height\nuniform float uDotSize; // base dot radius in cell units, 0..0.5\nuniform float uWaveAmp; // radius modulation depth, 0..1\nuniform float uSpeed; // wave travel rate; 0 freezes\nuniform float uShape; // dot shape: 0 diamond, 1 circle, 2 square\nuniform float uAngle; // wave direction, radians\nuniform float uCalm; // 0..1 eases the waves at frame center (face zone)\n\nin highp vec2 vUv;\nout vec4 oColor;\n\n// Antialias half-width in cell units; ~1px at the default pitch.\nconst float AA = 0.06;\n\nvoid main() {\n // Aspect-correct, screen-centered coordinates (matches plasma/nebula).\n vec2 fragCoord = vUv * uResolution;\n vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y;\n float centerDist = length(uv);\n\n vec2 luv = uv * uPitch;\n vec2 id = floor(luv);\n vec2 gv = fract(luv) - 0.5;\n // Wave phase is sampled at the CELL CENTER so a dot's radius is uniform\n // across its own pixels (true halftone, not a warped field).\n vec2 c = (id + 0.5) / uPitch;\n\n float t = uTime * uSpeed;\n vec2 dir1 = vec2(cos(uAngle), sin(uAngle));\n vec2 dir2 = vec2(cos(uAngle + 2.2), sin(uAngle + 2.2));\n // Two traveling waves at incommensurate frequencies: interference patterns\n // that drift forever without visibly repeating.\n float w = 0.5 + 0.25 * sin(dot(c, dir1) * 3.1 + t) + 0.25 * sin(dot(c, dir2) * 4.7 - t * 0.77);\n\n // uCalm: flatten the modulation toward its midpoint near frame center.\n float calm = uCalm * (1.0 - smoothstep(0.15, 0.62, centerDist));\n w = mix(w, 0.5, calm);\n\n float radius = uDotSize * mix(1.0 - uWaveAmp, 1.0 + uWaveAmp, w);\n\n // Blended distance metric, pow-free (variable-exponent pow lowers to\n // exp2+log2 on mobile): diamond (L1) -> circle (L2) -> square (Linf).\n vec2 q = abs(gv);\n float dDiamond = (q.x + q.y) * 0.7071;\n float dCircle = length(q);\n float dSquare = max(q.x, q.y);\n float d = (uShape < 1.0)\n ? mix(dDiamond, dCircle, clamp(uShape, 0.0, 1.0))\n : mix(dCircle, dSquare, clamp(uShape - 1.0, 0.0, 1.0));\n\n float m = smoothstep(radius + AA, radius - AA, d);\n vec3 color = mix(uPaper, uInk, m);\n\n // Opaque procedural background; the person is composited over it downstream.\n oColor = vec4(color, 1.0);\n}\n";
11
+ export declare const AURORA_SILK_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing; range [0, inf)\nuniform vec2 uResolution; // framebuffer size in pixels; both components > 0\nuniform vec3 uColorLow; // gradient color at the flow's low side\nuniform vec3 uColorHigh; // gradient color at the flow's high side\nuniform vec3 uRibbonColor; // ribbon tint; shades blend toward uColorHigh\nuniform float uRibbons; // visible ribbon count, 1..5 (MAX_RIBBONS)\nuniform float uSoftness; // ribbon edge softness, 0..1\nuniform float uAngle; // flow direction, radians\nuniform float uSpeed; // drift rate; 0 freezes\nuniform float uStyle; // 0 flat paper-cut .. 1 glowing silk\nuniform float uCalm; // 0..1 eases ribbons at frame center (face zone)\n\nin highp vec2 vUv;\nout vec4 oColor;\n\nconst int MAX_RIBBONS = 5;\n\nfloat hash11(float n) {\n return fract(sin(n) * 43758.5453123);\n}\n\n// 1D value noise: smooth, cheap, non-repeating drift source per ribbon.\nfloat vnoise(float x, float seed) {\n float i = floor(x);\n float f = fract(x);\n float a = hash11(i + seed);\n float b = hash11(i + 1.0 + seed);\n return mix(a, b, f * f * (3.0 - 2.0 * f));\n}\n\nvoid main() {\n // Aspect-correct, screen-centered coordinates (matches plasma/nebula).\n vec2 fragCoord = vUv * uResolution;\n vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y;\n float centerDist = length(uv);\n\n // Rotate into flow space: ribbons run along q.x, stack along q.y.\n float cs = cos(uAngle);\n float sn = sin(uAngle);\n vec2 q = mat2(cs, -sn, sn, cs) * uv;\n\n float t = uTime * uSpeed;\n\n // Base: soft two-stop gradient across the stacking axis, with a slow\n // breathing tilt so the field is alive even at uRibbons = 0 edge cases.\n float g = clamp(q.y * 0.85 + 0.5 + 0.04 * sin(t * 0.17), 0.0, 1.0);\n vec3 color = mix(uColorLow, uColorHigh, g);\n\n float ribbons = clamp(uRibbons, 0.0, float(MAX_RIBBONS));\n float calm = 1.0 - uCalm * (1.0 - smoothstep(0.15, 0.62, centerDist));\n\n for (int i = 0; i < MAX_RIBBONS; i++) {\n float fi = float(i);\n if (fi >= ribbons) break;\n\n // Stack centers across the frame, each with its own slow vertical sway.\n float center = -0.42 + 0.84 * (fi + 0.5) / ribbons + 0.07 * sin(t * 0.19 + fi * 1.7);\n // Lateral warp: low-frequency noise plus one sine, per-ribbon phase and\n // rate so the bands never move in lockstep.\n float warp = (vnoise(q.x * 1.4 + t * (0.1 + 0.04 * fi), fi * 17.0) - 0.5) * 0.5\n + 0.1 * sin(q.x * 2.3 + t * (0.26 + 0.06 * fi) + fi * 2.1);\n float dy = abs(q.y - (center + warp));\n\n float widthR = mix(0.06, 0.15, hash11(fi * 7.3 + 1.0));\n float soft = mix(0.008, widthR * 1.6, uSoftness);\n float band = (1.0 - smoothstep(widthR - soft, widthR + soft, dy)) * calm;\n\n // Ribbon shade: deeper tints at the back of the stack.\n vec3 rc = mix(uRibbonColor, uColorHigh, fi / float(MAX_RIBBONS) * 0.6);\n\n // uStyle blends two composites of the same band: flat paint-over vs\n // additive glow.\n vec3 flat_ = mix(color, rc, band * 0.85);\n vec3 glow = color + rc * band * 0.4;\n color = mix(flat_, glow, uStyle);\n }\n\n // Opaque procedural background; the person is composited over it downstream.\n oColor = vec4(color, 1.0);\n}\n";
8
12
  export declare const CLOUDS_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime;\nuniform vec2 uResolution;\nuniform vec3 uSkyLowColor;\nuniform vec3 uSkyHighColor;\nuniform vec3 uCloudLightColor;\nuniform vec3 uCloudDarkColor;\nuniform float uExposure;\nuniform float uStepSize;\nuniform float uCloudSpeed;\nuniform float uCloudScale;\nuniform float uDensity;\nuniform float uCoverage;\nuniform float uSoftness;\n\nin highp vec2 vUv;\nout vec4 oColor;\n\n// STEPS must stay a compile-time constant (GLSL ES loop bound).\n// 32 (was 48; issue #37): the distance-growing step in main() keeps the\n// marched range, so fewer steps buys speed instead of clipping the horizon.\n#define STEPS 32\n\nfloat hash(vec3 p) {\n p = fract(p * 0.3183099 + 0.1);\n p *= 17.0;\n return fract(p.x * p.y * p.z * (p.x + p.y + p.z));\n}\n\nfloat rand(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);\n}\n\nfloat noise(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(\n mix(hash(i + vec3(0,0,0)), hash(i + vec3(1,0,0)), f.x),\n mix(hash(i + vec3(0,1,0)), hash(i + vec3(1,1,0)), f.x),\n f.y),\n mix(\n mix(hash(i + vec3(0,0,1)), hash(i + vec3(1,0,1)), f.x),\n mix(hash(i + vec3(0,1,1)), hash(i + vec3(1,1,1)), f.x),\n f.y),\n f.z);\n}\n\n// 4 octaves (was 5; issue #37): the 5th octave is fine wisp detail the\n// smoothstep(uCoverage, uCoverage + uSoftness, n) threshold mostly eats; each\n// octave is 8 hash() calls per sample, so this is a flat -20% on the march.\nfloat fbm(vec3 p) {\n float v = 0.0;\n float a = 0.5;\n for (int i = 0; i < 4; i++) {\n v += a * noise(p);\n p *= 2.03;\n a *= 0.5;\n }\n return v;\n}\n\nfloat cloudDensity(vec3 p) {\n p += vec3(uTime * uCloudSpeed, 0.0, uTime * uCloudSpeed * 0.35);\n // Outside the slab the height mask is 0, so the sample is 0; bail before fbm.\n if (p.y <= 0.0 || p.y >= 3.0) return 0.0;\n float n = fbm(p * uCloudScale);\n float bottom = smoothstep(0.0, 0.7, p.y);\n float top = smoothstep(3.0, 1.2, p.y);\n float heightMask = bottom * top;\n float cloud = smoothstep(uCoverage, uCoverage + uSoftness, n);\n return cloud * heightMask;\n}\n\nvoid main() {\n vec2 fragCoord = vUv * uResolution;\n vec2 uv = (fragCoord - 0.5 * uResolution) / uResolution.y;\n vec3 ro = vec3(0.0, 1.2, -4.0);\n vec3 rd = normalize(vec3(uv, 1.5));\n float skyGradient = clamp(rd.y * 0.5 + 0.5, 0.0, 1.0);\n vec3 skyColor = mix(uSkyLowColor, uSkyHighColor, skyGradient);\n vec3 accum = vec3(0.0);\n float alpha = 0.0;\n float t = rand(fragCoord) * uStepSize;\n for (int i = 0; i < STEPS; i++) {\n vec3 p = ro + rd * t;\n // The slab is crossed monotonically in t; once past it, all samples are 0.\n if (rd.y > 0.0 && p.y >= 3.0) break;\n if (rd.y < 0.0 && p.y <= 0.0) break;\n float d = cloudDensity(p);\n // Distance-growing step (issue #37): far clouds are small on screen and\n // tolerate coarser sampling, so the step stretches with t. 32 growing\n // steps reach slightly past where 48 uniform steps did, spending the\n // samples up close where banding would show. growth also scales the\n // per-sample opacity so optical depth per unit distance stays consistent\n // with the uniform-step tuning the presets were dialed against.\n float growth = 1.0 + t * 0.15;\n if (d > 0.01) {\n float light = smoothstep(0.4, 2.8, p.y);\n vec3 sampleColor = mix(uCloudDarkColor, uCloudLightColor, light);\n float a = min(d * uDensity * growth, 1.0);\n accum += (1.0 - alpha) * sampleColor * a;\n alpha += (1.0 - alpha) * a;\n }\n t += uStepSize * growth;\n if (alpha > 0.95) break;\n }\n vec3 color = mix(skyColor, accum, alpha);\n color *= uExposure;\n color = pow(color, vec3(0.9));\n oColor = vec4(color, 1.0);\n}\n";
9
13
  export declare const NEBULA_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing; range [0, inf)\nuniform vec2 uResolution; // framebuffer size in pixels; both components > 0\nuniform vec3 uColor; // overall tint / color grade; [1,1,1] = untinted\nuniform float uBrightness; // final glow multiplier; 1.0 = stock\nuniform float uSpeed; // drift + rotation rate; 1.0 = stock, 0 freezes\nuniform float uTwinkleSpeed; // star color-cycle rate; 1.0 = stock\nuniform float uScale; // starfield zoom / density; >1 = more, smaller stars\nuniform float uStarGlow; // star-core size; 1.0 = stock\n\nin highp vec2 vUv;\nout vec4 oColor;\n\nconst float PI = 3.14159265;\nconst float MIN_DIVIDE = 64.0;\nconst float MAX_DIVIDE = 0.01;\n// Number of stacked starfield layers. Compile-time constant so the layer\n// loop has a fixed integer bound (cross-compile-safe; no float loop counter).\n// 8 (was 12) for low-end-mobile cost (issue #39); the work is linear in the\n// count and dimByDensity rebalances per-star brightness automatically.\nconst int STARFIELD_LAYERS_COUNT = 8;\n\nmat2 Rotate(float angle) {\n float s = sin(angle);\n float c = cos(angle);\n return mat2(c, -s, s, c);\n}\n\nfloat Star(vec2 uv, float flaresize, float rotAngle, float randomN) {\n float d = length(uv);\n // The concentric fade at the bottom is exactly 0 for d >= 1.0; the star is\n // invisible there, so skip everything (issue #39: a large share of the 3x3\n // neighbor sweep lands outside this radius; the cull is output-identical).\n if (d >= 1.0) return 0.0;\n // Star core. Guard the division: length(uv) can be exactly 0 at a cell\n // center, which yields inf/NaN under Metal. max(d, 1e-4) caps the core\n // brightness without visibly changing the look (the concentric\n // smoothstep fade below already clamps it).\n float starcore = 0.05 * uStarGlow / max(d, 1e-4);\n // Flares exist only on the brightest stars: flaresize is exactly 0 below the\n // smoothstep(0.9, 1.0, size) knee (~90% of cells), and both Rotates feed\n // nothing but the flares. Skipping the block is output-identical, and\n // flaresize is constant per cell, so the branch is coherent (issue #39).\n if (flaresize > 0.0) {\n uv *= Rotate(-2.0 * PI * rotAngle);\n float flareMax = 1.0;\n\n // flares\n float starflares = max(0.0, flareMax - abs(uv.x * uv.y * 3000.0));\n starcore += starflares * flaresize;\n uv *= Rotate(PI * 0.25);\n starflares = max(0.0, flareMax - abs(uv.x * uv.y * 3000.0));\n starcore += starflares * 0.3 * flaresize;\n }\n // light can't go forever, fade it concentrically.\n starcore *= smoothstep(1.0, 0.05, d);\n return starcore;\n}\n\nfloat PseudoRandomizer(vec2 p) {\n // not really random, but it looks random.\n p = fract(p * vec2(123.45, 345.67));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nvec3 StarFieldLayer(vec2 uv, float rotAngle) {\n vec3 col = vec3(0.0);\n\n vec2 gv = fract(uv) - 0.5;\n vec2 id = floor(uv);\n\n float deltaTimeTwinkle = uTime * 0.35 * uTwinkleSpeed;\n\n // sweep the 8 neighbors plus the home cell so stars are not clipped at\n // cell borders. Constant 3x3 bounds.\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 offset = vec2(float(x), float(y));\n\n float randomN = PseudoRandomizer(id + offset); // 0..1\n float randoX = randomN - 0.5;\n float randoY = fract(randomN * 45.0) - 0.5;\n vec2 randomPosition = gv - offset - vec2(randoX, randoY);\n // fract trick: random sizes\n float size = fract(randomN * 1356.33);\n float flareSwitch = smoothstep(0.9, 1.0, size);\n float star = Star(randomPosition, flareSwitch, rotAngle, randomN);\n\n // fract trick: random colors\n float randomStarColorSeed = fract(randomN * 2150.0) * (3.0 * PI) * deltaTimeTwinkle;\n vec3 color = sin(vec3(0.7, 0.3, 0.9) * randomStarColorSeed);\n\n // compress\n color = color * (0.4 * sin(deltaTimeTwinkle)) + 0.6;\n // filter\n color = color * vec3(1.0, 0.1, 0.9 + size);\n float dimByDensity = 15.0 / float(STARFIELD_LAYERS_COUNT);\n col += star * size * color * dimByDensity;\n }\n }\n\n return col;\n}\n\nvoid main() {\n // ShaderToy fragCoord, reconstructed from vUv (see header).\n vec2 fragCoord = vUv * uResolution;\n\n // Normalized pixel coordinates centered at screen middle.\n vec2 uv = (fragCoord - 0.5 * uResolution.xy) / uResolution.y;\n\n float deltaTime = uTime * 0.01 * uSpeed;\n\n vec3 col = vec3(0.0);\n\n float rotAngle = deltaTime * 0.09;\n\n // Layer accumulation. Integer-counted loop replacing the original\n // `for (float i = 0.0; i < 1.0; i += 1.0/COUNT)`. With n in [0, COUNT),\n // i = n/COUNT reproduces the exact same {0, 1/N, 2/N, ...} sequence and\n // the same iteration count, so visual output is unchanged; only the loop\n // form is cross-compile-safe.\n for (int n = 0; n < STARFIELD_LAYERS_COUNT; n++) {\n float i = float(n) / float(STARFIELD_LAYERS_COUNT);\n float layerDepth = fract(i + deltaTime);\n float layerScale = mix(MIN_DIVIDE, MAX_DIVIDE, layerDepth);\n float layerFader = layerDepth * smoothstep(0.1, 1.1, layerDepth);\n float layerOffset = i * (3430.0 + fract(i));\n mat2 layerRot = Rotate(rotAngle * i * -10.0);\n uv *= layerRot;\n vec2 starfieldUv = uv * layerScale * uScale + layerOffset;\n col += StarFieldLayer(starfieldUv, rotAngle) * layerFader;\n }\n\n // Glow + color grade, then opaque procedural background.\n col *= uBrightness * uColor;\n oColor = vec4(col, 1.0);\n}\n";
10
14
  export declare const GODRAYS_FRAG_SRC = "#version 300 es\nprecision highp float;\n\nuniform float uTime; // seconds, monotonically increasing\nuniform vec2 uResolution; // framebuffer size in pixels\nuniform vec3 uLightColor; // ray tint (linear-ish RGB, 0..1)\nuniform float uRayCount; // number of ray bands\nuniform float uRaySpeed; // drift speed\nuniform float uRayIntensity; // overall brightness / additive strength\nuniform float uRaySoftness; // edge falloff exponent (higher = crisper shafts)\nuniform float uTopGlow; // extra glow concentrated near the top\nuniform float uFadeDistance; // vertical falloff from the top\nuniform float uWobbleAmount; // horizontal wobble magnitude\nuniform float uWobbleSpeed; // wobble animation speed\n\nin highp vec2 vUv;\nout vec4 oColor;\n\nfloat hash(float n) {\n return fract(sin(n) * 43758.5453123);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n\n f = f * f * (3.0 - 2.0 * f);\n\n float a = hash(i.x + i.y * 57.0);\n float b = hash(i.x + 1.0 + i.y * 57.0);\n float c = hash(i.x + (i.y + 1.0) * 57.0);\n float d = hash(i.x + 1.0 + (i.y + 1.0) * 57.0);\n\n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\n\nvoid main() {\n // vUv is already 0..1 with bottom-left origin; this is the Shadertoy `uv`.\n vec2 uv = vUv;\n\n float aspect = uResolution.x / uResolution.y;\n vec2 p = uv;\n p.x = (p.x - 0.5) * aspect + 0.5;\n\n float t = uTime;\n float fromTop = 1.0 - uv.y;\n\n float verticalFade = exp(-fromTop * uFadeDistance);\n float topGlow = exp(-fromTop * 8.0) * uTopGlow;\n\n float wobble =\n (noise(vec2(uv.y * 3.0, t * uWobbleSpeed)) - 0.5) * uWobbleAmount;\n\n float rayCoord = (p.x + wobble) * uRayCount;\n\n float raysA = sin(rayCoord + t * uRaySpeed);\n float raysB = sin(rayCoord * 1.73 - t * uRaySpeed * 0.7);\n\n float rays = raysA * 0.65 + raysB * 0.35;\n rays = rays * 0.5 + 0.5;\n rays = pow(rays, uRaySoftness);\n\n float shimmer = noise(vec2(uv.x * 10.0, uv.y * 4.0 - t * 0.3));\n rays *= mix(0.75, 1.25, shimmer);\n\n float alpha = rays * verticalFade * uRayIntensity;\n alpha += topGlow * uRayIntensity;\n alpha = clamp(alpha, 0.0, 1.0);\n\n // Premultiplied additive output: rgb already scaled by alpha.\n vec3 rayColor = uLightColor * alpha;\n oColor = vec4(rayColor, alpha);\n}\n";
@@ -1 +1 @@
1
- {"version":3,"file":"shaders.generated.d.ts","sourceRoot":"","sources":["../../web-driver/shaders.generated.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,0NAQhC,CAAC;AAEF,eAAO,MAAM,yBAAyB,oLAQrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,6oBAwBnC,CAAC;AAEF,eAAO,MAAM,wBAAwB,2QAWpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,kgBAiBtC,CAAC;AAEF,eAAO,MAAM,yBAAyB,2eAiBrC,CAAC;AAE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