@chuzi/shared 1.3.34 → 1.3.36

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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Constellation presentation tokens — consumed by the cosmos realm camera,
3
+ * star billboards, and ghost title typography. Admins can override via
4
+ * saved experience / appearance templates.
5
+ */
6
+ interface ConstellationAppearance {
7
+ /** Ghost film title spanning the constellation. */
8
+ titleFontSize: number;
9
+ titleOpacity: number;
10
+ titleColor: string;
11
+ titleLetterSpacing: number;
12
+ titleYOffset: number;
13
+ /** Per-star preview card + label. */
14
+ previewWidth: number;
15
+ previewHeight: number;
16
+ previewOffsetY: number;
17
+ labelFontSize: number;
18
+ labelLetterSpacing: number;
19
+ labelGap: number;
20
+ billboardDistanceFactor: number;
21
+ /** Camera — floating-in-space slide between stars. */
22
+ cameraDefaultOffset: [number, number, number];
23
+ cameraTargetOffset: [number, number, number];
24
+ /** 0–1 lerp factor per frame while gliding (lower = smoother / pressurized). */
25
+ cameraSlideLerp: number;
26
+ cameraArrivalThreshold: number;
27
+ }
28
+ declare const DEFAULT_CONSTELLATION_APPEARANCE: ConstellationAppearance;
29
+ declare function mergeConstellationAppearance(overrides?: Partial<ConstellationAppearance>): ConstellationAppearance;
30
+
31
+ export { type ConstellationAppearance as C, DEFAULT_CONSTELLATION_APPEARANCE as D, mergeConstellationAppearance as m };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,29 @@
1
- export { AcceptGenerationRequest, AcceptGenerationResponse, AiGeneration, AiGenerationShowResponse, AiGenerationStatus, BookmarkListItem, BookmarkListResponse, BookmarkResponse, CatalogResponse, ContentRating, ContentRatingDefinition, CreateSceneActionRequest, CreateSceneRequest, CreateStoryRequest, EngagementResponse, GenerateImageRequest, GenerateImageResponse, HistoryEntry, LineType, LocaleId, MagicLinkRequest, MagicLinkRequestResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, MediaItem, MineResponse, OidcExchangeRequest, OidcExchangeResponse, PaginatedLink, PaginatedResponse, PasswordLoginRequest, PasswordLoginResponse, PlayUrlResponse, PopularChoice, PublicDirectorProfile, RealmConfigResponse, RealmDefinition, RealmId, RegisterMediaRequest, RegisterMediaResponse, RejectGenerationRequest, RejectGenerationResponse, SaveBookmarkRequest, SceneActionItem, SceneActionPayload, SceneChoice, SceneListItem, SceneMapEntry, SceneMapResponse, SceneNode, SceneTextContent, SceneVisibility, SourceUrlResponse, StateUpdate, StoryListItem, StoryPreview, StoryProgress, StoryStyleResponse, TagListResponse, TextLine, TrackEngagementRequest, TranscodeRequest, TranscodeResponse, TreeGraph, TreeGraphEdge, TreeGraphNode, UpdateLocaleRequest, UpdateLocaleResponse, UpdateProfileRequest, UpdateProfileResponse, UpdateRealmRequest, UpdateRealmResponse, UpdateSceneActionRequest, UpdateSceneRequest, UpdateStoryRequest, UploadUrlRequest, UploadUrlResponse, UserProfile, UsernameAvailabilityResponse, VisibilityCondition, VisibilityRules, WatchSnapshot, computeSceneVisibility } from './types/index.js';
1
+ import { SceneListItem, SceneChoice, TextLine } from './types/index.js';
2
+ export { AcceptGenerationRequest, AcceptGenerationResponse, AiGeneration, AiGenerationShowResponse, AiGenerationStatus, BookmarkListItem, BookmarkListResponse, BookmarkResponse, CatalogResponse, ContentRating, ContentRatingDefinition, CreateSceneActionRequest, CreateSceneRequest, CreateStoryRequest, EngagementResponse, GenerateImageRequest, GenerateImageResponse, HistoryEntry, LineType, LocaleId, MagicLinkRequest, MagicLinkRequestResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, MediaItem, MineResponse, OidcExchangeRequest, OidcExchangeResponse, PaginatedLink, PaginatedResponse, PasswordLoginRequest, PasswordLoginResponse, PlayUrlResponse, PopularChoice, PublicDirectorProfile, RealmConfigResponse, RealmDefinition, RealmId, RegisterMediaRequest, RegisterMediaResponse, RejectGenerationRequest, RejectGenerationResponse, SaveBookmarkRequest, SceneActionItem, SceneActionPayload, SceneMapEntry, SceneMapResponse, SceneNode, SceneTextContent, SceneVisibility, SourceUrlResponse, StateUpdate, StoryListItem, StoryPreview, StoryProgress, StoryStyleResponse, TagListResponse, TrackEngagementRequest, TranscodeRequest, TranscodeResponse, TreeGraph, TreeGraphEdge, TreeGraphNode, UpdateLocaleRequest, UpdateLocaleResponse, UpdateProfileRequest, UpdateProfileResponse, UpdateRealmRequest, UpdateRealmResponse, UpdateSceneActionRequest, UpdateSceneRequest, UpdateStoryRequest, UploadUrlRequest, UploadUrlResponse, UserProfile, UsernameAvailabilityResponse, VisibilityCondition, VisibilityRules, WatchSnapshot, computeSceneVisibility } from './types/index.js';
2
3
  export { CONTENT_RATINGS, CONTENT_RATING_IDS, DEFAULT_LOCALE, FALLBACK_LEXICON, FALLBACK_LOCALES, LOCALE_LABELS, REALMS, REALM_IDS, SUPPORTED_LOCALES, getRealmLexiconOverrides, isContentRating, isSupportedLocale, lexiconForRealm, matchAcceptLanguage, normalizeLocale, setRealmLexiconOverrides, t } from './config/index.js';
