@hamur/devtools 0.0.0-stage → 0.0.2

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.
Files changed (134) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +24 -2
  3. package/dist/src/client.js +780 -0
  4. package/dist/src/index.js +1711 -0
  5. package/dist/types/src/apps/locator.d.ts +3 -0
  6. package/dist/types/src/bridge.d.ts +8 -0
  7. package/dist/types/src/client.d.ts +3 -0
  8. package/dist/types/src/dev/analyze.d.ts +31 -0
  9. package/dist/types/src/dev/assets.d.ts +33 -0
  10. package/dist/types/src/dev/authz.d.ts +49 -0
  11. package/dist/types/src/dev/bundle.d.ts +22 -0
  12. package/dist/types/src/dev/config.d.ts +24 -0
  13. package/dist/types/src/dev/handler.d.ts +20 -0
  14. package/dist/types/src/dev/modules.d.ts +28 -0
  15. package/dist/types/src/dev/overview.d.ts +20 -0
  16. package/dist/types/src/dev/processes.d.ts +4 -0
  17. package/dist/types/src/dev/server-routes.d.ts +7 -0
  18. package/dist/types/src/dev/tasks.d.ts +26 -0
  19. package/dist/types/src/dev/timeline.d.ts +20 -0
  20. package/dist/types/src/dev/virtual.d.ts +9 -0
  21. package/dist/types/src/icons.d.ts +24 -0
  22. package/dist/types/src/index.d.ts +8 -0
  23. package/dist/types/src/locator.d.ts +17 -0
  24. package/dist/types/src/mask.d.ts +8 -0
  25. package/dist/types/src/module.d.ts +27 -0
  26. package/dist/types/src/open-in-editor.d.ts +4 -0
  27. package/dist/types/src/options.d.ts +14 -0
  28. package/dist/types/src/panel/document.d.ts +16 -0
  29. package/dist/types/src/panel/groups.d.ts +14 -0
  30. package/dist/types/src/panel/index.d.ts +1 -0
  31. package/dist/types/src/panel/settings.d.ts +69 -0
  32. package/dist/types/src/panel/style.d.ts +1 -0
  33. package/dist/types/src/panel/ui.d.ts +34 -0
  34. package/dist/types/src/server/authz.d.ts +30 -0
  35. package/dist/types/src/server/index.d.ts +3 -0
  36. package/dist/types/src/server/routes.d.ts +6 -0
  37. package/dist/types/src/server/storage.d.ts +56 -0
  38. package/dist/types/src/source-link.d.ts +2 -0
  39. package/dist/types/src/tabs/analyze-model.d.ts +31 -0
  40. package/dist/types/src/tabs/analyze.d.ts +2 -0
  41. package/dist/types/src/tabs/assets.d.ts +11 -0
  42. package/dist/types/src/tabs/audit-model.d.ts +42 -0
  43. package/dist/types/src/tabs/audit.d.ts +2 -0
  44. package/dist/types/src/tabs/authz-model.d.ts +11 -0
  45. package/dist/types/src/tabs/authz.d.ts +2 -0
  46. package/dist/types/src/tabs/config.d.ts +8 -0
  47. package/dist/types/src/tabs/inspect.d.ts +7 -0
  48. package/dist/types/src/tabs/modules.d.ts +4 -0
  49. package/dist/types/src/tabs/overview.d.ts +2 -0
  50. package/dist/types/src/tabs/pages.d.ts +2 -0
  51. package/dist/types/src/tabs/payload.d.ts +6 -0
  52. package/dist/types/src/tabs/plugins-model.d.ts +15 -0
  53. package/dist/types/src/tabs/plugins.d.ts +2 -0
  54. package/dist/types/src/tabs/seo-model.d.ts +36 -0
  55. package/dist/types/src/tabs/seo.d.ts +2 -0
  56. package/dist/types/src/tabs/server-routes.d.ts +2 -0
  57. package/dist/types/src/tabs/storage.d.ts +13 -0
  58. package/dist/types/src/tabs/tasks-model.d.ts +16 -0
  59. package/dist/types/src/tabs/tasks.d.ts +2 -0
  60. package/dist/types/src/tabs/terminals-model.d.ts +53 -0
  61. package/dist/types/src/tabs/terminals.d.ts +2 -0
  62. package/dist/types/src/tabs/timeline-model.d.ts +58 -0
  63. package/dist/types/src/tabs/timeline.d.ts +2 -0
  64. package/dist/types/src/tester.d.ts +43 -0
  65. package/dist/types/src/toolbar/element.d.ts +28 -0
  66. package/dist/types/src/toolbar/shortcut.d.ts +14 -0
  67. package/dist/types/src/toolbar/style.d.ts +3 -0
  68. package/dist/types/src/view-context.d.ts +13 -0
  69. package/package.json +34 -4
  70. package/src/apps/locator.ts +131 -0
  71. package/src/bridge.ts +172 -0
  72. package/src/client.ts +10 -0
  73. package/src/dev/analyze.ts +128 -0
  74. package/src/dev/assets.ts +208 -0
  75. package/src/dev/authz.ts +162 -0
  76. package/src/dev/bundle.ts +91 -0
  77. package/src/dev/config.ts +132 -0
  78. package/src/dev/handler.ts +161 -0
  79. package/src/dev/modules.ts +60 -0
  80. package/src/dev/overview.ts +57 -0
  81. package/src/dev/processes.ts +34 -0
  82. package/src/dev/server-routes.ts +14 -0
  83. package/src/dev/tasks.ts +93 -0
  84. package/src/dev/timeline.ts +43 -0
  85. package/src/dev/virtual.ts +40 -0
  86. package/src/env.d.ts +21 -0
  87. package/src/icons.ts +48 -0
  88. package/src/index.ts +12 -0
  89. package/src/locator.ts +31 -0
  90. package/src/mask.ts +16 -0
  91. package/src/module.ts +352 -0
  92. package/src/open-in-editor.ts +18 -0
  93. package/src/options.ts +36 -0
  94. package/src/panel/document.ts +60 -0
  95. package/src/panel/groups.ts +41 -0
  96. package/src/panel/index.ts +429 -0
  97. package/src/panel/settings.ts +224 -0
  98. package/src/panel/style.ts +321 -0
  99. package/src/panel/ui.ts +52 -0
  100. package/src/server/authz.ts +110 -0
  101. package/src/server/index.ts +25 -0
  102. package/src/server/routes.ts +51 -0
  103. package/src/server/storage.ts +251 -0
  104. package/src/source-link.ts +29 -0
  105. package/src/tabs/analyze-model.ts +97 -0
  106. package/src/tabs/analyze.ts +217 -0
  107. package/src/tabs/assets.ts +375 -0
  108. package/src/tabs/audit-model.ts +216 -0
  109. package/src/tabs/audit.ts +223 -0
  110. package/src/tabs/authz-model.ts +28 -0
  111. package/src/tabs/authz.ts +337 -0
  112. package/src/tabs/config.ts +250 -0
  113. package/src/tabs/inspect.ts +101 -0
  114. package/src/tabs/modules.ts +58 -0
  115. package/src/tabs/overview.ts +104 -0
  116. package/src/tabs/pages.ts +188 -0
  117. package/src/tabs/payload.ts +224 -0
  118. package/src/tabs/plugins-model.ts +44 -0
  119. package/src/tabs/plugins.ts +95 -0
  120. package/src/tabs/seo-model.ts +140 -0
  121. package/src/tabs/seo.ts +162 -0
  122. package/src/tabs/server-routes.ts +469 -0
  123. package/src/tabs/storage.ts +313 -0
  124. package/src/tabs/tasks-model.ts +59 -0
  125. package/src/tabs/tasks.ts +287 -0
  126. package/src/tabs/terminals-model.ts +127 -0
  127. package/src/tabs/terminals.ts +294 -0
  128. package/src/tabs/timeline-model.ts +200 -0
  129. package/src/tabs/timeline.ts +260 -0
  130. package/src/tester.ts +158 -0
  131. package/src/toolbar/element.ts +428 -0
  132. package/src/toolbar/shortcut.ts +56 -0
  133. package/src/toolbar/style.ts +94 -0
  134. package/src/view-context.ts +93 -0
