@markupai/sidebar-adapter 2.1.0 → 2.3.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 +45 -3
- package/asyncapi.json +121 -4
- package/dist/adapters/pluginAdapter.d.ts +9 -0
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/errors.d.ts +38 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +4 -2
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/ipc-core.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +8 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-build-info.d.ts +10 -0
- package/dist/ipc/sidebar-build-info.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +298 -242
- package/dist/main.umd.cjs +6 -6
- package/dist/types/common.d.ts +16 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/errors.d.ts +47 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +3 -0
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(r,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(r=typeof globalThis<"u"?globalThis:r||self,g(r.main={}))})(this,function(r){Object.defineProperty(r,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),K=["text/plain","text/markdown","text/html","application/dita+xml"],q={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,supportCheckSelection:!0,multiAgent:!1,multiDocument:!1},Z=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(n=>{if(typeof n!="object"||n===null)return!1;const i=n;return typeof i.value=="string"&&typeof i.label=="string"}):!1},ee="2.1.0",A=class X extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,X.prototype)}};function te(e){return e instanceof A}var v={TextLookupError:e=>new A(e)};function P(e){const t=e.message??"",n=e.name,i=typeof n=="string"&&n in v?v[n]:void 0;return i?i(t,e):Object.assign(new Error(t),n?{name:n}:{})}var R=":",T=/^[a-z][a-z0-9-]*$/;function ne(e){const t=e.indexOf(R);return t<=0||t===e.length-1?!1:T.test(e.slice(0,t))}function ie(e,t){const n=e.trim().toLowerCase(),i=t.trim();if(!T.test(n))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(i.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${n}${R}`;return i.startsWith(a)?i:`${a}${i}`}var O=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,n;super((i,a)=>{t=i,n=a,e(i,a)}),this.resolve=t,this.reject=n}},_={timeout:1e4};function re(e){const t=JSON.stringify(e,Object.getOwnPropertyNames(e)),n=JSON.parse(t);return n.message===void 0||n.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}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...n){const i=this.currentID++,a=new O,o=t.timeout??this.config.timeout,s=setTimeout(()=>{if(i in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(o)}ms`);a.reject(c),Reflect.deleteProperty(this.promisesByID,i)}},o);this.promisesByID[i]={promise:a,timeoutId:s};const l={type:"call",id:i,name:e,data:n};return this.postMessage(l),a}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:n,data:i}=e;if(!(n in this.receiversByName)){const o=new Error(`No receiver registered for: ${n}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:n,errorJSON:s});return}const a=this.receiversByName[n];try{if(!Array.isArray(i))throw new TypeError(`IPC: Expected array of arguments but got ${typeof i}`);const o=await a(...i),s={type:"response",id:t,name:n,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:n,errorJSON:re(o)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:n,timeoutId:i}=this.promisesByID[t];clearTimeout(i),n.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:n}=e;if(t in this.promisesByID){const{promise:i,timeoutId:a}=this.promisesByID[t];clearTimeout(a);try{const o=JSON.parse(n),s=P(o);i.reject(s)}catch{i.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},D=class{ipc;sidebar;targetOrigin;constructor(e,t,n="*"){this.sidebar=e||{},this.targetOrigin=n,this.ipc=new C(i=>{window.parent.postMessage(i,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,n)=>{await e(t,n)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async(t,n)=>{await e(t,typeof n=="string"?n:null)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}if(this.sidebar.onActiveDocumentChanged){const e=this.sidebar.onActiveDocumentChanged;this.ipc.receive("onActiveDocumentChanged",async t=>{await e(t)})}}async getInitConfig(e){return e?await this.ipc.call("getInitConfig",{...e,adapterVersion:e.adapterVersion??"2.1.0"}):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,n=null){await this.ipc.call("replaceContent",e,t,n)}async selectContent(e,t=null){await this.ipc.call("selectContent",e,t)}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t,n=null){await this.ipc.call("onAgenticAgentResults",e,t,n)}async onAgenticStreamComplete(e=null){await this.ipc.call("onAgenticStreamComplete",e)}async onAgenticIssueStatusChanged(e,t,n){await this.ipc.call("onAgenticIssueStatusChanged",e,t,n)}async onAgenticIssuesCleared(e=null){await this.ipc.call("onAgenticIssuesCleared",e)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},ae=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new D(e,t,n)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(e){return await this.ipcAdapter.getInitConfig(e)}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t,n=null){await this.ipcAdapter.replaceContent(e,t,n)}async selectContent(e,t=null){await this.ipcAdapter.selectContent(e,t)}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t,n=null){return this.ipcAdapter.onAgenticAgentResults(e,t,n)}onAgenticStreamComplete(e=null){return this.ipcAdapter.onAgenticStreamComplete(e)}onAgenticIssueStatusChanged(e,t,n){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,n)}onAgenticIssuesCleared(e=null){return this.ipcAdapter.onAgenticIssuesCleared(e)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_e=64,oe=new Set(["auto","prompt"]),b=(e,t)=>{const n=e[t];if(!(typeof n!="string"||n.length===0))return n.slice(0,64)};function se(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const t=e,n=b(t,"version"),i=b(t,"commitHash");if(n===void 0||i===void 0)return null;const a={version:n,commitHash:i};typeof t.swControlled=="boolean"&&(a.swControlled=t.swControlled),oe.has(t.pwaUpdateMode)&&(a.pwaUpdateMode=t.pwaUpdateMode);const o=b(t,"adapterVersion");return o!==void 0&&(a.adapterVersion=o),a}function De(e,t){if(!e)return`getInitConfig from sidebar build unknown (no valid build report — sidebar predates build reporting; host adapter ${t})`;const n=[e.commitHash];return e.swControlled!==void 0&&n.push(e.swControlled?"sw-controlled":"network"),e.pwaUpdateMode&&n.push(`${e.pwaUpdateMode} update mode`),e.adapterVersion&&n.push(`sidebar adapter ${e.adapterVersion}`),n.push(`host adapter ${t}`),`getInitConfig from sidebar v${e.version} (${n.join(", ")})`}var L=class{ipc;plugin;iframe;window;targetOrigin;latestSidebarBuildInfo=null;constructor(e,t,n,i,a="*"){this.plugin=e,this.iframe=t,this.window=n??window,this.targetOrigin=a,this.ipc=new C(o=>{this.iframe.contentWindow?.postMessage(o,this.targetOrigin)},i),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async e=>{const t=se(e);return this.latestSidebarBuildInfo=t,await this.plugin.getInitConfig(t??void 0)}),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t,n)=>{await this.plugin.replaceContent(e,t,typeof n=="string"?n:null)}),this.ipc.receive("selectContent",async(e,t)=>{await this.plugin.selectContent(e,typeof t=="string"?t:null)}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t,n)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t,typeof n=="string"?n:null)}),this.ipc.receive("onAgenticStreamComplete",async e=>{const t=this.plugin.onAgenticStreamComplete;t&&await t(typeof e=="string"?e:null)}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,n)=>{const i=this.plugin.onAgenticIssueStatusChanged;if(i&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||n!=="user"&&n!=="host"))try{await i(e,t,n)}catch{}}),this.ipc.receive("onAgenticIssuesCleared",async e=>{const t=this.plugin.onAgenticIssuesCleared;if(t)try{await t(typeof e=="string"?e:null)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,n)=>{await e(t,n)})}}async activateAgenticIssue(e,t=null){await this.ipc.call("activateAgenticIssue",e,t)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}async notifyActiveDocumentChanged(e){await this.ipc.call("onActiveDocumentChanged",e)}getSidebarBuildInfo(){return this.latestSidebarBuildInfo}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},M=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new L(e,t,n?.win,n?.config,n?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e,t=null){await this.ipcAdapter.activateAgenticIssue(e,t)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}async notifyActiveDocumentChanged(e){await this.ipcAdapter.notifyActiveDocumentChanged(e)}getSidebarBuildInfo(){return this.ipcAdapter.getSidebarBuildInfo()}configure(e){this.ipcAdapter.configure(e)}},le=`
|
|
1
|
+
(function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.main={}))})(this,function(i){Object.defineProperty(i,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),te=["text/plain","text/markdown","text/html","application/dita+xml"],ne={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,supportCheckSelection:!0,multiAgent:!1,multiDocument:!1},re=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),ie=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(n=>{if(typeof n!="object"||n===null)return!1;const r=n;return typeof r.value=="string"&&typeof r.label=="string"}):!1},R="2.3.0",h=class Q extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,Q.prototype)}},v=class ee extends h{name="ReplaceBatchError";applied;failed;constructor(t,n){super(t),this.applied=n.applied.map(r=>({start:r.start,end:r.end})),this.failed=n.failed.map(r=>T(r,r.message)),Object.setPrototypeOf(this,ee.prototype)}};function ae(e){return e instanceof v}function T(e,t){const n={start:e.start,end:e.end};return typeof t=="string"&&t.trim()!==""&&(n.message=t),n}function O(e){return Array.isArray(e)?e.flatMap(t=>{if(t===null||typeof t!="object")return[];const{start:n,end:r,message:a}=t;return typeof n!="number"||typeof r!="number"?[]:[{range:{start:n,end:r},message:a}]}):[]}function oe(e){return e instanceof h}var C={TextLookupError:e=>new h(e),ReplaceBatchError:(e,t)=>new v(e,{applied:O(t.applied).map(n=>n.range),failed:O(t.failed).map(n=>T(n.range,n.message))})};function _(e){const t=e.message??"",n=e.name,r=typeof n=="string"&&n in C?C[n]:void 0;return r?r(t,e):Object.assign(new Error(t),n?{name:n}:{})}var D=":",L=/^[a-z][a-z0-9-]*$/;function se(e){const t=e.indexOf(D);return t<=0||t===e.length-1?!1:L.test(e.slice(0,t))}function le(e,t){const n=e.trim().toLowerCase(),r=t.trim();if(!L.test(n))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(r.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${n}${D}`;return r.startsWith(a)?r:`${a}${r}`}var M=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,n;super((r,a)=>{t=r,n=a,e(r,a)}),this.resolve=t,this.reject=n}},B={timeout:1e4};function ce(e){const t=typeof e=="object"&&e!==null?Object.fromEntries(Object.getOwnPropertyNames(e).map(s=>[s,e[s]])):{},n=e instanceof Error?e.message:String(e),r=typeof t.message=="string"&&t.message!==""?t.message:n,a=e instanceof Error?e.name:void 0,o=typeof t.name=="string"?t.name:a;return JSON.stringify({...t,message:r,...o!==void 0&&{name:o}})}var b=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...B,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...n){const r=this.currentID++,a=new M,o=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(o)}ms`);a.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},o);this.promisesByID[r]={promise:a,timeoutId:s};const l={type:"call",id:r,name:e,data:n};return this.postMessage(l),a}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:n,data:r}=e;if(!(n in this.receiversByName)){const o=new Error(`No receiver registered for: ${n}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:n,errorJSON:s});return}const a=this.receiversByName[n];try{if(!Array.isArray(r))throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);const o=await a(...r),s={type:"response",id:t,name:n,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:n,errorJSON:ce(o)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:n,timeoutId:r}=this.promisesByID[t];clearTimeout(r),n.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:n}=e;if(t in this.promisesByID){const{promise:r,timeoutId:a}=this.promisesByID[t];clearTimeout(a);try{const o=JSON.parse(n),s=_(o);r.reject(s)}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={}}},Ne=64,de=new Set(["auto","prompt"]),S=(e,t)=>{const n=e[t];if(!(typeof n!="string"||n.length===0))return n.slice(0,64)};function ge(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const t=e,n=S(t,"version"),r=S(t,"commitHash");if(n===void 0||r===void 0)return null;const a={version:n,commitHash:r};typeof t.swControlled=="boolean"&&(a.swControlled=t.swControlled),de.has(t.pwaUpdateMode)&&(a.pwaUpdateMode=t.pwaUpdateMode);const o=S(t,"adapterVersion");return o!==void 0&&(a.adapterVersion=o),a}function ue(e){return typeof e!="string"||e.length===0?null:e.slice(0,64)}function He(e,t){if(!e)return`getInitConfig from sidebar build unknown (no valid build report — sidebar predates build reporting; host adapter ${t})`;const n=[e.commitHash];return e.swControlled!==void 0&&n.push(e.swControlled?"sw-controlled":"network"),e.pwaUpdateMode&&n.push(`${e.pwaUpdateMode} update mode`),e.adapterVersion&&n.push(`sidebar adapter ${e.adapterVersion}`),n.push(`host adapter ${t}`),`getInitConfig from sidebar v${e.version} (${n.join(", ")})`}var k=class{ipc;sidebar;targetOrigin;latestHostAdapterVersion=null;constructor(e,t,n="*"){this.sidebar=e||{},this.targetOrigin=n,this.ipc=new b(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,n)=>{await e(t,n)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async(t,n)=>{await e(t,typeof n=="string"?n:null)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}if(this.sidebar.onActiveDocumentChanged){const e=this.sidebar.onActiveDocumentChanged;this.ipc.receive("onActiveDocumentChanged",async t=>{await e(t)})}}async getInitConfig(e){const{hostAdapterVersion:t,...n}=e?await this.ipc.call("getInitConfig",{...e,adapterVersion:e.adapterVersion??"2.3.0"}):await this.ipc.call("getInitConfig");return this.latestHostAdapterVersion=ue(t),n}getHostAdapterVersion(){return this.latestHostAdapterVersion}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t,n=null){await this.ipc.call("replaceContent",e,t,n)}async selectContent(e,t=null){await this.ipc.call("selectContent",e,t)}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t,n=null){await this.ipc.call("onAgenticAgentResults",e,t,n)}async onAgenticStreamComplete(e=null){await this.ipc.call("onAgenticStreamComplete",e)}async onAgenticIssueStatusChanged(e,t,n){await this.ipc.call("onAgenticIssueStatusChanged",e,t,n)}async onAgenticIssuesCleared(e=null){await this.ipc.call("onAgenticIssuesCleared",e)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},pe=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new k(e,t,n)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(e){return await this.ipcAdapter.getInitConfig(e)}getHostAdapterVersion(){return this.ipcAdapter.getHostAdapterVersion()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t,n=null){await this.ipcAdapter.replaceContent(e,t,n)}async selectContent(e,t=null){await this.ipcAdapter.selectContent(e,t)}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t,n=null){return this.ipcAdapter.onAgenticAgentResults(e,t,n)}onAgenticStreamComplete(e=null){return this.ipcAdapter.onAgenticStreamComplete(e)}onAgenticIssueStatusChanged(e,t,n){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,n)}onAgenticIssuesCleared(e=null){return this.ipcAdapter.onAgenticIssuesCleared(e)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},N=class{ipc;plugin;iframe;window;targetOrigin;latestSidebarBuildInfo=null;constructor(e,t,n,r,a="*"){this.plugin=e,this.iframe=t,this.window=n??window,this.targetOrigin=a,this.ipc=new b(o=>{this.iframe.contentWindow?.postMessage(o,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,n=this.targetOrigin;e.origin!==t&&(n!=="*"&&e.origin!==n||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async e=>{const t=ge(e);return this.latestSidebarBuildInfo=t,{...await this.plugin.getInitConfig(t??void 0),hostAdapterVersion:R}}),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t,n)=>{await this.plugin.replaceContent(e,t,typeof n=="string"?n:null)}),this.ipc.receive("selectContent",async(e,t)=>{await this.plugin.selectContent(e,typeof t=="string"?t:null)}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t,n)=>{if(!Array.isArray(t))return;const r=this.plugin.onAgenticAgentResults;r&&await r(e,t,typeof n=="string"?n:null)}),this.ipc.receive("onAgenticStreamComplete",async e=>{const t=this.plugin.onAgenticStreamComplete;t&&await t(typeof e=="string"?e:null)}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,n)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||n!=="user"&&n!=="host"))try{await r(e,t,n)}catch{}}),this.ipc.receive("onAgenticIssuesCleared",async e=>{const t=this.plugin.onAgenticIssuesCleared;if(t)try{await t(typeof e=="string"?e:null)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,n)=>{await e(t,n)})}}async activateAgenticIssue(e,t=null){await this.ipc.call("activateAgenticIssue",e,t)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}async notifyActiveDocumentChanged(e){await this.ipc.call("onActiveDocumentChanged",e)}getSidebarBuildInfo(){return this.latestSidebarBuildInfo}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},H=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new N(e,t,n?.win,n?.config,n?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e,t=null){await this.ipcAdapter.activateAgenticIssue(e,t)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}async notifyActiveDocumentChanged(e){await this.ipcAdapter.notifyActiveDocumentChanged(e)}getSidebarBuildInfo(){return this.ipcAdapter.getSidebarBuildInfo()}configure(e){this.ipcAdapter.configure(e)}},he=`
|
|
2
2
|
<div class="sidebar-load-overlay-card">
|
|
3
3
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
4
4
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<span>Retry</span>
|
|
20
20
|
</button>
|
|
21
21
|
</div>
|
|
22
|
-
`,
|
|
22
|
+
`,fe=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=he;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},U="markupai-sidebar-load-overlay-styles",me=`
|
|
23
23
|
:root {
|
|
24
24
|
--background: #f5f5f4;
|
|
25
25
|
--foreground: #333332;
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
box-shadow: 0 0 0 2px
|
|
112
112
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
113
113
|
}
|
|
114
|
-
`,
|
|
114
|
+
`,Ie=e=>{const t=e??document;if(t.getElementById(U))return;const n=t.createElement("style");n.id=U,n.textContent=me,t.head.appendChild(n)},ye=8e3,Ae=12e3,F=(e,t,n={})=>{Ie(e.ownerDocument);const{sidebarUrl:r,targetOrigin:a,timeoutMs:o=ye,retryIntervalMs:s=Ae,messageListenWindow:l}=n,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),f=()=>r??t.src,Be=()=>{if(a)return a;try{return new URL(f()).origin}catch{return"*"}},{overlay:P,button:z}=fe();e.appendChild(P);let m=!1,I,u;const p=d=>{P.style.display=d?"flex":"none"};p(!1);const y=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},Y=()=>{y(),I=globalThis.setTimeout(()=>{m||p(!0)},o)},J=d=>{const A=d?.preserveOverlay??!0;m=!1,A||p(!1),t.src=f(),Y()},ke=()=>{u||s<=0||(u=globalThis.setInterval(()=>{m||J({preserveOverlay:!0})},s))},X=()=>{u&&(globalThis.clearInterval(u),u=void 0)},K=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const A=Be();A!=="*"&&d.origin!==A||(m=!0,y(),X(),p(!1))},q=()=>{y(),p(!0)},Z=()=>{J()};return z.addEventListener("click",Z),t.addEventListener("error",q),c.addEventListener("message",K),Y(),ke(),()=>{y(),X(),t.removeEventListener("error",q),c.removeEventListener("message",K),z.removeEventListener("click",Z),P.remove()}},x="Markup AI Sidebar",$="clipboard-read; clipboard-write",ve="markupai.sidebarNextGen.overrideUrl",Ce="https://sidebar.markup.ai/";function be(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var j="markupai.sidebarNextGen.authOverride";function Se(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const n=globalThis.localStorage.getItem(j)?.trim();if(!n)return e;const r=JSON.parse(n);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function we(e,t){try{return new URL(e).origin}catch(n){return t?.onInvalidUrl?.(e,n),"*"}}function Ee(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function Pe(e){const{iframe:t,iframeMount:n}=e;if(t!==void 0&&n!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(n===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:a,allow:o=$}=n,s=document.createElement("iframe");return s.title=x,s.src=a,o&&s.setAttribute("allow",o),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function Re(e){const{plugin:t,loadOverlayContainer:n,loadOverlayOptions:r,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=Pe(e),l=n!==void 0?F(n,o,r??{}):null;if(t!==void 0){const c=new H(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var w="sidebarContainer",V="markupai-sidebar-host-shell-styles";function G(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(String.raw`sidebar host shell: containerId must match /^[a-zA-Z_][\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);return e}function E(e=w){const t=G(e);return`
|
|
115
115
|
html {
|
|
116
116
|
height: 100%;
|
|
117
117
|
}
|
|
@@ -133,17 +133,17 @@ body {
|
|
|
133
133
|
margin: 0;
|
|
134
134
|
display: block;
|
|
135
135
|
}
|
|
136
|
-
`.trim()}var
|
|
136
|
+
`.trim()}var Te=E();function Oe(e){return e instanceof Document?e:e.ownerDocument}function _e(e,t,n){if(!t||e.getElementById(V))return;const r=e.createElement("style");r.id=V,r.textContent=E(n),e.head.appendChild(r)}function De(e){const{root:t=typeof document<"u"?document:void 0,containerId:n=w,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const a=Oe(t);_e(a,r,n);const o=t instanceof Document?a.getElementById(n):t.querySelector(`#${G(n)}`);if(o instanceof HTMLElement&&(t instanceof Document||t.contains(o)))return o;if(!(t instanceof Document)){const l=a.createElement("div");return l.id=n,t.appendChild(l),l}const s=a.createElement("div");return s.id=n,a.body.appendChild(s),s}function W(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function Le(e){const{title:t="Markup AI Sidebar",headInnerHtml:n="",includePluginHostHead:r=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?W():"",n].filter(f=>f.trim().length>0).join(`
|
|
137
137
|
`);return`<!DOCTYPE html>
|
|
138
138
|
<html ${s}>
|
|
139
139
|
<head>
|
|
140
140
|
<base target="_top" />
|
|
141
141
|
<meta charset="UTF-8" />
|
|
142
|
-
<title>${
|
|
142
|
+
<title>${Me(t)}</title>${c?`
|
|
143
143
|
${c}`:""}
|
|
144
144
|
</head>
|
|
145
145
|
<body ${l}>
|
|
146
146
|
${a}
|
|
147
147
|
</body>
|
|
148
148
|
</html>
|
|
149
|
-
`}function
|
|
149
|
+
`}function Me(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}i.ADAPTER_VERSION=R,i.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=j,i.DEFAULT_IPC_CONFIG=B,i.DEFAULT_SIDEBAR_CONFIG=ne,i.DeferredPromise=M,i.IPCCore=b,i.MimeType=g,i.PluginAdapter=pe,i.PluginIPCAdapter=k,i.ReplaceBatchError=v,i.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=Ce,i.SIDEBAR_HOST_CONTAINER_ID=w,i.SIDEBAR_HOST_SHELL_CSS=Te,i.SIDEBAR_IFRAME_DEFAULT_ALLOW=$,i.SIDEBAR_IFRAME_DEFAULT_TITLE=x,i.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=ve,i.SidebarAdapter=H,i.SidebarIPCAdapter=N,i.TEXT_MIME_TYPES=te,i.TextLookupError=h,i.assertSidebarHostAdapter=Ee,i.buildDocumentReference=le,i.buildSidebarHostHtmlDocument=Le,i.buildSidebarHostShellCss=E,i.buildSidebarPluginHostHeadInnerHtml=W,i.createSidebarHost=Re,i.ensureSidebarHostShell=De,i.getAuthConfigWithOverride=Se,i.getSidebarBaseUrlWithOverride=be,i.ipcErrorReconstructors=C,i.isDocumentReference=se,i.isIntegrationSettingField=ie,i.isIntegrationSettingsSchema=re,i.isReplaceBatchError=ae,i.isTextLookupError=oe,i.reconstructError=_,i.setupSidebarLoadOverlay=F,i.sidebarPostMessageTargetOrigin=we});
|
package/dist/types/common.d.ts
CHANGED
|
@@ -250,6 +250,22 @@ export interface SidebarConfig {
|
|
|
250
250
|
*/
|
|
251
251
|
integrationSettings?: IntegrationSettingsSchema;
|
|
252
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* The `getInitConfig` reply as it crosses the IPC boundary: the integration's
|
|
255
|
+
* {@link SidebarConfig} plus the host adapter's own version stamp.
|
|
256
|
+
*
|
|
257
|
+
* `hostAdapterVersion` is written by the host-side adapter itself from its
|
|
258
|
+
* compiled-in {@link ADAPTER_VERSION}; it always overwrites whatever the
|
|
259
|
+
* integration returned. Integrations never set it — their
|
|
260
|
+
* {@link PluginInterface.getInitConfig} keeps returning a plain `SidebarConfig`.
|
|
261
|
+
* The sidebar-side adapter strips it again before handing the config to the
|
|
262
|
+
* sidebar app and exposes it through `PluginAdapter.getHostAdapterVersion()`.
|
|
263
|
+
* Non-JS host ports set it themselves from their own version.
|
|
264
|
+
*/
|
|
265
|
+
export interface InitConfigResponse extends SidebarConfig {
|
|
266
|
+
/** Version of `@markupai/sidebar-adapter` compiled into the host, e.g. `"2.2.0"`. */
|
|
267
|
+
hostAdapterVersion?: string;
|
|
268
|
+
}
|
|
253
269
|
export declare const DEFAULT_SIDEBAR_CONFIG: SidebarConfig;
|
|
254
270
|
/**
|
|
255
271
|
* Character-offset span of an agentic issue within the document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;GAIG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,oBAAoB,yBAAyB;CAC9C;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,2GAKlB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IACl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AAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yGAAyG;IACzG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ContentRange } from "./common";
|
|
2
|
+
/**
|
|
3
|
+
* Wire shape of the `errorJSON` payload for a `TextLookupError` thrown by a
|
|
4
|
+
* host's `selectContent` / `replaceContent` / `replaceMultipleContents`.
|
|
5
|
+
*
|
|
6
|
+
* The receiving side rebuilds the typed error from `name` through the error
|
|
7
|
+
* registry (`ipcErrorReconstructors`), so a non-JS port must send exactly this
|
|
8
|
+
* `name` for the sidebar to recognise the failure.
|
|
9
|
+
*/
|
|
10
|
+
export interface TextLookupErrorPayload {
|
|
11
|
+
name: "TextLookupError";
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A range (as sent in the call) that the host could not apply, optionally
|
|
16
|
+
* with the reason for that one occurrence.
|
|
17
|
+
*/
|
|
18
|
+
export interface ReplaceBatchFailedRange extends ContentRange {
|
|
19
|
+
/**
|
|
20
|
+
* Why this occurrence failed, written for the author (e.g. "This text was
|
|
21
|
+
* edited since the last check."). The sidebar shows it on that occurrence's
|
|
22
|
+
* card; when omitted it shows its own "text could not be found" message. The
|
|
23
|
+
* error's top-level `message` describes the batch and is shown only on the
|
|
24
|
+
* card the user applied from.
|
|
25
|
+
*/
|
|
26
|
+
message?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wire shape of the `errorJSON` payload for a `ReplaceBatchError`: a
|
|
30
|
+
* `replaceMultipleContents` batch that the host could not apply in full.
|
|
31
|
+
*
|
|
32
|
+
* `applied` lists the ranges (as sent in the call) whose replacement landed in
|
|
33
|
+
* the document; `failed` lists the ranges the host could not locate or verify,
|
|
34
|
+
* each with an optional per-occurrence `message`. A range in neither list was
|
|
35
|
+
* left untouched. A host that verifies the whole
|
|
36
|
+
* batch before editing sends every unverifiable range in `failed` and an empty
|
|
37
|
+
* `applied`.
|
|
38
|
+
*/
|
|
39
|
+
export interface ReplaceBatchErrorPayload {
|
|
40
|
+
name: "ReplaceBatchError";
|
|
41
|
+
message: string;
|
|
42
|
+
applied: ContentRange[];
|
|
43
|
+
failed: ReplaceBatchFailedRange[];
|
|
44
|
+
}
|
|
45
|
+
/** Every `errorJSON` payload the sidebar reconstructs into a typed error. */
|
|
46
|
+
export type KnownIpcErrorPayload = TextLookupErrorPayload | ReplaceBatchErrorPayload;
|
|
47
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,uBAAuB,EAAE,CAAC;CACnC;AAED,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,UAAU,CAAC"}
|
|
@@ -43,6 +43,9 @@ export interface PluginInterface {
|
|
|
43
43
|
* Replace multiple contents in the editor
|
|
44
44
|
* @param replacements - Array of content replacements to apply
|
|
45
45
|
* @returns Promise that resolves when all replacements are complete
|
|
46
|
+
* @throws {ReplaceBatchError} When the batch could not be applied in full; carries
|
|
47
|
+
* the ranges that were applied and the ones that failed (see ReplaceMultipleContentsError)
|
|
48
|
+
* @throws {TextLookupError} When the batch failed and the host cannot say which ranges landed
|
|
46
49
|
*/
|
|
47
50
|
replaceMultipleContents: (replacements: ContentReplacement[]) => Promise<void>;
|
|
48
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAEvC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/C;;;;;;;;OAQG;IACH,cAAc,EAAE,CACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,KAC9B,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