3
4
  export { RealmThemeTokens, SCENE_TREE_THEMES, SceneTreeTheme, THEME_TOKENS, getSceneTreeTheme, getThemeTokens } from './themes/index.js';
4
5
  export { ChuziApiError, ChuziClient, ChuziClientConfig, TokenResolver, createChuziClient } from './api/index.js';
5
6
  export { Direction, InputMode, Intent, IntentEvent, IntentName, IntentSource, mergeIntentSources } from './input/index.js';
6
7
  export { AtomLocation, AtomMapping, AtomState, AtomVisualProps, AudioPalette, FocusSnap, MotionTokens, RealmModule, ZoomLevel, defaultFocusSnap } from './realms/index.js';
8
+
9
+ /** Playhead position where timed content is fully visible (after fade-in). */
10
+ declare function previewMsWhenVisible(timing: {
11
+ appear_at_ms: number;
12
+ fade_in_ms: number;
13
+ }): number;
14
+ interface ChoiceTiming {
15
+ appear_at_ms: number;
16
+ fade_in_ms: number;
17
+ duration_ms: number;
18
+ fade_out_ms: number;
19
+ }
20
+ declare function resolveChoiceTiming(choice: SceneChoice, fallbackAppearMs: number): ChoiceTiming;
21
+ /**
22
+ * Pick the playhead instant where the most scene content is on screen —
23
+ * text lines, choices, and other timed elements at full opacity.
24
+ */
25
+ declare function computeScenePreviewMs(scene: SceneListItem, choices: SceneChoice[], textLines: TextLine[]): number;
26
+ declare function isLikelyImageUrl(url: string, mediaType?: string | null): boolean;
27
+ declare function isLikelyVideoUrl(url: string, mediaType?: string | null): boolean;
28
+
29
+ export { type ChoiceTiming, SceneChoice, SceneListItem, TextLine, computeScenePreviewMs, isLikelyImageUrl, isLikelyVideoUrl, previewMsWhenVisible, resolveChoiceTiming };
package/dist/index.js CHANGED
@@ -1339,6 +1339,58 @@ function defaultFocusSnap(currentId, direction, atoms) {
1339
1339
  return best?.id ?? null;
1340
1340
  }
1341
1341
 
