@puzzmo/sdk 1.0.30 → 1.0.32
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/contracts.cjs +0 -0
- package/dist/contracts.d.ts +95 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +0 -0
- package/dist/{createSimulator-DqF2fN_0.js → createSimulator-COj3lAeu.js} +225 -204
- package/dist/{createSimulator-DqF2fN_0.js.map → createSimulator-COj3lAeu.js.map} +1 -1
- package/dist/{createSimulator-B7x0QRdO.cjs → createSimulator-DIT36V1k.cjs} +31 -23
- package/dist/{createSimulator-B7x0QRdO.cjs.map → createSimulator-DIT36V1k.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -90
- package/dist/index.js.map +1 -1
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.spec.d.ts +2 -0
- package/dist/plugins.spec.d.ts.map +1 -0
- package/dist/sdk.d.ts +7 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/simulator/createSimulator.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.d.ts +1 -1
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.js +1 -1
- package/dist/simulator/types.d.ts +6 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/SettingsView.d.ts.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -1
|
File without changes
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** The SDK-owned timer methods exposed to plugins. */
|
|
2
|
+
export interface SDKTimer {
|
|
3
|
+
/** Get elapsed time in milliseconds */
|
|
4
|
+
timeMs: () => number;
|
|
5
|
+
/** Get elapsed time in seconds */
|
|
6
|
+
timeSecs: () => number;
|
|
7
|
+
/** Get added/penalty time in milliseconds */
|
|
8
|
+
addedTimeMs: () => number;
|
|
9
|
+
/** Get added/penalty time in seconds */
|
|
10
|
+
addedTimeSecs: () => number;
|
|
11
|
+
/** Get elapsed time without penalties in seconds */
|
|
12
|
+
timeWithoutPenaltySecs: () => number;
|
|
13
|
+
/** Get formatted display strings [elapsed, added] */
|
|
14
|
+
display: () => [string, string];
|
|
15
|
+
/** Add penalty time in milliseconds */
|
|
16
|
+
addPenalty: (ms: number) => void;
|
|
17
|
+
/** Check if timer is paused */
|
|
18
|
+
isPaused: () => boolean;
|
|
19
|
+
/** Check if timer has been started */
|
|
20
|
+
isRunning: () => boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The bootstrap payload exposed to plugins. `currentUser` is typed for convenience; the rest of the
|
|
24
|
+
* host payload (`startOrFindGameplay`, `theme`, `hostContext`, …) is reachable via the index
|
|
25
|
+
* signature so this stays self-contained and doesn't have to restate the full `BootstrapGameData`.
|
|
26
|
+
*/
|
|
27
|
+
export interface SDKPluginBootstrap {
|
|
28
|
+
/** The signed-in Puzzmo user, or null when the viewer is anonymous. */
|
|
29
|
+
currentUser?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
name?: string | null;
|
|
32
|
+
username?: string;
|
|
33
|
+
usernameID?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
roles?: string;
|
|
36
|
+
/** Nakama account id for multiplayer; null when not logged into Nakama. */
|
|
37
|
+
nakamaID?: string | null;
|
|
38
|
+
} | null;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The low-level seam a plugin is handed in `setup`. It exposes the same host transport the core SDK
|
|
43
|
+
* uses, so a plugin can send/receive message types the slim core does not surface itself (e.g.
|
|
44
|
+
* `SENSORY_EVENT`, `SIDEBAR_UPDATE`, the `COLLAB_*` family). The host already understands the full
|
|
45
|
+
* protocol; plugins just opt extra channels back in.
|
|
46
|
+
*/
|
|
47
|
+
export interface SDKPluginContext {
|
|
48
|
+
/** Send a host message. The type is intentionally open so plugins can use the full protocol. */
|
|
49
|
+
send: (type: string, json: unknown) => void;
|
|
50
|
+
/** Subscribe to a host message by type. Returns an unsubscribe function. */
|
|
51
|
+
on: (type: string, handler: (data: any) => void) => () => void;
|
|
52
|
+
/** The SDK-owned timer (read-only for plugins; the SDK still drives it). */
|
|
53
|
+
timer: SDKTimer;
|
|
54
|
+
/** The resolved bootstrap payload, or null until `gameReady()` has resolved. */
|
|
55
|
+
bootstrap: () => SDKPluginBootstrap | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A Puzzmo SDK plugin. `setup` wires up host messaging and returns the plugin's public API, which is
|
|
59
|
+
* hung off `sdk.plugins[name]`. Keep `name` a string literal so the `sdk.plugins` map stays typed.
|
|
60
|
+
*/
|
|
61
|
+
export interface SDKPlugin<Name extends string = string, API = unknown> {
|
|
62
|
+
/** Unique key the returned API is exposed under (`sdk.plugins[name]`). */
|
|
63
|
+
name: Name;
|
|
64
|
+
/** Wire up host messaging and return the plugin's public API. */
|
|
65
|
+
setup: (ctx: SDKPluginContext) => API;
|
|
66
|
+
}
|
|
67
|
+
/** Maps a tuple of plugins to the `{ [name]: API }` shape exposed at `sdk.plugins`. */
|
|
68
|
+
export type PluginAPIs<Plugins extends readonly SDKPlugin[]> = {
|
|
69
|
+
[Plugin in Plugins[number] as Plugin["name"]]: Plugin extends SDKPlugin<string, infer API> ? API : never;
|
|
70
|
+
};
|
|
71
|
+
/** The simulator context a plugin-provided view renders into (the subset views use). */
|
|
72
|
+
export interface SimulatorContext {
|
|
73
|
+
/** Find an element inside the simulator panel by selector. */
|
|
74
|
+
getElement: <T extends HTMLElement>(selector: string) => T | null;
|
|
75
|
+
/** Update the badge count on this view's tab. Pass 0/undefined to hide it. */
|
|
76
|
+
updateBadge: (tabId: string, count: number | undefined) => void;
|
|
77
|
+
/** Send a host→game message down to the game (the simulator acts as the host). */
|
|
78
|
+
sendToGame: (type: string, data: any) => void;
|
|
79
|
+
}
|
|
80
|
+
/** A simulator tab/view a plugin contributes via `createSimulator({ views })`. */
|
|
81
|
+
export interface SimulatorView {
|
|
82
|
+
/** Tab id (also the message-badge key). */
|
|
83
|
+
id: string;
|
|
84
|
+
/** Tab label. */
|
|
85
|
+
label: string;
|
|
86
|
+
/** Returns the tab's HTML. */
|
|
87
|
+
render(): string;
|
|
88
|
+
/** Wire up event listeners after render. */
|
|
89
|
+
bind(context: SimulatorContext): void;
|
|
90
|
+
/** Called when the tab becomes active. */
|
|
91
|
+
onActivate?(context: SimulatorContext): void;
|
|
92
|
+
/** Handle a message coming from the game. */
|
|
93
|
+
onMessage?(type: string, data: any, context: SimulatorContext): void;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAQA,sDAAsD;AACtD,MAAM,WAAW,QAAQ;IACvB,uCAAuC;IACvC,MAAM,EAAE,MAAM,MAAM,CAAA;IACpB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,wCAAwC;IACxC,aAAa,EAAE,MAAM,MAAM,CAAA;IAC3B,oDAAoD;IACpD,sBAAsB,EAAE,MAAM,MAAM,CAAA;IACpC,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,uCAAuC;IACvC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,OAAO,CAAA;IACvB,sCAAsC;IACtC,SAAS,EAAE,MAAM,OAAO,CAAA;CACzB;AAED;;;;GA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