@markupai/sidebar-adapter 2.2.0 → 2.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.
Files changed (35) hide show
  1. package/README.md +80 -6
  2. package/asyncapi.json +208 -49
  3. package/dist/adapters/index.d.ts +2 -2
  4. package/dist/adapters/pluginAdapter.d.ts +10 -2
  5. package/dist/adapters/pluginAdapter.d.ts.map +1 -1
  6. package/dist/adapters/sidebarAdapter.d.ts +2 -2
  7. package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
  8. package/dist/errors.d.ts +38 -1
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/ipc/call-signatures.d.ts +7 -2
  11. package/dist/ipc/call-signatures.d.ts.map +1 -1
  12. package/dist/ipc/deferred-promise.d.ts.map +1 -1
  13. package/dist/ipc/index.d.ts +8 -8
  14. package/dist/ipc/ipc-core.d.ts +2 -2
  15. package/dist/ipc/ipc-core.d.ts.map +1 -1
  16. package/dist/ipc/plugin-ipc-adapter.d.ts +11 -4
  17. package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
  18. package/dist/ipc/sidebar-build-info.d.ts +1 -1
  19. package/dist/ipc/sidebar-ipc-adapter.d.ts +4 -4
  20. package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
  21. package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -1
  22. package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -1
  23. package/dist/main.js +190 -136
  24. package/dist/main.umd.cjs +6 -6
  25. package/dist/sidebar-host/createSidebarHost.d.ts +4 -4
  26. package/dist/types/common.d.ts +30 -0
  27. package/dist/types/common.d.ts.map +1 -1
  28. package/dist/types/errors.d.ts +47 -0
  29. package/dist/types/errors.d.ts.map +1 -0
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/integrationSettings.d.ts.map +1 -1
  33. package/dist/types/pluginInterface.d.ts +29 -1
  34. package/dist/types/pluginInterface.d.ts.map +1 -1
  35. package/package.json +2 -2
