dev-inspector 1.1.0 → 1.1.1

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.
Files changed (37) hide show
  1. package/package.json +3 -2
  2. package/lib/integrations/index.d.ts +0 -2
  3. package/lib/integrations/index.js +0 -7
  4. package/lib/integrations/jira/adf.d.ts +0 -11
  5. package/lib/integrations/jira/adf.js +0 -17
  6. package/lib/integrations/jira/client.d.ts +0 -4
  7. package/lib/integrations/jira/client.js +0 -113
  8. package/lib/integrations/jira/errors.d.ts +0 -10
  9. package/lib/integrations/jira/errors.js +0 -13
  10. package/lib/integrations/jira/index.d.ts +0 -2
  11. package/lib/integrations/jira/index.js +0 -8
  12. package/lib/integrations/types.d.ts +0 -54
  13. package/lib/integrations/types.js +0 -2
  14. package/lib/storage/localStorage.d.ts +0 -30
  15. package/lib/storage/localStorage.js +0 -166
  16. package/lib/ui/logList.d.ts +0 -7
  17. package/lib/ui/logList.js +0 -117
  18. package/lib/ui/panel/integrations/icons.d.ts +0 -1
  19. package/lib/ui/panel/integrations/icons.js +0 -7
  20. package/lib/ui/panel/integrations/index.d.ts +0 -1
  21. package/lib/ui/panel/integrations/index.js +0 -5
  22. package/lib/ui/panel/integrations/jiraDialog.d.ts +0 -6
  23. package/lib/ui/panel/integrations/jiraDialog.js +0 -234
  24. package/lib/ui/panel/integrations/screenshot.d.ts +0 -4
  25. package/lib/ui/panel/integrations/screenshot.js +0 -51
  26. package/lib/ui/panel/localStorage/createLocalStorageView.d.ts +0 -4
  27. package/lib/ui/panel/localStorage/createLocalStorageView.js +0 -108
  28. package/lib/ui/panel/localStorage/index.d.ts +0 -3
  29. package/lib/ui/panel/localStorage/index.js +0 -7
  30. package/lib/ui/panel/localStorage/setupLocalStorageSync.d.ts +0 -9
  31. package/lib/ui/panel/localStorage/setupLocalStorageSync.js +0 -30
  32. package/lib/ui/panel/localStorage/types.d.ts +0 -6
  33. package/lib/ui/panel/localStorage/types.js +0 -2
  34. package/lib/ui/panel.d.ts +0 -15
  35. package/lib/ui/panel.js +0 -375
  36. package/lib/ui/shared/copy.d.ts +0 -2
  37. package/lib/ui/shared/copy.js +0 -101
