squiffy-runtime 6.0.0 → 7.0.0-beta.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/dist/assets.d.ts +2 -0
- package/dist/assets.test.d.ts +1 -0
- package/dist/events.d.ts +4 -0
- package/dist/pluginManager.d.ts +2 -1
- package/dist/preview-host.d.ts +29 -0
- package/dist/preview-host.js +83 -0
- package/dist/preview-host.js.map +7 -0
- package/dist/preview-host.test.d.ts +1 -0
- package/dist/preview-html.d.ts +2 -0
- package/dist/preview-html.js +2 -0
- package/dist/preview-protocol.d.ts +53 -0
- package/dist/preview.d.ts +14 -0
- package/dist/preview.main.d.ts +1 -0
- package/dist/preview.test.d.ts +1 -0
- package/dist/squiffy.preview.html +298 -0
- package/dist/squiffy.runtime.global.js +58 -53
- package/dist/squiffy.runtime.global.js.map +1 -1
- package/dist/squiffy.runtime.js +2146 -1996
- package/dist/squiffy.runtime.js.map +1 -1
- package/dist/types.d.ts +12 -1
- package/dist/types.plugins.d.ts +1 -0
- package/package.json +21 -12
- package/src/assets.test.ts +227 -0
- package/src/assets.ts +92 -0
- package/src/events.ts +1 -0
- package/src/pluginManager.ts +5 -1
- package/src/plugins/animate.ts +6 -5
- package/src/preview-host.test.ts +75 -0
- package/src/preview-host.ts +129 -0
- package/src/preview-protocol.ts +57 -0
- package/src/preview.main.ts +33 -0
- package/src/preview.test.ts +168 -0
- package/src/preview.ts +165 -0
- package/src/squiffy.runtime.ts +25 -6
- package/src/types.plugins.ts +4 -0
- package/src/types.ts +17 -1
- package/vite.preview.config.ts +72 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { StartAt } from './types.js';
|
|
2
|
+
export type { StartAt } from './types.js';
|
|
3
|
+
export declare const PREVIEW_CHANNEL = "squiffy-preview";
|
|
4
|
+
export interface PreviewStory {
|
|
5
|
+
js: string;
|
|
6
|
+
css?: string[];
|
|
7
|
+
scripts?: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface PreviewAssets {
|
|
10
|
+
files?: Record<string, Blob | ArrayBuffer | Uint8Array>;
|
|
11
|
+
urls?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export type HostMessage = {
|
|
14
|
+
type: "load";
|
|
15
|
+
story: PreviewStory;
|
|
16
|
+
startAt?: StartAt;
|
|
17
|
+
} | {
|
|
18
|
+
type: "update";
|
|
19
|
+
js: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "restart";
|
|
22
|
+
} | {
|
|
23
|
+
type: "back";
|
|
24
|
+
} | {
|
|
25
|
+
type: "assets";
|
|
26
|
+
assets: PreviewAssets;
|
|
27
|
+
};
|
|
28
|
+
export type PreviewMessage = {
|
|
29
|
+
type: "ready";
|
|
30
|
+
} | {
|
|
31
|
+
type: "loaded";
|
|
32
|
+
} | {
|
|
33
|
+
type: "attributeSet";
|
|
34
|
+
name: string;
|
|
35
|
+
value: unknown;
|
|
36
|
+
} | {
|
|
37
|
+
type: "canGoBackChanged";
|
|
38
|
+
canGoBack: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
type: "navigated";
|
|
41
|
+
section: string;
|
|
42
|
+
passage?: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: "runtimeError";
|
|
45
|
+
message: string;
|
|
46
|
+
stack?: string;
|
|
47
|
+
};
|
|
48
|
+
export type Envelope<T> = T & {
|
|
49
|
+
channel: typeof PREVIEW_CHANNEL;
|
|
50
|
+
};
|
|
51
|
+
export declare const isEnvelope: <T extends {
|
|
52
|
+
type: string;
|
|
53
|
+
}>(data: unknown) => data is Envelope<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HostMessage, PreviewMessage } from './preview-protocol.js';
|
|
2
|
+
import { Story } from './types.js';
|
|
3
|
+
export interface PreviewOptions {
|
|
4
|
+
element: HTMLElement;
|
|
5
|
+
send(message: PreviewMessage): void;
|
|
6
|
+
loadModule?(js: string): Promise<{
|
|
7
|
+
story: Story;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
declare function errorMessage(error: unknown): PreviewMessage;
|
|
11
|
+
export declare function createPreview(options: PreviewOptions): {
|
|
12
|
+
receive: (message: HostMessage) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export { errorMessage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|