package/dist/main.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(r,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(r=typeof globalThis<"u"?globalThis:r||self,g(r.main={}))})(this,function(r){Object.defineProperty(r,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})({}),q=["text/plain","text/markdown","text/html","application/dita+xml"],Z={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,supportCheckSelection:!0,multiAgent:!1,multiDocument:!1},Q=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),ee=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(n=>{if(typeof n!="object"||n===null)return!1;const i=n;return typeof i.value=="string"&&typeof i.label=="string"}):!1},P="2.2.0",y=class K extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,K.prototype)}};function te(e){return e instanceof y}var v={TextLookupError:e=>new y(e)};function R(e){const t=e.message??"",n=e.name,i=typeof n=="string"&&n in v?v[n]:void 0;return i?i(t,e):Object.assign(new Error(t),n?{name:n}:{})}var T=":",O=/^[a-z][a-z0-9-]*$/;function ne(e){const t=e.indexOf(T);return t<=0||t===e.length-1?!1:O.test(e.slice(0,t))}function ie(e,t){const n=e.trim().toLowerCase(),i=t.trim();if(!O.test(n))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(i.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${n}${T}`;return i.startsWith(a)?i:`${a}${i}`}var _=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,n;super((i,a)=>{t=i,n=a,e(i,a)}),this.resolve=t,this.reject=n}},D={timeout:1e4};function re(e){const t=typeof e=="object"&&e!==null?JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e))):{},n=e instanceof Error?e.message:String(e),i=typeof t.message=="string"&&t.message!==""?t.message:n,a=e instanceof Error?e.name:void 0,o=typeof t.name=="string"?t.name:a;return JSON.stringify({...t,message:i,...o!==void 0&&{name:o}})}var C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...D,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...n){const i=this.currentID++,a=new _,o=t.timeout??this.config.timeout,s=setTimeout(()=>{if(i 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,i)}},o);this.promisesByID[i]={promise:a,timeoutId:s};const l={type:"call",id:i,name:e,data:n};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:n,data:i}=e;if(!(n in this.receiversByName)){const o=new Error(`No receiver registered for: ${n}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:n,errorJSON:s});return}const a=this.receiversByName[n];try{if(!Array.isArray(i))throw new TypeError(`IPC: Expected array of arguments but got ${typeof i}`);const o=await a(...i),s={type:"response",id:t,name:n,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:n,errorJSON:re(o)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:n,timeoutId:i}=this.promisesByID[t];clearTimeout(i),n.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:n}=e;if(t in this.promisesByID){const{promise:i,timeoutId:a}=this.promisesByID[t];clearTimeout(a);try{const o=JSON.parse(n),s=R(o);i.reject(s)}catch{i.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={}}},De=64,ae=new Set(["auto","prompt"]),b=(e,t)=>{const n=e[t];if(!(typeof n!="string"||n.length===0))return n.slice(0,64)};function oe(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const t=e,n=b(t,"version"),i=b(t,"commitHash");if(n===void 0||i===void 0)return null;const a={version:n,commitHash:i};typeof t.swControlled=="boolean"&&(a.swControlled=t.swControlled),ae.has(t.pwaUpdateMode)&&(a.pwaUpdateMode=t.pwaUpdateMode);const o=b(t,"adapterVersion");return o!==void 0&&(a.adapterVersion=o),a}function se(e){return typeof e!="string"||e.length===0?null:e.slice(0,64)}function Le(e,t){if(!e)return`getInitConfig from sidebar build unknown (no valid build report — sidebar predates build reporting; host adapter ${t})`;const n=[e.commitHash];return e.swControlled!==void 0&&n.push(e.swControlled?"sw-controlled":"network"),e.pwaUpdateMode&&n.push(`${e.pwaUpdateMode} update mode`),e.adapterVersion&&n.push(`sidebar adapter ${e.adapterVersion}`),n.push(`host adapter ${t}`),`getInitConfig from sidebar v${e.version} (${n.join(", ")})`}var L=class{ipc;sidebar;targetOrigin;latestHostAdapterVersion=null;constructor(e,t,n="*"){this.sidebar=e||{},this.targetOrigin=n,this.ipc=new C(i=>{window.parent.postMessage(i,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||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,n)=>{await e(t,n)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async(t,n)=>{await e(t,typeof n=="string"?n:null)})}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())}if(this.sidebar.onActiveDocumentChanged){const e=this.sidebar.onActiveDocumentChanged;this.ipc.receive("onActiveDocumentChanged",async t=>{await e(t)})}}async getInitConfig(e){const{hostAdapterVersion:t,...n}=e?await this.ipc.call("getInitConfig",{...e,adapterVersion:e.adapterVersion??"2.2.0"}):await this.ipc.call("getInitConfig");return this.latestHostAdapterVersion=se(t),n}getHostAdapterVersion(){return this.latestHostAdapterVersion}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t,n=null){await this.ipc.call("replaceContent",e,t,n)}async selectContent(e,t=null){await this.ipc.call("selectContent",e,t)}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t,n=null){await this.ipc.call("onAgenticAgentResults",e,t,n)}async onAgenticStreamComplete(e=null){await this.ipc.call("onAgenticStreamComplete",e)}async onAgenticIssueStatusChanged(e,t,n){await this.ipc.call("onAgenticIssueStatusChanged",e,t,n)}async onAgenticIssuesCleared(e=null){await this.ipc.call("onAgenticIssuesCleared",e)}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()}},le=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new L(e,t,n)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(e){return await this.ipcAdapter.getInitConfig(e)}getHostAdapterVersion(){return this.ipcAdapter.getHostAdapterVersion()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t,n=null){await this.ipcAdapter.replaceContent(e,t,n)}async selectContent(e,t=null){await this.ipcAdapter.selectContent(e,t)}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t,n=null){return this.ipcAdapter.onAgenticAgentResults(e,t,n)}onAgenticStreamComplete(e=null){return this.ipcAdapter.onAgenticStreamComplete(e)}onAgenticIssueStatusChanged(e,t,n){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,n)}onAgenticIssuesCleared(e=null){return this.ipcAdapter.onAgenticIssuesCleared(e)}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()}},M=class{ipc;plugin;iframe;window;targetOrigin;latestSidebarBuildInfo=null;constructor(e,t,n,i,a="*"){this.plugin=e,this.iframe=t,this.window=n??window,this.targetOrigin=a,this.ipc=new C(o=>{this.iframe.contentWindow?.postMessage(o,this.targetOrigin)},i),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async e=>{const t=oe(e);return this.latestSidebarBuildInfo=t,{...await this.plugin.getInitConfig(t??void 0),hostAdapterVersion:P}}),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,n)=>{await this.plugin.replaceContent(e,t,typeof n=="string"?n:null)}),this.ipc.receive("selectContent",async(e,t)=>{await this.plugin.selectContent(e,typeof t=="string"?t:null)}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t,n)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t,typeof n=="string"?n:null)}),this.ipc.receive("onAgenticStreamComplete",async e=>{const t=this.plugin.onAgenticStreamComplete;t&&await t(typeof e=="string"?e:null)}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,n)=>{const i=this.plugin.onAgenticIssueStatusChanged;if(i&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||n!=="user"&&n!=="host"))try{await i(e,t,n)}catch{}}),this.ipc.receive("onAgenticIssuesCleared",async e=>{const t=this.plugin.onAgenticIssuesCleared;if(t)try{await t(typeof e=="string"?e:null)}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,n)=>{await e(t,n)})}}async activateAgenticIssue(e,t=null){await this.ipc.call("activateAgenticIssue",e,t)}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")}async notifyActiveDocumentChanged(e){await this.ipc.call("onActiveDocumentChanged",e)}getSidebarBuildInfo(){return this.latestSidebarBuildInfo}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},k=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new M(e,t,n?.win,n?.config,n?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e,t=null){await this.ipcAdapter.activateAgenticIssue(e,t)}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()}async notifyActiveDocumentChanged(e){await this.ipcAdapter.notifyActiveDocumentChanged(e)}getSidebarBuildInfo(){return this.ipcAdapter.getSidebarBuildInfo()}configure(e){this.ipcAdapter.configure(e)}},ce=`
1
+ (function(r,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(r=typeof globalThis<"u"?globalThis:r||self,g(r.main={}))})(this,function(r){Object.defineProperty(r,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})({}),te=["text/plain","text/markdown","text/html","application/dita+xml"],ne={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,supportCheckSelection:!0,supportComments:!1,multiAgent:!1,multiDocument:!1},ie=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),re=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(n=>{if(typeof n!="object"||n===null)return!1;const i=n;return typeof i.value=="string"&&typeof i.label=="string"}):!1},R="2.4.0",h=class Q extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,Q.prototype)}},v=class ee extends h{name="ReplaceBatchError";applied;failed;constructor(t,n){super(t),this.applied=n.applied.map(i=>({start:i.start,end:i.end})),this.failed=n.failed.map(i=>T(i,i.message)),Object.setPrototypeOf(this,ee.prototype)}};function ae(e){return e instanceof v}function T(e,t){const n={start:e.start,end:e.end};return typeof t=="string"&&t.trim()!==""&&(n.message=t),n}function O(e){return Array.isArray(e)?e.flatMap(t=>{if(t===null||typeof t!="object")return[];const{start:n,end:i,message:a}=t;return typeof n!="number"||typeof i!="number"?[]:[{range:{start:n,end:i},message:a}]}):[]}function oe(e){return e instanceof h}var C={TextLookupError:e=>new h(e),ReplaceBatchError:(e,t)=>new v(e,{applied:O(t.applied).map(n=>n.range),failed:O(t.failed).map(n=>T(n.range,n.message))})};function _(e){const t=e.message??"",n=e.name,i=typeof n=="string"&&n in C?C[n]:void 0;return i?i(t,e):Object.assign(new Error(t),n?{name:n}:{})}var D=":",L=/^[a-z][a-z0-9-]*$/;function se(e){const t=e.indexOf(D);return t<=0||t===e.length-1?!1:L.test(e.slice(0,t))}function le(e,t){const n=e.trim().toLowerCase(),i=t.trim();if(!L.test(n))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(i.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${n}${D}`;return i.startsWith(a)?i:`${a}${i}`}var M=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,n;super((i,a)=>{t=i,n=a,e(i,a)}),this.resolve=t,this.reject=n}},B={timeout:1e4};function ce(e){const t=typeof e=="object"&&e!==null?Object.fromEntries(Object.getOwnPropertyNames(e).map(s=>[s,e[s]])):{},n=e instanceof Error?e.message:String(e),i=typeof t.message=="string"&&t.message!==""?t.message:n,a=e instanceof Error?e.name:void 0,o=typeof t.name=="string"?t.name:a;return JSON.stringify({...t,message:i,...o!==void 0&&{name:o}})}var b=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...B,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...n){const i=this.currentID++,a=new M,o=t.timeout??this.config.timeout,s=setTimeout(()=>{if(i 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,i)}},o);this.promisesByID[i]={promise:a,timeoutId:s};const l={type:"call",id:i,name:e,data:n};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:n,data:i}=e;if(!(n in this.receiversByName)){const o=new Error(`No receiver registered for: ${n}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:n,errorJSON:s});return}const a=this.receiversByName[n];try{if(!Array.isArray(i))throw new TypeError(`IPC: Expected array of arguments but got ${typeof i}`);const o=await a(...i),s={type:"response",id:t,name:n,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:n,errorJSON:ce(o)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:n,timeoutId:i}=this.promisesByID[t];clearTimeout(i),n.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:n}=e;if(t in this.promisesByID){const{promise:i,timeoutId:a}=this.promisesByID[t];clearTimeout(a);try{const o=JSON.parse(n),s=_(o);i.reject(s)}catch{i.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={}}},Ne=64,de=new Set(["auto","prompt"]),S=(e,t)=>{const n=e[t];if(!(typeof n!="string"||n.length===0))return n.slice(0,64)};function ge(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const t=e,n=S(t,"version"),i=S(t,"commitHash");if(n===void 0||i===void 0)return null;const a={version:n,commitHash:i};typeof t.swControlled=="boolean"&&(a.swControlled=t.swControlled),de.has(t.pwaUpdateMode)&&(a.pwaUpdateMode=t.pwaUpdateMode);const o=S(t,"adapterVersion");return o!==void 0&&(a.adapterVersion=o),a}function ue(e){return typeof e!="string"||e.length===0?null:e.slice(0,64)}function He(e,t){if(!e)return`getInitConfig from sidebar build unknown (no valid build report — sidebar predates build reporting; host adapter ${t})`;const n=[e.commitHash];return e.swControlled!==void 0&&n.push(e.swControlled?"sw-controlled":"network"),e.pwaUpdateMode&&n.push(`${e.pwaUpdateMode} update mode`),e.adapterVersion&&n.push(`sidebar adapter ${e.adapterVersion}`),n.push(`host adapter ${t}`),`getInitConfig from sidebar v${e.version} (${n.join(", ")})`}var k=class{ipc;sidebar;targetOrigin;latestHostAdapterVersion=null;constructor(e,t,n="*"){this.sidebar=e||{},this.targetOrigin=n,this.ipc=new b(i=>{window.parent.postMessage(i,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||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,n)=>{await e(t,n)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async(t,n)=>{await e(t,typeof n=="string"?n:null)})}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())}if(this.sidebar.onActiveDocumentChanged){const e=this.sidebar.onActiveDocumentChanged;this.ipc.receive("onActiveDocumentChanged",async t=>{await e(t)})}}async getInitConfig(e){const{hostAdapterVersion:t,...n}=e?await this.ipc.call("getInitConfig",{...e,adapterVersion:e.adapterVersion??"2.4.0"}):await this.ipc.call("getInitConfig");return this.latestHostAdapterVersion=ue(t),n}getHostAdapterVersion(){return this.latestHostAdapterVersion}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t,n=null){await this.ipc.call("replaceContent",e,t,n)}async selectContent(e,t=null){await this.ipc.call("selectContent",e,t)}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t,n=null){await this.ipc.call("onAgenticAgentResults",e,t,n)}async onAgenticStreamComplete(e=null){await this.ipc.call("onAgenticStreamComplete",e)}async onAgenticIssueStatusChanged(e,t,n){await this.ipc.call("onAgenticIssueStatusChanged",e,t,n)}async onAgenticIssuesCleared(e=null){await this.ipc.call("onAgenticIssuesCleared",e)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async addComment(e,t=null){await this.ipc.call("addComment",e,t)}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()}},pe=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new k(e,t,n)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(e){return await this.ipcAdapter.getInitConfig(e)}getHostAdapterVersion(){return this.ipcAdapter.getHostAdapterVersion()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t,n=null){await this.ipcAdapter.replaceContent(e,t,n)}async selectContent(e,t=null){await this.ipcAdapter.selectContent(e,t)}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t,n=null){return this.ipcAdapter.onAgenticAgentResults(e,t,n)}onAgenticStreamComplete(e=null){return this.ipcAdapter.onAgenticStreamComplete(e)}onAgenticIssueStatusChanged(e,t,n){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,n)}onAgenticIssuesCleared(e=null){return this.ipcAdapter.onAgenticIssuesCleared(e)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}addComment(e,t=null){return this.ipcAdapter.addComment(e,t)}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()}},N=class{ipc;plugin;iframe;window;targetOrigin;latestSidebarBuildInfo=null;constructor(e,t,n,i,a="*"){this.plugin=e,this.iframe=t,this.window=n??window,this.targetOrigin=a,this.ipc=new b(o=>{this.iframe.contentWindow?.postMessage(o,this.targetOrigin)},i),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async e=>{const t=ge(e);return this.latestSidebarBuildInfo=t,{...await this.plugin.getInitConfig(t??void 0),hostAdapterVersion:R}}),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,n)=>{await this.plugin.replaceContent(e,t,typeof n=="string"?n:null)}),this.ipc.receive("selectContent",async(e,t)=>{await this.plugin.selectContent(e,typeof t=="string"?t:null)}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t,n)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t,typeof n=="string"?n:null)}),this.ipc.receive("onAgenticStreamComplete",async e=>{const t=this.plugin.onAgenticStreamComplete;t&&await t(typeof e=="string"?e:null)}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,n)=>{const i=this.plugin.onAgenticIssueStatusChanged;if(i&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||n!=="user"&&n!=="host"))try{await i(e,t,n)}catch{}}),this.ipc.receive("onAgenticIssuesCleared",async e=>{const t=this.plugin.onAgenticIssuesCleared;if(t)try{await t(typeof e=="string"?e:null)}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.addComment){const e=this.plugin.addComment;this.ipc.receive("addComment",async(t,n)=>{await e(t,typeof n=="string"?n:null)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,n)=>{await e(t,n)})}}async activateAgenticIssue(e,t=null){await this.ipc.call("activateAgenticIssue",e,t)}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")}async notifyActiveDocumentChanged(e){await this.ipc.call("onActiveDocumentChanged",e)}getSidebarBuildInfo(){return this.latestSidebarBuildInfo}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},H=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new N(e,t,n?.win,n?.config,n?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e,t=null){await this.ipcAdapter.activateAgenticIssue(e,t)}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()}async notifyActiveDocumentChanged(e){await this.ipcAdapter.notifyActiveDocumentChanged(e)}getSidebarBuildInfo(){return this.ipcAdapter.getSidebarBuildInfo()}configure(e){this.ipcAdapter.configure(e)}},he=`
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
- `,de=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ce;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}},N="markupai-sidebar-load-overlay-styles",ge=`
22
+ `,fe=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=he;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}},U="markupai-sidebar-load-overlay-styles",me=`
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
- `,ue=e=>{const t=e??document;if(t.getElementById(N))return;const n=t.createElement("style");n.id=N,n.textContent=ge,t.head.appendChild(n)},pe=8e3,he=12e3,B=(e,t,n={})=>{ue(e.ownerDocument);const{sidebarUrl:i,targetOrigin:a,timeoutMs:o=pe,retryIntervalMs:s=he,messageListenWindow:l}=n,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>i??t.src,Oe=()=>{if(a)return a;try{return new URL(h()).origin}catch{return"*"}},{overlay:E,button:V}=de();e.appendChild(E);let f=!1,I,u;const p=d=>{E.style.display=d?"flex":"none"};p(!1);const m=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},G=()=>{m(),I=globalThis.setTimeout(()=>{f||p(!0)},o)},W=d=>{const A=d?.preserveOverlay??!0;f=!1,A||p(!1),t.src=h(),G()},_e=()=>{u||s<=0||(u=globalThis.setInterval(()=>{f||W({preserveOverlay:!0})},s))},z=()=>{u&&(globalThis.clearInterval(u),u=void 0)},Y=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const A=Oe();A!=="*"&&d.origin!==A||(f=!0,m(),z(),p(!1))},J=()=>{m(),p(!0)},X=()=>{W()};return V.addEventListener("click",X),t.addEventListener("error",J),c.addEventListener("message",Y),G(),_e(),()=>{m(),z(),t.removeEventListener("error",J),c.removeEventListener("message",Y),V.removeEventListener("click",X),E.remove()}},H="Markup AI Sidebar",U="clipboard-read; clipboard-write",fe="markupai.sidebarNextGen.overrideUrl",Ie="https://sidebar.markup.ai/";function me(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var x="markupai.sidebarNextGen.authOverride";function Ae(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const n=globalThis.localStorage.getItem(x)?.trim();if(!n)return e;const i=JSON.parse(n);return i!==null&&typeof i=="object"&&"type"in i&&(i.type==="mediation"||i.type==="popup")?i:e}catch{return e}}function ye(e,t){try{return new URL(e).origin}catch(n){return t?.onInvalidUrl?.(e,n),"*"}}function ve(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function Ce(e){const{iframe:t,iframeMount:n}=e;if(t!==void 0&&n!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(n===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:i,src:a,allow:o=U}=n,s=document.createElement("iframe");return s.title=H,s.src=a,o&&s.setAttribute("allow",o),i.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function be(e){const{plugin:t,loadOverlayContainer:n,loadOverlayOptions:i,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=Ce(e),l=n!==void 0?B(n,o,i??{}):null;if(t!==void 0){const c=new k(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var S="sidebarContainer",F="markupai-sidebar-host-shell-styles";function $(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 w(e=S){const t=$(e);return`
114
+ `,Ie=e=>{const t=e??document;if(t.getElementById(U))return;const n=t.createElement("style");n.id=U,n.textContent=me,t.head.appendChild(n)},ye=8e3,Ae=12e3,F=(e,t,n={})=>{Ie(e.ownerDocument);const{sidebarUrl:i,targetOrigin:a,timeoutMs:o=ye,retryIntervalMs:s=Ae,messageListenWindow:l}=n,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),f=()=>i??t.src,Be=()=>{if(a)return a;try{return new URL(f()).origin}catch{return"*"}},{overlay:P,button:z}=fe();e.appendChild(P);let m=!1,I,u;const p=d=>{P.style.display=d?"flex":"none"};p(!1);const y=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},Y=()=>{y(),I=globalThis.setTimeout(()=>{m||p(!0)},o)},J=d=>{const A=d?.preserveOverlay??!0;m=!1,A||p(!1),t.src=f(),Y()},ke=()=>{u||s<=0||(u=globalThis.setInterval(()=>{m||J({preserveOverlay:!0})},s))},X=()=>{u&&(globalThis.clearInterval(u),u=void 0)},K=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const A=Be();A!=="*"&&d.origin!==A||(m=!0,y(),X(),p(!1))},q=()=>{y(),p(!0)},Z=()=>{J()};return z.addEventListener("click",Z),t.addEventListener("error",q),c.addEventListener("message",K),Y(),ke(),()=>{y(),X(),t.removeEventListener("error",q),c.removeEventListener("message",K),z.removeEventListener("click",Z),P.remove()}},x="Markup AI Sidebar",$="clipboard-read; clipboard-write",ve="markupai.sidebarNextGen.overrideUrl",Ce="https://sidebar.markup.ai/";function be(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var j="markupai.sidebarNextGen.authOverride";function Se(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const n=globalThis.localStorage.getItem(j)?.trim();if(!n)return e;const i=JSON.parse(n);return i!==null&&typeof i=="object"&&"type"in i&&(i.type==="mediation"||i.type==="popup")?i:e}catch{return e}}function we(e,t){try{return new URL(e).origin}catch(n){return t?.onInvalidUrl?.(e,n),"*"}}function Ee(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function Pe(e){const{iframe:t,iframeMount:n}=e;if(t!==void 0&&n!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(n===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:i,src:a,allow:o=$}=n,s=document.createElement("iframe");return s.title=x,s.src=a,o&&s.setAttribute("allow",o),i.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function Re(e){const{plugin:t,loadOverlayContainer:n,loadOverlayOptions:i,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=Pe(e),l=n!==void 0?F(n,o,i??{}):null;if(t!==void 0){const c=new H(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var w="sidebarContainer",V="markupai-sidebar-host-shell-styles";function G(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 E(e=w){const t=G(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 Se=w();function we(e){return e instanceof Document?e:e.ownerDocument}function Ee(e,t,n){if(!t||e.getElementById(F))return;const i=e.createElement("style");i.id=F,i.textContent=w(n),e.head.appendChild(i)}function Pe(e){const{root:t=typeof document<"u"?document:void 0,containerId:n=S,includeDefaultStyles:i=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const a=we(t);Ee(a,i,n);const o=t instanceof Document?a.getElementById(n):t.querySelector(`#${$(n)}`);if(o instanceof HTMLElement&&(t instanceof Document||t.contains(o)))return o;if(!(t instanceof Document)){const l=a.createElement("div");return l.id=n,t.appendChild(l),l}const s=a.createElement("div");return s.id=n,a.body.appendChild(s),s}function j(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function Re(e){const{title:t="Markup AI Sidebar",headInnerHtml:n="",includePluginHostHead:i=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[i?j():"",n].filter(h=>h.trim().length>0).join(`
136
+ `.trim()}var Te=E();function Oe(e){return e instanceof Document?e:e.ownerDocument}function _e(e,t,n){if(!t||e.getElementById(V))return;const i=e.createElement("style");i.id=V,i.textContent=E(n),e.head.appendChild(i)}function De(e){const{root:t=typeof document<"u"?document:void 0,containerId:n=w,includeDefaultStyles:i=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const a=Oe(t);_e(a,i,n);const o=t instanceof Document?a.getElementById(n):t.querySelector(`#${G(n)}`);if(o instanceof HTMLElement&&(t instanceof Document||t.contains(o)))return o;if(!(t instanceof Document)){const l=a.createElement("div");return l.id=n,t.appendChild(l),l}const s=a.createElement("div");return s.id=n,a.body.appendChild(s),s}function W(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function Le(e){const{title:t="Markup AI Sidebar",headInnerHtml:n="",includePluginHostHead:i=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[i?W():"",n].filter(f=>f.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>${Te(t)}</title>${c?`
142
+ <title>${Me(t)}</title>${c?`
143
143
  ${c}`:""}