@@ -1,234 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openJiraDialog = openJiraDialog;
4
- const integrations_1 = require("../../../integrations");
5
- const screenshot_1 = require("./screenshot");
6
- function nowIso() {
7
- try {
8
- return new Date().toISOString();
9
- }
10
- catch (_a) {
11
- return "";
12
- }
13
- }
14
- function getContext(integrations) {
15
- var _a, _b, _c;
16
- const nav = globalThis;
17
- const loc = globalThis;
18
- return {
19
- url: typeof ((_a = loc.location) === null || _a === void 0 ? void 0 : _a.href) === "string" ? loc.location.href : undefined,
20
- userAgent: typeof ((_b = nav.navigator) === null || _b === void 0 ? void 0 : _b.userAgent) === "string" ? nav.navigator.userAgent : undefined,
21
- timestamp: nowIso(),
22
- user: (_c = integrations === null || integrations === void 0 ? void 0 : integrations.jira) === null || _c === void 0 ? void 0 : _c.user,
23
- };
24
- }
25
- function setText(el, text) {
26
- el.textContent = text;
27
- }
28
- function createField(doc, label, input) {
29
- const wrap = doc.createElement("div");
30
- wrap.className = "di-field";
31
- const l = doc.createElement("div");
32
- l.className = "di-fieldLabel";
33
- l.textContent = label;
34
- wrap.append(l, input);
35
- return wrap;
36
- }
37
- function friendlyError(e) {
38
- if (e instanceof integrations_1.JiraIntegrationError)
39
- return e.message;
40
- if (e instanceof Error)
41
- return e.message;
42
- return "Something went wrong.";
43
- }
44
- function openJiraDialog(doc, integrations) {
45
- return new Promise((resolve) => {
46
- var _a, _b, _c, _d, _e;
47
- const cfg = integrations === null || integrations === void 0 ? void 0 : integrations.jira;
48
- const hasJira = Boolean(cfg);
49
- const backdrop = doc.createElement("div");
50
- backdrop.className = "di-modalBackdrop";
51
- const modal = doc.createElement("div");
52
- modal.className = "di-modal";
53
- const head = doc.createElement("div");
54
- head.className = "di-modalHead";
55
- const title = doc.createElement("div");
56
- title.className = "di-modalTitle";
57
- title.textContent = "Create Jira issue";
58
- const close = doc.createElement("button");
59
- close.type = "button";
60
- close.className = "di-modalClose";
61
- close.textContent = "Close";
62
- head.append(title, close);
63
- const body = doc.createElement("div");
64
- body.className = "di-modalBody";
65
- const error = doc.createElement("div");
66
- error.className = "di-modalError di-hidden";
67
- const summary = doc.createElement("input");
68
- summary.className = "di-input";
69
- summary.placeholder = "Summary (required)";
70
- summary.setAttribute("aria-label", "Summary");
71
- const desc = doc.createElement("textarea");
72
- desc.className = "di-textarea";
73
- desc.placeholder = "Description (optional)";
74
- desc.setAttribute("aria-label", "Description");
75
- const projectKey = doc.createElement("input");
76
- projectKey.className = "di-input";
77
- projectKey.placeholder = "Project key (e.g. DEV)";
78
- projectKey.setAttribute("aria-label", "Project key");
79
- projectKey.value = (_a = cfg === null || cfg === void 0 ? void 0 : cfg.projectKey) !== null && _a !== void 0 ? _a : "";
80
- const issueTypeSelect = doc.createElement("select");
81
- issueTypeSelect.className = "di-select";
82
- issueTypeSelect.setAttribute("aria-label", "Issue type");
83
- const issueTypeFallback = doc.createElement("input");
84
- issueTypeFallback.className = "di-input di-hidden";
85
- issueTypeFallback.placeholder = "Issue type (e.g. Bug)";
86
- issueTypeFallback.setAttribute("aria-label", "Issue type (fallback)");
87
- issueTypeFallback.value = (_c = (_b = cfg === null || cfg === void 0 ? void 0 : cfg.issueType) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : "";
88
- const issueTypeHint = doc.createElement("div");
89
- issueTypeHint.className = "di-hint";
90
- issueTypeHint.textContent = "Loading issue types…";
91
- const includeScreenshot = doc.createElement("label");
92
- includeScreenshot.className = "di-check";
93
- const cb = doc.createElement("input");
94
- cb.type = "checkbox";
95
- cb.checked = (_e = (_d = cfg === null || cfg === void 0 ? void 0 : cfg.screenshot) === null || _d === void 0 ? void 0 : _d.enabled) !== null && _e !== void 0 ? _e : false;
96
- const cbText = doc.createElement("span");
97
- cbText.textContent = "Attach screenshot";
98
- includeScreenshot.append(cb, cbText);
99
- const hint = doc.createElement("div");
100
- hint.className = "di-hint";
101
- hint.textContent = "This integration uses a proxy endpoint so Jira secrets stay on your server.";
102
- const actions = doc.createElement("div");
103
- actions.className = "di-modalActions";
104
- const submit = doc.createElement("button");
105
- submit.type = "button";
106
- submit.className = "di-btn";
107
- submit.textContent = "Create issue";
108
- const cancel = doc.createElement("button");
109
- cancel.type = "button";
110
- cancel.className = "di-btn";
111
- cancel.textContent = "Cancel";
112
- actions.append(submit, cancel);
113
- if (!hasJira) {
114
- const empty = doc.createElement("div");
115
- empty.className = "di-hint";
116
- empty.textContent = "Jira integration is not configured. Pass integrations.jira in initDevInspector(...).";
117
- body.append(empty);
118
- }
119
- else {
120
- body.append(error, createField(doc, "Summary", summary), createField(doc, "Description", desc), createField(doc, "Project key", projectKey), createField(doc, "Issue type", issueTypeSelect), issueTypeFallback, issueTypeHint, includeScreenshot, hint);
121
- }
122
- modal.append(head, body, actions);
123
- backdrop.append(modal);
124
- const cleanup = () => {
125
- backdrop.remove();
126
- doc.removeEventListener("keydown", onKeyDown);
127
- };
128
- const finish = (ok) => {
129
- cleanup();
130
- resolve({ ok });
131
- };
132
- const onKeyDown = (ev) => {
133
- if (ev.key === "Escape")
134
- finish(false);
135
- };
136
- close.addEventListener("click", () => finish(false));
137
- cancel.addEventListener("click", () => finish(false));
138
- backdrop.addEventListener("click", (ev) => {
139
- if (ev.target === backdrop)
140
- finish(false);
141
- });
142
- submit.addEventListener("click", async () => {
143
- var _a, _b;
144
- if (!cfg)
145
- return;
146
- error.classList.add("di-hidden");
147
- const titleValue = summary.value.trim();
148
- if (titleValue.length === 0) {
149
- setText(error, "Summary is required.");
150
- error.classList.remove("di-hidden");
151
- return;
152
- }
153
- const pk = projectKey.value.trim();
154
- const itName = issueTypeSelect.value.trim() || issueTypeFallback.value.trim();
155
- if (pk.length === 0 || itName.length === 0) {
156
- setText(error, "Project key and issue type are required.");
157
- error.classList.remove("di-hidden");
158
- return;
159
- }
160
- submit.disabled = true;
161
- submit.textContent = "Creating…";
162
- try {
163
- const input = {
164
- title: titleValue,
165
- description: desc.value,
166
- context: getContext(integrations),
167
- jira: { projectKey: pk, issueType: { name: itName } },
168
- };
169
- if (cb.checked && ((_b = (_a = cfg.screenshot) === null || _a === void 0 ? void 0 : _a.mode) !== null && _b !== void 0 ? _b : "displayMedia") === "displayMedia") {
170
- const shot = await (0, screenshot_1.captureScreenshotDisplayMedia)();
171
- if (shot)
172
- input.screenshot = shot;
173
- }
174
- const res = await (0, integrations_1.createJiraIssue)(input, cfg);
175
- submit.textContent = res.key ? `Created ${res.key}` : "Created";
176
- globalThis.setTimeout(() => finish(true), 650);
177
- }
178
- catch (e) {
179
- setText(error, friendlyError(e));
180
- error.classList.remove("di-hidden");
181
- submit.disabled = false;
182
- submit.textContent = "Create issue";
183
- }
184
- });
185
- doc.addEventListener("keydown", onKeyDown);
186
- doc.body.append(backdrop);
187
- if (hasJira)
188
- summary.focus();
189
- if (cfg === null || cfg === void 0 ? void 0 : cfg.proxyUrl) {
190
- const loadTypes = async () => {
191
- var _a;
192
- issueTypeHint.textContent = "Loading issue types…";
193
- try {
194
- const types = await (0, integrations_1.fetchJiraIssueTypes)(cfg, projectKey.value.trim());
195
- issueTypeSelect.replaceChildren();
196
- if (types.length === 0) {
197
- issueTypeHint.textContent = "Could not load issue types. Enter manually.";
198
- issueTypeFallback.classList.remove("di-hidden");
199
- issueTypeSelect.classList.add("di-hidden");
200
- return;
201
- }
202
- const placeholder = doc.createElement("option");
203
- placeholder.value = "";
204
- placeholder.textContent = "Select issue type…";
205
- issueTypeSelect.append(placeholder);
206
- for (const t of types) {
207
- const opt = doc.createElement("option");
208
- opt.value = t.name;
209
- opt.textContent = t.name;
210
- issueTypeSelect.append(opt);
211
- }
212
- const initial = (_a = cfg.issueType) === null || _a === void 0 ? void 0 : _a.name;
213
- if (initial)
214
- issueTypeSelect.value = initial;
215
- issueTypeHint.textContent = "Issue types loaded from Jira.";
216
- issueTypeFallback.classList.add("di-hidden");
217
- issueTypeSelect.classList.remove("di-hidden");
218
- }
219
- catch (_b) {
220
- issueTypeHint.textContent = "Could not load issue types. Enter manually.";
221
- issueTypeFallback.classList.remove("di-hidden");
222
- issueTypeSelect.classList.add("di-hidden");
223
- }
224
- };
225
- void loadTypes();
226
- projectKey.addEventListener("blur", () => void loadTypes());
227
- }
228
- else {
229
- issueTypeHint.textContent = "Missing proxyUrl. Issue types cannot be loaded.";
230
- issueTypeFallback.classList.remove("di-hidden");
231
- issueTypeSelect.classList.add("di-hidden");
232
- }
233
- });
234
- }
@@ -1,4 +0,0 @@
1
- export declare function captureScreenshotDisplayMedia(): Promise<{
2
- dataUrl: string;
3
- filename: string;
4
- } | undefined>;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.captureScreenshotDisplayMedia = captureScreenshotDisplayMedia;
4
- async function blobToDataUrl(blob) {
5
- return await new Promise((resolve, reject) => {
6
- const r = new FileReader();
7
- r.onload = () => resolve(String(r.result));
8
- r.onerror = () => reject(new Error("Failed to read screenshot."));
9
- r.readAsDataURL(blob);
10
- });
11
- }
12
- async function captureScreenshotDisplayMedia() {
13
- var _a, _b;
14
- const nav = globalThis;
15
- const getDisplayMedia = (_b = (_a = nav.navigator) === null || _a === void 0 ? void 0 : _a.mediaDevices) === null || _b === void 0 ? void 0 : _b.getDisplayMedia;
16
- if (typeof getDisplayMedia !== "function")
17
- return undefined;
18
- const stream = await getDisplayMedia({ video: true, audio: false });
19
- try {
20
- const track = stream.getVideoTracks()[0];
21
- if (!track)
22
- return undefined;
23
- const imageCapture = globalThis.ImageCapture;
24
- if (typeof imageCapture === "function") {
25
- const ic = new imageCapture(track);
26
- const blob = await ic.takePhoto();
27
- const dataUrl = await blobToDataUrl(blob);
28
- return { dataUrl, filename: `screenshot-${Date.now()}.png` };
29
- }
30
- const video = document.createElement("video");
31
- video.srcObject = stream;
32
- video.muted = true;
33
- await video.play();
34
- await new Promise((r) => globalThis.setTimeout(r, 50));
35
- const w = Math.max(1, video.videoWidth || 1);
36
- const h = Math.max(1, video.videoHeight || 1);
37
- const canvas = document.createElement("canvas");
38
- canvas.width = w;
39
- canvas.height = h;
40
- const ctx = canvas.getContext("2d");
41
- if (!ctx)
42
- return undefined;
43
- ctx.drawImage(video, 0, 0, w, h);
44
- const dataUrl = canvas.toDataURL("image/png");
45
- return { dataUrl, filename: `screenshot-${Date.now()}.png` };
46
- }
47
- finally {
48
- for (const t of stream.getTracks())
49
- t.stop();
50
- }
51
- }
@@ -1,4 +0,0 @@
1
- import type { LocalStorageView } from "./types";
2
- export declare function createLocalStorageView(doc: Document, opts: {
3
- onCount?: (count: number) => void;
4
- }): LocalStorageView;
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLocalStorageView = createLocalStorageView;
4
- const copy_1 = require("../../shared/copy");
5
- const jsonViewer_1 = require("../../jsonViewer");
6
- function tryParseJson(text) {
7
- const t = text.trim();
8
- if (t.length < 2)
9
- return undefined;
10
- const looksLikeObject = t.startsWith("{") && t.endsWith("}");
11
- const looksLikeArray = t.startsWith("[") && t.endsWith("]");
12
- if (!looksLikeObject && !looksLikeArray)
13
- return undefined;
14
- try {
15
- return JSON.parse(t);
16
- }
17
- catch (_a) {
18
- return undefined;
19
- }
20
- }
21
- function localStorageValueToElement(doc, value) {
22
- const parsed = tryParseJson(value);
23
- if (parsed && typeof parsed === "object") {
24
- return (0, jsonViewer_1.createJsonViewer)(doc, parsed, { maxDepth: 6, maxKeys: 200, maxNodes: 2000, initiallyOpen: false });
25
- }
26
- const el = doc.createElement("div");
27
- el.className = "di-netBodyText";
28
- el.textContent = value;
29
- return el;
30
- }
31
- function createLocalStorageView(doc, opts) {
32
- const root = doc.createElement("div");
33
- root.className = "di-lsRoot";
34
- const msg = doc.createElement("div");
35
- msg.className = "di-lsMsg di-hidden";
36
- const empty = doc.createElement("div");
37
- empty.className = "di-lsEmpty di-hidden";
38
- empty.textContent = "localStorage is empty.";
39
- const table = doc.createElement("div");
40
- table.className = "di-lsTable di-hidden";
41
- const head = doc.createElement("div");
42
- head.className = "di-lsHead";
43
- head.append(Object.assign(doc.createElement("div"), { className: "di-lsH di-lsHKey", textContent: "Key" }), Object.assign(doc.createElement("div"), { className: "di-lsH di-lsHVal", textContent: "Value" }), Object.assign(doc.createElement("div"), { className: "di-lsH di-lsHAct", textContent: "" }));
44
- const body = doc.createElement("div");
45
- body.className = "di-lsBody";
46
- table.append(head, body);
47
- const setMessage = (message) => {
48
- var _a;
49
- msg.textContent = message;
50
- msg.classList.remove("di-hidden");
51
- table.classList.add("di-hidden");
52
- empty.classList.add("di-hidden");
53
- (_a = opts.onCount) === null || _a === void 0 ? void 0 : _a.call(opts, 0);
54
- };
55
- const setSnapshot = (snapshot) => {
56
- var _a;
57
- msg.classList.add("di-hidden");
58
- table.classList.remove("di-hidden");
59
- body.replaceChildren();
60
- (_a = opts.onCount) === null || _a === void 0 ? void 0 : _a.call(opts, snapshot.items.length);
61
- if (snapshot.items.length === 0) {
62
- empty.classList.remove("di-hidden");
63
- table.classList.add("di-hidden");
64
- return;
65
- }
66
- empty.classList.add("di-hidden");
67
- for (const it of snapshot.items) {
68
- const row = doc.createElement("div");
69
- row.className = "di-lsRow";
70
- const key = doc.createElement("div");
71
- key.className = "di-lsCell di-lsKey";
72
- key.textContent = it.key;
73
- key.title = it.key;
74
- const valueCell = doc.createElement("div");
75
- valueCell.className = "di-lsCell di-lsValue";
76
- valueCell.append(localStorageValueToElement(doc, it.value));
77
- const copyBtn = doc.createElement("button");
78
- copyBtn.type = "button";
79
- copyBtn.className = "di-copyBtn di-lsCopyBtn";
80
- copyBtn.innerHTML =
81
- `<svg class="di-iconSvg" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">` +
82
- `<path d="M9 9H18.5C19.33 9 20 9.67 20 10.5V19.5C20 20.33 19.33 21 18.5 21H9.5C8.67 21 8 20.33 8 19.5V10.5C8 9.67 8.67 9 9.5 9Z" stroke="currentColor" stroke-width="1.5"/>` +
83
- `<path d="M6 15H5.5C4.67 15 4 14.33 4 13.5V4.5C4 3.67 4.67 3 5.5 3H14.5C15.33 3 16 3.67 16 4.5V5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>` +
84
- `</svg>`;
85
- copyBtn.setAttribute("aria-label", `Copy value for ${it.key}`);
86
- copyBtn.addEventListener("click", (ev) => {
87
- ev.preventDefault();
88
- ev.stopPropagation();
89
- void (0, copy_1.copyText)(it.value).then((ok) => {
90
- if (!ok)
91
- return;
92
- (0, copy_1.launchMiniConfetti)(copyBtn);
93
- copyBtn.classList.add("di-copied");
94
- globalThis.setTimeout(() => {
95
- copyBtn.classList.remove("di-copied");
96
- }, 900);
97
- });
98
- });
99
- const actions = doc.createElement("div");
100
- actions.className = "di-lsCell di-lsActions";
101
- actions.append(copyBtn);
102
- row.append(key, valueCell, actions);
103
- body.append(row);
104
- }
105
- };
106
- root.append(msg, empty, table);
107
- return { el: root, setSnapshot, setMessage };
108
- }
@@ -1,3 +0,0 @@
1
- export { createLocalStorageView } from "./createLocalStorageView";
2
- export { setupLocalStorageSync } from "./setupLocalStorageSync";
3
- export type { LocalStorageView } from "./types";
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupLocalStorageSync = exports.createLocalStorageView = void 0;
4
- var createLocalStorageView_1 = require("./createLocalStorageView");
5
- Object.defineProperty(exports, "createLocalStorageView", { enumerable: true, get: function () { return createLocalStorageView_1.createLocalStorageView; } });
6
- var setupLocalStorageSync_1 = require("./setupLocalStorageSync");
7
- Object.defineProperty(exports, "setupLocalStorageSync", { enumerable: true, get: function () { return setupLocalStorageSync_1.setupLocalStorageSync; } });
@@ -1,9 +0,0 @@
1
- import type { LocalStorageView } from "./types";
2
- export declare function setupLocalStorageSync(args: {
3
- view: LocalStorageView;
4
- maxPreviewLength: number;
5
- pollIntervalMs: number;
6
- }): {
7
- refresh: () => void;
8
- destroy: () => void;
9
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupLocalStorageSync = setupLocalStorageSync;
4
- const localStorage_1 = require("../../../storage/localStorage");
5
- function setupLocalStorageSync(args) {
6
- const access = (0, localStorage_1.getLocalStorageAccess)();
7
- if (!access.ok) {
8
- args.view.setMessage(access.message);
9
- return { refresh: () => void 0, destroy: () => void 0 };
10
- }
11
- const refresh = () => {
12
- try {
13
- const snap = (0, localStorage_1.readLocalStorageSnapshot)(access.storage, { maxPreviewLength: args.maxPreviewLength });
14
- args.view.setSnapshot(snap);
15
- }
16
- catch (_a) {
17
- args.view.setMessage("localStorage could not be read (it may be blocked by browser settings).");
18
- }
19
- };
20
- refresh();
21
- const watcher = (0, localStorage_1.createLocalStorageWatcher)({
22
- storage: access.storage,
23
- pollIntervalMs: args.pollIntervalMs,
24
- onChange: refresh,
25
- });
26
- return {
27
- refresh,
28
- destroy: () => watcher.destroy(),
29
- };
30
- }
@@ -1,6 +0,0 @@
1
- import type { LocalStorageSnapshot } from "../../../storage/localStorage";
2
- export type LocalStorageView = {
3
- el: HTMLElement;
4
- setSnapshot: (snapshot: LocalStorageSnapshot) => void;
5
- setMessage: (message: string) => void;
6
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/lib/ui/panel.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { LogStorage } from "../storage/logStorage";
2
- export type PanelOptions = {
3
- storage: LogStorage;
4
- title?: string;
5
- initiallyOpen?: boolean;
6
- mount?: HTMLElement;
7
- };
8
- export type PanelHandle = {
9
- open: () => void;
10
- close: () => void;
11
- toggle: () => void;
12
- destroy: () => void;
13
- isOpen: () => boolean;
14
- };
15
- export declare function createPanel(options: PanelOptions): PanelHandle;