@dice-plus/sdk 1.3.1 → 1.4.0
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/index.js +10 -1
- package/dist/types/sdk/src/index.d.ts +11 -2
- package/dist/types/src/embed/protocol.d.ts +28 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ function formatRoomCode(roomId) {
|
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/index.ts
|
|
72
|
-
var SDK_VERSION = "1.
|
|
72
|
+
var SDK_VERSION = "1.4.0";
|
|
73
73
|
var DEFAULT_BASE_URL = "https://dice-plus.missinglinkdev.com";
|
|
74
74
|
/** Room Code and Passcode helpers, so a page never has to guess our formats. */
|
|
75
75
|
var rooms = {
|
|
@@ -288,6 +288,15 @@ var DicePlusTray = class extends Embed {
|
|
|
288
288
|
roll(request) {
|
|
289
289
|
return this.invoke("roll", request);
|
|
290
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Throw a finished roll again on this screen only, as a visual replay: no new
|
|
293
|
+
* numbers, nothing recorded, no 'roll-result'. Pass a result (or its `result`, or a
|
|
294
|
+
* history entry) whose `replay` is set. Resolves once the tray has taken it; if it
|
|
295
|
+
* can't play, 'roll-error' fires with a REPLAY_* `code`.
|
|
296
|
+
*/
|
|
297
|
+
replay(target) {
|
|
298
|
+
return this.invoke("replay", target);
|
|
299
|
+
}
|
|
291
300
|
/** Change some settings; the rest stay as they are. */
|
|
292
301
|
setSettings(settings) {
|
|
293
302
|
this.settings = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type BagEvents, type EmbedTheme, type HelloMessage, type SiteDice, type TrayEvents, type TrayIdentity, type TrayMethods, type TraySettings, type UnauthorizedReason } from '../../src/embed/protocol';
|
|
1
|
+
import { type BagEvents, type EmbedTheme, type HelloMessage, type ReplayTarget, type SiteDice, type TrayEvents, type TrayIdentity, type TrayMethods, type TraySettings, type UnauthorizedReason } from '../../src/embed/protocol';
|
|
2
2
|
import { normalizeRoomId } from '../../src/platform/relay/protocol';
|
|
3
3
|
import { formatRoomCode } from '../../src/platform/relay/roomCode';
|
|
4
4
|
export type * from '../../src/embed/protocol';
|
|
5
|
-
export declare const SDK_VERSION = "1.
|
|
5
|
+
export declare const SDK_VERSION = "1.4.0";
|
|
6
6
|
export declare const DEFAULT_BASE_URL = "https://dice-plus.missinglinkdev.com";
|
|
7
7
|
/** Room Code and Passcode helpers, so a page never has to guess our formats. */
|
|
8
8
|
export declare const rooms: {
|
|
@@ -100,6 +100,15 @@ export declare class DicePlusTray extends Embed<DicePlusTrayEvents> {
|
|
|
100
100
|
roll(request: Parameters<TrayMethods['roll']>[0]): Promise<{
|
|
101
101
|
rollId: string;
|
|
102
102
|
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Throw a finished roll again on this screen only, as a visual replay: no new
|
|
105
|
+
* numbers, nothing recorded, no 'roll-result'. Pass a result (or its `result`, or a
|
|
106
|
+
* history entry) whose `replay` is set. Resolves once the tray has taken it; if it
|
|
107
|
+
* can't play, 'roll-error' fires with a REPLAY_* `code`.
|
|
108
|
+
*/
|
|
109
|
+
replay(target: ReplayTarget): Promise<{
|
|
110
|
+
rollId: string;
|
|
111
|
+
}>;
|
|
103
112
|
/** Change some settings; the rest stay as they are. */
|
|
104
113
|
setSettings(settings: TraySettings): Promise<void>;
|
|
105
114
|
setIdentity(identity: TrayIdentity): Promise<void>;
|
|
@@ -74,14 +74,38 @@ export interface DiceRollResult {
|
|
|
74
74
|
rollSummary: string;
|
|
75
75
|
groups: RolledGroup[];
|
|
76
76
|
tally?: Record<string, number>;
|
|
77
|
+
/** Throws this roll again on one screen, visual only (`replay`). Opaque; absent when it can't be replayed */
|
|
78
|
+
replay?: RollReplayData;
|
|
77
79
|
};
|
|
78
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* What a result carries to throw its roll again. Opaque: keep it with the
|
|
83
|
+
* result and hand it back, never read or build one. `v` is its format.
|
|
84
|
+
*/
|
|
85
|
+
export type RollReplayData = {
|
|
86
|
+
v: number;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
/** Why a replay did not play, on `roll-error`'s `code`. */
|
|
90
|
+
export type ReplayErrorCode = 'REPLAY_BUSY' | 'REPLAY_UNAVAILABLE' | 'REPLAY_VERSION_MISMATCH';
|
|
91
|
+
/** Anything holding a roll's replay: a DiceRollResult, its `result`, or a history entry. */
|
|
92
|
+
export type ReplayTarget = {
|
|
93
|
+
replay?: RollReplayData;
|
|
94
|
+
} | {
|
|
95
|
+
result: {
|
|
96
|
+
replay?: RollReplayData;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
79
99
|
export interface DiceRollError {
|
|
80
100
|
rollId: string;
|
|
81
101
|
error: string;
|
|
82
102
|
notation: string;
|
|
83
103
|
/** The roll still went ahead; something in the request was ignored */
|
|
84
104
|
warning?: true;
|
|
105
|
+
/** Set when a replay did not play */
|
|
106
|
+
code?: ReplayErrorCode;
|
|
107
|
+
/** The replay request's requestId, echoed back (OBR broadcast only) */
|
|
108
|
+
requestId?: string;
|
|
85
109
|
}
|
|
86
110
|
export type SettleTime = 'very-fast' | 'fast' | 'normal' | 'slow' | 'very-slow';
|
|
87
111
|
export type DieType = 'd1' | 'd2' | 'd3' | 'd4' | 'd6' | 'd8' | 'd10' | 'd12' | 'd20' | 'd100' | 'dF';
|
|
@@ -166,6 +190,10 @@ export type TrayMethods = {
|
|
|
166
190
|
roll: (request: TrayRollRequest) => {
|
|
167
191
|
rollId: string;
|
|
168
192
|
};
|
|
193
|
+
/** Throw a finished roll again on this screen only: no new numbers, nothing recorded. Failures fire `roll-error` with a REPLAY_* code */
|
|
194
|
+
replay: (target: ReplayTarget) => {
|
|
195
|
+
rollId: string;
|
|
196
|
+
};
|
|
169
197
|
setSettings: (settings: TraySettings) => void;
|
|
170
198
|
setIdentity: (identity: TrayIdentity) => void;
|
|
171
199
|
setSiteDice: (dice: SiteDice | null) => void;
|