144
144
  </head>
145
145
  <body ${l}>
146
146
  ${a}
147
147
  </body>
148
148
  </html>
149
- `}function Te(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}r.ADAPTER_VERSION=P,r.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=x,r.DEFAULT_IPC_CONFIG=D,r.DEFAULT_SIDEBAR_CONFIG=Z,r.DeferredPromise=_,r.IPCCore=C,r.MimeType=g,r.PluginAdapter=le,r.PluginIPCAdapter=L,r.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=Ie,r.SIDEBAR_HOST_CONTAINER_ID=S,r.SIDEBAR_HOST_SHELL_CSS=Se,r.SIDEBAR_IFRAME_DEFAULT_ALLOW=U,r.SIDEBAR_IFRAME_DEFAULT_TITLE=H,r.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=fe,r.SidebarAdapter=k,r.SidebarIPCAdapter=M,r.TEXT_MIME_TYPES=q,r.TextLookupError=y,r.assertSidebarHostAdapter=ve,r.buildDocumentReference=ie,r.buildSidebarHostHtmlDocument=Re,r.buildSidebarHostShellCss=w,r.buildSidebarPluginHostHeadInnerHtml=j,r.createSidebarHost=be,r.ensureSidebarHostShell=Pe,r.getAuthConfigWithOverride=Ae,r.getSidebarBaseUrlWithOverride=me,r.ipcErrorReconstructors=v,r.isDocumentReference=ne,r.isIntegrationSettingField=ee,r.isIntegrationSettingsSchema=Q,r.isTextLookupError=te,r.reconstructError=R,r.setupSidebarLoadOverlay=B,r.sidebarPostMessageTargetOrigin=ye});
149
+ `}function Me(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}r.ADAPTER_VERSION=R,r.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=j,r.DEFAULT_IPC_CONFIG=B,r.DEFAULT_SIDEBAR_CONFIG=ne,r.DeferredPromise=M,r.IPCCore=b,r.MimeType=g,r.PluginAdapter=pe,r.PluginIPCAdapter=k,r.ReplaceBatchError=v,r.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=Ce,r.SIDEBAR_HOST_CONTAINER_ID=w,r.SIDEBAR_HOST_SHELL_CSS=Te,r.SIDEBAR_IFRAME_DEFAULT_ALLOW=$,r.SIDEBAR_IFRAME_DEFAULT_TITLE=x,r.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=ve,r.SidebarAdapter=H,r.SidebarIPCAdapter=N,r.TEXT_MIME_TYPES=te,r.TextLookupError=h,r.assertSidebarHostAdapter=Ee,r.buildDocumentReference=le,r.buildSidebarHostHtmlDocument=Le,r.buildSidebarHostShellCss=E,r.buildSidebarPluginHostHeadInnerHtml=W,r.createSidebarHost=Re,r.ensureSidebarHostShell=De,r.getAuthConfigWithOverride=Se,r.getSidebarBaseUrlWithOverride=be,r.ipcErrorReconstructors=C,r.isDocumentReference=se,r.isIntegrationSettingField=re,r.isIntegrationSettingsSchema=ie,r.isReplaceBatchError=ae,r.isTextLookupError=oe,r.reconstructError=_,r.setupSidebarLoadOverlay=F,r.sidebarPostMessageTargetOrigin=we});
@@ -1,7 +1,7 @@
1
- import { SidebarAdapter, type SidebarAdapterOptions } from "../adapters/sidebarAdapter";
2
- import { type SidebarLoadOverlayOptions } from "../load-overlay";
3
- import type { AuthConfig } from "../types/common";
4
- import type { PluginInterface } from "../types/pluginInterface";
1
+ import { SidebarAdapter, type SidebarAdapterOptions } from "../adapters/sidebarAdapter.js";
2
+ import { type SidebarLoadOverlayOptions } from "../load-overlay/index.js";
3
+ import type { AuthConfig } from "../types/common.js";
4
+ import type { PluginInterface } from "../types/pluginInterface.js";
5
5
  /** Fixed `iframe.title` for accessibility on adapter-created sidebars. */
