@koderlabs/tasks-sdk-web-reporter 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/README.md +4 -0
- package/dist/index.cjs +59 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.umd.js +11 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,11 @@ This package replaces the v0 `@koderlabs/tasks-widget`. The factory function `wi
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
+
npm install @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-reporter
|
|
13
|
+
# or
|
|
12
14
|
pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-reporter
|
|
15
|
+
# or
|
|
16
|
+
yarn add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-reporter
|
|
13
17
|
```
|
|
14
18
|
|
|
15
19
|
## Usage
|
package/dist/index.cjs
CHANGED
|
@@ -1746,6 +1746,9 @@ var WidgetIntegration = class WidgetIntegration2 {
|
|
|
1746
1746
|
this.opts.hotkey = false;
|
|
1747
1747
|
this.opts.autoInject = false;
|
|
1748
1748
|
}
|
|
1749
|
+
if (init.requireUser === void 0 && typeof cfg.defaultReporterBehavior === "string") {
|
|
1750
|
+
this.opts.requireUser = cfg.defaultReporterBehavior === "current_user";
|
|
1751
|
+
}
|
|
1749
1752
|
} catch {
|
|
1750
1753
|
}
|
|
1751
1754
|
}
|
|
@@ -1794,11 +1797,66 @@ var WidgetIntegration = class WidgetIntegration2 {
|
|
|
1794
1797
|
if (this._visible) return;
|
|
1795
1798
|
if (!this.client) return;
|
|
1796
1799
|
this._visible = true;
|
|
1797
|
-
this.
|
|
1800
|
+
if (this.opts.requireUser && !this._hasIdentity()) {
|
|
1801
|
+
this._openLoginPrompt();
|
|
1802
|
+
} else {
|
|
1803
|
+
this._openModal();
|
|
1804
|
+
}
|
|
1798
1805
|
this._emit({
|
|
1799
1806
|
name: "show"
|
|
1800
1807
|
});
|
|
1801
1808
|
}
|
|
1809
|
+
/** True when the client carries a logged-in user (id or email present). */
|
|
1810
|
+
_hasIdentity() {
|
|
1811
|
+
const u = this.client?.options.user;
|
|
1812
|
+
return Boolean(u && (u.id || u.email));
|
|
1813
|
+
}
|
|
1814
|
+
/** Build a minimal "Please sign in" modal — no form, just a CTA + cancel. */
|
|
1815
|
+
_openLoginPrompt() {
|
|
1816
|
+
const shell = new ModalShell({
|
|
1817
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
1818
|
+
this._visible = false;
|
|
1819
|
+
this._emit({
|
|
1820
|
+
name: "hide"
|
|
1821
|
+
});
|
|
1822
|
+
}, "onClose")
|
|
1823
|
+
});
|
|
1824
|
+
this.shell?.destroy();
|
|
1825
|
+
this.shell = shell;
|
|
1826
|
+
const here = typeof window !== "undefined" ? window.location.pathname + window.location.search : "/";
|
|
1827
|
+
const loginUrl = this.opts.loginUrl ?? `/login?next=${encodeURIComponent(here)}`;
|
|
1828
|
+
const wrapper = document.createElement("div");
|
|
1829
|
+
wrapper.style.cssText = "padding:24px;font-family:system-ui,-apple-system,sans-serif;text-align:center;max-width:340px;";
|
|
1830
|
+
wrapper.innerHTML = `
|
|
1831
|
+
<div style="font-size:32px;margin-bottom:8px">\u{1F512}</div>
|
|
1832
|
+
<div style="font-size:18px;font-weight:600;color:#111827;margin-bottom:6px">Sign in to report a bug</div>
|
|
1833
|
+
<div style="font-size:13px;color:#6b7280;margin-bottom:18px;line-height:1.5">This project requires reporters to be signed in so bug reports can be linked to your account.</div>
|
|
1834
|
+
`;
|
|
1835
|
+
const signInBtn = document.createElement("button");
|
|
1836
|
+
signInBtn.type = "button";
|
|
1837
|
+
signInBtn.textContent = "Sign in";
|
|
1838
|
+
signInBtn.style.cssText = "width:100%;padding:10px 16px;background:#2563eb;color:#fff;border:0;border-radius:6px;font-size:14px;font-weight:600;cursor:pointer;margin-bottom:8px;";
|
|
1839
|
+
signInBtn.addEventListener("click", () => {
|
|
1840
|
+
try {
|
|
1841
|
+
window.location.assign(loginUrl);
|
|
1842
|
+
} catch {
|
|
1843
|
+
}
|
|
1844
|
+
});
|
|
1845
|
+
const cancelBtn = document.createElement("button");
|
|
1846
|
+
cancelBtn.type = "button";
|
|
1847
|
+
cancelBtn.textContent = "Cancel";
|
|
1848
|
+
cancelBtn.style.cssText = "width:100%;padding:10px 16px;background:transparent;color:#6b7280;border:1px solid #e5e7eb;border-radius:6px;font-size:14px;cursor:pointer;";
|
|
1849
|
+
cancelBtn.addEventListener("click", () => {
|
|
1850
|
+
shell.close();
|
|
1851
|
+
this._visible = false;
|
|
1852
|
+
this._emit({
|
|
1853
|
+
name: "feedbackdiscarded"
|
|
1854
|
+
});
|
|
1855
|
+
});
|
|
1856
|
+
wrapper.appendChild(signInBtn);
|
|
1857
|
+
wrapper.appendChild(cancelBtn);
|
|
1858
|
+
shell.open(wrapper);
|
|
1859
|
+
}
|
|
1802
1860
|
hide() {
|
|
1803
1861
|
if (!this._visible) return;
|
|
1804
1862
|
this.shell?.close();
|