@wix/editor 1.335.0 → 1.337.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/dist/esm/index.js CHANGED
@@ -1,280 +1,9 @@
1
+ import { EditorPlatformContextEnvironment } from '@wix/editor-platform-environment-api';
2
+ import { ApplicationContext } from '@wix/editor-platform-contexts';
1
3
  import { createErrorBuilder, BaseError } from '@wix/public-editor-platform-errors';
2
- import { PlatformAppEvent } from '@wix/public-editor-platform-events';
3
- import { WorkerConsumerEndpoint, IFrameConsumerEndpoint } from '@wix/editor-platform-transport';
4
- import { PlatformFrameAPI } from '@wix/editor-application/platform-frame-api';
5
- import { PlatformWorkerAPI } from '@wix/editor-application/platform-worker-api';
6
4
  import { createHostModule } from '@wix/sdk-runtime/host-modules';
7
5
 
8
- var EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {
9
- EditorPlatformApplicationContextErrorCode2["IncorrectEnvironment"] = "IncorrectEnvironment";
10
- EditorPlatformApplicationContextErrorCode2["ClientAuthError"] = "ClientAuthError";
11
- return EditorPlatformApplicationContextErrorCode2;
12
- })(EditorPlatformApplicationContextErrorCode || {});
13
- class EditorPlatformApplicationContextError extends BaseError {
14
- state = {};
15
- constructor(message, code) {
16
- super(message, code, "Editor Platform Application Context Error");
17
- }
18
- withUrl(url) {
19
- this.state = { ...this.state, url };
20
- return this;
21
- }
22
- withAppDefinitionId(appDefinitionId) {
23
- this.state = { ...this.state, appDefinitionId };
24
- return this;
25
- }
26
- }
27
- const createEditorPlatformApplicationContextError = createErrorBuilder(EditorPlatformApplicationContextError);
28
- async function transformEventPayload(eventPayload, privateAPI) {
29
- if (!eventPayload?.type) {
30
- return eventPayload;
31
- }
32
- switch (eventPayload.type) {
33
- case "componentSelectionChanged":
34
- const componentRefs = eventPayload.componentRefs || [];
35
- const components = await Promise.all(
36
- componentRefs.map((ref) => {
37
- return privateAPI.components.getComponent(ref);
38
- })
39
- );
40
- return {
41
- type: eventPayload.type,
42
- components
43
- };
44
- default:
45
- return eventPayload;
46
- }
47
- }
48
- class ApplicationBoundEvents {
49
- constructor(appDefinitionId, events, privateAPI) {
50
- this.appDefinitionId = appDefinitionId;
51
- this.privateAPI = privateAPI;
52
- this.events = events;
53
- this.subscribe = events.subscribe.bind(events);
54
- this.commit = events.commit.bind(events);
55
- this.startTransaction = events.startTransaction.bind(events);
56
- this.silent = events.silent.bind(events);
57
- }
58
- events;
59
- subscribe;
60
- commit;
61
- startTransaction;
62
- silent;
63
- notify(event) {
64
- this.events.notify({
65
- type: event.type,
66
- payload: event.payload,
67
- meta: {
68
- appDefinitionId: this.appDefinitionId
69
- }
70
- });
71
- }
72
- notifyCustomEvent(type, payload) {
73
- this.notify({
74
- type: PlatformAppEvent.CustomEvent,
75
- payload: {
76
- ...payload,
77
- type
78
- }
79
- });
80
- }
81
- /**
82
- * TODO: we should use same interface for all events
83
- * (subscribe vs addEventListener)
84
- */
85
- addEventListener(eventType, fn) {
86
- return this.events.subscribe(async (event) => {
87
- const isAppMatch = event.meta?.appDefinitionId === this.appDefinitionId || event.meta?.appDefinitionId === null;
88
- const transformPayload = () => transformEventPayload(event.payload, this.privateAPI);
89
- if (eventType === "*") {
90
- fn(await transformPayload());
91
- } else if (event.type === PlatformAppEvent.CustomEvent) {
92
- if (eventType === event.payload?.type && !isAppMatch) {
93
- fn(await transformPayload());
94
- }
95
- } else if (event.type === PlatformAppEvent.HostEvent) {
96
- if (eventType === event.payload?.type && isAppMatch) {
97
- fn(await transformPayload());
98
- }
99
- }
100
- });
101
- }
102
- }
103
- const WAIT_INJECTED_TIMEOUT = 200;
104
- const WAIT_INJECTED_RETRY_COUNT = 50;
105
- class ContextInjectionStatus {
106
- _resolveContextInjected = () => {
107
- };
108
- _isInjected = false;
109
- key;
110
- constructor(uuid) {
111
- this.key = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;
112
- if (!globalThis[this.key]) {
113
- globalThis[this.key] = new Promise((resolve) => {
114
- this._resolveContextInjected = () => {
115
- this._isInjected = true;
116
- resolve();
117
- };
118
- });
119
- }
120
- }
121
- isInjected() {
122
- return !!this._isInjected;
123
- }
124
- resolveInjected() {
125
- this._resolveContextInjected?.();
126
- }
127
- waitInjected() {
128
- return new Promise((resolve, reject) => {
129
- let injected = false;
130
- let timeoutId;
131
- let retryCount = 0;
132
- const timeout = () => {
133
- if (injected) {
134
- return;
135
- }
136
- timeoutId = setTimeout(() => {
137
- retryCount++;
138
- if (retryCount < WAIT_INJECTED_RETRY_COUNT) {
139
- if (retryCount % 10 === 0) {
140
- console.log(
141
- createEditorPlatformApplicationContextError(
142
- EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
143
- "contexts are not resolved, still re-trying"
144
- ).withMessage(`try number ${retryCount}`).message
145
- );
146
- }
147
- timeout();
148
- return;
149
- }
150
- if (!injected) {
151
- const error = createEditorPlatformApplicationContextError(
152
- EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
153
- "contexts are not resolved, threw by timeout"
154
- );
155
- reject(error);
156
- }
157
- }, WAIT_INJECTED_TIMEOUT);
158
- };
159
- timeout();
160
- const _waitContextInjectedPromise = globalThis[this.key];
161
- _waitContextInjectedPromise.then(() => {
162
- injected = true;
163
- clearTimeout(timeoutId);
164
- resolve();
165
- });
166
- });
167
- }
168
- }
169
- const ENVIRONMENT_CONTEXT_KEY = "__ENVIRONMENT_CONTEXT_KEY";
170
- var PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {
171
- PlatformEnvironment2["Worker"] = "Worker";
172
- PlatformEnvironment2["Frame"] = "Frame";
173
- PlatformEnvironment2["ComponentPanel"] = "ComponentPanel";
174
- return PlatformEnvironment2;
175
- })(PlatformEnvironment || {});
176
- class EnvironmentContext {
177
- constructor(environmentContext) {
178
- this.environmentContext = environmentContext;
179
- }
180
- static status = new ContextInjectionStatus("environment");
181
- static async inject(context) {
182
- if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {
183
- throw createEditorPlatformApplicationContextError(
184
- EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
185
- "Environment context already exists and should not be overridden"
186
- );
187
- }
188
- globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);
189
- this.status.resolveInjected();
190
- }
191
- static async getInstance() {
192
- await this.status.waitInjected();
193
- return globalThis[ENVIRONMENT_CONTEXT_KEY];
194
- }
195
- getPrivateAPI() {
196
- return this.environmentContext.privateApi;
197
- }
198
- getEvents() {
199
- return this.environmentContext.events;
200
- }
201
- getApplicationAPIs() {
202
- return this.environmentContext.applicationAPIs ?? {};
203
- }
204
- getEnvironment() {
205
- return this.environmentContext.environment;
206
- }
207
- }
208
- const APPLICATION_CONTEXT_KEY = "__APPLICATION_CONTEXT_KEY";
209
- class ApplicationContext {
210
- constructor(applicationContext, environment) {
211
- this.applicationContext = applicationContext;
212
- this.environment = environment;
213
- this.events = new ApplicationBoundEvents(
214
- this.applicationContext.appDefinitionId,
215
- this.environment.getEvents(),
216
- this.environment.getPrivateAPI()
217
- );
218
- }
219
- static status = new ContextInjectionStatus("application");
220
- /**
221
- * TODO: use generics for context type
222
- * - application
223
- * - editor
224
- */
225
- static async inject(context) {
226
- const environment = await EnvironmentContext.getInstance();
227
- if (environment.getEnvironment() !== PlatformEnvironment.Frame) {
228
- throw createEditorPlatformApplicationContextError(
229
- EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
230
- "Application context can be injected only in frame environment"
231
- );
232
- }
233
- if (globalThis[APPLICATION_CONTEXT_KEY]) {
234
- throw createEditorPlatformApplicationContextError(
235
- EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
236
- "Application context already exists and should not be overridden"
237
- );
238
- }
239
- globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(
240
- context,
241
- await EnvironmentContext.getInstance()
242
- );
243
- this.status.resolveInjected();
244
- }
245
- static async getInstance() {
246
- const environment = await EnvironmentContext.getInstance();
247
- if (environment.getEnvironment() === PlatformEnvironment.Frame) {
248
- await this.status.waitInjected();
249
- return globalThis[APPLICATION_CONTEXT_KEY];
250
- } else {
251
- return __APPLICATION_CONTEXT_KEY;
252
- }
253
- }
254
- events;
255
- getAppDefinitionId() {
256
- return this.applicationContext.appDefinitionId;
257
- }
258
- getBindings() {
259
- return this.applicationContext;
260
- }
261
- getEvents() {
262
- return this.events;
263
- }
264
- getPrivateAPI() {
265
- return this.environment.getPrivateAPI();
266
- }
267
- getPrivateApplicationAPI() {
268
- const appDefinitionId = this.getAppDefinitionId();
269
- if (!appDefinitionId) {
270
- throw createEditorPlatformApplicationContextError(
271
- EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
272
- "appDefinitionId is not available"
273
- );
274
- }
275
- return this.environment.getApplicationAPIs()[appDefinitionId];
276
- }
277
- }
6
+ new EditorPlatformContextEnvironment().expose();
278
7
 
