dsh-mermaid-plus 0.1.1 → 0.1.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/client.js +13 -11
- package/index.js +8 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({
|
|
2
2
|
id: 'dsh-mermaid-plus',
|
|
3
3
|
factory(require) {
|
|
4
|
+
/** Package name; also the boot-graph entry id and the source of every runtime name. */
|
|
5
|
+
const PKG = 'dsh-mermaid-plus';
|
|
6
|
+
/**
|
|
7
|
+
* Host route serving the vendored runtime, derived from the package name so two
|
|
8
|
+
* diagram plugins can be installed side by side. The Host half derives the same
|
|
9
|
+
* value from its own manifest; the two formulas must stay identical.
|
|
10
|
+
*/
|
|
11
|
+
const RUNTIME_PATH = `/x-${PKG.replace(/^@/, '').replace(/[^a-z0-9]+/gi, '-').toLowerCase()}`;
|
|
12
|
+
/** Bundled Mermaid release; part of the URL so a page reload refetches a new build. */
|
|
13
|
+
const RUNTIME_VERSION = '11.17.0';
|
|
14
|
+
|
|
4
15
|
/** Report one browser-half event to the Host's sink; a failure here is never fatal. */
|
|
5
16
|
function report(event, detail) {
|
|
6
17
|
try {
|
|
@@ -8,7 +19,8 @@ window.__ModuleLoader__.load({
|
|
|
8
19
|
method: 'POST',
|
|
9
20
|
headers: { 'content-type': 'application/json' },
|
|
10
21
|
body: JSON.stringify({ event, detail, href: String(window.location.href), at: Date.now() }),
|
|
11
|
-
keepalive
|
|
22
|
+
// No `keepalive`: on the desktop app's custom scheme the browser
|
|
23
|
+
// drops keepalive requests, and this report is best-effort anyway.
|
|
12
24
|
}).catch(() => undefined);
|
|
13
25
|
} catch {
|
|
14
26
|
/* the report is best effort only */
|
|
@@ -27,16 +39,6 @@ window.__ModuleLoader__.load({
|
|
|
27
39
|
const h = React.createElement;
|
|
28
40
|
|
|
29
41
|
//#region configuration
|
|
30
|
-
/** Package name; also the boot-graph entry id and the source of every runtime name. */
|
|
31
|
-
const PKG = 'dsh-mermaid-plus';
|
|
32
|
-
/**
|
|
33
|
-
* Host route serving the vendored runtime, derived from the package name so two
|
|
34
|
-
* diagram plugins can be installed side by side. The Host half derives the same
|
|
35
|
-
* value from its own manifest; the two formulas must stay identical.
|
|
36
|
-
*/
|
|
37
|
-
const RUNTIME_PATH = `/x-${PKG.replace(/^@/, '').replace(/[^a-z0-9]+/gi, '-').toLowerCase()}`;
|
|
38
|
-
/** Bundled Mermaid release; part of the URL so a page reload refetches a new build. */
|
|
39
|
-
const RUNTIME_VERSION = '11.17.0';
|
|
40
42
|
/**
|
|
41
43
|
* Preference key for the render mode. Namespaced by package name so a second
|
|
42
44
|
* diagram plugin cannot read or overwrite this one's choice.
|
package/index.js
CHANGED
|
@@ -110,6 +110,8 @@ export const inject = ['webServer'];
|
|
|
110
110
|
*/
|
|
111
111
|
const DIAG_DIR = join(tmpdir(), PKG_NAME.replace(/^@/, '').replace(/[^a-z0-9]+/gi, '-').toLowerCase());
|
|
112
112
|
const DIAG_FILE = join(DIAG_DIR, 'report.json');
|
|
113
|
+
/** The Host half's own activation dump, separate from the browser's event log. */
|
|
114
|
+
const ACTIVATION_FILE = join(DIAG_DIR, 'activation.json');
|
|
113
115
|
|
|
114
116
|
/** Cap the diagnostic log so a long session cannot grow the file without bound. */
|
|
115
117
|
const DIAG_LIMIT = 200;
|
|
@@ -193,6 +195,10 @@ async function receiveReport(request, response) {
|
|
|
193
195
|
*/
|
|
194
196
|
async function dumpDiagnostics(ctx) {
|
|
195
197
|
try {
|
|
198
|
+
// The client-module graph is composed after plugins mount, so an immediate
|
|
199
|
+
// read sees nothing. One short delay makes the dump answer the question it
|
|
200
|
+
// exists for: is this package's browser row in the graph?
|
|
201
|
+
await new Promise((resolve) => setTimeout(resolve, 2500).unref?.());
|
|
196
202
|
const clientModules = ctx.get('clientModules');
|
|
197
203
|
const graph = clientModules?.graph?.();
|
|
198
204
|
const table = clientModules?.table;
|
|
@@ -218,7 +224,8 @@ async function dumpDiagnostics(ctx) {
|
|
|
218
224
|
}
|
|
219
225
|
})(),
|
|
220
226
|
};
|
|
221
|
-
await
|
|
227
|
+
await mkdir(DIAG_DIR, { recursive: true });
|
|
228
|
+
await writeFile(ACTIVATION_FILE, `${JSON.stringify(payload, null, 2)}\n`);
|
|
222
229
|
} catch (error) {
|
|
223
230
|
ctx.logger?.warn?.(`dsh-mermaid: diagnostics failed: ${String(error)}`);
|
|
224
231
|
}
|
package/package.json
CHANGED