@markupai/sidebar-adapter 1.3.2 → 1.4.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.
package/dist/main.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),V=["text/plain","text/markdown","text/html","application/dita+xml"],K={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},X=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),q=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},v=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function Z(e){return e instanceof v}var A={TextLookupError:e=>new v(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in A?A[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=()=>{},T=class{_promise;[Symbol.toStringTag]="Promise";resolve=P;reject=P;constructor(){this._promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}},R={timeout:1e4},C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...R,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,o=new T,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},a);this.promisesByID[r]={promise:o,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),o}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(i in this.receiversByName){const o=this.receiversByName[i];try{if(!Array.isArray(r))throw new Error(`IPC: Expected array of arguments but got ${typeof r}`);const a=await o(...r),s={type:"response",id:t,name:i,data:a};this.postMessage(s)}catch(a){let s=JSON.stringify(a,Object.getOwnPropertyNames(a));const l=JSON.parse(s);(l.message===void 0||l.message==="")&&(s=JSON.stringify({message:a instanceof Error?a.message:String(a),name:a instanceof Error?a.name:void 0}));const c={type:"error",id:t,name:i,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${i}`),a={type:"error",id:t,name:i,errorJSON:JSON.stringify({message:o.message,name:o.name})};this.postMessage(a)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(i));r.reject(a)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},O=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async onAgenticIssueStatusChanged(e,t,i){await this.ipc.call("onAgenticIssueStatusChanged",e,t,i)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},Q=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new O(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},D=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,o="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await r(e,t,i)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},_=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new D(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ee=`
1
+ (function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),K=["text/plain","text/markdown","text/html","application/dita+xml"],X={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0,multiAgent:!1},q=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),Z=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},A=class V extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,V.prototype)}};function Q(e){return e instanceof A}var v={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in v?v[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=":",R=/^[a-z][a-z0-9-]*$/;function ee(e){const t=e.indexOf(P);return t<=0||t===e.length-1?!1:R.test(e.slice(0,t))}function te(e,t){const i=e.trim().toLowerCase(),r=t.trim();if(!R.test(i))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(r.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${i}${P}`;return r.startsWith(a)?r:`${a}${r}`}var T=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,i;super((r,a)=>{t=r,i=a,e(r,a)}),this.resolve=t,this.reject=i}},O={timeout:1e4};function ie(e){const t=JSON.stringify(e,Object.getOwnPropertyNames(e)),i=JSON.parse(t);return i.message===void 0||i.message===""?JSON.stringify({message:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:void 0}):t}var C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...O,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,a=new T,o=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(o)}ms`);a.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},o);this.promisesByID[r]={promise:a,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),a}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(!(i in this.receiversByName)){const o=new Error(`No receiver registered for: ${i}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:i,errorJSON:s});return}const a=this.receiversByName[i];try{if(!Array.isArray(r))throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);const o=await a(...r),s={type:"response",id:t,name:i,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:i,errorJSON:ie(o)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:a}=this.promisesByID[t];clearTimeout(a);try{const o=E(JSON.parse(i));r.reject(o)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},D=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async onAgenticIssueStatusChanged(e,t,i){await this.ipc.call("onAgenticIssueStatusChanged",e,t,i)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},re=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new D(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,a="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=a,this.ipc=new C(o=>{this.iframe.contentWindow?.postMessage(o,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{if(!this.plugin.showDialog)throw new Error("SidebarIPCAdapter: host does not implement showDialog");await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{if(!this.plugin.closeDialog)throw new Error("SidebarIPCAdapter: host does not implement closeDialog");await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await r(e,t,i)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},L=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new _(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ne=`
2
2
  <div class="sidebar-load-overlay-card">
3
3
  <div class="sidebar-load-overlay-title">Sidebar failed to load</div>
4
4
  <div class="sidebar-load-overlay-description">Check your connection or try again.</div>
@@ -19,7 +19,7 @@
19
19
  <span>Retry</span>
20
20
  </button>
21
21
  </div>
22
- `,te=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ee;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},L="markupai-sidebar-load-overlay-styles",ie=`
22
+ `,ae=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ne;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},M="markupai-sidebar-load-overlay-styles",oe=`
23
23
  :root {
24
24
  --background: #f5f5f4;
25
25
  --foreground: #333332;
@@ -111,7 +111,7 @@
111
111
  box-shadow: 0 0 0 2px
112
112
  color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
113
113
  }
114
- `,re=e=>{const t=e??document;if(t.getElementById(L))return;const i=t.createElement("style");i.id=L,i.textContent=ie,t.head.appendChild(i)},ne=8e3,ae=12e3,M=(e,t,i={})=>{re(e.ownerDocument);const{sidebarUrl:r,targetOrigin:o,timeoutMs:a=ne,retryIntervalMs:s=ae,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,Ae=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:F}=te();e.appendChild(w);let f=!1,I,p;const u=d=>{w.style.display=d?"flex":"none"};u(!1);const y=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},j=()=>{y(),I=globalThis.setTimeout(()=>{f||u(!0)},a)},$=d=>{const m=d?.preserveOverlay??!0;f=!1,m||u(!1),t.src=h(),j()},Ce=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||$({preserveOverlay:!0})},s))},G=()=>{p&&(globalThis.clearInterval(p),p=void 0)},W=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const m=Ae();m!=="*"&&d.origin!==m||(f=!0,y(),G(),u(!1))},Y=()=>{y(),u(!0)},z=()=>{$()};return F.addEventListener("click",z),t.addEventListener("error",Y),c.addEventListener("message",W),j(),Ce(),()=>{y(),G(),t.removeEventListener("error",Y),c.removeEventListener("message",W),F.removeEventListener("click",z),w.remove()}},k="Markup AI Sidebar",N="clipboard-read; clipboard-write",oe="markupai.sidebarNextGen.overrideUrl",se="https://sidebar.markup.ai/";function le(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var H="markupai.sidebarNextGen.authOverride";function ce(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(H)?.trim();if(!i)return e;const r=JSON.parse(i);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function de(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function ge(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function pe(e){const{iframe:t,iframeMount:i}=e;if(t!==void 0&&i!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(i===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:o,allow:a=N}=i,s=document.createElement("iframe");return s.title=k,s.src=o,a&&s.setAttribute("allow",a),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ue(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=pe(e),l=i!==void 0?M(i,a,r??{}):null;if(t!==void 0){const c=new _(t,a,o);return{iframe:a,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:a,adapter:null,destroy:()=>{l?.(),s?.()}}}var b="sidebarContainer",U="markupai-sidebar-host-shell-styles";function B(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);return e}function S(e=b){const t=B(e);return`
114
+ `,se=e=>{const t=e??document;if(t.getElementById(M))return;const i=t.createElement("style");i.id=M,i.textContent=oe,t.head.appendChild(i)},le=8e3,ce=12e3,k=(e,t,i={})=>{se(e.ownerDocument);const{sidebarUrl:r,targetOrigin:a,timeoutMs:o=le,retryIntervalMs:s=ce,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,we=()=>{if(a)return a;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:j}=ae();e.appendChild(w);let f=!1,I,p;const u=d=>{w.style.display=d?"flex":"none"};u(!1);const m=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},$=()=>{m(),I=globalThis.setTimeout(()=>{f||u(!0)},o)},W=d=>{const y=d?.preserveOverlay??!0;f=!1,y||u(!1),t.src=h(),$()},Ee=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||W({preserveOverlay:!0})},s))},G=()=>{p&&(globalThis.clearInterval(p),p=void 0)},z=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const y=we();y!=="*"&&d.origin!==y||(f=!0,m(),G(),u(!1))},J=()=>{m(),u(!0)},Y=()=>{W()};return j.addEventListener("click",Y),t.addEventListener("error",J),c.addEventListener("message",z),$(),Ee(),()=>{m(),G(),t.removeEventListener("error",J),c.removeEventListener("message",z),j.removeEventListener("click",Y),w.remove()}},N="Markup AI Sidebar",H="clipboard-read; clipboard-write",de="markupai.sidebarNextGen.overrideUrl",ge="https://sidebar.markup.ai/";function pe(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var U="markupai.sidebarNextGen.authOverride";function ue(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(U)?.trim();if(!i)return e;const r=JSON.parse(i);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function he(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function fe(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function Ie(e){const{iframe:t,iframeMount:i}=e;if(t!==void 0&&i!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(i===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:a,allow:o=H}=i,s=document.createElement("iframe");return s.title=N,s.src=a,o&&s.setAttribute("allow",o),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function me(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=Ie(e),l=i!==void 0?k(i,o,r??{}):null;if(t!==void 0){const c=new L(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var b="sidebarContainer",B="markupai-sidebar-host-shell-styles";function x(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(String.raw`sidebar host shell: containerId must match /^[a-zA-Z_][\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);return e}function S(e=b){const t=x(e);return`
115
115
  html {
116
116
  height: 100%;
117
117
  }
@@ -133,17 +133,17 @@ body {
133
133
  margin: 0;
134
134
  display: block;
135
135
  }
136
- `.trim()}var he=S();function fe(e){return e instanceof Document?e:e.ownerDocument}function Ie(e,t,i){if(!t||e.getElementById(U))return;const r=e.createElement("style");r.id=U,r.textContent=S(i),e.head.appendChild(r)}function ye(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=b,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=fe(t);Ie(o,r,i);const a=t instanceof Document?o.getElementById(i):t.querySelector(`#${B(i)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=i,t.appendChild(l),l}const s=o.createElement("div");return s.id=i,o.body.appendChild(s),s}function x(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function me(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?x():"",i].filter(h=>h.trim().length>0).join(`
136
+ `.trim()}var ye=S();function Ae(e){return e instanceof Document?e:e.ownerDocument}function ve(e,t,i){if(!t||e.getElementById(B))return;const r=e.createElement("style");r.id=B,r.textContent=S(i),e.head.appendChild(r)}function Ce(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=b,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const a=Ae(t);ve(a,r,i);const o=t instanceof Document?a.getElementById(i):t.querySelector(`#${x(i)}`);if(o instanceof HTMLElement&&(t instanceof Document||t.contains(o)))return o;if(!(t instanceof Document)){const l=a.createElement("div");return l.id=i,t.appendChild(l),l}const s=a.createElement("div");return s.id=i,a.body.appendChild(s),s}function F(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function be(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?F():"",i].filter(h=>h.trim().length>0).join(`
137
137
  `);return`<!DOCTYPE html>
138
138
  <html ${s}>
139
139
  <head>
140
140
  <base target="_top" />
141
141
  <meta charset="UTF-8" />
142
- <title>${ve(t)}</title>${c?`
142
+ <title>${Se(t)}</title>${c?`
143
143
  ${c}`:""}
144
144
  </head>
145
145
  <body ${l}>
146
- ${o}
146
+ ${a}
147
147
  </body>
148
148
  </html>
149
- `}function ve(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=H,n.DEFAULT_IPC_CONFIG=R,n.DEFAULT_SIDEBAR_CONFIG=K,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=g,n.PluginAdapter=Q,n.PluginIPCAdapter=O,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=se,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=he,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=N,n.SIDEBAR_IFRAME_DEFAULT_TITLE=k,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=oe,n.SidebarAdapter=_,n.SidebarIPCAdapter=D,n.TEXT_MIME_TYPES=V,n.TextLookupError=v,n.assertSidebarHostAdapter=ge,n.buildSidebarHostHtmlDocument=me,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=x,n.createSidebarHost=ue,n.ensureSidebarHostShell=ye,n.getAuthConfigWithOverride=ce,n.getSidebarBaseUrlWithOverride=le,n.ipcErrorReconstructors=A,n.isIntegrationSettingField=q,n.isIntegrationSettingsSchema=X,n.isTextLookupError=Z,n.reconstructError=E,n.setupSidebarLoadOverlay=M,n.sidebarPostMessageTargetOrigin=de});
149
+ `}function Se(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=U,n.DEFAULT_IPC_CONFIG=O,n.DEFAULT_SIDEBAR_CONFIG=X,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=g,n.PluginAdapter=re,n.PluginIPCAdapter=D,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=ge,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=ye,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=H,n.SIDEBAR_IFRAME_DEFAULT_TITLE=N,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=de,n.SidebarAdapter=L,n.SidebarIPCAdapter=_,n.TEXT_MIME_TYPES=K,n.TextLookupError=A,n.assertSidebarHostAdapter=fe,n.buildDocumentReference=te,n.buildSidebarHostHtmlDocument=be,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=F,n.createSidebarHost=me,n.ensureSidebarHostShell=Ce,n.getAuthConfigWithOverride=ue,n.getSidebarBaseUrlWithOverride=pe,n.ipcErrorReconstructors=v,n.isDocumentReference=ee,n.isIntegrationSettingField=Z,n.isIntegrationSettingsSchema=q,n.isTextLookupError=Q,n.reconstructError=E,n.setupSidebarLoadOverlay=k,n.sidebarPostMessageTargetOrigin=he});
@@ -38,8 +38,16 @@ export type ContentReplacement = {
38
38
  * Content information including the content, document reference, optional document name, and optional mime type
39
39
  * The integration must provide content and documentReference - documentName and mimeType are optional
40
40
  *
41
- * - documentReference: A unique identifier for the document (e.g., URL, file path, or document ID).
42
- * Required because the API uses it to track a document across scans.
41
+ * - documentReference: A unique identifier for the document, used to track it across scans.
42
+ * Compose it with `buildDocumentReference(prefix, id)`: you pick a prefix naming your
43
+ * platform and supply an id that is stable for the document. The `<prefix>:<id>` format is
44
+ * shared with every other Markup surface, so the same document correlates across products,
45
+ * and the Markup session id's document component is derived from it.
46
+ *
47
+ * Choose the prefix once and never change it — it is part of the document's identity, and
48
+ * changing it re-keys every document you have checked. Use the same reference for a whole
49
+ * document and for a selection within it. A bare, unprefixed value is still accepted and
50
+ * behaves as before; it simply cannot be correlated with the same document seen elsewhere.
43
51
  * - documentName: A human-readable name/title for the document (e.g., "My Report.docx").
44
52
  * Optional; when absent, the sidebar will attempt to derive it from documentReference if it
45
53
  * contains a filename with extension.
@@ -65,6 +73,18 @@ export interface ContentInfo {
65
73
  */
66
74
  export type AuthConfigMediation = {
67
75
  type: "mediation";
76
+ /**
77
+ * Explicit Auth0 relay-connection slug for the mediation login flow. Set this
78
+ * when one login provider must serve several `integrationId`s — e.g. a single
79
+ * add-in spanning multiple editors that each report a distinct `integrationId`
80
+ * (for analytics / the `x-integration-id` header / settings storage) but share
81
+ * one Auth0 relay connection. Example: `provider: "microsoft-365"` while
82
+ * `integrationId` is `"markupai-m365-word"` / `"markupai-m365-excel"` / ….
83
+ *
84
+ * When omitted, the sidebar derives the provider from `integrationId` (via its
85
+ * legacy compat map). Only meaningful for `type: "mediation"`.
86
+ */
87
+ provider?: string;
68
88
  };
69
89
  export type AuthConfigPopup = {
70
90
  type: "popup";
@@ -83,10 +103,45 @@ export type PluginStatusType = "error" | "warning" | "info";
83
103
  * Configuration for the sidebar
84
104
  */
85
105
  export interface SidebarConfig {
106
+ /**
107
+ * Human-readable name of the underlying integration. **Display only** — shown
108
+ * verbatim to the user (e.g. on the sidebar's About page). Never derive a
109
+ * machine identifier from this string; use {@link SidebarConfig.integrationId}
110
+ * for that. Example: `"Madcap Flare Desktop"`.
111
+ */
86
112
  integrationName: string;
113
+ /**
114
+ * Version string of the host integration (the plugin/add-in build, not the
115
+ * sidebar or this adapter). Display only — e.g. shown on the sidebar's About
116
+ * page next to {@link SidebarConfig.integrationName}. Free-form; hosts typically
117
+ * pass their own package/build version such as `"1.4.2"`.
118
+ */
87
119
  integrationVersion: string;
120
+ /**
121
+ * Stable, machine-readable identifier for the integration. Used for everything
122
+ * non-display: the Auth0 mediation login provider, PostHog analytics keys, the
123
+ * `x-integration-id` API header, and per-integration settings storage. Should be
124
+ * a stable slug (lowercase, hyphenated, no spaces) that does not change between
125
+ * releases. Example: `"madcap-flare-desktop"`.
126
+ *
127
+ * Optional for backward compatibility: when omitted the sidebar falls back to
128
+ * `DEFAULT_SIDEBAR_CONFIG.integrationId` (`"markupai-sidebar-app"`). Hosts that
129
+ * use mediation login or want per-integration analytics/storage should set it.
130
+ */
88
131
  integrationId?: string;
132
+ /**
133
+ * Hide the promotional/upsell banner the sidebar shows by default. Set `true`
134
+ * for embedded hosts where the banner is inappropriate (e.g. Figma, Office task
135
+ * pane). Defaults to `false` when omitted.
136
+ */
89
137
  hideBanner?: boolean;
138
+ /**
139
+ * JavaScript source the sidebar runs inside a host-rendered dialog to close it
140
+ * (see {@link PluginInterface.showDialog}/`closeDialog`). Lets hosts that render
141
+ * dialog chrome themselves supply the exact close call for their environment
142
+ * (e.g. `google.script.host.close();`). Omit when the host closes dialogs
143
+ * through the normal `closeDialog` IPC.
144
+ */
90
145
  dialogClosingScript?: string;
91
146
  /**
92
147
  * Origin of the plugin/editor window where messages should be sent
@@ -105,6 +160,20 @@ export interface SidebarConfig {
105
160
  * If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false
106
161
  */
107
162
  supportCheckSelection?: boolean;
163
+ /**
164
+ * Whether the sidebar may run several agents concurrently in one check.
165
+ *
166
+ * When `false` or omitted (the default), only the Style agent is offered and
167
+ * run, and a check is dispatched as a single-agent run. When `true`, the
168
+ * sidebar offers every agent the organization is entitled to and fans the
169
+ * selected ones out through the parallel executor, streaming results per
170
+ * agent; each agent can then be cancelled independently of the others.
171
+ *
172
+ * The host flag and the organization's entitlement **intersect**: enabling
173
+ * this never grants access to an agent the organization does not have, and an
174
+ * entitled agent is never offered while this is `false`.
175
+ */
176
+ multiAgent?: boolean;
108
177
  /**
109
178
  * How the sidebar should run the Auth0 login flow. When omitted, the sidebar
110
179
  * falls back to heuristic strategy selection (iframe context, secure origin,
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;GAIG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,oBAAoB,yBAAyB;CAC9C;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,2GAKlB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,EA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BAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yGAAyG;IACzG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -33,19 +33,28 @@ export interface PluginInterface {
33
33
  */
34
34
  selectContent: (range: ContentRange) => Promise<void>;
35
35
  /**
36
- * Show a dialog in the editor
36
+ * Show a dialog in the editor.
37
+ *
38
+ * Optional: not every host embedding the sidebar has dialog support. Hosts
39
+ * without a dialog surface should omit this method (and `closeDialog`). The
40
+ * sidebar gates dialog workflows behind `SidebarConfig.useCheckPreviewDialog`,
41
+ * so a host that omits these should also leave that flag `false`.
42
+ *
37
43
  * @param dialogHtml - The HTML content of the dialog
38
44
  * @param width - Optional dialog width
39
45
  * @param height - Optional dialog height
40
46
  * @param title - Optional dialog title
41
47
  * @returns Promise that resolves when dialog is shown
42
48
  */
43
- showDialog: (dialogHtml: string, width?: number, height?: number, title?: string) => Promise<void>;
49
+ showDialog?: (dialogHtml: string, width?: number, height?: number, title?: string) => Promise<void>;
44
50
  /**
45
- * Close the dialog in the editor
51
+ * Close the dialog in the editor.
52
+ *
53
+ * Optional: see `showDialog`. Omit on hosts without dialog support.
54
+ *
46
55
  * @returns Promise that resolves when dialog is closed
47
56
  */
48
- closeDialog: () => Promise<void>;
57
+ closeDialog?: () => Promise<void>;
49
58
  /**
50
59
  * Replace multiple contents in the editor
51
60
  * @param replacements - Array of content replacements to apply
@@ -1 +1 @@
1
- {"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAEvC;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;;;OAKG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;;;;;;OAOG;IACH,UAAU,EAAE,CACV,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,KACX,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;OAGG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC;;;;OAIG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,kBAAkB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;;;OAIG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;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;;;;;;;;;;OAWG;IACH,2BAA2B,CAAC,EAAE,CAC5B,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE,6BAA6B,KAChC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markupai/sidebar-adapter",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Adapter package for MarkupAI Sidebar integration",
5
5
  "keywords": [
6
6
  "markupai",