279
8
  class EditorPlatformSDKAuthError extends BaseError {
280
9
  state = {};
@@ -335,118 +64,110 @@ const auth = () => {
335
64
  };
336
65
  };
337
66
 
338
- const INIT_KEY = "_EP_TRANSPORT_INIT_KEY";
339
- if (!globalThis[INIT_KEY]) {
340
- const isWorker = typeof importScripts === "function";
341
- if (isWorker) {
342
- WorkerConsumerEndpoint.exposeAPI(new PlatformWorkerAPI());
343
- } else {
344
- IFrameConsumerEndpoint.exposeAPI(new PlatformFrameAPI());
345
- }
346
- globalThis[INIT_KEY] = true;
347
- }
348
-
349
67
  class PlatformSDKShape {
350
- constructor(namespace, shape) {
68
+ constructor(namespace, shapeConstructor) {
351
69
  this.namespace = namespace;
352
- this.shape = shape;
70
+ this.shapeConstructor = shapeConstructor;
353
71
  }
354
72
  build() {
355
- return createHostModule(
356
- Object.fromEntries(
357
- Object.entries(this.shape).map(([key, value]) => [
358
- key,
359
- (host) => {
360
- if (host?.environmentContext && host?.applicationContext) {
361
- return async (...args) => {
362
- const [environmentContext, applicationContext] = await Promise.all([
363
- host.environmentContext,
364
- host.applicationContext
365
- ]);
366
- return value({
367
- environmentContext,
368
- applicationContext
369
- })(...args);
370
- };
371
- }
372
- return async (...args) => {
373
- const [environmentContext, applicationContext] = await Promise.all([
374
- EnvironmentContext.getInstance(),
375
- ApplicationContext.getInstance()
376
- ]);
377
- return value({
378
- environmentContext,
379
- applicationContext
380
- })(...args);
381
- };
382
- }
383
- ])
384
- )
73
+ const instance = new this.shapeConstructor();
74
+ const methods = Object.getOwnPropertyNames(
75
+ Object.getPrototypeOf(instance)
76
+ ).filter(
77
+ (prop) => prop !== "constructor" && typeof // @ts-expect-error
78
+ instance[prop] === "function"
385
79
  );
80
+ const api = methods.reduce((acc, method) => {
81
+ return {
82
+ ...acc,
83
+ [method]: (host) => {
84
+ if (host?.applicationContext) {
85
+ const _instance = instance.withApplicationContext(
86
+ host.applicationContext
87
+ );
88
+ return _instance[method].bind(_instance);
89
+ } else {
90
+ return instance[method].bind(instance);
91
+ }
92
+ }
93
+ };
94
+ }, {});
95
+ return createHostModule(api);
386
96
  }
387
97
  }
388
98
 
389
- const applicationShape = new PlatformSDKShape("application", {
390
- getPrivateAPI({ applicationContext }) {
391
- return async () => {
392
- return applicationContext.getPrivateApplicationAPI();
393
- };
394
- },
395
- getPublicAPI({ applicationContext }) {
396
- return async (appDefinitionId) => {
397
- const privateAPI = applicationContext.getPrivateAPI();
398
- return privateAPI.applicationManager.getPublicApplicationAPI(
399
- appDefinitionId
400
- );
401
- };
402
- },
403
- getAppInstance({ applicationContext }) {
404
- return async () => {
405
- const privateAPI = applicationContext.getPrivateAPI();
406
- const bindings = applicationContext.getBindings();
407
- return privateAPI.info.getAppInstance(bindings.appDefinitionId);
408
- };
99
+ class BaseSDKShape {
100
+ /**
101
+ * note, constructor might be called multiple times
102
+ * because of the context override
103
+ */
104
+ constructor(overrideApplicationContext = null) {
105
+ this.overrideApplicationContext = overrideApplicationContext;
106
+ }
107
+ getApplicationContext() {
108
+ return this.overrideApplicationContext ? this.overrideApplicationContext : ApplicationContext.getInstance();
109
+ }
110
+ async getEnvironmentContext() {
111
+ return (await this.getApplicationContext()).getEnvironmentContext();
112
+ }
113
+ async getPlatformPrivateAPI() {
114
+ return (await this.getApplicationContext()).getPrivateAPI();
409
115
  }
410
- });
411
- var index$4 = applicationShape.build();
116
+ async getContextBindings() {
117
+ return (await this.getApplicationContext()).getBindings();
118
+ }
119
+ withApplicationContext(applicationContext) {
120
+ return new this.constructor(applicationContext);
121
+ }
122
+ }
412
123
 
413
- const componentsShape = new PlatformSDKShape("components", {
414
- getSelectedComponents({ applicationContext }) {
415
- return async () => {
416
- const privateAPI = applicationContext.getPrivateAPI();
417
- const refs = await privateAPI.components.getSelectedComponents();
418
- return Promise.all(
419
- refs.map((ref) => privateAPI.components.getComponent(ref))
420
- );
421
- };
124
+ class ApplicationSDKShape extends BaseSDKShape {
125
+ async getPrivateAPI() {
126
+ return (await this.getApplicationContext()).getPrivateApplicationAPI();
127
+ }
128
+ async getPublicAPI(appDefinitionId) {
129
+ const privateAPI = await this.getPlatformPrivateAPI();
130
+ return privateAPI.applicationManager.getPublicApplicationAPI(
131
+ appDefinitionId
132
+ );
133
+ }
134
+ async getAppInstance() {
135
+ const privateAPI = await this.getPlatformPrivateAPI();
136
+ const bindings = await this.getContextBindings();
137
+ return privateAPI.info.getAppInstance(bindings.appDefinitionId);
422
138
  }
423
- });
424
- var components = componentsShape.build();
139
+ }
140
+ var index$5 = new PlatformSDKShape("application", ApplicationSDKShape).build();
425
141
 
426
- const eventsShape = new PlatformSDKShape("events", {
427
- addEventListener({ applicationContext }) {
428
- return async (name, cb) => {
429
- return applicationContext.getEvents().addEventListener(name, cb);
430
- };
142
+ class ComponentsSDKShape extends BaseSDKShape {
143
+ async getSelectedComponents() {
144
+ const privateAPI = await this.getPlatformPrivateAPI();
145
+ const refs = await privateAPI.components.getSelectedComponents();
146
+ return Promise.all(
147
+ refs.map((ref) => privateAPI.components.getComponent(ref))
148
+ );
431
149
  }
432
- });
433
- var index$3 = eventsShape.build();
150
+ }
151
+ var components = new PlatformSDKShape("components", ComponentsSDKShape).build();
434
152
 
435
- const infoShape = new PlatformSDKShape("info", {
436
- getViewMode({ applicationContext }) {
437
- return async () => {
438
- const privateAPI = applicationContext.getPrivateAPI();
439
- return privateAPI.info.getViewMode();
440
- };
441
- },
442
- getLanguageCode({ applicationContext }) {
443
- return async () => {
444
- const privateAPI = applicationContext.getPrivateAPI();
445
- return privateAPI.info.getLanguageCode();
446
- };
153
+ class EventsSDKShape extends BaseSDKShape {
154
+ async addEventListener(name, cb) {
155
+ return (await this.getApplicationContext()).getEvents().addEventListener(name, cb);
156
+ }
157
+ }
158
+ var index$4 = new PlatformSDKShape("events", EventsSDKShape).build();
159
+
160
+ class InfoSDKShape extends BaseSDKShape {
161
+ async getViewMode() {
162
+ const privateAPI = await this.getPlatformPrivateAPI();
163
+ return privateAPI.info.getViewMode();
164
+ }
165
+ async getLanguageCode() {
166
+ const privateAPI = await this.getPlatformPrivateAPI();
167
+ return privateAPI.info.getLanguageCode();
447
168
  }
448
- });
449
- var index$2 = infoShape.build();
169
+ }
170
+ var index$3 = new PlatformSDKShape("info", InfoSDKShape).build();
450
171
 
451
172
  var WidgetShapeErrorCode = /* @__PURE__ */ ((WidgetShapeErrorCode2) => {
452
173
  WidgetShapeErrorCode2["UndefinedCompRef"] = "UndefinedCompRef";
@@ -459,31 +180,28 @@ class WidgetShapeError extends BaseError {
459
180
  }
460
181
  const createWidgetShapeError = createErrorBuilder(WidgetShapeError);
461
182
 
462
- const getSelectedComponentRef = async () => {
463
- const selected = await components.getSelectedComponents();
464
- const compRef = selected[0]?.compRef;
465
- if (!compRef) {
466
- throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);
467
- }
468
- return compRef;
469
- };
470
- const widgetShape = new PlatformSDKShape("widget", {
471
- getProp({ applicationContext }) {
472
- return async (propName) => {
473
- const privateAPI = applicationContext.getPrivateAPI();
474
- const compRef = await getSelectedComponentRef();
475
- return privateAPI.customElement.getAttribute(compRef, propName);
476
- };
477
- },
478
- setProp({ applicationContext }) {
479
- return async (propName, value) => {
480
- const privateAPI = applicationContext.getPrivateAPI();
481
- const compRef = await getSelectedComponentRef();
482
- await privateAPI.customElement.setAttribute(compRef, propName, value);
483
- };
183
+ class WidgetSDKShape extends BaseSDKShape {
184
+ async getProp(propName) {
185
+ const privateAPI = await this.getPlatformPrivateAPI();
186
+ const compRef = await this.#getSelectedComponentRef();
187
+ return privateAPI.customElement.getAttribute(compRef, propName);
188
+ }
189
+ async setProp(propName, value) {
190
+ const privateAPI = await this.getPlatformPrivateAPI();
191
+ const compRef = await this.#getSelectedComponentRef();
192
+ await privateAPI.customElement.setAttribute(compRef, propName, value);
193
+ }
194
+ async #getSelectedComponentRef() {
195
+ const selected = await components.getSelectedComponents();
196
+ const compRef = selected[0]?.compRef;
197
+ if (!compRef) {
198
+ throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);
199
+ }
200
+ return compRef;
484
201
  }
485
- });
486
- var index$1 = widgetShape.build();
202
+ }
203
+ const widgetShape = new PlatformSDKShape("widget", WidgetSDKShape);
204
+ var index$2 = widgetShape.build();
487
205
 
488
206
  const UNDERLINE_DEFINITION = "underline";
489
207
  function extractFontVar(fontString) {
@@ -588,145 +306,125 @@ const fonts = {
588
306
  }
589
307
  }
590
308
  };
591
- const inputsShape = new PlatformSDKShape("inputs", {
592
- selectColor({ applicationContext }) {
593
- return async (value, options) => {
594
- const privateAPI = applicationContext.getPrivateAPI();
595
- let colorValue = parseColorString(value);
596
- let colorResult = colorValueToCSS(colorValue);
597
- await privateAPI.inputs.openColorPicker(
598
- {
599
- color: colorValue?.cssVariableName || colorValue?.theme || colorValue?.color
600
- },
601
- ({
309
+ class InputsSDKShape extends BaseSDKShape {
310
+ async selectColor(value, options) {
311
+ const privateAPI = await this.getPlatformPrivateAPI();
312
+ let colorValue = parseColorString(value);
313
+ let colorResult = colorValueToCSS(colorValue);
314
+ await privateAPI.inputs.openColorPicker(
315
+ {
316
+ color: colorValue?.cssVariableName || colorValue?.theme || colorValue?.color
317
+ },
318
+ ({
319
+ color,
320
+ theme,
321
+ cssVariableTheme
322
+ }) => {
323
+ colorValue = {
602
324
  color,
603
325
  theme,
604
- cssVariableTheme
605
- }) => {
606
- colorValue = {
607
- color,
608
- theme,
609
- cssVariableName: cssVariableTheme
610
- };
611
- colorResult = colorValueToCSS(colorValue);
612
- options?.onChange?.(colorResult);
613
- }
614
- );
615
- return colorResult;
616
- };
617
- },
618
- selectFont({ applicationContext }) {
619
- return async (value, options) => {
620
- const privateAPI = applicationContext.getPrivateAPI();
621
- const fontValue = parseFontString(value);
622
- let _value = value;
623
- await privateAPI.inputs.openFontPickerV2(
624
- {
625
- ...options,
626
- panelSectionsDefinition: {
627
- htmlTag: "hidden"
628
- },
629
- componentStyle: fonts.transformFontInternalValue(fontValue)
326
+ cssVariableName: cssVariableTheme
327
+ };
328
+ colorResult = colorValueToCSS(colorValue);
329
+ options?.onChange?.(colorResult);
330
+ }
331
+ );
332
+ return colorResult;
333
+ }
334
+ async selectFont(value, options) {
335
+ const privateAPI = await this.getPlatformPrivateAPI();
336
+ const fontValue = parseFontString(value);
337
+ let _value = value;
338
+ await privateAPI.inputs.openFontPickerV2(
339
+ {
340
+ ...options,
341
+ panelSectionsDefinition: {
342
+ htmlTag: "hidden"
630
343
  },
631
- (font, accessibility) => {
632
- _value = {
633
- font: fontValueToCSS(font),
634
- textDecoration: font.underline ? UNDERLINE_DEFINITION : void 0
635
- };
636
- options?.onChange?.(_value);
637
- }
638
- );
639
- return _value;
640
- };
344
+ componentStyle: fonts.transformFontInternalValue(fontValue)
345
+ },
346
+ (font, accessibility) => {
347
+ _value = {
348
+ font: fontValueToCSS(font),
349
+ textDecoration: font.underline ? UNDERLINE_DEFINITION : void 0
350
+ };
351
+ options?.onChange?.(_value);
352
+ }
353
+ );
354
+ return _value;
641
355
  }
642
- });
643
- var index = inputsShape.build();
356
+ }
357
+ var index$1 = new PlatformSDKShape("inputs", InputsSDKShape).build();
644
358
 
645
- const externalPanels = new PlatformSDKShape("externalPanels", {
646
- getData({ applicationContext }) {
647
- return async () => {
648
- const privateAPI = applicationContext.getPrivateAPI();
649
- return privateAPI.externalPanels.getData();
650
- };
651
- },
652
- setData({ applicationContext }) {
653
- return async (newData) => {
654
- const privateAPI = applicationContext.getPrivateAPI();
655
- return privateAPI.externalPanels.setData(newData);
656
- };
657
- },
658
- getStyle({ applicationContext }) {
659
- return async () => {
660
- const privateAPI = applicationContext.getPrivateAPI();
661
- return privateAPI.externalPanels.getStyle();
662
- };
663
- },
664
- setStyle({ applicationContext }) {
665
- return async (newStyle) => {
666
- const privateAPI = applicationContext.getPrivateAPI();
667
- return privateAPI.externalPanels.setStyle(newStyle);
668
- };
669
- },
670
- getTheme({ applicationContext }) {
671
- return async () => {
672
- const privateAPI = applicationContext.getPrivateAPI();
673
- return privateAPI.externalPanels.getTheme();
674
- };
675
- },
676
- selectMedia({ applicationContext }) {
359
+ class ExternalPanelsSDKShape extends BaseSDKShape {
360
+ async getData() {
361
+ const privateAPI = await this.getPlatformPrivateAPI();
362
+ return privateAPI.externalPanels.getData();
363
+ }
364
+ async setData(newData) {
365
+ const privateAPI = await this.getPlatformPrivateAPI();
366
+ return privateAPI.externalPanels.setData(newData);
367
+ }
368
+ async getStyle() {
369
+ const privateAPI = await this.getPlatformPrivateAPI();
370
+ return privateAPI.externalPanels.getStyle();
371
+ }
372
+ async setStyle(newStyle) {
373
+ const privateAPI = await this.getPlatformPrivateAPI();
374
+ return privateAPI.externalPanels.setStyle(newStyle);
375
+ }
376
+ async getTheme() {
377
+ const privateAPI = await this.getPlatformPrivateAPI();
378
+ return privateAPI.externalPanels.getTheme();
379
+ }
380
+ async selectMedia() {
381
+ const privateAPI = await this.getPlatformPrivateAPI();
382
+ return privateAPI.externalPanels.selectMedia();
383
+ }
384
+ async selectLink(...options) {
385
+ const privateAPI = await this.getPlatformPrivateAPI();
386
+ return privateAPI.externalPanels.selectLink(...options);
387
+ }
388
+ async selectColor(...options) {
677
389
  return async () => {
678
- const privateAPI = applicationContext.getPrivateAPI();
679
- return privateAPI.externalPanels.selectMedia();
680
- };
681
- },
682
- selectLink({ applicationContext }) {
683
- return async (...options) => {
684
- const privateAPI = applicationContext.getPrivateAPI();
685
- return privateAPI.externalPanels.selectLink(...options);
686
- };
687
- },
688
- selectColor({ applicationContext }) {
689
- return async (...options) => {
690
- const privateAPI = applicationContext.getPrivateAPI();
390
+ const privateAPI = await this.getPlatformPrivateAPI();
691
391
  return privateAPI.externalPanels.selectColor(...options);
692
392
  };
693
- },
694
- translate({ applicationContext }) {
695
- return async (key, values) => {
696
- const privateAPI = applicationContext.getPrivateAPI();
697
- return privateAPI.externalPanels.translate(key, values);
698
- };
699
393
  }
700
- });
701
- var externalPanels$1 = externalPanels.build();
394
+ async translate(key, values) {
395
+ const privateAPI = await this.getPlatformPrivateAPI();
396
+ return privateAPI.externalPanels.translate(key, values);
397
+ }
398
+ }
399
+ var index = new PlatformSDKShape(
400
+ "externalPanels",
401
+ ExternalPanelsSDKShape
402
+ ).build();
702
403
 
703
- const editorPlatformFrameHost = () => {
404
+ const frame = () => {
704
405
  const queryParams = new URLSearchParams(window.location.search);
705
406
  return {
706
407
  environment: {},
408
+ applicationContext: ApplicationContext.getInstance(),
707
409
  channel: {
708
410
  observeState: async () => {
709
411
  return { disconnect() {
710
412
  } };
711
413
  }
712
414
  },
713
- environmentContext: EnvironmentContext.getInstance(),
714
- applicationContext: ApplicationContext.getInstance(),
715
415
  essentials: queryParams.has("essentials") ? JSON.parse(queryParams.get("essentials")) : {}
716
416
  };
717
417
  };
718
-
719
- const editorPlatformWorkerHost = () => {
418
+ const worker = () => {
720
419
  return {
721
420
  environment: {},
421
+ applicationContext: ApplicationContext.getInstance(),
722
422
  channel: {
723
423
  observeState: async () => {
724
424
  return { disconnect() {
725
425
  } };
726
426
  }
727
- },
728
- environmentContext: EnvironmentContext.getInstance(),
729
- applicationContext: ApplicationContext.getInstance()
427
+ }
730
428
  };
731
429
  };
732
430
 
@@ -734,12 +432,12 @@ const editor = {
734
432
  host: () => {
735
433
  const isWorker = typeof importScripts === "function";
736
434
  if (isWorker) {
737
- return editorPlatformWorkerHost();
435
+ return worker();
738
436
  }
739
- return editorPlatformFrameHost();
437
+ return frame();
740
438
  },
741
439
  auth
742
440
  };
743
441
 
744
- export { index$4 as application, components, editor, index$3 as events, externalPanels$1 as externalPanels, index$2 as info, index as inputs, index$1 as widget };
442
+ export { index$5 as application, components, editor, index$4 as events, index as externalPanels, index$3 as info, index$1 as inputs, index$2 as widget };
745
443
  //# sourceMappingURL=index.js.map