@markupai/sidebar-adapter 0.0.23 → 1.1.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 (51) hide show
  1. package/README.md +106 -23
  2. package/dist/adapters/index.d.ts +3 -0
  3. package/dist/adapters/index.d.ts.map +1 -0
  4. package/dist/adapters/pluginAdapter.d.ts +79 -0
  5. package/dist/adapters/pluginAdapter.d.ts.map +1 -0
  6. package/dist/adapters/sidebarAdapter.d.ts +43 -0
  7. package/dist/adapters/sidebarAdapter.d.ts.map +1 -0
  8. package/dist/errors.d.ts +48 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/ipc/call-signatures.d.ts +69 -0
  13. package/dist/ipc/call-signatures.d.ts.map +1 -0
  14. package/dist/ipc/deferred-promise.d.ts +49 -0
  15. package/dist/ipc/deferred-promise.d.ts.map +1 -0
  16. package/dist/ipc/index.d.ts +9 -0
  17. package/dist/ipc/index.d.ts.map +1 -0
  18. package/dist/ipc/ipc-core.d.ts +72 -0
  19. package/dist/ipc/ipc-core.d.ts.map +1 -0
  20. package/dist/ipc/message-types.d.ts +57 -0
  21. package/dist/ipc/message-types.d.ts.map +1 -0
  22. package/dist/ipc/plugin-ipc-adapter.d.ts +83 -0
  23. package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -0
  24. package/dist/ipc/sidebar-ipc-adapter.d.ts +38 -0
  25. package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -0
  26. package/dist/load-overlay/index.d.ts +2 -0
  27. package/dist/load-overlay/index.d.ts.map +1 -0
  28. package/dist/load-overlay/loadOverlayDom.d.ts +5 -0
  29. package/dist/load-overlay/loadOverlayDom.d.ts.map +1 -0
  30. package/dist/load-overlay/loadOverlayStyles.d.ts +3 -0
  31. package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -0
  32. package/dist/load-overlay/sidebarLoadOverlay.d.ts +14 -0
  33. package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -0
  34. package/dist/main.js +312 -514
  35. package/dist/main.umd.cjs +12 -12
  36. package/dist/sidebar-host/createSidebarHost.d.ts +107 -0
  37. package/dist/sidebar-host/createSidebarHost.d.ts.map +1 -0
  38. package/dist/sidebar-host/index.d.ts +3 -0
  39. package/dist/sidebar-host/index.d.ts.map +1 -0
  40. package/dist/sidebar-host/sidebarHostShell.d.ts +56 -0
  41. package/dist/sidebar-host/sidebarHostShell.d.ts.map +1 -0
  42. package/dist/types/common.d.ts +132 -0
  43. package/dist/types/common.d.ts.map +1 -0
  44. package/dist/types/index.d.ts +4 -0
  45. package/dist/types/index.d.ts.map +1 -0
  46. package/dist/types/pluginInterface.d.ts +89 -0
  47. package/dist/types/pluginInterface.d.ts.map +1 -0
  48. package/dist/types/sidebarInterface.d.ts +41 -0
  49. package/dist/types/sidebarInterface.d.ts.map +1 -0
  50. package/package.json +5 -5
  51. package/dist/main.d.ts +0 -888
