@lincyaw/host 0.0.0-stage → 1.0.0-rc.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/LICENSE +202 -0
- package/README.md +39 -2
- package/package.json +39 -3
- package/src/PresenterPanels.vue +91 -0
- package/src/StartReportPanel.vue +45 -0
- package/src/Toolbar.vue +49 -0
- package/src/approvals.ts +58 -0
- package/src/blocks.ts +82 -0
- package/src/boundary.ts +56 -0
- package/src/design/components.ts +327 -0
- package/src/design/design.css +1 -0
- package/src/design/theme.ts +32 -0
- package/src/env.d.ts +7 -0
- package/src/host.ts +82 -0
- package/src/index.ts +84 -0
- package/src/kernel.ts +131 -0
- package/src/key.ts +6 -0
- package/src/locale.ts +42 -0
- package/src/messages.ts +51 -0
- package/src/operations.ts +76 -0
- package/src/panels.ts +60 -0
- package/src/scope.ts +29 -0
- package/src/server.ts +173 -0
- package/src/session.ts +34 -0
- package/src/shared.ts +85 -0
- package/src/types.ts +107 -0
- package/src/vue-shim.d.ts +6 -0
- package/src/windows.ts +28 -0
package/src/windows.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Message = { join: true } | { value: unknown }
|
|
2
|
+
|
|
3
|
+
export interface WindowChannel {
|
|
4
|
+
send(value: unknown): void
|
|
5
|
+
close(): void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function deckChannel(name: string): string {
|
|
9
|
+
return `${name} @ ${import.meta.env?.BASE_URL ?? '/'}`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function joinWindows(name: string, receive: (value: unknown) => void, known: () => unknown): WindowChannel | undefined {
|
|
13
|
+
if (typeof window === 'undefined' || typeof BroadcastChannel === 'undefined') return undefined
|
|
14
|
+
const channel = new BroadcastChannel(deckChannel(name))
|
|
15
|
+
channel.onmessage = ({ data }: MessageEvent<Message>) => {
|
|
16
|
+
if ('value' in data) {
|
|
17
|
+
receive(data.value)
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
const value = known()
|
|
21
|
+
if (value !== undefined) channel.postMessage({ value } satisfies Message)
|
|
22
|
+
}
|
|
23
|
+
channel.postMessage({ join: true } satisfies Message)
|
|
24
|
+
return {
|
|
25
|
+
send: value => channel.postMessage({ value } satisfies Message),
|
|
26
|
+
close: () => channel.close(),
|
|
27
|
+
}
|
|
28
|
+
}
|