@diffenderfer-games/hub 2.0.0-next.1 โ 2.0.0-next.11
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/CHANGELOG.md +173 -5
- package/README.md +27 -15
- package/dist/auto.d.ts +8 -8
- package/dist/auto.js +3 -3
- package/dist/avatar-pixi.d.ts +165 -0
- package/dist/avatar-pixi.d.ts.map +1 -0
- package/dist/avatar-pixi.js +299 -0
- package/dist/avatar-pixi.js.map +1 -0
- package/dist/avatar-svg.d.ts +4 -0
- package/dist/avatar-svg.js +5 -0
- package/dist/avatar-three.d.ts +69 -0
- package/dist/avatar-three.d.ts.map +1 -0
- package/dist/avatar-three.js +49 -0
- package/dist/avatar-three.js.map +1 -0
- package/dist/avatar.d.ts +7 -0
- package/dist/avatar.js +500 -0
- package/dist/avatar.js.map +1 -0
- package/dist/daily.d.ts +2 -2
- package/dist/doctor/cli.mjs +134 -10
- package/dist/doctor/cli.mjs.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +3 -3
- package/dist/input.d.ts +2 -2
- package/dist/input.js +2 -2
- package/dist/mp.d.ts +3 -3
- package/dist/race.d.ts +1 -1
- package/dist/rooms.d.ts +3 -3
- package/dist/rooms.js +1 -1
- package/dist/shared/animator.d.ts +104 -0
- package/dist/shared/animator.d.ts.map +1 -0
- package/dist/shared/art.js +1946 -0
- package/dist/shared/art.js.map +1 -0
- package/dist/shared/atlas.d.ts +138 -0
- package/dist/shared/atlas.d.ts.map +1 -0
- package/dist/shared/avatar.d.ts +123 -0
- package/dist/shared/avatar.d.ts.map +1 -0
- package/dist/shared/bridge.js +18 -4
- package/dist/shared/bridge.js.map +1 -1
- package/dist/shared/client-version.gen.js +1 -1
- package/dist/shared/daily.d.ts +145 -19
- package/dist/shared/daily.d.ts.map +1 -1
- package/dist/shared/daily.js +138 -25
- package/dist/shared/daily.js.map +1 -1
- package/dist/shared/defineProperty.js +39 -0
- package/dist/shared/describe.d.ts +32 -0
- package/dist/shared/describe.d.ts.map +1 -0
- package/dist/shared/describe.js +109 -0
- package/dist/shared/describe.js.map +1 -0
- package/dist/shared/globals.js +1 -39
- package/dist/shared/globals.js.map +1 -1
- package/dist/shared/index.d.ts +1122 -46
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/input.d.ts +74 -14
- package/dist/shared/input.d.ts.map +1 -1
- package/dist/shared/input.js +179 -25
- package/dist/shared/input.js.map +1 -1
- package/dist/shared/json-guards.js +48 -0
- package/dist/shared/json-guards.js.map +1 -0
- package/dist/shared/latest-state.js +1 -1
- package/dist/shared/live-canvas.js +62 -0
- package/dist/shared/live-canvas.js.map +1 -0
- package/dist/shared/mp.js +10 -2
- package/dist/shared/mp.js.map +1 -1
- package/dist/shared/multiplayer-types.d.ts +15 -2
- package/dist/shared/multiplayer-types.d.ts.map +1 -1
- package/dist/shared/overlays.js +800 -0
- package/dist/shared/overlays.js.map +1 -0
- package/dist/shared/page-stack.js +2 -1
- package/dist/shared/page-stack.js.map +1 -1
- package/dist/shared/pose-key.js +249 -0
- package/dist/shared/pose-key.js.map +1 -0
- package/dist/shared/race-types.d.ts +1 -1
- package/dist/shared/race.js +1 -1
- package/dist/shared/room-types.d.ts +28 -3
- package/dist/shared/room-types.d.ts.map +1 -1
- package/dist/shared/rooms.d.ts.map +1 -1
- package/dist/shared/rooms.js +23 -4
- package/dist/shared/rooms.js.map +1 -1
- package/dist/shared/runtime-opener.js +1 -1
- package/dist/shared/scene.d.ts +90 -0
- package/dist/shared/scene.d.ts.map +1 -0
- package/dist/shared/social.d.ts +90 -9
- package/dist/shared/social.d.ts.map +1 -1
- package/dist/shared/social.js +6 -1
- package/dist/shared/social.js.map +1 -1
- package/dist/shared/src.js +4563 -667
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/svg-markup.js +2411 -0
- package/dist/shared/svg-markup.js.map +1 -0
- package/dist/shared/svg.js +27 -0
- package/dist/shared/svg.js.map +1 -0
- package/dist/shared/types.d.ts +174 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/wire-types.d.ts +6 -2
- package/dist/shared/wire-types.d.ts.map +1 -1
- package/dist/social.d.ts +5 -5
- package/dist/social.js +2 -2
- package/dist/turns-rules.d.ts +2 -0
- package/dist/turns-rules.js +1 -0
- package/dist/turns.d.ts +61 -0
- package/dist/turns.d.ts.map +1 -0
- package/dist/turns.js +183 -0
- package/dist/turns.js.map +1 -0
- package/package.json +39 -3
- package/src/avatar/adapters/pixi-avatar.ts +73 -0
- package/src/avatar/adapters/pixi-crowd.ts +329 -0
- package/src/avatar/adapters/pixi-types.ts +84 -0
- package/src/avatar/adapters/three.ts +126 -0
- package/src/avatar/animator/animator.ts +285 -0
- package/src/avatar/animator/reactions.ts +44 -0
- package/src/avatar/animator/schedule.ts +73 -0
- package/src/avatar/art/beard.ts +49 -0
- package/src/avatar/art/glasses.ts +67 -0
- package/src/avatar/art/hair.ts +254 -0
- package/src/avatar/art/headwear.ts +75 -0
- package/src/avatar/art/index.ts +21 -0
- package/src/avatar/art/shape.ts +87 -0
- package/src/avatar/art-store.ts +36 -0
- package/src/avatar/atlas.ts +246 -0
- package/src/avatar/catalog-view.ts +14 -0
- package/src/avatar/colour.ts +109 -0
- package/src/avatar/describe.ts +79 -0
- package/src/avatar/face.ts +187 -0
- package/src/avatar/geom.ts +173 -0
- package/src/avatar/layout.ts +47 -0
- package/src/avatar/look-like.ts +52 -0
- package/src/avatar/outputs/bitmap.ts +75 -0
- package/src/avatar/outputs/canvas-paint.ts +177 -0
- package/src/avatar/outputs/canvas.ts +62 -0
- package/src/avatar/outputs/custom-element.ts +140 -0
- package/src/avatar/outputs/element.ts +58 -0
- package/src/avatar/outputs/live-canvas.ts +57 -0
- package/src/avatar/outputs/overlay-svg.ts +22 -0
- package/src/avatar/outputs/pose-key.ts +30 -0
- package/src/avatar/outputs/svg-markup.ts +113 -0
- package/src/avatar/outputs/svg.ts +41 -0
- package/src/avatar/overlays.ts +128 -0
- package/src/avatar/render/body.ts +116 -0
- package/src/avatar/render/colours.ts +81 -0
- package/src/avatar/render/compose.ts +346 -0
- package/src/avatar/render/context.ts +117 -0
- package/src/avatar/render/eyes.ts +78 -0
- package/src/avatar/render/eyewear.ts +118 -0
- package/src/avatar/render/frame.ts +73 -0
- package/src/avatar/render/head.ts +81 -0
- package/src/avatar/render/mouth.ts +86 -0
- package/src/avatar/render/props.ts +91 -0
- package/src/avatar/render/types.ts +93 -0
- package/src/avatar/render/walker-parts.ts +124 -0
- package/src/avatar/render/walker.ts +239 -0
- package/src/avatar/scene.ts +119 -0
- package/src/avatar-pixi.ts +20 -0
- package/src/avatar-svg.ts +21 -0
- package/src/avatar-three.ts +18 -0
- package/src/avatar.ts +63 -0
- package/src/core/avatar/avatar-cache.ts +95 -0
- package/src/core/avatar/avatar-ref.ts +34 -0
- package/src/core/avatar/avatar-types.ts +43 -0
- package/src/core/avatar/hub-avatar.ts +308 -0
- package/src/core/connection.ts +201 -92
- package/src/core/errors.ts +15 -2
- package/src/core/game-data.ts +11 -9
- package/src/core/hub-economy.ts +47 -10
- package/src/core/hub-progress.ts +94 -30
- package/src/core/hub.ts +228 -7
- package/src/core/offline/cloud-saves.ts +62 -0
- package/src/core/offline/hub-kinds/avatar-kind.ts +42 -0
- package/src/core/offline/hub-kinds/daily-kind.ts +68 -0
- package/src/core/offline/hub-kinds/economy-kinds.ts +86 -0
- package/src/core/offline/hub-kinds/game-fields.ts +2 -0
- package/src/core/offline/hub-kinds/index.ts +52 -0
- package/src/core/offline/hub-kinds/legacy-ops.ts +37 -0
- package/src/core/offline/hub-kinds/progress-kinds.ts +165 -0
- package/src/core/offline/hub-kinds/resume-kind.ts +108 -0
- package/src/core/offline/hub-kinds/saved-kind.ts +93 -0
- package/src/core/offline/kind-adapters.ts +48 -0
- package/src/core/offline/local-inventory.ts +64 -0
- package/src/core/offline/local-store.ts +66 -23
- package/src/core/offline/offline-api.ts +65 -0
- package/src/core/offline/outbox-entry.ts +59 -0
- package/src/core/offline/outbox-kinds.ts +78 -0
- package/src/core/offline/outbox-merge.ts +39 -0
- package/src/core/offline/outbox-replayer.ts +141 -0
- package/src/core/offline/outbox-store.ts +85 -0
- package/src/core/offline/outbox.ts +232 -0
- package/src/core/offline/queue.ts +4 -49
- package/src/core/offline/replay-lease.ts +87 -0
- package/src/core/offline/replay-policy.ts +52 -0
- package/src/core/page-account.ts +121 -0
- package/src/core/page.ts +14 -1
- package/src/core/rest/rest-client.ts +14 -3
- package/src/core/rest/routes.gen.ts +144 -88
- package/src/core/resume/hub-resume.ts +286 -0
- package/src/core/resume/local-resume.ts +130 -0
- package/src/core/resume/resume-list.ts +65 -0
- package/src/core/resume/resume-request.ts +52 -0
- package/src/core/resume/resume-types.ts +64 -0
- package/src/core/saved/daily-saves.ts +196 -0
- package/src/core/saved/daily-seed.ts +16 -0
- package/src/core/saved/hub-saved.ts +221 -0
- package/src/core/saved/local-saved.ts +122 -0
- package/src/core/saved/saved-list.ts +129 -0
- package/src/core/saved/saved-open.ts +104 -0
- package/src/core/saved/saved-order.ts +49 -0
- package/src/core/saved/saved-types.ts +24 -0
- package/src/core/storage/json-guards.ts +6 -0
- package/src/core/turns/hub-turns.ts +161 -0
- package/src/core/turns/turn-game.ts +510 -0
- package/src/core/turns/your-turn-buzz.ts +69 -0
- package/src/core/version/client-version.gen.ts +2 -2
- package/src/daily/daily-system.ts +127 -12
- package/src/daily/page-daily.ts +2 -2
- package/src/daily/types.ts +49 -11
- package/src/doctor/checks.ts +12 -4
- package/src/doctor/cli.ts +8 -2
- package/src/doctor/embed-check.ts +61 -0
- package/src/doctor/hub-version-fetch.ts +43 -43
- package/src/doctor/world-check.ts +61 -0
- package/src/index.ts +20 -2
- package/src/input/focus-ring.ts +13 -0
- package/src/input/input-registry.ts +9 -2
- package/src/input/input-system.ts +14 -1
- package/src/input/modality.ts +122 -0
- package/src/input/nav-state.ts +13 -4
- package/src/input/navigator.ts +11 -0
- package/src/input/zero-config.ts +1 -14
- package/src/input.ts +4 -0
- package/src/mp.ts +1 -1
- package/src/overlay/overlay.ts +30 -4
- package/src/overlay/styles.ts +4 -3
- package/src/realtime/bridge.ts +5 -0
- package/src/realtime/multiplayer-forwarder.ts +13 -1
- package/src/realtime/multiplayer-types.ts +15 -1
- package/src/realtime/room-types.ts +28 -2
- package/src/realtime/rooms-forwarder.ts +27 -2
- package/src/realtime/runtime-api.ts +33 -8
- package/src/realtime/social-forwarder.ts +5 -0
- package/src/realtime/social-types.ts +8 -0
- package/src/realtime/types.ts +1 -0
- package/src/realtime/wire-types.ts +7 -0
- package/src/realtime/world-types.ts +20 -0
- package/src/rooms.ts +1 -1
- package/src/social.ts +1 -0
- package/src/turns-kit/check-rules.ts +281 -0
- package/src/turns-rules.ts +12 -0
- package/src/turns.ts +14 -0
package/dist/shared/daily.d.ts
CHANGED
|
@@ -1,37 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DailyCompletion, DailyCompletions, Json, dailyEndpoints } from "@diffenderfer-games/hub-contract";
|
|
1
|
+
import { m as SchemaOutput } from "./wire-types.js";
|
|
2
|
+
import { DailyCompletion, DailyCompletions, Json, SavedCounts as SavedCounts$1, SavedDaily, SavedGame, SavedKind, SavedKind as SavedKind$1, SavedProgress, SavedStatus, TurnSummary as TurnSummary$1, dailyEndpoints } from "@diffenderfer-games/hub-contract";
|
|
3
|
+
//#region src/core/saved/saved-open.d.ts
|
|
4
|
+
/** The instance id parameter (the contract's `SAVED_OPEN_PARAM`). */
|
|
5
|
+
declare const SAVED_OPEN_PARAM = "hub_open";
|
|
6
|
+
/** The instance kind parameter (the contract's `SAVED_KIND_PARAM`). */
|
|
7
|
+
declare const SAVED_KIND_PARAM = "hub_kind";
|
|
8
|
+
/** The window event the hub menu fires to open an instance of this page's game (cancelable). */
|
|
9
|
+
declare const SAVED_OPEN_EVENT = "hub:saved-open";
|
|
10
|
+
/** The window event the social runtime fires for each `ev:saved` (detail: the `SavedGame`). */
|
|
11
|
+
declare const SAVED_CHANGE_EVENT = "hub:saved";
|
|
12
|
+
/** The instance a page was opened for. */
|
|
13
|
+
interface SavedOpened {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly kind: SavedKind;
|
|
16
|
+
}
|
|
17
|
+
/** The address that opens `game` in its page. */
|
|
18
|
+
declare function savedGameUrl(game: Pick<SavedGame, 'id' | 'kind' | 'path' | 'daily'>): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/core/saved/saved-types.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* One game in progress: a daily challenge, a single-player run or an online
|
|
23
|
+
* game. Its `id` is the hub's, or `local:โฆ` for one saved only on this
|
|
24
|
+
* device so far.
|
|
25
|
+
*/
|
|
26
|
+
interface SavedEntry extends Omit<SavedGame, 'id'> {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
/** Saved on this device and not yet sent to the hub (offline, or the tab closed first). */
|
|
29
|
+
readonly isLocalOnly?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Which kinds to list. */
|
|
32
|
+
interface SavedListOptions {
|
|
33
|
+
readonly kinds?: readonly SavedKind$1[];
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/core/game-data.d.ts
|
|
37
|
+
/** Anything a game may store as JSON: an object (interfaces included), an array, text, a number, a boolean or `null`. */
|
|
38
|
+
type GamePayload = object | string | number | boolean | null;
|
|
39
|
+
//#endregion
|
|
3
40
|
//#region src/daily/types.d.ts
|
|
4
41
|
/** The response type of a daily endpoint. */
|
|
5
42
|
type DailyResponse<Name extends keyof typeof dailyEndpoints> = SchemaOutput<(typeof dailyEndpoints)[Name]['cfg']['response']>;
|
|
6
|
-
/** This game's daily window
|
|
43
|
+
/** This game's daily window, the player's completions and days in progress (`GET /games/:slug/daily`). */
|
|
7
44
|
type DailyStatus = DailyResponse<'getGameDailyChallenges'>;
|
|
8
45
|
/** Every daily game and the global standings (`GET /daily`). */
|
|
9
46
|
type DailyAll = DailyResponse<'listDailyChallengesForAllGames'>;
|
|
10
47
|
/** One game's row in {@link DailyAll}. */
|
|
11
48
|
type DailyGameStatus = DailyAll['games'][number];
|
|
12
|
-
/** The answer to starting a day: its seed
|
|
49
|
+
/** The answer to starting (or resuming) a day: its seed, the signed token to present on completion, and its saved game. */
|
|
13
50
|
type DailyStartResponse = DailyResponse<'startDailyChallenge'>;
|
|
14
51
|
/** The answer to completing a day: the player's new completion count and rank. */
|
|
15
52
|
type DailyCompleteResponse = DailyResponse<'completeDailyChallenge'>;
|
|
16
53
|
/** The challenge a game's `play` receives: set up and start exactly this day (derive the level from `seed`). */
|
|
17
54
|
interface DailyChallenge {
|
|
18
|
-
/** The day, `YYYY-MM-DD
|
|
55
|
+
/** The day, `YYYY-MM-DD` (a UTC day key). */
|
|
19
56
|
day: string;
|
|
20
57
|
/** Deterministic per game and day. */
|
|
21
58
|
seed: number;
|
|
22
|
-
/** The signed token `complete` presents. */
|
|
59
|
+
/** The signed token `complete` presents (empty for a day started offline: it is fetched when the hub is back). */
|
|
23
60
|
token: string;
|
|
24
|
-
/** The player already completed this day (a replay). */
|
|
61
|
+
/** The player already completed this day (a replay for fun: nothing is saved or recorded). */
|
|
25
62
|
alreadyCompleted?: boolean;
|
|
63
|
+
/** The day's saved game; `null` for a replay of a completed day. */
|
|
64
|
+
instanceId: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* The state last saved for this day (`hub.daily.save`, or `hub.resume.save`
|
|
67
|
+
* during the daily), or `null` when the day starts fresh. A game that
|
|
68
|
+
* saves restores from it: `if (challenge.saved) startFrom(challenge.saved)`.
|
|
69
|
+
*/
|
|
70
|
+
saved: GamePayload | null;
|
|
71
|
+
/** The game's state version of `saved` (0 when none). */
|
|
72
|
+
savedVersion: number;
|
|
73
|
+
/** The day was already in progress and was picked up again. */
|
|
74
|
+
resumed?: boolean;
|
|
26
75
|
}
|
|
27
76
|
/** What `hub.daily.define` takes. */
|
|
28
77
|
interface DailyDefinition {
|
|
29
|
-
/** Start this challenge now. */
|
|
78
|
+
/** Start this challenge now (restore `challenge.saved` when it has one). */
|
|
30
79
|
play: (challenge: DailyChallenge) => void;
|
|
31
80
|
}
|
|
32
81
|
/** Metadata a game records with a completion (`{ score, difficulty, timeMs, โฆ }`). */
|
|
33
82
|
type DailyCompletionMeta = Record<string, Json>;
|
|
34
|
-
/**
|
|
83
|
+
/** A daily state save (the same shape as `hub.resume.save`). */
|
|
84
|
+
interface DailySaveInput {
|
|
85
|
+
/** Everything needed to rebuild the day's run (up to 512 KB as JSON). */
|
|
86
|
+
readonly state: GamePayload;
|
|
87
|
+
/** A short line ("34 cards left") and an optional 0 to 1 fraction. */
|
|
88
|
+
readonly progress: {
|
|
89
|
+
readonly label: string;
|
|
90
|
+
readonly fraction?: number | null;
|
|
91
|
+
};
|
|
92
|
+
readonly title?: string | null;
|
|
93
|
+
/** The game's state version (default 0). */
|
|
94
|
+
readonly version?: number;
|
|
95
|
+
}
|
|
96
|
+
/** What the daily system needs from the hub client: the REST calls, the device copy and its window events. */
|
|
35
97
|
interface DailyHost {
|
|
36
98
|
/** This page's game slug. */
|
|
37
99
|
readonly slug: string | null;
|
|
@@ -39,10 +101,20 @@ interface DailyHost {
|
|
|
39
101
|
status(): Promise<DailyStatus>;
|
|
40
102
|
/** `GET /daily`. */
|
|
41
103
|
all(): Promise<DailyAll>;
|
|
42
|
-
/** `POST /games/:slug/daily/:day/start
|
|
104
|
+
/** Start (or pick up) a day: `POST /games/:slug/daily/:day/start`, or a device-only start while offline. */
|
|
43
105
|
start(day: string): Promise<DailyStartResponse>;
|
|
44
|
-
/**
|
|
45
|
-
|
|
106
|
+
/** Pick a day in progress up again by its saved game's id. */
|
|
107
|
+
resume(instanceId: string): Promise<DailyStartResponse>;
|
|
108
|
+
/** `POST /games/:slug/daily/:day/complete`; `null` when it was queued offline, to replay when the hub is back. */
|
|
109
|
+
complete(day: string, token: string, meta: DailyCompletionMeta): Promise<DailyCompleteResponse | null>;
|
|
110
|
+
/** Keep the day's state on the device at once and send it soon (works offline); `false` when it can't be stored. */
|
|
111
|
+
save(challenge: DailyChallenge, input: DailySaveInput): boolean;
|
|
112
|
+
/** Send a waiting save now. */
|
|
113
|
+
flush(): Promise<void>;
|
|
114
|
+
/** Give the day up: discard its saved game (works offline). */
|
|
115
|
+
discard(challenge: DailyChallenge): Promise<void>;
|
|
116
|
+
/** This game's days in progress (the saved games of kind daily). */
|
|
117
|
+
inProgress(): Promise<SavedEntry[]>;
|
|
46
118
|
/** Fire a `hub:*` window event (the menu listens). */
|
|
47
119
|
emit(name: string, detail: DailyEventDetail): void;
|
|
48
120
|
}
|
|
@@ -51,11 +123,22 @@ type DailyEventDetail = {
|
|
|
51
123
|
day: string;
|
|
52
124
|
seed: number;
|
|
53
125
|
alreadyCompleted: boolean;
|
|
126
|
+
resumed?: boolean;
|
|
54
127
|
} | {
|
|
55
128
|
day: string;
|
|
56
129
|
count: number;
|
|
57
130
|
rank: number | null;
|
|
58
131
|
meta: DailyCompletionMeta;
|
|
132
|
+
} | {
|
|
133
|
+
day: string;
|
|
134
|
+
queued: true;
|
|
135
|
+
meta: DailyCompletionMeta;
|
|
136
|
+
} | {
|
|
137
|
+
day: string;
|
|
138
|
+
paused: true;
|
|
139
|
+
} | {
|
|
140
|
+
day: string;
|
|
141
|
+
discarded: true;
|
|
59
142
|
} | {
|
|
60
143
|
day: string;
|
|
61
144
|
error: string;
|
|
@@ -67,13 +150,21 @@ declare const DAILY_START_EVENT = "hub:daily-start";
|
|
|
67
150
|
/** Daily challenges (`hub.daily`). */
|
|
68
151
|
declare class DailySystem {
|
|
69
152
|
/**
|
|
70
|
-
* The challenge in progress
|
|
71
|
-
*
|
|
153
|
+
* The challenge in progress: set when a day starts; cleared the moment the
|
|
154
|
+
* game calls `complete` (whatever the hub answers, and before it answers)
|
|
155
|
+
* or `cancel` (or `discard`). A game's win handler checks it:
|
|
156
|
+
* `if (hub.daily.active) hub.daily.complete(โฆ)`. While it is set the page
|
|
157
|
+
* is in a daily run, so `hub.resume.save` saves to the day instead of the
|
|
158
|
+
* game's run: a game whose player leaves a daily unfinished must call
|
|
159
|
+
* `cancel()`.
|
|
72
160
|
*/
|
|
73
161
|
active: DailyChallenge | null;
|
|
74
162
|
private readonly host;
|
|
75
163
|
private play;
|
|
76
164
|
private pendingDay;
|
|
165
|
+
private pendingInstance;
|
|
166
|
+
/** A start on its way to the hub, so a resume of the same day waits for it instead of starting it twice. */
|
|
167
|
+
private inFlight;
|
|
77
168
|
private isRelaying;
|
|
78
169
|
constructor(host: DailyHost);
|
|
79
170
|
/** Whether a game registered a daily-challenge handler on this page. */
|
|
@@ -91,15 +182,50 @@ declare class DailySystem {
|
|
|
91
182
|
* daily system on the page (a client copy that couldn't share this one).
|
|
92
183
|
*/
|
|
93
184
|
startAndPlay(day: string): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Pick up a day in progress by its saved game's id (from `hub.saved`):
|
|
187
|
+
* a fresh token, then the game's `play` with `challenge.saved`. Finishing
|
|
188
|
+
* it any time later gives that day's credit. A no-op while that day is
|
|
189
|
+
* already being played.
|
|
190
|
+
*/
|
|
191
|
+
resume(instanceId: string): Promise<void>;
|
|
192
|
+
/** Make `challenge` the active day and hand it to the game. */
|
|
193
|
+
private begin;
|
|
194
|
+
/**
|
|
195
|
+
* Save the active day's state, so it can be picked up later (a reload,
|
|
196
|
+
* another device, next week) and still give that day's credit. Kept on
|
|
197
|
+
* the device at once and sent after a short quiet spell (works offline).
|
|
198
|
+
* `hub.resume.save` during a daily lands here too. Returns `false` with
|
|
199
|
+
* no daily active, or for a replay of a completed day (nothing to save).
|
|
200
|
+
*/
|
|
201
|
+
save(input: DailySaveInput): boolean;
|
|
202
|
+
/** This game's days in progress (the calendar marks them, the game can list them). */
|
|
203
|
+
inProgress(): Promise<SavedEntry[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Give up the active day: its progress is discarded and nothing is
|
|
206
|
+
* recorded. The day can be started again fresh while it is in the 30-day
|
|
207
|
+
* window. (The hub's lists ask the player first; a game asks for itself.)
|
|
208
|
+
*/
|
|
209
|
+
discard(): Promise<void>;
|
|
94
210
|
/**
|
|
95
211
|
* Record completion of the active challenge with optional metadata.
|
|
96
212
|
* Resolves with the new completion count and rank, or `null` when no
|
|
97
|
-
* challenge is active or the hub
|
|
213
|
+
* challenge is active, the hub refused, or the hub can't be reached: then
|
|
214
|
+
* the completion is queued (`hub:daily-queued`) and replays when it is
|
|
215
|
+
* back (`hub:daily-complete` follows). The daily run ends at the call,
|
|
216
|
+
* so `active` is `null` at once, even if the hub then refuses it.
|
|
98
217
|
*/
|
|
99
218
|
complete(meta?: DailyCompletionMeta): Promise<DailyCompleteResponse | null>;
|
|
100
219
|
/** Ask the page's other daily systems to start `day` (this one ignores its own event). */
|
|
101
220
|
private relayStart;
|
|
102
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Pause the active day: the player left it unfinished (quit, picked
|
|
223
|
+
* another level, started a normal game). Nothing is recorded, and the day
|
|
224
|
+
* stays in progress in "Your games" and the calendar, to finish later
|
|
225
|
+
* (its last save is sent now). Until then the page counts as in a daily,
|
|
226
|
+
* so `hub.resume.save` saves to the day: call `cancel()` on every path
|
|
227
|
+
* that leaves a daily without `complete`. To give a day up, `discard()`.
|
|
228
|
+
*/
|
|
103
229
|
cancel(): void;
|
|
104
230
|
/** This game's window and the player's completions. */
|
|
105
231
|
status(): Promise<DailyStatus>;
|
|
@@ -108,8 +234,8 @@ declare class DailySystem {
|
|
|
108
234
|
}
|
|
109
235
|
//#endregion
|
|
110
236
|
//#region src/daily/page-daily.d.ts
|
|
111
|
-
/** The cross-bundle shape number of the `daily` singleton. Bump only on an incompatible change. */
|
|
112
|
-
declare const DAILY_SINGLETON_API =
|
|
237
|
+
/** The cross-bundle shape number of the `daily` singleton (2 added save, resume, discard and inProgress). Bump only on an incompatible change. */
|
|
238
|
+
declare const DAILY_SINGLETON_API = 2;
|
|
113
239
|
/** Whether `candidate` is some bundle's daily system (v1 copies included). */
|
|
114
240
|
declare function isDailySystem(candidate: unknown): candidate is DailySystem;
|
|
115
241
|
/**
|
|
@@ -119,5 +245,5 @@ declare function isDailySystem(candidate: unknown): candidate is DailySystem;
|
|
|
119
245
|
*/
|
|
120
246
|
declare function getDaily(host: DailyHost): DailySystem;
|
|
121
247
|
//#endregion
|
|
122
|
-
export {
|
|
248
|
+
export { SAVED_OPEN_EVENT as A, SavedKind$1 as C, TurnSummary$1 as D, SavedStatus as E, SavedOpened as M, savedGameUrl as N, SAVED_CHANGE_EVENT as O, SavedEntry as S, SavedProgress as T, DailyStartResponse as _, isDailySystem as a, SavedCounts$1 as b, DailyAll as c, DailyCompletionMeta as d, DailyDefinition as f, DailySaveInput as g, DailyHost as h, getDaily as i, SAVED_OPEN_PARAM as j, SAVED_KIND_PARAM as k, DailyChallenge as l, DailyGameStatus as m, DailyCompletions as n, DAILY_START_EVENT as o, DailyEventDetail as p, DAILY_SINGLETON_API as r, DailySystem as s, DailyCompletion as t, DailyCompleteResponse as u, DailyStatus as v, SavedListOptions as w, SavedDaily as x, GamePayload as y };
|
|
123
249
|
//# sourceMappingURL=daily.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daily.d.ts","names":[],"sources":["../../src/daily/types.ts","../../src/daily/daily-system.ts","../../src/daily/page-daily.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"daily.d.ts","names":["SavedKind"],"sources":["../../src/core/saved/saved-open.ts","../../src/core/saved/saved-types.ts","../../src/core/game-data.ts","../../src/daily/types.ts","../../src/daily/daily-system.ts","../../src/daily/page-daily.ts"],"mappings":";;;;cAoBa;;cAGA;;cAGA;;cAGA;;UAMI;WACN;WACA,MAAM;;;iBAWD,aAAa,MAAM,KAAK;;;;;;;;UClCvB,mBAAmB,KAAK;WAC9B;;WAEA;;;UAIM;WACN,iBAAiBA;;;;;KCXhB;;;;KCDP,cAAc,0BAA0B,kBAAkB,qBAAqB,gBAAgB;;KAGxF,cAAc;;KAGd,WAAW;;KAGX,kBAAkB;;KAGlB,qBAAqB;;KAGrB,wBAAwB;;UAGnB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA,OAAO;;EAEP;;EAEA;;;UAIe;;EAEf,OAAO,WAAW;;;KAIR,sBAAsB,eAAe;;UAGhC;;WAEN,OAAO;;WAEP;aAAqB;aAAwB;;WAC7C;;WAEA;;;UAIM;;WAEN;;EAET,UAAU,QAAQ;;EAElB,OAAO,QAAQ;;EAEf,MAAM,cAAc,QAAQ;;EAE5B,OAAO,qBAAqB,QAAQ;;EAEpC,SAAS,aAAa,eAAe,MAAM,sBAAsB,QAAQ;;EAEzE,KAAK,WAAW,gBAAgB,OAAO;;EAEvC,SAAS;;EAET,QAAQ,WAAW,iBAAiB;;EAEpC,cAAc,QAAQ;;EAEtB,KAAK,cAAc,QAAQ;;;KAIjB;EACN;EAAa;EAAc;EAA2B;;EACtD;EAAa;EAAe;EAAqB,MAAM;;EACvD;EAAa;EAAc,MAAM;;EACjC;EAAa;;EACb;EAAa;;EACb;EAAa;;;;;cCvFN;;cAkCA;;;;;;;;;;EAUX,QAAQ;mBACS;UACT;UACA;UACA;;UAEA;UACA;EAEI,YAAA,MAAM;;MAiBd;;;;;;EASJ,OAAO,YAAY;;;;;;;EAmBb,aAAa,cAAc;;;;;;;EA2B3B,OAAO,qBAAqB;;UAmB1B;;;;;;;;EAgBR,KAAK,OAAO;;EASZ,cAAc,QAAQ;;;;;;EAShB,WAAW;;;;;;;;;EAoBX,SAAS,OAAM,sBAA2B,QAAQ;;UAsBhD;;;;;;;;;EAoBR;;EAUA,UAAU,QAAQ;;EAKlB,OAAO,QAAQ;;;;;cCrQJ;;iBAIG,cAAc,qBAAqB,aAAa;;;;;;iBAWhD,SAAS,MAAM,YAAY"}
|
package/dist/shared/daily.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as readField, n as claimSingleton, r as hasMethods } from "./globals.js";
|
|
2
|
+
import { t as _defineProperty } from "./defineProperty.js";
|
|
2
3
|
import "./client-version.gen.js";
|
|
3
4
|
//#region src/daily/daily-system.ts
|
|
4
5
|
/**
|
|
@@ -28,14 +29,32 @@ function readDeepLinkDay() {
|
|
|
28
29
|
function messageOf(error) {
|
|
29
30
|
return error instanceof Error ? error.message : String(error);
|
|
30
31
|
}
|
|
32
|
+
/** The challenge a start or resume answered. */
|
|
33
|
+
function challengeOf(started) {
|
|
34
|
+
return {
|
|
35
|
+
day: started.day,
|
|
36
|
+
seed: started.seed,
|
|
37
|
+
token: started.token,
|
|
38
|
+
alreadyCompleted: started.alreadyCompleted,
|
|
39
|
+
instanceId: started.instanceId,
|
|
40
|
+
saved: started.saved,
|
|
41
|
+
savedVersion: started.savedVersion,
|
|
42
|
+
resumed: started.resumed
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
/** Daily challenges (`hub.daily`). */
|
|
32
46
|
var DailySystem = class {
|
|
33
47
|
constructor(host) {
|
|
34
48
|
_defineProperty(
|
|
35
49
|
this,
|
|
36
50
|
/**
|
|
37
|
-
* The challenge in progress
|
|
38
|
-
*
|
|
51
|
+
* The challenge in progress: set when a day starts; cleared the moment the
|
|
52
|
+
* game calls `complete` (whatever the hub answers, and before it answers)
|
|
53
|
+
* or `cancel` (or `discard`). A game's win handler checks it:
|
|
54
|
+
* `if (hub.daily.active) hub.daily.complete(โฆ)`. While it is set the page
|
|
55
|
+
* is in a daily run, so `hub.resume.save` saves to the day instead of the
|
|
56
|
+
* game's run: a game whose player leaves a daily unfinished must call
|
|
57
|
+
* `cancel()`.
|
|
39
58
|
*/
|
|
40
59
|
"active",
|
|
41
60
|
null
|
|
@@ -43,6 +62,8 @@ var DailySystem = class {
|
|
|
43
62
|
_defineProperty(this, "host", void 0);
|
|
44
63
|
_defineProperty(this, "play", null);
|
|
45
64
|
_defineProperty(this, "pendingDay", null);
|
|
65
|
+
_defineProperty(this, "pendingInstance", null);
|
|
66
|
+
_defineProperty(this, "inFlight", null);
|
|
46
67
|
_defineProperty(this, "isRelaying", false);
|
|
47
68
|
this.host = host;
|
|
48
69
|
if (typeof window !== "undefined") window.addEventListener(DAILY_START_EVENT, (event) => {
|
|
@@ -63,8 +84,11 @@ var DailySystem = class {
|
|
|
63
84
|
define(definition) {
|
|
64
85
|
this.play = definition.play;
|
|
65
86
|
const day = readDeepLinkDay() ?? this.pendingDay;
|
|
87
|
+
const instanceId = this.pendingInstance;
|
|
66
88
|
this.pendingDay = null;
|
|
89
|
+
this.pendingInstance = null;
|
|
67
90
|
if (day !== null) this.startAndPlay(day);
|
|
91
|
+
else if (instanceId !== null) this.resume(instanceId);
|
|
68
92
|
}
|
|
69
93
|
/**
|
|
70
94
|
* Fetch the signed token for `day`, make it active and call the game's
|
|
@@ -79,39 +103,113 @@ var DailySystem = class {
|
|
|
79
103
|
this.relayStart(day);
|
|
80
104
|
return;
|
|
81
105
|
}
|
|
106
|
+
const starting = (async () => {
|
|
107
|
+
try {
|
|
108
|
+
this.begin(play, challengeOf(await this.host.start(day)));
|
|
109
|
+
} catch (error) {
|
|
110
|
+
this.host.emit("hub:daily-error", {
|
|
111
|
+
day,
|
|
112
|
+
error: messageOf(error)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
})();
|
|
116
|
+
this.inFlight = starting;
|
|
117
|
+
await starting;
|
|
118
|
+
if (this.inFlight === starting) this.inFlight = null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Pick up a day in progress by its saved game's id (from `hub.saved`):
|
|
122
|
+
* a fresh token, then the game's `play` with `challenge.saved`. Finishing
|
|
123
|
+
* it any time later gives that day's credit. A no-op while that day is
|
|
124
|
+
* already being played.
|
|
125
|
+
*/
|
|
126
|
+
async resume(instanceId) {
|
|
127
|
+
await this.inFlight;
|
|
128
|
+
if (this.active?.instanceId === instanceId) return;
|
|
129
|
+
const play = this.play;
|
|
130
|
+
if (play === null) {
|
|
131
|
+
this.pendingInstance = instanceId;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
82
134
|
try {
|
|
83
|
-
|
|
84
|
-
const challenge = {
|
|
85
|
-
day: started.day,
|
|
86
|
-
seed: started.seed,
|
|
87
|
-
token: started.token,
|
|
88
|
-
alreadyCompleted: started.alreadyCompleted
|
|
89
|
-
};
|
|
90
|
-
this.active = challenge;
|
|
91
|
-
this.host.emit("hub:daily-started", {
|
|
92
|
-
day: started.day,
|
|
93
|
-
seed: started.seed,
|
|
94
|
-
alreadyCompleted: started.alreadyCompleted
|
|
95
|
-
});
|
|
96
|
-
play({ ...challenge });
|
|
135
|
+
this.begin(play, challengeOf(await this.host.resume(instanceId)));
|
|
97
136
|
} catch (error) {
|
|
98
137
|
this.host.emit("hub:daily-error", {
|
|
99
|
-
day,
|
|
138
|
+
day: "",
|
|
100
139
|
error: messageOf(error)
|
|
101
140
|
});
|
|
102
141
|
}
|
|
103
142
|
}
|
|
143
|
+
/** Make `challenge` the active day and hand it to the game. */
|
|
144
|
+
begin(play, challenge) {
|
|
145
|
+
this.active = challenge;
|
|
146
|
+
this.host.emit("hub:daily-started", {
|
|
147
|
+
day: challenge.day,
|
|
148
|
+
seed: challenge.seed,
|
|
149
|
+
alreadyCompleted: challenge.alreadyCompleted === true,
|
|
150
|
+
resumed: challenge.resumed === true
|
|
151
|
+
});
|
|
152
|
+
if (challenge.resumed === true) this.host.emit("hub:daily-resumed", {
|
|
153
|
+
day: challenge.day,
|
|
154
|
+
seed: challenge.seed,
|
|
155
|
+
alreadyCompleted: false,
|
|
156
|
+
resumed: true
|
|
157
|
+
});
|
|
158
|
+
play({ ...challenge });
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Save the active day's state, so it can be picked up later (a reload,
|
|
162
|
+
* another device, next week) and still give that day's credit. Kept on
|
|
163
|
+
* the device at once and sent after a short quiet spell (works offline).
|
|
164
|
+
* `hub.resume.save` during a daily lands here too. Returns `false` with
|
|
165
|
+
* no daily active, or for a replay of a completed day (nothing to save).
|
|
166
|
+
*/
|
|
167
|
+
save(input) {
|
|
168
|
+
const challenge = this.active;
|
|
169
|
+
if (challenge === null || challenge.instanceId === null) return false;
|
|
170
|
+
return this.host.save(challenge, input);
|
|
171
|
+
}
|
|
172
|
+
/** This game's days in progress (the calendar marks them, the game can list them). */
|
|
173
|
+
inProgress() {
|
|
174
|
+
return this.host.inProgress();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Give up the active day: its progress is discarded and nothing is
|
|
178
|
+
* recorded. The day can be started again fresh while it is in the 30-day
|
|
179
|
+
* window. (The hub's lists ask the player first; a game asks for itself.)
|
|
180
|
+
*/
|
|
181
|
+
async discard() {
|
|
182
|
+
const challenge = this.active;
|
|
183
|
+
if (challenge === null) return;
|
|
184
|
+
this.active = null;
|
|
185
|
+
if (challenge.instanceId !== null) await this.host.discard(challenge);
|
|
186
|
+
this.host.emit("hub:daily-discarded", {
|
|
187
|
+
day: challenge.day,
|
|
188
|
+
discarded: true
|
|
189
|
+
});
|
|
190
|
+
}
|
|
104
191
|
/**
|
|
105
192
|
* Record completion of the active challenge with optional metadata.
|
|
106
193
|
* Resolves with the new completion count and rank, or `null` when no
|
|
107
|
-
* challenge is active or the hub
|
|
194
|
+
* challenge is active, the hub refused, or the hub can't be reached: then
|
|
195
|
+
* the completion is queued (`hub:daily-queued`) and replays when it is
|
|
196
|
+
* back (`hub:daily-complete` follows). The daily run ends at the call,
|
|
197
|
+
* so `active` is `null` at once, even if the hub then refuses it.
|
|
108
198
|
*/
|
|
109
199
|
async complete(meta = {}) {
|
|
110
200
|
const challenge = this.active;
|
|
111
201
|
if (challenge === null) return null;
|
|
202
|
+
this.active = null;
|
|
112
203
|
try {
|
|
113
204
|
const completed = await this.host.complete(challenge.day, challenge.token, meta);
|
|
114
|
-
|
|
205
|
+
if (completed === null) {
|
|
206
|
+
this.host.emit("hub:daily-queued", {
|
|
207
|
+
day: challenge.day,
|
|
208
|
+
queued: true,
|
|
209
|
+
meta
|
|
210
|
+
});
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
115
213
|
this.host.emit("hub:daily-complete", {
|
|
116
214
|
day: challenge.day,
|
|
117
215
|
count: completed.count,
|
|
@@ -137,9 +235,24 @@ var DailySystem = class {
|
|
|
137
235
|
this.isRelaying = false;
|
|
138
236
|
}
|
|
139
237
|
}
|
|
140
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Pause the active day: the player left it unfinished (quit, picked
|
|
240
|
+
* another level, started a normal game). Nothing is recorded, and the day
|
|
241
|
+
* stays in progress in "Your games" and the calendar, to finish later
|
|
242
|
+
* (its last save is sent now). Until then the page counts as in a daily,
|
|
243
|
+
* so `hub.resume.save` saves to the day: call `cancel()` on every path
|
|
244
|
+
* that leaves a daily without `complete`. To give a day up, `discard()`.
|
|
245
|
+
*/
|
|
141
246
|
cancel() {
|
|
247
|
+
const challenge = this.active;
|
|
142
248
|
this.active = null;
|
|
249
|
+
if (challenge !== null) {
|
|
250
|
+
this.host.flush().catch(() => void 0);
|
|
251
|
+
this.host.emit("hub:daily-paused", {
|
|
252
|
+
day: challenge.day,
|
|
253
|
+
paused: true
|
|
254
|
+
});
|
|
255
|
+
}
|
|
143
256
|
}
|
|
144
257
|
/** This game's window and the player's completions. */
|
|
145
258
|
status() {
|
|
@@ -156,8 +269,8 @@ var DailySystem = class {
|
|
|
156
269
|
* The page's one daily-challenge system (plan ยง4.4): the first bundle to
|
|
157
270
|
* create it wins, so the menu starts days on the instance the game defined.
|
|
158
271
|
*/
|
|
159
|
-
/** The cross-bundle shape number of the `daily` singleton. Bump only on an incompatible change. */
|
|
160
|
-
const DAILY_SINGLETON_API =
|
|
272
|
+
/** The cross-bundle shape number of the `daily` singleton (2 added save, resume, discard and inProgress). Bump only on an incompatible change. */
|
|
273
|
+
const DAILY_SINGLETON_API = 2;
|
|
161
274
|
/** Whether `candidate` is some bundle's daily system (v1 copies included). */
|
|
162
275
|
function isDailySystem(candidate) {
|
|
163
276
|
return hasMethods(candidate, [
|
|
@@ -178,8 +291,8 @@ let claimedDaily = null;
|
|
|
178
291
|
function getDaily(host) {
|
|
179
292
|
claimedDaily ?? (claimedDaily = claimSingleton({
|
|
180
293
|
name: "daily",
|
|
181
|
-
version: "2.0.0-next.
|
|
182
|
-
api:
|
|
294
|
+
version: "2.0.0-next.11",
|
|
295
|
+
api: 2,
|
|
183
296
|
create: () => new DailySystem(host),
|
|
184
297
|
isInstance: isDailySystem
|
|
185
298
|
}));
|
package/dist/shared/daily.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daily.js","names":[],"sources":["../../src/daily/daily-system.ts","../../src/daily/page-daily.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"daily.js","names":[],"sources":["../../src/daily/daily-system.ts","../../src/daily/page-daily.ts"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,cAAc;;AAGpB,MAAa,oBAAoB;;AAIjC,SAAS,SAAS,WAAmC;CACnD,OAAO,OAAO,cAAc,YAAY,YAAY,KAAK,SAAS,IAAI,YAAY;AACpF;;AAGA,SAAS,kBAAiC;CAGxC,MAAM,WAAW,OAAO,WAAW,cAAc,OAAO,SAAS,UAAU,QAAQ,gBAAgB,CAAC;CACpG,IAAI,aAAa,QAAQ,OAAO,aAAa,aAC3C,OAAO;CAET,OAAO,SAAS,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,aAAa,IAAI,OAAO,CAAC;AAClE;;AAIA,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;AAGA,SAAS,YAAY,SAA6C;CAChE,OAAO;EACL,KAAK,QAAQ;EAAK,MAAM,QAAQ;EAAM,OAAO,QAAQ;EAAO,kBAAkB,QAAQ;EACtF,YAAY,QAAQ;EAAY,OAAO,QAAQ;EAAO,cAAc,QAAQ;EAAc,SAAS,QAAQ;CAC7G;AACF;;AAGA,IAAa,cAAb,MAAyB;CAmBvB,YAAY,MAAiB;;;;;;;;;;;;GAT7B;GAAgC;;EACf,gBAAA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EAClC,YAAY;CACd,CAAC;CACD,OAAO;AACT"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
12
|
+
function toPrimitive(t, r) {
|
|
13
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
14
|
+
var e = t[Symbol.toPrimitive];
|
|
15
|
+
if (void 0 !== e) {
|
|
16
|
+
var i = e.call(t, r || "default");
|
|
17
|
+
if ("object" != _typeof(i)) return i;
|
|
18
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
19
|
+
}
|
|
20
|
+
return ("string" === r ? String : Number)(t);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
24
|
+
function toPropertyKey(t) {
|
|
25
|
+
var i = toPrimitive(t, "string");
|
|
26
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
30
|
+
function _defineProperty(e, r, t) {
|
|
31
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
32
|
+
value: t,
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
configurable: !0,
|
|
35
|
+
writable: !0
|
|
36
|
+
}) : e[r] = t, e;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { _defineProperty as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { c as Point, s as LookLike, t as Anchor, u as RenderOptions } from "./types.js";
|
|
2
|
+
import { t as SceneNode } from "./scene.js";
|
|
3
|
+
import { AvatarLook } from "@diffenderfer-games/hub-contract/avatar";
|
|
4
|
+
//#region src/avatar/render/compose.d.ts
|
|
5
|
+
/** The head centre's height above the feet. */
|
|
6
|
+
declare const HEAD_Y = -96;
|
|
7
|
+
/** A composed avatar: scene nodes in rig space and its anchors. */
|
|
8
|
+
interface Composed {
|
|
9
|
+
readonly nodes: readonly SceneNode[];
|
|
10
|
+
readonly anchors: Readonly<Record<Anchor, Point>>;
|
|
11
|
+
}
|
|
12
|
+
/** Composes a look (or `null` for the silhouette) with a pose. */
|
|
13
|
+
declare function composeAvatar(look: AvatarLook | null, opts?: RenderOptions): Composed;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/avatar/outputs/svg.d.ts
|
|
16
|
+
/** An avatar as SVG markup. */
|
|
17
|
+
declare function renderSvg(like: LookLike, opts?: RenderOptions): string;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/avatar/art-store.d.ts
|
|
20
|
+
/** Loads the art chunk (once). Resolves when rendering is synchronous. */
|
|
21
|
+
declare function ready(): Promise<void>;
|
|
22
|
+
/** Calls `fn` once the art has loaded (now, when it already has). */
|
|
23
|
+
declare function onArtReady(fn: () => void): void;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/avatar/describe.d.ts
|
|
26
|
+
/** Alt text for any {@link LookLike} (`''` for none). */
|
|
27
|
+
declare function describe(like: LookLike): string;
|
|
28
|
+
/** A person emoji with the nearest of the five skin tones and a hair hint where Unicode has one: `๐ง๐ฝโ๐ฆฑ`. */
|
|
29
|
+
declare function avatarEmoji(like: LookLike): string;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { renderSvg as a, composeAvatar as c, ready as i, describe as n, Composed as o, onArtReady as r, HEAD_Y as s, avatarEmoji as t };
|
|
32
|
+
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.d.ts","names":[],"sources":["../../src/avatar/render/compose.ts","../../src/avatar/outputs/svg.ts","../../src/avatar/art-store.ts","../../src/avatar/describe.ts"],"mappings":";;;;;cA4Ba;;UASI;WACN,gBAAgB;WAChB,SAAS,SAAS,OAAO,QAAQ;;;iBA2P5B,cAAc,MAAM,mBAAmB,OAAM,gBAAqB;;;;iBC7PlE,UAAU,MAAM,UAAU,OAAM;;;;iBCpBhC,SAAS;;iBAYT,WAAW;;;;iBC+BX,SAAS,MAAM;;iBASf,YAAY,MAAM"}
|