@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.
- package/dist/appearance-CVHSA6Ql.d.ts +38 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/dist/realms/cosmos/components/index.d.ts +49 -7
- package/dist/realms/cosmos/components/index.js +264 -12
- package/dist/realms/cosmos/components/index.js.map +1 -1
- package/dist/realms/cosmos/index.d.ts +2 -0
- package/dist/realms/cosmos/index.js +27 -1
- package/dist/realms/cosmos/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
/** Rainbow arc title above the constellation (SVG px). */
|
|
8
|
+
titleFontSize: number;
|
|
9
|
+
titleOpacity: number;
|
|
10
|
+
titleColor: string;
|
|
11
|
+
titleLetterSpacing: number;
|
|
12
|
+
/** World-space lift above constellation center. */
|
|
13
|
+
titleYOffset: number;
|
|
14
|
+
/** Html distance factor for the arc title billboard. */
|
|
15
|
+
titleDistanceFactor: number;
|
|
16
|
+
/** DOM z-index ceiling for constellation Html overlays (keep below editor). */
|
|
17
|
+
htmlZIndexRange: [number, number];
|
|
18
|
+
/** Per-star preview card + label. */
|
|
19
|
+
previewWidth: number;
|
|
20
|
+
previewHeight: number;
|
|
21
|
+
previewOffsetY: number;
|
|
22
|
+
labelFontSize: number;
|
|
23
|
+
labelLetterSpacing: number;
|
|
24
|
+
labelGap: number;
|
|
25
|
+
/** Reserved space below preview for the 2×2 HUD control grid (px). */
|
|
26
|
+
controlsGridHeight: number;
|
|
27
|
+
billboardDistanceFactor: number;
|
|
28
|
+
/** Camera — floating-in-space slide between stars. */
|
|
29
|
+
cameraDefaultOffset: [number, number, number];
|
|
30
|
+
cameraTargetOffset: [number, number, number];
|
|
31
|
+
/** 0–1 lerp factor per frame while gliding (lower = smoother / pressurized). */
|
|
32
|
+
cameraSlideLerp: number;
|
|
33
|
+
cameraArrivalThreshold: number;
|
|
34
|
+
}
|
|
35
|
+
declare const DEFAULT_CONSTELLATION_APPEARANCE: ConstellationAppearance;
|
|
36
|
+
declare function mergeConstellationAppearance(overrides?: Partial<ConstellationAppearance>): ConstellationAppearance;
|
|
37
|
+
|
|
38
|
+
export { type ConstellationAppearance as C, DEFAULT_CONSTELLATION_APPEARANCE as D, mergeConstellationAppearance as m };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|