dev-inspector 1.1.0 → 1.2.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.
Files changed (52) hide show
  1. package/README.md +12 -7
  2. package/lib/init.d.ts +9 -0
  3. package/lib/init.js +3 -2
  4. package/lib/ui/panel/behavior/setupPanelBehavior.d.ts +3 -0
  5. package/lib/ui/panel/behavior/setupPanelBehavior.js +3 -1
  6. package/lib/ui/panel/index.d.ts +2 -0
  7. package/lib/ui/panel/index.js +2 -2
  8. package/lib/ui/panel/shared/ensureStyle.js +2 -1
  9. package/lib/ui/panel/skin/applySkin.d.ts +2 -0
  10. package/lib/ui/panel/skin/applySkin.js +6 -0
  11. package/lib/ui/panel/skin/cartoonStyles.d.ts +14 -0
  12. package/lib/ui/panel/skin/cartoonStyles.js +172 -0
  13. package/lib/ui/panel/skin/index.d.ts +3 -0
  14. package/lib/ui/panel/skin/index.js +7 -0
  15. package/lib/ui/panel/skin/types.d.ts +4 -0
  16. package/package.json +3 -2
  17. package/lib/integrations/index.d.ts +0 -2
  18. package/lib/integrations/index.js +0 -7
  19. package/lib/integrations/jira/adf.d.ts +0 -11
  20. package/lib/integrations/jira/adf.js +0 -17
  21. package/lib/integrations/jira/client.d.ts +0 -4
  22. package/lib/integrations/jira/client.js +0 -113
  23. package/lib/integrations/jira/errors.d.ts +0 -10
  24. package/lib/integrations/jira/errors.js +0 -13
  25. package/lib/integrations/jira/index.d.ts +0 -2
  26. package/lib/integrations/jira/index.js +0 -8
  27. package/lib/integrations/types.d.ts +0 -54
  28. package/lib/storage/localStorage.d.ts +0 -30
  29. package/lib/storage/localStorage.js +0 -166
  30. package/lib/ui/logList.d.ts +0 -7
  31. package/lib/ui/logList.js +0 -117
  32. package/lib/ui/panel/integrations/icons.d.ts +0 -1
  33. package/lib/ui/panel/integrations/icons.js +0 -7
  34. package/lib/ui/panel/integrations/index.d.ts +0 -1
  35. package/lib/ui/panel/integrations/index.js +0 -5
  36. package/lib/ui/panel/integrations/jiraDialog.d.ts +0 -6
  37. package/lib/ui/panel/integrations/jiraDialog.js +0 -234
  38. package/lib/ui/panel/integrations/screenshot.d.ts +0 -4
  39. package/lib/ui/panel/integrations/screenshot.js +0 -51
  40. package/lib/ui/panel/localStorage/createLocalStorageView.d.ts +0 -4
  41. package/lib/ui/panel/localStorage/createLocalStorageView.js +0 -108
  42. package/lib/ui/panel/localStorage/index.d.ts +0 -3
  43. package/lib/ui/panel/localStorage/index.js +0 -7
  44. package/lib/ui/panel/localStorage/setupLocalStorageSync.d.ts +0 -9
  45. package/lib/ui/panel/localStorage/setupLocalStorageSync.js +0 -30
  46. package/lib/ui/panel/localStorage/types.d.ts +0 -6
  47. package/lib/ui/panel/localStorage/types.js +0 -2
  48. package/lib/ui/panel.d.ts +0 -15
  49. package/lib/ui/panel.js +0 -375
  50. package/lib/ui/shared/copy.d.ts +0 -2
  51. package/lib/ui/shared/copy.js +0 -101
  52. /package/lib/{integrations → ui/panel/skin}/types.js +0 -0
