@farm.js/devtools 0.1.0-beta.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/README.md +34 -0
- package/THIRD-PARTY-NOTICES.md +24 -0
- package/dist/client.d.ts +13 -0
- package/dist/client.js +30 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +67 -0
- package/dist/modules.d.ts +14 -0
- package/dist/modules.js +116 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +126 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +1 -0
- package/dist/ui/LICENSE-geist-mono.txt +93 -0
- package/dist/ui/LICENSE-geist.txt +93 -0
- package/dist/ui/geist-cyrillic-ext-wght-normal-RO72NYA2.woff2 +0 -0
- package/dist/ui/geist-cyrillic-wght-normal-CK2XY27K.woff2 +0 -0
- package/dist/ui/geist-latin-ext-wght-normal-XEQ56JUF.woff2 +0 -0
- package/dist/ui/geist-latin-wght-normal-T72VVCUW.woff2 +0 -0
- package/dist/ui/geist-mono-cyrillic-ext-wght-normal-QXKVIKFD.woff2 +0 -0
- package/dist/ui/geist-mono-cyrillic-wght-normal-GOIAQAGU.woff2 +0 -0
- package/dist/ui/geist-mono-latin-ext-wght-normal-HU3ZAWN6.woff2 +0 -0
- package/dist/ui/geist-mono-latin-wght-normal-CJNQKXUG.woff2 +0 -0
- package/dist/ui/geist-mono-symbols2-wght-normal-WZJJVLQO.woff2 +0 -0
- package/dist/ui/geist-mono-vietnamese-wght-normal-KW5NM6YV.woff2 +0 -0
- package/dist/ui/geist-vietnamese-wght-normal-Y2R7JZKV.woff2 +0 -0
- package/dist/ui/logo.svg +8 -0
- package/dist/ui/panel.css +1 -0
- package/dist/ui/panel.js +10 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @farm.js/devtools
|
|
2
|
+
|
|
3
|
+
A development-only workspace for Farm.js routes, APIs, integrations, runtime diagnostics, and
|
|
4
|
+
browser modules. Uses the Farm logo, bundled Geist fonts, light/dark themes, and syntax-highlighted
|
|
5
|
+
source and JSON with safe copy controls.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { defineConfig } from "@farm.js/core";
|
|
9
|
+
import { devtools } from "@farm.js/devtools";
|
|
10
|
+
|
|
11
|
+
export default defineConfig({ plugins: [devtools()] });
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Install with `pnpm add -D @farm.js/devtools`. Open the lower-left launcher or press
|
|
15
|
+
`Command/Ctrl + Shift + .` during `farm dev`. The UI loads only when opened. The plugin is
|
|
16
|
+
removed from production configuration, with no production client or server endpoint.
|
|
17
|
+
|
|
18
|
+
Options: `launcher?: boolean`, `shortcut?: string | false`, `inspect?: boolean`. Registration
|
|
19
|
+
is the opt-in; there is no `enabled` option. Existing top-level DevTools configuration remains
|
|
20
|
+
supported without the plugin. Do not combine it with `devtools: false`.
|
|
21
|
+
|
|
22
|
+
Inspect compares the current application source with Vite's cached browser output, not individual
|
|
23
|
+
plugin stages. Only already-transformed, in-project browser source is eligible; virtual/server-only
|
|
24
|
+
modules, dependencies, hidden paths, and outside-project symlinks are excluded. Limits: 500 listed
|
|
25
|
+
modules, 1 MiB per source/output, 1,500 displayed lines. Copy includes the full bounded text.
|
|
26
|
+
|
|
27
|
+
DevTools is read-only, not an authentication boundary for a public development server. Environment
|
|
28
|
+
values are absent from snapshots; literals in client source are not redacted. Keep development
|
|
29
|
+
servers private. Assets and highlighting are local, without CDN calls.
|
|
30
|
+
|
|
31
|
+
Full documentation: https://farmjs.dev/docs/plugins/devtools
|
|
32
|
+
|
|
33
|
+
This package is independently versioned and is picked up by the workspace build, test, packing,
|
|
34
|
+
and publishing scripts. No starter dependency is added automatically.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Bundled UI dependencies
|
|
2
|
+
|
|
3
|
+
- **sugar-high 0.9.5**: MIT, https://github.com/huozhi/sugar-high. The package's license
|
|
4
|
+
identifier is MIT; its published archive does not include a separate copyright notice.
|
|
5
|
+
- **Geist and Geist Mono 5.3.0**: SIL Open Font License 1.1. The original copyright
|
|
6
|
+
notices and full license text accompany the bundled fonts in `dist/ui/LICENSE-geist.txt`
|
|
7
|
+
and `dist/ui/LICENSE-geist-mono.txt`.
|
|
8
|
+
|
|
9
|
+
## MIT license (sugar-high)
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
14
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
18
|
+
substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
21
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
22
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "@fontsource-variable/geist-mono/wght.css";
|
|
2
|
+
type DevtoolsWindow = Window & {
|
|
3
|
+
__FARM_DEVTOOLS__?: {
|
|
4
|
+
open(view?: string): void;
|
|
5
|
+
close(): void;
|
|
6
|
+
toggle(): void;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/** A small launcher only. The inspector and highlighter load when the iframe opens. */
|
|
10
|
+
export declare function startDevtoolsLauncher(runtimeWindow?: DevtoolsWindow): {
|
|
11
|
+
dispose(): void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "@fontsource-variable/geist-mono/wght.css";
|
|
3
|
+
/** A small launcher only. The inspector and highlighter load when the iframe opens. */
|
|
4
|
+
export function startDevtoolsLauncher(runtimeWindow = window) {
|
|
5
|
+
const document = runtimeWindow.document;
|
|
6
|
+
const existing = document.querySelector("farm-devtools-launcher");
|
|
7
|
+
existing?.remove();
|
|
8
|
+
const host = document.createElement("farm-devtools-launcher");
|
|
9
|
+
const shadow = host.attachShadow({ mode: "open", delegatesFocus: true });
|
|
10
|
+
shadow.innerHTML = `<style>
|
|
11
|
+
:host{--bg:#ffffff;--surface:#fafafa;--line:#d9d9d3;--text:#1b1b19;position:fixed;left:18px;bottom:18px;z-index:2147483645}
|
|
12
|
+
button{box-sizing:border-box;display:flex;align-items:center;gap:9px;min-height:42px;margin:0;padding:0 12px;border:1px solid var(--line);border-radius:999px;background:var(--bg);color:var(--text);box-shadow:0 10px 32px rgb(0 0 0 / 16%);font:11px/1.45 "Geist Mono Variable","Geist Mono",ui-monospace,SFMono-Regular,Menlo,monospace;font-variation-settings:"wght" 620;letter-spacing:0;text-transform:uppercase;text-rendering:geometricPrecision;white-space:nowrap;cursor:pointer;-webkit-tap-highlight-color:transparent}
|
|
13
|
+
@media(hover:hover){button:hover{background:var(--surface)}}
|
|
14
|
+
button:active{background:var(--surface)}
|
|
15
|
+
button:focus-visible{outline:2px solid #4074bd;outline-offset:3px}
|
|
16
|
+
img{display:block;flex-shrink:0;width:16px;height:16px;filter:brightness(.3)}
|
|
17
|
+
@media(prefers-color-scheme:dark){:host{--bg:#101010;--surface:#141414;--line:#353531;--text:#f0f0eb}img{filter:none}button:focus-visible{outline-color:#78a8ed}}
|
|
18
|
+
@media(max-width:520px){:host{left:8px;bottom:8px}}
|
|
19
|
+
@media(pointer:coarse){button{min-height:44px}}
|
|
20
|
+
</style><button type="button" aria-label="Open Farm DevTools"><img src="/__farm/devtools/assets/logo.svg" alt=""><span>DevTools</span></button>`;
|
|
21
|
+
const button = shadow.querySelector("button");
|
|
22
|
+
button.onclick = () => runtimeWindow.__FARM_DEVTOOLS__?.open();
|
|
23
|
+
document.body.append(host);
|
|
24
|
+
return {
|
|
25
|
+
dispose() {
|
|
26
|
+
button.onclick = null;
|
|
27
|
+
host.remove();
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type FarmPlugin } from "@farm.js/core/plugin";
|
|
2
|
+
import type { DevtoolsOptions } from "./types.js";
|
|
3
|
+
export type { DevtoolsOptions } from "./types.js";
|
|
4
|
+
/** Add the development-only workspace inspector. No production runtime is registered. */
|
|
5
|
+
export declare function devtools(options?: DevtoolsOptions): FarmPlugin;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { definePlugin } from "@farm.js/core/plugin";
|
|
2
|
+
/** Add the development-only workspace inspector. No production runtime is registered. */
|
|
3
|
+
export function devtools(options = {}) {
|
|
4
|
+
for (const name of ["launcher", "inspect"]) {
|
|
5
|
+
if (options[name] !== undefined && typeof options[name] !== "boolean") {
|
|
6
|
+
throw new TypeError(`[farm:devtools] ${name} must be a boolean`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
if (options.shortcut !== undefined &&
|
|
10
|
+
options.shortcut !== false &&
|
|
11
|
+
(typeof options.shortcut !== "string" ||
|
|
12
|
+
!options.shortcut.trim() ||
|
|
13
|
+
!/^[a-z0-9+.,/ -]+$/i.test(options.shortcut))) {
|
|
14
|
+
throw new TypeError("[farm:devtools] shortcut must be a keyboard shortcut such as mod+shift+d, or false");
|
|
15
|
+
}
|
|
16
|
+
const inspect = options.inspect ?? true;
|
|
17
|
+
const launcher = options.launcher ?? true;
|
|
18
|
+
return definePlugin({
|
|
19
|
+
name: "farm:devtools",
|
|
20
|
+
enforce: "pre",
|
|
21
|
+
configure(config, context) {
|
|
22
|
+
if (context.isProd) {
|
|
23
|
+
return {
|
|
24
|
+
...config,
|
|
25
|
+
plugins: config.plugins?.filter((candidate) => candidate.name !== "farm:devtools"),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if ((config.plugins ?? []).filter((candidate) => candidate.name === "farm:devtools").length > 1) {
|
|
29
|
+
throw new Error("[farm:devtools] Configure one devtools() plugin instance");
|
|
30
|
+
}
|
|
31
|
+
if (config.devtools === false ||
|
|
32
|
+
(typeof config.devtools === "object" && config.devtools.enabled === false)) {
|
|
33
|
+
throw new Error("[farm:devtools] Remove devtools: false (or enabled: false) when using the devtools() plugin");
|
|
34
|
+
}
|
|
35
|
+
const vitePlugin = {
|
|
36
|
+
name: "farm:devtools-ui",
|
|
37
|
+
enforce: "pre",
|
|
38
|
+
apply: "serve",
|
|
39
|
+
async configureServer(server) {
|
|
40
|
+
const { installDevtoolsServer } = await import("./server.js");
|
|
41
|
+
installDevtoolsServer(server, { inspect });
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
...config,
|
|
46
|
+
devtools: {
|
|
47
|
+
...(typeof config.devtools === "object" ? config.devtools : {}),
|
|
48
|
+
enabled: true,
|
|
49
|
+
...(options.shortcut === undefined ? {} : { shortcut: options.shortcut }),
|
|
50
|
+
},
|
|
51
|
+
vite: { ...config.vite, plugins: [vitePlugin, ...(config.vite?.plugins ?? [])] },
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
client: {
|
|
55
|
+
public: { launcher },
|
|
56
|
+
async setup({ isDev, public: config }) {
|
|
57
|
+
if (!isDev || !config.launcher)
|
|
58
|
+
return;
|
|
59
|
+
const { startDevtoolsLauncher } = await import("@farm.js/devtools/client");
|
|
60
|
+
return startDevtoolsLauncher();
|
|
61
|
+
},
|
|
62
|
+
close({ state }) {
|
|
63
|
+
state?.dispose();
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
import type { InspectedModule, ModuleDetails } from "./types.js";
|
|
3
|
+
export declare class ModuleInspectionError extends Error {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
constructor(message: string, status: number);
|
|
6
|
+
}
|
|
7
|
+
/** Only already-transformed browser modules are eligible. Never transform or execute on request. */
|
|
8
|
+
export declare function createModuleInspector(server: ViteDevServer): {
|
|
9
|
+
list(): Promise<{
|
|
10
|
+
modules: InspectedModule[];
|
|
11
|
+
limited: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
read(id: string): Promise<ModuleDetails>;
|
|
14
|
+
};
|
package/dist/modules.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { open, realpath } from "node:fs/promises";
|
|
4
|
+
const SOURCE_LIMIT = 1024 * 1024;
|
|
5
|
+
const MODULE_LIMIT = 500;
|
|
6
|
+
const SOURCE_EXTENSION = /\.(?:[cm]?[jt]sx?|css|vue|svelte)$/i;
|
|
7
|
+
export class ModuleInspectionError extends Error {
|
|
8
|
+
status;
|
|
9
|
+
constructor(message, status) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.status = status;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function contained(root, file) {
|
|
15
|
+
const relative = path.relative(root, file);
|
|
16
|
+
return (relative !== "" &&
|
|
17
|
+
!relative.startsWith(`..${path.sep}`) &&
|
|
18
|
+
relative !== ".." &&
|
|
19
|
+
!path.isAbsolute(relative));
|
|
20
|
+
}
|
|
21
|
+
/** Only already-transformed browser modules are eligible. Never transform or execute on request. */
|
|
22
|
+
export function createModuleInspector(server) {
|
|
23
|
+
const root = path.resolve(server.config.root);
|
|
24
|
+
const rootReal = realpath(root);
|
|
25
|
+
function entries() {
|
|
26
|
+
return [...server.moduleGraph.idToModuleMap.values()]
|
|
27
|
+
.filter((module) => module.id &&
|
|
28
|
+
module.file &&
|
|
29
|
+
module.transformResult &&
|
|
30
|
+
contained(root, module.file) &&
|
|
31
|
+
SOURCE_EXTENSION.test(module.file) &&
|
|
32
|
+
!path
|
|
33
|
+
.relative(root, module.file)
|
|
34
|
+
.split(path.sep)
|
|
35
|
+
.some((part) => part.startsWith(".") || part === "node_modules"))
|
|
36
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
37
|
+
}
|
|
38
|
+
function summary(module) {
|
|
39
|
+
return {
|
|
40
|
+
id: createHash("sha256").update(module.id).digest("hex"),
|
|
41
|
+
path: path.relative(root, module.file).split(path.sep).join("/"),
|
|
42
|
+
url: module.url,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function safe(module) {
|
|
46
|
+
try {
|
|
47
|
+
const canonical = await realpath(module.file);
|
|
48
|
+
const realRoot = await rootReal;
|
|
49
|
+
return contained(realRoot, canonical) &&
|
|
50
|
+
SOURCE_EXTENSION.test(canonical) &&
|
|
51
|
+
!path
|
|
52
|
+
.relative(realRoot, canonical)
|
|
53
|
+
.split(path.sep)
|
|
54
|
+
.some((part) => part.startsWith(".") || part === "node_modules")
|
|
55
|
+
? canonical
|
|
56
|
+
: undefined;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
async list() {
|
|
64
|
+
const candidates = entries();
|
|
65
|
+
const modules = [];
|
|
66
|
+
for (const module of candidates) {
|
|
67
|
+
if (await safe(module))
|
|
68
|
+
modules.push(summary(module));
|
|
69
|
+
if (modules.length === MODULE_LIMIT)
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
modules,
|
|
74
|
+
limited: candidates.length > modules.length && modules.length === MODULE_LIMIT,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
async read(id) {
|
|
78
|
+
if (!/^[a-f0-9]{64}$/.test(id))
|
|
79
|
+
throw new ModuleInspectionError("Unknown browser module", 404);
|
|
80
|
+
const module = entries().find((entry) => summary(entry).id === id);
|
|
81
|
+
const canonical = module && (await safe(module));
|
|
82
|
+
// Vite can invalidate the transform while the filesystem check is pending.
|
|
83
|
+
const transformed = module?.transformResult?.code;
|
|
84
|
+
if (!module || !canonical || transformed === undefined)
|
|
85
|
+
throw new ModuleInspectionError("Module is no longer available. Reload the app and refresh Inspect.", 404);
|
|
86
|
+
if (Buffer.byteLength(transformed) > SOURCE_LIMIT)
|
|
87
|
+
throw new ModuleInspectionError("Module exceeds the 1 MiB inspection limit", 413);
|
|
88
|
+
const file = await open(canonical, "r");
|
|
89
|
+
try {
|
|
90
|
+
const stat = await file.stat();
|
|
91
|
+
if (!stat.isFile() || stat.size > SOURCE_LIMIT)
|
|
92
|
+
throw new ModuleInspectionError("Source exceeds the 1 MiB inspection limit", 413);
|
|
93
|
+
const buffer = Buffer.alloc(SOURCE_LIMIT + 1);
|
|
94
|
+
let bytesRead = 0;
|
|
95
|
+
while (bytesRead < buffer.length) {
|
|
96
|
+
const chunk = await file.read(buffer, bytesRead, buffer.length - bytesRead, bytesRead);
|
|
97
|
+
if (!chunk.bytesRead)
|
|
98
|
+
break;
|
|
99
|
+
bytesRead += chunk.bytesRead;
|
|
100
|
+
}
|
|
101
|
+
if (bytesRead > SOURCE_LIMIT)
|
|
102
|
+
throw new ModuleInspectionError("Source exceeds the 1 MiB inspection limit", 413);
|
|
103
|
+
return {
|
|
104
|
+
...summary(module),
|
|
105
|
+
source: buffer.subarray(0, bytesRead).toString("utf8"),
|
|
106
|
+
transformed,
|
|
107
|
+
imports: [...module.importedModules].map((entry) => entry.url).sort(),
|
|
108
|
+
importers: [...module.importers].map((entry) => entry.url).sort(),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
await file.close();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import type { ViteDevServer } from "vite";
|
|
3
|
+
/** Guard our early middleware, before Vite's own host/CORS middleware runs. */
|
|
4
|
+
export declare function isTrustedRequest(req: IncomingMessage, server: ViteDevServer): boolean;
|
|
5
|
+
export declare function installDevtoolsServer(server: ViteDevServer, options: {
|
|
6
|
+
inspect: boolean;
|
|
7
|
+
}): void;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { isIP } from "node:net";
|
|
3
|
+
import { createModuleInspector, ModuleInspectionError } from "./modules.js";
|
|
4
|
+
import { DEVTOOLS_PATH } from "./types.js";
|
|
5
|
+
/** Guard our early middleware, before Vite's own host/CORS middleware runs. */
|
|
6
|
+
export function isTrustedRequest(req, server) {
|
|
7
|
+
try {
|
|
8
|
+
const authority = req.headers.host ?? "";
|
|
9
|
+
if (!authority || /[\s/@\\?#]/.test(authority))
|
|
10
|
+
return false;
|
|
11
|
+
const protocol = req.socket?.encrypted
|
|
12
|
+
? "https:"
|
|
13
|
+
: "http:";
|
|
14
|
+
const host = new URL(`${protocol}//${authority}`);
|
|
15
|
+
const hostname = host.hostname.replace(/^\[|\]$/g, "");
|
|
16
|
+
const allowed = server.config.server.allowedHosts;
|
|
17
|
+
const explicitHost = server.config.server.host;
|
|
18
|
+
const trusted = hostname === "localhost" ||
|
|
19
|
+
hostname.endsWith(".localhost") ||
|
|
20
|
+
isIP(hostname) !== 0 ||
|
|
21
|
+
(typeof explicitHost === "string" && hostname === explicitHost) ||
|
|
22
|
+
(Array.isArray(allowed) &&
|
|
23
|
+
allowed.some((value) => value.startsWith(".")
|
|
24
|
+
? hostname === value.slice(1) || hostname.endsWith(value)
|
|
25
|
+
: hostname === value));
|
|
26
|
+
if (!trusted || req.headers["sec-fetch-site"] === "cross-site")
|
|
27
|
+
return false;
|
|
28
|
+
if (req.headers.origin && new URL(req.headers.origin).origin !== host.origin)
|
|
29
|
+
return false;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function installDevtoolsServer(server, options) {
|
|
37
|
+
const inspector = createModuleInspector(server);
|
|
38
|
+
const assetRoot = new URL("./ui/", import.meta.url);
|
|
39
|
+
const assets = new Map();
|
|
40
|
+
let closed = false;
|
|
41
|
+
server.httpServer?.once("close", () => {
|
|
42
|
+
closed = true;
|
|
43
|
+
assets.clear();
|
|
44
|
+
});
|
|
45
|
+
server.middlewares.use(async (req, res, next) => {
|
|
46
|
+
let url;
|
|
47
|
+
try {
|
|
48
|
+
url = new URL(req.url || "/", "http://localhost");
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return next();
|
|
52
|
+
}
|
|
53
|
+
if (url.pathname !== DEVTOOLS_PATH &&
|
|
54
|
+
url.pathname !== `${DEVTOOLS_PATH}.json` &&
|
|
55
|
+
!url.pathname.startsWith(`${DEVTOOLS_PATH}/`))
|
|
56
|
+
return next();
|
|
57
|
+
if (closed)
|
|
58
|
+
return next();
|
|
59
|
+
res.setHeader("Cache-Control", "no-store");
|
|
60
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
61
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
62
|
+
res.setHeader("Referrer-Policy", "no-referrer");
|
|
63
|
+
if (!isTrustedRequest(req, server)) {
|
|
64
|
+
res.statusCode = 403;
|
|
65
|
+
res.end("DevTools requires a trusted, same-origin development request.");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
69
|
+
res.statusCode = 405;
|
|
70
|
+
res.setHeader("Allow", "GET, HEAD");
|
|
71
|
+
res.end();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const send = (body, type) => {
|
|
75
|
+
res.setHeader("Content-Type", type);
|
|
76
|
+
res.end(req.method === "HEAD" ? undefined : body);
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
if (url.pathname === `${DEVTOOLS_PATH}.json`)
|
|
80
|
+
return next();
|
|
81
|
+
if (url.pathname === DEVTOOLS_PATH) {
|
|
82
|
+
if (url.searchParams.get("embedded") !== "1")
|
|
83
|
+
return next();
|
|
84
|
+
res.setHeader("Content-Security-Policy", "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self'; connect-src 'self'; frame-ancestors 'self'; base-uri 'none'; form-action 'none'");
|
|
85
|
+
send(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="dark light"><title>Farm.js DevTools</title><link rel="stylesheet" href="${DEVTOOLS_PATH}/assets/panel.css"></head><body><div id="farm-devtools" data-inspect="${options.inspect}"></div><script type="module" src="${DEVTOOLS_PATH}/assets/panel.js"></script></body></html>`, "text/html; charset=utf-8");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (url.pathname === `${DEVTOOLS_PATH}/modules.json` && options.inspect) {
|
|
89
|
+
send(JSON.stringify(await inspector.list()), "application/json; charset=utf-8");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (url.pathname === `${DEVTOOLS_PATH}/module.json` && options.inspect) {
|
|
93
|
+
send(JSON.stringify(await inspector.read(url.searchParams.get("id") ?? "")), "application/json; charset=utf-8");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (url.pathname.startsWith(`${DEVTOOLS_PATH}/assets/`)) {
|
|
97
|
+
const name = url.pathname.slice(`${DEVTOOLS_PATH}/assets/`.length);
|
|
98
|
+
const type = name === "panel.js"
|
|
99
|
+
? "text/javascript; charset=utf-8"
|
|
100
|
+
: name === "panel.css"
|
|
101
|
+
? "text/css; charset=utf-8"
|
|
102
|
+
: name === "logo.svg"
|
|
103
|
+
? "image/svg+xml"
|
|
104
|
+
: /^[a-zA-Z0-9_-]+\.woff2$/.test(name)
|
|
105
|
+
? "font/woff2"
|
|
106
|
+
: undefined;
|
|
107
|
+
if (type) {
|
|
108
|
+
if (!assets.has(name))
|
|
109
|
+
assets.set(name, readFile(new URL(name, assetRoot)));
|
|
110
|
+
send(await assets.get(name), type);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
res.statusCode = 404;
|
|
115
|
+
send("Not found", "text/plain; charset=utf-8");
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
res.statusCode = error instanceof ModuleInspectionError ? error.status : 500;
|
|
119
|
+
send(JSON.stringify({
|
|
120
|
+
error: error instanceof ModuleInspectionError
|
|
121
|
+
? error.message
|
|
122
|
+
: "DevTools could not read this resource. Refresh the app and try again.",
|
|
123
|
+
}), "application/json; charset=utf-8");
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface DevtoolsOptions {
|
|
2
|
+
/** Show the floating launcher. The keyboard shortcut remains available when false. */
|
|
3
|
+
launcher?: boolean;
|
|
4
|
+
/** Override the existing Farm DevTools shortcut. Set false to disable it. */
|
|
5
|
+
shortcut?: string | false;
|
|
6
|
+
/** Include the read-only browser module inspector. Defaults to true. */
|
|
7
|
+
inspect?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface InspectedModule {
|
|
10
|
+
id: string;
|
|
11
|
+
path: string;
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ModuleDetails extends InspectedModule {
|
|
15
|
+
source: string;
|
|
16
|
+
transformed: string;
|
|
17
|
+
imports: string[];
|
|
18
|
+
importers: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare const DEVTOOLS_PATH = "/__farm/devtools";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEVTOOLS_PATH = "/__farm/devtools";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git) GeistMono-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font) Geist-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/ui/logo.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="24" viewBox="125 68 161 152">
|
|
2
|
+
<path d="M157 68H133C128.582 68 125 71.5817 125 76V100C125 104.418 128.582 108 133 108H157C161.418 108 165 104.418 165 100V76C165 71.5817 161.418 68 157 68Z" fill="#F5F5F4"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M182.383 68H280.617C282.045 68 283.414 68.8429 284.423 70.3431C285.433 71.8434 286 73.8783 286 76V100C286 102.122 285.433 104.157 284.423 105.657C283.414 107.157 282.045 108 280.617 108H182.383C180.955 108 179.586 107.157 178.577 105.657C177.567 104.157 177 102.122 177 100V76C177 73.8783 177.567 71.8434 178.577 70.3431C179.586 68.8429 180.955 68 182.383 68ZM271.852 81C270.747 81 269.852 81.8954 269.852 83V93C269.852 94.1046 270.747 95 271.852 95H277.272C278.376 95 279.272 94.1046 279.272 93V83C279.272 81.8954 278.376 81 277.272 81H271.852Z" fill="#F5F5F4"/>
|
|
4
|
+
<path d="M157 124H133C128.582 124 125 127.582 125 132V156C125 160.418 128.582 164 133 164H157C161.418 164 165 160.418 165 156V132C165 127.582 161.418 124 157 124Z" fill="#A3A3A3"/>
|
|
5
|
+
<path d="M280.334 124H182.666C179.537 124 177 127.582 177 132V156C177 160.418 179.537 164 182.666 164H280.334C283.463 164 286 160.418 286 156V132C286 127.582 283.463 124 280.334 124Z" fill="#A3A3A3"/>
|
|
6
|
+
<path d="M157 180H133C128.582 180 125 183.582 125 188V212C125 216.418 128.582 220 133 220H157C161.418 220 165 216.418 165 212V188C165 183.582 161.418 180 157 180Z" fill="#595959"/>
|
|
7
|
+
<path d="M230.189 180H182.811C179.602 180 177 183.582 177 188V212C177 216.418 179.602 220 182.811 220H230.189C233.398 220 236 216.418 236 212V188C236 183.582 233.398 180 230.189 180Z" fill="#595959"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-cyrillic-ext-wght-normal-RO72NYA2.woff2") format("woff2-variations");unicode-range:U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-cyrillic-wght-normal-CK2XY27K.woff2") format("woff2-variations");unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-vietnamese-wght-normal-Y2R7JZKV.woff2") format("woff2-variations");unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-latin-ext-wght-normal-XEQ56JUF.woff2") format("woff2-variations");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-latin-wght-normal-T72VVCUW.woff2") format("woff2-variations");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-mono-cyrillic-ext-wght-normal-QXKVIKFD.woff2") format("woff2-variations");unicode-range:U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-mono-cyrillic-wght-normal-GOIAQAGU.woff2") format("woff2-variations");unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-mono-symbols2-wght-normal-WZJJVLQO.woff2") format("woff2-variations");unicode-range:U+2000-2001,U+2004-2008,U+200A,U+23B8-23BD,U+2500-259F}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-mono-vietnamese-wght-normal-KW5NM6YV.woff2") format("woff2-variations");unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-mono-latin-ext-wght-normal-HU3ZAWN6.woff2") format("woff2-variations");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Mono Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url("/__farm/devtools/assets/geist-mono-latin-wght-normal-CJNQKXUG.woff2") format("woff2-variations");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}#farm-devtools{--fd-bg: light-dark(#ffffff, #101010);--fd-side: light-dark(#fafafa, #141414);--fd-fg: light-dark(#202020, #ededed);--fd-muted: light-dark(#676767, #a0a0a0);--fd-line: light-dark(#e7e7e7, #2b2b2b);--fd-outline: light-dark(#d4d4d4, #404040);--fd-active: light-dark(#eeeeee, #262626);--fd-green: light-dark(#28633b, #a5d8b4);--fd-amber: light-dark(#895e17, #dfba78);--fd-purple: light-dark(#7953a0, #c7a9df);--fd-string: light-dark(#27665b, #a5d8c4);--fd-add: light-dark(#eef7ef, #16241c);--fd-remove: light-dark(#fff0f0, #2b1a1a);--fd-red: light-dark(#a13f3f, #e3a2a2);--fd-pad: 24px;--fd-row: 12px;font:400 14px/1.5 Geist,sans-serif;color:var(--fd-fg);background:var(--fd-bg);border:1px solid var(--fd-outline);border-radius:12px;overflow:clip;width:100%}#farm-devtools,#farm-devtools *{box-sizing:border-box}#farm-devtools [hidden]{display:none!important}#farm-devtools button,#farm-devtools input,#farm-devtools select{font:inherit;color:inherit}#farm-devtools button{cursor:pointer;line-height:20px;min-height:32px}#farm-devtools button:not(:disabled):active{background:var(--fd-active)}#farm-devtools h2,#farm-devtools h3,#farm-devtools p{margin:0}#farm-devtools h2{font:500 21px/1.4 Geist,sans-serif;letter-spacing:-.5px}#farm-devtools h3{font:500 13px/20px Geist,sans-serif}#farm-devtools code,#farm-devtools .fd-mono{font-family:Geist Mono,monospace;font-weight:400;font-size:12px}#farm-devtools code{background:none;padding:0;color:inherit;overflow-wrap:anywhere;white-space:normal}#farm-devtools .fd-muted{color:var(--fd-muted)}#farm-devtools .fd-label{font:400 11px/1.5 Geist Mono,monospace;color:var(--fd-muted);letter-spacing:.1px}#farm-devtools .fd-header{min-height:57px;display:flex;align-items:center;gap:8px;font-size:11px;padding:10px 18px;border-bottom:1px solid var(--fd-line);flex-wrap:wrap}#farm-devtools .fd-brand{font:500 12px/1.4 Geist Mono,monospace;letter-spacing:-.5px}#farm-devtools .fd-header-actions{display:flex;align-items:center;gap:5px;margin-left:auto}#farm-devtools .fd-icon-button{display:inline-flex;justify-content:center;align-items:center;min-width:32px;min-height:32px;width:32px;height:32px;padding:0;border:0;background:transparent;border-radius:7px;color:var(--fd-muted)}#farm-devtools svg{display:block;width:16px;height:16px;stroke-width:1.5;flex-shrink:0}#farm-devtools .fd-body{display:grid;grid-template-columns:174px minmax(0,1fr);min-height:584px}#farm-devtools .fd-sidebar{padding:20px 10px 12px;background:var(--fd-side);border-right:1px solid var(--fd-line);display:flex;flex-direction:column}#farm-devtools .fd-group-label{padding:0 10px 8px}#farm-devtools .fd-nav-button{display:flex;align-items:center;gap:8px;text-align:left;width:100%;padding:8px 10px;border-radius:7px;border:0;background:transparent;color:var(--fd-muted);font-size:13px}#farm-devtools .fd-nav-button[aria-current=page]{color:var(--fd-fg);background:var(--fd-active)}#farm-devtools .fd-count{margin-left:auto;font-size:11px;font-family:Geist Mono,monospace;color:var(--fd-muted)}#farm-devtools .fd-count:empty{display:none}#farm-devtools .fd-green{color:var(--fd-green)}#farm-devtools .fd-amber{color:var(--fd-amber)}#farm-devtools .fd-main{min-width:0}#farm-devtools .fd-page-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:24px var(--fd-pad) 22px;flex-wrap:wrap}#farm-devtools .fd-subtitle{color:var(--fd-muted);font-size:12px;margin-top:5px}#farm-devtools .fd-tag{border:1px solid var(--fd-line);border-radius:4px;padding:3px 7px;color:var(--fd-muted);font:400 11px/1.5 Geist Mono,monospace;white-space:nowrap}#farm-devtools .fd-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-top:1px solid var(--fd-line);border-bottom:1px solid var(--fd-line)}#farm-devtools .fd-stat{padding:17px var(--fd-pad);display:flex;align-items:baseline;justify-content:space-between;gap:6px}#farm-devtools .fd-stat+.fd-stat{border-left:1px solid var(--fd-line)}#farm-devtools .fd-stat-value{font:400 24px/1.2 Geist Mono,monospace;letter-spacing:-1px}#farm-devtools .fd-section{padding:22px var(--fd-pad)}#farm-devtools .fd-section+.fd-section{border-top:1px solid var(--fd-line)}#farm-devtools .fd-section-heading{display:flex;gap:12px;justify-content:space-between;align-items:center;margin-bottom:12px}#farm-devtools .fd-link-button{border:0;background:transparent;display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:6px 10px;border-radius:7px;color:var(--fd-muted);font-size:12px;text-align:left}#farm-devtools .fd-button-label{min-width:0}#farm-devtools .fd-route-preview{border-top:1px solid var(--fd-line)}#farm-devtools .fd-preview-row{display:grid;grid-template-columns:minmax(0,1fr) auto 16px;gap:12px;align-items:center;width:100%;padding:var(--fd-row) 10px;text-align:left;background:transparent;border:0;border-bottom:1px solid var(--fd-line)}#farm-devtools .fd-preview-row:last-child{border-bottom:0}#farm-devtools .fd-preview-meta{font-size:11px;color:var(--fd-muted)}#farm-devtools .fd-diagnostic{display:flex;gap:11px;padding:10px 0;align-items:flex-start}#farm-devtools .fd-diagnostic>span{display:flex;align-items:center;justify-content:center;flex:0 0 16px;height:20px}#farm-devtools .fd-diagnostic .fd-label{line-height:20px}#farm-devtools .fd-diagnostic p{font-size:12px;color:var(--fd-muted);margin-top:3px}#farm-devtools .fd-diagnostic strong{font-weight:400;font-size:13px}#farm-devtools .fd-footer{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 18px;border-top:1px solid var(--fd-line);font:400 9px/1.5 Geist Mono,monospace;color:var(--fd-muted)}#farm-devtools .fd-footer-label{font-size:8px;font-variation-settings:"wght" 620;letter-spacing:0;text-transform:uppercase;white-space:nowrap}#farm-devtools .fd-footer-status{min-width:0;display:flex;flex-wrap:wrap;justify-content:center;gap:4px 12px;text-align:center;overflow-wrap:anywhere}#farm-devtools [data-feedback]:empty{display:none}#farm-devtools .fd-filter-row{padding:0 var(--fd-pad) 18px}#farm-devtools .fd-search{display:flex;align-items:center;gap:8px;border:1px solid var(--fd-line);background:var(--fd-side);border-radius:5px;padding:8px 10px;color:var(--fd-muted)}#farm-devtools .fd-search input{width:100%;min-width:0;background:transparent;border:0;font-size:12px;padding:0}#farm-devtools .fd-search input::placeholder{color:var(--fd-muted)}#farm-devtools .fd-search kbd{font:400 11px/1.5 Geist Mono,monospace}#farm-devtools .fd-browser{border-top:1px solid var(--fd-line);display:grid;grid-template-columns:minmax(0,.95fr) minmax(0,1.3fr)}#farm-devtools .fd-list{border-right:1px solid var(--fd-line);padding:9px}#farm-devtools .fd-list-button{width:100%;display:flex;flex-direction:column;gap:6px;text-align:left;border:0;background:transparent;border-radius:4px;padding:12px 10px}#farm-devtools .fd-list-button[aria-pressed=true]{background:var(--fd-active)}#farm-devtools .fd-detail{min-width:0;padding:20px}#farm-devtools .fd-detail-title{display:flex;align-items:center;gap:10px;margin-bottom:18px}#farm-devtools .fd-detail-title code{font-size:14px}#farm-devtools .fd-properties{margin:0}#farm-devtools .fd-property{display:grid;grid-template-columns:95px minmax(0,1fr);gap:15px;border-bottom:1px solid var(--fd-line);padding:11px 0;font-size:12px}#farm-devtools .fd-property dt{color:var(--fd-muted)}#farm-devtools .fd-property dd{margin:0;overflow-wrap:anywhere}#farm-devtools .fd-property:first-child{padding-top:0}#farm-devtools .fd-tree-item{display:flex;align-items:center;gap:9px;padding:8px 0;overflow-wrap:anywhere}#farm-devtools .fd-tree-item small{color:var(--fd-muted);font-size:11px;margin-left:auto}#farm-devtools .fd-tree-item svg{color:var(--fd-muted)}#farm-devtools .fd-detail-sub{margin-top:23px}#farm-devtools .fd-empty{padding:25px 12px;font-size:12px;color:var(--fd-muted);text-align:center}#farm-devtools .fd-system-row{display:grid;grid-template-columns:24px minmax(0,1fr) auto;gap:8px;padding:14px 0;align-items:start;border-bottom:1px solid var(--fd-line)}#farm-devtools .fd-system-row:last-child{border-bottom:0}#farm-devtools .fd-system-row p{color:var(--fd-muted);font-size:12px;margin-top:3px;overflow-wrap:anywhere}#farm-devtools .fd-system-row svg{color:var(--fd-muted);margin-top:3px}#farm-devtools details{border-top:1px solid var(--fd-line);padding:14px 0}#farm-devtools summary{cursor:pointer;font-size:13px}#farm-devtools details .fd-properties{margin-top:15px}#farm-devtools .fd-runtime-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:30px}#farm-devtools .fd-inspect-toolbar{border-top:1px solid var(--fd-line);border-bottom:1px solid var(--fd-line);padding:12px var(--fd-pad);display:flex;gap:12px;align-items:center;flex-wrap:wrap}#farm-devtools select{background:var(--fd-side);border:1px solid var(--fd-line);border-radius:4px;padding:6px 8px;max-width:100%;min-width:0;font-size:12px}#farm-devtools .fd-inspect-toolbar select{flex:1}#farm-devtools .fd-pipeline{padding:16px var(--fd-pad);border-bottom:1px solid var(--fd-line)}#farm-devtools .fd-comparison{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}#farm-devtools .fd-code-pane{min-width:0}#farm-devtools .fd-code-pane+.fd-code-pane{border-left:1px solid var(--fd-line)}#farm-devtools .fd-code-title{min-height:48px;padding:8px 16px;gap:12px;border-bottom:1px solid var(--fd-line);display:flex;align-items:center;justify-content:space-between;font-size:11px}#farm-devtools[data-code-layout=stacked] .fd-comparison{grid-template-columns:minmax(0,1fr)}#farm-devtools[data-code-layout=stacked] .fd-code-pane+.fd-code-pane{border-left:0;border-top:1px solid var(--fd-line)}@media(hover:hover)and (pointer:fine){#farm-devtools button:not(:disabled):hover{background:var(--fd-active);color:var(--fd-fg)}}@media(max-width:720px){#farm-devtools .fd-body{grid-template-columns:minmax(0,1fr);min-height:0}#farm-devtools .fd-sidebar{padding:10px;border-right:0;border-bottom:1px solid var(--fd-line);gap:6px}#farm-devtools .fd-group-label{display:none}#farm-devtools .fd-nav-button{width:auto;gap:6px;padding:8px;font-size:12px}#farm-devtools .fd-count{margin-left:0}#farm-devtools .fd-header{gap:8px;padding-left:14px;padding-right:10px}#farm-devtools .fd-comparison{grid-template-columns:minmax(0,1fr)}#farm-devtools .fd-code-pane+.fd-code-pane{border-left:0;border-top:1px solid var(--fd-line)}}@media(max-width:500px){#farm-devtools{--fd-pad: 16px}#farm-devtools .fd-browser,#farm-devtools .fd-runtime-grid{grid-template-columns:minmax(0,1fr)}#farm-devtools .fd-list{border-right:0;border-bottom:1px solid var(--fd-line)}#farm-devtools .fd-list-button{padding:9px 10px}#farm-devtools .fd-stat{flex-direction:column;padding:14px 16px;gap:7px}#farm-devtools .fd-stat-value{font-size:21px}#farm-devtools .fd-preview-meta{max-width:90px;text-align:right}#farm-devtools .fd-tag{white-space:normal}#farm-devtools .fd-system-row{grid-template-columns:24px minmax(0,1fr)}#farm-devtools .fd-system-row>.fd-tag{grid-column:2;justify-self:start}#farm-devtools .fd-property{grid-template-columns:90px minmax(0,1fr);gap:10px}#farm-devtools .fd-footer{grid-template-columns:1fr auto;gap:6px 12px;padding:10px 16px}#farm-devtools .fd-footer-status{grid-column:1 / -1;grid-row:2;justify-content:flex-start;text-align:left}}@media(pointer:coarse){#farm-devtools button,#farm-devtools select,#farm-devtools summary{min-height:44px}#farm-devtools .fd-icon-button{min-width:44px}#farm-devtools .fd-search input{font-size:16px;min-height:28px}}html,body{margin:0;height:100%;overflow:hidden;overscroll-behavior:none;color-scheme:light dark}#farm-devtools{font-family:Geist Variable,sans-serif;display:flex;flex-direction:column;height:100%}#farm-devtools h2,#farm-devtools h3{font-family:Geist Variable,sans-serif}#farm-devtools code,#farm-devtools .fd-mono,#farm-devtools .fd-label,#farm-devtools .fd-brand,#farm-devtools .fd-footer,#farm-devtools .fd-count,#farm-devtools .fd-tag,#farm-devtools .fd-stat-value{font-family:Geist Mono Variable,monospace}#farm-devtools .fd-header,#farm-devtools .fd-footer{flex-shrink:0}#farm-devtools .fd-body{min-height:0;flex:1;overflow:hidden}#farm-devtools .fd-main,#farm-devtools .fd-sidebar{min-height:0;overflow-y:auto;overscroll-behavior:contain}#farm-devtools .fd-logo{width:16px;height:16px;object-fit:contain;flex-shrink:0;filter:brightness(.25)}#farm-devtools[data-theme=dark] .fd-logo{filter:none}@media(prefers-color-scheme:dark){#farm-devtools[data-theme=system] .fd-logo{filter:none}}#farm-devtools .fd-flush-top{padding-top:0}#farm-devtools .fd-error{padding:10px 18px;color:var(--fd-red);border-bottom:1px solid var(--fd-line);font-size:12px}#farm-devtools .fd-danger{color:var(--fd-red)}#farm-devtools .fd-source{margin:0;padding:16px;overflow:auto;font:400 12px/1.8 Geist Mono Variable,monospace;tab-size:2;counter-reset:line}#farm-devtools .fd-source code{white-space:normal;font:inherit}#farm-devtools .sh__line{display:block;min-height:1.8em;white-space:pre}#farm-devtools .sh__line:before{counter-increment:line;content:counter(line);display:inline-block;width:32px;padding-right:14px;text-align:right;color:var(--fd-muted);user-select:none}#farm-devtools{--sh-class: var(--fd-purple);--sh-identifier: var(--fd-fg);--sh-sign: var(--fd-muted);--sh-property: var(--fd-string);--sh-entity: var(--fd-purple);--sh-jsxliterals: var(--fd-fg);--sh-string: var(--fd-string);--sh-keyword: var(--fd-purple);--sh-comment: var(--fd-muted)}#farm-devtools button:focus-visible,#farm-devtools summary:focus-visible,#farm-devtools select:focus-visible,#farm-devtools input:focus-visible{outline:2px solid var(--fd-purple);outline-offset:2px}@media(max-width:720px){#farm-devtools .fd-body{display:flex;flex-direction:column}#farm-devtools .fd-sidebar{display:flex;flex-direction:row;flex-wrap:wrap;flex-shrink:0}#farm-devtools .fd-nav-button{flex:0 0 auto}#farm-devtools .fd-main{flex:1}}
|
package/dist/ui/panel.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var Y="/__farm/devtools";var fe=new Set(["<",">","{","}","[","]"]),Me=new Set(["for","do","while","if","else","return","function","var","let","const","true","false","undefined","this","new","delete","typeof","in","instanceof","void","break","continue","switch","case","default","throw","try","catch","finally","debugger","with","yield","async","await","class","extends","super","import","export","from","static"]),ye=new Set(["+","-","*","/","%","=","!","&","|","^","~","!","?",":",".",",",";","'",'"',".","(",")","[","]","#","@","\\",...fe]),Ee={keywords:Me,onCommentStart:ke,onCommentEnd:Re},ae=["identifier","keyword","string","class","property","entity","jsxliterals","sign","comment","break","space"],[de,Se,z,Ce,le,Ae,Le,q,ve,ce,xe]=ae.map((t,a)=>a);function te(t){return/^[^\S\r\n]+$/g.test(t)}function Fe(t){return ye.has(t)}function De(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function se(t){return/^[\w_]+$/.test(t)||be(t)}function je(t){let a=t[0];return se(a)&&a===a.toUpperCase()||t==="null"}function be(t){return/[^\u0000-\u007f]/.test(t)}function we(t){return/^[a-zA-Z]$/.test(t)}function $e(t){return we(t)||be(t)}function oe(t){return $e(t[0])&&(t.length===1||se(t.slice(1)))}function pe(t){return t==="`"}function me(t){return t==='"'||t==="'"}function He(t){return me(t)||pe(t)}function ke(t,a){let u=t+a;return u==="/*"?2:u==="//"?1:0}function Re(t,a){return t+a==="*/"?2:a===`
|
|
2
|
+
`?1:0}function _e(t){return t[0]==="/"&&!ke(t[0],t[1])}function Be(t,a){let{keywords:u,onCommentStart:v,onCommentEnd:l}={...Ee,...a},s="",g=-1,w=[-1,""],S=[-2,""],A=[],T=!1,f=0,$=!1,N=0,L=()=>T&&!$&&!f,I=()=>f&&!L(),M=()=>!f&&L()&&!$&&N>0,j=null,P=!1,_=0,c=0,V=()=>j!==null,K=()=>P,H=()=>c>_,y=()=>c>0&&c===_,k=()=>V()||H();function X(n){let r=n===`
|
|
3
|
+
`;if(I()){if(V())return z;let[,x]=w;if(oe(n)&&(x==="<"||x==="</"))return Ae}if(M())return Le;if(V()||H())return z;if(u.has(n))return w[1]==="."?de:Se;if(r)return ce;if(te(n))return xe;if(n.split("").every(Fe))return q;if(je(n))return I()?de:Ce;if(oe(n)){let x=w[1]==="."&&oe(S[1]);if(!k()&&!x)return de;if(x)return le}return z}let i=(n,r)=>{if(r&&(s=r),s){g=n||X(s);let F=[g,s];g!==xe&&g!==ce&&(S=w,w=F),A.push(F)}s=""};for(let n=0;n<t.length;n++){let r=t[n],F=t[n-1],x=t[n+1],Q=F+r,E=r+x;if(me(r)&&!M()&&!H()){i(),F!=="\\"&&(j&&r===j?j=null:j||(j=r)),i(z,r);continue}if(!H()&&F!=="\\n"&&pe(r)){i(),i(z,r),c++;continue}if(H()){if(F!=="\\n"&&pe(r)&&c>0){i(),c--,i(z,r);continue}if(E==="${"){_++,i(z),i(q,E),n++;continue}}if(y()&&r==="}"){i(),_--,i(q,r);continue}if(L()&&r==="{"){i(),i(q,r),$=!0;continue}if(T){if(!f&&r==="<"){i(),x==="/"?(f=2,s=E,n++):(f=1,s=r),i(q);continue}if(f){if(r===">"&&!"/=".includes(F)){i(),f===1?(f=0,N++):(f=0,T=!1),i(q,r);continue}if(E==="/>"||E==="</"){s!=="<"&&s!=="/"&&i(),E==="/>"?f=0:N--,N||(T=!1),s=E,n++,i(q);continue}if(r==="<"){i(),s=r,i(q);continue}if(x==="-"&&!k()&&!M()&&s){i(le,s+r+x),n++;continue}if(x==="="&&!k()&&!te(r)){te(s)&&i();let R=s+r;if(oe(R)){i(le,R);continue}}}}!f&&(r==="<"&&$e(x)||E==="</")&&(f=x==="/"?2:1,r==="<"&&(x==="/"||we(x))&&!k()&&!M()&&!K()&&(T=!0));let ne=He(r),ie=H(),Z=!T&&_e(E),W=M();if(ne||ie||me(j))s+=r;else if(Z){i();let[R,J]=w;if(Z&&R!==-1&&!(R===q&&J!==")"||R===ve)){s=r,i();continue}P=!0;let O=n++,e=()=>n>=t.length,o=()=>e()||t[n]===`
|
|
4
|
+
`,d=!1;for(;!o();n++)if(t[n]==="/"&&t[n-1]!=="\\"){for(d=!0;O!==n&&/^[a-z]$/.test(t[n+1])&&!o();)n++;break}P=!1,O!==n&&d?(s=t.slice(O,n+1),i(z)):(s=r,i(),n=O)}else if(v(r,x)){i();let R=n,J=v(r,x);if(J)for(;n<t.length&&l(t[n-1],t[n])!=J;n++);s=t.slice(R,n+1),i(ve)}else r===" "||r===`
|
|
5
|
+
`?r===" "&&(te(s)||!s||W)?(s+=r,x==="<"&&i()):(i(),s=r,i()):$&&r==="}"?(i(),s=r,i(),$=!1):W&&!fe.has(r)||H()||(se(r)===se(s[s.length-1])||L())&&!ye.has(r)?s+=r:(Q==="</"&&(s=Q),i(),Q!=="</"&&(s=r),E==="</"||E==="/>"?(s=E,i(),n++):fe.has(r)&&i())}return i(),A}function Ne(t){let a=[],u=g=>({type:"element",tagName:"span",children:g,properties:{className:"sh__line"}});function v(g){let w=g.map(([S,A])=>{let T=ae[S];return{type:"element",tagName:"span",children:[{type:"text",value:A}],properties:{className:`sh__token--${T}`,style:{color:`var(--sh-${T})`}}}});a.push(u(w))}let l=[],s=!1;for(let g=0;g<t.length;g++){let w=t[g],[S,A]=w,T=g===t.length-1;if(S!==ce){if(A.includes(`
|
|
6
|
+
`)){let f=A.split(`
|
|
7
|
+
`);for(let $=0;$<f.length;$++)l.push([S,f[$]]),$<f.length-1&&(v(l),l.length=0)}else l.push(w);s=!1}else s?v([]):(v(l),l.length=0),T&&v([]),s=!0}return l.length&&v(l),a}var Ie=t=>{let a=`class="${t.className}"`;if(t.style){let u=Object.entries(t.style).map(([v,l])=>`${v}:${l}`).join(";");a+=` style="${u}"`}return a};function qe(t){return t.map(a=>{let{tagName:u}=a,v=a.children.map(l=>{let{tagName:s,children:g,properties:w}=l;return`<${s} ${Ie(w)}>${De(g[0].value)}</${s}>`}).join("");return`<${u} class="${a.properties.className}">${v}</${u}>`}).join(`
|
|
8
|
+
`)}function Ue(t,a){let u=Be(t,a),v=Ne(u);return qe(v)}var Ye={TokenTypes:ae,TokenMap:new Map(ae.map((t,a)=>[t,a]))};var Oe={activity:'<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',api:'<path d="M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2h-1"/>',app:'<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',blocks:'<rect width="7" height="7" x="3" y="3"/><rect width="7" height="7" x="14" y="3"/><rect width="7" height="7" x="14" y="14"/><rect width="7" height="7" x="3" y="14"/>',book:'<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/>',clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',chevron:'<path d="m9 18 6-6-6-6"/>',close:'<path d="M18 6 6 18M6 6l12 12"/>',copy:'<rect width="14" height="14" x="8" y="8"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',database:'<ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5v14c0 1.7 4 3 9 3s9-1.3 9-3V5"/><path d="M3 12c0 1.7 4 3 9 3s9-1.3 9-3"/>',external:'<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',layers:'<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="m22 12.5-9.17 4.17a2 2 0 0 1-1.66 0L2 12.5"/><path d="m22 17.5-9.17 4.17a2 2 0 0 1-1.66 0L2 17.5"/>',overview:'<rect width="7" height="9" x="3" y="3"/><rect width="7" height="5" x="14" y="3"/><rect width="7" height="9" x="14" y="12"/><rect width="7" height="5" x="3" y="16"/>',refresh:'<path d="M20 11a8.1 8.1 0 0 0-15.5-2M4 4v5h5"/><path d="M4 13a8.1 8.1 0 0 0 15.5 2M20 20v-5h-5"/>',route:'<circle cx="6" cy="19" r="3"/><path d="M9 19h5.5a3.5 3.5 0 0 0 0-7h-5a3.5 3.5 0 0 1 0-7H18"/><circle cx="18" cy="5" r="3"/>',runtime:'<rect width="20" height="14" x="2" y="3"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M2 12h2m16 0h2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/>',moon:'<path d="M20.9 13A9 9 0 0 1 11 3.1 9 9 0 1 0 20.9 13Z"/>',shield:'<path d="M20 13c0 5-3.5 7.5-8 9-4.5-1.5-8-4-8-9V5l8-3 8 3z"/><path d="m9 12 2 2 4-4"/>',terminal:'<polyline points="4 17 10 11 4 5"/><line x1="12" x2="20" y1="19" y2="19"/>'};function U(t,a=""){return`<svg class="icon ${a}" data-lucide="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Oe[t]}</svg>`}function p(t){return String(t??"").replace(/[&<>"']/g,a=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[a])}function re(t,a,u){let v=t.split(`
|
|
9
|
+
`),l=v.slice(0,1500).join(`
|
|
10
|
+
`);return`<section class="fd-code-pane" aria-label="${p(a)}"><div class="fd-code-title"><span class="fd-label">${p(a)}</span><button type="button" class="fd-link-button" data-copy="${p(u)}" aria-label="Copy ${p(a)}">${U("copy")}<span class="fd-button-label">Copy</span></button></div><pre class="fd-source"><code>${Ue(l)}</code></pre>${v.length>1500?'<p class="fd-subtitle">Showing the first 1,500 lines. Copy includes the full bounded source.</p>':""}</section>`}function b(t,a){return`<div class="fd-property"><dt>${p(t)}</dt><dd>${p(a)}</dd></div>`}function G(t,a,u=""){return`<div class="fd-page-heading"><div><h2>${p(t)}</h2><p class="fd-subtitle">${p(a)}</p></div>${u?`<span class="fd-tag">${p(u)}</span>`:""}</div>`}function ze(t){let a=t.ownerDocument.defaultView,u=t.ownerDocument,v=[["overview","Overview","overview"],["routes","Routes","route"],["api","API","api"],["systems","Systems","layers"],["runtime","Runtime","runtime"],...t.dataset.inspect==="true"?[["inspect","Inspect","search"]]:[],["diagnostics","Diagnostics","activity"],["raw","Snapshot","terminal"]],l=v.some(([e])=>e===a.location.hash.slice(1))?a.location.hash.slice(1):"overview",s,g=0,w=0,S="",A=[],T=0,f=0,$=!1,N,L,I=new Map,M="system";try{let e=a.localStorage.getItem("farm:devtools:theme");(e==="light"||e==="dark")&&(M=e)}catch{}let j=a.matchMedia("(prefers-color-scheme: dark)"),P=()=>M==="dark"||M==="system"&&j.matches,_=()=>{t.dataset.theme=M,t.style.colorScheme=M==="light"||M==="dark"?M:"light dark";let e=t.querySelector("[data-theme-toggle]");if(e){let o=P()?"Switch to light theme":"Switch to dark theme";e.innerHTML=U(P()?"sun":"moon"),e.setAttribute("aria-label",o),e.title=o}};_(),t.innerHTML=`<header class="fd-header"><img class="fd-logo" src="${Y}/assets/logo.svg" alt="Farm.js logo"><span class="fd-brand">FARM.JS</span><span class="fd-muted">/</span><span>DevTools</span><div class="fd-header-actions"><button type="button" class="fd-icon-button" data-refresh aria-label="Refresh DevTools">${U("refresh")}</button><button type="button" class="fd-icon-button" data-theme-toggle aria-label="Switch theme"></button><button type="button" class="fd-icon-button" data-close aria-label="Close DevTools">${U("close")}</button></div></header><div class="fd-error" role="alert" data-error hidden></div><div class="fd-body"><nav class="fd-sidebar" aria-label="DevTools navigation"><div class="fd-label fd-group-label">WORKSPACE</div>${v.map(([e,o,d])=>`<button type="button" class="fd-nav-button" data-view="${e}">${U(d)}<span class="fd-button-label">${o}</span><span class="fd-count" data-count="${e}"></span></button>`).join("")}</nav><main class="fd-main" data-main></main></div><footer class="fd-footer"><span class="fd-footer-label">Development only</span><div class="fd-footer-status"><span data-status role="status">Loading workspace\u2026</span><span data-feedback role="status"></span></div><span class="fd-footer-label">Esc to close</span></footer>`;let c=t.querySelector("[data-main]"),V=t.querySelector("[data-status]"),K=t.querySelector("[data-feedback]"),H=t.querySelector("[data-error]"),y=e=>`<div class="fd-empty">${p(e)}</div>`,k=e=>`<code>${p(e)}</code>`,X=e=>e?`${e.runtime}${e.regions?.length?" \xB7 "+e.regions.join(", "):""}${e.maxDuration?" \xB7 "+e.maxDuration+"s":""}`:"Inherited",i=()=>{a.parent!==a?a.parent.postMessage({type:"farm:devtools:close"},a.location.origin):a.location.assign("/")};function n(e){v.some(([o])=>o===e)&&(l=e,a.history.replaceState(null,"",`#${l}`),R())}async function r(e,o){let d=await a.fetch(e,{cache:"no-store",credentials:"same-origin",signal:o});if(!d.ok){let m=await d.json().catch(()=>null);throw new Error(typeof m?.error=="string"?m.error:`DevTools request failed (${d.status}).`)}return d.json()}async function F(){let e=++T;N?.abort(),N=new AbortController,t.setAttribute("aria-busy","true"),V.textContent="Refreshing workspace\u2026",H.hidden=!0,s||(c.innerHTML=y("Loading the current Farm workspace\u2026"));try{let o=await r(`${Y}.json`,N.signal);if($||e!==T)return;if(!o.project||!o.counts||!Array.isArray(o.routes))throw new Error("Unexpected DevTools snapshot. Check that core and the plugin are up to date.");s=o,g=Math.min(g,Math.max(0,o.routes.length-1)),w=Math.min(w,Math.max(0,o.apiRoutes.length-1)),V.textContent=`${o.project.name} \xB7 Updated ${new Date(o.generatedAt).toLocaleTimeString()}`,R()}catch(o){if($||e!==T)return;H.textContent=o.message,H.hidden=!1,V.textContent=s?"Showing the last snapshot":"Workspace unavailable",s||(c.innerHTML=y("Use Refresh to reconnect to the development server."))}finally{e===T&&t.removeAttribute("aria-busy")}}function x(){return s.diagnostics.map(e=>`<article class="fd-diagnostic"><span class="${e.severity==="error"?"fd-danger":"fd-amber"}">${U(e.severity==="error"?"activity":"shield")}</span><div><div class="fd-label">${p(e.code)} \xB7 ${p(e.severity)}</div><h3>${p(e.title)}</h3><p>${p(e.message)}</p>${e.action?`<p>${p(e.action)}</p>`:""}</div></article>`).join("")||`<div class="fd-diagnostic"><span class="fd-green">${U("shield")}</span><div><h3>Framework checks passed</h3><p>No runtime configuration diagnostics in this snapshot.</p></div></div>`}function Q(){let e=s;c.innerHTML=G("Overview",`${e.project.name} \xB7 ${e.project.srcDir}`,"Development")+`<div class="fd-stats">${[["PAGES",e.counts.pages],["API ROUTES",e.counts.apiRoutes],["INTEGRATIONS",e.counts.integrations]].map(([o,d])=>`<div class="fd-stat"><span class="fd-label">${o}</span><span class="fd-stat-value">${d}</span></div>`).join("")}</div><section class="fd-section"><div class="fd-section-heading"><h3>Application routes</h3><button type="button" class="fd-link-button" data-go="routes"><span class="fd-button-label">View all routes</span>${U("external")}</button></div><div class="fd-route-preview">${e.routes.map((o,d)=>({route:o,index:d})).filter(({route:o})=>o.kind==="page").slice(0,5).map(({route:o,index:d})=>`<button type="button" class="fd-preview-row" data-route="${d}">${k(o.pattern)}<span class="fd-preview-meta">${p(X(o.runtime))}</span>${U("chevron")}</button>`).join("")||y("No page routes discovered.")}</div></section><section class="fd-section"><div class="fd-section-heading"><h3>Diagnostics</h3><button type="button" class="fd-link-button" data-go="diagnostics"><span class="fd-button-label">${e.counts.diagnostics} notices</span>${U("external")}</button></div>${x()}</section>`,c.querySelectorAll("[data-route]").forEach(o=>o.onclick=()=>{g=Number(o.dataset.route),n("routes")})}function E(e){let o=s;c.innerHTML=G(e?"API":"Routes",e?"Registered methods and effective server runtime controls.":"Pages, layouts, loading states, and error boundaries.")+`<div class="fd-filter-row"><label class="fd-search">${U("search")}<input type="search" aria-label="${e?"Filter APIs":"Filter routes"}" placeholder="Filter by path, ${e?"method":"kind"}, or source\u2026" data-filter><kbd>/</kbd></label></div><div class="fd-browser"><div class="fd-list" data-list></div><section class="fd-detail" data-detail aria-label="Selected ${e?"API":"route"}"></section></div>`;let d=e?o.apiRoutes.map((C,h)=>({index:h,path:C.path,kind:C.methods.join(" / "),file:C.filePath})):o.routes.map((C,h)=>({index:h,path:C.pattern,kind:C.kind,file:C.filePath})),m=c.querySelector("[data-filter]"),D=c.querySelector("[data-list]");function B(){let C=e?w:g,h=d[C],ge=c.querySelector("[data-detail]");if(!h){ge.innerHTML=y("Nothing selected.");return}let ee=e?o.apiRoutes[C]:o.routes[C];ge.innerHTML=`<div class="fd-detail-title">${U(e?"api":"route")}${k(h.path)}</div><dl class="fd-properties">${b("Source",h.file)}${b(e?"Methods":"Kind",h.kind)}${b("Runtime",X(ee.runtime))}${b("Regions",ee.runtime?.regions?.join(", ")||"Not overridden")}${b("Max duration",ee.runtime?.maxDuration?`${ee.runtime.maxDuration}s`:"Not overridden")}</dl><div class="fd-detail-sub"><button class="fd-link-button" type="button" data-copy="route-source">${U("copy")}<span class="fd-button-label">Copy source path</span></button></div>${e?'<p class="fd-subtitle">Read-only metadata. Inspecting an endpoint does not send a request.</p>':""}`,I.set("route-source",h.file),D.querySelectorAll("button").forEach(he=>he.setAttribute("aria-pressed",String(Number(he.dataset.select)===C)))}function ue(){let C=m.value.toLowerCase();D.innerHTML=d.filter(h=>(h.path+" "+h.kind+" "+h.file).toLowerCase().includes(C)).map(h=>`<button type="button" class="fd-list-button" data-select="${h.index}" aria-pressed="${h.index===(e?w:g)}">${k(h.path)}<span class="fd-preview-meta">${p(h.kind)}</span></button>`).join("")||y("No matches. Try another path, kind, or source."),D.querySelectorAll("button").forEach(h=>h.onclick=()=>{e?w=Number(h.dataset.select):g=Number(h.dataset.select),B()})}m.oninput=ue,ue(),B()}function ne(){let e=s;c.innerHTML=G("Systems","Configured integrations, middleware, and storage.")+`<section class="fd-section fd-flush-top"><div class="fd-section-heading"><h3>Integrations</h3><span class="fd-label">${e.integrations.length} REGISTERED</span></div>${e.integrations.map(o=>`<details><summary>${p(o.key)} <span class="fd-muted">/ ${p(o.type)}</span></summary><dl class="fd-properties">${b("Category",o.category)}${b("Runtime",o.serverRuntime?"Server":"Platform")}${b("Middleware",String(o.middlewareCount))}${b("Providers",String(o.providerCount))}${b("Schema models",String(o.schemaModelCount))}</dl>${o.routes.map(d=>`<div class="fd-tree-item">${k(d.methods.join(" / ")+" "+d.path)}</div>`).join("")}</details>`).join("")||y("No integrations configured.")}</section><section class="fd-section"><h3>Request middleware</h3>${e.middleware.map(o=>`<div class="fd-system-row">${U("shield")}<div>${k(o.path)}<p>${p(o.filePath||o.source)}</p></div><span class="fd-tag">${o.handlerCount} handlers</span></div>`).join("")||y("No request middleware configured.")}</section><section class="fd-section"><h3>KV mounts</h3>${e.storage.map(o=>`<div class="fd-system-row">${U("database")}<div>${k(o.mount)}<p>${p(o.driver)}</p></div><span class="fd-tag">${o.default?"Default":"Configured"}</span></div>`).join("")||y("No storage mounts.")}</section>`}function ie(){let e=s;c.innerHTML=G("Runtime","Resolved deployment, schedules, layers, and environment.","Read only")+`<section class="fd-section fd-flush-top"><div class="fd-runtime-grid"><dl class="fd-properties">${b("Target",e.deployment.target)}${b("Nitro preset",e.deployment.preset)}${b("Output",e.deployment.outputDir||"Default")}</dl><dl class="fd-properties">${b("Project",e.project.name)}${b("Source",e.project.srcDir)}${b("Base path",e.project.basePath||"/")}</dl></div></section><section class="fd-section"><div class="fd-section-heading"><h3>Environment</h3><span class="fd-label">KEY NAMES ONLY</span></div><dl class="fd-properties">${b("Server",e.environment.server.join(", ")||"None declared")}${b("Public",e.environment.public.join(", ")||"None declared")}</dl><p class="fd-subtitle">Values and credentials are never included.</p></section><section class="fd-section"><h3>Schedules</h3>${e.cron.map(o=>`<div class="fd-system-row">${U("clock")}<div>${k(o.name)}<p>${p(o.path)}</p></div><span class="fd-mono">${p(o.schedule.join(" / "))} UTC</span></div>`).join("")||y("No cron schedules configured.")}<details><summary>Workflows (${e.workflows.length})</summary>${e.workflows.map(o=>`<div class="fd-tree-item">${k(o.id)} ${k(o.routePath)}</div>`).join("")||y("No workflows discovered.")}</details><details><summary>Layers (${e.layers.length})</summary>${e.layers.map(o=>`<div class="fd-tree-item">${k(o.name)} ${k(o.source)}</div>`).join("")||y("No layers configured.")}</details><details><summary>Framework features</summary><dl class="fd-properties">${Object.entries(e.features).map(([o,d])=>b(o,d?"On":"Off")).join("")}</dl></details></section>`}async function Z(){let e=++f;L?.abort(),L=new AbortController;let o=L.signal;c.innerHTML=G("Inspect","Browser source and the JavaScript Vite actually served.","Read only")+`<div class="fd-inspect-toolbar"><label class="fd-label" for="module-select">MODULE</label><select id="module-select" disabled><option>Loading browser modules\u2026</option></select></div><div data-inspected>${y("Loading module graph\u2026")}</div>`;let d=c.querySelector("[data-inspected]"),m=c.querySelector("select");try{let D=await r(`${Y}/modules.json`,o);if($||e!==f||l!=="inspect")return;if(A=D.modules,!A.length){m.replaceChildren(new Option("No browser modules yet","")),d.innerHTML=y("Visit an app page, then refresh DevTools. Only transformed browser modules inside this project are listed.");return}m.replaceChildren(...A.map(B=>new Option(B.path+(B.url.includes("?")?" "+B.url.slice(B.url.indexOf("?")):""),B.id))),m.disabled=!1,A.some(B=>B.id===S)||(S=A[0].id),m.value=S,m.onchange=()=>{S=m.value,W(S)},D.limited&&(K.textContent="Inspect lists the first 500 browser modules."),await W(S)}catch(D){if($||e!==f||l!=="inspect")return;d.innerHTML=y(D.message),m.replaceChildren(new Option("Module graph unavailable",""))}}async function W(e){let o=++f;L?.abort(),L=new AbortController;let d=c.querySelector("[data-inspected]");d.innerHTML=y("Reading module\u2026");try{let m=await r(`${Y}/module.json?id=${encodeURIComponent(e)}`,L.signal);if($||o!==f||l!=="inspect")return;I.set("module-source",m.source),I.set("module-output",m.transformed),d.innerHTML=`<div class="fd-pipeline"><span class="fd-label">SOURCE \u2192 VITE OUTPUT</span><p class="fd-subtitle">Current file on disk and the latest cached browser transform. Refresh the app after edits.</p></div><div class="fd-comparison">${re(m.source,"Source","module-source")}${re(m.transformed,"Served JavaScript","module-output")}</div><section class="fd-section"><details><summary>Imports (${m.imports.length})</summary>${m.imports.map(D=>`<div class="fd-tree-item">${k(D)}</div>`).join("")||y("No imports.")}</details><details><summary>Importers (${m.importers.length})</summary>${m.importers.map(D=>`<div class="fd-tree-item">${k(D)}</div>`).join("")||y("No importers.")}</details></section>`}catch(m){if($||o!==f||l!=="inspect")return;d.innerHTML=y(m.message)}}function R(){if(!s)return;L?.abort(),++f,I.clear(),K.textContent="",t.querySelectorAll("[data-view]").forEach(o=>{o.dataset.view===l?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")});let e={routes:s.routes.length,api:s.apiRoutes.length,diagnostics:s.diagnostics.length};switch(t.querySelectorAll("[data-count]").forEach(o=>o.textContent=e[o.dataset.count]===void 0?"":String(e[o.dataset.count])),l){case"overview":Q();break;case"routes":E(!1);break;case"api":E(!0);break;case"systems":ne();break;case"runtime":ie();break;case"diagnostics":c.innerHTML=G("Diagnostics","The same runtime checks used by farm doctor.")+`<section class="fd-section fd-flush-top">${x()}</section>`;break;case"raw":{let o=JSON.stringify(s,null,2);I.set("snapshot",o),c.innerHTML=G("Snapshot","Machine-readable workspace data. Environment values are excluded.")+re(o,"Runtime JSON","snapshot");break}case"inspect":Z();break}c.querySelectorAll("[data-go]").forEach(o=>o.onclick=()=>n(o.dataset.go))}let J=async e=>{let o=e.target.closest("[data-copy]");if(!o)return;let d=I.get(o.dataset.copy);if(d!==void 0)try{await a.navigator.clipboard.writeText(d),K.textContent="Copied to clipboard"}catch{K.textContent="Copy was blocked. Select the code and copy it manually."}},O=e=>{if(e.key==="Escape"){e.preventDefault(),i();return}if(e.key==="/"&&!["INPUT","SELECT","TEXTAREA"].includes(e.target.tagName)){let o=c.querySelector("[data-filter]");if(o){e.preventDefault(),o.focus();return}}if(e.key==="Tab"){let o=[...t.querySelectorAll("button,input,select,summary,a[href]")].filter(d=>!d.hasAttribute("disabled")&&d.getClientRects().length);e.shiftKey&&u.activeElement===o[0]?(e.preventDefault(),o.at(-1)?.focus()):!e.shiftKey&&u.activeElement===o.at(-1)&&(e.preventDefault(),o[0]?.focus())}a.parent!==a&&a.parent.postMessage({type:"farm:devtools:keydown",event:{key:e.key,code:e.code,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,repeat:e.repeat}},a.location.origin)};return t.querySelectorAll("[data-view]").forEach(e=>e.onclick=()=>n(e.dataset.view)),t.querySelector("[data-close]").onclick=i,t.querySelector("[data-refresh]").onclick=()=>{F()},t.querySelector("[data-theme-toggle]").onclick=()=>{M=P()?"light":"dark",_();try{a.localStorage.setItem("farm:devtools:theme",M)}catch{}K.textContent=M+" theme"},_(),j.addEventListener("change",_),t.addEventListener("click",J),u.addEventListener("keydown",O),t.querySelector("[data-close]").focus(),F(),{dispose(){$=!0,N?.abort(),L?.abort(),t.removeEventListener("click",J),u.removeEventListener("keydown",O),j.removeEventListener("change",_)}}}var Te=document.getElementById("farm-devtools");Te&&ze(Te);export{ze as startPanel};
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@farm.js/devtools",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Development workspace inspector for Farm.js routes, runtime, and browser modules",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"devtools",
|
|
7
|
+
"farm.js",
|
|
8
|
+
"inspect",
|
|
9
|
+
"vite"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/farming-labs/farm.js",
|
|
15
|
+
"directory": "packages/farm-devtools"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"THIRD-PARTY-NOTICES.md",
|
|
19
|
+
"dist/index.*",
|
|
20
|
+
"dist/client.*",
|
|
21
|
+
"dist/server.*",
|
|
22
|
+
"dist/modules.*",
|
|
23
|
+
"dist/types.*",
|
|
24
|
+
"dist/ui"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./client": {
|
|
36
|
+
"types": "./dist/client.d.ts",
|
|
37
|
+
"import": "./dist/client.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@fontsource-variable/geist-mono": "5.3.0",
|
|
45
|
+
"@farm.js/core": "0.1.0-beta.96"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@fontsource-variable/geist": "5.3.0",
|
|
49
|
+
"@types/node": "^20.10.5",
|
|
50
|
+
"esbuild": "^0.28.0",
|
|
51
|
+
"jsdom": "^25.0.0",
|
|
52
|
+
"sugar-high": "0.9.5",
|
|
53
|
+
"typescript": "^5.3.3",
|
|
54
|
+
"vite": "^5.0.10",
|
|
55
|
+
"vitest": "^3.2.7"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=22.13.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsc && node scripts/build-ui.mjs",
|
|
62
|
+
"type-check": "tsc --noEmit",
|
|
63
|
+
"test": "vitest run"
|
|
64
|
+
}
|
|
65
|
+
}
|