@crowdedkingdoms/crowdyjs 17.14.0-dev.1 → 18.0.1-dev.1
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/MIGRATION.md +129 -1
- package/README.md +97 -164
- package/dist/crowdy-client.d.ts +12 -31
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +15 -37
- package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
- package/dist/crowdy-dsh/bridge.js +3 -6
- package/dist/crowdy-studio/controller.d.ts +34 -59
- package/dist/crowdy-studio/controller.d.ts.map +1 -1
- package/dist/crowdy-studio/controller.js +96 -225
- package/dist/crowdy-studio/diagnostics.d.ts +3 -12
- package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.d.ts +2 -4
- package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.js +16 -49
- package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -2
- package/dist/crowdy-studio/embed/hud-layer.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.d.ts +3 -13
- package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.js +3 -6
- package/dist/crowdy-studio/index.d.ts +1 -3
- package/dist/crowdy-studio/index.d.ts.map +1 -1
- package/dist/crowdy-studio/index.js +0 -2
- package/dist/crowdy-studio/models.d.ts +3 -4
- package/dist/crowdy-studio/models.d.ts.map +1 -1
- package/dist/crowdy-studio/starter-projects.d.ts +8 -12
- package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
- package/dist/crowdy-studio/starter-projects.js +12 -103
- package/dist/domains/appAccess.d.ts +14 -1
- package/dist/domains/appAccess.d.ts.map +1 -1
- package/dist/domains/appAccess.js +37 -1
- package/dist/domains/apps.d.ts +1 -10
- package/dist/domains/apps.d.ts.map +1 -1
- package/dist/domains/apps.js +1 -16
- package/dist/domains/host.d.ts +3 -3
- package/dist/domains/host.js +3 -3
- package/dist/domains/hosting.d.ts +0 -6
- package/dist/domains/hosting.d.ts.map +1 -1
- package/dist/domains/hosting.js +1 -16
- package/dist/domains/marketplace.d.ts +9 -70
- package/dist/domains/marketplace.d.ts.map +1 -1
- package/dist/domains/marketplace.js +9 -120
- package/dist/domains/organizations.d.ts +1 -9
- package/dist/domains/organizations.d.ts.map +1 -1
- package/dist/domains/organizations.js +1 -15
- package/dist/domains/payments.d.ts +5 -48
- package/dist/domains/payments.d.ts.map +1 -1
- package/dist/domains/payments.js +5 -57
- package/dist/domains/playerWallet.d.ts +6 -12
- package/dist/domains/playerWallet.d.ts.map +1 -1
- package/dist/domains/playerWallet.js +6 -21
- package/dist/domains/quotas.d.ts +20 -7
- package/dist/domains/quotas.d.ts.map +1 -1
- package/dist/domains/quotas.js +15 -6
- package/dist/domains/users.d.ts +7 -74
- package/dist/domains/users.d.ts.map +1 -1
- package/dist/domains/users.js +7 -105
- package/dist/errors.d.ts +7 -13
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +6 -10
- package/dist/generated/graphql.d.ts +955 -8272
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +5 -329
- package/dist/grid-mods/exec-client-halves.d.ts +19 -3
- package/dist/grid-mods/exec-client-halves.d.ts.map +1 -1
- package/dist/grid-mods/exec-client-halves.js +17 -2
- package/dist/grid-mods/grid-host-calls.d.ts +29 -17
- package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
- package/dist/grid-mods/grid-host-calls.js +40 -46
- package/dist/grid-mods/mod-runtime.d.ts +18 -11
- package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
- package/dist/grid-mods/mod-runtime.js +4 -2
- package/dist/grid-scope.d.ts +0 -189
- package/dist/grid-scope.d.ts.map +1 -1
- package/dist/grid-scope.js +0 -70
- package/dist/index.d.ts +12 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -16
- package/dist/kit/actions.d.ts +5 -9
- package/dist/kit/actions.d.ts.map +1 -1
- package/dist/kit/actions.js +5 -9
- package/dist/kit/index.d.ts +2 -33
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +1 -32
- package/dist/kit/kit.d.ts +8 -208
- package/dist/kit/kit.d.ts.map +1 -1
- package/dist/kit/kit.js +5 -163
- package/dist/kit/social.d.ts +1 -3
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/kit/social.js +1 -3
- package/dist/kit/wire.d.ts +16 -5
- package/dist/kit/wire.d.ts.map +1 -1
- package/dist/kit/wire.js +19 -5
- package/dist/live-coding/assets/browser-authoring-index.json +1 -1
- package/dist/live-coding/assets/manifest.json +1 -1
- package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
- package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
- package/dist/live-coding/rust-analysis.d.ts.map +1 -1
- package/dist/live-coding/rust-analysis.js +30 -34
- package/dist/player-runtime/client-host-calls.d.ts +8 -0
- package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
- package/dist/player-runtime/client-host-calls.js +28 -0
- package/dist/player-runtime/glue-runtime.d.ts +24 -20
- package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
- package/dist/player-runtime/glue-runtime.js +26 -55
- package/dist/player-runtime/glue-sab.d.ts +2 -2
- package/dist/player-runtime/glue-sab.js +2 -2
- package/dist/player-runtime/player-code-broker.d.ts +70 -43
- package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
- package/dist/player-runtime/player-code-broker.js +159 -64
- package/dist/player-runtime/player-glue-worker.d.ts +8 -9
- package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
- package/dist/player-runtime/player-glue-worker.js +26 -11
- package/dist/stores/inbox.d.ts +1 -1
- package/dist/stores/inbox.d.ts.map +1 -1
- package/dist/stores/index.d.ts +0 -11
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +0 -4
- package/dist/stores/session.d.ts +0 -2
- package/dist/stores/session.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
- package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
- package/dist/crowdy-studio/model-lint-log.js +0 -93
- package/dist/crowdy-studio/model-lint.d.ts +0 -61
- package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
- package/dist/crowdy-studio/model-lint.js +0 -45
- package/dist/domains/compute.d.ts +0 -208
- package/dist/domains/compute.d.ts.map +0 -1
- package/dist/domains/compute.js +0 -274
- package/dist/domains/controlPlane.d.ts +0 -38
- package/dist/domains/controlPlane.d.ts.map +0 -1
- package/dist/domains/controlPlane.js +0 -43
- package/dist/domains/gameModel.d.ts +0 -1174
- package/dist/domains/gameModel.d.ts.map +0 -1
- package/dist/domains/gameModel.js +0 -1333
- package/dist/domains/playerCompute.d.ts +0 -91
- package/dist/domains/playerCompute.d.ts.map +0 -1
- package/dist/domains/playerCompute.js +0 -136
- package/dist/domains/playerModel.d.ts +0 -20
- package/dist/domains/playerModel.d.ts.map +0 -1
- package/dist/domains/playerModel.js +0 -54
- package/dist/kit/abilities.d.ts +0 -66
- package/dist/kit/abilities.d.ts.map +0 -1
- package/dist/kit/abilities.js +0 -71
- package/dist/kit/blueprints/combat.d.ts +0 -81
- package/dist/kit/blueprints/combat.d.ts.map +0 -1
- package/dist/kit/blueprints/combat.js +0 -357
- package/dist/kit/blueprints/core.d.ts +0 -222
- package/dist/kit/blueprints/core.d.ts.map +0 -1
- package/dist/kit/blueprints/core.js +0 -185
- package/dist/kit/blueprints/decks.d.ts +0 -50
- package/dist/kit/blueprints/decks.d.ts.map +0 -1
- package/dist/kit/blueprints/decks.js +0 -163
- package/dist/kit/blueprints/economy.d.ts +0 -88
- package/dist/kit/blueprints/economy.d.ts.map +0 -1
- package/dist/kit/blueprints/economy.js +0 -533
- package/dist/kit/blueprints/guild.d.ts +0 -51
- package/dist/kit/blueprints/guild.d.ts.map +0 -1
- package/dist/kit/blueprints/guild.js +0 -50
- package/dist/kit/blueprints/index.d.ts +0 -23
- package/dist/kit/blueprints/index.d.ts.map +0 -1
- package/dist/kit/blueprints/index.js +0 -22
- package/dist/kit/blueprints/inventory.d.ts +0 -84
- package/dist/kit/blueprints/inventory.d.ts.map +0 -1
- package/dist/kit/blueprints/inventory.js +0 -257
- package/dist/kit/blueprints/leaderboards.d.ts +0 -49
- package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
- package/dist/kit/blueprints/leaderboards.js +0 -126
- package/dist/kit/blueprints/liveops.d.ts +0 -42
- package/dist/kit/blueprints/liveops.d.ts.map +0 -1
- package/dist/kit/blueprints/liveops.js +0 -170
- package/dist/kit/blueprints/locks.d.ts +0 -82
- package/dist/kit/blueprints/locks.d.ts.map +0 -1
- package/dist/kit/blueprints/locks.js +0 -155
- package/dist/kit/blueprints/loot.d.ts +0 -90
- package/dist/kit/blueprints/loot.d.ts.map +0 -1
- package/dist/kit/blueprints/loot.js +0 -229
- package/dist/kit/blueprints/matches.d.ts +0 -84
- package/dist/kit/blueprints/matches.d.ts.map +0 -1
- package/dist/kit/blueprints/matches.js +0 -349
- package/dist/kit/blueprints/moderation.d.ts +0 -32
- package/dist/kit/blueprints/moderation.d.ts.map +0 -1
- package/dist/kit/blueprints/moderation.js +0 -140
- package/dist/kit/blueprints/npcs.d.ts +0 -78
- package/dist/kit/blueprints/npcs.d.ts.map +0 -1
- package/dist/kit/blueprints/npcs.js +0 -125
- package/dist/kit/blueprints/plots.d.ts +0 -63
- package/dist/kit/blueprints/plots.d.ts.map +0 -1
- package/dist/kit/blueprints/plots.js +0 -151
- package/dist/kit/blueprints/progression.d.ts +0 -68
- package/dist/kit/blueprints/progression.d.ts.map +0 -1
- package/dist/kit/blueprints/progression.js +0 -324
- package/dist/kit/blueprints/quests.d.ts +0 -72
- package/dist/kit/blueprints/quests.d.ts.map +0 -1
- package/dist/kit/blueprints/quests.js +0 -285
- package/dist/kit/blueprints/worldsim.d.ts +0 -91
- package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
- package/dist/kit/blueprints/worldsim.js +0 -468
- package/dist/kit/combat.d.ts +0 -141
- package/dist/kit/combat.d.ts.map +0 -1
- package/dist/kit/combat.js +0 -196
- package/dist/kit/decks.d.ts +0 -157
- package/dist/kit/decks.d.ts.map +0 -1
- package/dist/kit/decks.js +0 -186
- package/dist/kit/director.d.ts +0 -88
- package/dist/kit/director.d.ts.map +0 -1
- package/dist/kit/director.js +0 -86
- package/dist/kit/economy.d.ts +0 -289
- package/dist/kit/economy.d.ts.map +0 -1
- package/dist/kit/economy.js +0 -427
- package/dist/kit/engine.d.ts +0 -48
- package/dist/kit/engine.d.ts.map +0 -1
- package/dist/kit/engine.js +0 -113
- package/dist/kit/features.d.ts +0 -60
- package/dist/kit/features.d.ts.map +0 -1
- package/dist/kit/features.js +0 -65
- package/dist/kit/instances.d.ts +0 -52
- package/dist/kit/instances.d.ts.map +0 -1
- package/dist/kit/instances.js +0 -60
- package/dist/kit/inventory.d.ts +0 -129
- package/dist/kit/inventory.d.ts.map +0 -1
- package/dist/kit/inventory.js +0 -200
- package/dist/kit/leaderboards.d.ts +0 -86
- package/dist/kit/leaderboards.d.ts.map +0 -1
- package/dist/kit/leaderboards.js +0 -133
- package/dist/kit/liveops.d.ts +0 -112
- package/dist/kit/liveops.d.ts.map +0 -1
- package/dist/kit/liveops.js +0 -183
- package/dist/kit/loot.d.ts +0 -128
- package/dist/kit/loot.d.ts.map +0 -1
- package/dist/kit/loot.js +0 -160
- package/dist/kit/matches.d.ts +0 -301
- package/dist/kit/matches.d.ts.map +0 -1
- package/dist/kit/matches.js +0 -458
- package/dist/kit/matchmaking.d.ts +0 -57
- package/dist/kit/matchmaking.d.ts.map +0 -1
- package/dist/kit/matchmaking.js +0 -59
- package/dist/kit/minigames.d.ts +0 -30
- package/dist/kit/minigames.d.ts.map +0 -1
- package/dist/kit/minigames.js +0 -38
- package/dist/kit/mobs.d.ts +0 -90
- package/dist/kit/mobs.d.ts.map +0 -1
- package/dist/kit/mobs.js +0 -98
- package/dist/kit/moderation.d.ts +0 -73
- package/dist/kit/moderation.d.ts.map +0 -1
- package/dist/kit/moderation.js +0 -103
- package/dist/kit/movement.d.ts +0 -78
- package/dist/kit/movement.d.ts.map +0 -1
- package/dist/kit/movement.js +0 -103
- package/dist/kit/notifications.d.ts +0 -45
- package/dist/kit/notifications.d.ts.map +0 -1
- package/dist/kit/notifications.js +0 -67
- package/dist/kit/npcs.d.ts +0 -226
- package/dist/kit/npcs.d.ts.map +0 -1
- package/dist/kit/npcs.js +0 -141
- package/dist/kit/objects.d.ts +0 -116
- package/dist/kit/objects.d.ts.map +0 -1
- package/dist/kit/objects.js +0 -119
- package/dist/kit/pets.d.ts +0 -85
- package/dist/kit/pets.d.ts.map +0 -1
- package/dist/kit/pets.js +0 -96
- package/dist/kit/plots.d.ts +0 -85
- package/dist/kit/plots.d.ts.map +0 -1
- package/dist/kit/plots.js +0 -113
- package/dist/kit/progression.d.ts +0 -181
- package/dist/kit/progression.d.ts.map +0 -1
- package/dist/kit/progression.js +0 -265
- package/dist/kit/quests.d.ts +0 -171
- package/dist/kit/quests.d.ts.map +0 -1
- package/dist/kit/quests.js +0 -237
- package/dist/kit/racing.d.ts +0 -85
- package/dist/kit/racing.d.ts.map +0 -1
- package/dist/kit/racing.js +0 -99
- package/dist/kit/shared.d.ts +0 -73
- package/dist/kit/shared.d.ts.map +0 -1
- package/dist/kit/shared.js +0 -101
- package/dist/kit/telemetry.d.ts +0 -66
- package/dist/kit/telemetry.d.ts.map +0 -1
- package/dist/kit/telemetry.js +0 -133
- package/dist/kit/territory.d.ts +0 -97
- package/dist/kit/territory.d.ts.map +0 -1
- package/dist/kit/territory.js +0 -114
- package/dist/kit/worldsim.d.ts +0 -263
- package/dist/kit/worldsim.d.ts.map +0 -1
- package/dist/kit/worldsim.js +0 -268
- package/dist/stores/model.d.ts +0 -81
- package/dist/stores/model.d.ts.map +0 -1
- package/dist/stores/model.js +0 -163
package/dist/stores/model.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContainerMirror — the client half of the platform's **notify-to-pull**
|
|
3
|
-
* pattern for game-model state: keep typed snapshots of the containers you
|
|
4
|
-
* care about, re-pull them on demand or whenever a bound channel pings
|
|
5
|
-
* ("state changed"), and render straight from the cache.
|
|
6
|
-
*
|
|
7
|
-
* Model changes are pull-based on this platform (there is no model
|
|
8
|
-
* subscription); functions declare channel/spatial notifications and clients
|
|
9
|
-
* re-read. The Game Kit's match layer pings a per-match channel — bind the
|
|
10
|
-
* mirror to that channel and every watched container refreshes itself.
|
|
11
|
-
*/
|
|
12
|
-
import type { WorldSessionContext } from './session.js';
|
|
13
|
-
/** A typed snapshot of one watched container. */
|
|
14
|
-
export interface MirroredContainer<T = Record<string, unknown>> {
|
|
15
|
-
readonly containerId: string;
|
|
16
|
-
typeName: string;
|
|
17
|
-
displayName: string;
|
|
18
|
-
ownerUserId: string | null;
|
|
19
|
-
/** The parsed, caller-visible properties. */
|
|
20
|
-
value: T;
|
|
21
|
-
/** Bumped on every refresh that changed the snapshot. */
|
|
22
|
-
revision: number;
|
|
23
|
-
/** Local time of the last refresh. */
|
|
24
|
-
refreshedAt: number;
|
|
25
|
-
}
|
|
26
|
-
/** Options for {@link attachContainerMirror}. */
|
|
27
|
-
export interface ContainerMirrorConfig {
|
|
28
|
-
/** Clock override for tests. Defaults to `Date.now`. */
|
|
29
|
-
now?: () => number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The SDK-managed **model mirror**: typed, cached snapshots of watched
|
|
33
|
-
* game-model containers with coalesced refresh and channel-ping binding.
|
|
34
|
-
* Reads are synchronous ({@link get}); {@link onChange} fires only when a
|
|
35
|
-
* refresh actually changed the visible state.
|
|
36
|
-
*/
|
|
37
|
-
export declare class ContainerMirror {
|
|
38
|
-
private readonly ctx;
|
|
39
|
-
private readonly watches;
|
|
40
|
-
private readonly listeners;
|
|
41
|
-
private readonly boundChannels;
|
|
42
|
-
private readonly now;
|
|
43
|
-
private refreshing;
|
|
44
|
-
private refreshQueued;
|
|
45
|
-
constructor(ctx: WorldSessionContext, config?: ContainerMirrorConfig);
|
|
46
|
-
/**
|
|
47
|
-
* Watch a container: fetches the initial snapshot and keeps it refreshable.
|
|
48
|
-
* `parse` maps the visible properties object to your type (defaults to the
|
|
49
|
-
* raw object).
|
|
50
|
-
*/
|
|
51
|
-
watch<T = Record<string, unknown>>(containerId: string, parse?: (properties: Record<string, unknown>) => T): Promise<MirroredContainer<T>>;
|
|
52
|
-
/** Stop watching a container (its snapshot is dropped). */
|
|
53
|
-
unwatch(containerId: string): void;
|
|
54
|
-
/** The current snapshot of a watched container (undefined before watch resolves). */
|
|
55
|
-
get<T = Record<string, unknown>>(containerId: string): MirroredContainer<T> | undefined;
|
|
56
|
-
/** Every watched snapshot. */
|
|
57
|
-
list(): Array<MirroredContainer<unknown>>;
|
|
58
|
-
/**
|
|
59
|
-
* Subscribe to snapshot changes — every watched container, or one
|
|
60
|
-
* `containerId`. Fires only when a refresh changed the visible state.
|
|
61
|
-
* @returns off.
|
|
62
|
-
*/
|
|
63
|
-
onChange(handler: (container: MirroredContainer<unknown>) => void, containerId?: string): () => void;
|
|
64
|
-
/**
|
|
65
|
-
* Bind a channel: any message on it triggers a coalesced {@link refreshAll}
|
|
66
|
-
* — pair with model functions that declare channel notifications (e.g. the
|
|
67
|
-
* Game Kit's `match_changed` pings).
|
|
68
|
-
*/
|
|
69
|
-
bindToChannel(channelId: string): () => void;
|
|
70
|
-
/** Re-pull one watched container now. */
|
|
71
|
-
refresh(containerId: string): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Re-pull every watched container. Concurrent calls coalesce: a refresh
|
|
74
|
-
* requested while one is running queues exactly one follow-up pass (pings
|
|
75
|
-
* can burst; state converges without stampeding the API).
|
|
76
|
-
*/
|
|
77
|
-
refreshAll(): Promise<void>;
|
|
78
|
-
}
|
|
79
|
-
/** Attach a {@link ContainerMirror}. Prefer the `model` config key. */
|
|
80
|
-
export declare function attachContainerMirror(ctx: WorldSessionContext, config?: ContainerMirrorConfig): ContainerMirror;
|
|
81
|
-
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/stores/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,iDAAiD;AACjD,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,6CAA6C;IAC7C,KAAK,EAAE,CAAC,CAAC;IACT,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,iDAAiD;AACjD,MAAM,WAAW,qBAAqB;IACpC,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AASD;;;;;GAKG;AACH,qBAAa,eAAe;IAYxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAXtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAGrB;IACL,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;gBAGX,GAAG,EAAE,mBAAmB,EACzC,MAAM,GAAE,qBAA0B;IAcpC;;;;OAIG;IACG,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,GACjD,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAWhC,2DAA2D;IAC3D,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIlC,qFAAqF;IACrF,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS;IAMvF,8BAA8B;IAC9B,IAAI,IAAI,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAQzC;;;;OAIG;IACH,QAAQ,CACN,OAAO,EAAE,CAAC,SAAS,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,IAAI,EACxD,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,IAAI;IAMb;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,IAAI;IAK5C,yCAAyC;IACnC,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDjD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAqBlC;AAED,uEAAuE;AACvE,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,mBAAmB,EACxB,MAAM,GAAE,qBAA0B,GACjC,eAAe,CAEjB"}
|
package/dist/stores/model.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContainerMirror — the client half of the platform's **notify-to-pull**
|
|
3
|
-
* pattern for game-model state: keep typed snapshots of the containers you
|
|
4
|
-
* care about, re-pull them on demand or whenever a bound channel pings
|
|
5
|
-
* ("state changed"), and render straight from the cache.
|
|
6
|
-
*
|
|
7
|
-
* Model changes are pull-based on this platform (there is no model
|
|
8
|
-
* subscription); functions declare channel/spatial notifications and clients
|
|
9
|
-
* re-read. The Game Kit's match layer pings a per-match channel — bind the
|
|
10
|
-
* mirror to that channel and every watched container refreshes itself.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* The SDK-managed **model mirror**: typed, cached snapshots of watched
|
|
14
|
-
* game-model containers with coalesced refresh and channel-ping binding.
|
|
15
|
-
* Reads are synchronous ({@link get}); {@link onChange} fires only when a
|
|
16
|
-
* refresh actually changed the visible state.
|
|
17
|
-
*/
|
|
18
|
-
export class ContainerMirror {
|
|
19
|
-
constructor(ctx, config = {}) {
|
|
20
|
-
this.ctx = ctx;
|
|
21
|
-
this.watches = new Map();
|
|
22
|
-
this.listeners = new Set();
|
|
23
|
-
this.boundChannels = new Set();
|
|
24
|
-
this.refreshing = false;
|
|
25
|
-
this.refreshQueued = false;
|
|
26
|
-
this.now = config.now ?? Date.now;
|
|
27
|
-
// One listener serves every bound channel: a ping means "model state
|
|
28
|
-
// changed somewhere relevant" → coalesced refresh of all watches.
|
|
29
|
-
ctx.onDispose(ctx.on('channelMessage', (notification) => {
|
|
30
|
-
if (!this.boundChannels.has(String(notification.channelId)))
|
|
31
|
-
return;
|
|
32
|
-
void this.refreshAll();
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Watch a container: fetches the initial snapshot and keeps it refreshable.
|
|
37
|
-
* `parse` maps the visible properties object to your type (defaults to the
|
|
38
|
-
* raw object).
|
|
39
|
-
*/
|
|
40
|
-
async watch(containerId, parse) {
|
|
41
|
-
const entry = {
|
|
42
|
-
parse: parse ?? ((props) => props),
|
|
43
|
-
snapshot: null,
|
|
44
|
-
lastSerialized: null,
|
|
45
|
-
};
|
|
46
|
-
this.watches.set(containerId, entry);
|
|
47
|
-
await this.refresh(containerId);
|
|
48
|
-
return entry.snapshot;
|
|
49
|
-
}
|
|
50
|
-
/** Stop watching a container (its snapshot is dropped). */
|
|
51
|
-
unwatch(containerId) {
|
|
52
|
-
this.watches.delete(containerId);
|
|
53
|
-
}
|
|
54
|
-
/** The current snapshot of a watched container (undefined before watch resolves). */
|
|
55
|
-
get(containerId) {
|
|
56
|
-
return (this.watches.get(containerId)?.snapshot ?? undefined);
|
|
57
|
-
}
|
|
58
|
-
/** Every watched snapshot. */
|
|
59
|
-
list() {
|
|
60
|
-
const out = [];
|
|
61
|
-
for (const entry of this.watches.values()) {
|
|
62
|
-
if (entry.snapshot)
|
|
63
|
-
out.push(entry.snapshot);
|
|
64
|
-
}
|
|
65
|
-
return out;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Subscribe to snapshot changes — every watched container, or one
|
|
69
|
-
* `containerId`. Fires only when a refresh changed the visible state.
|
|
70
|
-
* @returns off.
|
|
71
|
-
*/
|
|
72
|
-
onChange(handler, containerId) {
|
|
73
|
-
const entry = { containerId, handler };
|
|
74
|
-
this.listeners.add(entry);
|
|
75
|
-
return () => this.listeners.delete(entry);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Bind a channel: any message on it triggers a coalesced {@link refreshAll}
|
|
79
|
-
* — pair with model functions that declare channel notifications (e.g. the
|
|
80
|
-
* Game Kit's `match_changed` pings).
|
|
81
|
-
*/
|
|
82
|
-
bindToChannel(channelId) {
|
|
83
|
-
this.boundChannels.add(String(channelId));
|
|
84
|
-
return () => this.boundChannels.delete(String(channelId));
|
|
85
|
-
}
|
|
86
|
-
/** Re-pull one watched container now. */
|
|
87
|
-
async refresh(containerId) {
|
|
88
|
-
const entry = this.watches.get(containerId);
|
|
89
|
-
if (!entry)
|
|
90
|
-
return;
|
|
91
|
-
const state = await this.ctx.client.gameModel.containerState({
|
|
92
|
-
appId: this.ctx.appId,
|
|
93
|
-
containerId,
|
|
94
|
-
});
|
|
95
|
-
let properties;
|
|
96
|
-
try {
|
|
97
|
-
properties = JSON.parse(state.propertiesJson);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
properties = {};
|
|
101
|
-
}
|
|
102
|
-
const serialized = `${state.displayName}|${state.propertiesJson}`;
|
|
103
|
-
const changed = serialized !== entry.lastSerialized;
|
|
104
|
-
entry.lastSerialized = serialized;
|
|
105
|
-
if (!entry.snapshot) {
|
|
106
|
-
entry.snapshot = {
|
|
107
|
-
containerId,
|
|
108
|
-
typeName: state.typeName,
|
|
109
|
-
displayName: state.displayName,
|
|
110
|
-
ownerUserId: state.ownerUserId != null ? String(state.ownerUserId) : null,
|
|
111
|
-
value: entry.parse(properties),
|
|
112
|
-
revision: 1,
|
|
113
|
-
refreshedAt: this.now(),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
entry.snapshot.refreshedAt = this.now();
|
|
118
|
-
if (changed) {
|
|
119
|
-
entry.snapshot.typeName = state.typeName;
|
|
120
|
-
entry.snapshot.displayName = state.displayName;
|
|
121
|
-
entry.snapshot.ownerUserId =
|
|
122
|
-
state.ownerUserId != null ? String(state.ownerUserId) : null;
|
|
123
|
-
entry.snapshot.value = entry.parse(properties);
|
|
124
|
-
entry.snapshot.revision += 1;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (changed) {
|
|
128
|
-
for (const listener of [...this.listeners]) {
|
|
129
|
-
if (listener.containerId === undefined ||
|
|
130
|
-
listener.containerId === containerId) {
|
|
131
|
-
listener.handler(entry.snapshot);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Re-pull every watched container. Concurrent calls coalesce: a refresh
|
|
138
|
-
* requested while one is running queues exactly one follow-up pass (pings
|
|
139
|
-
* can burst; state converges without stampeding the API).
|
|
140
|
-
*/
|
|
141
|
-
async refreshAll() {
|
|
142
|
-
if (this.refreshing) {
|
|
143
|
-
this.refreshQueued = true;
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this.refreshing = true;
|
|
147
|
-
try {
|
|
148
|
-
do {
|
|
149
|
-
this.refreshQueued = false;
|
|
150
|
-
await Promise.all([...this.watches.keys()].map((id) => this.refresh(id).catch(() => {
|
|
151
|
-
// A failed pull keeps the previous snapshot; the next ping retries.
|
|
152
|
-
})));
|
|
153
|
-
} while (this.refreshQueued);
|
|
154
|
-
}
|
|
155
|
-
finally {
|
|
156
|
-
this.refreshing = false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/** Attach a {@link ContainerMirror}. Prefer the `model` config key. */
|
|
161
|
-
export function attachContainerMirror(ctx, config = {}) {
|
|
162
|
-
return new ContainerMirror(ctx, config);
|
|
163
|
-
}
|