@markupai/sidebar-adapter 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -16
- package/asyncapi.json +1912 -0
- package/dist/adapters/pluginAdapter.d.ts +7 -0
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +5 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/deferred-promise.d.ts +14 -29
- package/dist/ipc/deferred-promise.d.ts.map +1 -1
- package/dist/ipc/ipc-core.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +6 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +164 -155
- package/dist/main.umd.cjs +6 -6
- package/dist/types/common.d.ts +60 -7
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/integrationSettings.d.ts +9 -4
- package/dist/types/integrationSettings.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +31 -4
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +14 -6
package/dist/main.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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},K=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),q=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},A=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function Z(e){return e instanceof A}var v={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in v?v[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=()=>{},T=class{_promise;[Symbol.toStringTag]="Promise";resolve=P;reject=P;constructor(){this._promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}},R={timeout:1e4},C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...R,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,o=new T,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},a);this.promisesByID[r]={promise:o,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),o}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(i in this.receiversByName){const o=this.receiversByName[i];try{if(!Array.isArray(r))throw new Error(`IPC: Expected array of arguments but got ${typeof r}`);const a=await o(...r),s={type:"response",id:t,name:i,data:a};this.postMessage(s)}catch(a){let s=JSON.stringify(a,Object.getOwnPropertyNames(a));const l=JSON.parse(s);(l.message===void 0||l.message==="")&&(s=JSON.stringify({message:a instanceof Error?a.message:String(a),name:a instanceof Error?a.name:void 0}));const c={type:"error",id:t,name:i,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${i}`),a={type:"error",id:t,name:i,errorJSON:JSON.stringify({message:o.message,name:o.name})};this.postMessage(a)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(i));r.reject(a)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},O=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async onAgenticIssueStatusChanged(e,t,i){await this.ipc.call("onAgenticIssueStatusChanged",e,t,i)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},Q=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new O(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,o="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await r(e,t,i)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},D=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new _(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ee=`
|
|
1
|
+
(function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),J=["text/plain","text/markdown","text/html","application/dita+xml"],V={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},K=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),X=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},v=class Y extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,Y.prototype)}};function q(e){return e instanceof v}var A={TextLookupError:e=>new v(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in A?A[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,i;super((r,o)=>{t=r,i=o,e(r,o)}),this.resolve=t,this.reject=i}},T={timeout:1e4};function Z(e){const t=JSON.stringify(e,Object.getOwnPropertyNames(e)),i=JSON.parse(t);return i.message===void 0||i.message===""?JSON.stringify({message:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:void 0}):t}var C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...T,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,o=new P,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},a);this.promisesByID[r]={promise:o,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),o}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(!(i in this.receiversByName)){const a=new Error(`No receiver registered for: ${i}`),s=JSON.stringify({message:a.message,name:a.name});this.postMessage({type:"error",id:t,name:i,errorJSON:s});return}const o=this.receiversByName[i];try{if(!Array.isArray(r))throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);const a=await o(...r),s={type:"response",id:t,name:i,data:a};this.postMessage(s)}catch(a){const s={type:"error",id:t,name:i,errorJSON:Z(a)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(i));r.reject(a)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},R=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async onAgenticIssueStatusChanged(e,t,i){await this.ipc.call("onAgenticIssueStatusChanged",e,t,i)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},Q=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new R(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},O=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,o="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{if(!this.plugin.showDialog)throw new Error("SidebarIPCAdapter: host does not implement showDialog");await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{if(!this.plugin.closeDialog)throw new Error("SidebarIPCAdapter: host does not implement closeDialog");await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await r(e,t,i)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},D=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new O(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ee=`
|
|
2
2
|
<div class="sidebar-load-overlay-card">
|
|
3
3
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
4
4
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<span>Retry</span>
|
|
20
20
|
</button>
|
|
21
21
|
</div>
|
|
22
|
-
`,te=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ee;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},
|
|
22
|
+
`,te=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ee;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},_="markupai-sidebar-load-overlay-styles",ie=`
|
|
23
23
|
:root {
|
|
24
24
|
--background: #f5f5f4;
|
|
25
25
|
--foreground: #333332;
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
box-shadow: 0 0 0 2px
|
|
112
112
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
113
113
|
}
|
|
114
|
-
`,re=e=>{const t=e??document;if(t.getElementById(
|
|
114
|
+
`,re=e=>{const t=e??document;if(t.getElementById(_))return;const i=t.createElement("style");i.id=_,i.textContent=ie,t.head.appendChild(i)},ne=8e3,ae=12e3,L=(e,t,i={})=>{re(e.ownerDocument);const{sidebarUrl:r,targetOrigin:o,timeoutMs:a=ne,retryIntervalMs:s=ae,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,Ae=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:x}=te();e.appendChild(w);let f=!1,I,p;const u=d=>{w.style.display=d?"flex":"none"};u(!1);const y=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},F=()=>{y(),I=globalThis.setTimeout(()=>{f||u(!0)},a)},j=d=>{const m=d?.preserveOverlay??!0;f=!1,m||u(!1),t.src=h(),F()},Ce=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||j({preserveOverlay:!0})},s))},$=()=>{p&&(globalThis.clearInterval(p),p=void 0)},G=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const m=Ae();m!=="*"&&d.origin!==m||(f=!0,y(),$(),u(!1))},W=()=>{y(),u(!0)},z=()=>{j()};return x.addEventListener("click",z),t.addEventListener("error",W),c.addEventListener("message",G),F(),Ce(),()=>{y(),$(),t.removeEventListener("error",W),c.removeEventListener("message",G),x.removeEventListener("click",z),w.remove()}},M="Markup AI Sidebar",k="clipboard-read; clipboard-write",oe="markupai.sidebarNextGen.overrideUrl",se="https://sidebar.markup.ai/";function le(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var N="markupai.sidebarNextGen.authOverride";function ce(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(N)?.trim();if(!i)return e;const r=JSON.parse(i);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function de(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function ge(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function pe(e){const{iframe:t,iframeMount:i}=e;if(t!==void 0&&i!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(i===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:o,allow:a=k}=i,s=document.createElement("iframe");return s.title=M,s.src=o,a&&s.setAttribute("allow",a),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ue(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=pe(e),l=i!==void 0?L(i,a,r??{}):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",H="markupai-sidebar-host-shell-styles";function U(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=U(e);return`
|
|
115
115
|
html {
|
|
116
116
|
height: 100%;
|
|
117
117
|
}
|
|
@@ -133,17 +133,17 @@ body {
|
|
|
133
133
|
margin: 0;
|
|
134
134
|
display: block;
|
|
135
135
|
}
|
|
136
|
-
`.trim()}var he=
|
|
136
|
+
`.trim()}var he=S();function fe(e){return e instanceof Document?e:e.ownerDocument}function Ie(e,t,i){if(!t||e.getElementById(H))return;const r=e.createElement("style");r.id=H,r.textContent=S(i),e.head.appendChild(r)}function ye(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=b,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=fe(t);Ie(o,r,i);const a=t instanceof Document?o.getElementById(i):t.querySelector(`#${U(i)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=i,t.appendChild(l),l}const s=o.createElement("div");return s.id=i,o.body.appendChild(s),s}function B(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function me(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?B():"",i].filter(h=>h.trim().length>0).join(`
|
|
137
137
|
`);return`<!DOCTYPE html>
|
|
138
138
|
<html ${s}>
|
|
139
139
|
<head>
|
|
140
140
|
<base target="_top" />
|
|
141
141
|
<meta charset="UTF-8" />
|
|
142
|
-
<title>${
|
|
142
|
+
<title>${ve(t)}</title>${c?`
|
|
143
143
|
${c}`:""}
|
|
144
144
|
</head>
|
|
145
145
|
<body ${l}>
|
|
146
146
|
${o}
|
|
147
147
|
</body>
|
|
148
148
|
</html>
|
|
149
|
-
`}function
|
|
149
|
+
`}function ve(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=N,n.DEFAULT_IPC_CONFIG=T,n.DEFAULT_SIDEBAR_CONFIG=V,n.DeferredPromise=P,n.IPCCore=C,n.MimeType=g,n.PluginAdapter=Q,n.PluginIPCAdapter=R,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=se,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=he,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=k,n.SIDEBAR_IFRAME_DEFAULT_TITLE=M,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=oe,n.SidebarAdapter=D,n.SidebarIPCAdapter=O,n.TEXT_MIME_TYPES=J,n.TextLookupError=v,n.assertSidebarHostAdapter=ge,n.buildSidebarHostHtmlDocument=me,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=B,n.createSidebarHost=ue,n.ensureSidebarHostShell=ye,n.getAuthConfigWithOverride=ce,n.getSidebarBaseUrlWithOverride=le,n.ipcErrorReconstructors=A,n.isIntegrationSettingField=X,n.isIntegrationSettingsSchema=K,n.isTextLookupError=q,n.reconstructError=E,n.setupSidebarLoadOverlay=L,n.sidebarPostMessageTargetOrigin=de});
|
package/dist/types/common.d.ts
CHANGED
|
@@ -63,11 +63,25 @@ export interface ContentInfo {
|
|
|
63
63
|
* - `"popup"` — Auth0 SPA client `loginWithPopup`. Requires a secure origin and
|
|
64
64
|
* Web Crypto; breaks in iframes with `null` origin.
|
|
65
65
|
*/
|
|
66
|
-
export type
|
|
66
|
+
export type AuthConfigMediation = {
|
|
67
67
|
type: "mediation";
|
|
68
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Explicit Auth0 relay-connection slug for the mediation login flow. Set this
|
|
70
|
+
* when one login provider must serve several `integrationId`s — e.g. a single
|
|
71
|
+
* add-in spanning multiple editors that each report a distinct `integrationId`
|
|
72
|
+
* (for analytics / the `x-integration-id` header / settings storage) but share
|
|
73
|
+
* one Auth0 relay connection. Example: `provider: "microsoft-365"` while
|
|
74
|
+
* `integrationId` is `"markupai-m365-word"` / `"markupai-m365-excel"` / ….
|
|
75
|
+
*
|
|
76
|
+
* When omitted, the sidebar derives the provider from `integrationId` (via its
|
|
77
|
+
* legacy compat map). Only meaningful for `type: "mediation"`.
|
|
78
|
+
*/
|
|
79
|
+
provider?: string;
|
|
80
|
+
};
|
|
81
|
+
export type AuthConfigPopup = {
|
|
69
82
|
type: "popup";
|
|
70
83
|
};
|
|
84
|
+
export type AuthConfig = AuthConfigMediation | AuthConfigPopup;
|
|
71
85
|
/**
|
|
72
86
|
* Severity of a plugin status notification surfaced by the sidebar.
|
|
73
87
|
*
|
|
@@ -81,10 +95,45 @@ export type PluginStatusType = "error" | "warning" | "info";
|
|
|
81
95
|
* Configuration for the sidebar
|
|
82
96
|
*/
|
|
83
97
|
export interface SidebarConfig {
|
|
98
|
+
/**
|
|
99
|
+
* Human-readable name of the underlying integration. **Display only** — shown
|
|
100
|
+
* verbatim to the user (e.g. on the sidebar's About page). Never derive a
|
|
101
|
+
* machine identifier from this string; use {@link SidebarConfig.integrationId}
|
|
102
|
+
* for that. Example: `"Madcap Flare Desktop"`.
|
|
103
|
+
*/
|
|
84
104
|
integrationName: string;
|
|
105
|
+
/**
|
|
106
|
+
* Version string of the host integration (the plugin/add-in build, not the
|
|
107
|
+
* sidebar or this adapter). Display only — e.g. shown on the sidebar's About
|
|
108
|
+
* page next to {@link SidebarConfig.integrationName}. Free-form; hosts typically
|
|
109
|
+
* pass their own package/build version such as `"1.4.2"`.
|
|
110
|
+
*/
|
|
85
111
|
integrationVersion: string;
|
|
112
|
+
/**
|
|
113
|
+
* Stable, machine-readable identifier for the integration. Used for everything
|
|
114
|
+
* non-display: the Auth0 mediation login provider, PostHog analytics keys, the
|
|
115
|
+
* `x-integration-id` API header, and per-integration settings storage. Should be
|
|
116
|
+
* a stable slug (lowercase, hyphenated, no spaces) that does not change between
|
|
117
|
+
* releases. Example: `"madcap-flare-desktop"`.
|
|
118
|
+
*
|
|
119
|
+
* Optional for backward compatibility: when omitted the sidebar falls back to
|
|
120
|
+
* `DEFAULT_SIDEBAR_CONFIG.integrationId` (`"markupai-sidebar-app"`). Hosts that
|
|
121
|
+
* use mediation login or want per-integration analytics/storage should set it.
|
|
122
|
+
*/
|
|
86
123
|
integrationId?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Hide the promotional/upsell banner the sidebar shows by default. Set `true`
|
|
126
|
+
* for embedded hosts where the banner is inappropriate (e.g. Figma, Office task
|
|
127
|
+
* pane). Defaults to `false` when omitted.
|
|
128
|
+
*/
|
|
87
129
|
hideBanner?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* JavaScript source the sidebar runs inside a host-rendered dialog to close it
|
|
132
|
+
* (see {@link PluginInterface.showDialog}/`closeDialog`). Lets hosts that render
|
|
133
|
+
* dialog chrome themselves supply the exact close call for their environment
|
|
134
|
+
* (e.g. `google.script.host.close();`). Omit when the host closes dialogs
|
|
135
|
+
* through the normal `closeDialog` IPC.
|
|
136
|
+
*/
|
|
88
137
|
dialogClosingScript?: string;
|
|
89
138
|
/**
|
|
90
139
|
* Origin of the plugin/editor window where messages should be sent
|
|
@@ -126,6 +175,14 @@ export interface SidebarConfig {
|
|
|
126
175
|
integrationSettings?: IntegrationSettingsSchema;
|
|
127
176
|
}
|
|
128
177
|
export declare const DEFAULT_SIDEBAR_CONFIG: SidebarConfig;
|
|
178
|
+
/**
|
|
179
|
+
* Character-offset span of an agentic issue within the document.
|
|
180
|
+
*/
|
|
181
|
+
export interface AgenticIssuePosition {
|
|
182
|
+
start: number;
|
|
183
|
+
end: number;
|
|
184
|
+
text: string;
|
|
185
|
+
}
|
|
129
186
|
/**
|
|
130
187
|
* Serializable payload for a single agentic issue sent over IPC (Sidebar → Plugin).
|
|
131
188
|
* Used when streaming agent results so the plugin can render underlines or other UI.
|
|
@@ -139,11 +196,7 @@ export interface AgenticIssuePayload {
|
|
|
139
196
|
explanation: string;
|
|
140
197
|
severity: "low" | "medium" | "high" | "critical";
|
|
141
198
|
confidence: number;
|
|
142
|
-
position:
|
|
143
|
-
start: number;
|
|
144
|
-
end: number;
|
|
145
|
-
text: string;
|
|
146
|
-
};
|
|
199
|
+
position: AgenticIssuePosition;
|
|
147
200
|
suggestion?: string;
|
|
148
201
|
suggestions?: string[];
|
|
149
202
|
category?: string;
|
|
@@ -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;;;;;;;;;;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,CAA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CACrB"}
|
|
@@ -35,6 +35,14 @@ export interface IntegrationSettingBooleanField extends IntegrationSettingFieldB
|
|
|
35
35
|
type: "boolean";
|
|
36
36
|
default: boolean;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A single option in an {@link IntegrationSettingEnumField} dropdown.
|
|
40
|
+
* `value` is the stable persisted key; `label` is the user-visible display text.
|
|
41
|
+
*/
|
|
42
|
+
export interface IntegrationSettingEnumOption {
|
|
43
|
+
value: string;
|
|
44
|
+
label: string;
|
|
45
|
+
}
|
|
38
46
|
/**
|
|
39
47
|
* Single-select enum rendered as a dropdown. Each option carries a stable
|
|
40
48
|
* `value` (persisted) and a user-visible `label`.
|
|
@@ -42,10 +50,7 @@ export interface IntegrationSettingBooleanField extends IntegrationSettingFieldB
|
|
|
42
50
|
export interface IntegrationSettingEnumField extends IntegrationSettingFieldBase {
|
|
43
51
|
type: "enum";
|
|
44
52
|
default: string;
|
|
45
|
-
options: ReadonlyArray<
|
|
46
|
-
value: string;
|
|
47
|
-
label: string;
|
|
48
|
-
}>;
|
|
53
|
+
options: ReadonlyArray<IntegrationSettingEnumOption>;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* Discriminated union of every supported field type. Adding a new field type
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file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AC,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,IAAI,CAAC,CAAC;CACnE;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,+BAA+B,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,+BAA+B,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,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,yBAIrE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,uBAmBnE,CAAC"}
|
|
@@ -33,19 +33,28 @@ export interface PluginInterface {
|
|
|
33
33
|
*/
|
|
34
34
|
selectContent: (range: ContentRange) => Promise<void>;
|
|
35
35
|
/**
|
|
36
|
-
* Show a dialog in the editor
|
|
36
|
+
* Show a dialog in the editor.
|
|
37
|
+
*
|
|
38
|
+
* Optional: not every host embedding the sidebar has dialog support. Hosts
|
|
39
|
+
* without a dialog surface should omit this method (and `closeDialog`). The
|
|
40
|
+
* sidebar gates dialog workflows behind `SidebarConfig.useCheckPreviewDialog`,
|
|
41
|
+
* so a host that omits these should also leave that flag `false`.
|
|
42
|
+
*
|
|
37
43
|
* @param dialogHtml - The HTML content of the dialog
|
|
38
44
|
* @param width - Optional dialog width
|
|
39
45
|
* @param height - Optional dialog height
|
|
40
46
|
* @param title - Optional dialog title
|
|
41
47
|
* @returns Promise that resolves when dialog is shown
|
|
42
48
|
*/
|
|
43
|
-
showDialog
|
|
49
|
+
showDialog?: (dialogHtml: string, width?: number, height?: number, title?: string) => Promise<void>;
|
|
44
50
|
/**
|
|
45
|
-
* Close the dialog in the editor
|
|
51
|
+
* Close the dialog in the editor.
|
|
52
|
+
*
|
|
53
|
+
* Optional: see `showDialog`. Omit on hosts without dialog support.
|
|
54
|
+
*
|
|
46
55
|
* @returns Promise that resolves when dialog is closed
|
|
47
56
|
*/
|
|
48
|
-
closeDialog
|
|
57
|
+
closeDialog?: () => Promise<void>;
|
|
49
58
|
/**
|
|
50
59
|
* Replace multiple contents in the editor
|
|
51
60
|
* @param replacements - Array of content replacements to apply
|
|
@@ -99,6 +108,24 @@ export interface PluginInterface {
|
|
|
99
108
|
* sidebar handles that via backend polling).
|
|
100
109
|
*/
|
|
101
110
|
openAuthUrl?: (url: string) => Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Write text to the system clipboard on the sidebar's behalf.
|
|
113
|
+
*
|
|
114
|
+
* Optional. When the host does not provide this, the sidebar copies with
|
|
115
|
+
* `navigator.clipboard.writeText` (falling back to `document.execCommand`).
|
|
116
|
+
* Those in-iframe paths are blocked in some embedded contexts — most
|
|
117
|
+
* notably VS Code webviews, whose Electron permission handler denies the
|
|
118
|
+
* async clipboard API to any frame that is not on the `vscode-webview://`
|
|
119
|
+
* origin, regardless of Permissions-Policy delegation.
|
|
120
|
+
*
|
|
121
|
+
* Hosts with a privileged clipboard primitive should implement this with
|
|
122
|
+
* it — for example, the VS Code extension calls
|
|
123
|
+
* `vscode.env.clipboard.writeText(text)` in the extension host.
|
|
124
|
+
*
|
|
125
|
+
* The returned promise resolves once the text has been written to the
|
|
126
|
+
* clipboard; reject to signal the write failed.
|
|
127
|
+
*/
|
|
128
|
+
copyToClipboard?: (text: string) => Promise<void>;
|
|
102
129
|
/**
|
|
103
130
|
* Called when the user changes a value in the integration-settings form
|
|
104
131
|
* 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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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markupai/sidebar-adapter",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Adapter package for MarkupAI Sidebar integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markupai",
|
|
@@ -15,18 +15,23 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/main.js",
|
|
21
|
+
"require": "./dist/main.umd.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./asyncapi.json": "./asyncapi.json"
|
|
21
24
|
},
|
|
22
25
|
"main": "./dist/main.umd.cjs",
|
|
23
26
|
"module": "./dist/main.js",
|
|
24
27
|
"types": "./dist/index.d.ts",
|
|
25
28
|
"files": [
|
|
26
|
-
"dist"
|
|
29
|
+
"dist",
|
|
30
|
+
"asyncapi.json"
|
|
27
31
|
],
|
|
28
32
|
"scripts": {
|
|
29
|
-
"build": "vite build && tsc --project tsconfig.declarations.json && tsc-alias -p tsconfig.declarations.json",
|
|
33
|
+
"build": "npm run build:contract && vite build && tsc --project tsconfig.declarations.json && tsc-alias -p tsconfig.declarations.json",
|
|
34
|
+
"build:contract": "node scripts/build-asyncapi.mjs",
|
|
30
35
|
"dev": "vite",
|
|
31
36
|
"format:check": "prettier --check .",
|
|
32
37
|
"format:fix": "prettier --write .",
|
|
@@ -38,6 +43,9 @@
|
|
|
38
43
|
"type-check": "tsc --project tsconfig.json --noEmit"
|
|
39
44
|
},
|
|
40
45
|
"devDependencies": {
|
|
46
|
+
"@asyncapi/parser": "^3.6.0",
|
|
47
|
+
"ajv": "^8.20.0",
|
|
48
|
+
"ts-json-schema-generator": "^2.9.0",
|
|
41
49
|
"tsc-alias": "1.8.17"
|
|
42
50
|
},
|
|
43
51
|
"publishConfig": {
|