@@ -1,54 +0,0 @@
1
- export type IntegrationId = "jira";
2
- export type JiraIssueType = {
3
- name?: string;
4
- id?: string;
5
- };
6
- export type JiraIssueTypeOption = {
7
- id: string;
8
- name: string;
9
- };
10
- export type JiraIntegrationConfig = {
11
- proxyUrl?: string;
12
- projectKey?: string;
13
- issueType?: JiraIssueType;
14
- screenshot?: {
15
- enabled?: boolean;
16
- mode?: "displayMedia" | "none";
17
- };
18
- user?: {
19
- id?: string;
20
- email?: string;
21
- name?: string;
22
- };
23
- };
24
- export type IntegrationsConfig = {
25
- jira?: JiraIntegrationConfig;
26
- };
27
- export type IntegrationContext = {
28
- url?: string;
29
- userAgent?: string;
30
- timestamp?: string;
31
- user?: {
32
- id?: string;
33
- email?: string;
34
- name?: string;
35
- };
36
- };
37
- export type CreateIssueInput = {
38
- title: string;
39
- description?: string;
40
- context?: IntegrationContext;
41
- screenshot?: {
42
- dataUrl: string;
43
- filename: string;
44
- };
45
- jira?: {
46
- projectKey?: string;
47
- issueType?: JiraIssueType;
48
- };
49
- };
50
- export type CreateIssueResult = {
51
- id?: string;
52
- key?: string;
53
- url?: string;
54
- };
@@ -1,30 +0,0 @@
1
- export type LocalStorageItem = {
2
- key: string;
3
- value: string;
4
- preview: string;
5
- valueLength: number;
6
- approxBytes: number;
7
- };
8
- export type LocalStorageSnapshot = {
9
- items: LocalStorageItem[];
10
- totalApproxBytes: number;
11
- };
12
- export type LocalStorageAccess = {
13
- ok: true;
14
- storage: Storage;
15
- } | {
16
- ok: false;
17
- message: string;
18
- };
19
- export declare function getLocalStorageAccess(): LocalStorageAccess;
20
- export declare function readLocalStorageSnapshot(storage: Storage, opts: {
21
- maxPreviewLength: number;
22
- }): LocalStorageSnapshot;
23
- export declare function createLocalStorageWatcher(args: {
24
- storage: Storage;
25
- pollIntervalMs: number;
26
- onChange: () => void;
27
- }): {
28
- destroy: () => void;
29
- trigger: () => void;
30
- };
@@ -1,166 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLocalStorageAccess = getLocalStorageAccess;
4
- exports.readLocalStorageSnapshot = readLocalStorageSnapshot;
5
- exports.createLocalStorageWatcher = createLocalStorageWatcher;
6
- function safeTruncate(value, maxLen) {
7
- if (maxLen <= 0)
8
- return "";
9
- if (value.length <= maxLen)
10
- return value;
11
- return `${value.slice(0, maxLen)}…`;
12
- }
13
- function getLocalStorageAccess() {
14
- try {
15
- const w = globalThis;
16
- const storage = w.localStorage;
17
- if (!storage)
18
- return { ok: false, message: "localStorage is not available in this environment." };
19
- // Some environments expose the object but throw on access (privacy modes / blocked cookies).
20
- void storage.length;
21
- return { ok: true, storage };
22
- }
23
- catch (_a) {
24
- return { ok: false, message: "localStorage access is blocked in this environment (privacy settings / permissions)." };
25
- }
26
- }
27
- function readLocalStorageSnapshot(storage, opts) {
28
- var _a;
29
- const items = [];
30
- let totalApproxBytes = 0;
31
- const len = storage.length;
32
- for (let i = 0; i < len; i += 1) {
33
- const key = storage.key(i);
34
- if (!key)
35
- continue;
36
- const value = (_a = storage.getItem(key)) !== null && _a !== void 0 ? _a : "";
37
- const approxBytes = (key.length + value.length) * 2; // UTF-16-ish approximation
38
- totalApproxBytes += approxBytes;
39
- items.push({
40
- key,
41
- value,
42
- preview: safeTruncate(value, opts.maxPreviewLength),
43
- valueLength: value.length,
44
- approxBytes,
45
- });
46
- }
47
- items.sort((a, b) => a.key.localeCompare(b.key));
48
- return { items, totalApproxBytes };
49
- }
50
- function buildSignature(storage) {
51
- var _a;
52
- try {
53
- const parts = [String(storage.length)];
54
- const len = storage.length;
55
- for (let i = 0; i < len; i += 1) {
56
- const k = storage.key(i);
57
- if (!k)
58
- continue;
59
- const v = (_a = storage.getItem(k)) !== null && _a !== void 0 ? _a : "";
60
- parts.push(`${k}:${v.length}`);
61
- }
62
- return parts.join("|");
63
- }
64
- catch (_b) {
65
- return "err";
66
- }
67
- }
68
- function createLocalStorageWatcher(args) {
69
- var _a, _b, _c, _d;
70
- const { storage, onChange } = args;
71
- const pollIntervalMs = Math.max(250, args.pollIntervalMs);
72
- let destroyed = false;
73
- let lastSig = buildSignature(storage);
74
- const trigger = () => {
75
- if (destroyed)
76
- return;
77
- onChange();
78
- };
79
- const win = globalThis;
80
- const onStorageEvent = () => {
81
- const sig = buildSignature(storage);
82
- if (sig !== lastSig) {
83
- lastSig = sig;
84
- trigger();
85
- }
86
- };
87
- try {
88
- (_a = win.addEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "storage", onStorageEvent);
89
- }
90
- catch (_e) {
91
- void 0;
92
- }
93
- // Same-tab changes don't fire "storage" events. We try to patch methods; if that fails, polling still keeps UI fresh.
94
- const orig = {
95
- setItem: (_b = storage.setItem) === null || _b === void 0 ? void 0 : _b.bind(storage),
96
- removeItem: (_c = storage.removeItem) === null || _c === void 0 ? void 0 : _c.bind(storage),
97
- clear: (_d = storage.clear) === null || _d === void 0 ? void 0 : _d.bind(storage),
98
- };
99
- const patch = () => {
100
- try {
101
- storage.setItem = ((key, value) => {
102
- var _a;
103
- (_a = orig.setItem) === null || _a === void 0 ? void 0 : _a.call(orig, key, value);
104
- const sig = buildSignature(storage);
105
- if (sig !== lastSig) {
106
- lastSig = sig;
107
- trigger();
108
- }
109
- });
110
- storage.removeItem = ((key) => {
111
- var _a;
112
- (_a = orig.removeItem) === null || _a === void 0 ? void 0 : _a.call(orig, key);
113
- const sig = buildSignature(storage);
114
- if (sig !== lastSig) {
115
- lastSig = sig;
116
- trigger();
117
- }
118
- });
119
- storage.clear = (() => {
120
- var _a;
121
- (_a = orig.clear) === null || _a === void 0 ? void 0 : _a.call(orig);
122
- const sig = buildSignature(storage);
123
- if (sig !== lastSig) {
124
- lastSig = sig;
125
- trigger();
126
- }
127
- });
128
- return true;
129
- }
130
- catch (_a) {
131
- return false;
132
- }
133
- };
134
- const patched = patch();
135
- const timer = globalThis.setInterval(() => {
136
- const sig = buildSignature(storage);
137
- if (sig !== lastSig) {
138
- lastSig = sig;
139
- trigger();
140
- }
141
- }, patched ? Math.max(800, pollIntervalMs) : pollIntervalMs);
142
- const destroy = () => {
143
- var _a;
144
- destroyed = true;
145
- globalThis.clearInterval(timer);
146
- try {
147
- (_a = win.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "storage", onStorageEvent);
148
- }
149
- catch (_b) {
150
- void 0;
151
- }
152
- // best-effort restore
153
- try {
154
- if (orig.setItem)
155
- storage.setItem = orig.setItem;
156
- if (orig.removeItem)
157
- storage.removeItem = orig.removeItem;
158
- if (orig.clear)
159
- storage.clear = orig.clear;
160
- }
161
- catch (_c) {
162
- void 0;
163
- }
164
- };
165
- return { destroy, trigger };
166
- }
@@ -1,7 +0,0 @@
1
- import type { LogEntry } from "../utils/types";
2
- export type LogList = {
3
- el: HTMLUListElement;
4
- append: (entry: LogEntry) => void;
5
- clear: () => void;
6
- };
7
- export declare function createLogList(doc: Document): LogList;
package/lib/ui/logList.js DELETED
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLogList = createLogList;
4
- const jsonViewer_1 = require("./jsonViewer");
5
- const networkDetails_1 = require("./logList/networkDetails");
6
- function fmtTime(ts) {
7
- const d = new Date(ts);
8
- const hh = String(d.getHours()).padStart(2, "0");
9
- const mm = String(d.getMinutes()).padStart(2, "0");
10
- const ss = String(d.getSeconds()).padStart(2, "0");
11
- return `${hh}:${mm}:${ss}`;
12
- }
13
- function toneForEntry(entry) {
14
- if (entry.source === "console") {
15
- if (entry.level === "error")
16
- return "error";
17
- if (entry.level === "warn")
18
- return "warning";
19
- return "neutral";
20
- }
21
- const s = entry.status;
22
- if (typeof s !== "number")
23
- return "error";
24
- if (s >= 400)
25
- return "error";
26
- if (s >= 300)
27
- return "warning";
28
- return "success";
29
- }
30
- function classForTone(tone) {
31
- if (tone === "error")
32
- return "di-itemToneError";
33
- if (tone === "warning")
34
- return "di-itemToneWarning";
35
- if (tone === "success")
36
- return "di-itemToneSuccess";
37
- return "di-itemToneNeutral";
38
- }
39
- function isNetworkFailure(entry) {
40
- if (entry.source !== "network")
41
- return false;
42
- return typeof entry.status !== "number" || entry.status >= 400;
43
- }
44
- function isInspectableValue(value) {
45
- if (typeof value !== "object" || value === null)
46
- return false;
47
- if (value instanceof Error)
48
- return false;
49
- if (value instanceof Date)
50
- return false;
51
- if (value instanceof RegExp)
52
- return false;
53
- return true;
54
- }
55
- function getInspectableArgs(args) {
56
- return args.filter(isInspectableValue);
57
- }
58
- function createLogList(doc) {
59
- const el = doc.createElement("ul");
60
- el.className = "di-list";
61
- const append = (entry) => {
62
- const li = doc.createElement("li");
63
- const tone = toneForEntry(entry);
64
- li.className = `di-item ${classForTone(tone)}`;
65
- const meta = doc.createElement("div");
66
- meta.className = "di-meta";
67
- const time = doc.createElement("span");
68
- time.textContent = fmtTime(entry.timestamp);
69
- const source = doc.createElement("span");
70
- source.textContent = entry.source;
71
- const detail = doc.createElement("span");
72
- if (entry.source === "console") {
73
- detail.textContent = entry.level;
74
- }
75
- else {
76
- detail.className = `di-statusChip ${isNetworkFailure(entry) ? "di-statusChipError" : "di-statusChipSuccess"}`;
77
- detail.textContent = typeof entry.status === "number" ? String(entry.status) : "ERR";
78
- }
79
- meta.append(time, source, detail);
80
- li.append(meta);
81
- if (entry.message && entry.message.trim().length > 0) {
82
- const msg = doc.createElement("div");
83
- msg.className = "di-msg";
84
- msg.textContent = entry.message;
85
- li.append(msg);
86
- }
87
- if (entry.source === "console") {
88
- const inspectable = getInspectableArgs(entry.args);
89
- if (inspectable.length > 0) {
90
- const details = doc.createElement("details");
91
- details.className = "di-details";
92
- const summary = doc.createElement("summary");
93
- summary.className = "di-detailsSummary";
94
- summary.textContent = "Inspect";
95
- const viewerWrap = doc.createElement("div");
96
- viewerWrap.className = "di-detailsBody";
97
- viewerWrap.append((0, jsonViewer_1.createJsonViewer)(doc, inspectable.length === 1 ? inspectable[0] : inspectable, {
98
- maxDepth: 6,
99
- maxKeys: 200,
100
- maxNodes: 2000,
101
- }));
102
- details.append(summary, viewerWrap);
103
- li.append(details);
104
- }
105
- }
106
- if (entry.source === "network") {
107
- const details = (0, networkDetails_1.createNetworkDetails)(doc, entry);
108
- if (details)
109
- li.append(details);
110
- }
111
- el.append(li);
112
- };
113
- const clear = () => {
114
- el.replaceChildren();
115
- };
116
- return { el, append, clear };
117
- }
@@ -1 +0,0 @@
1
- export declare const INTEGRATIONS_ICON_HTML: string;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INTEGRATIONS_ICON_HTML = void 0;
4
- exports.INTEGRATIONS_ICON_HTML = `<svg class="di-iconSvg" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">` +
5
- `<path d="M8 7.5C8 6.12 9.12 5 10.5 5H19.5C20.88 5 22 6.12 22 7.5V16.5C22 17.88 20.88 19 19.5 19H15L13 21L11 19H10.5C9.12 19 8 17.88 8 16.5V7.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>` +
6
- `<path d="M6 9H4.5C3.12 9 2 10.12 2 11.5V16.5C2 17.88 3.12 19 4.5 19H6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>` +
7
- `</svg>`;
@@ -1 +0,0 @@
1
- export { openJiraDialog } from "./jiraDialog";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openJiraDialog = void 0;
4
- var jiraDialog_1 = require("./jiraDialog");
5
- Object.defineProperty(exports, "openJiraDialog", { enumerable: true, get: function () { return jiraDialog_1.openJiraDialog; } });
@@ -1,6 +0,0 @@
1
- import type { IntegrationsConfig } from "../../../integrations";
2
- type DialogResult = {
3
- ok: boolean;
4
- };
5
- export declare function openJiraDialog(doc: Document, integrations?: IntegrationsConfig): Promise<DialogResult>;
6
- export {};
@@ -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>;