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