@powerhousedao/devtools 0.0.0-stage → 6.3.0-dev.12

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.
@@ -0,0 +1,97 @@
1
+ //#region src/props.d.ts
2
+ /** What the app around DevTools can tell it or do for it. A host leaves out
3
+ * what it does not have, and DevTools falls back as each member says. */
4
+ type DevtoolsApp = {
5
+ /** Ids of the editors and drive apps the app has loaded in this tab.
6
+ * Without it, Build does not say whether a module is loaded. */
7
+ loadedModules?: {
8
+ editors: readonly string[];
9
+ apps: readonly string[];
10
+ };
11
+ /** Shows an error in the app's own notifications. Without it, the error
12
+ * goes to the console. */
13
+ notifyError?: (message: string) => void;
14
+ /** Takes a search param out of the URL through the app's router, with no
15
+ * history entry. Without it, DevTools replaces the URL itself. */
16
+ removeSearchParam?: (name: string) => void;
17
+ /** Moves the app to one of its own paths without loading the page again.
18
+ * Without it, DevTools uses `history.pushState`, which a router that
19
+ * patches it follows, as TanStack Router does. A router that changes the
20
+ * URL later answers a promise that settles once it has. */
21
+ navigate?: (href: string) => void | Promise<unknown>;
22
+ };
23
+ /** What the host hands DevTools. Every prop is optional: with none, DevTools
24
+ * works on a dev server that serves the app at `/`. */
25
+ type DevtoolsProps = {
26
+ /** The base path the dev server serves the app under, for example "/app/".
27
+ * The API answers below it, at `__ph/devtools/api`. "/" by default. */
28
+ base?: string;
29
+ /** Href of the standalone page. `__ph/devtools` below `base` by default. */
30
+ standaloneHref?: string;
31
+ /** Href that leaves the standalone page for the app. `base` by default. */
32
+ appHref?: string;
33
+ /** Pixels from the window's right edge that a control of the app takes at
34
+ * the bottom-right corner. The launcher rests left of it. */
35
+ bottomRightReserved?: number;
36
+ /** The URL that opens a project file, given by its absolute path, in the
37
+ * developer's editor. Vite's `__open-in-editor` below `base` by default. */
38
+ openInEditorUrl?: (path: string) => string;
39
+ app?: DevtoolsApp;
40
+ };
41
+ //#endregion
42
+ //#region src/app-source.d.ts
43
+ /**
44
+ * Where DevTools reads what the app around it knows. `read` answers the same
45
+ * object until something it holds changes, and `subscribe` tells of a change.
46
+ */
47
+ type AppSource = {
48
+ read: () => DevtoolsApp;
49
+ subscribe: (onChange: () => void) => () => void;
50
+ };
51
+ /**
52
+ * What a Powerhouse app keeps on `window.ph`: its loaded modules, its
53
+ * notifications and its router. It reads the page, not the app's code, so it
54
+ * works on any page that has `window.ph`, and gives nothing on one that has
55
+ * not. A change reaches it through the `ph:<key>Updated` events of the page.
56
+ */
57
+ export declare function powerhouseAppSource(): AppSource;
58
+ //#endregion
59
+ //#region src/mount.d.ts
60
+ type MountedProps = DevtoolsProps & {
61
+ /** "auto", the default, follows a `dark` class on `<html>`. */
62
+ theme?: "auto" | "light" | "dark";
63
+ /** "auto", the default, shows the standalone page while the location is
64
+ * its path, and the dock everywhere else. "page" shows the page wherever
65
+ * the location is: an app whose router keeps the location to itself says
66
+ * so while its router is on the page. */
67
+ surface?: "auto" | "page";
68
+ /** Where DevTools reads what the app knows. By default what a Powerhouse
69
+ * app keeps on `window.ph`. A member of `app` goes ahead of the source's. */
70
+ appSource?: AppSource;
71
+ };
72
+ export type MountDevtoolsOptions = MountedProps & {
73
+ /** Where the DevTools element goes. `document.body` by default. */
74
+ target?: HTMLElement;
75
+ };
76
+ export type DevtoolsHandle = {
77
+ /** Shows DevTools with `options` laid over the ones it has. */
78
+ update: (options: MountedProps) => void;
79
+ unmount: () => void;
80
+ };
81
+ /**
82
+ * Shows DevTools on a page of any app, whatever it is built with: the dock,
83
+ * and the standalone page when the location is its path. DevTools renders in
84
+ * a shadow root with its own stylesheet and its own React, so the page's
85
+ * styles and DevTools' do not reach each other.
86
+ *
87
+ * Returns the handle of what is mounted, or undefined on a page no DevTools
88
+ * dev server served, where it does nothing. A page has one DevTools: the dev
89
+ * server's module mounts it before the app's code runs, and a later call
90
+ * lays its `options` over that mount. The base path comes from the dev
91
+ * server's tag unless `options` has one.
92
+ */
93
+ export declare function mountDevtools({ target, ...given }?: MountDevtoolsOptions): DevtoolsHandle | undefined;
94
+ //#endregion
95
+ export type { AppSource, DevtoolsApp, DevtoolsProps };
96
+ export {};
97
+ //# sourceMappingURL=mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.ts","names":[],"sources":["../src/props.ts","../src/app-source.ts","../src/mount.tsx"],"mappings":";;;KAIY;;;EAGV;IAAkB;IAA4B;;;;EAG9C,eAAe;;;EAGf,qBAAqB;;;;;EAKrB,YAAY,wBAAwB;;;;KAK1B;;;EAGV;;EAEA;;EAEA;;;EAGA;;;EAGA,mBAAmB;EACnB,MAAM;;;;;;;;KC7BI;EACV,YAAY;EACZ,YAAY;;;;;;;;wBAkDE,uBAAuB;;;KC1ClC,eAAe;;EAElB;;;;;EAKA;;;EAGA,YAAY;;YAGF,uBAAuB;;EAEjC,SAAS;;YAGC;;EAEV,SAAS,SAAS;EAClB;;;;;;;;;;;;;;wBAmFc,gBAAgB,WAAW,UAAS,uBAChD"}