package/dist/main.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(o,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(o=typeof globalThis<"u"?globalThis:o||self,g(o.main={}))})(this,(function(o){"use strict";var g=(r=>(r.TEXT_PLAIN="text/plain",r.TEXT_MARKDOWN="text/markdown",r.TEXT_HTML="text/html",r.APPLICATION_DITA_XML="application/dita+xml",r))(g||{});const z=["text/plain","text/markdown","text/html","application/dita+xml"],G={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0};class p extends Error{name="TextLookupError";constructor(e){super(e),Object.setPrototypeOf(this,p.prototype)}}function X(r){return r instanceof p}const S={TextLookupError:r=>new p(r)};function C(r){const e=r.message??"",t=r.name,i=typeof t=="string"&&t in S?S[t]:void 0;return i?i(e,r):Object.assign(new Error(e),t?{name:t}:{})}const T=()=>{};class O{_promise;[Symbol.toStringTag]="Promise";resolve=T;reject=T;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)}}const D={timeout:1e4};class E{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,...i){const n=this.currentID++,s=new O,a=t.timeout??this.config.timeout,c=setTimeout(()=>{if(n in this.promisesByID){const d=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);s.reject(d),Reflect.deleteProperty(this.promisesByID,n)}},a);this.promisesByID[n]={promise:s,timeoutId:c};const l={type:"call",id:n,name:e,data:i};return this.postMessage(l),s}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}}async handleCall(e){const{id:t,name:i,data:n}=e;if(i in this.receiversByName){const s=this.receiversByName[i];try{if(!Array.isArray(n))throw new Error(`IPC: Expected array of arguments but got ${typeof n}`);const a=await s(...n),c={type:"response",id:t,name:i,data:a};this.postMessage(c)}catch(a){let c=JSON.stringify(a,Object.getOwnPropertyNames(a));const l=JSON.parse(c);(l.message===void 0||l.message==="")&&(c=JSON.stringify({message:a instanceof Error?a.message:String(a),name:a instanceof Error?a.name:void 0}));const d={type:"error",id:t,name:i,errorJSON:c};this.postMessage(d)}}else{const s=new Error(`No receiver registered for: ${i}`),a=JSON.stringify({message:s.message,name:s.name}),c={type:"error",id:t,name:i,errorJSON:a};this.postMessage(c)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:n}=this.promisesByID[t];clearTimeout(n),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:n,timeoutId:s}=this.promisesByID[t];clearTimeout(s);try{const a=JSON.parse(i),c=C(a);n.reject(c)}catch{n.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={}}}class _{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new E(n=>{window.parent.postMessage(n,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=>{await e(t)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}}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,i){await this.ipc.call("replaceContent",e,t,i)}async selectContent(e,t){await this.ipc.call("selectContent",e,t)}async showDialog(e,t,i,n){await this.ipc.call("showDialog",e,t,i,n)}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")}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()}}class V{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new _(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,i){await this.ipcAdapter.replaceContent(e,t,i)}async selectContent(e,t){await this.ipcAdapter.selectContent(e,t)}async showDialog(e,t,i,n){await this.ipcAdapter.showDialog(e,t,i,n)}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()}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}}class L{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,n,s="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=s,this.ipc=new E(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},n),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(){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,i)=>{await this.plugin.replaceContent(e,t,i)}),this.ipc.receive("selectContent",async(e,t)=>{await this.plugin.selectContent(e,t)}),this.ipc.receive("showDialog",async(e,t,i,n)=>{await this.plugin.showDialog(e,t,i,n)}),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()})}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async notifyPluginStatus(e){await this.ipc.call("onPluginStatusChange",e)}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}}class M{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new L(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e){await this.ipcAdapter.notifyPluginStatus(e)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}configure(e){this.ipcAdapter.configure(e)}}const q=`
1
+ (function(n,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(n=typeof globalThis<"u"?globalThis:n||self,d(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var d=(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})({}),X=[d.TEXT_PLAIN,d.TEXT_MARKDOWN,d.TEXT_HTML,d.APPLICATION_DITA_XML],V={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},A=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function K(e){return e instanceof A}var I={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",r=e.name,i=typeof r=="string"&&r in I?I[r]:void 0;return i?i(t,e):Object.assign(new Error(t),r?{name:r}:{})}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)}},O={timeout:1e4},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,...r){const i=this.currentID++,o=new T,a=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(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,i)}},a);this.promisesByID[i]={promise:o,timeoutId:s};const l={type:"call",id:i,name:e,data:r};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:r,data:i}=e;if(r in this.receiversByName){const o=this.receiversByName[r];try{if(!Array.isArray(i))throw new Error(`IPC: Expected array of arguments but got ${typeof i}`);const a=await o(...i),s={type:"response",id:t,name:r,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:r,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${r}`),a={type:"error",id:t,name:r,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:r,timeoutId:i}=this.promisesByID[t];clearTimeout(i),r.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:r}=e;if(t in this.promisesByID){const{promise:i,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(r));i.reject(a)}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={}}},R=class{ipc;sidebar;targetOrigin;constructor(e,t,r="*"){this.sidebar=e||{},this.targetOrigin=r,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,r=this.targetOrigin;e.origin!==t&&(r!=="*"&&e.origin!==r||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=>{await e(t)})}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)})}}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,r,i){await this.ipc.call("showDialog",e,t,r,i)}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 openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}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,r){this.ipcAdapter=new R(e,t,r)}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,r,i){await this.ipcAdapter.showDialog(e,t,r,i)}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()}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}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,r,i,o="*"){this.plugin=e,this.iframe=t,this.window=r??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},i),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,r=this.targetOrigin;e.origin!==t&&(r!=="*"&&e.origin!==r||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,r,i)=>{await this.plugin.showDialog(e,t,r,i)}),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 r=this.plugin.onAgenticAgentResults;r&&await r(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async notifyPluginStatus(e){await this.ipc.call("onPluginStatusChange",e)}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},D=class{ipcAdapter;constructor(e,t,r){this.ipcAdapter=new _(e,t,r?.win,r?.config,r?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e){await this.ipcAdapter.notifyPluginStatus(e)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}configure(e){this.ipcAdapter.configure(e)}},Z=`
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
- `,K=()=>{const r=document.createElement("div");r.className="sidebar-load-overlay",r.style.display="none",r.innerHTML=q;const e=r.querySelector(".sidebar-load-overlay-button");if(!e)throw new Error("Missing retry button in load overlay template.");return{overlay:r,button:e}},R="markupai-sidebar-load-overlay-styles",Z=`
22
+ `,Q=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=Z;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",ee=`
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
- `,Q=()=>{if(document.getElementById(R))return;const r=document.createElement("style");r.id=R,r.textContent=Z,document.head.appendChild(r)},ee=8e3,te=12e3,P=(r,e,t={})=>{Q();const{sidebarUrl:i,targetOrigin:n,timeoutMs:s=ee,retryIntervalMs:a=te}=t,c=()=>i??e.src,l=()=>{if(n)return n;try{return new URL(c()).origin}catch{return"*"}},{overlay:d,button:m}=K();r.appendChild(d);let y=!1,v,h;const f=u=>{d.style.display=u?"flex":"none"};f(!1);const b=()=>{v&&(globalThis.clearTimeout(v),v=void 0)},F=()=>{b(),v=globalThis.setTimeout(()=>{y||f(!0)},s)},j=u=>{const w=u?.preserveOverlay??!0;y=!1,w||f(!1),e.src=c(),F()},he=()=>{h||a<=0||(h=globalThis.setInterval(()=>{y||j({preserveOverlay:!0})},a))},$=()=>{h&&(globalThis.clearInterval(h),h=void 0)},W=u=>{if(!e.contentWindow||u.source!==e.contentWindow)return;const w=l();w!=="*"&&u.origin!==w||(y=!0,b(),$(),f(!1))},J=()=>{b(),f(!0)},Y=()=>{j()};return m.addEventListener("click",Y),e.addEventListener("error",J),globalThis.addEventListener("message",W),F(),he(),()=>{b(),$(),e.removeEventListener("error",J),globalThis.removeEventListener("message",W),m.removeEventListener("click",Y),d.remove()}},B="Markup AI Sidebar",k="clipboard-read; clipboard-write",H="markupai.sidebarNextGen.overrideUrl",re="https://sidebar.markup.ai/";function ie(r){try{return typeof globalThis.localStorage>"u"?r:globalThis.localStorage.getItem(H)?.trim()||r}catch{return r}}function ne(r,e){try{return new URL(r).origin}catch(t){return e?.onInvalidUrl?.(r,t),"*"}}function ae(r,e="Expected SidebarAdapter from createSidebarHost"){if(r.adapter===null)throw new Error(e)}function oe(r){const{iframe:e,iframeMount:t}=r;if(e!==void 0&&t!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(e!==void 0)return{iframe:e,removeMountedIframe:null};if(t===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:i,src:n,allow:s=k}=t,a=document.createElement("iframe");return a.title=B,a.src=n,s&&a.setAttribute("allow",s),i.appendChild(a),{iframe:a,removeMountedIframe:()=>{a.remove()}}}function se(r){const{plugin:e,loadOverlayContainer:t,loadOverlayOptions:i,adapterOptions:n}=r,{iframe:s,removeMountedIframe:a}=oe(r),c=t!==void 0?P(t,s,i??{}):null;if(e!==void 0){const l=new M(e,s,n);return{iframe:s,adapter:l,destroy:()=>{c?.(),l.destroy(),a?.()}}}return{iframe:s,adapter:null,destroy:()=>{c?.(),a?.()}}}const A="sidebarContainer",N="markupai-sidebar-host-shell-styles";function x(r){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(r);if(!/^[a-zA-Z_][\w-]*$/.test(r))throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(r)})`);return r}function I(r=A){const e=x(r);return`
114
+ `,te=e=>{const t=e??document;if(t.getElementById(L))return;const r=t.createElement("style");r.id=L,r.textContent=ee,t.head.appendChild(r)},re=8e3,ie=12e3,M=(e,t,r={})=>{te(e.ownerDocument);const{sidebarUrl:i,targetOrigin:o,timeoutMs:a=re,retryIntervalMs:s=ie,messageListenWindow:l}=r,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>i??t.src,ye=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:F}=Q();e.appendChild(w);let m=!1,f,p;const u=g=>{w.style.display=g?"flex":"none"};u(!1);const v=()=>{f&&(globalThis.clearTimeout(f),f=void 0)},j=()=>{v(),f=globalThis.setTimeout(()=>{m||u(!0)},a)},$=g=>{const y=g?.preserveOverlay??!0;m=!1,y||u(!1),t.src=h(),j()},Ae=()=>{p||s<=0||(p=globalThis.setInterval(()=>{m||$({preserveOverlay:!0})},s))},W=()=>{p&&(globalThis.clearInterval(p),p=void 0)},G=g=>{if(!t.contentWindow||g.source!==t.contentWindow)return;const y=ye();y!=="*"&&g.origin!==y||(m=!0,v(),W(),u(!1))},Y=()=>{v(),u(!0)},z=()=>{$()};return F.addEventListener("click",z),t.addEventListener("error",Y),c.addEventListener("message",G),j(),Ae(),()=>{v(),W(),t.removeEventListener("error",Y),c.removeEventListener("message",G),F.removeEventListener("click",z),w.remove()}},N="Markup AI Sidebar",H="clipboard-read; clipboard-write",ne="markupai.sidebarNextGen.overrideUrl",ae="https://sidebar.markup.ai/";function oe(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var k="markupai.sidebarNextGen.authOverride";function se(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const r=globalThis.localStorage.getItem(k)?.trim();if(!r)return e;const i=JSON.parse(r);return i!==null&&typeof i=="object"&&"type"in i&&(i.type==="mediation"||i.type==="popup")?i:e}catch{return e}}function le(e,t){try{return new URL(e).origin}catch(r){return t?.onInvalidUrl?.(e,r),"*"}}function ce(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function de(e){const{iframe:t,iframeMount:r}=e;if(t!==void 0&&r!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(r===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:i,src:o,allow:a=H}=r,s=document.createElement("iframe");return s.title=N,s.src=o,a&&s.setAttribute("allow",a),i.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ge(e){const{plugin:t,loadOverlayContainer:r,loadOverlayOptions:i,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=de(e),l=r!==void 0?M(r,a,i??{}):null;if(t!==void 0){const c=new D(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`
115
115
  html {
116
116
  height: 100%;
117
117
  }
@@ -119,12 +119,12 @@ body {
119
119
  height: 100%;
120
120
  margin: 0;
121
121
  }
122
- #${e} {
122
+ #${t} {
123
123
  height: 100%;
124
124
  box-sizing: border-box;
125
125
  position: relative;
126
126
  }
127
- #${e} iframe {
127
+ #${t} iframe {
128
128
  width: 100%;
129
129
  height: 100%;
130
130
  border: 0;
@@ -133,17 +133,17 @@ body {
133
133
  margin: 0;
134
134
  display: block;
135
135
  }
136
- `.trim()}const ce=I();function le(r){return r instanceof Document?r:r.ownerDocument}function de(r,e,t){if(!e||r.getElementById(N))return;const i=r.createElement("style");i.id=N,i.textContent=I(t),r.head.appendChild(i)}function ge(r){const{root:e=typeof document<"u"?document:void 0,containerId:t=A,includeDefaultStyles:i=!0}=r??{};if(e===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const n=le(e);de(n,i,t);const s=e instanceof Document?n.getElementById(t):e.querySelector(`#${x(t)}`);if(s instanceof HTMLElement&&(e instanceof Document||e.contains(s)))return s;if(!(e instanceof Document)){const c=n.createElement("div");return c.id=t,e.appendChild(c),c}const a=n.createElement("div");return a.id=t,n.body.appendChild(a),a}function U(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function ue(r){const{title:e="Markup AI Sidebar",headInnerHtml:t="",includePluginHostHead:i=!1,bodyScriptsHtml:n,htmlLang:s="en",htmlAttrs:a=`lang="${s}" style="height:100%"`,bodyAttrs:c='style="height:100%;margin:0"'}=r,d=[i?U():"",t].filter(m=>m.trim().length>0).join(`
136
+ `.trim()}var pe=S();function ue(e){return e instanceof Document?e:e.ownerDocument}function he(e,t,r){if(!t||e.getElementById(U))return;const i=e.createElement("style");i.id=U,i.textContent=S(r),e.head.appendChild(i)}function me(e){const{root:t=typeof document<"u"?document:void 0,containerId:r=b,includeDefaultStyles:i=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=ue(t);he(o,i,r);const a=t instanceof Document?o.getElementById(r):t.querySelector(`#${B(r)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=r,t.appendChild(l),l}const s=o.createElement("div");return s.id=r,o.body.appendChild(s),s}function x(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function fe(e){const{title:t="Markup AI Sidebar",headInnerHtml:r="",includePluginHostHead:i=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[i?x():"",r].filter(h=>h.trim().length>0).join(`
137
137
  `);return`<!DOCTYPE html>
138
- <html ${a}>
138
+ <html ${s}>
139
139
  <head>
140
140
  <base target="_top" />
141
141
  <meta charset="UTF-8" />
142
- <title>${pe(e)}</title>${d?`
143
- ${d}`:""}
142
+ <title>${ve(t)}</title>${c?`
143
+ ${c}`:""}
144
144
  </head>
145
- <body ${c}>
146
- ${n}
145
+ <body ${l}>
146
+ ${o}
147
147
  </body>
148
148
  </html>
149
- `}function pe(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}o.DEFAULT_IPC_CONFIG=D,o.DEFAULT_SIDEBAR_CONFIG=G,o.DeferredPromise=O,o.IPCCore=E,o.MimeType=g,o.PluginAdapter=V,o.PluginIPCAdapter=_,o.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=re,o.SIDEBAR_HOST_CONTAINER_ID=A,o.SIDEBAR_HOST_SHELL_CSS=ce,o.SIDEBAR_IFRAME_DEFAULT_ALLOW=k,o.SIDEBAR_IFRAME_DEFAULT_TITLE=B,o.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=H,o.SidebarAdapter=M,o.SidebarIPCAdapter=L,o.TEXT_MIME_TYPES=z,o.TextLookupError=p,o.assertSidebarHostAdapter=ae,o.buildSidebarHostHtmlDocument=ue,o.buildSidebarHostShellCss=I,o.buildSidebarPluginHostHeadInnerHtml=U,o.createSidebarHost=se,o.ensureSidebarHostShell=ge,o.getSidebarBaseUrlWithOverride=ie,o.ipcErrorReconstructors=S,o.isTextLookupError=X,o.reconstructError=C,o.setupSidebarLoadOverlay=P,o.sidebarPostMessageTargetOrigin=ne,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
149
+ `}function ve(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=k,n.DEFAULT_IPC_CONFIG=O,n.DEFAULT_SIDEBAR_CONFIG=V,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=d,n.PluginAdapter=q,n.PluginIPCAdapter=R,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=ae,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=pe,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=H,n.SIDEBAR_IFRAME_DEFAULT_TITLE=N,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=ne,n.SidebarAdapter=D,n.SidebarIPCAdapter=_,n.TEXT_MIME_TYPES=X,n.TextLookupError=A,n.assertSidebarHostAdapter=ce,n.buildSidebarHostHtmlDocument=fe,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=x,n.createSidebarHost=ge,n.ensureSidebarHostShell=me,n.getAuthConfigWithOverride=se,n.getSidebarBaseUrlWithOverride=oe,n.ipcErrorReconstructors=I,n.isTextLookupError=K,n.reconstructError=E,n.setupSidebarLoadOverlay=M,n.sidebarPostMessageTargetOrigin=le});
@@ -0,0 +1,107 @@
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";
5
+ /** Fixed `iframe.title` for accessibility on adapter-created sidebars. */
6
+ export declare const SIDEBAR_IFRAME_DEFAULT_TITLE = "Markup AI Sidebar";
7
+ /** Default `iframe.allow` so the embedded sidebar can use the clipboard (Permissions Policy). */
8
+ export declare const SIDEBAR_IFRAME_DEFAULT_ALLOW = "clipboard-read; clipboard-write";
9
+ /**
10
+ * Shared `localStorage` key integrations may read to override the sidebar base URL (e.g. local dev).
11
+ * Used by {@link getSidebarBaseUrlWithOverride}, Google Workspace, and Figma plugin UI.
12
+ */
13
+ export declare const SIDEBAR_URL_OVERRIDE_STORAGE_KEY = "markupai.sidebarNextGen.overrideUrl";
14
+ /**
15
+ * Canonical production sidebar app base URL (trailing slash).
16
+ * Use as {@link getSidebarBaseUrlWithOverride}'s `defaultUrl` when no build-time env override is set.
17
+ */
18
+ export declare const SIDEBAR_DEFAULT_PRODUCTION_BASE_URL: "https://sidebar.markup.ai/";
19
+ /**
20
+ * Resolves the sidebar base URL: reads {@link SIDEBAR_URL_OVERRIDE_STORAGE_KEY} from `localStorage`
21
+ * when present (trimmed), otherwise returns `defaultUrl`. Safe when `localStorage` is unavailable or throws.
22
+ */
23
+ export declare function getSidebarBaseUrlWithOverride(defaultUrl: string): string;
24
+ /**
25
+ * `localStorage` key for forcing an {@link AuthConfig} at runtime, used for
26
+ * local dev + automated tests where the host-supplied config may be missing
27
+ * or wrong. Value is a JSON-serialized {@link AuthConfig}, e.g.
28
+ * `'{"type":"mediation"}'`. Read by {@link getAuthConfigWithOverride}.
29
+ */
30
+ export declare const AUTH_CONFIG_OVERRIDE_STORAGE_KEY = "markupai.sidebarNextGen.authOverride";
31
+ /**
32
+ * Returns the effective {@link AuthConfig} for the sidebar. Priority:
33
+ *
34
+ * 1. Dev/test override from `localStorage[AUTH_CONFIG_OVERRIDE_STORAGE_KEY]`
35
+ * (honored only when `allowOverride` is `true` — sidebar-app gates this on
36
+ * `import.meta.env.DEV` so production builds can't be coerced).
37
+ * 2. The `hostConfig` value passed in (from the integration's
38
+ * `SidebarConfig.auth`).
39
+ * 3. `undefined` — meaning the sidebar should fall back to its legacy
40
+ * heuristic strategy selection.
41
+ *
42
+ * Invalid JSON in the override is logged and ignored. Safe when
43
+ * `localStorage` is unavailable or throws.
44
+ */
45
+ export declare function getAuthConfigWithOverride(hostConfig: AuthConfig | undefined, allowOverride: boolean): AuthConfig | undefined;
46
+ export type SidebarPostMessageTargetOriginOptions = {
47
+ /** Invoked when `sidebarUrl` is not a valid URL; the return value falls back to `"*"`. */
48
+ onInvalidUrl?: (sidebarUrl: string, error: unknown) => void;
49
+ };
50
+ /**
51
+ * Origin for {@link SidebarAdapterOptions.targetOrigin} / `postMessage` to the sidebar iframe,
52
+ * derived from the sidebar URL (hash routes are ignored by `URL#origin`). Returns `"*"` if parsing fails.
53
+ */
54
+ export declare function sidebarPostMessageTargetOrigin(sidebarUrl: string, options?: SidebarPostMessageTargetOriginOptions): string;
55
+ /** Create and mount a new sidebar iframe under `container`. */
56
+ export type CreateSidebarIframeMount = {
57
+ /** Parent element; the iframe is appended as the last child. */
58
+ container: HTMLElement;
59
+ /** Full URL for `iframe.src` (include hash route if needed, e.g. `.../#/next-ui`). */
60
+ src: string;
61
+ /**
62
+ * `iframe.allow` (Permissions Policy). Defaults to {@link SIDEBAR_IFRAME_DEFAULT_ALLOW}.
63
+ * Pass `""` to omit the attribute.
64
+ */
65
+ allow?: string;
66
+ };
67
+ export type CreateSidebarHostOptions = {
68
+ /**
69
+ * When set, a {@link SidebarAdapter} is created. Omit for **iframe-only** hosts (e.g. Figma UI)
70
+ * that forward IPC to another thread and only need the load overlay.
71
+ */
72
+ plugin?: PluginInterface;
73
+ /**
74
+ * When set, {@link setupSidebarLoadOverlay} is mounted for this container + iframe.
75
+ */
76
+ loadOverlayContainer?: HTMLElement;
77
+ /** Options for the load overlay; only used when a load overlay container is in effect. */
78
+ loadOverlayOptions?: SidebarLoadOverlayOptions;
79
+ /** Forwarded to {@link SidebarAdapter} when `plugin` is set (e.g. `targetOrigin`, `config`, `win`). */
80
+ adapterOptions?: SidebarAdapterOptions;
81
+ /**
82
+ * Existing sidebar iframe. Provide this **or** {@link iframeMount}, not both.
83
+ */
84
+ iframe?: HTMLIFrameElement;
85
+ /**
86
+ * Create and append a new iframe. Provide this **or** {@link iframe}, not both.
87
+ */
88
+ iframeMount?: CreateSidebarIframeMount;
89
+ };
90
+ export type SidebarHostWithAdapter = {
91
+ iframe: HTMLIFrameElement;
92
+ adapter: SidebarAdapter;
93
+ destroy: () => void;
94
+ };
95
+ export type SidebarShellHost = {
96
+ iframe: HTMLIFrameElement;
97
+ adapter: null;
98
+ destroy: () => void;
99
+ };
100
+ /** Return type when `plugin` is provided or omitted. */
101
+ export type SidebarHost = SidebarHostWithAdapter | SidebarShellHost;
102
+ /**
103
+ * Narrows {@link SidebarHost} after {@link createSidebarHost} when `plugin` was provided.
104
+ */
105
+ export declare function assertSidebarHostAdapter(host: SidebarHost, message?: string): asserts host is SidebarHostWithAdapter;
106
+ export declare function createSidebarHost(options: CreateSidebarHostOptions): SidebarHost;
107
+ //# sourceMappingURL=createSidebarHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSidebarHost.d.ts","sourceRoot":"","sources":["../../src/sidebar-host/createSidebarHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAA2B,KAAK,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,sBAAsB,CAAC;AAEhE,iGAAiG;AACjG,eAAO,MAAM,4BAA4B,oCAAoC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,gCAAgC,wCAAwC,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,mCAAmC,EAAG,4BAAqC,CAAC;AAEzF;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CASxE;AAED;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,yCAAyC,CAAC;AAEvF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,aAAa,EAAE,OAAO,GACrB,UAAU,GAAG,SAAS,CA+BxB;AAED,MAAM,MAAM,qCAAqC,GAAG;IAClD,0FAA0F;IAC1F,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,qCAAqC,GAC9C,MAAM,CAOR;AAED,+DAA+D;AAC/D,MAAM,MAAM,wBAAwB,GAAG;IACrC,gEAAgE;IAChE,SAAS,EAAE,WAAW,CAAC;IACvB,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;OAEG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC;IACnC,0FAA0F;IAC1F,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,uGAAuG;IACvG,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC;;OAEG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG,sBAAsB,GAAG,gBAAgB,CAAC;AAEpE;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,WAAW,EACjB,OAAO,SAAmD,GACzD,OAAO,CAAC,IAAI,IAAI,sBAAsB,CAIxC;AAgCD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CA8BhF"}
@@ -0,0 +1,3 @@
1
+ export { assertSidebarHostAdapter, AUTH_CONFIG_OVERRIDE_STORAGE_KEY, createSidebarHost, getAuthConfigWithOverride, getSidebarBaseUrlWithOverride, SIDEBAR_DEFAULT_PRODUCTION_BASE_URL, SIDEBAR_IFRAME_DEFAULT_ALLOW, SIDEBAR_IFRAME_DEFAULT_TITLE, SIDEBAR_URL_OVERRIDE_STORAGE_KEY, sidebarPostMessageTargetOrigin, type CreateSidebarHostOptions, type CreateSidebarIframeMount, type SidebarHost, type SidebarHostWithAdapter, type SidebarPostMessageTargetOriginOptions, type SidebarShellHost, } from "./createSidebarHost";
2
+ export { SIDEBAR_HOST_CONTAINER_ID, SIDEBAR_HOST_SHELL_CSS, buildSidebarHostHtmlDocument, buildSidebarHostShellCss, buildSidebarPluginHostHeadInnerHtml, ensureSidebarHostShell, type BuildSidebarHostHtmlDocumentOptions, type EnsureSidebarHostShellOptions, } from "./sidebarHostShell";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sidebar-host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,mCAAmC,EACnC,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,qCAAqC,EAC1C,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,mCAAmC,EACnC,sBAAsB,EACtB,KAAK,mCAAmC,EACxC,KAAK,6BAA6B,GACnC,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,56 @@
1
+ /** Default `id` of the element {@link ensureSidebarHostShell} creates or looks up. */
2
+ export declare const SIDEBAR_HOST_CONTAINER_ID = "sidebarContainer";
3
+ /**
4
+ * Layout CSS for hosts that embed the sidebar iframe (matches prior Google Workspace / Figma shells).
5
+ * Use {@link buildSidebarHostShellCss} when the container id is not {@link SIDEBAR_HOST_CONTAINER_ID}.
6
+ */
7
+ export declare function buildSidebarHostShellCss(containerId?: string): string;
8
+ /** Default shell CSS for {@link SIDEBAR_HOST_CONTAINER_ID}. */
9
+ export declare const SIDEBAR_HOST_SHELL_CSS: string;
10
+ export type EnsureSidebarHostShellOptions = {
11
+ /** Host element for the container; defaults to `document`. */
12
+ root?: Document | HTMLElement;
13
+ /** Container element id. Defaults to {@link SIDEBAR_HOST_CONTAINER_ID}. */
14
+ containerId?: string;
15
+ /** Inject {@link SIDEBAR_HOST_SHELL_CSS} once. Default `true`. */
16
+ includeDefaultStyles?: boolean;
17
+ };
18
+ /**
19
+ * Ensures a sidebar host container exists and default shell styles are applied.
20
+ * Host apps can use an almost empty HTML document and call this from their entry script
21
+ * (Google Workspace, Figma plugin UI, etc.).
22
+ */
23
+ export declare function ensureSidebarHostShell(options?: EnsureSidebarHostShellOptions): HTMLElement;
24
+ /**
25
+ * Default viewport `<meta>` for plugin UI host documents.
26
+ * Use with {@link buildSidebarHostHtmlDocument} via {@link includePluginHostHead}, or as `headInnerHtml`.
27
+ */
28
+ export declare function buildSidebarPluginHostHeadInnerHtml(): string;
29
+ export type BuildSidebarHostHtmlDocumentOptions = {
30
+ title?: string;
31
+ /**
32
+ * Extra tags inside `<head>` after charset/title (and after the plugin viewport block if {@link includePluginHostHead}).
33
+ * No need to include shell styles.
34
+ */
35
+ headInnerHtml?: string;
36
+ /**
37
+ * When true, inserts {@link buildSidebarPluginHostHeadInnerHtml} before {@link headInnerHtml}.
38
+ */
39
+ includePluginHostHead?: boolean;
40
+ /** One or more `<script>` tags (e.g. Vite entry). */
41
+ bodyScriptsHtml: string;
42
+ htmlLang?: string;
43
+ /** Attributes for `<html>`, e.g. `lang="en" style="height:100%"`. */
44
+ htmlAttrs?: string;
45
+ /** Attributes for `<body>`, e.g. `style="height:100%;margin:0"`. */
46
+ bodyAttrs?: string;
47
+ /** Include `<base target="_top" />` as first element in `<head>`. */
48
+ googleApps?: boolean;
49
+ };
50
+ /**
51
+ * Build a minimal HTML document string for hosts that generate UI HTML at build time
52
+ * (e.g. inline script into a single file). Runtime hosts usually prefer {@link ensureSidebarHostShell}
53
+ * plus a tiny static HTML file.
54
+ */
55
+ export declare function buildSidebarHostHtmlDocument(options: BuildSidebarHostHtmlDocumentOptions): string;
56
+ //# sourceMappingURL=sidebarHostShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebarHostShell.d.ts","sourceRoot":"","sources":["../../src/sidebar-host/sidebarHostShell.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAqB5D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,GAAE,MAAkC,GAAG,MAAM,CAyBhG;AAED,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,QAA6B,CAAC;AAEjE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,8DAA8D;IAC9D,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC9B,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAeF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,6BAA6B,GAAG,WAAW,CAoC3F;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAG5D;AAED,MAAM,MAAM,mCAAmC,GAAG;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,mCAAmC,GAAG,MAAM,CA4BjG"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Common MIME type constants for text content
3
+ * Integrations are not limited to these values - any valid MIME type string can be used
4
+ * Note: The sidebar currently only supports text-based content analysis
5
+ */
6
+ export declare enum MimeType {
7
+ TEXT_PLAIN = "text/plain",
8
+ TEXT_MARKDOWN = "text/markdown",
9
+ TEXT_HTML = "text/html",
10
+ APPLICATION_DITA_XML = "application/dita+xml"
11
+ }
12
+ /**
13
+ * Array of common text MIME types
14
+ * This is a convenience constant for reference - integrations can use any MIME type
15
+ * The sidebar accepts any MIME type string and passes it through to the API
16
+ */
17
+ export declare const TEXT_MIME_TYPES: readonly [MimeType.TEXT_PLAIN, MimeType.TEXT_MARKDOWN, MimeType.TEXT_HTML, MimeType.APPLICATION_DITA_XML];
18
+ /**
19
+ * Half-open document span `[start, end)` for replace or select operations.
20
+ */
21
+ export interface ContentRange {
22
+ /**
23
+ * The zero-based character offset from the beginning of the document where the content to replace starts.
24
+ * Must be a non-negative integer.
25
+ */
26
+ start: number;
27
+ /**
28
+ * The zero-based exclusive end offset; the span replaced or selected is `[start, end)` in the document.
29
+ */
30
+ end: number;
31
+ }
32
+ export type ContentReplacement = {
33
+ suggestion: string;
34
+ range: ContentRange;
35
+ };
36
+ /**
37
+ * Content information including the content, document reference, optional document name, and optional mime type
38
+ * The integration must provide content and documentReference - documentName and mimeType are optional
39
+ *
40
+ * - documentReference: A unique identifier for the document (e.g., URL, file path, or document ID).
41
+ * Required because the API uses it to track a document across scans.
42
+ * - documentName: A human-readable name/title for the document (e.g., "My Report.docx").
43
+ * Optional; when absent, the sidebar will attempt to derive it from documentReference if it
44
+ * contains a filename with extension.
45
+ * - mimeType: Any valid MIME type string, not limited to MimeType enum values.
46
+ */
47
+ export interface ContentInfo {
48
+ content: string | number[];
49
+ documentReference: string;
50
+ documentName?: string;
51
+ mimeType?: string;
52
+ }
53
+ /**
54
+ * How the sidebar should run the Auth0 login flow in a given host.
55
+ *
56
+ * - `"mediation"` — backend-mediated authorization code flow. The sidebar asks
57
+ * the backend to start an OAuth handshake, opens the returned `authorizeUrl`
58
+ * in an external browser (via the host, see {@link PluginInterface.openAuthUrl}
59
+ * if provided, else `globalThis.open(url, "_blank", "noopener,noreferrer")`),
60
+ * and polls the backend for the code + token exchange. Works in restricted
61
+ * iframe contexts such as Figma and Office task panes.
62
+ * - `"popup"` — Auth0 SPA client `loginWithPopup`. Requires a secure origin and
63
+ * Web Crypto; breaks in iframes with `null` origin.
64
+ */
65
+ export type AuthConfig = {
66
+ type: "mediation";
67
+ } | {
68
+ type: "popup";
69
+ };
70
+ /**
71
+ * Configuration for the sidebar
72
+ */
73
+ export interface SidebarConfig {
74
+ integrationName: string;
75
+ integrationVersion: string;
76
+ integrationId?: string;
77
+ hideBanner?: boolean;
78
+ dialogClosingScript?: string;
79
+ /**
80
+ * Origin of the plugin/editor window where messages should be sent
81
+ * This is the origin where the plugin is listening for messages from the sidebar
82
+ */
83
+ pluginOrigin?: string;
84
+ /**
85
+ * Whether to use the check preview workflow dialog
86
+ * If true, the sidebar will show a check preview dialog where the user can apply issues to the content
87
+ * If false, the sidebar will not show a dialog, but there will be an issue tab on the sidebar from where the user can apply issues
88
+ */
89
+ useCheckPreviewDialog: boolean;
90
+ /**
91
+ * Whether to support selection-based check and rewrite functionality
92
+ * If true or undefined (default), the selection toggle UI will be shown and users can toggle between full content and selection modes
93
+ * If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false
94
+ */
95
+ supportCheckSelection?: boolean;
96
+ /**
97
+ * How the sidebar should run the Auth0 login flow. When omitted, the sidebar
98
+ * falls back to heuristic strategy selection (iframe context, secure origin,
99
+ * etc.) for backwards compatibility. New integrations should set this
100
+ * explicitly; `"mediation"` is the correct choice for hosts that embed the
101
+ * sidebar in an iframe (Figma, Office task pane).
102
+ *
103
+ * In dev builds, the sidebar also honors a `localStorage` override at the
104
+ * key exported as `AUTH_CONFIG_OVERRIDE_STORAGE_KEY` — see
105
+ * `getAuthConfigWithOverride` in `sidebar-host`.
106
+ */
107
+ auth?: AuthConfig;
108
+ }
109
+ export declare const DEFAULT_SIDEBAR_CONFIG: SidebarConfig;
110
+ /**
111
+ * Serializable payload for a single agentic issue sent over IPC (Sidebar → Plugin).
112
+ * Used when streaming agent results so the plugin can render underlines or other UI.
113
+ */
114
+ export interface AgenticIssuePayload {
115
+ id: string;
116
+ groupKey: string;
117
+ status: "active" | "resolved" | "dismissed";
118
+ original: string;
119
+ agent: string;
120
+ explanation: string;
121
+ severity: "low" | "medium" | "high" | "critical";
122
+ confidence: number;
123
+ position: {
124
+ start: number;
125
+ end: number;
126
+ sentence: string;
127
+ };
128
+ suggestion?: string;
129
+ suggestions?: string[];
130
+ category?: string;
131
+ }
132
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;;;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;;;;;;;;;;GAUG;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;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAQpC,CAAC;AAEF;;;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;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,4 @@
1
+ export * from "./common";
2
+ export * from "./pluginInterface";
3
+ export * from "./sidebarInterface";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,89 @@
1
+ import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, AgenticIssuePayload } from "./common";
2
+ /**
3
+ * Interface for the functions to implement in the Editor that the Sidebar will call via IPC
4
+ * All methods return Promises for proper async handling
5
+ */
6
+ export interface PluginInterface {
7
+ /**
8
+ * Get content from the editor in whatever format the integration supports
9
+ * The integration must provide content and documentReference; documentName and mimeType are optional
10
+ * @returns Promise that resolves with content info including documentReference and optional documentName/mimeType
11
+ */
12
+ getContent: () => Promise<ContentInfo>;
13
+ /**
14
+ * Get selected content from the editor in whatever format the integration supports
15
+ * The integration must provide content and documentReference; documentName and mimeType are optional
16
+ * @returns Promise that resolves with content info including documentReference and optional documentName/mimeType
17
+ */
18
+ getSelectedContent: () => Promise<ContentInfo>;
19
+ /**
20
+ * Replace content in the editor using document offsets only.
21
+ * @param suggestion - Replacement text for the span `[range.start, range.end)`
22
+ * @param range - Half-open document span to replace
23
+ * @returns Promise that resolves when replacement is complete
24
+ * @throws {TextLookupError} When the requested text cannot be found or located (see ReplaceContentError)
25
+ */
26
+ replaceContent: (suggestion: string, range: ContentRange) => Promise<void>;
27
+ /**
28
+ * Select or highlight content in the editor using document character offsets only.
29
+ * @param range - Half-open document span `[range.start, range.end)` to select (same semantics as `replaceContent`'s `range`)
30
+ * @returns Promise that resolves when selection is complete
31
+ * @throws {TextLookupError} When the requested text cannot be found or located (see SelectContentError)
32
+ */
33
+ selectContent: (range: ContentRange) => Promise<void>;
34
+ /**
35
+ * Show a dialog in the editor
36
+ * @param dialogHtml - The HTML content of the dialog
37
+ * @param width - Optional dialog width
38
+ * @param height - Optional dialog height
39
+ * @param title - Optional dialog title
40
+ * @returns Promise that resolves when dialog is shown
41
+ */
42
+ showDialog: (dialogHtml: string, width?: number, height?: number, title?: string) => Promise<void>;
43
+ /**
44
+ * Close the dialog in the editor
45
+ * @returns Promise that resolves when dialog is closed
46
+ */
47
+ closeDialog: () => Promise<void>;
48
+ /**
49
+ * Replace multiple contents in the editor
50
+ * @param replacements - Array of content replacements to apply
51
+ * @returns Promise that resolves when all replacements are complete
52
+ */
53
+ replaceMultipleContents: (replacements: ContentReplacement[]) => Promise<void>;
54
+ /**
55
+ * Get initialization configuration from the editor
56
+ * Called by the sidebar when it's ready to initialize
57
+ * @returns Promise that resolves with the sidebar configuration
58
+ */
59
+ getInitConfig: () => Promise<SidebarConfig>;
60
+ /**
61
+ * Called when one agent's results are available during agentic streaming.
62
+ * Enables the plugin to render underlines or update UI per agent as results arrive.
63
+ */
64
+ onAgenticAgentResults?: (agentName: string, issues: AgenticIssuePayload[]) => Promise<void>;
65
+ /**
66
+ * Called when the agentic stream has finished (all agents done or completion/error event).
67
+ */
68
+ onAgenticStreamComplete?: () => Promise<void>;
69
+ /**
70
+ * Open an external URL during an authentication flow (typically the Auth0
71
+ * `authorizeUrl` returned by the backend-mediated OAuth flow).
72
+ *
73
+ * Optional. When the host does not provide this, the sidebar falls back to
74
+ * `globalThis.open(url, "_blank", "noopener,noreferrer")` (the
75
+ * `noopener,noreferrer` mitigates reverse-tabnabbing when opening a
76
+ * third-party auth domain). The fallback is blocked or silently broken in
77
+ * some embedded contexts (Office task pane, some Figma builds).
78
+ *
79
+ * Hosts that live inside a sandboxed container should implement this with
80
+ * their platform primitive — for example, Office add-ins should call
81
+ * `Office.context.ui.openBrowserWindow(url)`.
82
+ *
83
+ * The returned promise resolves once the host has handed off the URL; it
84
+ * does **not** need to wait for the user to complete the auth flow (the
85
+ * sidebar handles that via backend polling).
86
+ */
87
+ openAuthUrl?: (url: string) => Promise<void>;
88
+ }
89
+ //# sourceMappingURL=pluginInterface.d.ts.map
@@ -0,0 +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;AAElB;;;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;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5F;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Interface for functions to implement in the Sidebar that the Plugin can call via IPC
3
+ *
4
+ * Currently using PULL pattern where Sidebar initiates all communication.
5
+ * This interface is provided for future extensibility when Plugin → Sidebar calls are needed.
6
+ */
7
+ export interface SidebarInterface {
8
+ /**
9
+ * Example method: Called when plugin status changes (e.g., initialization complete)
10
+ * This serves as a template for adding future Plugin → Sidebar communication
11
+ *
12
+ * @param status - Status message from the plugin
13
+ * @returns Promise that resolves when the sidebar has processed the status
14
+ *
15
+ * @example
16
+ * // In Plugin implementation:
17
+ * onPluginStatusChange: async (status: string) => {
18
+ * console.log('Plugin status:', status);
19
+ * }
20
+ *
21
+ * // Sidebar can implement:
22
+ * const sidebarInterface: SidebarInterface = {
23
+ * onPluginStatusChange: async (status) => {
24
+ * console.log('Sidebar received status:', status);
25
+ * // Update UI, show notification, etc.
26
+ * }
27
+ * };
28
+ */
29
+ onPluginStatusChange?: (status: string) => Promise<void>;
30
+ /**
31
+ * Request the sidebar to activate (expand and scroll to) the card for the given issue.
32
+ * Used when the user clicks an underline in the document so the sidebar focuses that issue.
33
+ */
34
+ activateAgenticIssue?: (issueId: string) => Promise<void>;
35
+ /**
36
+ * Request the sidebar to invalidate (dismiss) the card for the given issue.
37
+ * Used when the plugin wants to programmatically dismiss an issue (e.g. after replacement).
38
+ */
39
+ invalidateAgenticIssue?: (issueId: string) => Promise<void>;
40
+ }
41
+ //# sourceMappingURL=sidebarInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebarInterface.d.ts","sourceRoot":"","sources":["../../src/types/sidebarInterface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D;;;OAGG;IACH,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D"}