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