6
6
  export declare const SIDEBAR_IFRAME_DEFAULT_TITLE = "Markup AI Sidebar";
7
7
  /** Default `iframe.allow` so the embedded sidebar can use the clipboard (Permissions Policy). */
@@ -34,6 +34,25 @@ export type ContentReplacement = {
34
34
  suggestion: string;
35
35
  range: ContentRange;
36
36
  };
37
+ /**
38
+ * A comment the sidebar asks the host to anchor on a span of the document
39
+ * (see {@link PluginInterface.addComment}).
40
+ */
41
+ export interface CommentRequest {
42
+ /**
43
+ * Ready-to-post plain-text comment body composed by the sidebar. Hosts can
44
+ * post it as-is or build their own body from {@link CommentRequest.issue}.
45
+ * It carries no author information — the host attributes the comment.
46
+ */
47
+ text: string;
48
+ /**
49
+ * Half-open document span `[range.start, range.end)` to anchor the comment
50
+ * on — same offset semantics as `replaceContent` / `selectContent`.
51
+ */
52
+ range: ContentRange;
53
+ /** The issue the comment is about, for hosts that format their own body. */
54
+ issue?: AgenticIssuePayload;
55
+ }
37
56
  /**
38
57
  * Content information including the content, document reference, optional document name, and optional mime type
39
58
  * The integration must provide content and documentReference - documentName and mimeType are optional
@@ -184,6 +203,17 @@ export interface SidebarConfig {
184
203
  * If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false
185
204
  */
