@jtfmumm/patchwork-standalone-frame 0.1.0 → 0.3.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/frame.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
2
- import type { ToolRegistration } from "./index.ts";
1
+ import type { AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
2
+ import type { ToolRegistration, StandaloneFrameConfig } from "./index.ts";
3
3
  declare global {
4
4
  interface Window {
5
5
  hive?: AutomergeRepoKeyhive;
@@ -7,4 +7,5 @@ declare global {
7
7
  }
8
8
  export declare function StandaloneApp<D>(props: {
9
9
  tool: ToolRegistration<D>;
10
+ config?: StandaloneFrameConfig;
10
11
  }): import("solid-js").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -15,6 +15,46 @@ export interface ToolRegistration<D = unknown> {
15
15
  isDocReady?: (doc: D) => boolean;
16
16
  render: (handle: DocHandle<D>, element: ToolElement) => (() => void);
17
17
  }
18
+ /** Duck-typed doc handle — structurally compatible with automerge-repo DocHandle */
19
+ export interface FrameDocHandle<D = unknown> {
20
+ url: string;
21
+ doc(): D | undefined;
22
+ whenReady(): Promise<unknown>;
23
+ on(event: string, cb: (...args: unknown[]) => void): void;
24
+ off(event: string, cb: (...args: unknown[]) => void): void;
25
+ }
26
+ /** Duck-typed repo — structurally compatible with automerge-repo Repo */
27
+ export interface FrameRepo {
28
+ find<D = unknown>(url: string): FrameDocHandle<D>;
29
+ create<D = unknown>(initialValue: D): FrameDocHandle<D>;
30
+ delete(url: string): void;
31
+ }
32
+ export interface StandaloneFrameConfig {
33
+ /** When true, use plain automerge docs without keyhive. Default: false */
34
+ legacyMode?: boolean;
35
+ /** Pre-built repo for legacy mode. Required when legacyMode is true. */
36
+ repo?: FrameRepo;
37
+ }
38
+ export interface PluginDescription {
39
+ id: string;
40
+ type: string;
41
+ name: string;
42
+ icon?: string;
43
+ }
44
+ export interface ToolPlugin<D = unknown> extends PluginDescription {
45
+ type: "patchwork:tool";
46
+ supportedDatatypes: "*" | string[];
47
+ load: () => Promise<(handle: DocHandle<D>, element: ToolElement) => (() => void)>;
48
+ }
49
+ export interface DatatypePlugin<D = unknown> extends PluginDescription {
50
+ type: "patchwork:datatype";
51
+ load: () => Promise<{
52
+ init(doc: D, repo: Repo): void;
53
+ getTitle(doc: D): string;
54
+ setTitle?(doc: D, title: string): void;
55
+ }>;
56
+ }
57
+ export type Plugin<D = unknown> = ToolPlugin<D> | DatatypePlugin<D>;
18
58
  export { mountStandaloneApp } from "./mount.tsx";
19
59
  export { ShareModal } from "./share-modal.tsx";
20
60
  export { ConfirmModal } from "./confirm-modal.tsx";