@markupai/sidebar-adapter 1.3.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -17
- package/asyncapi.json +125 -20
- package/dist/adapters/pluginAdapter.d.ts +4 -4
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/adapters/sidebarAdapter.d.ts +12 -1
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
- package/dist/document-reference/documentReference.d.ts +57 -0
- package/dist/document-reference/documentReference.d.ts.map +1 -0
- package/dist/document-reference/index.d.ts +2 -0
- package/dist/document-reference/index.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +30 -6
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +4 -4
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts +12 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +225 -197
- package/dist/main.umd.cjs +7 -7
- package/dist/types/common.d.ts +54 -2
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +21 -6
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/dist/types/sidebarInterface.d.ts +22 -1
- package/dist/types/sidebarInterface.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),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=`
|
|
1
|
+
(function(r,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(r=typeof globalThis<"u"?globalThis:r||self,g(r.main={}))})(this,function(r){Object.defineProperty(r,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),K=["text/plain","text/markdown","text/html","application/dita+xml"],X={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0,multiAgent:!1,multiDocument:!1},q=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),Z=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const n=i;return typeof n.value=="string"&&typeof n.label=="string"}):!1},A=class V extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,V.prototype)}};function Q(e){return e instanceof A}var v={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",i=e.name,n=typeof i=="string"&&i in v?v[i]:void 0;return n?n(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=":",R=/^[a-z][a-z0-9-]*$/;function ee(e){const t=e.indexOf(P);return t<=0||t===e.length-1?!1:R.test(e.slice(0,t))}function te(e,t){const i=e.trim().toLowerCase(),n=t.trim();if(!R.test(i))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(n.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${i}${P}`;return n.startsWith(a)?n:`${a}${n}`}var T=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,i;super((n,a)=>{t=n,i=a,e(n,a)}),this.resolve=t,this.reject=i}},D={timeout:1e4};function ie(e){const t=JSON.stringify(e,Object.getOwnPropertyNames(e)),i=JSON.parse(t);return i.message===void 0||i.message===""?JSON.stringify({message:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:void 0}):t}var C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...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++,a=new T,o=t.timeout??this.config.timeout,s=setTimeout(()=>{if(n in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(o)}ms`);a.reject(c),Reflect.deleteProperty(this.promisesByID,n)}},o);this.promisesByID[n]={promise:a,timeoutId:s};const l={type:"call",id:n,name:e,data:i};return this.postMessage(l),a}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:n}=e;if(!(i in this.receiversByName)){const o=new Error(`No receiver registered for: ${i}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:i,errorJSON:s});return}const a=this.receiversByName[i];try{if(!Array.isArray(n))throw new TypeError(`IPC: Expected array of arguments but got ${typeof n}`);const o=await a(...n),s={type:"response",id:t,name:i,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:i,errorJSON:ie(o)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId: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:a}=this.promisesByID[t];clearTimeout(a);try{const o=E(JSON.parse(i));n.reject(o)}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={}}},O=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(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,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async(t,i)=>{await e(t,typeof i=="string"?i:null)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}if(this.sidebar.onActiveDocumentChanged){const e=this.sidebar.onActiveDocumentChanged;this.ipc.receive("onActiveDocumentChanged",async t=>{await e(t)})}}async getInitConfig(){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=null){await this.ipc.call("replaceContent",e,t,i)}async selectContent(e,t=null){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,i=null){await this.ipc.call("onAgenticAgentResults",e,t,i)}async onAgenticStreamComplete(e=null){await this.ipc.call("onAgenticStreamComplete",e)}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()}},ne=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,i=null){await this.ipcAdapter.replaceContent(e,t,i)}async selectContent(e,t=null){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,i=null){return this.ipcAdapter.onAgenticAgentResults(e,t,i)}onAgenticStreamComplete(e=null){return this.ipcAdapter.onAgenticStreamComplete(e)}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,n,a="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=a,this.ipc=new C(o=>{this.iframe.contentWindow?.postMessage(o,this.targetOrigin)},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(){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,i)=>{await this.plugin.replaceContent(e,t,typeof i=="string"?i:null)}),this.ipc.receive("selectContent",async(e,t)=>{await this.plugin.selectContent(e,typeof t=="string"?t:null)}),this.ipc.receive("showDialog",async(e,t,i,n)=>{if(!this.plugin.showDialog)throw new Error("SidebarIPCAdapter: host does not implement showDialog");await this.plugin.showDialog(e,t,i,n)}),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,i)=>{if(!Array.isArray(t))return;const n=this.plugin.onAgenticAgentResults;n&&await n(e,t,typeof i=="string"?i:null)}),this.ipc.receive("onAgenticStreamComplete",async e=>{const t=this.plugin.onAgenticStreamComplete;t&&await t(typeof e=="string"?e:null)}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const n=this.plugin.onAgenticIssueStatusChanged;if(n&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await n(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,t=null){await this.ipc.call("activateAgenticIssue",e,t)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}async notifyActiveDocumentChanged(e){await this.ipc.call("onActiveDocumentChanged",e)}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},L=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new _(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e,t=null){await this.ipcAdapter.activateAgenticIssue(e,t)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}async notifyActiveDocumentChanged(e){await this.ipcAdapter.notifyActiveDocumentChanged(e)}configure(e){this.ipcAdapter.configure(e)}},re=`
|
|
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
|
-
`,
|
|
22
|
+
`,ae=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=re;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},M="markupai-sidebar-load-overlay-styles",oe=`
|
|
23
23
|
:root {
|
|
24
24
|
--background: #f5f5f4;
|
|
25
25
|
--foreground: #333332;
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
box-shadow: 0 0 0 2px
|
|
112
112
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
113
113
|
}
|
|
114
|
-
`,
|
|
114
|
+
`,se=e=>{const t=e??document;if(t.getElementById(M))return;const i=t.createElement("style");i.id=M,i.textContent=oe,t.head.appendChild(i)},le=8e3,ce=12e3,k=(e,t,i={})=>{se(e.ownerDocument);const{sidebarUrl:n,targetOrigin:a,timeoutMs:o=le,retryIntervalMs:s=ce,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>n??t.src,we=()=>{if(a)return a;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:j}=ae();e.appendChild(w);let f=!1,m,u;const p=d=>{w.style.display=d?"flex":"none"};p(!1);const I=()=>{m&&(globalThis.clearTimeout(m),m=void 0)},$=()=>{I(),m=globalThis.setTimeout(()=>{f||p(!0)},o)},W=d=>{const y=d?.preserveOverlay??!0;f=!1,y||p(!1),t.src=h(),$()},Ee=()=>{u||s<=0||(u=globalThis.setInterval(()=>{f||W({preserveOverlay:!0})},s))},G=()=>{u&&(globalThis.clearInterval(u),u=void 0)},z=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const y=we();y!=="*"&&d.origin!==y||(f=!0,I(),G(),p(!1))},J=()=>{I(),p(!0)},Y=()=>{W()};return j.addEventListener("click",Y),t.addEventListener("error",J),c.addEventListener("message",z),$(),Ee(),()=>{I(),G(),t.removeEventListener("error",J),c.removeEventListener("message",z),j.removeEventListener("click",Y),w.remove()}},N="Markup AI Sidebar",H="clipboard-read; clipboard-write",de="markupai.sidebarNextGen.overrideUrl",ge="https://sidebar.markup.ai/";function ue(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var U="markupai.sidebarNextGen.authOverride";function pe(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(U)?.trim();if(!i)return e;const n=JSON.parse(i);return n!==null&&typeof n=="object"&&"type"in n&&(n.type==="mediation"||n.type==="popup")?n:e}catch{return e}}function he(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function fe(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function me(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:n,src:a,allow:o=H}=i,s=document.createElement("iframe");return s.title=N,s.src=a,o&&s.setAttribute("allow",o),n.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function Ie(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:n,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=me(e),l=i!==void 0?k(i,o,n??{}):null;if(t!==void 0){const c=new L(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var b="sidebarContainer",B="markupai-sidebar-host-shell-styles";function x(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(String.raw`sidebar host shell: containerId must match /^[a-zA-Z_][\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);return e}function S(e=b){const t=x(e);return`
|
|
115
115
|
html {
|
|
116
116
|
height: 100%;
|
|
117
117
|
}
|
|
@@ -133,17 +133,17 @@ body {
|
|
|
133
133
|
margin: 0;
|
|
134
134
|
display: block;
|
|
135
135
|
}
|
|
136
|
-
`.trim()}var
|
|
136
|
+
`.trim()}var ye=S();function Ae(e){return e instanceof Document?e:e.ownerDocument}function ve(e,t,i){if(!t||e.getElementById(B))return;const n=e.createElement("style");n.id=B,n.textContent=S(i),e.head.appendChild(n)}function Ce(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=b,includeDefaultStyles:n=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const a=Ae(t);ve(a,n,i);const o=t instanceof Document?a.getElementById(i):t.querySelector(`#${x(i)}`);if(o instanceof HTMLElement&&(t instanceof Document||t.contains(o)))return o;if(!(t instanceof Document)){const l=a.createElement("div");return l.id=i,t.appendChild(l),l}const s=a.createElement("div");return s.id=i,a.body.appendChild(s),s}function F(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function be(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:n=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[n?F():"",i].filter(h=>h.trim().length>0).join(`
|
|
137
137
|
`);return`<!DOCTYPE html>
|
|
138
138
|
<html ${s}>
|
|
139
139
|
<head>
|
|
140
140
|
<base target="_top" />
|
|
141
141
|
<meta charset="UTF-8" />
|
|
142
|
-
<title>${
|
|
142
|
+
<title>${Se(t)}</title>${c?`
|
|
143
143
|
${c}`:""}
|
|
144
144
|
</head>
|
|
145
145
|
<body ${l}>
|
|
146
|
-
${
|
|
146
|
+
${a}
|
|
147
147
|
</body>
|
|
148
148
|
</html>
|
|
149
|
-
`}function
|
|
149
|
+
`}function Se(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}r.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=U,r.DEFAULT_IPC_CONFIG=D,r.DEFAULT_SIDEBAR_CONFIG=X,r.DeferredPromise=T,r.IPCCore=C,r.MimeType=g,r.PluginAdapter=ne,r.PluginIPCAdapter=O,r.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=ge,r.SIDEBAR_HOST_CONTAINER_ID=b,r.SIDEBAR_HOST_SHELL_CSS=ye,r.SIDEBAR_IFRAME_DEFAULT_ALLOW=H,r.SIDEBAR_IFRAME_DEFAULT_TITLE=N,r.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=de,r.SidebarAdapter=L,r.SidebarIPCAdapter=_,r.TEXT_MIME_TYPES=K,r.TextLookupError=A,r.assertSidebarHostAdapter=fe,r.buildDocumentReference=te,r.buildSidebarHostHtmlDocument=be,r.buildSidebarHostShellCss=S,r.buildSidebarPluginHostHeadInnerHtml=F,r.createSidebarHost=Ie,r.ensureSidebarHostShell=Ce,r.getAuthConfigWithOverride=pe,r.getSidebarBaseUrlWithOverride=ue,r.ipcErrorReconstructors=v,r.isDocumentReference=ee,r.isIntegrationSettingField=Z,r.isIntegrationSettingsSchema=q,r.isTextLookupError=Q,r.reconstructError=E,r.setupSidebarLoadOverlay=k,r.sidebarPostMessageTargetOrigin=he});
|
package/dist/types/common.d.ts
CHANGED
|
@@ -38,8 +38,16 @@ export type ContentReplacement = {
|
|
|
38
38
|
* Content information including the content, document reference, optional document name, and optional mime type
|
|
39
39
|
* The integration must provide content and documentReference - documentName and mimeType are optional
|
|
40
40
|
*
|
|
41
|
-
* - documentReference: A unique identifier for the document
|
|
42
|
-
*
|
|
41
|
+
* - documentReference: A unique identifier for the document, used to track it across scans.
|
|
42
|
+
* Compose it with `buildDocumentReference(prefix, id)`: you pick a prefix naming your
|
|
43
|
+
* platform and supply an id that is stable for the document. The `<prefix>:<id>` format is
|
|
44
|
+
* shared with every other Markup surface, so the same document correlates across products,
|
|
45
|
+
* and the Markup session id's document component is derived from it.
|
|
46
|
+
*
|
|
47
|
+
* Choose the prefix once and never change it — it is part of the document's identity, and
|
|
48
|
+
* changing it re-keys every document you have checked. Use the same reference for a whole
|
|
49
|
+
* document and for a selection within it. A bare, unprefixed value is still accepted and
|
|
50
|
+
* behaves as before; it simply cannot be correlated with the same document seen elsewhere.
|
|
43
51
|
* - documentName: A human-readable name/title for the document (e.g., "My Report.docx").
|
|
44
52
|
* Optional; when absent, the sidebar will attempt to derive it from documentReference if it
|
|
45
53
|
* contains a filename with extension.
|
|
@@ -152,6 +160,50 @@ export interface SidebarConfig {
|
|
|
152
160
|
* If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false
|
|
153
161
|
*/
|
|
154
162
|
supportCheckSelection?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Whether the sidebar may run several agents concurrently in one check.
|
|
165
|
+
*
|
|
166
|
+
* When `false` or omitted (the default), only the Style agent is offered and
|
|
167
|
+
* run, and a check is dispatched as a single-agent run. When `true`, the
|
|
168
|
+
* sidebar offers every agent the organization is entitled to and fans the
|
|
169
|
+
* selected ones out through the parallel executor, streaming results per
|
|
170
|
+
* agent; each agent can then be cancelled independently of the others.
|
|
171
|
+
*
|
|
172
|
+
* The host flag and the organization's entitlement **intersect**: enabling
|
|
173
|
+
* this never grants access to an agent the organization does not have, and an
|
|
174
|
+
* entitled agent is never offered while this is `false`.
|
|
175
|
+
*/
|
|
176
|
+
multiAgent?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Whether the sidebar retains check results and issue decisions separately
|
|
179
|
+
* per document, for hosts that let a user switch between several open
|
|
180
|
+
* documents (e.g. a tabbed editor).
|
|
181
|
+
*
|
|
182
|
+
* When `false` or omitted (the default), the sidebar holds a single shared
|
|
183
|
+
* check state regardless of any `onActiveDocumentChanged` calls the host
|
|
184
|
+
* makes. When `true`, switching the active document preserves the
|
|
185
|
+
* outgoing document's results and restores the incoming document's
|
|
186
|
+
* previously retained results, if any.
|
|
187
|
+
*/
|
|
188
|
+
multiDocument?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* The document the host considers active at the moment it responds to
|
|
191
|
+
* `getInitConfig()` — `null` if none is checkable right now, or omitted if
|
|
192
|
+
* the host doesn't know or doesn't support reporting it yet.
|
|
193
|
+
*
|
|
194
|
+
* This is a **one-time snapshot resolved at init**, not a live-updating
|
|
195
|
+
* field — `SidebarConfig` is fetched once per session, so later changes to
|
|
196
|
+
* the active document must still go through `notifyActiveDocumentChanged`.
|
|
197
|
+
* Only meaningful when `multiDocument` is `true`; ignored otherwise.
|
|
198
|
+
*
|
|
199
|
+
* Supplying this lets the sidebar show its "nothing to check" state
|
|
200
|
+
* immediately on load instead of only after a subsequent
|
|
201
|
+
* `notifyActiveDocumentChanged` call. Omit it if the host cannot answer
|
|
202
|
+
* the question at init time — the sidebar falls back to waiting for that
|
|
203
|
+
* later call (or its own passive detection from the first `getContent()`
|
|
204
|
+
* response) exactly as it does today.
|
|
205
|
+
*/
|
|
206
|
+
initialActiveDocumentReference?: string | null;
|
|
155
207
|
/**
|
|
156
208
|
* How the sidebar should run the Auth0 login flow. When omitted, the sidebar
|
|
157
209
|
* falls back to heuristic strategy selection (iframe context, secure origin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;GAIG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,oBAAoB,yBAAyB;CAC9C;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,2GAKlB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names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E,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yGAAyG;IACzG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -7,13 +7,16 @@ import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta } from ".
|
|
|
7
7
|
export interface PluginInterface {
|
|
8
8
|
/**
|
|
9
9
|
* Get content from the editor in whatever format the integration supports
|
|
10
|
-
* The integration must provide content and documentReference; documentName and mimeType are optional
|
|
10
|
+
* The integration must provide content and documentReference; documentName and mimeType are optional.
|
|
11
|
+
* Compose `documentReference` with the exported `buildDocumentReference(prefix, id)` helper —
|
|
12
|
+
* see {@link ContentInfo.documentReference} for why.
|
|
11
13
|
* @returns Promise that resolves with content info including documentReference and optional documentName/mimeType
|
|
12
14
|
*/
|
|
13
15
|
getContent: () => Promise<ContentInfo>;
|
|
14
16
|
/**
|
|
15
17
|
* Get selected content from the editor in whatever format the integration supports
|
|
16
|
-
* The integration must provide content and documentReference; documentName and mimeType are optional
|
|
18
|
+
* The integration must provide content and documentReference; documentName and mimeType are optional.
|
|
19
|
+
* Same `documentReference` as the whole document — see {@link ContentInfo.documentReference}.
|
|
17
20
|
* @returns Promise that resolves with content info including documentReference and optional documentName/mimeType
|
|
18
21
|
*/
|
|
19
22
|
getSelectedContent: () => Promise<ContentInfo>;
|
|
@@ -21,17 +24,21 @@ export interface PluginInterface {
|
|
|
21
24
|
* Replace content in the editor using document offsets only.
|
|
22
25
|
* @param suggestion - Replacement text for the span `[range.start, range.end)`
|
|
23
26
|
* @param range - Half-open document span to replace
|
|
27
|
+
* @param documentReference - The document to apply the edit to. Omitted or
|
|
28
|
+
* `null` means the integration's currently active document.
|
|
24
29
|
* @returns Promise that resolves when replacement is complete
|
|
25
30
|
* @throws {TextLookupError} When the requested text cannot be found or located (see ReplaceContentError)
|
|
26
31
|
*/
|
|
27
|
-
replaceContent: (suggestion: string, range: ContentRange) => Promise<void>;
|
|
32
|
+
replaceContent: (suggestion: string, range: ContentRange, documentReference?: string | null) => Promise<void>;
|
|
28
33
|
/**
|
|
29
34
|
* Select or highlight content in the editor using document character offsets only.
|
|
30
35
|
* @param range - Half-open document span `[range.start, range.end)` to select (same semantics as `replaceContent`'s `range`)
|
|
36
|
+
* @param documentReference - The document to select within. Omitted or
|
|
37
|
+
* `null` means the integration's currently active document.
|
|
31
38
|
* @returns Promise that resolves when selection is complete
|
|
32
39
|
* @throws {TextLookupError} When the requested text cannot be found or located (see SelectContentError)
|
|
33
40
|
*/
|
|
34
|
-
selectContent: (range: ContentRange) => Promise<void>;
|
|
41
|
+
selectContent: (range: ContentRange, documentReference?: string | null) => Promise<void>;
|
|
35
42
|
/**
|
|
36
43
|
* Show a dialog in the editor.
|
|
37
44
|
*
|
|
@@ -70,12 +77,20 @@ export interface PluginInterface {
|
|
|
70
77
|
/**
|
|
71
78
|
* Called when one agent's results are available during agentic streaming.
|
|
72
79
|
* Enables the plugin to render underlines or update UI per agent as results arrive.
|
|
80
|
+
*
|
|
81
|
+
* @param documentReference - The document the check was run against (the
|
|
82
|
+
* run's originating document, not necessarily the host's currently active
|
|
83
|
+
* one — a check keeps streaming results after the active document
|
|
84
|
+
* changes). `null` when `multiDocument` is not enabled.
|
|
73
85
|
*/
|
|
74
|
-
onAgenticAgentResults?: (agentName: string, issues: AgenticIssuePayload[]) => Promise<void>;
|
|
86
|
+
onAgenticAgentResults?: (agentName: string, issues: AgenticIssuePayload[], documentReference: string | null) => Promise<void>;
|
|
75
87
|
/**
|
|
76
88
|
* Called when the agentic stream has finished (all agents done or completion/error event).
|
|
89
|
+
*
|
|
90
|
+
* @param documentReference - The document the check was run against. `null`
|
|
91
|
+
* when `multiDocument` is not enabled. See {@link PluginInterface.onAgenticAgentResults}.
|
|
77
92
|
*/
|
|
78
|
-
onAgenticStreamComplete?: () => Promise<void>;
|
|
93
|
+
onAgenticStreamComplete?: (documentReference: string | null) => Promise<void>;
|
|
79
94
|
/**
|
|
80
95
|
* Called by the sidebar after every successful status transition for an
|
|
81
96
|
* agentic issue. Fires for transitions driven by sidebar card affordances
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B
|
|
1
|
+
{"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAEvC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/C;;;;;;;;OAQG;IACH,cAAc,EAAE,CACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,KAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;OAOG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzF;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,CACX,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE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@@ -35,8 +35,13 @@ export interface SidebarInterface {
|
|
|
35
35
|
/**
|
|
36
36
|
* Request the sidebar to activate (expand and scroll to) the card for the given issue.
|
|
37
37
|
* Used when the user clicks an underline in the document so the sidebar focuses that issue.
|
|
38
|
+
*
|
|
39
|
+
* @param documentReference - The document the issue belongs to. When it
|
|
40
|
+
* differs from the sidebar's currently displayed document, the sidebar
|
|
41
|
+
* switches to it before activating. Omitted or `null` means the
|
|
42
|
+
* sidebar's currently displayed document (prior behavior).
|
|
38
43
|
*/
|
|
39
|
-
activateAgenticIssue?: (issueId: string) => Promise<void>;
|
|
44
|
+
activateAgenticIssue?: (issueId: string, documentReference?: string | null) => Promise<void>;
|
|
40
45
|
/**
|
|
41
46
|
* Request the sidebar to invalidate (dismiss) the card for the given issue.
|
|
42
47
|
* Used when the plugin wants to programmatically dismiss an issue (e.g. after replacement).
|
|
@@ -91,5 +96,21 @@ export interface SidebarInterface {
|
|
|
91
96
|
* implementation always provides it.
|
|
92
97
|
*/
|
|
93
98
|
getIntegrationSettings?: () => Promise<IntegrationSettingsSnapshot>;
|
|
99
|
+
/**
|
|
100
|
+
* Notify the sidebar that the user switched which document is active in a
|
|
101
|
+
* multi-document host (e.g. a tabbed editor). Only meaningful when the
|
|
102
|
+
* host's init config sets `multiDocument: true`; the sidebar SHALL ignore
|
|
103
|
+
* this call otherwise.
|
|
104
|
+
*
|
|
105
|
+
* `documentReference` must match the `documentReference` returned in that
|
|
106
|
+
* document's `ContentInfo` — the same value built with
|
|
107
|
+
* `buildDocumentReference(prefix, id)`, not a re-derivation. Pass `null` when there is no checkable
|
|
108
|
+
* document currently active — every tab closed, or the active tab is
|
|
109
|
+
* content the host does not consider checkable — which the sidebar treats
|
|
110
|
+
* as a deliberate signal, not a malformed value. An empty string, by
|
|
111
|
+
* contrast, is ignored as malformed; the sidebar's active document stays
|
|
112
|
+
* whatever it was.
|
|
113
|
+
*/
|
|
114
|
+
onActiveDocumentChanged?: (documentReference: string | null) => Promise<void>;
|
|
94
115
|
}
|
|
95
116
|
//# sourceMappingURL=sidebarInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebarInterface.d.ts","sourceRoot":"","sources":["../../src/types/sidebarInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEnG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAElF
|
|
1
|
+
{"version":3,"file":"sidebarInterface.d.ts","sourceRoot":"","sources":["../../src/types/sidebarInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEnG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAElF;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7F;;;OAGG;IACH,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;;;;OAOG;IACH,wBAAwB,CAAC,EAAE,CAAC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