186
205
  supportCheckSelection?: boolean;
206
+ /**
207
+ * Whether the host can anchor a comment on a span of the document via
208
+ * {@link PluginInterface.addComment}.
209
+ *
210
+ * When `true`, the sidebar offers an "Add as Comment" action on open issue
211
+ * cards. When `false` or omitted (the default), the action is hidden. Only
212
+ * set it when the host implements `addComment` — and, where the editor's
213
+ * comment API is version-gated (e.g. Word's `WordApi 1.4`), only when that
214
+ * API is actually available.
215
+ */
216
+ supportComments?: boolean;
187
217
  /**
188
218
  * Whether the sidebar may run several agents concurrently in one check.
189
219
  *
@@ -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,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA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,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"}
@@ -0,0 +1,47 @@
1
+ import type { ContentRange } from "./common";
2
+ /**
3
+ * Wire shape of the `errorJSON` payload for a `TextLookupError` thrown by a
4
+ * host's `selectContent` / `replaceContent` / `replaceMultipleContents`.
5
+ *
6
+ * The receiving side rebuilds the typed error from `name` through the error
7
+ * registry (`ipcErrorReconstructors`), so a non-JS port must send exactly this
8
+ * `name` for the sidebar to recognise the failure.
9
+ */
10
+ export interface TextLookupErrorPayload {
11
+ name: "TextLookupError";
12
+ message: string;
13
+ }
14
+ /**
15
+ * A range (as sent in the call) that the host could not apply, optionally
16
+ * with the reason for that one occurrence.
17
+ */
18
+ export interface ReplaceBatchFailedRange extends ContentRange {
19
+ /**
20
+ * Why this occurrence failed, written for the author (e.g. "This text was
21
+ * edited since the last check."). The sidebar shows it on that occurrence's
22
+ * card; when omitted it shows its own "text could not be found" message. The
23
+ * error's top-level `message` describes the batch and is shown only on the
24
+ * card the user applied from.
25
+ */
26
+ message?: string;
27
+ }
28
+ /**
29
+ * Wire shape of the `errorJSON` payload for a `ReplaceBatchError`: a
30
+ * `replaceMultipleContents` batch that the host could not apply in full.
31
+ *
32
+ * `applied` lists the ranges (as sent in the call) whose replacement landed in
33
+ * the document; `failed` lists the ranges the host could not locate or verify,
34
+ * each with an optional per-occurrence `message`. A range in neither list was
35
+ * left untouched. A host that verifies the whole
36
+ * batch before editing sends every unverifiable range in `failed` and an empty
37
+ * `applied`.
38
+ */
39
+ export interface ReplaceBatchErrorPayload {
40
+ name: "ReplaceBatchError";
41
+ message: string;
42
+ applied: ContentRange[];
43
+ failed: ReplaceBatchFailedRange[];
44
+ }
45
+ /** Every `errorJSON` payload the sidebar reconstructs into a typed error. */
46
+ export type KnownIpcErrorPayload = TextLookupErrorPayload | ReplaceBatchErrorPayload;
47
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,uBAAuB,EAAE,CAAC;CACnC;AAED,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC"}
@@ -2,4 +2,5 @@ export * from "./common";
2
2
  export * from "./pluginInterface";
