@ourroadmaps/web-sdk 1.2.0 → 1.3.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.
- package/dist/{chunk-M2R3KO66.cjs → chunk-KDMQIQP4.cjs} +237 -30
- package/dist/chunk-KDMQIQP4.cjs.map +1 -0
- package/dist/{chunk-OHL77RGU.js → chunk-Q6BH54FY.js} +235 -30
- package/dist/chunk-Q6BH54FY.js.map +1 -0
- package/dist/index.cjs +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -4
- package/dist/index.js.map +1 -1
- package/dist/review/index.cjs +2 -2
- package/dist/review/index.d.cts +1 -1
- package/dist/review/index.d.ts +1 -1
- package/dist/review/index.js +1 -1
- package/dist/review.global.js +6 -9
- package/dist/review.global.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-M2R3KO66.cjs.map +0 -1
- package/dist/chunk-OHL77RGU.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkKGQKTDB4_cjs = require('./chunk-KGQKTDB4.cjs');
|
|
4
4
|
var chunkEKWWSLHU_cjs = require('./chunk-EKWWSLHU.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkKDMQIQP4_cjs = require('./chunk-KDMQIQP4.cjs');
|
|
6
6
|
require('./chunk-4DE2IREA.cjs');
|
|
7
7
|
|
|
8
8
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -48,13 +48,38 @@ function destroy() {
|
|
|
48
48
|
|
|
49
49
|
// src/index.ts
|
|
50
50
|
if (typeof window !== "undefined") {
|
|
51
|
-
window.OurRoadmaps = { init, destroy, createOverlay: chunkEKWWSLHU_cjs.createOverlay, Review:
|
|
51
|
+
window.OurRoadmaps = { init, destroy, createOverlay: chunkEKWWSLHU_cjs.createOverlay, Review: chunkKDMQIQP4_cjs.Review };
|
|
52
52
|
}
|
|
53
53
|
if (typeof window !== "undefined") {
|
|
54
|
+
let tokenType = null;
|
|
55
|
+
let token = null;
|
|
54
56
|
const params = new URLSearchParams(window.location.search);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const reviewToken = params.get("review");
|
|
58
|
+
const triageToken = params.get("triage");
|
|
59
|
+
if (reviewToken) {
|
|
60
|
+
tokenType = "review";
|
|
61
|
+
token = reviewToken;
|
|
62
|
+
chunkKDMQIQP4_cjs.storeToken("review", reviewToken);
|
|
63
|
+
const clean = new URL(window.location.href);
|
|
64
|
+
clean.searchParams.delete("review");
|
|
65
|
+
history.replaceState(null, "", clean.toString());
|
|
66
|
+
} else if (triageToken) {
|
|
67
|
+
tokenType = "triage";
|
|
68
|
+
token = triageToken;
|
|
69
|
+
chunkKDMQIQP4_cjs.storeToken("triage", triageToken);
|
|
70
|
+
const clean = new URL(window.location.href);
|
|
71
|
+
clean.searchParams.delete("triage");
|
|
72
|
+
history.replaceState(null, "", clean.toString());
|
|
73
|
+
} else {
|
|
74
|
+
const stored = chunkKDMQIQP4_cjs.getStoredToken();
|
|
75
|
+
if (stored) {
|
|
76
|
+
tokenType = stored.type;
|
|
77
|
+
token = stored.token;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (tokenType && token) {
|
|
81
|
+
const review = new chunkKDMQIQP4_cjs.Review();
|
|
82
|
+
review.init(tokenType, token);
|
|
58
83
|
}
|
|
59
84
|
}
|
|
60
85
|
|
|
@@ -68,7 +93,7 @@ Object.defineProperty(exports, "createOverlay", {
|
|
|
68
93
|
});
|
|
69
94
|
Object.defineProperty(exports, "Review", {
|
|
70
95
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
96
|
+
get: function () { return chunkKDMQIQP4_cjs.Review; }
|
|
72
97
|
});
|
|
73
98
|
exports.destroy = destroy;
|
|
74
99
|
exports.init = init;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/feedback/d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gBAAA,GAAmB,IAAA;AAAA,EACrB;AACF;;;
|
|
1
|
+
{"version":3,"sources":["../src/feedback/dev-mode.ts","../src/feedback-init.ts","../src/index.ts"],"names":["Feedback","createOverlay","Review","storeToken","getStoredToken"],"mappings":";;;;;;;;;AAAO,SAAS,SAAA,GAAqB;AAEnC,EAAA,IAAI,OAAO,OAAA,KAAY,WAAA,IAAe,OAAA,CAAQ,KAAK,QAAA,EAAU;AAC3D,IAAA,OAAO,OAAA,CAAQ,IAAI,QAAA,KAAa,YAAA;AAAA,EAClC;AAGA,EAAA,IAAI,OAAO,sQAAA,KAAgB,WAAA,IAAe,WAAiB,IAAA,EAAM;AAC/D,IAAA,OAAO,UAAgB,IAAA,KAAS,YAAA;AAAA,EAClC;AAGA,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,MAAA,CAAO,QAAA,EAAU;AACpD,IAAA,MAAM,QAAA,GAAW,OAAO,QAAA,CAAS,QAAA;AACjC,IAAA,OAAO,aAAa,WAAA,IAAe,QAAA,KAAa,WAAA,IAAe,QAAA,CAAS,SAAS,QAAQ,CAAA;AAAA,EAC3F;AAEA,EAAA,OAAO,KAAA;AACT;;;ACbA,IAAI,gBAAA,GAAoC,IAAA;AAEjC,SAAS,KAAK,MAAA,EAA4B;AAC/C,EAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,IAAA,OAAA,CAAQ,MAAM,iDAAiD,CAAA;AAC/D,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,WAAU,EAAG;AAChB,IAAA,OAAA,CAAQ,KAAK,kDAAkD,CAAA;AAC/D,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,OAAA,CAAQ,KAAK,0CAA0C,CAAA;AACvD,IAAA;AAAA,EACF;AAEA,EAAA,gBAAA,GAAmB,IAAIA,2BAAS,MAAM,CAAA;AACtC,EAAA,gBAAA,CAAiB,KAAA,EAAM;AACzB;AAEO,SAAS,OAAA,GA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AQ,YAAA,CAAa,IAAA,EAAM,EAAA,EAAI,KAAA,CAAM,UAAU,CAAA;AAAA,EACjD,CAAA,MAAO;AAEL,IAAA,MAAM,SAASC,gCAAA,EAAe;AAC9B,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,SAAA,GAAY,MAAA,CAAO,IAAA;AACnB,MAAA,KAAA,GAAQ,MAAA,CAAO,KAAA;AAAA,IACjB;AAAA,EACF;AAGA,EAAA,IAAI,aAAa,KAAA,EAAO;AACtB,IAAA,MAAM,MAAA,GAAS,IAAIF,wBAAA,EAAO;AAC1B,IAAA,MAAA,CAAO,IAAA,CAAK,WAAW,KAAK,CAAA;AAAA,EAC9B;AACF","file":"index.cjs","sourcesContent":["export function isDevMode(): boolean {\n // Check NODE_ENV (works with bundlers)\n if (typeof process !== 'undefined' && process.env?.NODE_ENV) {\n return process.env.NODE_ENV !== 'production'\n }\n\n // Check import.meta.env (Vite)\n if (typeof import.meta !== 'undefined' && import.meta.env?.MODE) {\n return import.meta.env.MODE !== 'production'\n }\n\n // Check hostname (works without bundler)\n if (typeof window !== 'undefined' && window.location) {\n const hostname = window.location.hostname\n return hostname === 'localhost' || hostname === '127.0.0.1' || hostname.endsWith('.local')\n }\n\n return false\n}\n","// Feedback initialization - extracted for lazy loading\nimport { isDevMode } from './feedback/dev-mode'\nimport { Feedback } from './feedback/Feedback'\nimport type { WidgetConfig } from './feedback/types'\n\nlet feedbackInstance: Feedback | null = null\n\nexport function init(config: WidgetConfig): void {\n if (!config.apiKey) {\n console.error('[OurRoadmaps] Missing required apiKey in config')\n return\n }\n\n if (!isDevMode()) {\n console.info('[OurRoadmaps] Widget disabled in production mode')\n return\n }\n\n if (feedbackInstance) {\n console.warn('[OurRoadmaps] Widget already initialized')\n return\n }\n\n feedbackInstance = new Feedback(config)\n feedbackInstance.mount()\n}\n\nexport function destroy(): void {\n if (feedbackInstance) {\n feedbackInstance.unmount()\n feedbackInstance = null\n }\n}\n","// Feedback module\n\nexport type { WidgetConfig } from './feedback/types'\nexport { destroy, init } from './feedback-init'\nexport type {\n Action,\n Anchor,\n Annotation,\n AnnotationsConfig,\n AnnotationsController,\n CursorConfig,\n CursorController,\n OverlayController,\n OverlayError,\n OverlayOptions,\n OverlayScript,\n Target,\n ValidationResult,\n} from './overlay'\n// Overlay module\nexport { createOverlay, Overlay } from './overlay'\n\n// Review module\nexport { Review } from './review'\nexport type { PinData, ReviewOptions } from './review'\n\n// For UMD bundle - expose on window\nimport { destroy, init } from './feedback-init'\nimport { createOverlay } from './overlay'\nimport { Review } from './review'\nimport { storeToken, getStoredToken } from './review/TokenStorage'\n\nif (typeof window !== 'undefined') {\n // biome-ignore lint/suspicious/noExplicitAny: Required for UMD global assignment\n ;(window as any).OurRoadmaps = { init, destroy, createOverlay, Review }\n}\n\n// Auto-init review mode: check URL params first, then sessionStorage\nif (typeof window !== 'undefined') {\n let tokenType: 'review' | 'triage' | null = null\n let token: string | null = null\n\n // 1. Check URL params (first visit via email/slack link)\n const params = new URLSearchParams(window.location.search)\n const reviewToken = params.get('review')\n const triageToken = params.get('triage')\n\n if (reviewToken) {\n tokenType = 'review'\n token = reviewToken\n storeToken('review', reviewToken)\n // Strip token from URL to prevent leaking into history/referrer\n const clean = new URL(window.location.href)\n clean.searchParams.delete('review')\n history.replaceState(null, '', clean.toString())\n } else if (triageToken) {\n tokenType = 'triage'\n token = triageToken\n storeToken('triage', triageToken)\n const clean = new URL(window.location.href)\n clean.searchParams.delete('triage')\n history.replaceState(null, '', clean.toString())\n } else {\n // 2. No URL param — check sessionStorage (subsequent navigation)\n const stored = getStoredToken()\n if (stored) {\n tokenType = stored.type\n token = stored.token\n }\n }\n\n // 3. Initialize if we have a token\n if (tokenType && token) {\n const review = new Review()\n review.init(tokenType, token)\n }\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Feedback } from './chunk-MKPDPQXT.js';
|
|
2
2
|
import { createOverlay } from './chunk-JPUN7P3T.js';
|
|
3
3
|
export { Overlay, createOverlay } from './chunk-JPUN7P3T.js';
|
|
4
|
-
import { Review } from './chunk-
|
|
5
|
-
export { Review } from './chunk-
|
|
4
|
+
import { Review, storeToken, getStoredToken } from './chunk-Q6BH54FY.js';
|
|
5
|
+
export { Review } from './chunk-Q6BH54FY.js';
|
|
6
6
|
import './chunk-V6TY7KAL.js';
|
|
7
7
|
|
|
8
8
|
// src/feedback/dev-mode.ts
|
|
@@ -50,10 +50,35 @@ if (typeof window !== "undefined") {
|
|
|
50
50
|
window.OurRoadmaps = { init, destroy, createOverlay, Review };
|
|
51
51
|
}
|
|
52
52
|
if (typeof window !== "undefined") {
|
|
53
|
+
let tokenType = null;
|
|
54
|
+
let token = null;
|
|
53
55
|
const params = new URLSearchParams(window.location.search);
|
|
54
|
-
|
|
56
|
+
const reviewToken = params.get("review");
|
|
57
|
+
const triageToken = params.get("triage");
|
|
58
|
+
if (reviewToken) {
|
|
59
|
+
tokenType = "review";
|
|
60
|
+
token = reviewToken;
|
|
61
|
+
storeToken("review", reviewToken);
|
|
62
|
+
const clean = new URL(window.location.href);
|
|
63
|
+
clean.searchParams.delete("review");
|
|
64
|
+
history.replaceState(null, "", clean.toString());
|
|
65
|
+
} else if (triageToken) {
|
|
66
|
+
tokenType = "triage";
|
|
67
|
+
token = triageToken;
|
|
68
|
+
storeToken("triage", triageToken);
|
|
69
|
+
const clean = new URL(window.location.href);
|
|
70
|
+
clean.searchParams.delete("triage");
|
|
71
|
+
history.replaceState(null, "", clean.toString());
|
|
72
|
+
} else {
|
|
73
|
+
const stored = getStoredToken();
|
|
74
|
+
if (stored) {
|
|
75
|
+
tokenType = stored.type;
|
|
76
|
+
token = stored.token;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (tokenType && token) {
|
|
55
80
|
const review = new Review();
|
|
56
|
-
review.init();
|
|
81
|
+
review.init(tokenType, token);
|
|
57
82
|
}
|
|
58
83
|
}
|
|
59
84
|
|
package/dist/index.js.map
CHANGED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A,CAAO,SAAS,IAAI,CAAA;AAC1C,IAAA,KAAA,CAAM,YAAA,CAAa,OAAO,QAAQ,CAAA;AAClC,IAAA,OAAA,CAAQ,YAAA,CAAa,IAAA,EAAM,EAAA,EAAI,KAAA,CAAM,UAAU,CAAA;AAAA,EACjD,CAAA,MAAO;AAEL,IAAA,MAAM,SAAS,cAAA,EAAe;AAC9B,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,SAAA,GAAY,MAAA,CAAO,IAAA;AACnB,MAAA,KAAA,GAAQ,MAAA,CAAO,KAAA;AAAA,IACjB;AAAA,EACF;AAGA,EAAA,IAAI,aAAa,KAAA,EAAO;AACtB,IAAA,MAAM,MAAA,GAAS,IAAI,MAAA,EAAO;AAC1B,IAAA,MAAA,CAAO,IAAA,CAAK,WAAW,KAAK,CAAA;AAAA,EAC9B;AACF","file":"index.js","sourcesContent":["export function isDevMode(): boolean {\n // Check NODE_ENV (works with bundlers)\n if (typeof process !== 'undefined' && process.env?.NODE_ENV) {\n return process.env.NODE_ENV !== 'production'\n }\n\n // Check import.meta.env (Vite)\n if (typeof import.meta !== 'undefined' && import.meta.env?.MODE) {\n return import.meta.env.MODE !== 'production'\n }\n\n // Check hostname (works without bundler)\n if (typeof window !== 'undefined' && window.location) {\n const hostname = window.location.hostname\n return hostname === 'localhost' || hostname === '127.0.0.1' || hostname.endsWith('.local')\n }\n\n return false\n}\n","// Feedback initialization - extracted for lazy loading\nimport { isDevMode } from './feedback/dev-mode'\nimport { Feedback } from './feedback/Feedback'\nimport type { WidgetConfig } from './feedback/types'\n\nlet feedbackInstance: Feedback | null = null\n\nexport function init(config: WidgetConfig): void {\n if (!config.apiKey) {\n console.error('[OurRoadmaps] Missing required apiKey in config')\n return\n }\n\n if (!isDevMode()) {\n console.info('[OurRoadmaps] Widget disabled in production mode')\n return\n }\n\n if (feedbackInstance) {\n console.warn('[OurRoadmaps] Widget already initialized')\n return\n }\n\n feedbackInstance = new Feedback(config)\n feedbackInstance.mount()\n}\n\nexport function destroy(): void {\n if (feedbackInstance) {\n feedbackInstance.unmount()\n feedbackInstance = null\n }\n}\n","// Feedback module\n\nexport type { WidgetConfig } from './feedback/types'\nexport { destroy, init } from './feedback-init'\nexport type {\n Action,\n Anchor,\n Annotation,\n AnnotationsConfig,\n AnnotationsController,\n CursorConfig,\n CursorController,\n OverlayController,\n OverlayError,\n OverlayOptions,\n OverlayScript,\n Target,\n ValidationResult,\n} from './overlay'\n// Overlay module\nexport { createOverlay, Overlay } from './overlay'\n\n// Review module\nexport { Review } from './review'\nexport type { PinData, ReviewOptions } from './review'\n\n// For UMD bundle - expose on window\nimport { destroy, init } from './feedback-init'\nimport { createOverlay } from './overlay'\nimport { Review } from './review'\nimport { storeToken, getStoredToken } from './review/TokenStorage'\n\nif (typeof window !== 'undefined') {\n // biome-ignore lint/suspicious/noExplicitAny: Required for UMD global assignment\n ;(window as any).OurRoadmaps = { init, destroy, createOverlay, Review }\n}\n\n// Auto-init review mode: check URL params first, then sessionStorage\nif (typeof window !== 'undefined') {\n let tokenType: 'review' | 'triage' | null = null\n let token: string | null = null\n\n // 1. Check URL params (first visit via email/slack link)\n const params = new URLSearchParams(window.location.search)\n const reviewToken = params.get('review')\n const triageToken = params.get('triage')\n\n if (reviewToken) {\n tokenType = 'review'\n token = reviewToken\n storeToken('review', reviewToken)\n // Strip token from URL to prevent leaking into history/referrer\n const clean = new URL(window.location.href)\n clean.searchParams.delete('review')\n history.replaceState(null, '', clean.toString())\n } else if (triageToken) {\n tokenType = 'triage'\n token = triageToken\n storeToken('triage', triageToken)\n const clean = new URL(window.location.href)\n clean.searchParams.delete('triage')\n history.replaceState(null, '', clean.toString())\n } else {\n // 2. No URL param — check sessionStorage (subsequent navigation)\n const stored = getStoredToken()\n if (stored) {\n tokenType = stored.type\n token = stored.token\n }\n }\n\n // 3. Initialize if we have a token\n if (tokenType && token) {\n const review = new Review()\n review.init(tokenType, token)\n }\n}\n"]}
|
package/dist/review/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkKDMQIQP4_cjs = require('../chunk-KDMQIQP4.cjs');
|
|
4
4
|
require('../chunk-4DE2IREA.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "Review", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkKDMQIQP4_cjs.Review; }
|
|
11
11
|
});
|
|
12
12
|
//# sourceMappingURL=index.cjs.map
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/review/index.d.cts
CHANGED
package/dist/review/index.d.ts
CHANGED
package/dist/review/index.js
CHANGED
package/dist/review.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var OurRoadmaps=(()=>{var
|
|
1
|
+
"use strict";var OurRoadmaps=(()=>{var v=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var _=(n,e,t)=>e in n?v(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var X=(n,e)=>{for(var t in e)v(n,t,{get:e[t],enumerable:!0})},F=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y(e))!O.call(n,o)&&o!==t&&v(n,o,{get:()=>e[o],enumerable:!(i=A(e,o))||i.enumerable});return n};var W=n=>F(v({},"__esModule",{value:!0}),n);var r=(n,e,t)=>_(n,typeof e!="symbol"?e+"":e,t);var K={};X(K,{Review:()=>P});var B={},S=(typeof B<"u","https://api.ourroadmaps.com");async function L(n){let e=await fetch(`${S}/v1/prototype-review/${n}`);if(e.status===410)throw new m("expired","This feedback session has expired");if(e.status===404)throw new m("invalid","This review link is not valid");if(!e.ok)throw new m("error","Something went wrong");return(await e.json()).data}async function M(n,e){let t=await fetch(`${S}/v1/prototype-review/${n}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new m("error","Failed to submit comment");return(await t.json()).data}async function w(n){let e=await fetch(`${S}/v1/prototype-review/${n}/comments`);if(!e.ok)throw new m("error","Failed to load comments");return(await e.json()).data}var m=class extends Error{constructor(t,i){super(i);this.code=t;this.name="ReviewError"}};function $(n,e){let t=document.elementFromPoint(n,e),i=document.documentElement,o=(n+window.scrollX)/i.scrollWidth*100,a=(e+window.scrollY)/i.scrollHeight*100;if(!t||t===document.body||t===i)return{pinX:o,pinY:a,element:{selector:"body",tag:"body",text:"",ariaLabel:null,className:"",boundingBox:{x:0,y:0,w:i.scrollWidth,h:i.scrollHeight}},context:{parentTag:"",parentText:"",grandparentTag:"",siblings:[],nearbyText:""},viewportWidth:window.innerWidth,viewportHeight:window.innerHeight};let s=t.getBoundingClientRect();return{pinX:o,pinY:a,element:{selector:j(t),tag:t.tagName.toLowerCase(),text:b(t).slice(0,200),ariaLabel:t.getAttribute("aria-label"),className:t.className&&typeof t.className=="string"?t.className:"",boundingBox:{x:Math.round(s.x),y:Math.round(s.y),w:Math.round(s.width),h:Math.round(s.height)}},context:{parentTag:t.parentElement?`${t.parentElement.tagName.toLowerCase()}${R(t.parentElement)}`:"",parentText:t.parentElement?b(t.parentElement).slice(0,100):"",grandparentTag:t.parentElement?.parentElement?`${t.parentElement.parentElement.tagName.toLowerCase()}${R(t.parentElement.parentElement)}`:"",siblings:q(t),nearbyText:G(t).slice(0,200)},viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function j(n){let e=[],t=n;for(;t&&t!==document.body;){if(t.id){e.unshift(`#${t.id}`);break}let i=t.tagName.toLowerCase();if(t.className&&typeof t.className=="string"){let o=t.className.trim().split(/\s+/).slice(0,2).join(".");o&&(i+=`.${o}`)}e.unshift(i),t=t.parentElement}return e.join(" > ")}function b(n){let e="";for(let t of n.childNodes)t.nodeType===Node.TEXT_NODE&&(e+=t.textContent?.trim()||"");return e.trim()||n.textContent?.trim().slice(0,200)||""}function R(n){if(!n.className||typeof n.className!="string")return"";let e=n.className.trim().split(/\s+/).slice(0,2).join(".");return e?`.${e}`:""}function q(n){if(!n.parentElement)return[];let e=[];for(let t of n.parentElement.children){if(t===n)continue;let i=t.tagName.toLowerCase(),o=(t.textContent?.trim()||"").slice(0,50);if(e.push(o?`${i}:${o}`:i),e.length>=4)break}return e}function G(n){let e=n.parentElement,t=0;for(;e&&t<3;){let i=b(e);if(i&&i!==b(n))return i;e=e.parentElement,t++}return""}var D=`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
}
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
transition-duration: 0.01ms !important;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
`,
|
|
260
|
+
`,z=`
|
|
261
261
|
body {
|
|
262
262
|
position: relative !important;
|
|
263
263
|
}
|
|
@@ -314,28 +314,25 @@ body {
|
|
|
314
314
|
transition-duration: 0.01ms !important;
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
`;var
|
|
317
|
+
`;var k="roadmaps-review-pin-styles",u=class{constructor(){r(this,"container");r(this,"pins",new Map);r(this,"styleEl",null);this.container=document.createElement("div"),this.container.className="pin-container"}mount(){document.getElementById(k)||(this.styleEl=document.createElement("style"),this.styleEl.id=k,this.styleEl.textContent=z,document.head.appendChild(this.styleEl)),document.body.appendChild(this.container)}addPin(e,t,i,o,a){let s=document.createElement("div");s.className=o?"review-pin":"review-pin review-pin--other",s.textContent=String(e),s.style.left=`${t}%`,s.style.top=`${i}%`,s.dataset.pinNumber=String(e),s.dataset.pageUrl=a,this.container.appendChild(s),this.pins.set(e,{el:s,pageUrl:a})}removePin(e){let t=this.pins.get(e);t&&(t.el.remove(),this.pins.delete(e))}highlightPin(e){for(let[t,{el:i}]of this.pins)i.classList.toggle("review-pin--highlighted",t===e)}clearHighlight(){for(let{el:e}of this.pins.values())e.classList.remove("review-pin--highlighted")}filterByPage(e){for(let{el:t,pageUrl:i}of this.pins.values())t.style.display=i===e?"":"none"}showAll(){for(let{el:e}of this.pins.values())e.style.display=""}countForPage(e){let t=0;for(let{pageUrl:i}of this.pins.values())i===e&&t++;return t}destroy(){this.container.remove(),this.pins.clear(),this.styleEl?(this.styleEl.remove(),this.styleEl=null):document.getElementById(k)?.remove()}};var x=class{constructor(e){this.shadowRoot=e;r(this,"card",null);r(this,"onSubmit",null);r(this,"onCancel",null)}show(e){this.hide(),this.onSubmit=e.onSubmit,this.onCancel=e.onCancel,this.card=document.createElement("div"),this.card.className="review-comment-card",this.card.style.left=`${Math.min(e.x,window.innerWidth-320)}px`,this.card.style.top=`${Math.min(e.y+20,window.innerHeight-200)}px`,this.card.innerHTML=`
|
|
318
318
|
<textarea class="review-comment-input" placeholder="Leave your feedback..." rows="3"></textarea>
|
|
319
319
|
<div class="review-comment-actions">
|
|
320
320
|
<button class="review-btn review-btn--cancel">Cancel</button>
|
|
321
321
|
<button class="review-btn review-btn--submit">Submit</button>
|
|
322
322
|
</div>
|
|
323
323
|
<div class="review-comment-error" style="display:none"></div>
|
|
324
|
-
`,this.attachListeners(),this.shadowRoot.appendChild(this.card),this.card.querySelector("textarea")?.focus()}hide(){this.card?.remove(),this.card=null}showForGeneral(e){this.show({x:window.innerWidth/2-150,y:window.innerHeight/2-100,onSubmit:e.onSubmit,onCancel:e.onCancel})}attachListeners(){this.card&&(this.card.querySelector(".review-btn--cancel")?.addEventListener("click",()=>{this.onCancel?.(),this.hide()}),this.card.querySelector(".review-btn--submit")?.addEventListener("click",()=>this.handleSubmit()),this.card.querySelector("textarea")?.addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&(e.preventDefault(),this.handleSubmit())}))}async handleSubmit(){if(!this.card)return;let e=this.card.querySelector("textarea"),t=e.value.trim();if(!t)return;let i=this.card.querySelector(".review-btn--submit"),o=this.card.querySelector(".review-comment-error");i.disabled=!0,i.textContent="Submitting...",e.disabled=!0,o.style.display="none";try{await this.onSubmit?.(t),this.hide()}catch(
|
|
324
|
+
`,this.attachListeners(),this.shadowRoot.appendChild(this.card),this.card.querySelector("textarea")?.focus()}hide(){this.card?.remove(),this.card=null}showForGeneral(e){this.show({x:window.innerWidth/2-150,y:window.innerHeight/2-100,onSubmit:e.onSubmit,onCancel:e.onCancel})}attachListeners(){this.card&&(this.card.querySelector(".review-btn--cancel")?.addEventListener("click",()=>{this.onCancel?.(),this.hide()}),this.card.querySelector(".review-btn--submit")?.addEventListener("click",()=>this.handleSubmit()),this.card.querySelector("textarea")?.addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&(e.preventDefault(),this.handleSubmit())}))}async handleSubmit(){if(!this.card)return;let e=this.card.querySelector("textarea"),t=e.value.trim();if(!t)return;let i=this.card.querySelector(".review-btn--submit"),o=this.card.querySelector(".review-comment-error");i.disabled=!0,i.textContent="Submitting...",e.disabled=!0,o.style.display="none";try{await this.onSubmit?.(t),this.hide()}catch(a){i.disabled=!1,i.textContent="Submit",e.disabled=!1,o.textContent=a instanceof Error?a.message:"Failed to submit",o.style.display="block"}}};function d(){return window.location.pathname+window.location.search+window.location.hash}var g=class{constructor(e){this.onChange=e;r(this,"popstateHandler",null);r(this,"hashchangeHandler",null);r(this,"originalPushState",null);r(this,"originalReplaceState",null);r(this,"lastPageId");this.lastPageId=d()}start(){if(this.originalPushState)return;let e=()=>{let t=d();t!==this.lastPageId&&(this.lastPageId=t,this.onChange(t))};this.popstateHandler=e,window.addEventListener("popstate",this.popstateHandler),this.hashchangeHandler=e,window.addEventListener("hashchange",this.hashchangeHandler),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history),history.pushState=(...t)=>{this.originalPushState(...t),e()},history.replaceState=(...t)=>{this.originalReplaceState(...t),e()}}destroy(){this.popstateHandler&&window.removeEventListener("popstate",this.popstateHandler),this.hashchangeHandler&&window.removeEventListener("hashchange",this.hashchangeHandler),this.originalPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&(history.replaceState=this.originalReplaceState)}};var y=class{constructor(e,t,i){this.token=e;this.shadowRoot=t;this.initData=i;r(this,"pinManager");r(this,"commentCard");r(this,"nextPinNumber");r(this,"pendingPinNumber",null);r(this,"promptEl",null);r(this,"toolbarEl",null);r(this,"clickHandler",null);r(this,"pageListener",null);this.pinManager=new u,this.commentCard=new x(t),this.nextPinNumber=i.nextPinNumber}async init(){document.body.style.cursor="crosshair",this.pinManager.mount(),this.showPrompt(),this.renderToolbar(),await this.loadExistingPins(),this.pinManager.filterByPage(d()),this.pageListener=new g(e=>{this.pinManager.filterByPage(e)}),this.pageListener.start(),this.clickHandler=e=>this.handleClick(e),document.addEventListener("click",this.clickHandler,!0)}showPrompt(){this.promptEl=document.createElement("div"),this.promptEl.className="review-prompt",this.promptEl.innerHTML=`
|
|
325
325
|
<h3 style="margin:0 0 8px;font-size:16px;">Click anywhere to leave feedback</h3>
|
|
326
326
|
<p style="margin:0;color:#666;font-size:14px;">Drop numbered pins on elements you want to comment on</p>
|
|
327
327
|
`,this.shadowRoot.appendChild(this.promptEl),setTimeout(()=>this.dismissPrompt(),5e3)}dismissPrompt(){this.promptEl&&(this.promptEl.remove(),this.promptEl=null)}renderToolbar(){this.toolbarEl=document.createElement("div"),this.toolbarEl.className="review-toolbar",this.updateToolbar(),this.shadowRoot.appendChild(this.toolbarEl)}updateToolbar(){if(!this.toolbarEl)return;let e=this.nextPinNumber-1;this.toolbarEl.innerHTML=`
|
|
328
328
|
<span style="font-weight:500;">${this.initData.session.name}</span>
|
|
329
329
|
<span style="opacity:0.7;">${e} pin${e!==1?"s":""}</span>
|
|
330
330
|
<button class="review-btn review-btn--submit" style="margin-left:auto;padding:6px 12px;font-size:13px;">General Comment</button>
|
|
331
|
-
`,this.toolbarEl.querySelector("button")?.addEventListener("click",t=>{t.stopPropagation(),this.handleGeneralComment()})}async loadExistingPins(){try{let e=await
|
|
332
|
-
<span style="font-weight:500;">Triage Mode</span>
|
|
333
|
-
<span style="opacity:0.7;">${e} pin${e!==1?"s":""}</span>
|
|
334
|
-
`,this.shadowRoot.appendChild(this.toolbarEl)}handlePinClick(e,t){this.hideTooltip(),this.pinManager.highlightPin(e),this.showTooltipForPin(e,t.clientX+16,t.clientY-10)}showTooltipForPin(e,t,i){this.hideTooltip();let o=this.comments.find(d=>d.pinNumber===e);if(!o)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className="review-tooltip";let s=new Date(o.createdAt).toLocaleString(),a=document.createElement("div");if(a.style.cssText="font-weight:500;margin-bottom:4px;",a.textContent=`Pin #${e}`,this.tooltipEl.appendChild(a),o.reviewerName){let d=document.createElement("div");d.style.cssText="font-size:11px;opacity:0.7;margin-bottom:2px;",d.textContent=o.reviewerName,this.tooltipEl.appendChild(d)}let m=document.createElement("div");m.style.cssText="margin-bottom:4px;",m.textContent=o.commentText||"(no text)",this.tooltipEl.appendChild(m);let c=document.createElement("div");c.style.cssText="font-size:11px;opacity:0.7;",c.textContent=s,this.tooltipEl.appendChild(c);let L=t??window.innerWidth/2,S=i??window.innerHeight/3;this.tooltipEl.style.position="fixed",this.tooltipEl.style.left=`${Math.min(L,window.innerWidth-300)}px`,this.tooltipEl.style.top=`${Math.min(S,window.innerHeight-150)}px`,this.shadowRoot.appendChild(this.tooltipEl);let C=d=>{d.target!==this.tooltipEl&&!this.tooltipEl?.contains(d.target)&&(this.hideTooltip(),this.pinManager.clearHighlight(),document.removeEventListener("click",C,!0))};setTimeout(()=>document.addEventListener("click",C,!0),0)}autoFocusPin(){let t=new URLSearchParams(window.location.search).get("pin");if(!t)return;let i=Number(t);if(!i)return;let o=this.comments.find(c=>c.pinNumber===i);if(!o?.pinData)return;let s=document.documentElement,a=o.pinData.pinX/100*s.scrollWidth,m=o.pinData.pinY/100*s.scrollHeight;window.scrollTo({left:a-window.innerWidth/2,top:m-window.innerHeight/2,behavior:"smooth"}),setTimeout(()=>{this.pinManager.highlightPin(i),this.showTooltipForPin(i)},500)}hideTooltip(){this.tooltipEl?.remove(),this.tooltipEl=null}destroy(){this.pinClickHandler&&document.removeEventListener("click",this.pinClickHandler,!0),this.hideTooltip(),this.toolbarEl?.remove(),this.pinManager.destroy()}};var x=class{constructor(e={}){r(this,"root");r(this,"shadow");r(this,"mode",null);r(this,"_isDestroyed",!1);this.root=document.createElement("div"),this.root.id="ourroadmaps-review",this.shadow=this.root.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=M,this.shadow.appendChild(t),document.body.appendChild(this.root)}async init(){let e=new URLSearchParams(window.location.search),t=e.get("review"),i=e.get("triage");if(t)try{let o=await y(t);this.mode=new b(t,this.shadow,o),await this.mode.init()}catch(o){o instanceof l&&this.showErrorOverlay(o.code==="expired"?"This feedback session has expired":"This review link is no longer valid")}else if(i)try{await y(i),this.mode=new w(i,this.shadow),await this.mode.init()}catch(o){o instanceof l&&this.showErrorOverlay(o.code==="expired"?"This feedback session has expired":"This review link is no longer valid")}}showErrorOverlay(e){let t=document.createElement("div");t.className="review-expired-overlay",t.innerHTML=`
|
|
331
|
+
`,this.toolbarEl.querySelector("button")?.addEventListener("click",t=>{t.stopPropagation(),this.handleGeneralComment()})}async loadExistingPins(){try{let e=await w(this.token);for(let t of e)if(t.pinNumber!=null&&t.pinData){let i=t.commentText!=null;this.pinManager.addPin(t.pinNumber,t.pinData.pinX,t.pinData.pinY,i,t.pageUrl??"")}}catch{}}handleClick(e){if(e.composedPath().some(a=>a instanceof HTMLElement&&a.closest?.("#ourroadmaps-review"))||this.pendingPinNumber!=null)return;this.dismissPrompt();let i=$(e.clientX,e.clientY),o=this.nextPinNumber;this.pinManager.addPin(o,i.pinX,i.pinY,!0,d()),this.pendingPinNumber=o,this.commentCard.show({x:e.clientX,y:e.clientY,onSubmit:async a=>{await M(this.token,{commentText:a,pinNumber:o,pinData:i,pageUrl:d()}),this.pendingPinNumber=null,this.nextPinNumber++,this.updateToolbar(),this.showToast("Comment saved")},onCancel:()=>{this.pinManager.removePin(o),this.pendingPinNumber=null}}),e.preventDefault(),e.stopPropagation()}handleGeneralComment(){this.pendingPinNumber==null&&this.commentCard.showForGeneral({onSubmit:async e=>{await M(this.token,{commentText:e,pinNumber:null,pinData:null,pageUrl:d()}),this.showToast("Comment saved")},onCancel:()=>{}})}showToast(e){let t=document.createElement("div");t.className="review-toast",t.textContent=e,this.shadowRoot.appendChild(t),setTimeout(()=>t.remove(),2500)}destroy(){document.body.style.cursor="",this.clickHandler&&document.removeEventListener("click",this.clickHandler,!0),this.pageListener?.destroy(),this.dismissPrompt(),this.toolbarEl?.remove(),this.commentCard.hide(),this.pinManager.destroy()}};var J="ourroadmaps:token";function N(){try{sessionStorage.removeItem(J)}catch{}}var E=class{constructor(e,t){this.token=e;this.shadowRoot=t;r(this,"pinManager");r(this,"toolbarEl",null);r(this,"tooltipEl",null);r(this,"comments",[]);r(this,"pinClickHandler",null);r(this,"pageListener",null);r(this,"showAllPages",!1);this.pinManager=new u}async init(){this.pinManager.mount();try{this.comments=await w(this.token);for(let e of this.comments)e.pinNumber!=null&&e.pinData&&this.pinManager.addPin(e.pinNumber,e.pinData.pinX,e.pinData.pinY,!0,e.pageUrl??"")}catch{}this.pinManager.filterByPage(d()),this.renderToolbar(),this.pageListener=new g(e=>{this.showAllPages||this.pinManager.filterByPage(e),this.updateToolbar()}),this.pageListener.start(),this.pinClickHandler=e=>{let t=e.target;if(t.classList?.contains("review-pin")){let i=Number(t.dataset.pinNumber);i&&this.handlePinClick(i,e)}},document.addEventListener("click",this.pinClickHandler,!0),this.autoFocusPin()}renderToolbar(){this.toolbarEl=document.createElement("div"),this.toolbarEl.className="review-toolbar",this.updateToolbar(),this.shadowRoot.appendChild(this.toolbarEl)}updateToolbar(){if(!this.toolbarEl)return;let e=this.comments.filter(l=>l.pinNumber!=null).length,t=d(),i=this.pinManager.countForPage(t),o=new URL(t,window.location.origin),a=o.hash?`${o.pathname}${o.hash.split("?")[0]}`:o.pathname||"/";this.toolbarEl.innerHTML="";let s=document.createElement("span");s.style.fontWeight="500",s.textContent="Triage Mode",this.toolbarEl.appendChild(s);let h=document.createElement("span");h.style.opacity="0.7",this.showAllPages?h.textContent=`${e} pin${e!==1?"s":""}`:h.textContent=`${i} pin${i!==1?"s":""} on ${a} (${e} total)`,this.toolbarEl.appendChild(h);let c=document.createElement("button");c.className="review-btn review-btn--submit",c.style.cssText="margin-left:auto;padding:6px 12px;font-size:13px;",c.textContent=this.showAllPages?"This page":"All pages",c.addEventListener("click",l=>{l.stopPropagation(),this.togglePageFilter()}),this.toolbarEl.appendChild(c)}togglePageFilter(){this.showAllPages=!this.showAllPages,this.showAllPages?this.pinManager.showAll():this.pinManager.filterByPage(d()),this.updateToolbar()}handlePinClick(e,t){this.hideTooltip(),this.pinManager.highlightPin(e),this.showTooltipForPin(e,t.clientX+16,t.clientY-10)}showTooltipForPin(e,t,i){this.hideTooltip();let o=this.comments.find(p=>p.pinNumber===e);if(!o)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className="review-tooltip";let a=new Date(o.createdAt).toLocaleString(),s=document.createElement("div");if(s.style.cssText="font-weight:500;margin-bottom:4px;",s.textContent=`Pin #${e}`,this.tooltipEl.appendChild(s),o.reviewerName){let p=document.createElement("div");p.style.cssText="font-size:11px;opacity:0.7;margin-bottom:2px;",p.textContent=o.reviewerName,this.tooltipEl.appendChild(p)}let h=document.createElement("div");h.style.cssText="margin-bottom:4px;",h.textContent=o.commentText||"(no text)",this.tooltipEl.appendChild(h);let c=document.createElement("div");c.style.cssText="font-size:11px;opacity:0.7;",c.textContent=a,this.tooltipEl.appendChild(c);let l=o.pageUrl??"";if(l&&l!==d()){let p=document.createElement("div");p.style.cssText="margin-top:6px;padding-top:6px;border-top:1px solid rgba(255,255,255,0.2);font-size:12px;";let C=document.createElement("span");C.style.opacity="0.7",C.textContent=`Page: ${l.split("?")[0].split("#")[0]||"/"} \u2014 `,p.appendChild(C);let f=document.createElement("a");f.style.cssText="color:#a78bfa;cursor:pointer;text-decoration:underline;pointer-events:auto;",f.textContent="Navigate there?",f.addEventListener("click",U=>{U.stopPropagation(),this.navigateToPin(l,e)}),p.appendChild(f),this.tooltipEl.appendChild(p),this.tooltipEl.style.pointerEvents="auto"}let T=t??window.innerWidth/2,I=i??window.innerHeight/3;this.tooltipEl.style.position="fixed",this.tooltipEl.style.left=`${Math.min(T,window.innerWidth-300)}px`,this.tooltipEl.style.top=`${Math.min(I,window.innerHeight-150)}px`,this.shadowRoot.appendChild(this.tooltipEl);let H=p=>{p.target!==this.tooltipEl&&!this.tooltipEl?.contains(p.target)&&(this.hideTooltip(),this.pinManager.clearHighlight(),document.removeEventListener("click",H,!0))};setTimeout(()=>document.addEventListener("click",H,!0),0)}navigateToPin(e,t){this.hideTooltip(),this.pinManager.clearHighlight();let i=new URL(e,window.location.origin);i.searchParams.set("pin",String(t)),window.location.href=i.toString()}autoFocusPin(){let t=new URLSearchParams(window.location.search).get("pin");if(!t)return;let i=Number(t);if(!i)return;let o=this.comments.find(l=>l.pinNumber===i);if(!o?.pinData)return;let a=o.pageUrl??"";if(a){let l=new URL(window.location.href);l.searchParams.delete("pin");let T=l.pathname+l.search+l.hash;if(a!==T){this.navigateToPin(a,i);return}}this.pinManager.showAll(),this.showAllPages=!0,this.updateToolbar();let s=document.documentElement,h=o.pinData.pinX/100*s.scrollWidth,c=o.pinData.pinY/100*s.scrollHeight;window.scrollTo({left:h-window.innerWidth/2,top:c-window.innerHeight/2,behavior:"smooth"}),setTimeout(()=>{this.pinManager.highlightPin(i),this.showTooltipForPin(i)},500)}hideTooltip(){this.tooltipEl?.remove(),this.tooltipEl=null}destroy(){this.pinClickHandler&&document.removeEventListener("click",this.pinClickHandler,!0),this.pageListener?.destroy(),this.hideTooltip(),this.toolbarEl?.remove(),this.pinManager.destroy()}};var P=class{constructor(e={}){r(this,"root");r(this,"shadow");r(this,"mode",null);r(this,"_isDestroyed",!1);this.root=document.createElement("div"),this.root.id="ourroadmaps-review",this.shadow=this.root.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=D,this.shadow.appendChild(t),document.body.appendChild(this.root)}async init(e,t){if(!e||!t){let i=new URLSearchParams(window.location.search),o=i.get("review"),a=i.get("triage");if(o)e="review",t=o;else if(a)e="triage",t=a;else return}if(e==="review")try{let i=await L(t);this.mode=new y(t,this.shadow,i),await this.mode.init()}catch(i){i instanceof m&&(N(),this.showErrorOverlay(i.code==="expired"?"This feedback session has expired":"This review link is no longer valid"))}else if(e==="triage")try{await L(t),this.mode=new E(t,this.shadow),await this.mode.init()}catch(i){i instanceof m&&(N(),this.showErrorOverlay(i.code==="expired"?"This feedback session has expired":"This review link is no longer valid"))}}showErrorOverlay(e){let t=document.createElement("div");t.className="review-expired-overlay",t.innerHTML=`
|
|
335
332
|
<div class="review-expired-card">
|
|
336
333
|
<h2 style="margin:0 0 8px;font-size:18px;">Session Unavailable</h2>
|
|
337
334
|
<p style="margin:0;color:#666;font-size:14px;">${e}</p>
|
|
338
335
|
<p style="margin:12px 0 0;color:#999;font-size:13px;">Contact the prototype owner for a new link.</p>
|
|
339
336
|
</div>
|
|
340
|
-
`,this.shadow.appendChild(t),document.body.style.filter="grayscale(0.8)"}destroy(){this._isDestroyed||(this._isDestroyed=!0,this.mode?.destroy(),this.root.remove(),document.body.style.filter="")}};return
|
|
337
|
+
`,this.shadow.appendChild(t),document.body.style.filter="grayscale(0.8)"}destroy(){this._isDestroyed||(this._isDestroyed=!0,this.mode?.destroy(),this.root.remove(),document.body.style.filter="")}};return W(K);})();
|
|
341
338
|
//# sourceMappingURL=review.global.js.map
|