archidocs 1.3.2 → 1.3.3
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 +1 -1
- package/dist/cli/dev.d.ts +7 -0
- package/dist/cli/dev.js +23 -5
- package/dist/viewer/assets/index-BhiW2o_9.js +138 -0
- package/dist/viewer/assets/{png-DMwnpRCt.js → png-CJovcggr.js} +1 -1
- package/dist/viewer/assets/{svg-DN6lMeZo.js → svg-Cg6M1xWg.js} +1 -1
- package/dist/viewer/index.html +1 -1
- package/package.json +10 -1
- package/dist/viewer/assets/index-C0lIIm8V.js +0 -138
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ npx archidocs check
|
|
|
102
102
|
npx archidocs dev
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
Open <http://localhost:4321>. The viewer starts on the
|
|
105
|
+
Open <http://localhost:4321>. The viewer starts on the C1 Landscape, which shows the Shopper and the Online Shop. Choose **Go deeper › C2 Landscape** and select the arrow button on the Online Shop box to see the two Services inside it. The viewer reloads as you edit the files.
|
|
106
106
|
|
|
107
107
|
The finished Workspace is in [examples/quick-start](examples/quick-start).
|
|
108
108
|
|
package/dist/cli/dev.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Issue } from "../core/index.ts";
|
|
2
2
|
import { type Checkout } from "../workspace/index.ts";
|
|
3
3
|
export declare const DEFAULT_DEV_PORT = 4321;
|
|
4
|
+
/**
|
|
5
|
+
* How long the Workspace must be quiet before it is read again, so an agent's
|
|
6
|
+
* run of MCP edits, seconds apart, makes one new Bundle, not one per edit.
|
|
7
|
+
*/
|
|
8
|
+
export declare const QUIET_MS = 1000;
|
|
9
|
+
/** The longest a burst of changes holds a rebuild back, so a long agent session still shows progress. */
|
|
10
|
+
export declare const MAX_WAIT_MS = 5000;
|
|
4
11
|
export interface DevOptions {
|
|
5
12
|
/** The Workspace to serve. Its root is watched for changes, and its name is how the viewer's exports name the Workspace, as `site.json` does in a built site. */
|
|
6
13
|
checkout: Checkout;
|
package/dist/cli/dev.js
CHANGED
|
@@ -8,6 +8,13 @@ import { INDEX_PATH, INDEX_VERSION, LATEST_BUNDLE_PATH, serializeBundle, seriali
|
|
|
8
8
|
export const DEFAULT_DEV_PORT = 4321;
|
|
9
9
|
/** The path the page listens on for reloads; under `__archidocs/` so it can't clash with a site file. */
|
|
10
10
|
const EVENTS = "/__archidocs/events";
|
|
11
|
+
/**
|
|
12
|
+
* How long the Workspace must be quiet before it is read again, so an agent's
|
|
13
|
+
* run of MCP edits, seconds apart, makes one new Bundle, not one per edit.
|
|
14
|
+
*/
|
|
15
|
+
export const QUIET_MS = 1000;
|
|
16
|
+
/** The longest a burst of changes holds a rebuild back, so a long agent session still shows progress. */
|
|
17
|
+
export const MAX_WAIT_MS = 5000;
|
|
11
18
|
const TYPES = {
|
|
12
19
|
".html": "text/html; charset=utf-8",
|
|
13
20
|
".js": "text/javascript; charset=utf-8",
|
|
@@ -20,14 +27,19 @@ const TYPES = {
|
|
|
20
27
|
".png": "image/png",
|
|
21
28
|
};
|
|
22
29
|
/**
|
|
23
|
-
* The page's side of dev mode:
|
|
24
|
-
* place
|
|
30
|
+
* The page's side of dev mode: on a new Bundle, have the viewer swap it in
|
|
31
|
+
* place (keeping the camera, selection and open boxes), or reload the page
|
|
32
|
+
* when it can't (hash routing keeps the place); and show the Workspace's
|
|
33
|
+
* errors in a banner while they last.
|
|
25
34
|
*/
|
|
26
35
|
const CLIENT = `<script>
|
|
27
36
|
(() => {
|
|
28
37
|
let banner;
|
|
29
38
|
const events = new EventSource(".${EVENTS}");
|
|
30
|
-
events.addEventListener("reload", () =>
|
|
39
|
+
events.addEventListener("reload", async () => {
|
|
40
|
+
const swapped = await Promise.resolve(window.__archidocsSwap?.()).catch(() => false);
|
|
41
|
+
if (!swapped) location.reload();
|
|
42
|
+
});
|
|
31
43
|
events.addEventListener("errors", (e) => {
|
|
32
44
|
banner ??= Object.assign(document.body.appendChild(document.createElement("pre")), { id: "archidocs-dev-errors" });
|
|
33
45
|
banner.style.cssText = "position:fixed;left:12px;right:12px;bottom:12px;z-index:99999;margin:0;max-height:40vh;overflow:auto;padding:12px 14px;border-radius:8px;background:#2b0f12;color:#ffd7d9;font:12px/1.5 ui-monospace,monospace;white-space:pre-wrap;box-shadow:0 6px 24px rgba(0,0,0,.35)";
|
|
@@ -73,17 +85,23 @@ export async function serveDev({ checkout, viewerDir, host = "127.0.0.1", port =
|
|
|
73
85
|
else if (hadErrors)
|
|
74
86
|
broadcast("ok");
|
|
75
87
|
};
|
|
76
|
-
//
|
|
88
|
+
// Changes in a burst (an editor's write-then-rename, a git checkout, an agent's
|
|
89
|
+
// run of MCP edits) make one rebuild once the Workspace has been quiet for
|
|
90
|
+
// QUIET_MS, or MAX_WAIT_MS after the burst's first change at the latest.
|
|
77
91
|
let timer;
|
|
92
|
+
let burstStart;
|
|
78
93
|
let running = Promise.resolve();
|
|
79
94
|
const schedule = () => {
|
|
80
95
|
clearTimeout(timer);
|
|
96
|
+
burstStart ??= Date.now();
|
|
97
|
+
const wait = Math.max(0, Math.min(QUIET_MS, burstStart + MAX_WAIT_MS - Date.now()));
|
|
81
98
|
timer = setTimeout(() => {
|
|
99
|
+
burstStart = undefined;
|
|
82
100
|
running = running.then(rebuild).catch((e) => {
|
|
83
101
|
errors = e instanceof Error ? e.message : String(e);
|
|
84
102
|
broadcast("errors", errors);
|
|
85
103
|
});
|
|
86
|
-
},
|
|
104
|
+
}, wait);
|
|
87
105
|
};
|
|
88
106
|
await rebuild();
|
|
89
107
|
const index = (await readFile(join(viewerDir, "index.html"), "utf8")).replace("</body>", `${CLIENT}</body>`);
|