3
3
  export * from "./sidebarInterface";
4
4
  export * from "./integrationSettings";
5
+ export * from "./errors";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"integrationSettings.d.ts","sourceRoot":"","sources":["../../src/types/integrationSettings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,2BAA2B;IACjF,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,2BAA2B;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,GAAG,2BAA2B,CAAC;AAEnG;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;I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,CAAC;CACzC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,yBAAyB,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,UAAW,OAAO,KAAG,KAAK,IAAI,yBAIrE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,UAAW,OAAO,KAAG,KAAK,IAAI,uBAmBnE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarBuildInfo, AgenticIssuePayload } from "./common";
1
+ import type { CommentRequest, ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarBuildInfo, AgenticIssuePayload } from "./common";
2
2
  import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta } from "./integrationSettings";
3
3
  /**
4
4
  * Interface for the functions to implement in the Editor that the Sidebar will call via IPC
@@ -43,6 +43,9 @@ export interface PluginInterface {
43
43
  * Replace multiple contents in the editor
44
44
  * @param replacements - Array of content replacements to apply
45
45
  * @returns Promise that resolves when all replacements are complete
46
+ * @throws {ReplaceBatchError} When the batch could not be applied in full; carries
47
+ * the ranges that were applied and the ones that failed (see ReplaceMultipleContentsError)
48
+ * @throws {TextLookupError} When the batch failed and the host cannot say which ranges landed
46
49
  */
