@ogygia/devtools 0.0.0-stage → 0.11.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/LICENSE +21 -0
- package/README.md +25 -2
- package/dist/client.d.ts +3 -0
- package/dist/client.js +24 -0
- package/dist/devtools/BoundaryOverlay.svelte +396 -0
- package/dist/devtools/BoundaryOverlay.svelte.d.ts +19 -0
- package/dist/devtools/Devtools.svelte +663 -0
- package/dist/devtools/Devtools.svelte.d.ts +15 -0
- package/dist/devtools/HubTab.svelte +206 -0
- package/dist/devtools/HubTab.svelte.d.ts +11 -0
- package/dist/devtools/HydrationTab.svelte +237 -0
- package/dist/devtools/HydrationTab.svelte.d.ts +13 -0
- package/dist/devtools/IslandDetail.svelte +615 -0
- package/dist/devtools/IslandDetail.svelte.d.ts +15 -0
- package/dist/devtools/LedgerTab.svelte +287 -0
- package/dist/devtools/LedgerTab.svelte.d.ts +11 -0
- package/dist/devtools/LensTab.svelte +290 -0
- package/dist/devtools/LensTab.svelte.d.ts +19 -0
- package/dist/devtools/NavTab.svelte +229 -0
- package/dist/devtools/NavTab.svelte.d.ts +11 -0
- package/dist/devtools/PageTab.svelte +1122 -0
- package/dist/devtools/PageTab.svelte.d.ts +15 -0
- package/dist/devtools/ProfilerTab.svelte +755 -0
- package/dist/devtools/ProfilerTab.svelte.d.ts +15 -0
- package/dist/devtools/PropsTree.svelte +155 -0
- package/dist/devtools/PropsTree.svelte.d.ts +15 -0
- package/dist/devtools/SessionTab.svelte +796 -0
- package/dist/devtools/SessionTab.svelte.d.ts +11 -0
- package/dist/devtools/TimelineTab.svelte +267 -0
- package/dist/devtools/TimelineTab.svelte.d.ts +11 -0
- package/dist/devtools/WireTab.svelte +149 -0
- package/dist/devtools/WireTab.svelte.d.ts +11 -0
- package/dist/devtools/bytes.d.ts +70 -0
- package/dist/devtools/bytes.js +82 -0
- package/dist/devtools/cache-headers.d.ts +20 -0
- package/dist/devtools/cache-headers.js +81 -0
- package/dist/devtools/highlight.d.ts +7 -0
- package/dist/devtools/highlight.js +83 -0
- package/dist/devtools/hydration.d.ts +48 -0
- package/dist/devtools/hydration.js +93 -0
- package/dist/devtools/index.d.ts +3 -0
- package/dist/devtools/index.js +3 -0
- package/dist/devtools/ledger-dom.d.ts +7 -0
- package/dist/devtools/ledger-dom.js +151 -0
- package/dist/devtools/leftovers.d.ts +77 -0
- package/dist/devtools/leftovers.js +319 -0
- package/dist/devtools/names.d.ts +1 -0
- package/dist/devtools/names.js +34 -0
- package/dist/devtools/page.d.ts +96 -0
- package/dist/devtools/page.js +957 -0
- package/dist/devtools/profile-anchors.d.ts +22 -0
- package/dist/devtools/profile-anchors.js +135 -0
- package/dist/devtools/profile-store.d.ts +175 -0
- package/dist/devtools/profile-store.js +239 -0
- package/dist/devtools/regions.d.ts +77 -0
- package/dist/devtools/regions.js +132 -0
- package/dist/devtools/session.d.ts +31 -0
- package/dist/devtools/session.js +455 -0
- package/dist/devtools/since-load.d.ts +50 -0
- package/dist/devtools/since-load.js +89 -0
- package/dist/devtools/source-lines.d.ts +24 -0
- package/dist/devtools/source-lines.js +106 -0
- package/dist/devtools/styles.d.ts +52 -0
- package/dist/devtools/styles.js +248 -0
- package/dist/devtools/testing-engine.d.ts +83 -0
- package/dist/devtools/testing-engine.js +220 -0
- package/dist/devtools/ui-app.d.ts +5 -0
- package/dist/devtools/ui-app.js +69 -0
- package/dist/devtools/ui.d.ts +50 -0
- package/dist/devtools/ui.js +175 -0
- package/dist/profiler/alloc.d.ts +75 -0
- package/dist/profiler/alloc.js +76 -0
- package/dist/profiler/analyze.d.ts +437 -0
- package/dist/profiler/analyze.js +1941 -0
- package/dist/profiler/app-path.d.ts +7 -0
- package/dist/profiler/app-path.js +26 -0
- package/dist/profiler/async-io.d.ts +58 -0
- package/dist/profiler/async-io.js +187 -0
- package/dist/profiler/beacon-standalone.d.ts +4 -0
- package/dist/profiler/beacon-standalone.js +409 -0
- package/dist/profiler/browser-findings.d.ts +25 -0
- package/dist/profiler/browser-findings.js +260 -0
- package/dist/profiler/byte-strip.d.ts +58 -0
- package/dist/profiler/byte-strip.js +228 -0
- package/dist/profiler/client-files.d.ts +16 -0
- package/dist/profiler/client-files.js +60 -0
- package/dist/profiler/client-windows.d.ts +49 -0
- package/dist/profiler/client-windows.js +95 -0
- package/dist/profiler/client.d.ts +40 -0
- package/dist/profiler/client.js +82 -0
- package/dist/profiler/compare.d.ts +308 -0
- package/dist/profiler/compare.js +733 -0
- package/dist/profiler/compress.d.ts +10 -0
- package/dist/profiler/compress.js +36 -0
- package/dist/profiler/contention.d.ts +60 -0
- package/dist/profiler/contention.js +86 -0
- package/dist/profiler/crypto.d.ts +19 -0
- package/dist/profiler/crypto.js +101 -0
- package/dist/profiler/doc-diff.d.ts +47 -0
- package/dist/profiler/doc-diff.js +214 -0
- package/dist/profiler/dom-diff.d.ts +43 -0
- package/dist/profiler/dom-diff.js +121 -0
- package/dist/profiler/drill.d.ts +89 -0
- package/dist/profiler/drill.js +553 -0
- package/dist/profiler/embedded-maps.d.ts +37 -0
- package/dist/profiler/embedded-maps.js +135 -0
- package/dist/profiler/env.d.ts +6 -0
- package/dist/profiler/env.js +10 -0
- package/dist/profiler/forecast.d.ts +76 -0
- package/dist/profiler/forecast.js +225 -0
- package/dist/profiler/frames.d.ts +11 -0
- package/dist/profiler/frames.js +42 -0
- package/dist/profiler/gc.d.ts +144 -0
- package/dist/profiler/gc.js +271 -0
- package/dist/profiler/hole-slots.d.ts +31 -0
- package/dist/profiler/hole-slots.js +90 -0
- package/dist/profiler/index.d.ts +288 -0
- package/dist/profiler/index.js +4921 -0
- package/dist/profiler/insights.d.ts +96 -0
- package/dist/profiler/insights.js +239 -0
- package/dist/profiler/ledger.d.ts +121 -0
- package/dist/profiler/ledger.js +440 -0
- package/dist/profiler/lineage.d.ts +81 -0
- package/dist/profiler/lineage.js +359 -0
- package/dist/profiler/module-map.d.ts +12 -0
- package/dist/profiler/module-map.js +94 -0
- package/dist/profiler/net.d.ts +169 -0
- package/dist/profiler/net.js +586 -0
- package/dist/profiler/on-demand.d.ts +11 -0
- package/dist/profiler/on-demand.js +15 -0
- package/dist/profiler/own-requests.d.ts +9 -0
- package/dist/profiler/own-requests.js +17 -0
- package/dist/profiler/patterns.d.ts +476 -0
- package/dist/profiler/patterns.js +2203 -0
- package/dist/profiler/profiler-router.d.ts +245 -0
- package/dist/profiler/profiler-router.js +113 -0
- package/dist/profiler/refresh-stub.d.ts +2 -0
- package/dist/profiler/refresh-stub.js +37 -0
- package/dist/profiler/report.d.ts +1404 -0
- package/dist/profiler/report.js +2638 -0
- package/dist/profiler/river.d.ts +65 -0
- package/dist/profiler/river.js +298 -0
- package/dist/profiler/route-files.d.ts +22 -0
- package/dist/profiler/route-files.js +55 -0
- package/dist/profiler/route-imports.d.ts +14 -0
- package/dist/profiler/route-imports.js +83 -0
- package/dist/profiler/saving.d.ts +22 -0
- package/dist/profiler/saving.js +42 -0
- package/dist/profiler/score.d.ts +109 -0
- package/dist/profiler/score.js +261 -0
- package/dist/profiler/session-cookie.d.ts +28 -0
- package/dist/profiler/session-cookie.js +45 -0
- package/dist/profiler/sink.d.ts +81 -0
- package/dist/profiler/sink.js +124 -0
- package/dist/profiler/site-fixes.d.ts +25 -0
- package/dist/profiler/site-fixes.js +62 -0
- package/dist/profiler/source-scan.d.ts +210 -0
- package/dist/profiler/source-scan.js +1724 -0
- package/dist/profiler/span.d.ts +90 -0
- package/dist/profiler/span.js +109 -0
- package/dist/profiler/stacks.d.ts +43 -0
- package/dist/profiler/stacks.js +107 -0
- package/dist/profiler/standalone.d.ts +27 -0
- package/dist/profiler/standalone.js +98 -0
- package/dist/profiler/steps.d.ts +39 -0
- package/dist/profiler/steps.js +74 -0
- package/dist/profiler/storage/index.d.ts +87 -0
- package/dist/profiler/storage/index.js +76 -0
- package/dist/profiler/storage/postgres.d.ts +12 -0
- package/dist/profiler/storage/postgres.js +94 -0
- package/dist/profiler/storage/redis.d.ts +19 -0
- package/dist/profiler/storage/redis.js +148 -0
- package/dist/profiler/storage/sqlite.d.ts +2 -0
- package/dist/profiler/storage/sqlite.js +85 -0
- package/dist/profiler/storage/visits.d.ts +4 -0
- package/dist/profiler/storage/visits.js +6 -0
- package/dist/profiler/stream-tail.d.ts +26 -0
- package/dist/profiler/stream-tail.js +74 -0
- package/dist/profiler/timeline.d.ts +279 -0
- package/dist/profiler/timeline.js +690 -0
- package/dist/profiler/ui/AllocStrip.svelte +146 -0
- package/dist/profiler/ui/AllocStrip.svelte.d.ts +17 -0
- package/dist/profiler/ui/Awaits.svelte +363 -0
- package/dist/profiler/ui/Awaits.svelte.d.ts +16 -0
- package/dist/profiler/ui/ByteStrip.svelte +182 -0
- package/dist/profiler/ui/ByteStrip.svelte.d.ts +18 -0
- package/dist/profiler/ui/Compare.svelte +24 -0
- package/dist/profiler/ui/Compare.svelte.d.ts +16 -0
- package/dist/profiler/ui/CompareBody.svelte +429 -0
- package/dist/profiler/ui/CompareBody.svelte.d.ts +8 -0
- package/dist/profiler/ui/ComponentsTable.svelte +265 -0
- package/dist/profiler/ui/ComponentsTable.svelte.d.ts +20 -0
- package/dist/profiler/ui/Dashboard.svelte +492 -0
- package/dist/profiler/ui/Dashboard.svelte.d.ts +31 -0
- package/dist/profiler/ui/DataRiver.svelte +206 -0
- package/dist/profiler/ui/DataRiver.svelte.d.ts +13 -0
- package/dist/profiler/ui/DomTravel.svelte +207 -0
- package/dist/profiler/ui/DomTravel.svelte.d.ts +9 -0
- package/dist/profiler/ui/DownloadHtml.svelte +52 -0
- package/dist/profiler/ui/DownloadHtml.svelte.d.ts +10 -0
- package/dist/profiler/ui/Drill.svelte +276 -0
- package/dist/profiler/ui/Drill.svelte.d.ts +12 -0
- package/dist/profiler/ui/ExportButton.svelte +59 -0
- package/dist/profiler/ui/ExportButton.svelte.d.ts +8 -0
- package/dist/profiler/ui/Flame.svelte +222 -0
- package/dist/profiler/ui/Flame.svelte.d.ts +12 -0
- package/dist/profiler/ui/FrameDetails.svelte +308 -0
- package/dist/profiler/ui/FrameDetails.svelte.d.ts +16 -0
- package/dist/profiler/ui/FunctionsTable.svelte +156 -0
- package/dist/profiler/ui/FunctionsTable.svelte.d.ts +17 -0
- package/dist/profiler/ui/IslandHeatmap.svelte +151 -0
- package/dist/profiler/ui/IslandHeatmap.svelte.d.ts +16 -0
- package/dist/profiler/ui/IslandsTable.svelte +448 -0
- package/dist/profiler/ui/IslandsTable.svelte.d.ts +16 -0
- package/dist/profiler/ui/KeepLocal.svelte +46 -0
- package/dist/profiler/ui/KeepLocal.svelte.d.ts +8 -0
- package/dist/profiler/ui/Ledger.svelte +196 -0
- package/dist/profiler/ui/Ledger.svelte.d.ts +18 -0
- package/dist/profiler/ui/LocalCompare.svelte +48 -0
- package/dist/profiler/ui/LocalCompare.svelte.d.ts +8 -0
- package/dist/profiler/ui/LocalReports.svelte +68 -0
- package/dist/profiler/ui/LocalReports.svelte.d.ts +7 -0
- package/dist/profiler/ui/Login.svelte +13 -0
- package/dist/profiler/ui/Login.svelte.d.ts +12 -0
- package/dist/profiler/ui/LoginForm.svelte +42 -0
- package/dist/profiler/ui/LoginForm.svelte.d.ts +7 -0
- package/dist/profiler/ui/Message.svelte +10 -0
- package/dist/profiler/ui/Message.svelte.d.ts +12 -0
- package/dist/profiler/ui/OnThisPage.svelte +137 -0
- package/dist/profiler/ui/OnThisPage.svelte.d.ts +3 -0
- package/dist/profiler/ui/OneClock.svelte +297 -0
- package/dist/profiler/ui/OneClock.svelte.d.ts +27 -0
- package/dist/profiler/ui/Panel.svelte +10 -0
- package/dist/profiler/ui/Panel.svelte.d.ts +16 -0
- package/dist/profiler/ui/Paths.svelte +269 -0
- package/dist/profiler/ui/Paths.svelte.d.ts +15 -0
- package/dist/profiler/ui/Patterns.svelte +364 -0
- package/dist/profiler/ui/Patterns.svelte.d.ts +15 -0
- package/dist/profiler/ui/PermalinkGate.svelte +143 -0
- package/dist/profiler/ui/PermalinkGate.svelte.d.ts +10 -0
- package/dist/profiler/ui/RenderSteps.svelte +218 -0
- package/dist/profiler/ui/RenderSteps.svelte.d.ts +13 -0
- package/dist/profiler/ui/Report.svelte +28 -0
- package/dist/profiler/ui/Report.svelte.d.ts +20 -0
- package/dist/profiler/ui/ReportBody.svelte +2592 -0
- package/dist/profiler/ui/ReportBody.svelte.d.ts +21 -0
- package/dist/profiler/ui/Run.svelte +17 -0
- package/dist/profiler/ui/Run.svelte.d.ts +14 -0
- package/dist/profiler/ui/RunView.svelte +146 -0
- package/dist/profiler/ui/RunView.svelte.d.ts +10 -0
- package/dist/profiler/ui/ScoreCard.svelte +197 -0
- package/dist/profiler/ui/ScoreCard.svelte.d.ts +7 -0
- package/dist/profiler/ui/Scrub.svelte +293 -0
- package/dist/profiler/ui/Scrub.svelte.d.ts +18 -0
- package/dist/profiler/ui/SeedExplainer.svelte +193 -0
- package/dist/profiler/ui/SeedExplainer.svelte.d.ts +16 -0
- package/dist/profiler/ui/ShareLink.svelte +148 -0
- package/dist/profiler/ui/ShareLink.svelte.d.ts +8 -0
- package/dist/profiler/ui/Shell.svelte +50 -0
- package/dist/profiler/ui/Shell.svelte.d.ts +27 -0
- package/dist/profiler/ui/Sidebar.svelte +312 -0
- package/dist/profiler/ui/Sidebar.svelte.d.ts +7 -0
- package/dist/profiler/ui/Site.svelte +20 -0
- package/dist/profiler/ui/Site.svelte.d.ts +23 -0
- package/dist/profiler/ui/SiteView.svelte +385 -0
- package/dist/profiler/ui/SiteView.svelte.d.ts +27 -0
- package/dist/profiler/ui/ThemeSwitch.svelte +78 -0
- package/dist/profiler/ui/ThemeSwitch.svelte.d.ts +3 -0
- package/dist/profiler/ui/Timeline.svelte +672 -0
- package/dist/profiler/ui/Timeline.svelte.d.ts +22 -0
- package/dist/profiler/ui/Treemap.svelte +278 -0
- package/dist/profiler/ui/Treemap.svelte.d.ts +20 -0
- package/dist/profiler/ui/Upload.svelte +19 -0
- package/dist/profiler/ui/Upload.svelte.d.ts +10 -0
- package/dist/profiler/ui/UploadForm.svelte +59 -0
- package/dist/profiler/ui/UploadForm.svelte.d.ts +6 -0
- package/dist/profiler/ui/WaitingTable.svelte +55 -0
- package/dist/profiler/ui/WaitingTable.svelte.d.ts +14 -0
- package/dist/profiler/ui/Waterfall.svelte +371 -0
- package/dist/profiler/ui/Waterfall.svelte.d.ts +7 -0
- package/dist/profiler/ui/WhatIf.svelte +87 -0
- package/dist/profiler/ui/WhatIf.svelte.d.ts +18 -0
- package/dist/profiler/ui/fake-progress.svelte.d.ts +15 -0
- package/dist/profiler/ui/fake-progress.svelte.js +38 -0
- package/dist/profiler/ui/format.d.ts +20 -0
- package/dist/profiler/ui/format.js +71 -0
- package/dist/profiler/ui/permalink.d.ts +9 -0
- package/dist/profiler/ui/permalink.js +108 -0
- package/dist/profiler/ui/press.d.ts +5 -0
- package/dist/profiler/ui/press.js +19 -0
- package/dist/profiler/ui/profiler.css +650 -0
- package/dist/profiler/ui/report-data.d.ts +189 -0
- package/dist/profiler/ui/report-data.js +393 -0
- package/dist/profiler/ui/report-request.d.ts +6 -0
- package/dist/profiler/ui/report-request.js +50 -0
- package/dist/profiler/ui/row-anchor.svelte.d.ts +12 -0
- package/dist/profiler/ui/row-anchor.svelte.js +44 -0
- package/dist/profiler/ui/sort.svelte.d.ts +14 -0
- package/dist/profiler/ui/sort.svelte.js +37 -0
- package/dist/profiler/ui/store.d.ts +45 -0
- package/dist/profiler/ui/store.js +92 -0
- package/dist/profiler/visit.d.ts +389 -0
- package/dist/profiler/visit.js +1002 -0
- package/dist/report.d.ts +5 -0
- package/dist/report.js +4 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +38 -0
- package/dist/vite.d.ts +12 -0
- package/dist/vite.js +78 -0
- package/package.json +103 -3
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { is_ogp, ogp_decode } from "./profiler/crypto.js";
|
|
2
|
+
import { is_dump, report_json } from "./profiler/report.js";
|
|
3
|
+
import { fix_impact } from "./profiler/patterns.js";
|
|
4
|
+
import { Forecast } from "./profiler/forecast.js";
|
|
5
|
+
export { type Forecast, fix_impact, is_dump, is_ogp, ogp_decode, report_json };
|
package/dist/report.js
ADDED
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProfilerOptions } from "./profiler/index.js";
|
|
2
|
+
import { ServerPlugin } from "@ogygia/core/plugin";
|
|
3
|
+
/** What `devtools()` hands its server half (vite.config → `virtual:ogygia/server-plugins`). The
|
|
4
|
+
* profiler's `secret` is here only when the app passed one (then it IS baked into the server build,
|
|
5
|
+
* on purpose — a serverless host may have no runtime env); left out, the profiler reads
|
|
6
|
+
* OGYGIA_PROFILER_SECRET at runtime. */
|
|
7
|
+
export interface DevtoolsServerOptions {
|
|
8
|
+
profiler: ProfilerOptions | null;
|
|
9
|
+
}
|
|
10
|
+
declare const server: ServerPlugin<DevtoolsServerOptions>;
|
|
11
|
+
export { server as default };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { profiler_demand_skip } from "./profiler/on-demand.js";
|
|
2
|
+
import { defineServer } from "@ogygia/core/plugin";
|
|
3
|
+
import { want_request_stats } from "@ogygia/core/internal/server";
|
|
4
|
+
// src/server.ts
|
|
5
|
+
/** the mounted profiler; `undefined` until the first request resolves it, `null` when unavailable */
|
|
6
|
+
let mounted;
|
|
7
|
+
async function mount(options) {
|
|
8
|
+
if (mounted !== void 0) return mounted;
|
|
9
|
+
try {
|
|
10
|
+
const { profiler } = await import("./profiler/index.js");
|
|
11
|
+
const { getProfilerStore } = await import("./profiler/storage/index.js").catch(() => ({ getProfilerStore: () => void 0 }));
|
|
12
|
+
const store = getProfilerStore();
|
|
13
|
+
mounted = profiler({
|
|
14
|
+
...options,
|
|
15
|
+
...store ? { store } : {}
|
|
16
|
+
});
|
|
17
|
+
} catch {
|
|
18
|
+
mounted = null;
|
|
19
|
+
}
|
|
20
|
+
return mounted;
|
|
21
|
+
}
|
|
22
|
+
const server = defineServer({
|
|
23
|
+
setup(app) {
|
|
24
|
+
if (app.options.profiler) want_request_stats();
|
|
25
|
+
},
|
|
26
|
+
async handle({ event, options }, next) {
|
|
27
|
+
const config = options.profiler;
|
|
28
|
+
if (!config) return next();
|
|
29
|
+
if (profiler_demand_skip(!!config.onDemand, mounted !== void 0, event.url.pathname, config.path || "/__profiler")) return next();
|
|
30
|
+
const prof = await mount(config);
|
|
31
|
+
if (!prof) return next();
|
|
32
|
+
return prof({
|
|
33
|
+
event,
|
|
34
|
+
resolve: (_event, opts) => next(opts)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export { server as default };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProfilerOptions } from "./profiler/index.js";
|
|
2
|
+
import { DevtoolsServerOptions } from "./server.js";
|
|
3
|
+
import { OgygiaPlugin } from "@ogygia/core/vite";
|
|
4
|
+
import { Plugin } from "vite";
|
|
5
|
+
export interface DevtoolsOptions {
|
|
6
|
+
/** The dock and core's events (default true). */
|
|
7
|
+
dock?: boolean;
|
|
8
|
+
/** The SSR profiler: `true` or its options (default off). */
|
|
9
|
+
profiler?: boolean | ProfilerOptions;
|
|
10
|
+
}
|
|
11
|
+
export declare function devtools(options?: DevtoolsOptions): [OgygiaPlugin<DevtoolsServerOptions>, Plugin];
|
|
12
|
+
export type { ProfilerOptions };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { isMainThread } from "node:worker_threads";
|
|
5
|
+
import { definePlugin } from "@ogygia/core/vite";
|
|
6
|
+
// src/vite.ts
|
|
7
|
+
/**
|
|
8
|
+
* `devtools()` — the in-page dock and the SSR profiler, listed beside `ogygia()`
|
|
9
|
+
* in vite.config. List it only where you want it:
|
|
10
|
+
*
|
|
11
|
+
* plugins: [...(mode !== 'production' ? [devtools({ profiler: true })] : [])]
|
|
12
|
+
*
|
|
13
|
+
* - `dock` (default true): core's events compiled in, browser and server, and the dock that reads
|
|
14
|
+
* them (Alt+O). In a build the pages carry only a small launcher: the dock's code loads when
|
|
15
|
+
* someone opens it, and the page is measured from the next load on.
|
|
16
|
+
* - `profiler` (default off): `true` or its options. The server half wraps every request, times the
|
|
17
|
+
* render and serves its UI at `/__profiler`; the build records what it reads (maps, island
|
|
18
|
+
* detail). Its secret defaults to the OGYGIA_PROFILER_SECRET env var at runtime.
|
|
19
|
+
*/
|
|
20
|
+
/** this package's directory (from `dist/vite.js` or `src/vite.ts`) */
|
|
21
|
+
const PKG_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
|
22
|
+
/** the workspace checkout ships `src`; an install, `dist` */
|
|
23
|
+
const FROM_SRC = fs.existsSync(path.join(PKG_ROOT, "src/profiler/profiler-router.ts"));
|
|
24
|
+
const posix = (p) => p.split(path.sep).join("/");
|
|
25
|
+
/** the server half's dynamic import of the profiler (src `.ts` or built `.js`) */
|
|
26
|
+
const PROFILER_IMPORT_RE = /import\((['"])\.\/profiler\/index\.(ts|js)\1\)/;
|
|
27
|
+
function devtools(options = {}) {
|
|
28
|
+
const dock = options.dock !== false;
|
|
29
|
+
const profiler = options.profiler ? options.profiler === true ? {} : { ...options.profiler } : null;
|
|
30
|
+
return [definePlugin({
|
|
31
|
+
name: "@ogygia/devtools",
|
|
32
|
+
server: import.meta.resolve("./server.js"),
|
|
33
|
+
client: import.meta.resolve("./client.js"),
|
|
34
|
+
options: { profiler },
|
|
35
|
+
build(b) {
|
|
36
|
+
if (dock) b.events({ lazy: !b.dev });
|
|
37
|
+
if (profiler) {
|
|
38
|
+
b.measure();
|
|
39
|
+
const profiler_router = path.join(PKG_ROOT, FROM_SRC ? "src/profiler/profiler-router.ts" : "dist/profiler/profiler-router.js");
|
|
40
|
+
b.files({
|
|
41
|
+
root: PKG_ROOT,
|
|
42
|
+
dirs: [path.join(PKG_ROOT, FROM_SRC ? "src/profiler/ui" : "dist/profiler/ui")],
|
|
43
|
+
files: [profiler_router]
|
|
44
|
+
});
|
|
45
|
+
b.pageModules({ files: [profiler_router] });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}), devtools_vite(dock, profiler)];
|
|
49
|
+
}
|
|
50
|
+
/** The plugin's own Vite side: its client dependencies for the dev optimizer, the build warnings, and
|
|
51
|
+
* the dev CSS-crawl guard on its server half. */
|
|
52
|
+
function devtools_vite(dock, profiler) {
|
|
53
|
+
const server_ids = /* @__PURE__ */ new Set([posix(path.join(PKG_ROOT, "src/server.ts")), posix(path.join(PKG_ROOT, "dist/server.js"))]);
|
|
54
|
+
let dev = false;
|
|
55
|
+
return {
|
|
56
|
+
name: "ogygia:devtools",
|
|
57
|
+
enforce: "pre",
|
|
58
|
+
config(_config, env) {
|
|
59
|
+
dev = env.command === "serve";
|
|
60
|
+
if (env.command === "build" && isMainThread) {
|
|
61
|
+
if (dock) console.warn("[ogygia] devtools is ON for this build: its pages carry the devtools launcher (the dock loads only when opened). Keep it off for production: list `devtools()` only when `mode !== 'production'`.");
|
|
62
|
+
if (profiler && "secret" in profiler && !profiler.secret) console.warn("[ogygia] profiler: `profiler.secret` is EMPTY in this build — the variable it reads is not set in the BUILD environment. The UI will be DISABLED in production unless OGYGIA_PROFILER_SECRET exists at runtime (on Amplify / Lambda it does not): /__profiler will answer \"installed but disabled\". Set the variable where the build runs, and keep the `profiler` option unconditional.");
|
|
63
|
+
}
|
|
64
|
+
const out = {};
|
|
65
|
+
if (dock && env.command === "serve") out.optimizeDeps = { include: ["@ogygia/devtools > @neodrag/svelte", "@ogygia/devtools > @neodrag/svelte/resize"] };
|
|
66
|
+
if (profiler) out.ssr = { noExternal: ["@ogygia/router"] };
|
|
67
|
+
return out;
|
|
68
|
+
},
|
|
69
|
+
transform(code, id, opts) {
|
|
70
|
+
if (!dev || !opts?.ssr || !server_ids.has(id.split("?")[0])) return null;
|
|
71
|
+
return {
|
|
72
|
+
code: code.replace(PROFILER_IMPORT_RE, "import(/* @vite-ignore */ ((s) => s)($1./profiler/index.$2$1))"),
|
|
73
|
+
map: null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export { devtools };
|
package/package.json
CHANGED
|
@@ -1,6 +1,106 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogygia/devtools",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "Devtools for ogygia: the in-page dock, and the SSR profiler with its report, client marks and storage adapters",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"devtools",
|
|
7
|
+
"ogygia",
|
|
8
|
+
"performance",
|
|
9
|
+
"profiler",
|
|
10
|
+
"sveltekit"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://ogygiajs.dev",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Puru Vijayvargia <devpuruvj@gmail.com>",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/ogygiajs/ogygia.git",
|
|
18
|
+
"directory": "packages/devtools"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/devtools/index.d.ts",
|
|
28
|
+
"svelte": "./dist/devtools/index.js",
|
|
29
|
+
"default": "./dist/devtools/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./vite": {
|
|
32
|
+
"types": "./dist/vite.d.ts",
|
|
33
|
+
"default": "./dist/vite.js"
|
|
34
|
+
},
|
|
35
|
+
"./report": {
|
|
36
|
+
"types": "./dist/report.d.ts",
|
|
37
|
+
"default": "./dist/report.js"
|
|
38
|
+
},
|
|
39
|
+
"./profiler": {
|
|
40
|
+
"types": "./dist/profiler/span.d.ts",
|
|
41
|
+
"default": "./dist/profiler/span.js"
|
|
42
|
+
},
|
|
43
|
+
"./profiler/client": {
|
|
44
|
+
"types": "./dist/profiler/client.d.ts",
|
|
45
|
+
"default": "./dist/profiler/client.js"
|
|
46
|
+
},
|
|
47
|
+
"./profiler/storage": {
|
|
48
|
+
"types": "./dist/profiler/storage/index.d.ts",
|
|
49
|
+
"default": "./dist/profiler/storage/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./profiler/storage/sqlite": {
|
|
52
|
+
"types": "./dist/profiler/storage/sqlite.d.ts",
|
|
53
|
+
"default": "./dist/profiler/storage/sqlite.js"
|
|
54
|
+
},
|
|
55
|
+
"./profiler/storage/redis": {
|
|
56
|
+
"types": "./dist/profiler/storage/redis.d.ts",
|
|
57
|
+
"default": "./dist/profiler/storage/redis.js"
|
|
58
|
+
},
|
|
59
|
+
"./profiler/storage/postgres": {
|
|
60
|
+
"types": "./dist/profiler/storage/postgres.d.ts",
|
|
61
|
+
"default": "./dist/profiler/storage/postgres.js"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@neodrag/svelte": "3.0.0-next.12",
|
|
69
|
+
"devalue": "^5.9.3"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@playwright/test": "1.62.1",
|
|
73
|
+
"@sveltejs/kit": "^2.70.2",
|
|
74
|
+
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
75
|
+
"@types/node": "^26.1.2",
|
|
76
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
77
|
+
"svelte": "5.56.8",
|
|
78
|
+
"svelte-check": "^4.7.4",
|
|
79
|
+
"tsdown": "^0.23.4",
|
|
80
|
+
"typescript": "^6.0.3",
|
|
81
|
+
"vite": "^8.3.5",
|
|
82
|
+
"vitest": "^4.1.12",
|
|
83
|
+
"@ogygia/core": "0.11.0",
|
|
84
|
+
"@ogygia/router": "0.11.0",
|
|
85
|
+
"@ogygia/tooling": "0.0.0",
|
|
86
|
+
"@ogygia/tsdown-plugin-svelte": "1.1.0"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"@sveltejs/kit": ">=2.70.2 <4",
|
|
90
|
+
"svelte": "^5.56.8",
|
|
91
|
+
"vite": "^8.2.4",
|
|
92
|
+
"@ogygia/core": "^0.11.0",
|
|
93
|
+
"@ogygia/router": "^0.11.0"
|
|
94
|
+
},
|
|
95
|
+
"peerDependenciesMeta": {
|
|
96
|
+
"@ogygia/router": {
|
|
97
|
+
"optional": true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "tsdown",
|
|
102
|
+
"check": "tsc -p . && svelte-check --tsconfig ./tsconfig.check.json --fail-on-warnings && tsc -p test && tsc -p e2e && vitest run",
|
|
103
|
+
"test": "vitest run",
|
|
104
|
+
"e2e": "playwright test"
|
|
105
|
+
}
|
|
6
106
|
}
|