rivia 0.0.87 → 0.0.90
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/dist/index.js +219 -93
- package/index.d.ts +29 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4283,15 +4283,15 @@ var triggerEvent = async (message) => {
|
|
|
4283
4283
|
}
|
|
4284
4284
|
};
|
|
4285
4285
|
|
|
4286
|
-
// src/utils/
|
|
4287
|
-
var
|
|
4286
|
+
// src/utils/pm.js
|
|
4287
|
+
var ProductManagement = /* @__PURE__ */ function() {
|
|
4288
4288
|
const defaults = {
|
|
4289
4289
|
apiUrl: "/api/changelog",
|
|
4290
4290
|
// backend endpoint to fetch changelog JSON (base URL)
|
|
4291
4291
|
appID: null,
|
|
4292
4292
|
authToken: null,
|
|
4293
4293
|
// optional Authorization header
|
|
4294
|
-
buttonSelector: "[data-
|
|
4294
|
+
buttonSelector: "[data-pm-changelog]",
|
|
4295
4295
|
position: "bottom",
|
|
4296
4296
|
// or 'top'
|
|
4297
4297
|
align: "right",
|
|
@@ -4304,79 +4304,194 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4304
4304
|
// additional fetch options
|
|
4305
4305
|
workspace: null,
|
|
4306
4306
|
// optional workspace identifier to send to backend for multi-tenant support
|
|
4307
|
-
|
|
4307
|
+
pmUserId: null,
|
|
4308
4308
|
// optional user identifier to send to backend for personalization
|
|
4309
4309
|
name: "abc",
|
|
4310
4310
|
user_avatar: null,
|
|
4311
4311
|
url: "https://img.freepik.com/free-photo/closeup-scarlet-macaw-from-side-view-scarlet-macaw-closeup-head_488145-3540.jpg?semt=ais_hybrid&w=740&q=80",
|
|
4312
|
-
email: "priyanshu@yopmail.com"
|
|
4312
|
+
email: "priyanshu@yopmail.com",
|
|
4313
|
+
// hardcoded preview id while debugging
|
|
4314
|
+
changelogPreviewId: "outplay"
|
|
4313
4315
|
};
|
|
4314
4316
|
const state = {
|
|
4315
4317
|
initialized: false,
|
|
4316
4318
|
config: {},
|
|
4317
4319
|
widgetEl: null,
|
|
4318
4320
|
backdropEl: null,
|
|
4319
|
-
|
|
4321
|
+
pmUserId: null,
|
|
4322
|
+
changelogEntries: [],
|
|
4323
|
+
// ✅ store API data
|
|
4324
|
+
titleFontSize: null,
|
|
4325
|
+
// for dynamic spacing when preview styles are applied
|
|
4326
|
+
workspaceId: null
|
|
4327
|
+
// to track current workspace for dynamic updates
|
|
4320
4328
|
};
|
|
4321
4329
|
function mergeConfig(cfg) {
|
|
4322
4330
|
state.config = Object.assign({}, defaults, cfg || {});
|
|
4323
4331
|
}
|
|
4332
|
+
async function fetchCSS(previewId, widget, header, body) {
|
|
4333
|
+
if (!previewId) return;
|
|
4334
|
+
try {
|
|
4335
|
+
console.log("Fetching preview styles for id:", previewId);
|
|
4336
|
+
const res = await fetch(`https://demoapi.rivia.ai/change_logs_preview_by_workspace_name/${previewId}`);
|
|
4337
|
+
if (!res.ok) throw new Error("Failed to fetch preview styles");
|
|
4338
|
+
const response = await res.json();
|
|
4339
|
+
const data = response?.message?.[0];
|
|
4340
|
+
console.log("Applying preview styles:", data);
|
|
4341
|
+
if (data.width) {
|
|
4342
|
+
widget.style.width = data.width;
|
|
4343
|
+
widget.style.maxWidth = data.width;
|
|
4344
|
+
}
|
|
4345
|
+
if (data.backgroundColor)
|
|
4346
|
+
widget.style.backgroundColor = data.backgroundColor;
|
|
4347
|
+
if (data.borderRadius)
|
|
4348
|
+
widget.style.borderRadius = data.borderRadius;
|
|
4349
|
+
if (data.fontFamily)
|
|
4350
|
+
widget.style.fontFamily = data.fontFamily;
|
|
4351
|
+
if (data.padding)
|
|
4352
|
+
body.style.padding = data.padding;
|
|
4353
|
+
if (data.bodyFontSize)
|
|
4354
|
+
body.style.fontSize = data.bodyFontSize;
|
|
4355
|
+
if (data.bodyColor)
|
|
4356
|
+
body.style.color = data.bodyColor;
|
|
4357
|
+
if (data.titleFontSize) {
|
|
4358
|
+
header.style.fontSize = data.titleFontSize;
|
|
4359
|
+
state.titleFontSize = data.titleFontSize;
|
|
4360
|
+
}
|
|
4361
|
+
if (data.titleColor)
|
|
4362
|
+
header.style.color = data.titleColor;
|
|
4363
|
+
} catch (err) {
|
|
4364
|
+
console.error("Preview CSS load failed:", err);
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4324
4367
|
function ensureStyles() {
|
|
4325
|
-
if (document.getElementById("
|
|
4368
|
+
if (document.getElementById("pm-lite-styles")) return;
|
|
4326
4369
|
const css = `
|
|
4327
|
-
.
|
|
4328
|
-
.
|
|
4329
|
-
.
|
|
4330
|
-
.
|
|
4331
|
-
.
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4370
|
+
.pm-lite-backdrop{position:fixed;inset:0;background:rgba(255, 255, 255, 0);display:none;z-index:9998}
|
|
4371
|
+
.pm-lite-widget{position:fixed;z-index:9999;max-width:420px;width:clamp(280px,30vw,420px);box-shadow:0 10px 40px rgba(0,0,0,0.2);border-radius:12px;overflow:hidden;font-family:Inter,system-ui,Segoe UI,Roboto,Arial,sans-serif}
|
|
4372
|
+
.pm-lite-widget.light{background:#fff;color:#111}
|
|
4373
|
+
.pm-lite-widget.dark{background:#111;color:#eee}
|
|
4374
|
+
.pm-lite-header{
|
|
4375
|
+
|
|
4376
|
+
padding:6px;
|
|
4377
|
+
padding-top:15px; /* default is 12px, can be overridden by preview styles */
|
|
4378
|
+
font-weight:600;
|
|
4379
|
+
position:relative;
|
|
4380
|
+
|
|
4381
|
+
display:flex;
|
|
4382
|
+
align-items:center;
|
|
4383
|
+
justify-content:center;
|
|
4384
|
+
}
|
|
4385
|
+
.pm-lite-rivia-btn{
|
|
4386
|
+
display:block;
|
|
4387
|
+
margin-left:auto;
|
|
4388
|
+
color:#2563eb; /* blue */
|
|
4389
|
+
font-style:italic;
|
|
4390
|
+
font-size:13px;
|
|
4391
|
+
background:transparent;
|
|
4392
|
+
border:none;
|
|
4393
|
+
cursor:pointer;
|
|
4394
|
+
font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
|
|
4395
|
+
padding:3px 15px;
|
|
4396
|
+
|
|
4397
|
+
}
|
|
4398
|
+
.pm-lite-rivia-label{
|
|
4399
|
+
display:block;
|
|
4400
|
+
margin-right:auto;
|
|
4401
|
+
color:rgba(0,0,0,0.6);
|
|
4402
|
+
font-style:italic;
|
|
4403
|
+
font-size:12px;
|
|
4404
|
+
font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
|
|
4405
|
+
padding-left:18px;
|
|
4406
|
+
}
|
|
4407
|
+
.pm-lite-badge{font-size:12px;margin-left:8px;color:rgba(0,0,0,0.6)}
|
|
4408
|
+
.pm-lite-body{max-height:60vh;overflow:auto;
|
|
4409
|
+
|
|
4410
|
+
overflow: visible; /* remove scroll */
|
|
4411
|
+
height: auto; /* dynamic height */
|
|
4412
|
+
max-height: none; }
|
|
4413
|
+
.pm-lite-item{
|
|
4414
|
+
box-sizing:border-box;
|
|
4415
|
+
margin-bottom:6px;
|
|
4416
|
+
padding:6px 7px;
|
|
4417
|
+
border:1px solid rgba(0,0,0,0.08);
|
|
4418
|
+
border-radius:8px;
|
|
4419
|
+
background:#ffffff;
|
|
4420
|
+
/* isolate from external CSS */
|
|
4421
|
+
font-family:inherit;
|
|
4422
|
+
line-height:1.4;
|
|
4423
|
+
}
|
|
4424
|
+
.pm-lite-item.unread{background:linear-gradient(90deg,rgba(255,245,235,0.6),transparent)}
|
|
4425
|
+
.pm-lite-close{position:absolute;right:8px;top:8px;border:none;background:transparent;font-size:16px;cursor:pointer}
|
|
4426
|
+
.pm-lite-tags{font-size:12px;opacity:0.8;}
|
|
4427
|
+
.pm-lite-link{display:inline-block;margin-top:6px;font-size:13px}
|
|
4428
|
+
.pm-lite-tags{
|
|
4429
|
+
display:inline-block;
|
|
4430
|
+
background-color:rgb(220, 252, 231);
|
|
4431
|
+
color:rgb(22, 101, 52);
|
|
4432
|
+
border-radius:999px;
|
|
4433
|
+
padding:2px 8px;
|
|
4434
|
+
font-size:12px;
|
|
4435
|
+
font-weight:bold;
|
|
4436
|
+
font:Verdana, sans-serif;
|
|
4437
|
+
}
|
|
4339
4438
|
`;
|
|
4340
4439
|
const style = document.createElement("style");
|
|
4341
|
-
style.id = "
|
|
4440
|
+
style.id = "pm-lite-styles";
|
|
4342
4441
|
style.appendChild(document.createTextNode(css));
|
|
4343
4442
|
document.head.appendChild(style);
|
|
4344
4443
|
}
|
|
4345
|
-
function createWidgetShell() {
|
|
4444
|
+
async function createWidgetShell() {
|
|
4346
4445
|
if (state.widgetEl) return;
|
|
4347
4446
|
ensureStyles();
|
|
4348
4447
|
const backdrop = document.createElement("div");
|
|
4349
|
-
backdrop.className = "
|
|
4448
|
+
backdrop.className = "pm-lite-backdrop";
|
|
4350
4449
|
backdrop.addEventListener("click", closeWidget);
|
|
4351
4450
|
const widget = document.createElement("div");
|
|
4352
|
-
widget.className = "
|
|
4451
|
+
widget.className = "pm-lite-widget " + (state.config.theme === "dark" ? "dark" : "light");
|
|
4353
4452
|
widget.setAttribute("role", "dialog");
|
|
4354
4453
|
const header = document.createElement("div");
|
|
4355
|
-
header.className = "
|
|
4356
|
-
header.innerText = "
|
|
4454
|
+
header.className = "pm-lite-header";
|
|
4455
|
+
header.innerText = "Latest Updates";
|
|
4456
|
+
header.paddingTop = "10px";
|
|
4357
4457
|
const badge = document.createElement("span");
|
|
4358
|
-
badge.className = "
|
|
4458
|
+
badge.className = "pm-lite-badge";
|
|
4359
4459
|
badge.style.display = "none";
|
|
4360
4460
|
header.appendChild(badge);
|
|
4361
4461
|
const closeBtn = document.createElement("button");
|
|
4362
|
-
closeBtn.className = "
|
|
4462
|
+
closeBtn.className = "pm-lite-close";
|
|
4363
4463
|
closeBtn.innerHTML = "\u2715";
|
|
4364
4464
|
closeBtn.addEventListener("click", closeWidget);
|
|
4365
4465
|
const body = document.createElement("div");
|
|
4366
|
-
body.className = "
|
|
4367
|
-
body.innerHTML = '<div class="
|
|
4466
|
+
body.className = "pm-lite-body";
|
|
4467
|
+
body.innerHTML = '<div class="pm-lite-loading">Loading\u2026</div>';
|
|
4468
|
+
const footerRow = document.createElement("div");
|
|
4469
|
+
footerRow.style.display = "flex";
|
|
4470
|
+
footerRow.style.alignItems = "center";
|
|
4471
|
+
footerRow.style.justifyContent = "space-between";
|
|
4472
|
+
footerRow.style.marginTop = "5px";
|
|
4473
|
+
footerRow.style.marginBottom = "5px";
|
|
4474
|
+
const riviaLabel = document.createElement("span");
|
|
4475
|
+
riviaLabel.className = "pm-lite-rivia-label";
|
|
4476
|
+
riviaLabel.innerText = "Powered by Rivia";
|
|
4477
|
+
riviaLabel.style.fontSize = "12px";
|
|
4478
|
+
riviaLabel.style.opacity = "0.7";
|
|
4368
4479
|
const riviaBtn = document.createElement("button");
|
|
4369
|
-
riviaBtn.className = "
|
|
4370
|
-
riviaBtn.innerText = "
|
|
4480
|
+
riviaBtn.className = "pm-lite-rivia-btn";
|
|
4481
|
+
riviaBtn.innerText = "See all changes";
|
|
4482
|
+
footerRow.appendChild(riviaLabel);
|
|
4483
|
+
footerRow.appendChild(riviaBtn);
|
|
4371
4484
|
riviaBtn.addEventListener("click", () => {
|
|
4372
|
-
const baseUrl = `http://${state.config.workspace}.rivia.ai/users/changelog?userId=${state.
|
|
4485
|
+
const baseUrl = `http://${state.config.workspace}.rivia.ai:8080/users/changelog?userId=${state.pmUserId || ""}`;
|
|
4373
4486
|
const url = new URL(baseUrl);
|
|
4374
4487
|
window.open(url.toString(), "_blank");
|
|
4375
4488
|
});
|
|
4376
4489
|
widget.appendChild(header);
|
|
4377
|
-
|
|
4378
|
-
|
|
4490
|
+
const divider = document.createElement("div");
|
|
4491
|
+
divider.style.borderTop = "1px solid rgba(0,0,0,0.08)";
|
|
4379
4492
|
widget.appendChild(body);
|
|
4493
|
+
widget.appendChild(divider);
|
|
4494
|
+
widget.appendChild(footerRow);
|
|
4380
4495
|
document.body.appendChild(backdrop);
|
|
4381
4496
|
document.body.appendChild(widget);
|
|
4382
4497
|
state.backdropEl = backdrop;
|
|
@@ -4384,6 +4499,8 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4384
4499
|
state.widgetBody = body;
|
|
4385
4500
|
state.widgetHeader = header;
|
|
4386
4501
|
state.widgetBadge = badge;
|
|
4502
|
+
console.log("Widget shell created, now fetching preview CSS if available...", state.config.workspace);
|
|
4503
|
+
await fetchCSS(state.config.workspace, widget, header, body);
|
|
4387
4504
|
positionWidget();
|
|
4388
4505
|
window.addEventListener("resize", positionWidget);
|
|
4389
4506
|
}
|
|
@@ -4412,12 +4529,9 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4412
4529
|
}
|
|
4413
4530
|
async function fetchChangelog(id) {
|
|
4414
4531
|
if (state.config.initialData) {
|
|
4415
|
-
|
|
4416
|
-
if (candidate && (candidate.integration_id === id || candidate.id === id || candidate.integration_id === candidate.id && !id)) {
|
|
4417
|
-
return candidate;
|
|
4418
|
-
}
|
|
4532
|
+
return state.config.initialData;
|
|
4419
4533
|
}
|
|
4420
|
-
let urlStr =
|
|
4534
|
+
let urlStr = `https://demoapi.rivia.ai/change_logs_by_workspace_name`;
|
|
4421
4535
|
if (!urlStr) throw new Error("apiUrl is not configured");
|
|
4422
4536
|
if (id) {
|
|
4423
4537
|
if (urlStr.includes("{id}")) urlStr = urlStr.replace("{id}", encodeURIComponent(id));
|
|
@@ -4429,55 +4543,69 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4429
4543
|
const headers = Object.assign({}, state.config.fetchOptions.headers || {});
|
|
4430
4544
|
const opts = Object.assign({ method: "GET", headers }, state.config.fetchOptions);
|
|
4431
4545
|
const res = await fetch(url.toString(), opts);
|
|
4432
|
-
if (!res.ok)
|
|
4546
|
+
if (!res.ok) {
|
|
4547
|
+
throw new Error("Failed to fetch changelog: " + res.status + " " + res.statusText);
|
|
4548
|
+
}
|
|
4433
4549
|
const payload = await res.json();
|
|
4434
|
-
|
|
4435
|
-
return
|
|
4550
|
+
state.changelogEntries = payload.message || [];
|
|
4551
|
+
return state.changelogEntries;
|
|
4436
4552
|
} catch (err) {
|
|
4437
4553
|
throw err;
|
|
4438
4554
|
}
|
|
4439
4555
|
}
|
|
4440
4556
|
function renderChangelog(data) {
|
|
4441
4557
|
if (!state.widgetBody) return;
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
state.widgetBadge.style.display = "inline-block";
|
|
4445
|
-
state.widgetBadge.innerText = `(${data.unread_count} new)`;
|
|
4446
|
-
} else {
|
|
4447
|
-
state.widgetBadge.style.display = "none";
|
|
4558
|
+
if (state.widgetHeader.childNodes[0]) {
|
|
4559
|
+
state.widgetHeader.childNodes[0].nodeValue = "Latest Updates";
|
|
4448
4560
|
}
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
state.widgetBody.innerHTML = '<div class="canny-lite-empty">No updates yet.</div>';
|
|
4561
|
+
if (!data || !data.length) {
|
|
4562
|
+
state.widgetBody.innerHTML = '<div class="pm-lite-empty">No updates yet.</div>';
|
|
4452
4563
|
return;
|
|
4453
4564
|
}
|
|
4454
4565
|
const frag = document.createDocumentFragment();
|
|
4455
|
-
|
|
4566
|
+
let i = 0;
|
|
4567
|
+
data.forEach((it) => {
|
|
4568
|
+
i++;
|
|
4569
|
+
if (i > 3) return;
|
|
4456
4570
|
const div = document.createElement("div");
|
|
4457
|
-
|
|
4458
|
-
|
|
4571
|
+
div.className = "pm-lite-item";
|
|
4572
|
+
const date = it.created_at ? new Date(it.created_at).toLocaleDateString() : "";
|
|
4573
|
+
if (it.label) {
|
|
4574
|
+
const tag = document.createElement("span");
|
|
4575
|
+
tag.className = "pm-lite-tags";
|
|
4576
|
+
tag.innerText = it.label;
|
|
4577
|
+
tag.style.display = "inline-block";
|
|
4578
|
+
tag.style.borderRadius = "999px";
|
|
4579
|
+
tag.style.fontSize = "11px";
|
|
4580
|
+
tag.style.fontWeight = "bold";
|
|
4581
|
+
tag.style.fontFamily = "Verdana, sans-serif";
|
|
4582
|
+
tag.style.backgroundColor = "rgb(220, 252, 231)";
|
|
4583
|
+
tag.style.color = "rgb(22, 101, 52)";
|
|
4584
|
+
tag.style.border = "1px solid rgb(187, 247, 208)";
|
|
4585
|
+
div.appendChild(tag);
|
|
4586
|
+
}
|
|
4459
4587
|
const header = document.createElement("div");
|
|
4588
|
+
header.className = "pm-lite-item-header";
|
|
4460
4589
|
header.style.fontWeight = "600";
|
|
4461
|
-
header.innerText =
|
|
4590
|
+
header.innerText = `${it.title || "Untitled"} `;
|
|
4591
|
+
header.style.display = "-webkit-box";
|
|
4592
|
+
header.style.webkitLineClamp = "1";
|
|
4593
|
+
header.style.webkitBoxOrient = "vertical";
|
|
4594
|
+
header.style.overflow = "hidden";
|
|
4595
|
+
header.style.textOverflow = "ellipsis";
|
|
4596
|
+
header.style.fontSize = state.titleFontSize;
|
|
4462
4597
|
const content = document.createElement("div");
|
|
4463
|
-
content.innerHTML =
|
|
4598
|
+
content.innerHTML = it.text || "";
|
|
4599
|
+
content.style.display = "-webkit-box";
|
|
4600
|
+
content.style.webkitLineClamp = "3";
|
|
4601
|
+
content.style.webkitBoxOrient = "vertical";
|
|
4602
|
+
content.style.overflow = "hidden";
|
|
4603
|
+
content.style.textOverflow = "ellipsis";
|
|
4604
|
+
content.querySelectorAll("b, strong").forEach((el) => {
|
|
4605
|
+
el.style.fontWeight = "normal";
|
|
4606
|
+
});
|
|
4464
4607
|
div.appendChild(header);
|
|
4465
4608
|
div.appendChild(content);
|
|
4466
|
-
if (Array.isArray(it.tags) && it.tags.length) {
|
|
4467
|
-
const tags = document.createElement("div");
|
|
4468
|
-
tags.className = "canny-lite-tags";
|
|
4469
|
-
tags.innerHTML = it.tags.map((t) => `<span>#${escapeHtml(t)}</span>`).join(" ");
|
|
4470
|
-
div.appendChild(tags);
|
|
4471
|
-
}
|
|
4472
|
-
if (it.url) {
|
|
4473
|
-
const a = document.createElement("a");
|
|
4474
|
-
a.className = "canny-lite-link";
|
|
4475
|
-
a.href = it.url;
|
|
4476
|
-
a.target = "_blank";
|
|
4477
|
-
a.rel = "noopener noreferrer";
|
|
4478
|
-
a.innerText = "Read more";
|
|
4479
|
-
div.appendChild(a);
|
|
4480
|
-
}
|
|
4481
4609
|
frag.appendChild(div);
|
|
4482
4610
|
});
|
|
4483
4611
|
state.widgetBody.innerHTML = "";
|
|
@@ -4492,6 +4620,7 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4492
4620
|
function showWidget() {
|
|
4493
4621
|
if (!state.widgetEl) createWidgetShell();
|
|
4494
4622
|
state.backdropEl.style.display = "block";
|
|
4623
|
+
state.widgetEl.style.visibility = "hidden";
|
|
4495
4624
|
state.widgetEl.style.display = "block";
|
|
4496
4625
|
}
|
|
4497
4626
|
function closeWidget() {
|
|
@@ -4525,11 +4654,11 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4525
4654
|
async function openWidgetFor(id) {
|
|
4526
4655
|
try {
|
|
4527
4656
|
showWidget();
|
|
4528
|
-
state.widgetBody.innerHTML = '<div class="
|
|
4657
|
+
state.widgetBody.innerHTML = '<div class="pm-lite-loading">Loading\u2026</div>';
|
|
4529
4658
|
const data = await fetchChangelog(id);
|
|
4530
4659
|
renderChangelog(data);
|
|
4531
4660
|
const active = document.activeElement;
|
|
4532
|
-
const selector = state.config.buttonSelector || "[data-
|
|
4661
|
+
const selector = state.config.buttonSelector || "[data-pm-changelog]";
|
|
4533
4662
|
const isTrigger = active && active instanceof Element && active.matches && active.matches(selector);
|
|
4534
4663
|
if (isTrigger) {
|
|
4535
4664
|
state.widgetEl.style.visibility = "hidden";
|
|
@@ -4549,7 +4678,7 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4549
4678
|
positionWidget();
|
|
4550
4679
|
}
|
|
4551
4680
|
} catch (err) {
|
|
4552
|
-
state.widgetBody.innerHTML = `<div class="
|
|
4681
|
+
state.widgetBody.innerHTML = `<div class="pm-lite-error">Error loading changelog: ${escapeHtml(err.message)}</div>`;
|
|
4553
4682
|
console.error(err);
|
|
4554
4683
|
}
|
|
4555
4684
|
}
|
|
@@ -4558,29 +4687,26 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4558
4687
|
const el = e.target.closest(state.config.buttonSelector);
|
|
4559
4688
|
if (!el) return;
|
|
4560
4689
|
e.preventDefault();
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
const url = new URL(baseUrl);
|
|
4564
|
-
window.open(url.toString(), "_blank");
|
|
4565
|
-
}
|
|
4690
|
+
const id = el.getAttribute("data-pm-changelog");
|
|
4691
|
+
openWidgetFor(state.config.workspace || id);
|
|
4566
4692
|
});
|
|
4567
4693
|
}
|
|
4568
4694
|
async function syncUserFromConfig() {
|
|
4569
4695
|
const cfg = state.config;
|
|
4570
4696
|
if (!cfg.workspace || !cfg.email) {
|
|
4571
|
-
console.warn("
|
|
4697
|
+
console.warn("ProductManagement: workspace/email missing, skipping user sync");
|
|
4572
4698
|
return;
|
|
4573
4699
|
}
|
|
4574
4700
|
const payload = {
|
|
4575
4701
|
workspace: cfg.workspace,
|
|
4576
|
-
|
|
4702
|
+
pmUserId: cfg.pmUserId,
|
|
4577
4703
|
name: cfg.name,
|
|
4578
4704
|
email: cfg.email,
|
|
4579
4705
|
user_avatar: cfg.user_avatar,
|
|
4580
4706
|
url: cfg.url
|
|
4581
4707
|
};
|
|
4582
4708
|
try {
|
|
4583
|
-
const res = await fetch(
|
|
4709
|
+
const res = await fetch(`https://demoapi.rivia.ai/pm_users`, {
|
|
4584
4710
|
method: "POST",
|
|
4585
4711
|
headers: {
|
|
4586
4712
|
"Content-Type": "application/json"
|
|
@@ -4591,18 +4717,18 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4591
4717
|
throw new Error(`Failed to sync user (${res.status})`);
|
|
4592
4718
|
}
|
|
4593
4719
|
const data = await res.json();
|
|
4594
|
-
if (data?.
|
|
4595
|
-
state.
|
|
4720
|
+
if (data?.pm_user?.pm_user_id) {
|
|
4721
|
+
state.pmUserId = data.pm_user.pm_user_id;
|
|
4596
4722
|
} else {
|
|
4597
|
-
state.
|
|
4723
|
+
state.pmUserId = cfg.pm_user_id;
|
|
4598
4724
|
}
|
|
4599
4725
|
} catch (err) {
|
|
4600
|
-
console.error("
|
|
4726
|
+
console.error("ProductManagement user sync failed:", err);
|
|
4601
4727
|
}
|
|
4602
4728
|
}
|
|
4603
4729
|
function init(cfg) {
|
|
4604
4730
|
if (state.initialized) {
|
|
4605
|
-
console.warn("
|
|
4731
|
+
console.warn("ProductManagement already initialized \u2014 ignoring subsequent init call.");
|
|
4606
4732
|
return;
|
|
4607
4733
|
}
|
|
4608
4734
|
mergeConfig(cfg);
|
|
@@ -4613,7 +4739,7 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4613
4739
|
function setConfig(cfg) {
|
|
4614
4740
|
mergeConfig(Object.assign({}, state.config, cfg));
|
|
4615
4741
|
if (state.widgetEl) {
|
|
4616
|
-
state.widgetEl.className = "
|
|
4742
|
+
state.widgetEl.className = "pm-lite-widget " + (state.config.theme === "dark" ? "dark" : "light");
|
|
4617
4743
|
positionWidget();
|
|
4618
4744
|
}
|
|
4619
4745
|
}
|
|
@@ -4623,7 +4749,7 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4623
4749
|
function destroy() {
|
|
4624
4750
|
if (state.widgetEl) state.widgetEl.remove();
|
|
4625
4751
|
if (state.backdropEl) state.backdropEl.remove();
|
|
4626
|
-
const style = document.getElementById("
|
|
4752
|
+
const style = document.getElementById("pm-lite-styles");
|
|
4627
4753
|
if (style) style.remove();
|
|
4628
4754
|
state.widgetEl = null;
|
|
4629
4755
|
state.backdropEl = null;
|
|
@@ -4638,8 +4764,8 @@ var CannyLite = /* @__PURE__ */ function() {
|
|
|
4638
4764
|
destroy
|
|
4639
4765
|
};
|
|
4640
4766
|
}();
|
|
4641
|
-
if (typeof window !== "undefined") window.
|
|
4642
|
-
var
|
|
4767
|
+
if (typeof window !== "undefined") window.ProductManagement = ProductManagement;
|
|
4768
|
+
var pm_default = ProductManagement;
|
|
4643
4769
|
|
|
4644
4770
|
// src/utils/index.js
|
|
4645
4771
|
if (typeof window !== "undefined") {
|
|
@@ -4647,12 +4773,12 @@ if (typeof window !== "undefined") {
|
|
|
4647
4773
|
window.Tours = rivia_tour_default;
|
|
4648
4774
|
window.Banner = banner_default;
|
|
4649
4775
|
window.triggerEvent = triggerEvent;
|
|
4650
|
-
window.
|
|
4776
|
+
window.ProductManagement = pm_default;
|
|
4651
4777
|
}
|
|
4652
4778
|
export {
|
|
4653
4779
|
banner_default as Banner,
|
|
4654
|
-
canny_default as CannyLite,
|
|
4655
4780
|
rivia_default as Checklist,
|
|
4781
|
+
pm_default as ProductManagement,
|
|
4656
4782
|
rivia_tour_default as Tours,
|
|
4657
4783
|
triggerEvent
|
|
4658
4784
|
};
|
package/index.d.ts
CHANGED
|
@@ -24,30 +24,48 @@ declare global {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
29
|
-
export type
|
|
27
|
+
export type ProductManagementTheme = "light" | "dark" | "auto";
|
|
28
|
+
export type ProductManagementPosition = "top" | "bottom";
|
|
29
|
+
export type ProductManagementAlign = "left" | "right" | "center";
|
|
30
30
|
|
|
31
|
-
export interface
|
|
31
|
+
export interface ProductManagementConfig {
|
|
32
32
|
apiUrl: string;
|
|
33
33
|
appID: string;
|
|
34
34
|
authToken?: string;
|
|
35
|
-
position?:
|
|
36
|
-
align?:
|
|
37
|
-
theme?:
|
|
35
|
+
position?: ProductManagementPosition;
|
|
36
|
+
align?: ProductManagementAlign;
|
|
37
|
+
theme?: ProductManagementTheme;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
declare function
|
|
41
|
-
init(config:
|
|
40
|
+
declare function ProductManagement(): {
|
|
41
|
+
init(config: ProductManagementConfig): void;
|
|
42
42
|
open(id?: string): void;
|
|
43
43
|
close(): void;
|
|
44
|
-
setConfig(config: Partial<
|
|
44
|
+
setConfig(config: Partial<ProductManagementConfig>): void;
|
|
45
45
|
attachButton(): void;
|
|
46
46
|
destroy(): void;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
declare global {
|
|
50
|
+
interface Window {
|
|
51
|
+
ProductManagement: {
|
|
52
|
+
init(config: ProductManagementConfig): void;
|
|
53
|
+
open(id?: string): void;
|
|
54
|
+
close(): void;
|
|
55
|
+
setConfig(config: Partial<ProductManagementConfig>): void;
|
|
56
|
+
attachButton(): void;
|
|
57
|
+
destroy(): void;
|
|
58
|
+
name?: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
workspace?: string;
|
|
61
|
+
user_avatar?: string;
|
|
62
|
+
};
|
|
63
|
+
triggerEvent: typeof triggerEvent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
49
67
|
declare function Tours(tourId: string, userId: object): void ;
|
|
50
|
-
export { Checklist,Banner, Tours,
|
|
68
|
+
export { Checklist,Banner, Tours, ProductManagement};
|
|
51
69
|
|
|
52
70
|
// declare function Checklist(
|
|
53
71
|
// checklist_id: string,
|