@narrative.io/jsonforms-provider-protocols 3.0.0-beta.19 → 3.0.0-beta.20

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.
@@ -1,308 +0,0 @@
1
- const RING_SIZE = 250;
2
- const PANEL_ID = "__pp_debug_panel__";
3
- const STYLE_ID = "__pp_debug_styles__";
4
- let entries = [];
5
- let panel = null;
6
- let listEl = null;
7
- function isEnabled() {
8
- if (typeof window === "undefined") return false;
9
- const w = window;
10
- if (w.__PP_DEBUG__ === true) return true;
11
- try {
12
- return window.localStorage?.getItem("PP_DEBUG") === "1";
13
- } catch {
14
- return false;
15
- }
16
- }
17
- function safeStringify(value) {
18
- const seen = /* @__PURE__ */ new WeakSet();
19
- try {
20
- const out = JSON.stringify(
21
- value,
22
- (_key, v) => {
23
- if (typeof v === "object" && v !== null) {
24
- if (seen.has(v)) return "[Circular]";
25
- seen.add(v);
26
- }
27
- if (typeof v === "function")
28
- return `[Function ${v.name || "anonymous"}]`;
29
- if (typeof v === "undefined") return "[undefined]";
30
- return v;
31
- },
32
- 2
33
- );
34
- return out ?? String(value);
35
- } catch (e) {
36
- return `[unstringifiable: ${e.message}]`;
37
- }
38
- }
39
- function ensureStyles() {
40
- if (document.getElementById(STYLE_ID)) return;
41
- const style = document.createElement("style");
42
- style.id = STYLE_ID;
43
- style.textContent = `
44
- #${PANEL_ID} {
45
- position: fixed;
46
- top: 12px;
47
- left: 12px;
48
- width: 460px;
49
- max-height: 70vh;
50
- z-index: 2147483647;
51
- background: #0b0f17;
52
- color: #d6e1ff;
53
- border: 1px solid #2a3656;
54
- border-radius: 6px;
55
- font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
56
- box-shadow: 0 8px 32px rgba(0,0,0,0.45);
57
- display: flex;
58
- flex-direction: column;
59
- resize: both;
60
- overflow: hidden;
61
- }
62
- #${PANEL_ID} .pp-header {
63
- display: flex;
64
- gap: 6px;
65
- align-items: center;
66
- padding: 6px 8px;
67
- background: #131a2c;
68
- border-bottom: 1px solid #2a3656;
69
- cursor: move;
70
- user-select: none;
71
- flex-shrink: 0;
72
- }
73
- #${PANEL_ID} .pp-title {
74
- flex: 1;
75
- font-weight: 600;
76
- color: #9fb4ff;
77
- }
78
- #${PANEL_ID} .pp-count {
79
- color: #6f7fa6;
80
- font-weight: 400;
81
- margin-left: 4px;
82
- }
83
- #${PANEL_ID} button {
84
- background: #1f2a47;
85
- color: #d6e1ff;
86
- border: 1px solid #2a3656;
87
- border-radius: 3px;
88
- padding: 2px 6px;
89
- cursor: pointer;
90
- font: inherit;
91
- line-height: 1.2;
92
- }
93
- #${PANEL_ID} button:hover { background: #2a3656; }
94
- #${PANEL_ID} .pp-list {
95
- flex: 1;
96
- overflow: auto;
97
- padding: 4px 6px;
98
- }
99
- #${PANEL_ID}.pp-collapsed { resize: none; max-height: none; }
100
- #${PANEL_ID}.pp-collapsed .pp-list { display: none; }
101
- #${PANEL_ID} details {
102
- margin: 4px 0;
103
- border: 1px solid #2a3656;
104
- border-radius: 3px;
105
- background: #0f1422;
106
- }
107
- #${PANEL_ID} summary {
108
- padding: 4px 6px;
109
- cursor: pointer;
110
- display: flex;
111
- gap: 6px;
112
- align-items: center;
113
- list-style: none;
114
- }
115
- #${PANEL_ID} summary::-webkit-details-marker { display: none; }
116
- #${PANEL_ID} summary::before {
117
- content: "▸";
118
- color: #6f7fa6;
119
- width: 10px;
120
- }
121
- #${PANEL_ID} details[open] > summary::before { content: "▾"; }
122
- #${PANEL_ID} .pp-label {
123
- color: #ffd479;
124
- font-weight: 600;
125
- }
126
- #${PANEL_ID} .pp-ts {
127
- color: #6f7fa6;
128
- }
129
- #${PANEL_ID} summary button { margin-left: auto; }
130
- #${PANEL_ID} pre {
131
- margin: 0;
132
- padding: 6px 8px;
133
- max-height: 320px;
134
- overflow: auto;
135
- background: #050811;
136
- color: #c9d6ff;
137
- white-space: pre-wrap;
138
- word-break: break-word;
139
- }
140
- `;
141
- document.head.appendChild(style);
142
- }
143
- function makeButton(label, onClick) {
144
- const btn = document.createElement("button");
145
- btn.type = "button";
146
- btn.textContent = label;
147
- btn.addEventListener("click", onClick);
148
- return btn;
149
- }
150
- function flashButton(btn, msg, original) {
151
- btn.textContent = msg;
152
- setTimeout(() => {
153
- btn.textContent = original;
154
- }, 1200);
155
- }
156
- function copyToClipboard(text, btn, original) {
157
- const fallback = () => {
158
- try {
159
- const ta = document.createElement("textarea");
160
- ta.value = text;
161
- ta.style.position = "fixed";
162
- ta.style.left = "-9999px";
163
- document.body.appendChild(ta);
164
- ta.select();
165
- document.execCommand("copy");
166
- document.body.removeChild(ta);
167
- flashButton(btn, "copied", original);
168
- } catch {
169
- flashButton(btn, "fail", original);
170
- }
171
- };
172
- if (navigator.clipboard?.writeText) {
173
- navigator.clipboard.writeText(text).then(
174
- () => flashButton(btn, "copied", original),
175
- fallback
176
- );
177
- } else {
178
- fallback();
179
- }
180
- }
181
- function updateCount() {
182
- if (!panel) return;
183
- const countEl = panel.querySelector(".pp-count");
184
- if (countEl) countEl.textContent = `(${entries.length})`;
185
- }
186
- function attachDrag(panelEl, header) {
187
- let dragging = false;
188
- let offX = 0;
189
- let offY = 0;
190
- header.addEventListener("mousedown", (e) => {
191
- if (e.target.tagName === "BUTTON") return;
192
- dragging = true;
193
- const rect = panelEl.getBoundingClientRect();
194
- offX = e.clientX - rect.left;
195
- offY = e.clientY - rect.top;
196
- e.preventDefault();
197
- });
198
- window.addEventListener("mousemove", (e) => {
199
- if (!dragging) return;
200
- panelEl.style.left = `${e.clientX - offX}px`;
201
- panelEl.style.top = `${e.clientY - offY}px`;
202
- });
203
- window.addEventListener("mouseup", () => {
204
- dragging = false;
205
- });
206
- }
207
- function ensurePanel() {
208
- if (panel && document.body.contains(panel)) return panel;
209
- ensureStyles();
210
- panel = document.createElement("div");
211
- panel.id = PANEL_ID;
212
- const header = document.createElement("div");
213
- header.className = "pp-header";
214
- const title = document.createElement("span");
215
- title.className = "pp-title";
216
- title.textContent = "[provider-protocols] debug";
217
- const count = document.createElement("span");
218
- count.className = "pp-count";
219
- count.textContent = `(${entries.length})`;
220
- title.appendChild(count);
221
- header.appendChild(title);
222
- const copyAllBtn = makeButton("copy all", (e) => {
223
- e.stopPropagation();
224
- const blob = entries.map((en) => `// ${new Date(en.ts).toISOString()} ${en.label}
225
- ${en.json}`).join("\n\n");
226
- copyToClipboard(blob, copyAllBtn, "copy all");
227
- });
228
- header.appendChild(copyAllBtn);
229
- const clearBtn = makeButton("clear", (e) => {
230
- e.stopPropagation();
231
- entries = [];
232
- if (listEl) listEl.innerHTML = "";
233
- updateCount();
234
- });
235
- header.appendChild(clearBtn);
236
- const collapseBtn = makeButton("−", (e) => {
237
- e.stopPropagation();
238
- panel.classList.toggle("pp-collapsed");
239
- collapseBtn.textContent = panel.classList.contains("pp-collapsed") ? "+" : "−";
240
- });
241
- header.appendChild(collapseBtn);
242
- attachDrag(panel, header);
243
- panel.appendChild(header);
244
- listEl = document.createElement("div");
245
- listEl.className = "pp-list";
246
- panel.appendChild(listEl);
247
- document.body.appendChild(panel);
248
- return panel;
249
- }
250
- function renderEntry(entry) {
251
- if (!listEl) return;
252
- const det = document.createElement("details");
253
- det.open = false;
254
- const sum = document.createElement("summary");
255
- const lbl = document.createElement("span");
256
- lbl.className = "pp-label";
257
- lbl.textContent = entry.label;
258
- const ts = document.createElement("span");
259
- ts.className = "pp-ts";
260
- ts.textContent = new Date(entry.ts).toISOString().slice(11, 23);
261
- const copyBtn = makeButton("copy", (e) => {
262
- e.preventDefault();
263
- e.stopPropagation();
264
- copyToClipboard(entry.json, copyBtn, "copy");
265
- });
266
- sum.appendChild(lbl);
267
- sum.appendChild(ts);
268
- sum.appendChild(copyBtn);
269
- det.appendChild(sum);
270
- const pre = document.createElement("pre");
271
- pre.textContent = entry.json;
272
- det.appendChild(pre);
273
- listEl.appendChild(det);
274
- listEl.scrollTop = listEl.scrollHeight;
275
- while (listEl.children.length > RING_SIZE) {
276
- const first = listEl.firstChild;
277
- if (first) listEl.removeChild(first);
278
- else break;
279
- }
280
- }
281
- function debugLog(label, payload) {
282
- if (!isEnabled()) return;
283
- if (typeof document === "undefined") return;
284
- const entry = {
285
- ts: Date.now(),
286
- label,
287
- json: safeStringify(payload)
288
- };
289
- entries.push(entry);
290
- if (entries.length > RING_SIZE) entries.shift();
291
- const append = () => {
292
- try {
293
- ensurePanel();
294
- renderEntry(entry);
295
- updateCount();
296
- } catch {
297
- }
298
- };
299
- if (document.body) {
300
- append();
301
- } else {
302
- document.addEventListener("DOMContentLoaded", append, { once: true });
303
- }
304
- }
305
- export {
306
- debugLog
307
- };
308
- //# sourceMappingURL=overlay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay.js","sources":["../../src/debug/overlay.ts"],"sourcesContent":["/**\n * In-DOM debug overlay for `@narrative.io/jsonforms-provider-protocols`.\n *\n * Renders a fixed-position panel with a scrollable list of structured log\n * entries. Used in place of `console.*` because some host apps strip console\n * output in production. No-op unless explicitly enabled at runtime via\n * either `window.__PP_DEBUG__ = true` or `localStorage.PP_DEBUG = \"1\"`.\n *\n * Internal API. Not part of the package's public surface.\n */\n\nconst RING_SIZE = 250;\nconst PANEL_ID = \"__pp_debug_panel__\";\nconst STYLE_ID = \"__pp_debug_styles__\";\n\ninterface Entry {\n ts: number;\n label: string;\n json: string;\n}\n\nlet entries: Entry[] = [];\nlet panel: HTMLElement | null = null;\nlet listEl: HTMLElement | null = null;\n\nfunction isEnabled(): boolean {\n if (typeof window === \"undefined\") return false;\n const w = window as unknown as { __PP_DEBUG__?: boolean };\n if (w.__PP_DEBUG__ === true) return true;\n try {\n return window.localStorage?.getItem(\"PP_DEBUG\") === \"1\";\n } catch {\n return false;\n }\n}\n\nfunction safeStringify(value: unknown): string {\n const seen = new WeakSet<object>();\n try {\n const out = JSON.stringify(\n value,\n (_key, v) => {\n if (typeof v === \"object\" && v !== null) {\n if (seen.has(v as object)) return \"[Circular]\";\n seen.add(v as object);\n }\n if (typeof v === \"function\")\n return `[Function ${(v as { name?: string }).name || \"anonymous\"}]`;\n if (typeof v === \"undefined\") return \"[undefined]\";\n return v;\n },\n 2,\n );\n return out ?? String(value);\n } catch (e) {\n return `[unstringifiable: ${(e as Error).message}]`;\n }\n}\n\nfunction ensureStyles(): void {\n if (document.getElementById(STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = STYLE_ID;\n style.textContent = `\n#${PANEL_ID} {\n position: fixed;\n top: 12px;\n left: 12px;\n width: 460px;\n max-height: 70vh;\n z-index: 2147483647;\n background: #0b0f17;\n color: #d6e1ff;\n border: 1px solid #2a3656;\n border-radius: 6px;\n font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;\n box-shadow: 0 8px 32px rgba(0,0,0,0.45);\n display: flex;\n flex-direction: column;\n resize: both;\n overflow: hidden;\n}\n#${PANEL_ID} .pp-header {\n display: flex;\n gap: 6px;\n align-items: center;\n padding: 6px 8px;\n background: #131a2c;\n border-bottom: 1px solid #2a3656;\n cursor: move;\n user-select: none;\n flex-shrink: 0;\n}\n#${PANEL_ID} .pp-title {\n flex: 1;\n font-weight: 600;\n color: #9fb4ff;\n}\n#${PANEL_ID} .pp-count {\n color: #6f7fa6;\n font-weight: 400;\n margin-left: 4px;\n}\n#${PANEL_ID} button {\n background: #1f2a47;\n color: #d6e1ff;\n border: 1px solid #2a3656;\n border-radius: 3px;\n padding: 2px 6px;\n cursor: pointer;\n font: inherit;\n line-height: 1.2;\n}\n#${PANEL_ID} button:hover { background: #2a3656; }\n#${PANEL_ID} .pp-list {\n flex: 1;\n overflow: auto;\n padding: 4px 6px;\n}\n#${PANEL_ID}.pp-collapsed { resize: none; max-height: none; }\n#${PANEL_ID}.pp-collapsed .pp-list { display: none; }\n#${PANEL_ID} details {\n margin: 4px 0;\n border: 1px solid #2a3656;\n border-radius: 3px;\n background: #0f1422;\n}\n#${PANEL_ID} summary {\n padding: 4px 6px;\n cursor: pointer;\n display: flex;\n gap: 6px;\n align-items: center;\n list-style: none;\n}\n#${PANEL_ID} summary::-webkit-details-marker { display: none; }\n#${PANEL_ID} summary::before {\n content: \"▸\";\n color: #6f7fa6;\n width: 10px;\n}\n#${PANEL_ID} details[open] > summary::before { content: \"▾\"; }\n#${PANEL_ID} .pp-label {\n color: #ffd479;\n font-weight: 600;\n}\n#${PANEL_ID} .pp-ts {\n color: #6f7fa6;\n}\n#${PANEL_ID} summary button { margin-left: auto; }\n#${PANEL_ID} pre {\n margin: 0;\n padding: 6px 8px;\n max-height: 320px;\n overflow: auto;\n background: #050811;\n color: #c9d6ff;\n white-space: pre-wrap;\n word-break: break-word;\n}\n`;\n document.head.appendChild(style);\n}\n\nfunction makeButton(label: string, onClick: (e: MouseEvent) => void): HTMLButtonElement {\n const btn = document.createElement(\"button\");\n btn.type = \"button\";\n btn.textContent = label;\n btn.addEventListener(\"click\", onClick);\n return btn;\n}\n\nfunction flashButton(btn: HTMLButtonElement, msg: string, original: string): void {\n btn.textContent = msg;\n setTimeout(() => {\n btn.textContent = original;\n }, 1200);\n}\n\nfunction copyToClipboard(text: string, btn: HTMLButtonElement, original: string): void {\n const fallback = () => {\n try {\n const ta = document.createElement(\"textarea\");\n ta.value = text;\n ta.style.position = \"fixed\";\n ta.style.left = \"-9999px\";\n document.body.appendChild(ta);\n ta.select();\n document.execCommand(\"copy\");\n document.body.removeChild(ta);\n flashButton(btn, \"copied\", original);\n } catch {\n flashButton(btn, \"fail\", original);\n }\n };\n if (navigator.clipboard?.writeText) {\n navigator.clipboard.writeText(text).then(\n () => flashButton(btn, \"copied\", original),\n fallback,\n );\n } else {\n fallback();\n }\n}\n\nfunction updateCount(): void {\n if (!panel) return;\n const countEl = panel.querySelector(\".pp-count\");\n if (countEl) countEl.textContent = `(${entries.length})`;\n}\n\nfunction attachDrag(panelEl: HTMLElement, header: HTMLElement): void {\n let dragging = false;\n let offX = 0;\n let offY = 0;\n header.addEventListener(\"mousedown\", (e) => {\n if ((e.target as HTMLElement).tagName === \"BUTTON\") return;\n dragging = true;\n const rect = panelEl.getBoundingClientRect();\n offX = e.clientX - rect.left;\n offY = e.clientY - rect.top;\n e.preventDefault();\n });\n window.addEventListener(\"mousemove\", (e) => {\n if (!dragging) return;\n panelEl.style.left = `${e.clientX - offX}px`;\n panelEl.style.top = `${e.clientY - offY}px`;\n });\n window.addEventListener(\"mouseup\", () => {\n dragging = false;\n });\n}\n\nfunction ensurePanel(): HTMLElement {\n if (panel && document.body.contains(panel)) return panel;\n ensureStyles();\n\n panel = document.createElement(\"div\");\n panel.id = PANEL_ID;\n\n const header = document.createElement(\"div\");\n header.className = \"pp-header\";\n\n const title = document.createElement(\"span\");\n title.className = \"pp-title\";\n title.textContent = \"[provider-protocols] debug\";\n const count = document.createElement(\"span\");\n count.className = \"pp-count\";\n count.textContent = `(${entries.length})`;\n title.appendChild(count);\n header.appendChild(title);\n\n const copyAllBtn = makeButton(\"copy all\", (e) => {\n e.stopPropagation();\n const blob = entries\n .map((en) => `// ${new Date(en.ts).toISOString()} ${en.label}\\n${en.json}`)\n .join(\"\\n\\n\");\n copyToClipboard(blob, copyAllBtn, \"copy all\");\n });\n header.appendChild(copyAllBtn);\n\n const clearBtn = makeButton(\"clear\", (e) => {\n e.stopPropagation();\n entries = [];\n if (listEl) listEl.innerHTML = \"\";\n updateCount();\n });\n header.appendChild(clearBtn);\n\n const collapseBtn = makeButton(\"−\", (e) => {\n e.stopPropagation();\n panel!.classList.toggle(\"pp-collapsed\");\n collapseBtn.textContent = panel!.classList.contains(\"pp-collapsed\") ? \"+\" : \"−\";\n });\n header.appendChild(collapseBtn);\n\n attachDrag(panel, header);\n panel.appendChild(header);\n\n listEl = document.createElement(\"div\");\n listEl.className = \"pp-list\";\n panel.appendChild(listEl);\n\n document.body.appendChild(panel);\n return panel;\n}\n\nfunction renderEntry(entry: Entry): void {\n if (!listEl) return;\n const det = document.createElement(\"details\");\n det.open = false;\n\n const sum = document.createElement(\"summary\");\n const lbl = document.createElement(\"span\");\n lbl.className = \"pp-label\";\n lbl.textContent = entry.label;\n const ts = document.createElement(\"span\");\n ts.className = \"pp-ts\";\n ts.textContent = new Date(entry.ts).toISOString().slice(11, 23);\n const copyBtn = makeButton(\"copy\", (e) => {\n e.preventDefault();\n e.stopPropagation();\n copyToClipboard(entry.json, copyBtn, \"copy\");\n });\n sum.appendChild(lbl);\n sum.appendChild(ts);\n sum.appendChild(copyBtn);\n det.appendChild(sum);\n\n const pre = document.createElement(\"pre\");\n pre.textContent = entry.json;\n det.appendChild(pre);\n\n listEl.appendChild(det);\n listEl.scrollTop = listEl.scrollHeight;\n\n while (listEl.children.length > RING_SIZE) {\n const first = listEl.firstChild;\n if (first) listEl.removeChild(first);\n else break;\n }\n}\n\n/**\n * Append a structured debug entry to the in-DOM overlay. No-op unless the\n * runtime gate is on (`window.__PP_DEBUG__ === true` or\n * `localStorage.PP_DEBUG === \"1\"`). Stringification is lazy: the payload is\n * not serialized when the gate is off, so this is safe to leave in hot paths.\n */\nexport function debugLog(label: string, payload: unknown): void {\n if (!isEnabled()) return;\n if (typeof document === \"undefined\") return;\n\n const entry: Entry = {\n ts: Date.now(),\n label,\n json: safeStringify(payload),\n };\n\n entries.push(entry);\n if (entries.length > RING_SIZE) entries.shift();\n\n const append = () => {\n try {\n ensurePanel();\n renderEntry(entry);\n updateCount();\n } catch {\n // never break the host on debug failure\n }\n };\n\n if (document.body) {\n append();\n } else {\n document.addEventListener(\"DOMContentLoaded\", append, { once: true });\n }\n}\n"],"names":[],"mappings":"AAWA,MAAM,YAAY;AAClB,MAAM,WAAW;AACjB,MAAM,WAAW;AAQjB,IAAI,UAAmB,CAAA;AACvB,IAAI,QAA4B;AAChC,IAAI,SAA6B;AAEjC,SAAS,YAAqB;AAC5B,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,IAAI;AACV,MAAI,EAAE,iBAAiB,KAAM,QAAO;AACpC,MAAI;AACF,WAAO,OAAO,cAAc,QAAQ,UAAU,MAAM;AAAA,EACtD,QAAQ;AACN,WA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SAAO,YAAY,OAAO;AAE1B,SAAO,OAAO,SAAS,SAAS,WAAW;AACzC,UAAM,QAAQ,OAAO;AACrB,QAAI,MAAO,QAAO,YAAY,KAAK;AAAA,QAC9B;AAAA,EACP;AACF;AAQO,SAAS,SAAS,OAAe,SAAwB;AAC9D,MAAI,CAAC,YAAa;AAClB,MAAI,OAAO,aAAa,YAAa;AAErC,QAAM,QAAe;AAAA,IACnB,IAAI,KAAK,IAAA;AAAA,IACT;AAAA,IACA,MAAM,cAAc,OAAO;AAAA,EAAA;AAG7B,UAAQ,KAAK,KAAK;AAClB,MAAI,QAAQ,SAAS,UAAW,SAAQ,MAAA;AAExC,QAAM,SAAS,MAAM;AACnB,QAAI;AACF,kBAAA;AACA,kBAAY,KAAK;AACjB,kBAAA;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,MAAI,SAAS,MAAM;AACjB,WAAA;AAAA,EACF,OAAO;AACL,aAAS,iBAAiB,oBAAoB,QAAQ,EAAE,MAAM,MAAM;AAAA,EACtE;AACF;"}
@@ -1,358 +0,0 @@
1
- /**
2
- * In-DOM debug overlay for `@narrative.io/jsonforms-provider-protocols`.
3
- *
4
- * Renders a fixed-position panel with a scrollable list of structured log
5
- * entries. Used in place of `console.*` because some host apps strip console
6
- * output in production. No-op unless explicitly enabled at runtime via
7
- * either `window.__PP_DEBUG__ = true` or `localStorage.PP_DEBUG = "1"`.
8
- *
9
- * Internal API. Not part of the package's public surface.
10
- */
11
-
12
- const RING_SIZE = 250;
13
- const PANEL_ID = "__pp_debug_panel__";
14
- const STYLE_ID = "__pp_debug_styles__";
15
-
16
- interface Entry {
17
- ts: number;
18
- label: string;
19
- json: string;
20
- }
21
-
22
- let entries: Entry[] = [];
23
- let panel: HTMLElement | null = null;
24
- let listEl: HTMLElement | null = null;
25
-
26
- function isEnabled(): boolean {
27
- if (typeof window === "undefined") return false;
28
- const w = window as unknown as { __PP_DEBUG__?: boolean };
29
- if (w.__PP_DEBUG__ === true) return true;
30
- try {
31
- return window.localStorage?.getItem("PP_DEBUG") === "1";
32
- } catch {
33
- return false;
34
- }
35
- }
36
-
37
- function safeStringify(value: unknown): string {
38
- const seen = new WeakSet<object>();
39
- try {
40
- const out = JSON.stringify(
41
- value,
42
- (_key, v) => {
43
- if (typeof v === "object" && v !== null) {
44
- if (seen.has(v as object)) return "[Circular]";
45
- seen.add(v as object);
46
- }
47
- if (typeof v === "function")
48
- return `[Function ${(v as { name?: string }).name || "anonymous"}]`;
49
- if (typeof v === "undefined") return "[undefined]";
50
- return v;
51
- },
52
- 2,
53
- );
54
- return out ?? String(value);
55
- } catch (e) {
56
- return `[unstringifiable: ${(e as Error).message}]`;
57
- }
58
- }
59
-
60
- function ensureStyles(): void {
61
- if (document.getElementById(STYLE_ID)) return;
62
- const style = document.createElement("style");
63
- style.id = STYLE_ID;
64
- style.textContent = `
65
- #${PANEL_ID} {
66
- position: fixed;
67
- top: 12px;
68
- left: 12px;
69
- width: 460px;
70
- max-height: 70vh;
71
- z-index: 2147483647;
72
- background: #0b0f17;
73
- color: #d6e1ff;
74
- border: 1px solid #2a3656;
75
- border-radius: 6px;
76
- font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
77
- box-shadow: 0 8px 32px rgba(0,0,0,0.45);
78
- display: flex;
79
- flex-direction: column;
80
- resize: both;
81
- overflow: hidden;
82
- }
83
- #${PANEL_ID} .pp-header {
84
- display: flex;
85
- gap: 6px;
86
- align-items: center;
87
- padding: 6px 8px;
88
- background: #131a2c;
89
- border-bottom: 1px solid #2a3656;
90
- cursor: move;
91
- user-select: none;
92
- flex-shrink: 0;
93
- }
94
- #${PANEL_ID} .pp-title {
95
- flex: 1;
96
- font-weight: 600;
97
- color: #9fb4ff;
98
- }
99
- #${PANEL_ID} .pp-count {
100
- color: #6f7fa6;
101
- font-weight: 400;
102
- margin-left: 4px;
103
- }
104
- #${PANEL_ID} button {
105
- background: #1f2a47;
106
- color: #d6e1ff;
107
- border: 1px solid #2a3656;
108
- border-radius: 3px;
109
- padding: 2px 6px;
110
- cursor: pointer;
111
- font: inherit;
112
- line-height: 1.2;
113
- }
114
- #${PANEL_ID} button:hover { background: #2a3656; }
115
- #${PANEL_ID} .pp-list {
116
- flex: 1;
117
- overflow: auto;
118
- padding: 4px 6px;
119
- }
120
- #${PANEL_ID}.pp-collapsed { resize: none; max-height: none; }
121
- #${PANEL_ID}.pp-collapsed .pp-list { display: none; }
122
- #${PANEL_ID} details {
123
- margin: 4px 0;
124
- border: 1px solid #2a3656;
125
- border-radius: 3px;
126
- background: #0f1422;
127
- }
128
- #${PANEL_ID} summary {
129
- padding: 4px 6px;
130
- cursor: pointer;
131
- display: flex;
132
- gap: 6px;
133
- align-items: center;
134
- list-style: none;
135
- }
136
- #${PANEL_ID} summary::-webkit-details-marker { display: none; }
137
- #${PANEL_ID} summary::before {
138
- content: "▸";
139
- color: #6f7fa6;
140
- width: 10px;
141
- }
142
- #${PANEL_ID} details[open] > summary::before { content: "▾"; }
143
- #${PANEL_ID} .pp-label {
144
- color: #ffd479;
145
- font-weight: 600;
146
- }
147
- #${PANEL_ID} .pp-ts {
148
- color: #6f7fa6;
149
- }
150
- #${PANEL_ID} summary button { margin-left: auto; }
151
- #${PANEL_ID} pre {
152
- margin: 0;
153
- padding: 6px 8px;
154
- max-height: 320px;
155
- overflow: auto;
156
- background: #050811;
157
- color: #c9d6ff;
158
- white-space: pre-wrap;
159
- word-break: break-word;
160
- }
161
- `;
162
- document.head.appendChild(style);
163
- }
164
-
165
- function makeButton(label: string, onClick: (e: MouseEvent) => void): HTMLButtonElement {
166
- const btn = document.createElement("button");
167
- btn.type = "button";
168
- btn.textContent = label;
169
- btn.addEventListener("click", onClick);
170
- return btn;
171
- }
172
-
173
- function flashButton(btn: HTMLButtonElement, msg: string, original: string): void {
174
- btn.textContent = msg;
175
- setTimeout(() => {
176
- btn.textContent = original;
177
- }, 1200);
178
- }
179
-
180
- function copyToClipboard(text: string, btn: HTMLButtonElement, original: string): void {
181
- const fallback = () => {
182
- try {
183
- const ta = document.createElement("textarea");
184
- ta.value = text;
185
- ta.style.position = "fixed";
186
- ta.style.left = "-9999px";
187
- document.body.appendChild(ta);
188
- ta.select();
189
- document.execCommand("copy");
190
- document.body.removeChild(ta);
191
- flashButton(btn, "copied", original);
192
- } catch {
193
- flashButton(btn, "fail", original);
194
- }
195
- };
196
- if (navigator.clipboard?.writeText) {
197
- navigator.clipboard.writeText(text).then(
198
- () => flashButton(btn, "copied", original),
199
- fallback,
200
- );
201
- } else {
202
- fallback();
203
- }
204
- }
205
-
206
- function updateCount(): void {
207
- if (!panel) return;
208
- const countEl = panel.querySelector(".pp-count");
209
- if (countEl) countEl.textContent = `(${entries.length})`;
210
- }
211
-
212
- function attachDrag(panelEl: HTMLElement, header: HTMLElement): void {
213
- let dragging = false;
214
- let offX = 0;
215
- let offY = 0;
216
- header.addEventListener("mousedown", (e) => {
217
- if ((e.target as HTMLElement).tagName === "BUTTON") return;
218
- dragging = true;
219
- const rect = panelEl.getBoundingClientRect();
220
- offX = e.clientX - rect.left;
221
- offY = e.clientY - rect.top;
222
- e.preventDefault();
223
- });
224
- window.addEventListener("mousemove", (e) => {
225
- if (!dragging) return;
226
- panelEl.style.left = `${e.clientX - offX}px`;
227
- panelEl.style.top = `${e.clientY - offY}px`;
228
- });
229
- window.addEventListener("mouseup", () => {
230
- dragging = false;
231
- });
232
- }
233
-
234
- function ensurePanel(): HTMLElement {
235
- if (panel && document.body.contains(panel)) return panel;
236
- ensureStyles();
237
-
238
- panel = document.createElement("div");
239
- panel.id = PANEL_ID;
240
-
241
- const header = document.createElement("div");
242
- header.className = "pp-header";
243
-
244
- const title = document.createElement("span");
245
- title.className = "pp-title";
246
- title.textContent = "[provider-protocols] debug";
247
- const count = document.createElement("span");
248
- count.className = "pp-count";
249
- count.textContent = `(${entries.length})`;
250
- title.appendChild(count);
251
- header.appendChild(title);
252
-
253
- const copyAllBtn = makeButton("copy all", (e) => {
254
- e.stopPropagation();
255
- const blob = entries
256
- .map((en) => `// ${new Date(en.ts).toISOString()} ${en.label}\n${en.json}`)
257
- .join("\n\n");
258
- copyToClipboard(blob, copyAllBtn, "copy all");
259
- });
260
- header.appendChild(copyAllBtn);
261
-
262
- const clearBtn = makeButton("clear", (e) => {
263
- e.stopPropagation();
264
- entries = [];
265
- if (listEl) listEl.innerHTML = "";
266
- updateCount();
267
- });
268
- header.appendChild(clearBtn);
269
-
270
- const collapseBtn = makeButton("−", (e) => {
271
- e.stopPropagation();
272
- panel!.classList.toggle("pp-collapsed");
273
- collapseBtn.textContent = panel!.classList.contains("pp-collapsed") ? "+" : "−";
274
- });
275
- header.appendChild(collapseBtn);
276
-
277
- attachDrag(panel, header);
278
- panel.appendChild(header);
279
-
280
- listEl = document.createElement("div");
281
- listEl.className = "pp-list";
282
- panel.appendChild(listEl);
283
-
284
- document.body.appendChild(panel);
285
- return panel;
286
- }
287
-
288
- function renderEntry(entry: Entry): void {
289
- if (!listEl) return;
290
- const det = document.createElement("details");
291
- det.open = false;
292
-
293
- const sum = document.createElement("summary");
294
- const lbl = document.createElement("span");
295
- lbl.className = "pp-label";
296
- lbl.textContent = entry.label;
297
- const ts = document.createElement("span");
298
- ts.className = "pp-ts";
299
- ts.textContent = new Date(entry.ts).toISOString().slice(11, 23);
300
- const copyBtn = makeButton("copy", (e) => {
301
- e.preventDefault();
302
- e.stopPropagation();
303
- copyToClipboard(entry.json, copyBtn, "copy");
304
- });
305
- sum.appendChild(lbl);
306
- sum.appendChild(ts);
307
- sum.appendChild(copyBtn);
308
- det.appendChild(sum);
309
-
310
- const pre = document.createElement("pre");
311
- pre.textContent = entry.json;
312
- det.appendChild(pre);
313
-
314
- listEl.appendChild(det);
315
- listEl.scrollTop = listEl.scrollHeight;
316
-
317
- while (listEl.children.length > RING_SIZE) {
318
- const first = listEl.firstChild;
319
- if (first) listEl.removeChild(first);
320
- else break;
321
- }
322
- }
323
-
324
- /**
325
- * Append a structured debug entry to the in-DOM overlay. No-op unless the
326
- * runtime gate is on (`window.__PP_DEBUG__ === true` or
327
- * `localStorage.PP_DEBUG === "1"`). Stringification is lazy: the payload is
328
- * not serialized when the gate is off, so this is safe to leave in hot paths.
329
- */
330
- export function debugLog(label: string, payload: unknown): void {
331
- if (!isEnabled()) return;
332
- if (typeof document === "undefined") return;
333
-
334
- const entry: Entry = {
335
- ts: Date.now(),
336
- label,
337
- json: safeStringify(payload),
338
- };
339
-
340
- entries.push(entry);
341
- if (entries.length > RING_SIZE) entries.shift();
342
-
343
- const append = () => {
344
- try {
345
- ensurePanel();
346
- renderEntry(entry);
347
- updateCount();
348
- } catch {
349
- // never break the host on debug failure
350
- }
351
- };
352
-
353
- if (document.body) {
354
- append();
355
- } else {
356
- document.addEventListener("DOMContentLoaded", append, { once: true });
357
- }
358
- }