@longstoryshort/vtt-sdk 0.1.0 → 0.2.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/README.md
CHANGED
|
@@ -84,9 +84,15 @@ sandbox="allow-same-origin allow-scripts allow-popups allow-popups-to-escape-san
|
|
|
84
84
|
|
|
85
85
|
`allow-same-origin` is required so the sheet can read its auth cookie and access localStorage. Without it the sheet gets an opaque origin and auth breaks.
|
|
86
86
|
|
|
87
|
-
## Reference bridge
|
|
87
|
+
## Reference bridge — Owlbear Rodeo (D&D 5e)
|
|
88
88
|
|
|
89
|
-
A
|
|
89
|
+
A deployable vanilla-TS bridge for Owlbear Rodeo lives in [`bridges/dnd/`](bridges/dnd/). It is automatically deployed to GitHub Pages on every push to `master`.
|
|
90
|
+
|
|
91
|
+
**Live manifest:** `https://bridge.longstoryshort.app/dnd/obr/manifest.json`
|
|
92
|
+
|
|
93
|
+
To install the extension in OBR: Extensions → Add extension → paste the manifest URL above.
|
|
94
|
+
|
|
95
|
+
To adapt for your own VTT: copy `bridges/dnd/src/main.ts`, swap `OwlbearAdapter` for your own `VTTAdapter` implementation, and deploy as a static page.
|
|
90
96
|
|
|
91
97
|
## Protocol events
|
|
92
98
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as VTTAdapter, a as VTTUser, S as SheetEvent, N as NotifyVariant } from '../../types-
|
|
1
|
+
import { V as VTTAdapter, a as VTTUser, S as SheetEvent, N as NotifyVariant } from '../../types-DQndRf3e.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Owlbear Rodeo implementation of {@link VTTAdapter}.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as SheetSource, V as VTTAdapter, c as SheetBridgeOptions, d as SheetClientOptions, e as SheetClient, C as CapabilityManifest, S as SheetEvent, M as MessageHost, D as DiceRollPayload, N as NotifyVariant } from './types-
|
|
2
|
-
export { f as CapabilityDescriptor, g as CapabilityOpAddTag, h as CapabilityOpAdjust, i as CapabilityOpName, j as CapabilityOpRemoveTag, k as CapabilityOpRequestRoll, l as CapabilityOpSet, m as CapabilityOpToggle, n as CapabilityOperation, H as HealthChangedPayload, o as MessageTarget, p as SheetBridgeMessages, a as VTTUser, q as VTTUserRole } from './types-
|
|
1
|
+
import { b as SheetSource, V as VTTAdapter, c as SheetBridgeOptions, d as SheetClientOptions, e as SheetClient, C as CapabilityManifest, S as SheetEvent, M as MessageHost, D as DiceRollPayload, N as NotifyVariant } from './types-DQndRf3e.js';
|
|
2
|
+
export { f as CapabilityDescriptor, g as CapabilityOpAddTag, h as CapabilityOpAdjust, i as CapabilityOpName, j as CapabilityOpRemoveTag, k as CapabilityOpRequestRoll, l as CapabilityOpSet, m as CapabilityOpToggle, n as CapabilityOperation, H as HealthChangedPayload, o as MessageTarget, p as SheetBridgeMessages, a as VTTUser, q as VTTUserRole } from './types-DQndRf3e.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Wires a host {@link SheetSource} to a {@link VTTAdapter}. This is the whole
|
|
@@ -49,7 +49,7 @@ interface BridgeSheetSource extends SheetSource {
|
|
|
49
49
|
onManifest(handler: (manifest: CapabilityManifest) => void): () => void;
|
|
50
50
|
/** Subscribe to every event coming from the sheet (not only rolls). */
|
|
51
51
|
onEvent(handler: (event: SheetEvent) => void): () => void;
|
|
52
|
-
/** Post an inbound command to the sheet (e.g. `
|
|
52
|
+
/** Post an inbound command to the sheet (e.g. `dnd:command`). */
|
|
53
53
|
send(event: SheetEvent): void;
|
|
54
54
|
dispose(): void;
|
|
55
55
|
}
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ function createSheetBridge(source, adapter, options = {}) {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
adapter.notify(formatRollMessage(roll), rollVariant(roll));
|
|
37
|
-
adapter.broadcast({ type: "
|
|
37
|
+
adapter.broadcast({ type: "dnd:roll", payload: roll });
|
|
38
38
|
void adapter.labelOverSelection(roll.total).then((placed) => {
|
|
39
39
|
if (!placed) {
|
|
40
40
|
adapter.notify(messages.labelHint, "warning");
|
|
@@ -47,7 +47,7 @@ function createSheetBridge(source, adapter, options = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
adapter.notify(messages.connected, "success");
|
|
49
49
|
cleanups.push(adapter.onEvent((event) => {
|
|
50
|
-
if (event.type !== "
|
|
50
|
+
if (event.type !== "dnd:roll") {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
adapter.notify(formatRollMessage(event.payload), rollVariant(event.payload));
|
|
@@ -61,7 +61,7 @@ function createSheetBridge(source, adapter, options = {}) {
|
|
|
61
61
|
|
|
62
62
|
// src/postMessageProtocol.ts
|
|
63
63
|
var MARKER = "__lssSheetSdk";
|
|
64
|
-
var VERSION =
|
|
64
|
+
var VERSION = 2;
|
|
65
65
|
function wrapEnvelope(event) {
|
|
66
66
|
return { __lssSheetSdk: VERSION, event };
|
|
67
67
|
}
|
|
@@ -147,7 +147,7 @@ function createBridgeSheetSource(options) {
|
|
|
147
147
|
return {
|
|
148
148
|
onRoll(handler) {
|
|
149
149
|
const wrapped = (event) => {
|
|
150
|
-
if (event.type === "
|
|
150
|
+
if (event.type === "dnd:roll") {
|
|
151
151
|
handler(event.payload);
|
|
152
152
|
}
|
|
153
153
|
};
|
|
@@ -158,7 +158,7 @@ function createBridgeSheetSource(options) {
|
|
|
158
158
|
},
|
|
159
159
|
onManifest(handler) {
|
|
160
160
|
const wrapped = (event) => {
|
|
161
|
-
if (event.type === "
|
|
161
|
+
if (event.type === "dnd:manifest") {
|
|
162
162
|
handler(event.payload);
|
|
163
163
|
}
|
|
164
164
|
};
|
|
@@ -83,7 +83,7 @@ interface CapabilityDescriptor {
|
|
|
83
83
|
/**
|
|
84
84
|
* Capability manifest — the sheet's public declaration of what the host may do.
|
|
85
85
|
* Sent outbound by the sheet at handshake time; the host reads it to know which
|
|
86
|
-
*
|
|
86
|
+
* dnd:command operations are valid for this member.
|
|
87
87
|
*/
|
|
88
88
|
interface CapabilityManifest {
|
|
89
89
|
version: '1';
|
|
@@ -101,20 +101,20 @@ interface HealthChangedPayload {
|
|
|
101
101
|
/**
|
|
102
102
|
* Everything that crosses the sheet↔VTT boundary.
|
|
103
103
|
*
|
|
104
|
-
* Outbound (sheet → host):
|
|
105
|
-
* Inbound (host → sheet):
|
|
104
|
+
* Outbound (sheet → host): dnd:roll · dnd:manifest · dnd:health
|
|
105
|
+
* Inbound (host → sheet): dnd:command
|
|
106
106
|
*/
|
|
107
107
|
type SheetEvent = {
|
|
108
|
-
type: '
|
|
108
|
+
type: 'dnd:roll';
|
|
109
109
|
payload: DiceRollPayload;
|
|
110
110
|
} | {
|
|
111
|
-
type: '
|
|
111
|
+
type: 'dnd:manifest';
|
|
112
112
|
payload: CapabilityManifest;
|
|
113
113
|
} | {
|
|
114
|
-
type: '
|
|
114
|
+
type: 'dnd:health';
|
|
115
115
|
payload: HealthChangedPayload;
|
|
116
116
|
} | {
|
|
117
|
-
type: '
|
|
117
|
+
type: 'dnd:command';
|
|
118
118
|
payload: CapabilityOperation;
|
|
119
119
|
};
|
|
120
120
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longstoryshort/vtt-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Embed a longstoryshort.app character sheet in any virtual tabletop via iframe and postMessage",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"typesVersions": {
|
|
20
20
|
"*": {
|
|
21
|
-
"owlbear": [
|
|
21
|
+
"owlbear": [
|
|
22
|
+
"./dist/adapters/owlbear/index.d.ts"
|
|
23
|
+
]
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
26
|
"files": [
|