@contello/extension 8.21.3 → 8.21.4
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/LICENSE +21 -0
- package/dist/index.cjs +339 -344
- package/dist/index.d.cts +222 -204
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +222 -204
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +336 -313
- package/dist/index.js.map +1 -0
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,326 +1,349 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/channel.ts
|
|
2
|
+
let channelIdIterator = 0;
|
|
3
|
+
let requestIdIterator = 0;
|
|
4
4
|
var ExtensionChannel = class {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
5
|
+
params;
|
|
6
|
+
targetWindow;
|
|
7
|
+
channelId;
|
|
8
|
+
targetOrigin;
|
|
9
|
+
isParent;
|
|
10
|
+
handler = (event) => {
|
|
11
|
+
if (event.data.channelId !== this.channelId) return;
|
|
12
|
+
if (this.targetOrigin === "*" || event.origin === this.targetOrigin) {
|
|
13
|
+
const { channelId: requestChannelId, requestId, method } = event.data;
|
|
14
|
+
if (requestChannelId === this.channelId) {
|
|
15
|
+
if (this.params.debug) console.log(this.isParent ? "Parent received" : "Child received", event.data);
|
|
16
|
+
if (this.handlers.has(requestId)) this.handlers.get(requestId)(event.data);
|
|
17
|
+
else if (this.listeners.has(method)) (async () => {
|
|
18
|
+
try {
|
|
19
|
+
const responsePayload = await this.listeners.get(method)?.(event.data.payload);
|
|
20
|
+
this.respond(event.data, responsePayload);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
this.respondError(event.data, error);
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
handlers = /* @__PURE__ */ new Map();
|
|
29
|
+
listeners = /* @__PURE__ */ new Map();
|
|
30
|
+
constructor(params) {
|
|
31
|
+
this.params = params;
|
|
32
|
+
}
|
|
33
|
+
connect() {
|
|
34
|
+
window.addEventListener("message", this.handler);
|
|
35
|
+
}
|
|
36
|
+
createChannelId() {
|
|
37
|
+
return `contello-channel-${++channelIdIterator}-${Math.random().toString(36).slice(2)}`;
|
|
38
|
+
}
|
|
39
|
+
createRequestId() {
|
|
40
|
+
return `${this.isParent ? "parent" : "child"}-request-${++requestIdIterator}-${Math.random().toString(36).slice(2)}`;
|
|
41
|
+
}
|
|
42
|
+
populateChannelId() {
|
|
43
|
+
if (!this.channelId) this.channelId = this.createChannelId();
|
|
44
|
+
return this.channelId;
|
|
45
|
+
}
|
|
46
|
+
connectParent(targetOrigin, channelId) {
|
|
47
|
+
this.channelId = channelId;
|
|
48
|
+
this.targetOrigin = targetOrigin;
|
|
49
|
+
this.targetWindow = window.parent;
|
|
50
|
+
this.isParent = false;
|
|
51
|
+
this.connect();
|
|
52
|
+
}
|
|
53
|
+
connectChild(targetWindow) {
|
|
54
|
+
this.populateChannelId();
|
|
55
|
+
this.targetWindow = targetWindow;
|
|
56
|
+
this.targetOrigin = "*";
|
|
57
|
+
this.isParent = true;
|
|
58
|
+
this.connect();
|
|
59
|
+
}
|
|
60
|
+
getChannelId() {
|
|
61
|
+
return this.channelId;
|
|
62
|
+
}
|
|
63
|
+
getIsDebug() {
|
|
64
|
+
return this.params.debug;
|
|
65
|
+
}
|
|
66
|
+
getTargetOrigin() {
|
|
67
|
+
return this.targetOrigin;
|
|
68
|
+
}
|
|
69
|
+
getTargetWindow() {
|
|
70
|
+
return this.targetWindow;
|
|
71
|
+
}
|
|
72
|
+
disconnect() {
|
|
73
|
+
window.removeEventListener("message", this.handler);
|
|
74
|
+
}
|
|
75
|
+
respond(request, payload) {
|
|
76
|
+
this.send({
|
|
77
|
+
channelId: request.channelId,
|
|
78
|
+
requestId: request.requestId,
|
|
79
|
+
method: request.method,
|
|
80
|
+
payload
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
respondError(request, error) {
|
|
84
|
+
this.send({
|
|
85
|
+
channelId: request.channelId,
|
|
86
|
+
requestId: request.requestId,
|
|
87
|
+
method: request.method,
|
|
88
|
+
error
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
on(method, handler) {
|
|
92
|
+
this.listeners.set(method, handler);
|
|
93
|
+
}
|
|
94
|
+
call(method, message) {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
const requestId = this.createRequestId();
|
|
97
|
+
this.send({
|
|
98
|
+
channelId: this.channelId,
|
|
99
|
+
requestId,
|
|
100
|
+
method,
|
|
101
|
+
payload: message
|
|
102
|
+
});
|
|
103
|
+
this.handlers.set(requestId, (data) => {
|
|
104
|
+
this.handlers.delete(requestId);
|
|
105
|
+
if (data.error) return reject(data.error);
|
|
106
|
+
resolve(data.payload);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
send(data) {
|
|
111
|
+
this.targetWindow?.postMessage(data, this.targetOrigin);
|
|
112
|
+
}
|
|
101
113
|
};
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/dialog-ref.ts
|
|
104
116
|
var ContelloDialogRef = class {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
_id;
|
|
118
|
+
open;
|
|
119
|
+
connected;
|
|
120
|
+
ready;
|
|
121
|
+
complete;
|
|
122
|
+
close;
|
|
123
|
+
constructor({ channel, options, controller }) {
|
|
124
|
+
this.open = (async () => {
|
|
125
|
+
const { id } = await channel.call("openDialog", options);
|
|
126
|
+
this._id = id;
|
|
127
|
+
})();
|
|
128
|
+
this.connected = controller.connected.promise;
|
|
129
|
+
this.ready = controller.ready.promise;
|
|
130
|
+
this.complete = controller.complete.promise;
|
|
131
|
+
this.close = controller.close;
|
|
132
|
+
}
|
|
133
|
+
get id() {
|
|
134
|
+
return this._id;
|
|
135
|
+
}
|
|
121
136
|
};
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/utils.ts
|
|
124
139
|
var Deferred = class {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
resolve;
|
|
141
|
+
reject;
|
|
142
|
+
promise = new Promise((resolve, reject) => {
|
|
143
|
+
this.resolve = resolve;
|
|
144
|
+
this.reject = reject;
|
|
145
|
+
});
|
|
131
146
|
};
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/client.ts
|
|
134
149
|
var ContelloClient = class {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
150
|
+
resizeObserver;
|
|
151
|
+
targetOrigin;
|
|
152
|
+
dialogs = /* @__PURE__ */ new Map();
|
|
153
|
+
channel;
|
|
154
|
+
projectId;
|
|
155
|
+
data;
|
|
156
|
+
constructor(targetOrigin, channelId, projectId, debug) {
|
|
157
|
+
this.channel = new ExtensionChannel({ debug });
|
|
158
|
+
this.channel.connectParent(targetOrigin, channelId);
|
|
159
|
+
this.projectId = projectId;
|
|
160
|
+
this.targetOrigin = targetOrigin;
|
|
161
|
+
}
|
|
162
|
+
createEntityEntryUrl(referenceName) {
|
|
163
|
+
return `${this.createProjectUrl()}/entities/${referenceName}`;
|
|
164
|
+
}
|
|
165
|
+
listenForResize() {
|
|
166
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
167
|
+
this.channel.call("resize", { height: this.getWindowHeight() });
|
|
168
|
+
});
|
|
169
|
+
this.resizeObserver.observe(document.documentElement);
|
|
170
|
+
}
|
|
171
|
+
getWindowHeight() {
|
|
172
|
+
return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.body.clientHeight);
|
|
173
|
+
}
|
|
174
|
+
getDialogController(id) {
|
|
175
|
+
const key = this.dialogs.keys().find((dialog) => dialog.id === id);
|
|
176
|
+
if (!key) return;
|
|
177
|
+
return this.dialogs.get(key);
|
|
178
|
+
}
|
|
179
|
+
async connect() {
|
|
180
|
+
const { data } = await this.channel.call("connect");
|
|
181
|
+
this.channel.on("dialogConnect", ({ id }) => this.getDialogController(id)?.connected.resolve());
|
|
182
|
+
this.channel.on("dialogReady", ({ id }) => this.getDialogController(id)?.ready.resolve());
|
|
183
|
+
this.channel.on("dialogComplete", ({ id, value }) => this.getDialogController(id)?.complete.resolve(value));
|
|
184
|
+
this.data = data;
|
|
185
|
+
}
|
|
186
|
+
ready() {
|
|
187
|
+
this.listenForResize();
|
|
188
|
+
return this.channel.call("ready", { height: this.getWindowHeight() });
|
|
189
|
+
}
|
|
190
|
+
async getAuthToken() {
|
|
191
|
+
const { token } = await this.channel.call("getAuthToken");
|
|
192
|
+
return token;
|
|
193
|
+
}
|
|
194
|
+
createProjectUrl() {
|
|
195
|
+
return `${this.targetOrigin}/ui/projects/${this.projectId}`;
|
|
196
|
+
}
|
|
197
|
+
createSingletonEntityUrl(referenceName) {
|
|
198
|
+
return this.createEntityEntryUrl(referenceName);
|
|
199
|
+
}
|
|
200
|
+
createEntityDetailUrl(referenceName, params) {
|
|
201
|
+
const base = this.createEntityEntryUrl(referenceName);
|
|
202
|
+
if (params.mode === "create") return `${base}/create`;
|
|
203
|
+
return `${base}/${params.mode}/${params.id}`;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* @deprecated Use createEntityDetailUrl instead
|
|
207
|
+
*/
|
|
208
|
+
createEntityUrl(referenceName, entityId) {
|
|
209
|
+
return this.createEntityDetailUrl(referenceName, {
|
|
210
|
+
mode: "edit",
|
|
211
|
+
id: entityId
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
createExtensionUrl(referenceName, params) {
|
|
215
|
+
const path = params?.path?.join("/") || "";
|
|
216
|
+
const query = new URLSearchParams(params?.query || {}).toString();
|
|
217
|
+
return `${this.createProjectUrl()}/extensions/${referenceName}${path ? `/${path}` : ""}${query ? `?${query}` : ""}`;
|
|
218
|
+
}
|
|
219
|
+
navigate(url) {
|
|
220
|
+
return this.channel.call("navigate", { url });
|
|
221
|
+
}
|
|
222
|
+
displayNotification(type, message) {
|
|
223
|
+
return this.channel.call("displayNotification", {
|
|
224
|
+
type,
|
|
225
|
+
message
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
openDialog(options) {
|
|
229
|
+
const controller = {
|
|
230
|
+
connected: new Deferred(),
|
|
231
|
+
ready: new Deferred(),
|
|
232
|
+
complete: new Deferred(),
|
|
233
|
+
close: () => {
|
|
234
|
+
if (!this.channel) throw new Error("The channel is not yet initialized");
|
|
235
|
+
this.channel.call("closeDialog", { id: dialog.id });
|
|
236
|
+
this.dialogs.delete(dialog);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const dialog = new ContelloDialogRef({
|
|
240
|
+
channel: this.channel,
|
|
241
|
+
options,
|
|
242
|
+
controller
|
|
243
|
+
});
|
|
244
|
+
this.dialogs.set(dialog, controller);
|
|
245
|
+
(async () => {
|
|
246
|
+
await dialog.complete;
|
|
247
|
+
this.dialogs.delete(dialog);
|
|
248
|
+
})();
|
|
249
|
+
return dialog;
|
|
250
|
+
}
|
|
229
251
|
};
|
|
230
|
-
|
|
231
|
-
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/url-parser.ts
|
|
232
254
|
function parseUrl(trustedOrigins) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
return { channelId, targetOrigin, applicationId, debug };
|
|
255
|
+
const url = new URL(globalThis.location.href);
|
|
256
|
+
const channelId = url.searchParams.get("channelId");
|
|
257
|
+
const targetOrigin = url.searchParams.get("origin");
|
|
258
|
+
const applicationId = url.searchParams.get("applicationId");
|
|
259
|
+
if (!channelId || !targetOrigin || !applicationId) throw new Error("Missing required URL parameters");
|
|
260
|
+
if (!trustedOrigins?.length) throw new Error("No trusted origins provided");
|
|
261
|
+
if (!trustedOrigins.includes(targetOrigin)) throw new Error(`Origin ${targetOrigin} is not trusted`);
|
|
262
|
+
return {
|
|
263
|
+
channelId,
|
|
264
|
+
targetOrigin,
|
|
265
|
+
applicationId,
|
|
266
|
+
debug: url.searchParams.get("debug") === "true"
|
|
267
|
+
};
|
|
248
268
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var ContelloCustomProperty = class
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/custom-property.ts
|
|
271
|
+
var ContelloCustomProperty = class ContelloCustomProperty extends ContelloClient {
|
|
272
|
+
static async connect(options) {
|
|
273
|
+
const { targetOrigin, channelId, applicationId, debug } = parseUrl(options.trustedOrigins);
|
|
274
|
+
const customProperty = new ContelloCustomProperty(targetOrigin, channelId, applicationId, debug);
|
|
275
|
+
customProperty.validate = options.validator || (() => true);
|
|
276
|
+
customProperty.newValue = options.newValue || (() => null);
|
|
277
|
+
await customProperty.connect();
|
|
278
|
+
return customProperty;
|
|
279
|
+
}
|
|
280
|
+
validate = () => true;
|
|
281
|
+
newValue = () => null;
|
|
282
|
+
constructor(targetOrigin, channelId, applicationId, debug) {
|
|
283
|
+
super(targetOrigin, channelId, applicationId, debug);
|
|
284
|
+
this.channel.on("validate", async () => {
|
|
285
|
+
return { valid: await Promise.resolve(this.validate()) };
|
|
286
|
+
});
|
|
287
|
+
this.channel.on("newValue", async (msg) => {
|
|
288
|
+
await Promise.resolve(this.newValue(msg.value));
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
async getValue() {
|
|
292
|
+
return (await this.channel.call("getValue")).value;
|
|
293
|
+
}
|
|
294
|
+
async setValue(value) {
|
|
295
|
+
const valid = await Promise.resolve(this.validate());
|
|
296
|
+
return await this.channel.call("setValue", {
|
|
297
|
+
value,
|
|
298
|
+
valid
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
async getValueByPath(path) {
|
|
302
|
+
return (await this.channel.call("getValueByPath", { path })).value;
|
|
303
|
+
}
|
|
304
|
+
async setValueByPath(path, value) {
|
|
305
|
+
return this.channel.call("setValueByPath", {
|
|
306
|
+
value,
|
|
307
|
+
path
|
|
308
|
+
});
|
|
309
|
+
}
|
|
286
310
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
var ContelloDialog = class
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// src/extension.ts
|
|
304
|
-
var ContelloExtension = class _ContelloExtension extends ContelloClient {
|
|
305
|
-
static connect({ trustedOrigins }) {
|
|
306
|
-
const { targetOrigin, channelId, applicationId, debug } = parseUrl(trustedOrigins);
|
|
307
|
-
const extension = new _ContelloExtension(targetOrigin, channelId, applicationId, debug);
|
|
308
|
-
return extension.connect().then(() => extension);
|
|
309
|
-
}
|
|
310
|
-
constructor(targetOrigin, channelId, applicationId, debug) {
|
|
311
|
-
super(targetOrigin, channelId, applicationId, debug);
|
|
312
|
-
}
|
|
313
|
-
getUrlData() {
|
|
314
|
-
return this.channel.call("getUrlData");
|
|
315
|
-
}
|
|
316
|
-
setBreadcrumbs(breadcrumbs) {
|
|
317
|
-
return this.channel.call("setBreadcrumbs", { breadcrumbs });
|
|
318
|
-
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/dialog.ts
|
|
313
|
+
var ContelloDialog = class ContelloDialog extends ContelloClient {
|
|
314
|
+
static async connect({ trustedOrigins }) {
|
|
315
|
+
const { targetOrigin, channelId, applicationId, debug } = parseUrl(trustedOrigins);
|
|
316
|
+
const dialog = new ContelloDialog(targetOrigin, channelId, applicationId, debug);
|
|
317
|
+
await dialog.connect();
|
|
318
|
+
return dialog;
|
|
319
|
+
}
|
|
320
|
+
constructor(targetOrigin, channelId, applicationId, debug) {
|
|
321
|
+
super(targetOrigin, channelId, applicationId, debug);
|
|
322
|
+
}
|
|
323
|
+
close(value) {
|
|
324
|
+
return this.channel.call("complete", { value });
|
|
325
|
+
}
|
|
319
326
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/extension.ts
|
|
329
|
+
var ContelloExtension = class ContelloExtension extends ContelloClient {
|
|
330
|
+
static async connect({ trustedOrigins }) {
|
|
331
|
+
const { targetOrigin, channelId, applicationId, debug } = parseUrl(trustedOrigins);
|
|
332
|
+
const extension = new ContelloExtension(targetOrigin, channelId, applicationId, debug);
|
|
333
|
+
await extension.connect();
|
|
334
|
+
return extension;
|
|
335
|
+
}
|
|
336
|
+
constructor(targetOrigin, channelId, applicationId, debug) {
|
|
337
|
+
super(targetOrigin, channelId, applicationId, debug);
|
|
338
|
+
}
|
|
339
|
+
getUrlData() {
|
|
340
|
+
return this.channel.call("getUrlData");
|
|
341
|
+
}
|
|
342
|
+
setBreadcrumbs(breadcrumbs) {
|
|
343
|
+
return this.channel.call("setBreadcrumbs", { breadcrumbs });
|
|
344
|
+
}
|
|
326
345
|
};
|
|
346
|
+
//#endregion
|
|
347
|
+
export { ContelloCustomProperty, ContelloDialog, ContelloDialogRef, ContelloExtension, ExtensionChannel };
|
|
348
|
+
|
|
349
|
+
//# sourceMappingURL=index.js.map
|