47
50
  replaceMultipleContents: (replacements: ContentReplacement[]) => Promise<void>;
48
51
  /**
@@ -151,6 +154,31 @@ export interface PluginInterface {
151
154
  * clipboard; reject to signal the write failed.
152
155
  */
153
156
  copyToClipboard?: (text: string) => Promise<void>;
157
+ /**
158
+ * Anchor a comment on a span of the document — e.g. Word's
159
+ * `Range.insertComment`. The sidebar calls this when the user picks
160
+ * **Add as Comment** on an issue card.
161
+ *
162
+ * Optional. Implement it together with
163
+ * {@link SidebarConfig.supportComments} `: true`; the sidebar only offers
164
+ * the action when that flag is set. Without a handler, the call rejects
165
+ * with `No receiver registered for: addComment`.
166
+ *
167
+ * The handler MUST NOT change the document text. Author attribution is the
168
+ * host's responsibility — the sidebar sends no user information, and
169
+ * editors typically attach the signed-in editor user themselves.
170
+ *
171
+ * @param comment - Composed plain-text body, the half-open range to anchor
172
+ * on (same semantics as `replaceContent`'s `range`), and the structured
173
+ * issue for hosts that build their own body.
174
+ * @param documentReference - The document to comment in. Omitted or `null`
175
+ * means the integration's currently active document.
176
+ * @returns Promise that resolves once the comment has been added
177
+ * @throws {TextLookupError} When the range cannot be located in the document
178
+ * @throws {Error} When the host cannot comment there (e.g. a protected
179
+ * document); its `message` is shown to the user on the issue card
180
+ */
181
+ addComment?: (comment: CommentRequest, documentReference?: string | null) => Promise<void>;
154
182
  /**
155
183
  * Called when the user changes a value in the integration-settings form
156
184
  * declared via {@link SidebarConfig.integrationSettings}.
@@ -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,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAEvC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/C;;;;;;;;OAQG;IACH,cAAc,EAAE,CACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,KAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;OAOG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,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,IAAI,KAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9E;;;;;;;;;;;OAWG;IACH,2BAA2B,CAAC,EAAE,CAC5B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,EAC3C,MAAM,EAAE,MAAM,GAAG,MAAM,KACpB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sBAAsB,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7E;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3F;;;;;;;;;;;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": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Adapter package for MarkupAI Sidebar integration",
5
5
  "keywords": [
6
6
  "markupai",
@@ -46,7 +46,7 @@
46
46
  "@asyncapi/parser": "^3.6.3",
47
47
  "ajv": "^8.20.0",
48
48
  "ts-json-schema-generator": "^2.9.0",
49
- "tsc-alias": "1.9.4"
49
+ "tsc-alias": "1.9.7"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"