@@ -0,0 +1,3 @@
1
+ /** Outlines the element under the pointer with its component file and opens it on click; the island view outlines every island. */
2
+ declare const _default: import("hamur/app").DevtoolsApp;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { DevtoolsPage } from "hamur/app";
2
+ /** The channel the panel's own window reads the page hook through. */
3
+ export declare const BRIDGE_CHANNEL = "hamur:devtools";
4
+ export declare const OWN_WINDOW = "hamur-devtools";
5
+ /** The page side: while a panel window says `hello`, sends it a snapshot of `page` every second, its events and the answers to its calls. */
6
+ export declare function serveBridge(page: DevtoolsPage): void;
7
+ /** The window side: a `DevtoolsPage` whose reads return the last snapshot; `undefined` when no page answers within `timeout` ms. */
8
+ export declare function connectBridge(timeout?: number): Promise<DevtoolsPage | undefined>;
@@ -0,0 +1,3 @@
1
+ /** The client app plugin the module adds in `hamur dev`; an app never imports it. */
2
+ declare const _default: import("hamur/app").AppPlugin<{}>;
3
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { type DevAnalyzeReport } from "hamur/kit";
2
+ /** `api/analyze/<ISO time>`: a saved run with the treemap SVG made from it at answer time. */
3
+ export interface AnalyzeAnswer extends DevAnalyzeReport {
4
+ id: string;
5
+ treemap: string;
6
+ }
7
+ /** GET `api/analyze`: one saved run's totals. */
8
+ export interface AnalyzeListRow {
9
+ id: string;
10
+ bytes: number;
11
+ gzip: number;
12
+ chunks: number;
13
+ routes: number;
14
+ }
15
+ /** An error with the status a data route answers it with. */
16
+ export declare class AnalyzeError extends Error {
17
+ readonly status: number;
18
+ constructor(message: string, status: number);
19
+ }
20
+ export declare const RUN_ID: RegExp;
21
+ export interface Analyzer {
22
+ run(): Promise<AnalyzeAnswer>;
23
+ list(): Promise<AnalyzeListRow[]>;
24
+ read(id: string): Promise<AnalyzeAnswer>;
25
+ }
26
+ /** The saved runs of `dir`; a run asked for while one builds joins that build and answers its result, so one build runs at a time. */
27
+ export declare function createAnalyzer({ dir, build, now, }: {
28
+ dir: string;
29
+ build: () => Promise<DevAnalyzeReport | undefined>;
30
+ now?: () => Date;
31
+ }): Analyzer;
@@ -0,0 +1,33 @@
1
+ import type { DevPublicAsset } from "hamur/kit";
2
+ export type AssetType = "image" | "font" | "text" | "other";
3
+ /** `api/assets`: one public file; `module` marks a module's asset, which the tab shows read-only. */
4
+ export interface AssetRow {
5
+ url: string;
6
+ file?: string;
7
+ bytes: number;
8
+ type: AssetType;
9
+ width?: number;
10
+ height?: number;
11
+ module?: string;
12
+ }
13
+ export declare const MAX_UPLOAD_BYTES: number;
14
+ export declare const assetType: (path: string) => AssetType;
15
+ /** Width and height from the image's header with `Bun.Image`; `undefined` when it does not decode. */
16
+ export declare function imageSize(input: Blob | Uint8Array): Promise<{
17
+ width: number;
18
+ height: number;
19
+ } | undefined>;
20
+ /** One row of `api/assets`; `undefined` for a file gone since it was listed. */
21
+ export declare function assetRow(rootDir: string, baseURL: string, asset: DevPublicAsset): Promise<AssetRow | undefined>;
22
+ /** GET `api/assets`: `public/` files, then module assets, sorted by URL. */
23
+ export declare function assetsAnswer(rootDir: string, baseURL: string, assets: DevPublicAsset[]): Promise<AssetRow[]>;
24
+ /** The reason `name` cannot be written as `public/<name>`, or `undefined`. */
25
+ export declare function nameProblem(name: string): string | undefined;
26
+ export interface UploadOptions {
27
+ rootDir: string;
28
+ publicDir: string;
29
+ baseURL: string;
30
+ rows: () => Promise<AssetRow[]>;
31
+ }
32
+ /** POST `api/assets`: writes the one `file` part as `public/<name>`; an existing file needs `?overwrite=1`. */
33
+ export declare function uploadAsset(request: Request, options: UploadOptions): Promise<Response>;
@@ -0,0 +1,49 @@
1
+ import type { HamurContext } from "hamur/kit";
2
+ /** One policy of the compiled set. */
3
+ export interface PolicyRow {
4
+ id: string;
5
+ effect: "permit" | "forbid";
6
+ principal: string;
7
+ action: string;
8
+ resource: string;
9
+ template: boolean;
10
+ /** As the build's messages name it: from the app root, or absolute outside it. */
11
+ file: string;
12
+ line: number;
13
+ column: number;
14
+ text: string;
15
+ }
16
+ /** An entity type. */
17
+ export interface EntityTypeRow {
18
+ name: string;
19
+ attributes: Array<{
20
+ name: string;
21
+ type: string;
22
+ required: boolean;
23
+ }>;
24
+ /** Every type it is in, transitively. */
25
+ parents: string[];
26
+ tags?: string;
27
+ enum?: string[];
28
+ }
29
+ /** An action. */
30
+ export interface ActionRow {
31
+ name: string;
32
+ groups: string[];
33
+ appliesTo?: {
34
+ principals: string[];
35
+ resources: string[];
36
+ context: string;
37
+ };
38
+ }
39
+ export interface PoliciesAnswer {
40
+ policies: PolicyRow[];
41
+ entityTypes: EntityTypeRow[];
42
+ actions: ActionRow[];
43
+ }
44
+ /** The tab is shown when the app or a layer has a `server/policies/` folder. */
45
+ export declare function hasPolicies(options: Pick<HamurContext["options"], "serverDir" | "layers">): boolean;
46
+ /** The lines of a policy: from its first line to the line before the next policy of the file, trailing blank and comment lines dropped. */
47
+ export declare function policyText(lines: readonly string[], line: number, next: number | undefined): string;
48
+ /** The compiled policies, schema and actions of `state`; empty without one. */
49
+ export declare function policiesAnswer(state: HamurContext["authz"]): Promise<PoliciesAnswer>;
@@ -0,0 +1,22 @@
1
+ export type PanelBuild = {
2
+ files: Map<string, Blob>;
3
+ } | {
4
+ error: string;
5
+ };
6
+ export interface PanelBundle {
7
+ /** The in-memory build, made on the first call and kept until `drop`; a failed one is made again on the next call. */
8
+ build(): Promise<PanelBuild>;
9
+ /** Forgets the build when `file` is one of its inputs; true when it did. */
10
+ drop(file: string): boolean;
11
+ }
12
+ export declare const VIEWS_MODULE = "#hamur/devtools-views";
13
+ /** The module `#hamur/devtools-views`: one lazy import per module tab, so each view is a chunk of the panel build. */
14
+ export declare function viewsSource(views: Array<{
15
+ name: string;
16
+ entry: string;
17
+ }>): string;
18
+ /** `Bun.build` of the panel and the module tabs' views, kept in memory and served below `<baseURL>_hamur/devtools/`. */
19
+ export declare function createPanelBundle(entry: string, views?: () => Array<{
20
+ name: string;
21
+ entry: string;
22
+ }>, define?: Record<string, string>): PanelBundle;
@@ -0,0 +1,24 @@
1
+ import { type DevServerConfig, type Redactor } from "hamur/kit";
2
+ export declare const MAX_DEPTH = 8;
3
+ export interface ConfigAnswer {
4
+ options: unknown;
5
+ runtimeConfig: {
6
+ public: unknown;
7
+ private: unknown;
8
+ };
9
+ }
10
+ /** A value as JSON the panel can show: functions, symbols, bigints, class instances, cycles and depth past `MAX_DEPTH` become strings; redacted keys `[redacted]`. */
11
+ export declare function serialize(value: unknown, redactor: Redactor, depth?: number, seen?: object[]): unknown;
12
+ /** The private runtime config with each value that is not a plain object `MASKED`, and each key the redactor matches `[redacted]`. */
13
+ export declare function maskPrivate(value: unknown, redactor: Redactor, depth?: number): unknown;
14
+ /** `api/config`: nothing private and nothing the redactor matches leaves the runner as its value. */
15
+ export declare function configAnswer(options: Record<string, unknown>, server: DevServerConfig, redactor: Redactor): ConfigAnswer;
16
+ /** `api/config/reveal`: one private value by its dot path; a path through a key the redactor matches stays `[redacted]`. */
17
+ export declare function revealAnswer(server: DevServerConfig, path: unknown, redactor: Redactor): {
18
+ value: unknown;
19
+ };
20
+ /** `api/config/runtime`: the dot path names a key `runtimeConfig.public` already has, shown whole, and the value has its JSON type. */
21
+ export declare function publicEdit(server: DevServerConfig, args: unknown, redactor: Redactor): {
22
+ path: string;
23
+ value: unknown;
24
+ };
@@ -0,0 +1,20 @@
1
+ import type { DevHandler, DevtoolsRegistry } from "hamur/kit";
2
+ import { type PanelConfig } from "../panel/document.ts";
3
+ import type { PanelBundle } from "./bundle.ts";
4
+ /** A runner-side devtools data route: the methods it answers and its JSON answer, or a `Response` of its own. */
5
+ export interface DataRoute {
6
+ method: "GET" | "POST" | Array<"GET" | "POST">;
7
+ /** The route also answers `<name>/<segment>`, its `answer` getting the decoded segment. */
8
+ param?: boolean;
9
+ answer(request: Request, param?: string): unknown;
10
+ }
11
+ export declare const json: (body: unknown, status?: number, headers?: Record<string, string>) => Response;
12
+ export declare const RPC_MAX_BYTES: number;
13
+ /** The module's dev handler of `<baseURL>_hamur/devtools/`: the panel document, its bundle and the runner-side `api/*`. */
14
+ export declare function createDevtoolsHandler(options: {
15
+ config: PanelConfig;
16
+ bundle: PanelBundle;
17
+ routes: Record<string, DataRoute>;
18
+ rpc: DevtoolsRegistry["rpc"];
19
+ log: (message: string) => void;
20
+ }): DevHandler;
@@ -0,0 +1,28 @@
1
+ import type { AppPluginInfo, InstalledModule, Redactor } from "hamur/kit";
2
+ /** `api/modules`: one configured module; `options` as its `setup` received them, with every key the redactor matches `"[redacted]"`. */
3
+ export interface ModuleRow {
4
+ name: string;
5
+ version: string | null;
6
+ configKey: string | null;
7
+ options: unknown;
8
+ }
9
+ /** `api/plugins`: the app plugins with their file, and the server plugins `defineServer` lists with theirs. */
10
+ export interface PluginsAnswer {
11
+ app: Array<{
12
+ name: string;
13
+ file: string;
14
+ mode: AppPluginInfo["mode"];
15
+ order: number;
16
+ }>;
17
+ server: Array<{
18
+ file: string;
19
+ module?: string;
20
+ }>;
21
+ }
22
+ /** The `version` of the nearest `package.json` above `file`, looking no higher than the app's own folder, whose version is not a module's. */
23
+ export declare function moduleVersion(file: string | undefined, rootDir: string): string | null;
24
+ export declare function modulesAnswer(modules: readonly InstalledModule[], rootDir: string, redactor: Redactor): ModuleRow[];
25
+ export declare function pluginsAnswer(app: readonly AppPluginInfo[], server: ReadonlyArray<{
26
+ file: string;
27
+ module?: string;
28
+ }>, rootDir: string): PluginsAnswer;
@@ -0,0 +1,20 @@
1
+ import type { HamurContext, ServerPlugins } from "hamur/kit";
2
+ export interface OverviewAnswer {
3
+ versions: {
4
+ hamur: string | null;
5
+ adapter: string | null;
6
+ library: string | null;
7
+ bun: string;
8
+ };
9
+ counts: {
10
+ pages: number;
11
+ serverRoutes: number;
12
+ modules: number;
13
+ appPlugins: number;
14
+ serverPlugins: number | null;
15
+ };
16
+ }
17
+ /** The `version` of the package `name`, found by resolving `specifier` from `from` and walking up to the `package.json` that carries that name. */
18
+ export declare function packageVersion(specifier: string, name: string, from: string): string | null;
19
+ /** `api/overview`: what the build already knows, counted without a scan; `serverPlugins` comes from `useServerPlugins()`. */
20
+ export declare function overviewAnswer(hamur: Pick<HamurContext, "options" | "routes" | "serverRoutes" | "plugins">, serverPlugins: ServerPlugins): OverviewAnswer;
@@ -0,0 +1,4 @@
1
+ import type { DevtoolsRegistry } from "hamur/kit";
2
+ import { type DataRoute } from "./handler.ts";
3
+ /** `api/processes` (GET) and `api/processes/<name>/restart`, `api/processes/<name>/kill` (POST, 204), only for a registered name. */
4
+ export declare function createProcessesRoute(processes: DevtoolsRegistry["processes"]): DataRoute;
@@ -0,0 +1,7 @@
1
+ import type { DevRouteTable, DevServerRoutes } from "hamur/kit";
2
+ export type ServerRouteRow = DevRouteTable["serverRoutes"][number] & {
3
+ middleware: string[];
4
+ bodySchema?: Record<string, unknown>;
5
+ };
6
+ /** `api/server-routes`: the route table's server routes, the serving process's middleware on each and the JSON Schema of each handler's `schema.body`; both are empty while no server process serves. */
7
+ export declare function serverRoutesAnswer(table: DevRouteTable, served: DevServerRoutes | undefined): ServerRouteRow[];
@@ -0,0 +1,26 @@
1
+ import type { DevtoolsRegistry } from "hamur/kit";
2
+ import { type DataRoute } from "./handler.ts";
3
+ /** One task of the build. */
4
+ export interface TaskRow {
5
+ name: string;
6
+ description?: string;
7
+ /** From the app root. */
8
+ file: string;
9
+ /** Set for a queued listener: the app event it runs on. */
10
+ listener?: string;
11
+ /** Epoch ms of the next firing in UTC; none when the expression cannot be read. */
12
+ schedules: Array<{
13
+ cron: string;
14
+ next?: number;
15
+ }>;
16
+ }
17
+ export declare function tasksAnswer(tasks: readonly {
18
+ name: string;
19
+ file: string;
20
+ description?: string;
21
+ listener?: string;
22
+ }[], scheduled: Readonly<Record<string, string | readonly string[]>>, rootDir: string, now?: number): {
23
+ tasks: TaskRow[];
24
+ };
25
+ /** `api/tasks/runs` (GET), `api/tasks/pending` (GET) and `api/tasks/cancel` (POST, 204) over the RPCs `devtools:task-runs` and `devtools:task-cancel`. */
26
+ export declare function createTasksRoute(rpc: DevtoolsRegistry["rpc"]): DataRoute;
@@ -0,0 +1,20 @@
1
+ import { type DevSpan, type Redactor } from "hamur/kit";
2
+ /** `api/spans`: a server span of one trace, its attributes redacted by the redactor's rule. */
3
+ export interface SpanRow {
4
+ traceId: string;
5
+ spanId: string;
6
+ parentSpanId?: string;
7
+ name: string;
8
+ kind: DevSpan["kind"];
9
+ startTime: number;
10
+ endTime: number;
11
+ status: DevSpan["status"];
12
+ attributes: Record<string, unknown>;
13
+ events: Array<{
14
+ name: string;
15
+ time: number;
16
+ }>;
17
+ }
18
+ /** The trace id of an `api/spans` call; a missing or malformed one throws, which answers 400. */
19
+ export declare function traceOf(args: unknown): string;
20
+ export declare function spansAnswer(spans: readonly DevSpan[], redactor: Redactor): SpanRow[];
@@ -0,0 +1,9 @@
1
+ import type { HamurContext } from "hamur/kit";
2
+ /** `api/virtual`: a `#hamur/*` virtual module or a `.hamur/` template with the text a build reads; `file` when the template is also written to `.hamur/`. */
3
+ export interface VirtualRow {
4
+ id: string;
5
+ source: string;
6
+ file?: string;
7
+ }
8
+ /** The virtual modules a template does not make, then the templates, each sorted by name; a source that throws is the message in its place. */
9
+ export declare function virtualAnswer(hamur: Pick<HamurContext, "vfs" | "templates">): Promise<VirtualRow[]>;
@@ -0,0 +1,24 @@
1
+ /** The 16 px SVG icons of the built-in tabs (by tab name), the locator app, the settings button and the Hamur mark. */
2
+ export declare const TAB_ICONS: {
3
+ overview: string;
4
+ pages: string;
5
+ payload: string;
6
+ config: string;
7
+ "server-routes": string;
8
+ storage: string;
9
+ assets: string;
10
+ tasks: string;
11
+ authz: string;
12
+ timeline: string;
13
+ plugins: string;
14
+ modules: string;
15
+ inspect: string;
16
+ analyze: string;
17
+ terminals: string;
18
+ audit: string;
19
+ seo: string;
20
+ };
21
+ export declare const LOCATOR_ICON = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M12 8.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7z\" fill=\"currentColor\" fill-opacity=\"0.16\" stroke=\"none\"></path><path d=\"M12 4.5a7.5 7.5 0 1 1 0 15 7.5 7.5 0 0 1 0-15zM12 1.5v3M12 19.5v3M1.5 12h3M19.5 12h3\"></path></svg>";
22
+ export declare const SETTINGS_ICON = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M15.5 4.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5zM8.5 14.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5z\" fill=\"currentColor\" fill-opacity=\"0.16\" stroke=\"none\"></path><path d=\"M3.5 7h9M18.5 7h2M3.5 17h2M11.5 17h9M15.5 4.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5zM8.5 14.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5z\"></path></svg>";
23
+ export declare const WINDOW_ICON = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M5.5 5.5h13a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1h-13a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1zM4.5 9.5h15M13 13.5l3-3M13.5 10.5H16v2.5\"></path></svg>";
24
+ export declare const HAMUR_MARK = "<svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M4.5 16c0-5 3.4-9 7.5-9s7.5 4 7.5 9M3.5 16h17M9.5 12.5v.5M14.5 12.5v.5\"></path></svg>";
@@ -0,0 +1,8 @@
1
+ import type { DevtoolsOptions } from "./options.ts";
2
+ export { default } from "./module.ts";
3
+ export type { DevtoolsOptions } from "./options.ts";
4
+ declare module "hamur" {
5
+ interface HamurModuleOptions {
6
+ devtools?: DevtoolsOptions;
7
+ }
8
+ }
@@ -0,0 +1,17 @@
1
+ export interface SourceLocation {
2
+ file: string;
3
+ line: number;
4
+ column: number;
5
+ }
6
+ /** The value of `data-hamur-src`, `<file>:<line>:<column>`; `undefined` for any other text. */
7
+ export declare function parseLocation(value: string | null | undefined): SourceLocation | undefined;
8
+ /** The nearest element at or above `element` that carries a source locator, with what it says. */
9
+ export declare function nearestLocation(element: Element | null): {
10
+ element: Element;
11
+ location: SourceLocation;
12
+ } | undefined;
13
+ /** An island's component name and hydration directive from its `component` chunk key and `on` attributes. */
14
+ export declare function describeIsland(component: string | null, on: string | null): {
15
+ name: string;
16
+ directive: string;
17
+ };
@@ -0,0 +1,8 @@
1
+ /** What `api/config` shows in place of a private runtime config value until it is revealed. */
2
+ export declare const MASKED = "\u2022\u2022\u2022\u2022";
3
+ export declare const TOO_DEEP = "[Max depth]";
4
+ export declare const CIRCULAR = "[Circular]";
5
+ /** `REDACTED` of `hamur/kit`, written out because the panel bundle cannot import the kit. */
6
+ export declare const REDACTED_TEXT = "[redacted]";
7
+ /** True when `value` holds text the serializer wrote in place of a value, which an edit must not write back. */
8
+ export declare function holdsPlaceholder(value: unknown): boolean;
@@ -0,0 +1,27 @@
1
+ import { type DevtoolsRegistry } from "hamur/kit";
2
+ import { type DevtoolsOptions } from "./options.ts";
3
+ /** `api/tabs`, every tab and app in registration order; module view and app entries stay on the runner. */
4
+ export declare function tabsAnswer(registry: DevtoolsRegistry): {
5
+ tabs: {
6
+ name: string;
7
+ title: string;
8
+ icon: string;
9
+ view: Readonly<{
10
+ type: "iframe";
11
+ src: string;
12
+ }> | {
13
+ type: "module";
14
+ };
15
+ module: string;
16
+ }[];
17
+ apps: {
18
+ name: string;
19
+ title: string;
20
+ icon: string;
21
+ module: string;
22
+ }[];
23
+ };
24
+ /** The template `devtools/apps`, one lazy import per app for the toolbar. */
25
+ export declare function appsSource(registry: DevtoolsRegistry): string;
26
+ declare const _default: import("hamur/kit").HamurModule<DevtoolsOptions>;
27
+ export default _default;
@@ -0,0 +1,4 @@
1
+ /** `<baseURL>_hamur/open-in-editor`. */
2
+ export declare const editorEndpoint: (baseURL: string) => string;
3
+ /** Asks the dev server to open `file` (relative to `rootDir` or absolute) in the editor; a refused answer is logged as a warning. */
4
+ export declare function openInEditor(endpoint: string, file: string, line?: number, column?: number): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import { type Placement } from "./panel/settings.ts";
2
+ /** The `devtools` config key. */
3
+ export interface DevtoolsOptions {
4
+ enabled?: boolean;
5
+ shortcut?: string | false;
6
+ placement?: Placement;
7
+ }
8
+ export interface ResolvedDevtoolsOptions {
9
+ enabled: boolean;
10
+ shortcut: string | false;
11
+ placement: Placement;
12
+ }
13
+ /** The first wrong value throws. */
14
+ export declare function resolveOptions(input: DevtoolsOptions | undefined): ResolvedDevtoolsOptions;
@@ -0,0 +1,16 @@
1
+ import type { Placement } from "./settings.ts";
2
+ export interface PanelConfig {
3
+ baseURL: string;
4
+ shortcut: string | false;
5
+ placement: Placement;
6
+ }
7
+ export declare const PANEL_CONFIG_ID = "hamur-devtools-config";
8
+ /** The fixed panel document; with `error` (a failed bundle) the content area shows it and no script runs. */
9
+ export declare function panelDocument(config: PanelConfig, error?: string): string;
10
+ export declare const PANEL_HEADERS: {
11
+ "content-type": string;
12
+ "cache-control": string;
13
+ "content-security-policy": string;
14
+ "x-frame-options": string;
15
+ "referrer-policy": string;
16
+ };
@@ -0,0 +1,14 @@
1
+ import { type DevtoolsSettings } from "./settings.ts";
2
+ export declare const GROUPS: readonly ["App", "Server", "Performance", "Debug", "Modules"];
3
+ export type Group = (typeof GROUPS)[number];
4
+ /** The sidebar group of each built-in tab; every other tab is under "Modules". */
5
+ export declare const TAB_GROUPS: Record<string, Exclude<Group, "Modules">>;
6
+ export declare const BUILT_IN_MODULE = "devtools";
7
+ /** The tabs of `orderTabs` in their groups, the groups in `GROUPS` order; a group with no tab is left out. */
8
+ export declare function groupTabs<T extends {
9
+ name: string;
10
+ module: string;
11
+ }>(tabs: readonly T[], settings: Pick<DevtoolsSettings, "hidden" | "order">): Array<{
12
+ group: Group;
13
+ tabs: T[];
14
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
1
+ export declare const SETTINGS_KEY = "hamur:devtools";
2
+ export declare const PLACEMENTS: readonly ["bottom-center", "bottom-left", "bottom-right", "top-center", "top-left", "top-right"];
3
+ export type Placement = (typeof PLACEMENTS)[number];
4
+ export declare const THEMES: readonly ["system", "light", "dark"];
5
+ export type Theme = (typeof THEMES)[number];
6
+ export declare const MIN_SCALE = 0.75;
7
+ export declare const MAX_SCALE = 1.5;
8
+ export declare const MIN_PANEL_WIDTH = 240;
9
+ export declare const MIN_PANEL_HEIGHT = 120;
10
+ export interface PanelRect {
11
+ x: number;
12
+ y: number;
13
+ width: number;
14
+ height: number;
15
+ }
16
+ /** `{ dock: "bottom" }` is the panel at the bottom edge with the kept `height`. */
17
+ export type PanelFrame = {
18
+ dock: "bottom";
19
+ } | PanelRect;
20
+ export declare const isDocked: (frame: PanelFrame | undefined) => frame is {
21
+ dock: "bottom";
22
+ } | undefined;
23
+ /** Where the pill was dropped, as fractions of the viewport. */
24
+ export interface PillPlace {
25
+ x: number;
26
+ y: number;
27
+ }
28
+ /** The viewer's own choices, kept in `localStorage`, not in the repo. */
29
+ export interface DevtoolsSettings {
30
+ hidden: string[];
31
+ order: string[];
32
+ theme: Theme;
33
+ scale: number;
34
+ placement?: Placement;
35
+ height: number;
36
+ panel?: PanelFrame;
37
+ pill?: PillPlace;
38
+ }
39
+ export declare const DEFAULT_SETTINGS: DevtoolsSettings;
40
+ /** A missing or broken value, or a broken field, reads as the default. */
41
+ export declare function parseSettings(text: string | null): DevtoolsSettings;
42
+ export declare function readSettings(): DevtoolsSettings;
43
+ export declare function writeSettings(settings: DevtoolsSettings): void;
44
+ /** `order` first, then the rest in registration order; `hidden` left out. */
45
+ export declare function orderTabs<T extends {
46
+ name: string;
47
+ }>(tabs: readonly T[], settings: Pick<DevtoolsSettings, "hidden" | "order">): T[];
48
+ export interface Viewport {
49
+ width: number;
50
+ height: number;
51
+ }
52
+ /** The rectangle kept inside the viewport: at least 240 × 120 px (less when the viewport is smaller), whole in view. */
53
+ export declare function clampRect(rect: PanelRect, viewport: Viewport): PanelRect;
54
+ export type Edge = "n" | "s" | "e" | "w" | "ne" | "nw" | "se" | "sw";
55
+ /** `start` moved by the pointer's travel `dx`, `dy` on `edge`: the opposite edge stays where it is, even when the minimum size stops the drag. */
56
+ export declare function resizeRect(start: PanelRect, edge: Edge, dx: number, dy: number, viewport: Viewport): PanelRect;
57
+ /** Where the pill sits in px for the kept fractions, whole in view. */
58
+ export declare function pillPosition(place: PillPlace, size: Viewport, viewport: Viewport): {
59
+ left: number;
60
+ top: number;
61
+ };
62
+ export interface ViewState {
63
+ open: boolean;
64
+ tab?: string;
65
+ }
66
+ export declare const VIEW_KEY = "hamur:devtools:view";
67
+ export declare function parseView(text: string | null): ViewState;
68
+ export declare function readView(): ViewState;
69
+ export declare function writeView(view: ViewState): void;
@@ -0,0 +1 @@
1
+ export declare const PANEL_CSS: string;
@@ -0,0 +1,34 @@
1
+ /** Makes a `tag` element with `props` (`className` for its utility classes) and appends `children`. */
2
+ export declare const element: <K extends keyof HTMLElementTagNameMap>(tag: K, props?: Partial<HTMLElementTagNameMap[K]>, ...children: (Node | string)[]) => HTMLElementTagNameMap[K];
3
+ export declare const FOCUS = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
4
+ /** The utility class strings the panel's own views share, as on the design boards. */
5
+ export declare const UI: {
6
+ readonly button: "inline-flex items-center gap-1.5 h-6 px-2 rounded-md border-0 bg-transparent text-fg-2 ring-1 ring-inset ring-line-strong font-medium text-sm whitespace-nowrap cursor-pointer hover:bg-hover hover:text-fg disabled:opacity-40 disabled:cursor-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
7
+ readonly primary: "inline-flex items-center gap-1.5 h-6 px-2 rounded-md border-0 bg-fg text-app font-medium text-sm whitespace-nowrap cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
8
+ readonly iconButton: "inline-flex items-center justify-center size-6 rounded-md border-0 bg-transparent text-fg-3 cursor-pointer hover:bg-hover hover:text-fg disabled:opacity-40 disabled:cursor-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
9
+ readonly field: "h-6 min-w-0 px-2 rounded-md border-0 bg-field ring-1 ring-inset ring-line text-xs text-fg placeholder:text-fg-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
10
+ readonly strip: "flex-none flex items-center gap-2 h-9 px-3 border-b border-line";
11
+ readonly groupHead: "flex items-center gap-2 h-8 mt-1 px-4 bg-field text-xs";
12
+ readonly label: "pb-0.5 text-xs font-medium text-fg-3";
13
+ readonly row: "flex items-center gap-3 min-h-7 text-sm";
14
+ readonly rowKey: "flex-none w-24 text-fg-3";
15
+ readonly rowValue: "flex-1 flex items-center gap-2 min-w-0 text-fg";
16
+ readonly notice: "m-0 p-4 text-sm text-fg-3";
17
+ readonly error: "m-0 p-4 whitespace-pre-wrap font-mono text-xs text-red";
18
+ readonly th: "h-8 px-2.5 border-b border-line text-left text-xs font-medium text-fg-3 whitespace-nowrap";
19
+ readonly td: "h-9 px-2.5 align-middle";
20
+ readonly tr: "hover:bg-hover";
21
+ readonly textarea: "block w-full min-h-20 px-2 py-1.5 rounded-md border-0 bg-field ring-1 ring-inset ring-line font-mono text-xs text-fg placeholder:text-fg-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
22
+ readonly pill: "inline-flex items-center gap-1.5 h-6 px-2 rounded-md border-0 font-medium text-xs whitespace-nowrap cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
23
+ readonly chip: "inline-flex items-center justify-center h-5 px-1.5 rounded-full ring-1 ring-inset ring-line-strong font-mono text-2xs font-semibold text-fg-2";
24
+ readonly hint: "text-xs text-fg-3";
25
+ readonly fail: "text-xs text-red";
26
+ readonly item: "flex items-center gap-3 min-h-8 mx-1.5 px-2.5 rounded-md";
27
+ readonly listButton: "flex items-center gap-2 w-full min-h-7 px-2.5 py-1 border-0 rounded-md bg-transparent text-left text-xs font-mono cursor-pointer hover:bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent";
28
+ };
29
+ /** A toggle button's classes: `on` marks the one that is selected. */
30
+ export declare const pill: (on: boolean) => string;
31
+ /** An underlined tab's classes: `on` marks the selected one. */
32
+ export declare const tab: (on: boolean) => string;
33
+ /** Colours a status line: red and `data-error` when it reports a failure, the muted hint colour otherwise. */
34
+ export declare function tone(node: HTMLElement, failed: boolean): void;
@@ -0,0 +1,30 @@
1
+ import { explainAs, type AuthzDecisionRecord } from "hamur/server/internal";
2
+ import type { HamurEvent } from "hamur/server";
3
+ export type { AuthzDecisionRecord };
4
+ /** A check with its place in the order this process made them. */
5
+ export type DecisionRow = AuthzDecisionRecord & {
6
+ seq: number;
7
+ };
8
+ /** The checks the dev server keeps. */
9
+ export declare const DECISIONS_MAX = 200;
10
+ /** How long the checks of one burst wait before they go to the panel in one push. */
11
+ export declare const PUSH_DELAY_MS = 100;
12
+ /** The newest `size` checks and the push of what is new, at most once per `delay` ms. */
13
+ export declare function createDecisionFeed(post: (decisions: DecisionRow[]) => void, size?: number, delay?: number): {
14
+ add(record: AuthzDecisionRecord): void;
15
+ /** Newest first. */
16
+ list: () => DecisionRow[];
17
+ flush: () => void;
18
+ };
19
+ /** Records every check of this process from now on; stopped by `unwatchDecisions`. */
20
+ export declare function watchAuthz(): void;
21
+ export declare function unwatchDecisions(): void;
22
+ /** `GET api/authz/decisions`: the last 200 checks of this process, newest first. */
23
+ export declare function answerDecisions(request: Request, list?: () => DecisionRow[]): Response;
24
+ /** An entity written as `User::"7"`, or the sentence that says what it must be. */
25
+ export declare function parseUid(part: "principal" | "resource", value: unknown): {
26
+ type: string;
27
+ id: string;
28
+ } | string;
29
+ /** `POST api/authz/explain` with `{ principal, action, resource, context? }`: the `explain` for that request. */
30
+ export declare function answerExplain(request: Request, event: HamurEvent, explain?: typeof explainAs): Promise<Response>;
@@ -0,0 +1,3 @@
1
+ export { devtoolsAuthzDecisions, devtoolsAuthzExplain, devtoolsStorageItem, devtoolsStorageKeys, devtoolsStorageMounts, devtoolsUnknown, } from "./routes.ts";
2
+ declare const _default: import("hamur/server").ServerDefinition;
3
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export declare const devtoolsStorageMounts: import("hamur/adapter").Handler<unknown, Response, unknown, Response, {}>;
2
+ export declare const devtoolsStorageKeys: import("hamur/adapter").Handler<unknown, Response, unknown, Response, {}>;
3
+ export declare const devtoolsStorageItem: import("hamur/adapter").Handler<unknown, Response, unknown, Response, {}>;
4
+ export declare const devtoolsAuthzDecisions: import("hamur/adapter").Handler<unknown, Response, unknown, Response, {}>;
5
+ export declare const devtoolsAuthzExplain: import("hamur/adapter").Handler<unknown, Response, unknown, Response, {}>;
6
+ export declare const devtoolsUnknown: import("hamur/adapter").Handler<unknown, Response, unknown, Response, {}>;