1342
- export { CONTENT_RATINGS, CONTENT_RATING_IDS, ChuziApiError, DEFAULT_LOCALE, FALLBACK_LEXICON, FALLBACK_LOCALES, Intent, LOCALE_LABELS, REALMS, REALM_IDS, SCENE_TREE_THEMES, SUPPORTED_LOCALES, THEME_TOKENS, computeSceneVisibility, createChuziClient, defaultFocusSnap, getRealmLexiconOverrides, getSceneTreeTheme, getThemeTokens, isContentRating, isSupportedLocale, lexiconForRealm, matchAcceptLanguage, mergeIntentSources, normalizeLocale, setRealmLexiconOverrides, t };
1342
+ // src/scene-preview.ts
1343
+ function previewMsWhenVisible(timing) {
1344
+ return timing.appear_at_ms + timing.fade_in_ms;
1345
+ }
1346
+ function resolveChoiceTiming(choice, fallbackAppearMs) {
1347
+ const appearMs = choice.start_time_seconds != null ? Math.round(choice.start_time_seconds * 1e3) : fallbackAppearMs;
1348
+ const fadeIn = choice.fade_in_ms ?? 400;
1349
+ const fadeOut = choice.fade_out_ms ?? 400;
1350
+ const endMs = choice.end_time_seconds != null ? Math.round(choice.end_time_seconds * 1e3) : appearMs + fadeIn + (choice.duration_ms ?? 2e3) + fadeOut;
1351
+ const duration = choice.duration_ms ?? Math.max(500, endMs - appearMs - fadeIn - fadeOut);
1352
+ return {
1353
+ appear_at_ms: appearMs,
1354
+ fade_in_ms: fadeIn,
1355
+ duration_ms: duration,
1356
+ fade_out_ms: fadeOut
1357
+ };
1358
+ }
1359
+ function lineHasVisiblePayload(line) {
1360
+ if (line.type === "sound" || line.type === "image") {
1361
+ return Boolean(line.media_id);
1362
+ }
1363
+ return line.html.replace(/<[^>]*>/g, "").trim().length > 0;
1364
+ }
1365
+ function fallbackAppearMsFromLines(lines) {
1366
+ if (lines.length === 0) return 0;
1367
+ const last = lines[lines.length - 1];
1368
+ return previewMsWhenVisible(last) + last.duration_ms;
1369
+ }
1370
+ function computeScenePreviewMs(scene, choices, textLines) {
1371
+ const fallback = fallbackAppearMsFromLines(textLines);
1372
+ const candidates = [0];
1373
+ for (const line of textLines) {
1374
+ if (lineHasVisiblePayload(line)) {
1375
+ candidates.push(previewMsWhenVisible(line));
1376
+ }
1377
+ }
1378
+ for (const choice of choices) {
1379
+ if (choice.label.trim().length > 0 || choice.target_scene_id) {
1380
+ candidates.push(previewMsWhenVisible(resolveChoiceTiming(choice, fallback)));
1381
+ }
1382
+ }
1383
+ return Math.max(...candidates);
1384
+ }
1385
+ function isLikelyImageUrl(url, mediaType) {
1386
+ if (mediaType?.startsWith("image/")) return true;
1387
+ return /\.(png|jpe?g|gif|webp|avif)(\?|$)/i.test(url);
1388
+ }
1389
+ function isLikelyVideoUrl(url, mediaType) {
1390
+ if (mediaType?.startsWith("video/")) return true;
1391
+ return /\.(mp4|webm|mov|m3u8)(\?|$)/i.test(url);
1392
+ }
1393
+
1394
+ export { CONTENT_RATINGS, CONTENT_RATING_IDS, ChuziApiError, DEFAULT_LOCALE, FALLBACK_LEXICON, FALLBACK_LOCALES, Intent, LOCALE_LABELS, REALMS, REALM_IDS, SCENE_TREE_THEMES, SUPPORTED_LOCALES, THEME_TOKENS, computeScenePreviewMs, computeSceneVisibility, createChuziClient, defaultFocusSnap, getRealmLexiconOverrides, getSceneTreeTheme, getThemeTokens, isContentRating, isLikelyImageUrl, isLikelyVideoUrl, isSupportedLocale, lexiconForRealm, matchAcceptLanguage, mergeIntentSources, normalizeLocale, previewMsWhenVisible, resolveChoiceTiming, setRealmLexiconOverrides, t };
1343
1395
  //# sourceMappingURL=index.js.map
1344
1396
  //# sourceMappingURL=index.js.map