@markupai/sidebar-adapter 1.1.0 → 1.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 +114 -0
- package/dist/adapters/pluginAdapter.d.ts +8 -1
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/adapters/sidebarAdapter.d.ts +24 -1
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +17 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +7 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts +9 -0
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +142 -98
- package/dist/main.umd.cjs +5 -5
- package/dist/sidebar-host/createSidebarHost.d.ts.map +1 -1
- package/dist/types/common.d.ts +10 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/integrationSettings.d.ts +159 -0
- package/dist/types/integrationSettings.d.ts.map +1 -0
- package/dist/types/pluginInterface.d.ts +14 -0
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/dist/types/sidebarInterface.d.ts +32 -0
- package/dist/types/sidebarInterface.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -541,6 +541,120 @@ The adapter uses a promise-based IPC system with automatic request/response corr
|
|
|
541
541
|
}
|
|
542
542
|
```
|
|
543
543
|
|
|
544
|
+
## Integration settings
|
|
545
|
+
|
|
546
|
+
A host MAY declare a small schema of settings it wants the sidebar to render and persist on its behalf. The sidebar shows a section in its Settings surface, persists user choices per-`integrationId` in `localStorage`, and notifies the host on user edits. The host can also push values and per-field UI state (`disabled`, `hidden`, `allowedValues`) to enforce its own rules — for example, "annotations off ⇒ view mode locked to `original`".
|
|
547
|
+
|
|
548
|
+
This is **opt-in and additive**. Hosts that omit `integrationSettings` from their `SidebarConfig` and never call `applyIntegrationSettings` see no behavior change.
|
|
549
|
+
|
|
550
|
+
### Declaring a schema
|
|
551
|
+
|
|
552
|
+
```typescript
|
|
553
|
+
import type { SidebarConfig } from "@markupai/sidebar-adapter";
|
|
554
|
+
|
|
555
|
+
const config: SidebarConfig = {
|
|
556
|
+
integrationName: "my-integration",
|
|
557
|
+
integrationVersion: "1.0.0",
|
|
558
|
+
integrationId: "my-integration",
|
|
559
|
+
useCheckPreviewDialog: false,
|
|
560
|
+
integrationSettings: {
|
|
561
|
+
title: "My integration",
|
|
562
|
+
fields: [
|
|
563
|
+
{
|
|
564
|
+
id: "showAnnotations",
|
|
565
|
+
type: "boolean",
|
|
566
|
+
label: "Show annotations",
|
|
567
|
+
default: true,
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
id: "viewMode",
|
|
571
|
+
type: "enum",
|
|
572
|
+
label: "View mode",
|
|
573
|
+
default: "simple",
|
|
574
|
+
options: [
|
|
575
|
+
{ value: "simple", label: "Simple markup" },
|
|
576
|
+
{ value: "none", label: "No markup" },
|
|
577
|
+
{ value: "original", label: "Original" },
|
|
578
|
+
],
|
|
579
|
+
},
|
|
580
|
+
],
|
|
581
|
+
},
|
|
582
|
+
};
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Field ids are stable storage keys inside the integration's namespace — keep them constant across versions so persisted values continue to apply.
|
|
586
|
+
|
|
587
|
+
### Reacting to user edits
|
|
588
|
+
|
|
589
|
+
Implement `onIntegrationSettingsChange` on your `PluginInterface`:
|
|
590
|
+
|
|
591
|
+
```typescript
|
|
592
|
+
import type { PluginInterface } from "@markupai/sidebar-adapter";
|
|
593
|
+
|
|
594
|
+
const plugin: PluginInterface = {
|
|
595
|
+
// …existing methods…
|
|
596
|
+
onIntegrationSettingsChange: async (values, meta) => {
|
|
597
|
+
// meta.source is always "user". Host-driven changes (your own
|
|
598
|
+
// applyIntegrationSettings calls) never echo back, so this handler
|
|
599
|
+
// fires only for actual user edits.
|
|
600
|
+
if (values.showAnnotations === false) {
|
|
601
|
+
// Apply your business rule (e.g. hide annotations in the editor).
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
};
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
Implementing the handler is optional; if you omit it, the sidebar simply does not call you.
|
|
608
|
+
|
|
609
|
+
### Driving the form from the host
|
|
610
|
+
|
|
611
|
+
The `SidebarAdapter` exposes `applyIntegrationSettings(patch)` so the host can push values and constraints into the sidebar:
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
// Lock viewMode to "original" when annotations are off.
|
|
615
|
+
await sidebarAdapter.applyIntegrationSettings({
|
|
616
|
+
values: { viewMode: "original" },
|
|
617
|
+
fieldStates: {
|
|
618
|
+
viewMode: { allowedValues: ["original"], disabled: true },
|
|
619
|
+
},
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
// Later, when annotations are re-enabled, clear the constraint.
|
|
623
|
+
await sidebarAdapter.applyIntegrationSettings({
|
|
624
|
+
fieldStates: { viewMode: null },
|
|
625
|
+
});
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
Merge semantics: keys present in the patch overwrite prior state; absent keys preserve it; passing `null` for a field's state clears it. **Values pushed by the host are persisted; field states are session-only** — the host re-asserts them on init or in response to its own state changes.
|
|
629
|
+
|
|
630
|
+
### Reading current state from the host
|
|
631
|
+
|
|
632
|
+
When your host UI re-mounts mid-session (for example, an Office task pane that gets unloaded and reloaded), call `getIntegrationSettings()` to read the sidebar's current snapshot before deciding whether to push your own state — the sidebar is the source of truth for persisted user values, and unconditional `applyIntegrationSettings` calls on every init would silently overwrite the user's choice.
|
|
633
|
+
|
|
634
|
+
```typescript
|
|
635
|
+
const { values, fieldStates } = await sidebarAdapter.getIntegrationSettings();
|
|
636
|
+
|
|
637
|
+
// Reconcile with whatever the host believes about its own state, then call
|
|
638
|
+
// applyIntegrationSettings only for the deltas you actually want to enforce.
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
When the host has not declared `integrationSettings` in its `SidebarConfig`, the snapshot is `{ values: {}, fieldStates: {} }`.
|
|
642
|
+
|
|
643
|
+
### Lifecycle and persistence
|
|
644
|
+
|
|
645
|
+
- The sidebar persists values under the `localStorage` key `markupai:integrationSettings:<integrationId>`. Different `integrationId` values are isolated.
|
|
646
|
+
- Schema validation is **lenient**: fields whose `type` the current sidebar does not understand are dropped (with a single `console.warn`). The remaining known fields still render — a host that ships a schema using a newer field type degrades gracefully on older sidebars without an explicit version handshake.
|
|
647
|
+
- Top-level malformed schemas (e.g. `fields` is not an array) are treated as absent — the sidebar logs a `console.warn` and never throws.
|
|
648
|
+
- Host-driven value changes do **not** echo back via `onIntegrationSettingsChange`. The host already knows what it pushed.
|
|
649
|
+
|
|
650
|
+
### Race semantics — last-write-wins per field
|
|
651
|
+
|
|
652
|
+
Updates are applied per-field with no coordination between user edits and host pushes:
|
|
653
|
+
|
|
654
|
+
- A user toggle and a near-simultaneous `applyIntegrationSettings` both target the same field — whichever lands second wins for that field.
|
|
655
|
+
- This means a reactive host that calls `applyIntegrationSettings` from inside `onIntegrationSettingsChange` (e.g. "if annotations are off, lock viewMode to original") can briefly visually revert a user click if the IPC round-trip lands after the user's own state change has rendered. This is a feature, not a bug — the host's business rule is meant to override — but make sure to apply your rules narrowly so unrelated user edits aren't silently undone.
|
|
656
|
+
- Use `getIntegrationSettings()` rather than caching last-known values when you need to be sure you're reconciling against the sidebar's actual current state.
|
|
657
|
+
|
|
544
658
|
## Development
|
|
545
659
|
|
|
546
660
|
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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CallOptions, IPCConfig } from "../ipc/message-types";
|
|
2
|
-
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarInterface, AgenticIssuePayload } from "../types";
|
|
2
|
+
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarInterface, AgenticIssuePayload, IntegrationSettingsValues, IntegrationSettingsChangeMeta } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* PluginAdapter - Use in the Sidebar to communicate with the Plugin in the editor
|
|
5
5
|
* This is a wrapper around PluginIPCAdapter for backwards compatibility and ease of use
|
|
@@ -63,6 +63,13 @@ export declare class PluginAdapter {
|
|
|
63
63
|
* callers should then fall back to `globalThis.open`.
|
|
64
64
|
*/
|
|
65
65
|
openAuthUrl(url: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Notify the host plugin that the user changed an integration-settings
|
|
68
|
+
* value. Optional on the host side — the returned promise rejects if the
|
|
69
|
+
* host has not implemented `onIntegrationSettingsChange`. Callers should
|
|
70
|
+
* swallow that error since the handler is documented as optional.
|
|
71
|
+
*/
|
|
72
|
+
onIntegrationSettingsChange(values: IntegrationSettingsValues, meta: IntegrationSettingsChangeMeta): Promise<void>;
|
|
66
73
|
/**
|
|
67
74
|
* Update IPC configuration
|
|
68
75
|
*/
|
|
@@ -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,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,
|
|
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,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,6BAA6B,EA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G;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,5 +1,5 @@
|
|
|
1
1
|
import type { IPCConfig } from "../ipc/message-types";
|
|
2
|
-
import type { PluginInterface } from "../types";
|
|
2
|
+
import type { IntegrationSettingsPatch, IntegrationSettingsSnapshot, PluginInterface } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Options for SidebarAdapter constructor
|
|
5
5
|
*/
|
|
@@ -35,6 +35,29 @@ export declare class SidebarAdapter {
|
|
|
35
35
|
* Request sidebar to invalidate (dismiss) the card for the given issue.
|
|
36
36
|
*/
|
|
37
37
|
invalidateAgenticIssue(issueId: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Apply a host-driven patch to the sidebar's integration-settings form
|
|
40
|
+
* values and/or per-field UI state. Use this to push values and
|
|
41
|
+
* constraints (e.g. `disabled`, `hidden`, `allowedValues`) into the
|
|
42
|
+
* sidebar so the integration can enforce its own rules.
|
|
43
|
+
*
|
|
44
|
+
* Merge semantics: keys present in the patch overwrite prior state; keys
|
|
45
|
+
* absent preserve prior state; passing `null` for a field's state clears
|
|
46
|
+
* it. Values pushed via this call are persisted; field states are
|
|
47
|
+
* session-only.
|
|
48
|
+
*/
|
|
49
|
+
applyIntegrationSettings(patch: IntegrationSettingsPatch): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Read back the sidebar's current integration-settings state — persisted
|
|
52
|
+
* user values plus session-only field states most recently pushed by the
|
|
53
|
+
* host. Use this when the host re-mounts mid-session and needs to mirror
|
|
54
|
+
* sidebar state without overwriting the user's persisted choices via a
|
|
55
|
+
* subsequent `applyIntegrationSettings` call.
|
|
56
|
+
*
|
|
57
|
+
* Returns an empty snapshot when the host has not declared
|
|
58
|
+
* `integrationSettings` in its `SidebarConfig`.
|
|
59
|
+
*/
|
|
60
|
+
getIntegrationSettings(): Promise<IntegrationSettingsSnapshot>;
|
|
38
61
|
/**
|
|
39
62
|
* Update IPC configuration
|
|
40
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebarAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/sidebarAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sidebarAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/sidebarAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAW/F;;OAEG;IACI,OAAO,IAAI,IAAI;IAKtB;;;OAGG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D;;OAEG;IACU,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE;;OAEG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE;;;;;;;;;;OAUG;IACU,wBAAwB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrF;;;;;;;;;OASG;IACU,sBAAsB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAI3E;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;CAG1C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, AgenticIssuePayload } from "../types/common";
|
|
2
|
+
import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta, IntegrationSettingsPatch, IntegrationSettingsSnapshot } from "../types/integrationSettings";
|
|
2
3
|
/**
|
|
3
4
|
* Call signatures for all bidirectional IPC communication.
|
|
4
5
|
* This interface maps method names to their parameter types and return types.
|
|
@@ -52,6 +53,12 @@ export interface CallSignatures {
|
|
|
52
53
|
* See {@link PluginInterface.openAuthUrl}.
|
|
53
54
|
*/
|
|
54
55
|
openAuthUrl(url: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Notify plugin when the user changes a value in the integration-settings
|
|
58
|
+
* form. Optional on the plugin side; absent handler is a no-op.
|
|
59
|
+
* See {@link PluginInterface.onIntegrationSettingsChange}.
|
|
60
|
+
*/
|
|
61
|
+
onIntegrationSettingsChange?(values: IntegrationSettingsValues, meta: IntegrationSettingsChangeMeta): Promise<void>;
|
|
55
62
|
/**
|
|
56
63
|
* Notify sidebar of plugin status changes
|
|
57
64
|
* Optional method - demonstrates Plugin → Sidebar communication pattern
|
|
@@ -65,5 +72,15 @@ export interface CallSignatures {
|
|
|
65
72
|
* Request sidebar to invalidate (dismiss) the card for the given issue id.
|
|
66
73
|
*/
|
|
67
74
|
invalidateAgenticIssue(issueId: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Apply a host-driven patch to the integration-settings form values and/or
|
|
77
|
+
* per-field UI state. See {@link SidebarInterface.applyIntegrationSettings}.
|
|
78
|
+
*/
|
|
79
|
+
applyIntegrationSettings(patch: IntegrationSettingsPatch): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Read back the sidebar's current integration-settings state. See
|
|
82
|
+
* {@link SidebarInterface.getIntegrationSettings}.
|
|
83
|
+
*/
|
|
84
|
+
getIntegrationSettings(): Promise<IntegrationSettingsSnapshot>;
|
|
68
85
|
}
|
|
69
86
|
//# sourceMappingURL=call-signatures.d.ts.map
|
|
@@ -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,aAAa,EACb,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;
|
|
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,aAAa,EACb,mBAAmB,EACpB,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;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvE;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;OAEG;IACH,UAA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|
1
1
|
import type { CallOptions, IPCConfig } from "../ipc/message-types";
|
|
2
2
|
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, AgenticIssuePayload } from "../types/common";
|
|
3
|
+
import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta } from "../types/integrationSettings";
|
|
3
4
|
import type { SidebarInterface } from "../types/sidebarInterface";
|
|
4
5
|
/**
|
|
5
6
|
* PluginIPCAdapter - Used in the Sidebar to communicate with the Plugin in the editor
|
|
@@ -63,6 +64,12 @@ export declare class PluginIPCAdapter {
|
|
|
63
64
|
* back (e.g. to `globalThis.open`).
|
|
64
65
|
*/
|
|
65
66
|
openAuthUrl(url: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Notify plugin when the user changes a value in the integration-settings
|
|
69
|
+
* form. Throws if the plugin has not registered a handler; callers should
|
|
70
|
+
* swallow that error since the handler is documented as optional.
|
|
71
|
+
*/
|
|
72
|
+
onIntegrationSettingsChange(values: IntegrationSettingsValues, meta: IntegrationSettingsChangeMeta): Promise<void>;
|
|
66
73
|
/**
|
|
67
74
|
* Update IPC configuration
|
|
68
75
|
*/
|
|
@@ -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;AAC9E,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAA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AEG;IACU,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D;;OAEG;IACU,UAAU,CACrB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAKhB;;OAEG;IACU,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzC;;OAEG;IACU,uBAAuB,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvF;;OAEG;IACU,qBAAqB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EAAE,GAC5B,OAAO,CAAC,IAAI,CAAC;IAIhB;;OAEG;IACU,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrD;;;;OAIG;IACU,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;;;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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IPCConfig } from "../ipc/message-types";
|
|
2
|
+
import type { IntegrationSettingsPatch, IntegrationSettingsSnapshot } from "../types/integrationSettings";
|
|
2
3
|
import type { PluginInterface } from "../types/pluginInterface";
|
|
3
4
|
/**
|
|
4
5
|
* SidebarIPCAdapter - Used in the Plugin to communicate with the Sidebar in the iframe
|
|
@@ -26,6 +27,14 @@ export declare class SidebarIPCAdapter {
|
|
|
26
27
|
* Example method demonstrating Plugin → Sidebar communication
|
|
27
28
|
*/
|
|
28
29
|
notifyPluginStatus(status: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Apply a host-driven patch to the sidebar's integration-settings form.
|
|
32
|
+
*/
|
|
33
|
+
applyIntegrationSettings(patch: IntegrationSettingsPatch): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Read back the sidebar's current integration-settings snapshot.
|
|
36
|
+
*/
|
|
37
|
+
getIntegrationSettings(): Promise<IntegrationSettingsSnapshot>;
|
|
29
38
|
/**
|
|
30
39
|
* Update IPC configuration
|
|
31
40
|
*/
|
|
@@ -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,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/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;gBAGpC,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;
|
|
1
|
+
{"version":3,"file":"sidebar-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-ipc-adapter.ts"],"names":[],"mappings":"AACA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@__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
|
-
})({}),
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
],
|
|
3
|
+
})({}), ae = [
|
|
4
|
+
y.TEXT_PLAIN,
|
|
5
|
+
y.TEXT_MARKDOWN,
|
|
6
|
+
y.TEXT_HTML,
|
|
7
|
+
y.APPLICATION_DITA_XML
|
|
8
|
+
], oe = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -13,18 +13,26 @@ var v = /* @__PURE__ */ (function(e) {
|
|
|
13
13
|
dialogClosingScript: void 0,
|
|
14
14
|
useCheckPreviewDialog: !1,
|
|
15
15
|
supportCheckSelection: !0
|
|
16
|
+
}, se = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), le = (e) => {
|
|
17
|
+
if (typeof e != "object" || e === null) return !1;
|
|
18
|
+
const t = e;
|
|
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((r) => {
|
|
20
|
+
if (typeof r != "object" || r === null) return !1;
|
|
21
|
+
const i = r;
|
|
22
|
+
return typeof i.value == "string" && typeof i.label == "string";
|
|
23
|
+
}) : !1;
|
|
16
24
|
}, D = class _ extends Error {
|
|
17
25
|
name = "TextLookupError";
|
|
18
26
|
constructor(t) {
|
|
19
27
|
super(t), Object.setPrototypeOf(this, _.prototype);
|
|
20
28
|
}
|
|
21
29
|
};
|
|
22
|
-
function
|
|
30
|
+
function ce(e) {
|
|
23
31
|
return e instanceof D;
|
|
24
32
|
}
|
|
25
|
-
var
|
|
33
|
+
var E = { TextLookupError: (e) => new D(e) };
|
|
26
34
|
function H(e) {
|
|
27
|
-
const t = e.message ?? "", r = e.name, i = typeof r == "string" && r in
|
|
35
|
+
const t = e.message ?? "", r = e.name, i = typeof r == "string" && r in E ? E[r] : void 0;
|
|
28
36
|
return i ? i(t, e) : Object.assign(new Error(t), r ? { name: r } : {});
|
|
29
37
|
}
|
|
30
38
|
var O = () => {
|
|
@@ -69,15 +77,15 @@ var O = () => {
|
|
|
69
77
|
return this.callWithOptions(e, {}, ...t);
|
|
70
78
|
}
|
|
71
79
|
callWithOptions(e, t, ...r) {
|
|
72
|
-
const i = this.currentID++,
|
|
80
|
+
const i = this.currentID++, a = new U(), n = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
73
81
|
if (i in this.promisesByID) {
|
|
74
82
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(n)}ms`);
|
|
75
|
-
|
|
83
|
+
a.reject(l), Reflect.deleteProperty(this.promisesByID, i);
|
|
76
84
|
}
|
|
77
85
|
}, n);
|
|
78
86
|
this.promisesByID[i] = {
|
|
79
|
-
promise:
|
|
80
|
-
timeoutId:
|
|
87
|
+
promise: a,
|
|
88
|
+
timeoutId: o
|
|
81
89
|
};
|
|
82
90
|
const s = {
|
|
83
91
|
type: "call",
|
|
@@ -85,7 +93,7 @@ var O = () => {
|
|
|
85
93
|
name: e,
|
|
86
94
|
data: r
|
|
87
95
|
};
|
|
88
|
-
return this.postMessage(s),
|
|
96
|
+
return this.postMessage(s), a;
|
|
89
97
|
}
|
|
90
98
|
receive(e, t) {
|
|
91
99
|
this.receiversByName[e] = t;
|
|
@@ -110,20 +118,20 @@ var O = () => {
|
|
|
110
118
|
async handleCall(e) {
|
|
111
119
|
const { id: t, name: r, data: i } = e;
|
|
112
120
|
if (r in this.receiversByName) {
|
|
113
|
-
const
|
|
121
|
+
const a = this.receiversByName[r];
|
|
114
122
|
try {
|
|
115
123
|
if (!Array.isArray(i)) throw new Error(`IPC: Expected array of arguments but got ${typeof i}`);
|
|
116
|
-
const n = await
|
|
124
|
+
const n = await a(...i), o = {
|
|
117
125
|
type: "response",
|
|
118
126
|
id: t,
|
|
119
127
|
name: r,
|
|
120
128
|
data: n
|
|
121
129
|
};
|
|
122
|
-
this.postMessage(
|
|
130
|
+
this.postMessage(o);
|
|
123
131
|
} catch (n) {
|
|
124
|
-
let
|
|
125
|
-
const s = JSON.parse(
|
|
126
|
-
(s.message === void 0 || s.message === "") && (
|
|
132
|
+
let o = JSON.stringify(n, Object.getOwnPropertyNames(n));
|
|
133
|
+
const s = JSON.parse(o);
|
|
134
|
+
(s.message === void 0 || s.message === "") && (o = JSON.stringify({
|
|
127
135
|
message: n instanceof Error ? n.message : String(n),
|
|
128
136
|
name: n instanceof Error ? n.name : void 0
|
|
129
137
|
}));
|
|
@@ -131,18 +139,18 @@ var O = () => {
|
|
|
131
139
|
type: "error",
|
|
132
140
|
id: t,
|
|
133
141
|
name: r,
|
|
134
|
-
errorJSON:
|
|
142
|
+
errorJSON: o
|
|
135
143
|
};
|
|
136
144
|
this.postMessage(l);
|
|
137
145
|
}
|
|
138
146
|
} else {
|
|
139
|
-
const
|
|
147
|
+
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${r}`), n = {
|
|
140
148
|
type: "error",
|
|
141
149
|
id: t,
|
|
142
150
|
name: r,
|
|
143
151
|
errorJSON: JSON.stringify({
|
|
144
|
-
message:
|
|
145
|
-
name:
|
|
152
|
+
message: a.message,
|
|
153
|
+
name: a.name
|
|
146
154
|
})
|
|
147
155
|
};
|
|
148
156
|
this.postMessage(n);
|
|
@@ -158,8 +166,8 @@ var O = () => {
|
|
|
158
166
|
handleError(e) {
|
|
159
167
|
const { id: t, errorJSON: r } = e;
|
|
160
168
|
if (t in this.promisesByID) {
|
|
161
|
-
const { promise: i, timeoutId:
|
|
162
|
-
clearTimeout(
|
|
169
|
+
const { promise: i, timeoutId: a } = this.promisesByID[t];
|
|
170
|
+
clearTimeout(a);
|
|
163
171
|
try {
|
|
164
172
|
const n = H(JSON.parse(r));
|
|
165
173
|
i.reject(n);
|
|
@@ -206,6 +214,16 @@ var O = () => {
|
|
|
206
214
|
await e(t);
|
|
207
215
|
});
|
|
208
216
|
}
|
|
217
|
+
if (this.sidebar.applyIntegrationSettings) {
|
|
218
|
+
const e = this.sidebar.applyIntegrationSettings;
|
|
219
|
+
this.ipc.receive("applyIntegrationSettings", async (t) => {
|
|
220
|
+
await e(t);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (this.sidebar.getIntegrationSettings) {
|
|
224
|
+
const e = this.sidebar.getIntegrationSettings;
|
|
225
|
+
this.ipc.receive("getIntegrationSettings", async () => await e());
|
|
226
|
+
}
|
|
209
227
|
}
|
|
210
228
|
async getInitConfig() {
|
|
211
229
|
return await this.ipc.call("getInitConfig");
|
|
@@ -240,6 +258,9 @@ var O = () => {
|
|
|
240
258
|
async openAuthUrl(e) {
|
|
241
259
|
await this.ipc.call("openAuthUrl", e);
|
|
242
260
|
}
|
|
261
|
+
async onIntegrationSettingsChange(e, t) {
|
|
262
|
+
await this.ipc.call("onIntegrationSettingsChange", e, t);
|
|
263
|
+
}
|
|
243
264
|
configure(e) {
|
|
244
265
|
this.ipc.configure(e);
|
|
245
266
|
}
|
|
@@ -259,7 +280,7 @@ var O = () => {
|
|
|
259
280
|
destroy() {
|
|
260
281
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
261
282
|
}
|
|
262
|
-
},
|
|
283
|
+
}, ge = class {
|
|
263
284
|
ipcAdapter;
|
|
264
285
|
constructor(e, t, r) {
|
|
265
286
|
this.ipcAdapter = new F(e, t, r);
|
|
@@ -300,6 +321,9 @@ var O = () => {
|
|
|
300
321
|
openAuthUrl(e) {
|
|
301
322
|
return this.ipcAdapter.openAuthUrl(e);
|
|
302
323
|
}
|
|
324
|
+
onIntegrationSettingsChange(e, t) {
|
|
325
|
+
return this.ipcAdapter.onIntegrationSettingsChange(e, t);
|
|
326
|
+
}
|
|
303
327
|
configure(e) {
|
|
304
328
|
this.ipcAdapter.configure(e);
|
|
305
329
|
}
|
|
@@ -315,8 +339,8 @@ var O = () => {
|
|
|
315
339
|
iframe;
|
|
316
340
|
window;
|
|
317
341
|
targetOrigin;
|
|
318
|
-
constructor(e, t, r, i,
|
|
319
|
-
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin =
|
|
342
|
+
constructor(e, t, r, i, a = "*") {
|
|
343
|
+
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = a, this.ipc = new L((n) => {
|
|
320
344
|
this.iframe.contentWindow?.postMessage(n, this.targetOrigin);
|
|
321
345
|
}, i), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
322
346
|
}
|
|
@@ -349,6 +373,12 @@ var O = () => {
|
|
|
349
373
|
await e(t);
|
|
350
374
|
});
|
|
351
375
|
}
|
|
376
|
+
if (this.plugin.onIntegrationSettingsChange) {
|
|
377
|
+
const e = this.plugin.onIntegrationSettingsChange;
|
|
378
|
+
this.ipc.receive("onIntegrationSettingsChange", async (t, r) => {
|
|
379
|
+
await e(t, r);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
352
382
|
}
|
|
353
383
|
async activateAgenticIssue(e) {
|
|
354
384
|
await this.ipc.call("activateAgenticIssue", e);
|
|
@@ -359,6 +389,12 @@ var O = () => {
|
|
|
359
389
|
async notifyPluginStatus(e) {
|
|
360
390
|
await this.ipc.call("onPluginStatusChange", e);
|
|
361
391
|
}
|
|
392
|
+
async applyIntegrationSettings(e) {
|
|
393
|
+
await this.ipc.call("applyIntegrationSettings", e);
|
|
394
|
+
}
|
|
395
|
+
async getIntegrationSettings() {
|
|
396
|
+
return await this.ipc.call("getIntegrationSettings");
|
|
397
|
+
}
|
|
362
398
|
configure(e) {
|
|
363
399
|
this.ipc.configure(e);
|
|
364
400
|
}
|
|
@@ -382,6 +418,12 @@ var O = () => {
|
|
|
382
418
|
async invalidateAgenticIssue(e) {
|
|
383
419
|
await this.ipcAdapter.invalidateAgenticIssue(e);
|
|
384
420
|
}
|
|
421
|
+
async applyIntegrationSettings(e) {
|
|
422
|
+
await this.ipcAdapter.applyIntegrationSettings(e);
|
|
423
|
+
}
|
|
424
|
+
async getIntegrationSettings() {
|
|
425
|
+
return await this.ipcAdapter.getIntegrationSettings();
|
|
426
|
+
}
|
|
385
427
|
configure(e) {
|
|
386
428
|
this.ipcAdapter.configure(e);
|
|
387
429
|
}
|
|
@@ -514,49 +556,49 @@ var O = () => {
|
|
|
514
556
|
r.id = T, r.textContent = J, t.head.appendChild(r);
|
|
515
557
|
}, Y = 8e3, V = 12e3, K = (e, t, r = {}) => {
|
|
516
558
|
X(e.ownerDocument);
|
|
517
|
-
const { sidebarUrl: i, targetOrigin:
|
|
518
|
-
if (
|
|
559
|
+
const { sidebarUrl: i, targetOrigin: a, timeoutMs: n = Y, retryIntervalMs: o = V, messageListenWindow: s } = r, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => i ?? t.src, k = () => {
|
|
560
|
+
if (a) return a;
|
|
519
561
|
try {
|
|
520
562
|
return new URL(p()).origin;
|
|
521
563
|
} catch {
|
|
522
564
|
return "*";
|
|
523
565
|
}
|
|
524
|
-
}, { overlay:
|
|
525
|
-
e.appendChild(
|
|
526
|
-
let u = !1, h,
|
|
527
|
-
const
|
|
528
|
-
|
|
566
|
+
}, { overlay: v, button: I } = z();
|
|
567
|
+
e.appendChild(v);
|
|
568
|
+
let u = !1, h, g;
|
|
569
|
+
const d = (c) => {
|
|
570
|
+
v.style.display = c ? "flex" : "none";
|
|
529
571
|
};
|
|
530
|
-
|
|
531
|
-
const
|
|
572
|
+
d(!1);
|
|
573
|
+
const f = () => {
|
|
532
574
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
533
|
-
},
|
|
534
|
-
|
|
535
|
-
u ||
|
|
575
|
+
}, C = () => {
|
|
576
|
+
f(), h = globalThis.setTimeout(() => {
|
|
577
|
+
u || d(!0);
|
|
536
578
|
}, n);
|
|
537
|
-
},
|
|
538
|
-
const
|
|
539
|
-
u = !1,
|
|
579
|
+
}, A = (c) => {
|
|
580
|
+
const m = c?.preserveOverlay ?? !0;
|
|
581
|
+
u = !1, m || d(!1), t.src = p(), C();
|
|
540
582
|
}, B = () => {
|
|
541
|
-
|
|
542
|
-
u ||
|
|
543
|
-
},
|
|
583
|
+
g || o <= 0 || (g = globalThis.setInterval(() => {
|
|
584
|
+
u || A({ preserveOverlay: !0 });
|
|
585
|
+
}, o));
|
|
544
586
|
}, b = () => {
|
|
545
|
-
|
|
587
|
+
g && (globalThis.clearInterval(g), g = void 0);
|
|
546
588
|
}, w = (c) => {
|
|
547
589
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
548
|
-
const
|
|
549
|
-
|
|
590
|
+
const m = k();
|
|
591
|
+
m !== "*" && c.origin !== m || (u = !0, f(), b(), d(!1));
|
|
550
592
|
}, S = () => {
|
|
551
|
-
|
|
552
|
-
},
|
|
553
|
-
|
|
593
|
+
f(), d(!0);
|
|
594
|
+
}, P = () => {
|
|
595
|
+
A();
|
|
554
596
|
};
|
|
555
|
-
return I.addEventListener("click",
|
|
556
|
-
|
|
597
|
+
return I.addEventListener("click", P), t.addEventListener("error", S), l.addEventListener("message", w), C(), B(), () => {
|
|
598
|
+
f(), b(), t.removeEventListener("error", S), l.removeEventListener("message", w), I.removeEventListener("click", P), v.remove();
|
|
557
599
|
};
|
|
558
|
-
}, q = "Markup AI Sidebar", Z = "clipboard-read; clipboard-write",
|
|
559
|
-
function
|
|
600
|
+
}, q = "Markup AI Sidebar", Z = "clipboard-read; clipboard-write", de = "markupai.sidebarNextGen.overrideUrl", pe = "https://sidebar.markup.ai/";
|
|
601
|
+
function ue(e) {
|
|
560
602
|
try {
|
|
561
603
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
562
604
|
} catch {
|
|
@@ -564,7 +606,7 @@ function ge(e) {
|
|
|
564
606
|
}
|
|
565
607
|
}
|
|
566
608
|
var Q = "markupai.sidebarNextGen.authOverride";
|
|
567
|
-
function
|
|
609
|
+
function he(e, t) {
|
|
568
610
|
if (!t) return e;
|
|
569
611
|
try {
|
|
570
612
|
if (!("localStorage" in globalThis)) return e;
|
|
@@ -576,14 +618,14 @@ function pe(e, t) {
|
|
|
576
618
|
return e;
|
|
577
619
|
}
|
|
578
620
|
}
|
|
579
|
-
function
|
|
621
|
+
function fe(e, t) {
|
|
580
622
|
try {
|
|
581
623
|
return new URL(e).origin;
|
|
582
624
|
} catch (r) {
|
|
583
625
|
return t?.onInvalidUrl?.(e, r), "*";
|
|
584
626
|
}
|
|
585
627
|
}
|
|
586
|
-
function
|
|
628
|
+
function me(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
587
629
|
if (e.adapter === null) throw new Error(t);
|
|
588
630
|
}
|
|
589
631
|
function ee(e) {
|
|
@@ -594,23 +636,23 @@ function ee(e) {
|
|
|
594
636
|
removeMountedIframe: null
|
|
595
637
|
};
|
|
596
638
|
if (r === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
597
|
-
const { container: i, src:
|
|
598
|
-
return
|
|
599
|
-
iframe:
|
|
639
|
+
const { container: i, src: a, allow: n = Z } = r, o = document.createElement("iframe");
|
|
640
|
+
return o.title = q, o.src = a, n && o.setAttribute("allow", n), i.appendChild(o), {
|
|
641
|
+
iframe: o,
|
|
600
642
|
removeMountedIframe: () => {
|
|
601
|
-
|
|
643
|
+
o.remove();
|
|
602
644
|
}
|
|
603
645
|
};
|
|
604
646
|
}
|
|
605
|
-
function
|
|
606
|
-
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: i, adapterOptions:
|
|
647
|
+
function ye(e) {
|
|
648
|
+
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: i, adapterOptions: a } = e, { iframe: n, removeMountedIframe: o } = ee(e), s = r !== void 0 ? K(r, n, i ?? {}) : null;
|
|
607
649
|
if (t !== void 0) {
|
|
608
|
-
const l = new W(t, n,
|
|
650
|
+
const l = new W(t, n, a);
|
|
609
651
|
return {
|
|
610
652
|
iframe: n,
|
|
611
653
|
adapter: l,
|
|
612
654
|
destroy: () => {
|
|
613
|
-
s?.(), l.destroy(),
|
|
655
|
+
s?.(), l.destroy(), o?.();
|
|
614
656
|
}
|
|
615
657
|
};
|
|
616
658
|
}
|
|
@@ -618,7 +660,7 @@ function me(e) {
|
|
|
618
660
|
iframe: n,
|
|
619
661
|
adapter: null,
|
|
620
662
|
destroy: () => {
|
|
621
|
-
s?.(),
|
|
663
|
+
s?.(), o?.();
|
|
622
664
|
}
|
|
623
665
|
};
|
|
624
666
|
}
|
|
@@ -654,7 +696,7 @@ body {
|
|
|
654
696
|
}
|
|
655
697
|
`.trim();
|
|
656
698
|
}
|
|
657
|
-
var
|
|
699
|
+
var ve = N();
|
|
658
700
|
function te(e) {
|
|
659
701
|
return e instanceof Document ? e : e.ownerDocument;
|
|
660
702
|
}
|
|
@@ -663,28 +705,28 @@ function re(e, t, r) {
|
|
|
663
705
|
const i = e.createElement("style");
|
|
664
706
|
i.id = R, i.textContent = N(r), e.head.appendChild(i);
|
|
665
707
|
}
|
|
666
|
-
function
|
|
708
|
+
function Ie(e) {
|
|
667
709
|
const { root: t = typeof document < "u" ? document : void 0, containerId: r = M, includeDefaultStyles: i = !0 } = e ?? {};
|
|
668
710
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
669
|
-
const
|
|
670
|
-
re(
|
|
671
|
-
const n = t instanceof Document ?
|
|
711
|
+
const a = te(t);
|
|
712
|
+
re(a, i, r);
|
|
713
|
+
const n = t instanceof Document ? a.getElementById(r) : t.querySelector(`#${x(r)}`);
|
|
672
714
|
if (n instanceof HTMLElement && (t instanceof Document || t.contains(n))) return n;
|
|
673
715
|
if (!(t instanceof Document)) {
|
|
674
|
-
const s =
|
|
716
|
+
const s = a.createElement("div");
|
|
675
717
|
return s.id = r, t.appendChild(s), s;
|
|
676
718
|
}
|
|
677
|
-
const
|
|
678
|
-
return
|
|
719
|
+
const o = a.createElement("div");
|
|
720
|
+
return o.id = r, a.body.appendChild(o), o;
|
|
679
721
|
}
|
|
680
722
|
function ie() {
|
|
681
723
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
682
724
|
}
|
|
683
|
-
function
|
|
684
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: i = !1, bodyScriptsHtml:
|
|
725
|
+
function Ce(e) {
|
|
726
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: i = !1, bodyScriptsHtml: a, htmlLang: n = "en", htmlAttrs: o = `lang="${n}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [i ? ie() : "", r].filter((p) => p.trim().length > 0).join(`
|
|
685
727
|
`);
|
|
686
728
|
return `<!DOCTYPE html>
|
|
687
|
-
<html ${
|
|
729
|
+
<html ${o}>
|
|
688
730
|
<head>
|
|
689
731
|
<base target="_top" />
|
|
690
732
|
<meta charset="UTF-8" />
|
|
@@ -692,7 +734,7 @@ function ye(e) {
|
|
|
692
734
|
${l}` : ""}
|
|
693
735
|
</head>
|
|
694
736
|
<body ${s}>
|
|
695
|
-
${
|
|
737
|
+
${a}
|
|
696
738
|
</body>
|
|
697
739
|
</html>
|
|
698
740
|
`;
|
|
@@ -703,33 +745,35 @@ function ne(e) {
|
|
|
703
745
|
export {
|
|
704
746
|
Q as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
705
747
|
j as DEFAULT_IPC_CONFIG,
|
|
706
|
-
|
|
748
|
+
oe as DEFAULT_SIDEBAR_CONFIG,
|
|
707
749
|
U as DeferredPromise,
|
|
708
750
|
L as IPCCore,
|
|
709
|
-
|
|
710
|
-
|
|
751
|
+
y as MimeType,
|
|
752
|
+
ge as PluginAdapter,
|
|
711
753
|
F as PluginIPCAdapter,
|
|
712
|
-
|
|
754
|
+
pe as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
713
755
|
M as SIDEBAR_HOST_CONTAINER_ID,
|
|
714
|
-
|
|
756
|
+
ve as SIDEBAR_HOST_SHELL_CSS,
|
|
715
757
|
Z as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
716
758
|
q as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
717
|
-
|
|
759
|
+
de as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
718
760
|
W as SidebarAdapter,
|
|
719
761
|
$ as SidebarIPCAdapter,
|
|
720
|
-
|
|
762
|
+
ae as TEXT_MIME_TYPES,
|
|
721
763
|
D as TextLookupError,
|
|
722
|
-
|
|
723
|
-
|
|
764
|
+
me as assertSidebarHostAdapter,
|
|
765
|
+
Ce as buildSidebarHostHtmlDocument,
|
|
724
766
|
N as buildSidebarHostShellCss,
|
|
725
767
|
ie as buildSidebarPluginHostHeadInnerHtml,
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
768
|
+
ye as createSidebarHost,
|
|
769
|
+
Ie as ensureSidebarHostShell,
|
|
770
|
+
he as getAuthConfigWithOverride,
|
|
771
|
+
ue as getSidebarBaseUrlWithOverride,
|
|
772
|
+
E as ipcErrorReconstructors,
|
|
773
|
+
le as isIntegrationSettingField,
|
|
774
|
+
se as isIntegrationSettingsSchema,
|
|
775
|
+
ce as isTextLookupError,
|
|
732
776
|
H as reconstructError,
|
|
733
777
|
K as setupSidebarLoadOverlay,
|
|
734
|
-
|
|
778
|
+
fe as sidebarPostMessageTargetOrigin
|
|
735
779
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(n,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(n=typeof globalThis<"u"?globalThis:n||self,d(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var d=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),X=[d.TEXT_PLAIN,d.TEXT_MARKDOWN,d.TEXT_HTML,d.APPLICATION_DITA_XML],V={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},A=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function K(e){return e instanceof A}var I={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",r=e.name,i=typeof r=="string"&&r in I?I[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,a=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(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,i)}},a);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 a=await o(...i),s={type:"response",id:t,name:r,data:a};this.postMessage(s)}catch(a){let s=JSON.stringify(a,Object.getOwnPropertyNames(a));const l=JSON.parse(s);(l.message===void 0||l.message==="")&&(s=JSON.stringify({message:a instanceof Error?a.message:String(a),name:a instanceof Error?a.name:void 0}));const c={type:"error",id:t,name:r,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${r}`),a={type:"error",id:t,name:r,errorJSON:JSON.stringify({message:o.message,name:o.name})};this.postMessage(a)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise: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 a=E(JSON.parse(r));i.reject(a)}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={}}},R=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")}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},q=class{ipcAdapter;constructor(e,t,r){this.ipcAdapter=new R(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()}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,r,i,o="*"){this.plugin=e,this.iframe=t,this.window=r??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,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(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,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()}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}}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()}},D=class{ipcAdapter;constructor(e,t,r){this.ipcAdapter=new _(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)}},Z=`
|
|
1
|
+
(function(n,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(n=typeof globalThis<"u"?globalThis:n||self,d(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var d=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),X=[d.TEXT_PLAIN,d.TEXT_MARKDOWN,d.TEXT_HTML,d.APPLICATION_DITA_XML],V={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},K=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),q=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},v=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function Z(e){return e instanceof v}var A={TextLookupError:e=>new v(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in A?A[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=()=>{},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,...i){const r=this.currentID++,o=new T,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},a);this.promisesByID[r]={promise:o,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),o}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(i in this.receiversByName){const o=this.receiversByName[i];try{if(!Array.isArray(r))throw new Error(`IPC: Expected array of arguments but got ${typeof r}`);const a=await o(...r),s={type:"response",id:t,name:i,data:a};this.postMessage(s)}catch(a){let s=JSON.stringify(a,Object.getOwnPropertyNames(a));const l=JSON.parse(s);(l.message===void 0||l.message==="")&&(s=JSON.stringify({message:a instanceof Error?a.message:String(a),name:a instanceof Error?a.name:void 0}));const c={type:"error",id:t,name:i,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${i}`),a={type:"error",id:t,name:i,errorJSON:JSON.stringify({message:o.message,name:o.name})};this.postMessage(a)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(i));r.reject(a)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},R=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async t=>{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)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},Q=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new R(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,o="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async notifyPluginStatus(e){await this.ipc.call("onPluginStatusChange",e)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},D=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new _(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e){await this.ipcAdapter.notifyPluginStatus(e)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ee=`
|
|
2
2
|
<div class="sidebar-load-overlay-card">
|
|
3
3
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
4
4
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<span>Retry</span>
|
|
20
20
|
</button>
|
|
21
21
|
</div>
|
|
22
|
-
`,
|
|
22
|
+
`,te=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ee;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},L="markupai-sidebar-load-overlay-styles",ie=`
|
|
23
23
|
:root {
|
|
24
24
|
--background: #f5f5f4;
|
|
25
25
|
--foreground: #333332;
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
box-shadow: 0 0 0 2px
|
|
112
112
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
113
113
|
}
|
|
114
|
-
`,
|
|
114
|
+
`,re=e=>{const t=e??document;if(t.getElementById(L))return;const i=t.createElement("style");i.id=L,i.textContent=ie,t.head.appendChild(i)},ne=8e3,ae=12e3,M=(e,t,i={})=>{re(e.ownerDocument);const{sidebarUrl:r,targetOrigin:o,timeoutMs:a=ne,retryIntervalMs:s=ae,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,Ae=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:x}=te();e.appendChild(w);let f=!1,m,p;const u=g=>{w.style.display=g?"flex":"none"};u(!1);const y=()=>{m&&(globalThis.clearTimeout(m),m=void 0)},j=()=>{y(),m=globalThis.setTimeout(()=>{f||u(!0)},a)},$=g=>{const I=g?.preserveOverlay??!0;f=!1,I||u(!1),t.src=h(),j()},Ce=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||$({preserveOverlay:!0})},s))},W=()=>{p&&(globalThis.clearInterval(p),p=void 0)},G=g=>{if(!t.contentWindow||g.source!==t.contentWindow)return;const I=Ae();I!=="*"&&g.origin!==I||(f=!0,y(),W(),u(!1))},Y=()=>{y(),u(!0)},z=()=>{$()};return x.addEventListener("click",z),t.addEventListener("error",Y),c.addEventListener("message",G),j(),Ce(),()=>{y(),W(),t.removeEventListener("error",Y),c.removeEventListener("message",G),x.removeEventListener("click",z),w.remove()}},N="Markup AI Sidebar",H="clipboard-read; clipboard-write",oe="markupai.sidebarNextGen.overrideUrl",se="https://sidebar.markup.ai/";function le(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var k="markupai.sidebarNextGen.authOverride";function ce(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(k)?.trim();if(!i)return e;const r=JSON.parse(i);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function de(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function ge(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function pe(e){const{iframe:t,iframeMount:i}=e;if(t!==void 0&&i!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(i===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:o,allow:a=H}=i,s=document.createElement("iframe");return s.title=N,s.src=o,a&&s.setAttribute("allow",a),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ue(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=pe(e),l=i!==void 0?M(i,a,r??{}):null;if(t!==void 0){const c=new D(t,a,o);return{iframe:a,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:a,adapter:null,destroy:()=>{l?.(),s?.()}}}var S="sidebarContainer",U="markupai-sidebar-host-shell-styles";function B(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 b(e=S){const t=B(e);return`
|
|
115
115
|
html {
|
|
116
116
|
height: 100%;
|
|
117
117
|
}
|
|
@@ -133,7 +133,7 @@ body {
|
|
|
133
133
|
margin: 0;
|
|
134
134
|
display: block;
|
|
135
135
|
}
|
|
136
|
-
`.trim()}var
|
|
136
|
+
`.trim()}var he=b();function fe(e){return e instanceof Document?e:e.ownerDocument}function me(e,t,i){if(!t||e.getElementById(U))return;const r=e.createElement("style");r.id=U,r.textContent=b(i),e.head.appendChild(r)}function ye(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=S,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=fe(t);me(o,r,i);const a=t instanceof Document?o.getElementById(i):t.querySelector(`#${B(i)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=i,t.appendChild(l),l}const s=o.createElement("div");return s.id=i,o.body.appendChild(s),s}function F(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function Ie(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?F():"",i].filter(h=>h.trim().length>0).join(`
|
|
137
137
|
`);return`<!DOCTYPE html>
|
|
138
138
|
<html ${s}>
|
|
139
139
|
<head>
|
|
@@ -146,4 +146,4 @@ ${c}`:""}
|
|
|
146
146
|
${o}
|
|
147
147
|
</body>
|
|
148
148
|
</html>
|
|
149
|
-
`}function ve(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=k,n.DEFAULT_IPC_CONFIG=O,n.DEFAULT_SIDEBAR_CONFIG=V,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=d,n.PluginAdapter=
|
|
149
|
+
`}function ve(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=k,n.DEFAULT_IPC_CONFIG=O,n.DEFAULT_SIDEBAR_CONFIG=V,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=d,n.PluginAdapter=Q,n.PluginIPCAdapter=R,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=se,n.SIDEBAR_HOST_CONTAINER_ID=S,n.SIDEBAR_HOST_SHELL_CSS=he,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=H,n.SIDEBAR_IFRAME_DEFAULT_TITLE=N,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=oe,n.SidebarAdapter=D,n.SidebarIPCAdapter=_,n.TEXT_MIME_TYPES=X,n.TextLookupError=v,n.assertSidebarHostAdapter=ge,n.buildSidebarHostHtmlDocument=Ie,n.buildSidebarHostShellCss=b,n.buildSidebarPluginHostHeadInnerHtml=F,n.createSidebarHost=ue,n.ensureSidebarHostShell=ye,n.getAuthConfigWithOverride=ce,n.getSidebarBaseUrlWithOverride=le,n.ipcErrorReconstructors=A,n.isIntegrationSettingField=q,n.isIntegrationSettingsSchema=K,n.isTextLookupError=Z,n.reconstructError=E,n.setupSidebarLoadOverlay=M,n.sidebarPostMessageTargetOrigin=de});
|
|
@@ -1 +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,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,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;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,yCAAyC,CAAC;AAEvF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,aAAa,EAAE,OAAO,GACrB,UAAU,GAAG,SAAS,
|
|
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,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AAkB,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"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IntegrationSettingsSchema } from "./integrationSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Common MIME type constants for text content
|
|
3
4
|
* Integrations are not limited to these values - any valid MIME type string can be used
|
|
@@ -105,6 +106,15 @@ export interface SidebarConfig {
|
|
|
105
106
|
* `getAuthConfigWithOverride` in `sidebar-host`.
|
|
106
107
|
*/
|
|
107
108
|
auth?: AuthConfig;
|
|
109
|
+
/**
|
|
110
|
+
* Optional declarative schema of host-supplied settings rendered in the
|
|
111
|
+
* sidebar's Settings surface. When omitted, no integration-settings section
|
|
112
|
+
* is rendered and no related IPC traffic is emitted.
|
|
113
|
+
*
|
|
114
|
+
* See `@markupai/sidebar-adapter` README → "Integration settings" for the
|
|
115
|
+
* shape and lifecycle.
|
|
116
|
+
*/
|
|
117
|
+
integrationSettings?: IntegrationSettingsSchema;
|
|
108
118
|
}
|
|
109
119
|
export declare const DEFAULT_SIDEBAR_CONFIG: SidebarConfig;
|
|
110
120
|
/**
|
|
@@ -1 +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;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnE;;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,C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3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for host-supplied integration settings rendered by the sidebar.
|
|
3
|
+
*
|
|
4
|
+
* A host integration MAY declare a small schema of settings in its
|
|
5
|
+
* {@link SidebarConfig.integrationSettings}. The sidebar renders a form for
|
|
6
|
+
* those fields, persists the user's choices per-integration, and notifies the
|
|
7
|
+
* host on user edits via {@link PluginInterface.onIntegrationSettingsChange}.
|
|
8
|
+
*
|
|
9
|
+
* The host may also push values and per-field UI state (disabled, hidden,
|
|
10
|
+
* narrowed enum options) through {@link SidebarInterface.applyIntegrationSettings}
|
|
11
|
+
* to enforce its own rules — e.g. "annotations off ⇒ view mode locked to
|
|
12
|
+
* `original`".
|
|
13
|
+
*
|
|
14
|
+
* All members are additive and optional on the host side. Hosts that do not
|
|
15
|
+
* set `integrationSettings` and never call `applyIntegrationSettings` observe
|
|
16
|
+
* no behavior change.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Common shape shared by every settings field.
|
|
20
|
+
*
|
|
21
|
+
* @property id - Stable storage key, opaque to the sidebar. The host MUST keep
|
|
22
|
+
* the id stable across versions so persisted user values continue to apply.
|
|
23
|
+
* @property label - User-visible label rendered next to the control.
|
|
24
|
+
* @property description - Optional help text rendered under the label.
|
|
25
|
+
*/
|
|
26
|
+
export interface IntegrationSettingFieldBase {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Boolean toggle rendered as a switch.
|
|
33
|
+
*/
|
|
34
|
+
export interface IntegrationSettingBooleanField extends IntegrationSettingFieldBase {
|
|
35
|
+
type: "boolean";
|
|
36
|
+
default: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Single-select enum rendered as a dropdown. Each option carries a stable
|
|
40
|
+
* `value` (persisted) and a user-visible `label`.
|
|
41
|
+
*/
|
|
42
|
+
export interface IntegrationSettingEnumField extends IntegrationSettingFieldBase {
|
|
43
|
+
type: "enum";
|
|
44
|
+
default: string;
|
|
45
|
+
options: ReadonlyArray<{
|
|
46
|
+
value: string;
|
|
47
|
+
label: string;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Discriminated union of every supported field type. Adding a new field type
|
|
52
|
+
* (`text`, `number`, …) is an additive change — existing fields keep working.
|
|
53
|
+
*/
|
|
54
|
+
export type IntegrationSettingField = IntegrationSettingBooleanField | IntegrationSettingEnumField;
|
|
55
|
+
/**
|
|
56
|
+
* Schema declared by the host in {@link SidebarConfig.integrationSettings}.
|
|
57
|
+
*
|
|
58
|
+
* The sidebar parses schemas leniently: fields whose `type` the sidebar
|
|
59
|
+
* does not understand are dropped (with a single `console.warn`) and the
|
|
60
|
+
* rest still render. Hosts can therefore ship a schema using newer field
|
|
61
|
+
* types and still have it degrade gracefully on older sidebars — no
|
|
62
|
+
* explicit version handshake is required.
|
|
63
|
+
*
|
|
64
|
+
* @property title - Optional section header. Defaults to "Integration settings"
|
|
65
|
+
* in the rendered form when omitted.
|
|
66
|
+
* @property fields - Ordered list of fields to render.
|
|
67
|
+
*/
|
|
68
|
+
export interface IntegrationSettingsSchema {
|
|
69
|
+
title?: string;
|
|
70
|
+
fields: ReadonlyArray<IntegrationSettingField>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Map of field id → current value. Booleans persist as `boolean`; enums
|
|
74
|
+
* persist as the option's `value` string.
|
|
75
|
+
*/
|
|
76
|
+
export type IntegrationSettingsValues = Record<string, boolean | string>;
|
|
77
|
+
/**
|
|
78
|
+
* Host-driven per-field UI state. Session-only — never persisted across
|
|
79
|
+
* sidebar reloads. The host re-asserts these on init or in response to its
|
|
80
|
+
* own state changes.
|
|
81
|
+
*
|
|
82
|
+
* @property disabled - Render the control read-only.
|
|
83
|
+
* @property hidden - Skip rendering the control entirely.
|
|
84
|
+
* @property allowedValues - For enum fields, narrow the rendered options to
|
|
85
|
+
* this subset. If exactly one option remains, the control is rendered as a
|
|
86
|
+
* single disabled value.
|
|
87
|
+
*/
|
|
88
|
+
export interface IntegrationSettingFieldState {
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
hidden?: boolean;
|
|
91
|
+
allowedValues?: ReadonlyArray<string>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Patch applied by the host via
|
|
95
|
+
* {@link SidebarInterface.applyIntegrationSettings}. Merge semantics:
|
|
96
|
+
*
|
|
97
|
+
* - Keys present in `values` overwrite the prior value for that field; absent
|
|
98
|
+
* keys preserve the prior value.
|
|
99
|
+
* - Keys present in `fieldStates` overwrite the prior state for that field;
|
|
100
|
+
* absent keys preserve the prior state. Pass `null` for a field to clear
|
|
101
|
+
* its state entirely.
|
|
102
|
+
*
|
|
103
|
+
* Values pushed by the host are persisted under the same per-integration
|
|
104
|
+
* `localStorage` key as user-driven values; field states are not persisted.
|
|
105
|
+
*/
|
|
106
|
+
export interface IntegrationSettingsPatch {
|
|
107
|
+
values?: Partial<IntegrationSettingsValues>;
|
|
108
|
+
fieldStates?: Record<string, IntegrationSettingFieldState | null>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Origin of a settings change forwarded to the host via
|
|
112
|
+
* {@link PluginInterface.onIntegrationSettingsChange}. Only user-driven
|
|
113
|
+
* changes are emitted — host-driven changes do not echo back, since the host
|
|
114
|
+
* already knows what it pushed.
|
|
115
|
+
*
|
|
116
|
+
* The union is intentionally narrow (single member) so future additions are
|
|
117
|
+
* additive and surface in TypeScript at the point a new source actually
|
|
118
|
+
* starts being emitted.
|
|
119
|
+
*/
|
|
120
|
+
export type IntegrationSettingsChangeSource = "user";
|
|
121
|
+
export interface IntegrationSettingsChangeMeta {
|
|
122
|
+
source: IntegrationSettingsChangeSource;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Snapshot of the sidebar's current integration-settings state, returned by
|
|
126
|
+
* {@link SidebarInterface.getIntegrationSettings}. Hosts call this to read
|
|
127
|
+
* back what the sidebar has — for example, on a re-mount where the host
|
|
128
|
+
* needs to mirror sidebar state without clobbering the user's persisted
|
|
129
|
+
* choices.
|
|
130
|
+
*
|
|
131
|
+
* The sidebar is the source of truth for `values` (persisted per
|
|
132
|
+
* `integrationId` in `localStorage`). `fieldStates` is session-only and
|
|
133
|
+
* reflects whatever the host most recently pushed via
|
|
134
|
+
* {@link SidebarInterface.applyIntegrationSettings}.
|
|
135
|
+
*/
|
|
136
|
+
export interface IntegrationSettingsSnapshot {
|
|
137
|
+
values: IntegrationSettingsValues;
|
|
138
|
+
fieldStates: Record<string, IntegrationSettingFieldState>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Top-level shape check for an {@link IntegrationSettingsSchema}: requires
|
|
142
|
+
* `fields` to be an array. Does not validate the contents of `fields` —
|
|
143
|
+
* pair this with {@link isIntegrationSettingField} to filter unknown or
|
|
144
|
+
* malformed entries.
|
|
145
|
+
*
|
|
146
|
+
* Validation is intentionally lenient so a schema authored against a newer
|
|
147
|
+
* adapter (extra field types) still produces a usable form on an older
|
|
148
|
+
* sidebar: the supported subset renders, the rest is dropped with a single
|
|
149
|
+
* `console.warn`.
|
|
150
|
+
*/
|
|
151
|
+
export declare const isIntegrationSettingsSchema: (value: unknown) => value is IntegrationSettingsSchema;
|
|
152
|
+
/**
|
|
153
|
+
* Type guard for a single {@link IntegrationSettingField}. Returns false for
|
|
154
|
+
* field types the current adapter does not understand — callers (typically
|
|
155
|
+
* the sidebar) use this to filter out unknown fields when rendering a schema
|
|
156
|
+
* that may have been authored against a newer adapter version.
|
|
157
|
+
*/
|
|
158
|
+
export declare const isIntegrationSettingField: (value: unknown) => value is IntegrationSettingField;
|
|
159
|
+
//# sourceMappingURL=integrationSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrationSettings.d.ts","sourceRoot":"","sources":["../../src/types/integrationSettings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,2BAA2B;IACjF,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,2BAA2B;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,GAAG,2BAA2B,CAAC;AAEnG;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;CAChD;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,IAAI,CAAC,CAAC;CACnE;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,+BAA+B,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,+BAA+B,CAAC;CACzC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,yBAAyB,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,yBAIrE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,uBAmBnE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, AgenticIssuePayload } from "./common";
|
|
2
|
+
import type { IntegrationSettingsValues, IntegrationSettingsChangeMeta } from "./integrationSettings";
|
|
2
3
|
/**
|
|
3
4
|
* Interface for the functions to implement in the Editor that the Sidebar will call via IPC
|
|
4
5
|
* All methods return Promises for proper async handling
|
|
@@ -85,5 +86,18 @@ export interface PluginInterface {
|
|
|
85
86
|
* sidebar handles that via backend polling).
|
|
86
87
|
*/
|
|
87
88
|
openAuthUrl?: (url: string) => Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Called when the user changes a value in the integration-settings form
|
|
91
|
+
* declared via {@link SidebarConfig.integrationSettings}.
|
|
92
|
+
*
|
|
93
|
+
* Optional. Only invoked for **user-driven** changes; values pushed by the
|
|
94
|
+
* host via {@link SidebarInterface.applyIntegrationSettings} do not echo
|
|
95
|
+
* back to this handler.
|
|
96
|
+
*
|
|
97
|
+
* @param values - Full current values map (every field id, including
|
|
98
|
+
* unchanged ones), so the host does not need to track prior state.
|
|
99
|
+
* @param meta - Source metadata. `meta.source` is currently always `"user"`.
|
|
100
|
+
*/
|
|
101
|
+
onIntegrationSettingsChange?: (values: IntegrationSettingsValues, meta: IntegrationSettingsChangeMeta) => Promise<void>;
|
|
88
102
|
}
|
|
89
103
|
//# sourceMappingURL=pluginInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;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;IAE9C;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C;;;;;;;;;;;OAWG;IACH,2BAA2B,CAAC,EAAE,CAC5B,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE,6BAA6B,KAChC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IntegrationSettingsPatch, IntegrationSettingsSnapshot } from "./integrationSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Interface for functions to implement in the Sidebar that the Plugin can call via IPC
|
|
3
4
|
*
|
|
@@ -37,5 +38,36 @@ export interface SidebarInterface {
|
|
|
37
38
|
* Used when the plugin wants to programmatically dismiss an issue (e.g. after replacement).
|
|
38
39
|
*/
|
|
39
40
|
invalidateAgenticIssue?: (issueId: string) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Apply a host-driven patch to the integration-settings form values and/or
|
|
43
|
+
* per-field UI state. The host calls this to push values and constraints
|
|
44
|
+
* into the sidebar — for example, locking a field's enum options or
|
|
45
|
+
* disabling it in response to its own state.
|
|
46
|
+
*
|
|
47
|
+
* Merge semantics: keys present in the patch overwrite prior state; keys
|
|
48
|
+
* absent preserve prior state; passing `null` for a field's state clears
|
|
49
|
+
* it. Values pushed via this call are persisted; field states are
|
|
50
|
+
* session-only.
|
|
51
|
+
*
|
|
52
|
+
* Optional on the `SidebarInterface` type so legacy consumers that pass
|
|
53
|
+
* `undefined` continue to compile. The sidebar app's actual implementation
|
|
54
|
+
* always provides it.
|
|
55
|
+
*/
|
|
56
|
+
applyIntegrationSettings?: (patch: IntegrationSettingsPatch) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Read back the sidebar's current integration-settings state — the
|
|
59
|
+
* persisted user values plus any session-only field states the host has
|
|
60
|
+
* pushed via {@link applyIntegrationSettings}. Hosts call this when they
|
|
61
|
+
* re-mount mid-session and need to mirror sidebar state without
|
|
62
|
+
* clobbering the user's persisted choices.
|
|
63
|
+
*
|
|
64
|
+
* Returns an empty snapshot (`{ values: {}, fieldStates: {} }`) when no
|
|
65
|
+
* integration-settings schema has been declared.
|
|
66
|
+
*
|
|
67
|
+
* Optional on the `SidebarInterface` type for the same reason as
|
|
68
|
+
* {@link applyIntegrationSettings}; the sidebar app's actual
|
|
69
|
+
* implementation always provides it.
|
|
70
|
+
*/
|
|
71
|
+
getIntegrationSettings?: () => Promise<IntegrationSettingsSnapshot>;
|
|
40
72
|
}
|
|
41
73
|
//# sourceMappingURL=sidebarInterface.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"sidebarInterface.d.ts","sourceRoot":"","sources":["../../src/types/sidebarInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEnG;;;;;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;IAE5D;;;;;;;;;;;;;;OAcG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9E;;;;;;;;;;;;;OAaG;IACH,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC,CAAC;CACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markupai/sidebar-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Adapter package for MarkupAI Sidebar integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markupai",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/markupai/
|
|
13
|
+
"url": "https://github.com/markupai/sidebar-app.git",
|
|
14
14
|
"directory": "packages/adapter"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"type-check": "tsc --project tsconfig.json --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"tsc-alias": "1.8.
|
|
41
|
+
"tsc-alias": "1.8.17"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|