@chuzi/shared 1.3.35 → 1.3.37

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/realms/cosmos/index.ts"],"names":[],"mappings":";AAoBA,IAAM,gBAAA,GAA2C;AAAA,EAC/C,KAAA,EAAO,EAAA;AAAA,EACP,QAAA,EAAU,GAAA;AAAA,EACV,MAAA,EAAQ,CAAA;AAAA,EACR,MAAA,EAAQ,EAAA;AAAA,EACR,OAAA,EAAS,GAAA;AAAA,EACT,KAAA,EAAO,GAAA;AAAA,EACP,WAAA,EAAa,GAAA;AAAA,EACb,SAAA,EAAW;AACb,CAAA;AAEA,IAAM,QAAA,GAAmC;AAAA,EACvC,MAAA,EAAQ,EAAA;AAAA,EACR,IAAA,EAAM,EAAA;AAAA,EACN,WAAA,EAAa,GAAA;AAAA,EACb,MAAA,EAAQ,GAAA;AAAA,EACR,KAAA,EAAO,GAAA;AAAA,EACP,OAAA,EAAS,GAAA;AAAA,EACT,UAAA,EAAY;AACd,CAAA;AAEA,SAAS,QAAQ,CAAA,EAAmB;AAClC,EAAA,OAAO,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,CAAC,CAAC,CAAA;AACnC;AAEA,SAAS,sBAAsB,IAAA,EAA6B;AAE1D,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,KAAK,kBAAkB,CAAA;AACnD,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,OAAO,CAAA;AAElC,EAAA,OAAO,OAAA,CAAQ,MAAM,CAAC,CAAA;AACxB;AAEA,SAAS,YAAY,IAAA,EAA6B;AAGhD,EAAA,MAAM,MAAA,GAAS,KAAK,YAAA,IAAgB,CAAA;AACpC,EAAA,OAAO,QAAQ,IAAA,GAAO,IAAA,CAAK,MAAM,CAAA,GAAI,MAAM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A;AAAA,EACZ,YAAA,EAAc,2BAAA;AAAA,EACd,UAAA,EAAY;AACd","file":"index.js","sourcesContent":["import type { StoryListItem } from \"../../types/index.js\";\nimport type { AtomMapping, AtomState, AudioPalette, MotionTokens } from \"../index.js\";\n\n/**\n * COSMOS realm — pure-data layer. The 3D components (World, Star, NavRig,\n * EngageTransition) live in a follow-up package once the JSX build is\n * wired up; this file owns the realm's mapping and tuning constants so\n * they can be consumed today by any non-3D surface (catalog list, search,\n * preview cards, sound design tooling).\n *\n * Mapping rationale:\n * runtime → scale (longer film = bigger star)\n * popularity → intensity (more watches = brighter)\n * mood → hue (warm/cool palette by tone)\n * genre → spectral hint (small offset on top of mood, reads as\n * \"stellar class\" — drama is yellow-G,\n * thriller is blue-O, romance is red-M).\n * state → orbit-ring rendering (handled by Atom component).\n */\n\nconst GENRE_HUE_OFFSET: Record<string, number> = {\n drama: 50,\n thriller: 220,\n horror: 0,\n comedy: 35,\n romance: 340,\n scifi: 200,\n documentary: 180,\n animation: 280,\n};\n\nconst MOOD_HUE: Record<string, number> = {\n bright: 50,\n warm: 25,\n bittersweet: 290,\n somber: 230,\n tense: 210,\n playful: 110,\n melancholy: 250,\n};\n\nfunction clamp01(n: number): number {\n return Math.max(0, Math.min(1, n));\n}\n\nfunction popularityToIntensity(film: StoryListItem): number {\n // Log-compress: a 100x more-watched film should not be 100x brighter.\n const watches = Math.max(0, film.watch_starts_count);\n const log = Math.log10(1 + watches);\n // Rough cap at ~6 (1M watches saturates the scale).\n return clamp01(log / 6);\n}\n\nfunction deriveScale(film: StoryListItem): number {\n // We don't have runtime in StoryListItem yet; proxy with scenes_count.\n // Caps the starfield from going visually noisy.\n const scenes = film.scenes_count ?? 1;\n return clamp01(0.25 + Math.log10(1 + scenes) / 4);\n}\n\nfunction deriveHue(film: StoryListItem): number {\n const genreKey = (film.genre ?? \"\").toLowerCase().replace(/[^a-z]/g, \"\");\n const moodKey = \"\";\n const moodHue = MOOD_HUE[moodKey];\n const genreOffset = GENRE_HUE_OFFSET[genreKey];\n if (moodHue !== undefined) return moodHue;\n if (genreOffset !== undefined) return genreOffset;\n return 210;\n}\n\nfunction deriveState(film: StoryListItem): AtomState {\n // Without per-user progress threaded through, default; the consuming\n // app will overlay state from CatalogResponse.meta.progress.\n return film.published ? \"default\" : \"new\";\n}\n\nexport const cosmosMapping: AtomMapping = (film) => ({\n position: [0, 0, 0], // assigned by the realm's spatial layouter\n scale: deriveScale(film),\n hue: deriveHue(film),\n intensity: popularityToIntensity(film),\n state: deriveState(film),\n metadata: {\n title: film.title,\n popularity: film.watch_starts_count,\n genre: film.genre,\n },\n});\n\nexport const cosmosMotion: MotionTokens = {\n flightAcceleration: 14,\n flightDamping: 0.92,\n focusEaseMs: 380,\n engageDurationMs: 900,\n backDurationMs: 900,\n};\n\nexport const cosmosAudio: AudioPalette = {\n // Asset paths are resolved by the host app's asset bundler; chuzi-shared\n // only declares the contract. Replace with CDN URLs at integration time.\n ambientLoop: \"audio/cosmos/ambient-deep.ogg\",\n focusChime: \"audio/cosmos/focus-shimmer.ogg\",\n engageImpact: \"audio/cosmos/dolly-in.ogg\",\n backWhoosh: \"audio/cosmos/dolly-out.ogg\",\n};\n"]}
1
+ {"version":3,"sources":["../../../src/realms/cosmos/appearance.ts","../../../src/realms/cosmos/index.ts"],"names":[],"mappings":";AAqCO,IAAM,gCAAA,GAA4D;AAAA,EACvE,aAAA,EAAe,EAAA;AAAA,EACf,YAAA,EAAc,IAAA;AAAA,EACd,UAAA,EAAY,SAAA;AAAA,EACZ,kBAAA,EAAoB,CAAA;AAAA,EACpB,YAAA,EAAc,EAAA;AAAA,EACd,mBAAA,EAAqB,EAAA;AAAA,EACrB,eAAA,EAAiB,CAAC,CAAA,EAAG,CAAC,CAAA;AAAA,EAEtB,YAAA,EAAc,GAAA;AAAA,EACd,aAAA,EAAe,EAAA;AAAA,EACf,cAAA,EAAgB,GAAA;AAAA,EAChB,aAAA,EAAe,EAAA;AAAA,EACf,kBAAA,EAAoB,G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oB,EAAA;AAAA,EACpB,aAAA,EAAe,IAAA;AAAA,EACf,WAAA,EAAa,GAAA;AAAA,EACb,gBAAA,EAAkB,GAAA;AAAA,EAClB,cAAA,EAAgB;AAClB;AAQO,IAAM,WAAA,GAA4B;AAAA;AAAA;AAAA,EAGvC,WAAA,EAAa,+BAAA;AAAA,EACb,UAAA,EAAY,gCAAA;AAAA,EACZ,YAAA,EAAc,2BAAA;AAAA,EACd,UAAA,EAAY;AACd","file":"index.js","sourcesContent":["/**\n * Constellation presentation tokens — consumed by the cosmos realm camera,\n * star billboards, and ghost title typography. Admins can override via\n * saved experience / appearance templates.\n */\nexport interface ConstellationAppearance {\n /** Rainbow arc title above the constellation (SVG px). */\n titleFontSize: number;\n titleOpacity: number;\n titleColor: string;\n titleLetterSpacing: number;\n /** World-space lift above constellation center. */\n titleYOffset: number;\n /** Html distance factor for the arc title billboard. */\n titleDistanceFactor: number;\n /** DOM z-index ceiling for constellation Html overlays (keep below editor). */\n htmlZIndexRange: [number, number];\n\n /** Per-star preview card + label. */\n previewWidth: number;\n previewHeight: number;\n previewOffsetY: number;\n labelFontSize: number;\n labelLetterSpacing: number;\n labelGap: number;\n /** Reserved space below preview for the 2×2 HUD control grid (px). */\n controlsGridHeight: number;\n billboardDistanceFactor: number;\n\n /** Camera — floating-in-space slide between stars. */\n cameraDefaultOffset: [number, number, number];\n cameraTargetOffset: [number, number, number];\n /** 0–1 lerp factor per frame while gliding (lower = smoother / pressurized). */\n cameraSlideLerp: number;\n cameraArrivalThreshold: number;\n}\n\nexport const DEFAULT_CONSTELLATION_APPEARANCE: ConstellationAppearance = {\n titleFontSize: 15,\n titleOpacity: 0.48,\n titleColor: \"#e8f0ff\",\n titleLetterSpacing: 4,\n titleYOffset: 14,\n titleDistanceFactor: 18,\n htmlZIndexRange: [8, 0],\n\n previewWidth: 148,\n previewHeight: 96,\n previewOffsetY: 2.4,\n labelFontSize: 13,\n labelLetterSpacing: 1.2,\n labelGap: 14,\n controlsGridHeight: 92,\n billboardDistanceFactor: 10,\n\n cameraDefaultOffset: [0, 4, 12],\n cameraTargetOffset: [0, 0, 0],\n cameraSlideLerp: 0.035,\n cameraArrivalThreshold: 0.08,\n};\n\nexport function mergeConstellationAppearance(\n overrides?: Partial<ConstellationAppearance>,\n): ConstellationAppearance {\n return { ...DEFAULT_CONSTELLATION_APPEARANCE, ...overrides };\n}\n","import type { StoryListItem } from \"../../types/index.js\";\nimport type { AtomMapping, AtomState, AudioPalette, MotionTokens } from \"../index.js\";\n\n/**\n * COSMOS realm — pure-data layer. The 3D components (World, Star, NavRig,\n * EngageTransition) live in a follow-up package once the JSX build is\n * wired up; this file owns the realm's mapping and tuning constants so\n * they can be consumed today by any non-3D surface (catalog list, search,\n * preview cards, sound design tooling).\n *\n * Mapping rationale:\n * runtime → scale (longer film = bigger star)\n * popularity → intensity (more watches = brighter)\n * mood → hue (warm/cool palette by tone)\n * genre → spectral hint (small offset on top of mood, reads as\n * \"stellar class\" — drama is yellow-G,\n * thriller is blue-O, romance is red-M).\n * state → orbit-ring rendering (handled by Atom component).\n */\n\nconst GENRE_HUE_OFFSET: Record<string, number> = {\n drama: 50,\n thriller: 220,\n horror: 0,\n comedy: 35,\n romance: 340,\n scifi: 200,\n documentary: 180,\n animation: 280,\n};\n\nconst MOOD_HUE: Record<string, number> = {\n bright: 50,\n warm: 25,\n bittersweet: 290,\n somber: 230,\n tense: 210,\n playful: 110,\n melancholy: 250,\n};\n\nfunction clamp01(n: number): number {\n return Math.max(0, Math.min(1, n));\n}\n\nfunction popularityToIntensity(film: StoryListItem): number {\n // Log-compress: a 100x more-watched film should not be 100x brighter.\n const watches = Math.max(0, film.watch_starts_count);\n const log = Math.log10(1 + watches);\n // Rough cap at ~6 (1M watches saturates the scale).\n return clamp01(log / 6);\n}\n\nfunction deriveScale(film: StoryListItem): number {\n // We don't have runtime in StoryListItem yet; proxy with scenes_count.\n // Caps the starfield from going visually noisy.\n const scenes = film.scenes_count ?? 1;\n return clamp01(0.25 + Math.log10(1 + scenes) / 4);\n}\n\nfunction deriveHue(film: StoryListItem): number {\n const genreKey = (film.genre ?? \"\").toLowerCase().replace(/[^a-z]/g, \"\");\n const moodKey = \"\";\n const moodHue = MOOD_HUE[moodKey];\n const genreOffset = GENRE_HUE_OFFSET[genreKey];\n if (moodHue !== undefined) return moodHue;\n if (genreOffset !== undefined) return genreOffset;\n return 210;\n}\n\nfunction deriveState(film: StoryListItem): AtomState {\n // Without per-user progress threaded through, default; the consuming\n // app will overlay state from CatalogResponse.meta.progress.\n return film.published ? \"default\" : \"new\";\n}\n\nexport const cosmosMapping: AtomMapping = (film) => ({\n position: [0, 0, 0], // assigned by the realm's spatial layouter\n scale: deriveScale(film),\n hue: deriveHue(film),\n intensity: popularityToIntensity(film),\n state: deriveState(film),\n metadata: {\n title: film.title,\n popularity: film.watch_starts_count,\n genre: film.genre,\n },\n});\n\nexport const cosmosMotion: MotionTokens = {\n flightAcceleration: 14,\n flightDamping: 0.92,\n focusEaseMs: 380,\n engageDurationMs: 900,\n backDurationMs: 900,\n};\n\nexport {\n DEFAULT_CONSTELLATION_APPEARANCE,\n mergeConstellationAppearance,\n} from \"./appearance.js\";\nexport type { ConstellationAppearance } from \"./appearance.js\";\n\nexport const cosmosAudio: AudioPalette = {\n // Asset paths are resolved by the host app's asset bundler; chuzi-shared\n // only declares the contract. Replace with CDN URLs at integration time.\n ambientLoop: \"audio/cosmos/ambient-deep.ogg\",\n focusChime: \"audio/cosmos/focus-shimmer.ogg\",\n engageImpact: \"audio/cosmos/dolly-in.ogg\",\n backWhoosh: \"audio/cosmos/dolly-out.ogg\",\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chuzi/shared",
3
- "version": "1.3.35",
3
+ "version": "1.3.37",
4
4
  "description": "Shared types, realm config, theme tokens, API client, input layer, and realm rendering primitives for CHUZI apps",
5
5
  "type": "module",
6
6
  "sideEffects": false,