@markupai/sidebar-adapter 2.1.0 → 2.2.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 +21 -1
- package/asyncapi.json +64 -3
- package/dist/adapters/pluginAdapter.d.ts +9 -0
- package/dist/adapters/pluginAdapter.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 +140 -125
- 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/package.json +1 -1
package/README.md
CHANGED
|
@@ -487,7 +487,7 @@ For agentic streaming callbacks, issue objects match the exported **`AgenticIssu
|
|
|
487
487
|
|
|
488
488
|
Implement these **on the host** as async functions. The sidebar calls them over IPC and waits on the returned promises (pull style):
|
|
489
489
|
|
|
490
|
-
- `getInitConfig(sidebarBuildInfo?: SidebarBuildInfo): Promise<SidebarConfig>` — Integration display name (`integrationName`), stable machine id (`integrationId`), version, feature flags, etc. See the `integrationName` vs `integrationId` note above. Called once per sidebar load; `sidebarBuildInfo` is the sidebar build that is executing (see [Sidebar build reporting](#sidebar-build-reporting)) — declaring the parameter is optional.
|
|
490
|
+
- `getInitConfig(sidebarBuildInfo?: SidebarBuildInfo): Promise<SidebarConfig>` — Integration display name (`integrationName`), stable machine id (`integrationId`), version, feature flags, etc. See the `integrationName` vs `integrationId` note above. Called once per sidebar load; `sidebarBuildInfo` is the sidebar build that is executing (see [Sidebar build reporting](#sidebar-build-reporting)) — declaring the parameter is optional. On the wire the reply is an `InitConfigResponse` (your `SidebarConfig` plus a `hostAdapterVersion` the adapter stamps itself, see [Host adapter version, sidebar side](#host-adapter-version-sidebar-side)).
|
|
491
491
|
- `getContent(): Promise<ContentInfo>` — Full document (or main buffer) text; must include `documentReference`; `mimeType` optional
|
|
492
492
|
- `getSelectedContent(): Promise<ContentInfo>` — Current selection; same `ContentInfo` rules as `getContent`
|
|
493
493
|
- `selectContent(range: ContentRange, documentReference?: string | null): Promise<void>` — Focus/highlight the document span `[range.start, range.end)`. `documentReference` names the target document for multi-document hosts; omitted/`null` means "whichever document is currently active" (the single-document default — see [Multi-document hosts](#multi-document-hosts))
|
|
@@ -945,6 +945,26 @@ const build = sidebarAdapter.getSidebarBuildInfo(); // SidebarBuildInfo | null
|
|
|
945
945
|
- `swControlled: true` alone does not mean "stale" — compare `version`/`commitHash` with the server's `/sidebar-info.json` if you need that verdict.
|
|
946
946
|
- Fully backward compatible: handlers declared without the parameter keep compiling, older adapters ignore the argument, and older sidebars simply don't send it.
|
|
947
947
|
|
|
948
|
+
### Host adapter version, sidebar side
|
|
949
|
+
|
|
950
|
+
The report also flows the other way. The host-side adapter stamps its own compiled version onto every `getInitConfig` reply, so the sidebar can tell which `@markupai/sidebar-adapter` your integration bundles and attribute analytics (adapter adoption, sidebar-vs-host version skew) to it. **You do nothing**: your `getInitConfig` handler keeps returning a plain `SidebarConfig`, and the adapter adds the stamp on the wire — always with its own version, overwriting any `hostAdapterVersion` an integration might return.
|
|
951
|
+
|
|
952
|
+
```ts
|
|
953
|
+
// Wire shape of the reply (you never construct this yourself)
|
|
954
|
+
interface InitConfigResponse extends SidebarConfig {
|
|
955
|
+
hostAdapterVersion?: string; // @markupai/sidebar-adapter version inside the host, e.g. "2.2.0"
|
|
956
|
+
}
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
On the sidebar side, `PluginAdapter` sanitizes the stamp (non-empty string, capped at 64 characters), strips it from the config it resolves, and exposes it separately:
|
|
960
|
+
|
|
961
|
+
```ts
|
|
962
|
+
const config = await pluginAdapter.getInitConfig(buildInfo); // plain SidebarConfig
|
|
963
|
+
const hostAdapter = pluginAdapter.getHostAdapterVersion(); // string | null
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
`null` means no valid stamp arrived — the host adapter predates 2.2.0. Non-JS host ports set `hostAdapterVersion` on their own reply; the field is described in `asyncapi.json` as the `getInitConfig` response payload.
|
|
967
|
+
|
|
948
968
|
## Development
|
|
949
969
|
|
|
950
970
|
The commands below are for **contributors** working on this npm package’s source. If you only consume **`@markupai/sidebar-adapter`** from your app, you do not need to run them.
|
package/asyncapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"asyncapi": "3.0.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Markup AI Sidebar IPC contract",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.2.0",
|
|
6
6
|
"description": "Bidirectional RPC-over-postMessage contract between the Markup AI sidebar and its host. Generated from the @markupai/sidebar-adapter TypeScript types — do not hand-edit."
|
|
7
7
|
},
|
|
8
8
|
"channels": {
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"action": "send",
|
|
198
198
|
"channel": { "$ref": "#/channels/sidebarToPlugin" },
|
|
199
199
|
"title": "getInitConfig",
|
|
200
|
-
"description": "Get initialization configuration from the editor. sidebarBuildInfo reports the sidebar build that is executing (absent from sidebars that predate build reporting).",
|
|
200
|
+
"description": "Get initialization configuration from the editor. sidebarBuildInfo reports the sidebar build that is executing (absent from sidebars that predate build reporting). The reply is the integration's SidebarConfig plus hostAdapterVersion, stamped by the host adapter itself (absent from host adapters that predate version stamping).",
|
|
201
201
|
"x-optional": false,
|
|
202
202
|
"messages": [{ "$ref": "#/channels/sidebarToPlugin/messages/getInitConfig_call" }],
|
|
203
203
|
"reply": {
|
|
@@ -692,7 +692,7 @@
|
|
|
692
692
|
"type": { "const": "response" },
|
|
693
693
|
"id": { "type": "integer" },
|
|
694
694
|
"name": { "const": "getInitConfig" },
|
|
695
|
-
"data": { "$ref": "#/components/schemas/
|
|
695
|
+
"data": { "$ref": "#/components/schemas/InitConfigResponse" }
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
},
|
|
@@ -1516,6 +1516,67 @@
|
|
|
1516
1516
|
"description": "A single option in an {@link IntegrationSettingEnumField } dropdown. `value` is the stable persisted key; `label` is the user-visible display text.",
|
|
1517
1517
|
"title": "IntegrationSettingEnumOption"
|
|
1518
1518
|
},
|
|
1519
|
+
"InitConfigResponse": {
|
|
1520
|
+
"type": "object",
|
|
1521
|
+
"properties": {
|
|
1522
|
+
"integrationName": {
|
|
1523
|
+
"type": "string",
|
|
1524
|
+
"description": "Human-readable name of the underlying integration. **Display only** — shown verbatim to the user (e.g. on the sidebar's About page). Never derive a machine identifier from this string; use {@link SidebarConfig.integrationId } for that. Example: `\"Madcap Flare Desktop\"`."
|
|
1525
|
+
},
|
|
1526
|
+
"integrationVersion": {
|
|
1527
|
+
"type": "string",
|
|
1528
|
+
"description": "Version string of the host integration (the plugin/add-in build, not the sidebar or this adapter). Display only — e.g. shown on the sidebar's About page next to {@link SidebarConfig.integrationName } . Free-form; hosts typically pass their own package/build version such as `\"1.4.2\"`."
|
|
1529
|
+
},
|
|
1530
|
+
"hostAppVersion": {
|
|
1531
|
+
"type": "string",
|
|
1532
|
+
"description": "Version string of the host application/editor itself — the surrounding app the plugin/add-in runs inside (e.g. the Figma desktop app build, or the Madcap Flare version), not the plugin's own version ( {@link SidebarConfig.integrationVersion } ) or the sidebar's/adapter's. Display only — appended to the integration name/version line on the sidebar's About page when present. Omit when the host cannot report its own version; the About page leaves it out rather than showing a placeholder."
|
|
1533
|
+
},
|
|
1534
|
+
"integrationId": {
|
|
1535
|
+
"type": "string",
|
|
1536
|
+
"description": "Stable, machine-readable identifier for the integration. Used for everything non-display: the Auth0 mediation login provider, PostHog analytics keys, the `x-integration-id` API header, and per-integration settings storage. Should be a stable slug (lowercase, hyphenated, no spaces) that does not change between releases. Example: `\"madcap-flare-desktop\"`.\n\nOptional for backward compatibility: when omitted the sidebar falls back to `DEFAULT_SIDEBAR_CONFIG.integrationId` (`\"markupai-sidebar-app\"`). Hosts that use mediation login or want per-integration analytics/storage should set it."
|
|
1537
|
+
},
|
|
1538
|
+
"hideBanner": {
|
|
1539
|
+
"type": "boolean",
|
|
1540
|
+
"description": "Hide the promotional/upsell banner the sidebar shows by default. Set `true` for embedded hosts where the banner is inappropriate (e.g. Figma, Office task pane). Defaults to `false` when omitted."
|
|
1541
|
+
},
|
|
1542
|
+
"pluginOrigin": {
|
|
1543
|
+
"type": "string",
|
|
1544
|
+
"description": "Origin of the plugin/editor window where messages should be sent This is the origin where the plugin is listening for messages from the sidebar"
|
|
1545
|
+
},
|
|
1546
|
+
"supportCheckSelection": {
|
|
1547
|
+
"type": "boolean",
|
|
1548
|
+
"description": "Whether to support selection-based check and rewrite functionality If true or undefined (default), the selection toggle UI will be shown and users can toggle between full content and selection modes If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false"
|
|
1549
|
+
},
|
|
1550
|
+
"multiAgent": {
|
|
1551
|
+
"type": "boolean",
|
|
1552
|
+
"description": "Whether the sidebar may run several agents concurrently in one check.\n\nWhen `false` or omitted (the default), only the Style agent is offered and run, and a check is dispatched as a single-agent run. When `true`, the sidebar offers every agent the organization is entitled to and fans the selected ones out through the parallel executor, streaming results per agent; each agent can then be cancelled independently of the others.\n\nThe host flag and the organization's entitlement **intersect**: enabling this never grants access to an agent the organization does not have, and an entitled agent is never offered while this is `false`."
|
|
1553
|
+
},
|
|
1554
|
+
"multiDocument": {
|
|
1555
|
+
"type": "boolean",
|
|
1556
|
+
"description": "Whether the sidebar retains check results and issue decisions separately per document, for hosts that let a user switch between several open documents (e.g. a tabbed editor).\n\nWhen `false` or omitted (the default), the sidebar holds a single shared check state regardless of any `onActiveDocumentChanged` calls the host makes. When `true`, switching the active document preserves the outgoing document's results and restores the incoming document's previously retained results, if any."
|
|
1557
|
+
},
|
|
1558
|
+
"initialActiveDocumentReference": {
|
|
1559
|
+
"type": ["string", "null"],
|
|
1560
|
+
"description": "The document the host considers active at the moment it responds to `getInitConfig()` — `null` if none is checkable right now, or omitted if the host doesn't know or doesn't support reporting it yet.\n\nThis is a **one-time snapshot resolved at init**, not a live-updating field — `SidebarConfig` is fetched once per session, so later changes to the active document must still go through `notifyActiveDocumentChanged`. Only meaningful when `multiDocument` is `true`; ignored otherwise.\n\nSupplying this lets the sidebar show its \"nothing to check\" state immediately on load instead of only after a subsequent `notifyActiveDocumentChanged` call. Omit it if the host cannot answer the question at init time — the sidebar falls back to waiting for that later call (or its own passive detection from the first `getContent()` response) exactly as it does today."
|
|
1561
|
+
},
|
|
1562
|
+
"auth": {
|
|
1563
|
+
"$ref": "#/components/schemas/AuthConfig",
|
|
1564
|
+
"description": "How the sidebar should run the Auth0 login flow. When omitted, the sidebar falls back to heuristic strategy selection (iframe context, secure origin, etc.) for backwards compatibility. New integrations should set this explicitly; `\"mediation\"` is the correct choice for hosts that embed the sidebar in an iframe (Figma, Office task pane).\n\nIn dev builds, the sidebar also honors a `localStorage` override at the key exported as `AUTH_CONFIG_OVERRIDE_STORAGE_KEY` — see `getAuthConfigWithOverride` in `sidebar-host`."
|
|
1565
|
+
},
|
|
1566
|
+
"integrationSettings": {
|
|
1567
|
+
"$ref": "#/components/schemas/IntegrationSettingsSchema",
|
|
1568
|
+
"description": "Optional declarative schema of host-supplied settings rendered in the sidebar's Settings surface. When omitted, no integration-settings section is rendered and no related IPC traffic is emitted.\n\nSee `@markupai/sidebar-adapter` README → \"Integration settings\" for the shape and lifecycle."
|
|
1569
|
+
},
|
|
1570
|
+
"hostAdapterVersion": {
|
|
1571
|
+
"type": "string",
|
|
1572
|
+
"description": "Version of `@markupai/sidebar-adapter` compiled into the host, e.g. `\"2.2.0\"`."
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
"additionalProperties": false,
|
|
1576
|
+
"required": ["integrationName", "integrationVersion"],
|
|
1577
|
+
"description": "The `getInitConfig` reply as it crosses the IPC boundary: the integration's {@link SidebarConfig } plus the host adapter's own version stamp.\n\n`hostAdapterVersion` is written by the host-side adapter itself from its compiled-in {@link ADAPTER_VERSION } ; it always overwrites whatever the integration returned. Integrations never set it — their {@link PluginInterface.getInitConfig } keeps returning a plain `SidebarConfig`. The sidebar-side adapter strips it again before handing the config to the sidebar app and exposes it through `PluginAdapter.getHostAdapterVersion()`. Non-JS host ports set it themselves from their own version.",
|
|
1578
|
+
"title": "InitConfigResponse"
|
|
1579
|
+
},
|
|
1519
1580
|
"AgenticIssuePosition": {
|
|
1520
1581
|
"type": "object",
|
|
1521
1582
|
"properties": {
|
|
@@ -22,6 +22,15 @@ export declare class PluginAdapter {
|
|
|
22
22
|
* automatically. Omit to send no report.
|
|
23
23
|
*/
|
|
24
24
|
getInitConfig(sidebarBuildInfo?: SidebarBuildInfo): Promise<SidebarConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* The `@markupai/sidebar-adapter` version the host stamped onto its most
|
|
27
|
+
* recent `getInitConfig` reply — the adapter compiled into the host, not a
|
|
28
|
+
* value the integration chose. Compare it with the sidebar's own
|
|
29
|
+
* {@link ADAPTER_VERSION} to spot contract skew. `null` before the first
|
|
30
|
+
* reply, and when the host adapter predates version stamping (below 2.2.0).
|
|
31
|
+
* Replaced on every reply, so it tracks host reloads.
|
|
32
|
+
*/
|
|
33
|
+
getHostAdapterVersion(): string | null;
|
|
25
34
|
/**
|
|
26
35
|
* Request content from the editor in whatever format the integration supports
|
|
27
36
|
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/pluginAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAA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AAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;;;;OAKG;IACI,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;;;;OAKG;IACI,2BAA2B,CAChC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,IAAI,CAAC;IAIhB;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAIlD;;OAEG;IACI,eAAe,IAAI,MAAM;CAGjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentRange, ContentReplacement, ContentInfo,
|
|
1
|
+
import type { ContentRange, ContentReplacement, ContentInfo, InitConfigResponse, SidebarBuildInfo, AgenticIssuePayload, PluginStatusType } from "../types/common";
|
|
2
2
|
import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta, IntegrationSettingsPatch, IntegrationSettingsSnapshot } from "../types/integrationSettings";
|
|
3
3
|
/**
|
|
4
4
|
* Call signatures for all bidirectional IPC communication.
|
|
@@ -39,8 +39,10 @@ export interface CallSignatures {
|
|
|
39
39
|
* `sidebarBuildInfo` reports the sidebar build that is executing — see
|
|
40
40
|
* {@link PluginInterface.getInitConfig}. Optional so an older sidebar that
|
|
41
41
|
* sends no argument, and a host receiver declared with none, keep working.
|
|
42
|
+
* The reply is the integration's `SidebarConfig` plus the host adapter's own
|
|
43
|
+
* `hostAdapterVersion` stamp — see {@link InitConfigResponse}.
|
|
42
44
|
*/
|
|
43
|
-
getInitConfig(sidebarBuildInfo?: SidebarBuildInfo): Promise<
|
|
45
|
+
getInitConfig(sidebarBuildInfo?: SidebarBuildInfo): Promise<InitConfigResponse>;
|
|
44
46
|
/**
|
|
45
47
|
* Notify plugin when one agent's agentic results are available (streaming).
|
|
46
48
|
* `documentReference` is the run's originating document (`null` when
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-signatures.d.ts","sourceRoot":"","sources":["../../src/ipc/call-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"call-signatures.d.ts","sourceRoot":"","sources":["../../src/ipc/call-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAK7B;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnC;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3C;;;;;;OAMG;IACH,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAChC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErF;;OAEG;IACH,uBAAuB,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;;;;;;OAQG;IACH,aAAa,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEhF;;;;;OAKG;IACH,qBAAqB,CACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EAAE,EAC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EzD;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;OAGG;IACH,wBAAwB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzE;;;OAGG;IACH,sBAAsB,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAE/D;;;;;OAKG;IACH,uBAAuB,CAAC,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipc-core.d.ts","sourceRoot":"","sources":["../../src/ipc/ipc-core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAGV,UAAU,EAEV,SAAS,EACT,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAK7B,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,cAAc,IAAI,CACvD,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAChD,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ipc-core.d.ts","sourceRoot":"","sources":["../../src/ipc/ipc-core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAGV,UAAU,EAEV,SAAS,EACT,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAK7B,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,cAAc,IAAI,CACvD,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAChD,UAAU,CAAC,WAAW,CA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U;IAgDxB;;OAEG;IACH,OAAO,CAAC,cAAc;IActB;;OAEG;IACH,OAAO,CAAC,WAAW;IAuBnB;;OAEG;IACI,OAAO,IAAI,IAAI;CAWvB"}
|
|
@@ -13,6 +13,7 @@ export declare class PluginIPCAdapter {
|
|
|
13
13
|
private readonly ipc;
|
|
14
14
|
private readonly sidebar;
|
|
15
15
|
private targetOrigin;
|
|
16
|
+
private latestHostAdapterVersion;
|
|
16
17
|
constructor(sidebar?: SidebarInterface, config?: IPCConfig, targetOrigin?: string);
|
|
17
18
|
private readonly handleMessage;
|
|
18
19
|
private registerReceivers;
|
|
@@ -23,6 +24,13 @@ export declare class PluginIPCAdapter {
|
|
|
23
24
|
* the caller leaves it out. Omit to send no report.
|
|
24
25
|
*/
|
|
25
26
|
getInitConfig(sidebarBuildInfo?: SidebarBuildInfo): Promise<SidebarConfig>;
|
|
27
|
+
/**
|
|
28
|
+
* The `@markupai/sidebar-adapter` version the host stamped onto its most
|
|
29
|
+
* recent `getInitConfig` reply, sanitized. `null` before the first reply,
|
|
30
|
+
* and when the host adapter predates version stamping. Replaced on every
|
|
31
|
+
* reply.
|
|
32
|
+
*/
|
|
33
|
+
getHostAdapterVersion(): string | null;
|
|
26
34
|
/**
|
|
27
35
|
* Request content from the editor in whatever format the integration supports
|
|
28
36
|
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/plugin-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/plugin-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAE9E,OAAO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AE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvF;;OAEG;IACU,qBAAqB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EAAE,EAC7B,iBAAiB,GAAE,MAAM,GAAG,IAAW,GACtC,OAAO,CAAC,IAAI,CAAC;IAIhB;;OAEG;IACU,uBAAuB,CAAC,iBAAiB,GAAE,MAAM,GAAG,IAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5F;;;;OAIG;IACU,2BAA2B,CACtC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,EAC3C,MAAM,EAAE,MAAM,GAAG,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;;OAKG;IACU,sBAAsB,CAAC,iBAAiB,GAAE,MAAM,GAAG,IAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3F;;;;OAIG;IACU,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;;;OAIG;IACU,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzD;;;;OAIG;IACU,2BAA2B,CACtC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,IAAI,CAAC;IAIhB;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAkBlD;;OAEG;IACI,eAAe,IAAI,MAAM;IAIhC;;OAEG;IACI,OAAO,IAAI,IAAI;CAKvB"}
|
|
@@ -12,6 +12,16 @@ export declare const SIDEBAR_BUILD_INFO_MAX_STRING_LENGTH = 64;
|
|
|
12
12
|
* a usable `version` or `commitHash`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function sanitizeSidebarBuildInfo(raw: unknown): SidebarBuildInfo | null;
|
|
15
|
+
/**
|
|
16
|
+
* Validate the `hostAdapterVersion` a host stamped onto its `getInitConfig`
|
|
17
|
+
* reply. It crosses a frame boundary, so it is treated as untrusted: only a
|
|
18
|
+
* non-empty string is accepted, truncated to
|
|
19
|
+
* {@link SIDEBAR_BUILD_INFO_MAX_STRING_LENGTH} characters.
|
|
20
|
+
*
|
|
21
|
+
* @returns The sanitized version, or `null` when absent or invalid (a host
|
|
22
|
+
* adapter that predates version stamping sends none).
|
|
23
|
+
*/
|
|
24
|
+
export declare function sanitizeHostAdapterVersion(raw: unknown): string | null;
|
|
15
25
|
/**
|
|
16
26
|
* The adapter's development/test log line for one `getInitConfig` request
|
|
17
27
|
* (stripped from the published build), e.g.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-build-info.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-build-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,oFAAoF;AACpF,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAUvD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAgB9E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAC7B,kBAAkB,EAAE,MAAM,GACzB,MAAM,CAYR"}
|
|
1
|
+
{"version":3,"file":"sidebar-build-info.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-build-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,oFAAoF;AACpF,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAUvD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAgB9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGtE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAC7B,kBAAkB,EAAE,MAAM,GACzB,MAAM,CAYR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sidebar-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EAGV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAGV,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,sBAAsB,CAAiC;gBAG7D,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,iBAAiB,EACzB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,SAAS,EAClB,YAAY,GAAE,MAAY;IAqB5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAqB5B;IAEF,OAAO,CAAC,iBAAiB;IA6KzB;;;;;;;OAOG;IACU,oBAAoB,CAC/B,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,GAAG,IAAW,GACtC,OAAO,CAAC,IAAI,CAAC;IAKhB;;OAEG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE;;OAEG;IACU,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrE;;OAEG;IACU,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhE;;;OAGG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvF;;OAEG;IACU,wBAAwB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrF;;OAEG;IACU,sBAAsB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAK3E;;;;OAIG;IACU,2BAA2B,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzF;;;;;OAKG;IACI,mBAAmB,IAAI,gBAAgB,GAAG,IAAI;IAIrD;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,OAAO,IAAI,IAAI;CAKvB"}
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ge = /* @__PURE__ */ (function(e) {
|
|
2
2
|
return e.TEXT_PLAIN = "text/plain", e.TEXT_MARKDOWN = "text/markdown", e.TEXT_HTML = "text/html", e.APPLICATION_DITA_XML = "application/dita+xml", e;
|
|
3
|
-
})({}),
|
|
3
|
+
})({}), pe = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], ue = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -13,7 +13,7 @@ var ce = /* @__PURE__ */ (function(e) {
|
|
|
13
13
|
supportCheckSelection: !0,
|
|
14
14
|
multiAgent: !1,
|
|
15
15
|
multiDocument: !1
|
|
16
|
-
},
|
|
16
|
+
}, he = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), fe = (e) => {
|
|
17
17
|
if (typeof e != "object" || e === null) return !1;
|
|
18
18
|
const t = e;
|
|
19
19
|
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) => {
|
|
@@ -21,33 +21,33 @@ var ce = /* @__PURE__ */ (function(e) {
|
|
|
21
21
|
const r = n;
|
|
22
22
|
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
23
|
}) : !1;
|
|
24
|
-
},
|
|
24
|
+
}, U = "2.2.0", O = class D extends Error {
|
|
25
25
|
name = "TextLookupError";
|
|
26
26
|
constructor(t) {
|
|
27
27
|
super(t), Object.setPrototypeOf(this, D.prototype);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
function
|
|
31
|
-
return e instanceof
|
|
30
|
+
function me(e) {
|
|
31
|
+
return e instanceof O;
|
|
32
32
|
}
|
|
33
|
-
var E = { TextLookupError: (e) => new
|
|
34
|
-
function
|
|
33
|
+
var E = { TextLookupError: (e) => new O(e) };
|
|
34
|
+
function $(e) {
|
|
35
35
|
const t = e.message ?? "", n = e.name, r = typeof n == "string" && n in E ? E[n] : void 0;
|
|
36
36
|
return r ? r(t, e) : Object.assign(new Error(t), n ? { name: n } : {});
|
|
37
37
|
}
|
|
38
|
-
var x = ":",
|
|
39
|
-
function
|
|
38
|
+
var x = ":", M = /^[a-z][a-z0-9-]*$/;
|
|
39
|
+
function ye(e) {
|
|
40
40
|
const t = e.indexOf(x);
|
|
41
|
-
return t <= 0 || t === e.length - 1 ? !1 :
|
|
41
|
+
return t <= 0 || t === e.length - 1 ? !1 : M.test(e.slice(0, t));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Ie(e, t) {
|
|
44
44
|
const n = e.trim().toLowerCase(), r = t.trim();
|
|
45
|
-
if (!
|
|
45
|
+
if (!M.test(n)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
46
46
|
if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
47
47
|
const i = `${n}${x}`;
|
|
48
48
|
return r.startsWith(i) ? r : `${i}${r}`;
|
|
49
49
|
}
|
|
50
|
-
var
|
|
50
|
+
var j = class extends Promise {
|
|
51
51
|
static get [Symbol.species]() {
|
|
52
52
|
return Promise;
|
|
53
53
|
}
|
|
@@ -60,15 +60,16 @@ var $ = class extends Promise {
|
|
|
60
60
|
t = r, n = i, e(r, i);
|
|
61
61
|
}), this.resolve = t, this.reject = n;
|
|
62
62
|
}
|
|
63
|
-
},
|
|
63
|
+
}, V = { timeout: 1e4 };
|
|
64
64
|
function F(e) {
|
|
65
|
-
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), n =
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
65
|
+
const t = typeof e == "object" && e !== null ? JSON.parse(JSON.stringify(e, Object.getOwnPropertyNames(e))) : {}, n = e instanceof Error ? e.message : String(e), r = typeof t.message == "string" && t.message !== "" ? t.message : n, i = e instanceof Error ? e.name : void 0, a = typeof t.name == "string" ? t.name : i;
|
|
66
|
+
return JSON.stringify({
|
|
67
|
+
...t,
|
|
68
|
+
message: r,
|
|
69
|
+
...a !== void 0 && { name: a }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
var _ = class {
|
|
72
73
|
promisesByID = {};
|
|
73
74
|
receiversByName = {};
|
|
74
75
|
currentID = 0;
|
|
@@ -76,7 +77,7 @@ var M = class {
|
|
|
76
77
|
postMessage;
|
|
77
78
|
constructor(e, t) {
|
|
78
79
|
this.postMessage = e, this.config = {
|
|
79
|
-
...
|
|
80
|
+
...V,
|
|
80
81
|
...t
|
|
81
82
|
};
|
|
82
83
|
}
|
|
@@ -90,7 +91,7 @@ var M = class {
|
|
|
90
91
|
return this.callWithOptions(e, {}, ...t);
|
|
91
92
|
}
|
|
92
93
|
callWithOptions(e, t, ...n) {
|
|
93
|
-
const r = this.currentID++, i = new
|
|
94
|
+
const r = this.currentID++, i = new j(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
94
95
|
if (r in this.promisesByID) {
|
|
95
96
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
96
97
|
i.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
@@ -176,7 +177,7 @@ var M = class {
|
|
|
176
177
|
const { promise: r, timeoutId: i } = this.promisesByID[t];
|
|
177
178
|
clearTimeout(i);
|
|
178
179
|
try {
|
|
179
|
-
const a = JSON.parse(n), o =
|
|
180
|
+
const a = JSON.parse(n), o = $(a);
|
|
180
181
|
r.reject(o);
|
|
181
182
|
} catch {
|
|
182
183
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
@@ -189,12 +190,34 @@ var M = class {
|
|
|
189
190
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
190
191
|
this.promisesByID = {}, this.receiversByName = {};
|
|
191
192
|
}
|
|
192
|
-
}
|
|
193
|
+
};
|
|
194
|
+
var z = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
195
|
+
const n = e[t];
|
|
196
|
+
if (!(typeof n != "string" || n.length === 0))
|
|
197
|
+
return n.slice(0, 64);
|
|
198
|
+
};
|
|
199
|
+
function W(e) {
|
|
200
|
+
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
201
|
+
const t = e, n = I(t, "version"), r = I(t, "commitHash");
|
|
202
|
+
if (n === void 0 || r === void 0) return null;
|
|
203
|
+
const i = {
|
|
204
|
+
version: n,
|
|
205
|
+
commitHash: r
|
|
206
|
+
};
|
|
207
|
+
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), z.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
208
|
+
const a = I(t, "adapterVersion");
|
|
209
|
+
return a !== void 0 && (i.adapterVersion = a), i;
|
|
210
|
+
}
|
|
211
|
+
function G(e) {
|
|
212
|
+
return typeof e != "string" || e.length === 0 ? null : e.slice(0, 64);
|
|
213
|
+
}
|
|
214
|
+
var J = class {
|
|
193
215
|
ipc;
|
|
194
216
|
sidebar;
|
|
195
217
|
targetOrigin;
|
|
218
|
+
latestHostAdapterVersion = null;
|
|
196
219
|
constructor(e, t, n = "*") {
|
|
197
|
-
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new
|
|
220
|
+
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new _((r) => {
|
|
198
221
|
window.parent.postMessage(r, this.targetOrigin);
|
|
199
222
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
200
223
|
}
|
|
@@ -251,10 +274,14 @@ var M = class {
|
|
|
251
274
|
}
|
|
252
275
|
}
|
|
253
276
|
async getInitConfig(e) {
|
|
254
|
-
|
|
277
|
+
const { hostAdapterVersion: t, ...n } = e ? await this.ipc.call("getInitConfig", {
|
|
255
278
|
...e,
|
|
256
|
-
adapterVersion: e.adapterVersion ?? "2.
|
|
279
|
+
adapterVersion: e.adapterVersion ?? "2.2.0"
|
|
257
280
|
}) : await this.ipc.call("getInitConfig");
|
|
281
|
+
return this.latestHostAdapterVersion = G(t), n;
|
|
282
|
+
}
|
|
283
|
+
getHostAdapterVersion() {
|
|
284
|
+
return this.latestHostAdapterVersion;
|
|
258
285
|
}
|
|
259
286
|
async getContent(e) {
|
|
260
287
|
return this.ipc.callWithOptions("getContent", e ?? {});
|
|
@@ -311,10 +338,10 @@ var M = class {
|
|
|
311
338
|
destroy() {
|
|
312
339
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
313
340
|
}
|
|
314
|
-
},
|
|
341
|
+
}, ve = class {
|
|
315
342
|
ipcAdapter;
|
|
316
343
|
constructor(e, t, n) {
|
|
317
|
-
this.ipcAdapter = new
|
|
344
|
+
this.ipcAdapter = new J(e, t, n);
|
|
318
345
|
}
|
|
319
346
|
destroy() {
|
|
320
347
|
this.ipcAdapter.destroy();
|
|
@@ -322,6 +349,9 @@ var M = class {
|
|
|
322
349
|
async getInitConfig(e) {
|
|
323
350
|
return await this.ipcAdapter.getInitConfig(e);
|
|
324
351
|
}
|
|
352
|
+
getHostAdapterVersion() {
|
|
353
|
+
return this.ipcAdapter.getHostAdapterVersion();
|
|
354
|
+
}
|
|
325
355
|
async getContent(e) {
|
|
326
356
|
return await this.ipcAdapter.getContent(e);
|
|
327
357
|
}
|
|
@@ -367,25 +397,7 @@ var M = class {
|
|
|
367
397
|
getTargetOrigin() {
|
|
368
398
|
return this.ipcAdapter.getTargetOrigin();
|
|
369
399
|
}
|
|
370
|
-
}
|
|
371
|
-
var V = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
372
|
-
const n = e[t];
|
|
373
|
-
if (!(typeof n != "string" || n.length === 0))
|
|
374
|
-
return n.slice(0, 64);
|
|
375
|
-
};
|
|
376
|
-
function W(e) {
|
|
377
|
-
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
378
|
-
const t = e, n = I(t, "version"), r = I(t, "commitHash");
|
|
379
|
-
if (n === void 0 || r === void 0) return null;
|
|
380
|
-
const i = {
|
|
381
|
-
version: n,
|
|
382
|
-
commitHash: r
|
|
383
|
-
};
|
|
384
|
-
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), V.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
385
|
-
const a = I(t, "adapterVersion");
|
|
386
|
-
return a !== void 0 && (i.adapterVersion = a), i;
|
|
387
|
-
}
|
|
388
|
-
var G = class {
|
|
400
|
+
}, Y = class {
|
|
389
401
|
ipc;
|
|
390
402
|
plugin;
|
|
391
403
|
iframe;
|
|
@@ -393,7 +405,7 @@ var G = class {
|
|
|
393
405
|
targetOrigin;
|
|
394
406
|
latestSidebarBuildInfo = null;
|
|
395
407
|
constructor(e, t, n, r, i = "*") {
|
|
396
|
-
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new
|
|
408
|
+
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new _((a) => {
|
|
397
409
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
398
410
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
399
411
|
}
|
|
@@ -404,7 +416,10 @@ var G = class {
|
|
|
404
416
|
registerReceivers() {
|
|
405
417
|
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
406
418
|
const t = W(e);
|
|
407
|
-
return this.latestSidebarBuildInfo = t,
|
|
419
|
+
return this.latestSidebarBuildInfo = t, {
|
|
420
|
+
...await this.plugin.getInitConfig(t ?? void 0),
|
|
421
|
+
hostAdapterVersion: U
|
|
422
|
+
};
|
|
408
423
|
}), 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) => {
|
|
409
424
|
await this.plugin.replaceContent(e, t, typeof n == "string" ? n : null);
|
|
410
425
|
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
@@ -485,10 +500,10 @@ var G = class {
|
|
|
485
500
|
destroy() {
|
|
486
501
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
487
502
|
}
|
|
488
|
-
},
|
|
503
|
+
}, X = class {
|
|
489
504
|
ipcAdapter;
|
|
490
505
|
constructor(e, t, n) {
|
|
491
|
-
this.ipcAdapter = new
|
|
506
|
+
this.ipcAdapter = new Y(e, t, n?.win, n?.config, n?.targetOrigin);
|
|
492
507
|
}
|
|
493
508
|
destroy() {
|
|
494
509
|
this.ipcAdapter.destroy();
|
|
@@ -523,7 +538,7 @@ var G = class {
|
|
|
523
538
|
configure(e) {
|
|
524
539
|
this.ipcAdapter.configure(e);
|
|
525
540
|
}
|
|
526
|
-
},
|
|
541
|
+
}, K = `
|
|
527
542
|
<div class="sidebar-load-overlay-card">
|
|
528
543
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
529
544
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -544,16 +559,16 @@ var G = class {
|
|
|
544
559
|
<span>Retry</span>
|
|
545
560
|
</button>
|
|
546
561
|
</div>
|
|
547
|
-
`,
|
|
562
|
+
`, q = () => {
|
|
548
563
|
const e = document.createElement("div");
|
|
549
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
564
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = K;
|
|
550
565
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
551
566
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
552
567
|
return {
|
|
553
568
|
overlay: e,
|
|
554
569
|
button: t
|
|
555
570
|
};
|
|
556
|
-
}, R = "markupai-sidebar-load-overlay-styles",
|
|
571
|
+
}, R = "markupai-sidebar-load-overlay-styles", Z = `
|
|
557
572
|
:root {
|
|
558
573
|
--background: #f5f5f4;
|
|
559
574
|
--foreground: #333332;
|
|
@@ -645,21 +660,21 @@ var G = class {
|
|
|
645
660
|
box-shadow: 0 0 0 2px
|
|
646
661
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
647
662
|
}
|
|
648
|
-
`,
|
|
663
|
+
`, Q = (e) => {
|
|
649
664
|
const t = e ?? document;
|
|
650
665
|
if (t.getElementById(R)) return;
|
|
651
666
|
const n = t.createElement("style");
|
|
652
|
-
n.id = R, n.textContent =
|
|
653
|
-
},
|
|
654
|
-
|
|
655
|
-
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a =
|
|
667
|
+
n.id = R, n.textContent = Z, t.head.appendChild(n);
|
|
668
|
+
}, ee = 8e3, te = 12e3, ne = (e, t, n = {}) => {
|
|
669
|
+
Q(e.ownerDocument);
|
|
670
|
+
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a = ee, retryIntervalMs: o = te, messageListenWindow: s } = n, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, B = () => {
|
|
656
671
|
if (i) return i;
|
|
657
672
|
try {
|
|
658
673
|
return new URL(p()).origin;
|
|
659
674
|
} catch {
|
|
660
675
|
return "*";
|
|
661
676
|
}
|
|
662
|
-
}, { overlay: y, button: v } =
|
|
677
|
+
}, { overlay: y, button: v } = q();
|
|
663
678
|
e.appendChild(y);
|
|
664
679
|
let u = !1, h, d;
|
|
665
680
|
const g = (c) => {
|
|
@@ -675,7 +690,7 @@ var G = class {
|
|
|
675
690
|
}, C = (c) => {
|
|
676
691
|
const m = c?.preserveOverlay ?? !0;
|
|
677
692
|
u = !1, m || g(!1), t.src = p(), A();
|
|
678
|
-
},
|
|
693
|
+
}, H = () => {
|
|
679
694
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
680
695
|
u || C({ preserveOverlay: !0 });
|
|
681
696
|
}, o));
|
|
@@ -690,23 +705,23 @@ var G = class {
|
|
|
690
705
|
}, P = () => {
|
|
691
706
|
C();
|
|
692
707
|
};
|
|
693
|
-
return v.addEventListener("click", P), t.addEventListener("error", w), l.addEventListener("message", S), A(),
|
|
708
|
+
return v.addEventListener("click", P), t.addEventListener("error", w), l.addEventListener("message", S), A(), H(), () => {
|
|
694
709
|
f(), b(), t.removeEventListener("error", w), l.removeEventListener("message", S), v.removeEventListener("click", P), y.remove();
|
|
695
710
|
};
|
|
696
|
-
},
|
|
697
|
-
function
|
|
711
|
+
}, re = "Markup AI Sidebar", ie = "clipboard-read; clipboard-write", Ae = "markupai.sidebarNextGen.overrideUrl", Ce = "https://sidebar.markup.ai/";
|
|
712
|
+
function be(e) {
|
|
698
713
|
try {
|
|
699
714
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
700
715
|
} catch {
|
|
701
716
|
return e;
|
|
702
717
|
}
|
|
703
718
|
}
|
|
704
|
-
var
|
|
705
|
-
function
|
|
719
|
+
var ae = "markupai.sidebarNextGen.authOverride";
|
|
720
|
+
function Se(e, t) {
|
|
706
721
|
if (!t) return e;
|
|
707
722
|
try {
|
|
708
723
|
if (!("localStorage" in globalThis)) return e;
|
|
709
|
-
const n = globalThis.localStorage.getItem(
|
|
724
|
+
const n = globalThis.localStorage.getItem(ae)?.trim();
|
|
710
725
|
if (!n) return e;
|
|
711
726
|
const r = JSON.parse(n);
|
|
712
727
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -714,17 +729,17 @@ function be(e, t) {
|
|
|
714
729
|
return e;
|
|
715
730
|
}
|
|
716
731
|
}
|
|
717
|
-
function
|
|
732
|
+
function we(e, t) {
|
|
718
733
|
try {
|
|
719
734
|
return new URL(e).origin;
|
|
720
735
|
} catch (n) {
|
|
721
736
|
return t?.onInvalidUrl?.(e, n), "*";
|
|
722
737
|
}
|
|
723
738
|
}
|
|
724
|
-
function
|
|
739
|
+
function Pe(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
725
740
|
if (e.adapter === null) throw new Error(t);
|
|
726
741
|
}
|
|
727
|
-
function
|
|
742
|
+
function oe(e) {
|
|
728
743
|
const { iframe: t, iframeMount: n } = e;
|
|
729
744
|
if (t !== void 0 && n !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
730
745
|
if (t !== void 0) return {
|
|
@@ -732,18 +747,18 @@ function ie(e) {
|
|
|
732
747
|
removeMountedIframe: null
|
|
733
748
|
};
|
|
734
749
|
if (n === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
735
|
-
const { container: r, src: i, allow: a =
|
|
736
|
-
return o.title =
|
|
750
|
+
const { container: r, src: i, allow: a = ie } = n, o = document.createElement("iframe");
|
|
751
|
+
return o.title = re, o.src = i, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
737
752
|
iframe: o,
|
|
738
753
|
removeMountedIframe: () => {
|
|
739
754
|
o.remove();
|
|
740
755
|
}
|
|
741
756
|
};
|
|
742
757
|
}
|
|
743
|
-
function
|
|
744
|
-
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } =
|
|
758
|
+
function Ee(e) {
|
|
759
|
+
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = oe(e), s = n !== void 0 ? ne(n, a, r ?? {}) : null;
|
|
745
760
|
if (t !== void 0) {
|
|
746
|
-
const l = new
|
|
761
|
+
const l = new X(t, a, i);
|
|
747
762
|
return {
|
|
748
763
|
iframe: a,
|
|
749
764
|
adapter: l,
|
|
@@ -760,7 +775,7 @@ function Pe(e) {
|
|
|
760
775
|
}
|
|
761
776
|
};
|
|
762
777
|
}
|
|
763
|
-
var L = "sidebarContainer",
|
|
778
|
+
var L = "sidebarContainer", T = "markupai-sidebar-host-shell-styles";
|
|
764
779
|
function k(e) {
|
|
765
780
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
766
781
|
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)})`);
|
|
@@ -792,20 +807,20 @@ body {
|
|
|
792
807
|
}
|
|
793
808
|
`.trim();
|
|
794
809
|
}
|
|
795
|
-
var
|
|
796
|
-
function
|
|
810
|
+
var Re = N();
|
|
811
|
+
function se(e) {
|
|
797
812
|
return e instanceof Document ? e : e.ownerDocument;
|
|
798
813
|
}
|
|
799
|
-
function
|
|
800
|
-
if (!t || e.getElementById(
|
|
814
|
+
function le(e, t, n) {
|
|
815
|
+
if (!t || e.getElementById(T)) return;
|
|
801
816
|
const r = e.createElement("style");
|
|
802
|
-
r.id =
|
|
817
|
+
r.id = T, r.textContent = N(n), e.head.appendChild(r);
|
|
803
818
|
}
|
|
804
|
-
function
|
|
819
|
+
function Te(e) {
|
|
805
820
|
const { root: t = typeof document < "u" ? document : void 0, containerId: n = L, includeDefaultStyles: r = !0 } = e ?? {};
|
|
806
821
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
807
|
-
const i =
|
|
808
|
-
|
|
822
|
+
const i = se(t);
|
|
823
|
+
le(i, r, n);
|
|
809
824
|
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${k(n)}`);
|
|
810
825
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
811
826
|
if (!(t instanceof Document)) {
|
|
@@ -815,18 +830,18 @@ function Re(e) {
|
|
|
815
830
|
const o = i.createElement("div");
|
|
816
831
|
return o.id = n, i.body.appendChild(o), o;
|
|
817
832
|
}
|
|
818
|
-
function
|
|
833
|
+
function ce() {
|
|
819
834
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
820
835
|
}
|
|
821
836
|
function Oe(e) {
|
|
822
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: n = "", includePluginHostHead: r = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ?
|
|
837
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: n = "", includePluginHostHead: r = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? ce() : "", n].filter((p) => p.trim().length > 0).join(`
|
|
823
838
|
`);
|
|
824
839
|
return `<!DOCTYPE html>
|
|
825
840
|
<html ${o}>
|
|
826
841
|
<head>
|
|
827
842
|
<base target="_top" />
|
|
828
843
|
<meta charset="UTF-8" />
|
|
829
|
-
<title>${
|
|
844
|
+
<title>${de(t)}</title>${l ? `
|
|
830
845
|
${l}` : ""}
|
|
831
846
|
</head>
|
|
832
847
|
<body ${s}>
|
|
@@ -835,44 +850,44 @@ ${l}` : ""}
|
|
|
835
850
|
</html>
|
|
836
851
|
`;
|
|
837
852
|
}
|
|
838
|
-
function
|
|
853
|
+
function de(e) {
|
|
839
854
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
840
855
|
}
|
|
841
856
|
export {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
857
|
+
U as ADAPTER_VERSION,
|
|
858
|
+
ae as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
859
|
+
V as DEFAULT_IPC_CONFIG,
|
|
860
|
+
ue as DEFAULT_SIDEBAR_CONFIG,
|
|
861
|
+
j as DeferredPromise,
|
|
862
|
+
_ as IPCCore,
|
|
863
|
+
ge as MimeType,
|
|
864
|
+
ve as PluginAdapter,
|
|
865
|
+
J as PluginIPCAdapter,
|
|
866
|
+
Ce as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
852
867
|
L as SIDEBAR_HOST_CONTAINER_ID,
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
868
|
+
Re as SIDEBAR_HOST_SHELL_CSS,
|
|
869
|
+
ie as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
870
|
+
re as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
871
|
+
Ae as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
872
|
+
X as SidebarAdapter,
|
|
873
|
+
Y as SidebarIPCAdapter,
|
|
874
|
+
pe as TEXT_MIME_TYPES,
|
|
875
|
+
O as TextLookupError,
|
|
876
|
+
Pe as assertSidebarHostAdapter,
|
|
877
|
+
Ie as buildDocumentReference,
|
|
863
878
|
Oe as buildSidebarHostHtmlDocument,
|
|
864
879
|
N as buildSidebarHostShellCss,
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
880
|
+
ce as buildSidebarPluginHostHeadInnerHtml,
|
|
881
|
+
Ee as createSidebarHost,
|
|
882
|
+
Te as ensureSidebarHostShell,
|
|
883
|
+
Se as getAuthConfigWithOverride,
|
|
884
|
+
be as getSidebarBaseUrlWithOverride,
|
|
870
885
|
E as ipcErrorReconstructors,
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
886
|
+
ye as isDocumentReference,
|
|
887
|
+
fe as isIntegrationSettingField,
|
|
888
|
+
he as isIntegrationSettingsSchema,
|
|
889
|
+
me as isTextLookupError,
|
|
890
|
+
$ as reconstructError,
|
|
891
|
+
ne as setupSidebarLoadOverlay,
|
|
892
|
+
we as sidebarPostMessageTargetOrigin
|
|
878
893
|
};
|
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(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})({}),q=["text/plain","text/markdown","text/html","application/dita+xml"],Z={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,supportCheckSelection:!0,multiAgent:!1,multiDocument:!1},Q=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),ee=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},P="2.2.0",y=class K extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,K.prototype)}};function te(e){return e instanceof y}var v={TextLookupError:e=>new y(e)};function R(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 T=":",O=/^[a-z][a-z0-9-]*$/;function ne(e){const t=e.indexOf(T);return t<=0||t===e.length-1?!1:O.test(e.slice(0,t))}function ie(e,t){const n=e.trim().toLowerCase(),i=t.trim();if(!O.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}${T}`;return i.startsWith(a)?i:`${a}${i}`}var _=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}},D={timeout:1e4};function re(e){const t=typeof e=="object"&&e!==null?JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e))):{},n=e instanceof Error?e.message:String(e),i=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:i,...o!==void 0&&{name:o}})}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,...n){const i=this.currentID++,a=new _,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=R(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={}}},De=64,ae=new Set(["auto","prompt"]),b=(e,t)=>{const n=e[t];if(!(typeof n!="string"||n.length===0))return n.slice(0,64)};function oe(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),ae.has(t.pwaUpdateMode)&&(a.pwaUpdateMode=t.pwaUpdateMode);const o=b(t,"adapterVersion");return o!==void 0&&(a.adapterVersion=o),a}function se(e){return typeof e!="string"||e.length===0?null:e.slice(0,64)}function Le(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;sidebar;targetOrigin;latestHostAdapterVersion=null;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){const{hostAdapterVersion:t,...n}=e?await this.ipc.call("getInitConfig",{...e,adapterVersion:e.adapterVersion??"2.2.0"}):await this.ipc.call("getInitConfig");return this.latestHostAdapterVersion=se(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()}},le=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new L(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()}},M=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=oe(e);return this.latestSidebarBuildInfo=t,{...await this.plugin.getInitConfig(t??void 0),hostAdapterVersion:P}}),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()}},k=class{ipcAdapter;constructor(e,t,n){this.ipcAdapter=new M(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)}},ce=`
|
|
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
|
+
`,de=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ce;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}},N="markupai-sidebar-load-overlay-styles",ge=`
|
|
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
|
+
`,ue=e=>{const t=e??document;if(t.getElementById(N))return;const n=t.createElement("style");n.id=N,n.textContent=ge,t.head.appendChild(n)},pe=8e3,he=12e3,B=(e,t,n={})=>{ue(e.ownerDocument);const{sidebarUrl:i,targetOrigin:a,timeoutMs:o=pe,retryIntervalMs:s=he,messageListenWindow:l}=n,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>i??t.src,Oe=()=>{if(a)return a;try{return new URL(h()).origin}catch{return"*"}},{overlay:E,button:V}=de();e.appendChild(E);let f=!1,I,u;const p=d=>{E.style.display=d?"flex":"none"};p(!1);const m=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},G=()=>{m(),I=globalThis.setTimeout(()=>{f||p(!0)},o)},W=d=>{const A=d?.preserveOverlay??!0;f=!1,A||p(!1),t.src=h(),G()},_e=()=>{u||s<=0||(u=globalThis.setInterval(()=>{f||W({preserveOverlay:!0})},s))},z=()=>{u&&(globalThis.clearInterval(u),u=void 0)},Y=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const A=Oe();A!=="*"&&d.origin!==A||(f=!0,m(),z(),p(!1))},J=()=>{m(),p(!0)},X=()=>{W()};return V.addEventListener("click",X),t.addEventListener("error",J),c.addEventListener("message",Y),G(),_e(),()=>{m(),z(),t.removeEventListener("error",J),c.removeEventListener("message",Y),V.removeEventListener("click",X),E.remove()}},H="Markup AI Sidebar",U="clipboard-read; clipboard-write",fe="markupai.sidebarNextGen.overrideUrl",Ie="https://sidebar.markup.ai/";function me(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var x="markupai.sidebarNextGen.authOverride";function Ae(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const n=globalThis.localStorage.getItem(x)?.trim();if(!n)return e;const i=JSON.parse(n);return i!==null&&typeof i=="object"&&"type"in i&&(i.type==="mediation"||i.type==="popup")?i:e}catch{return e}}function ye(e,t){try{return new URL(e).origin}catch(n){return t?.onInvalidUrl?.(e,n),"*"}}function ve(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function Ce(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:i,src:a,allow:o=U}=n,s=document.createElement("iframe");return s.title=H,s.src=a,o&&s.setAttribute("allow",o),i.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function be(e){const{plugin:t,loadOverlayContainer:n,loadOverlayOptions:i,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=Ce(e),l=n!==void 0?B(n,o,i??{}):null;if(t!==void 0){const c=new k(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var S="sidebarContainer",F="markupai-sidebar-host-shell-styles";function $(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 w(e=S){const t=$(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 Se=w();function we(e){return e instanceof Document?e:e.ownerDocument}function Ee(e,t,n){if(!t||e.getElementById(F))return;const i=e.createElement("style");i.id=F,i.textContent=w(n),e.head.appendChild(i)}function Pe(e){const{root:t=typeof document<"u"?document:void 0,containerId:n=S,includeDefaultStyles:i=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const a=we(t);Ee(a,i,n);const o=t instanceof Document?a.getElementById(n):t.querySelector(`#${$(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 j(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function Re(e){const{title:t="Markup AI Sidebar",headInnerHtml:n="",includePluginHostHead:i=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[i?j():"",n].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>${Te(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 Te(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}r.ADAPTER_VERSION=P,r.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=x,r.DEFAULT_IPC_CONFIG=D,r.DEFAULT_SIDEBAR_CONFIG=Z,r.DeferredPromise=_,r.IPCCore=C,r.MimeType=g,r.PluginAdapter=le,r.PluginIPCAdapter=L,r.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=Ie,r.SIDEBAR_HOST_CONTAINER_ID=S,r.SIDEBAR_HOST_SHELL_CSS=Se,r.SIDEBAR_IFRAME_DEFAULT_ALLOW=U,r.SIDEBAR_IFRAME_DEFAULT_TITLE=H,r.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=fe,r.SidebarAdapter=k,r.SidebarIPCAdapter=M,r.TEXT_MIME_TYPES=q,r.TextLookupError=y,r.assertSidebarHostAdapter=ve,r.buildDocumentReference=ie,r.buildSidebarHostHtmlDocument=Re,r.buildSidebarHostShellCss=w,r.buildSidebarPluginHostHeadInnerHtml=j,r.createSidebarHost=be,r.ensureSidebarHostShell=Pe,r.getAuthConfigWithOverride=Ae,r.getSidebarBaseUrlWithOverride=me,r.ipcErrorReconstructors=v,r.isDocumentReference=ne,r.isIntegrationSettingField=ee,r.isIntegrationSettingsSchema=Q,r.isTextLookupError=te,r.reconstructError=R,r.setupSidebarLoadOverlay=B,r.sidebarPostMessageTargetOrigin=ye});
|
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;IAClB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,eAAe,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,MA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