@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/cjs/index.js CHANGED
@@ -1,282 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ var editorPlatformEnvironmentApi = require('@wix/editor-platform-environment-api');
4
+ var editorPlatformContexts = require('@wix/editor-platform-contexts');
3
5
  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');
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
- }
8
+ new editorPlatformEnvironmentApi.EditorPlatformContextEnvironment().expose();
280
9
 
281
10
  class EditorPlatformSDKAuthError extends publicEditorPlatformErrors.BaseError {
282
11
  state = {};
@@ -299,7 +28,7 @@ const auth = () => {
299
28
  let instance;
300
29
  return {
301
30
  getAuthHeaders: async () => {
302
- const context = await ApplicationContext.getInstance();
31
+ const context = await editorPlatformContexts.ApplicationContext.getInstance();
303
32
  const bindings = context.getBindings();
304
33
  const privateAPI = context.getPrivateAPI();
305
34
  if (!bindings.appDefinitionId) {
@@ -337,118 +66,110 @@ const auth = () => {
337
66
  };
338
67
  };
339
68
 
340
- const INIT_KEY = "_EP_TRANSPORT_INIT_KEY";
341
- if (!globalThis[INIT_KEY]) {
342
- const isWorker = typeof importScripts === "function";
343
- if (isWorker) {
344
- editorPlatformTransport.WorkerConsumerEndpoint.exposeAPI(new platformWorkerApi.PlatformWorkerAPI());
345
- } else {
346
- editorPlatformTransport.IFrameConsumerEndpoint.exposeAPI(new platformFrameApi.PlatformFrameAPI());
347
- }
348
- globalThis[INIT_KEY] = true;
349
- }
350
-
351
69
  class PlatformSDKShape {
352
- constructor(namespace, shape) {
70
+ constructor(namespace, shapeConstructor) {
353
71
  this.namespace = namespace;
354
- this.shape = shape;
72
+ this.shapeConstructor = shapeConstructor;
355
73
  }
356
74
  build() {
357
- return hostModules.createHostModule(
358
- Object.fromEntries(
359
- Object.entries(this.shape).map(([key, value]) => [
360
- key,
361
- (host) => {
362
- if (host?.environmentContext && host?.applicationContext) {
363
- return async (...args) => {
364
- const [environmentContext, applicationContext] = await Promise.all([
365
- host.environmentContext,
366
- host.applicationContext
367
- ]);
368
- return value({
369
- environmentContext,
370
- applicationContext
371
- })(...args);
372
- };
373
- }
374
- return async (...args) => {
375
- const [environmentContext, applicationContext] = await Promise.all([
376
- EnvironmentContext.getInstance(),
377
- ApplicationContext.getInstance()
378
- ]);
379
- return value({
380
- environmentContext,
381
- applicationContext
382
- })(...args);
383
- };
384
- }
385
- ])
386
- )
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"
387
81
  );
82
+ const api = methods.reduce((acc, method) => {
83
+ return {
84
+ ...acc,
85
+ [method]: (host) => {
86
+ if (host?.applicationContext) {
87
+ const _instance = instance.withApplicationContext(
88
+ host.applicationContext
89
+ );
90
+ return _instance[method].bind(_instance);
91
+ } else {
92
+ return instance[method].bind(instance);
93
+ }
94
+ }
95
+ };
96
+ }, {});
97
+ return hostModules.createHostModule(api);
388
98
  }
389
99
  }
390
100
 
391
- const applicationShape = new PlatformSDKShape("application", {
392
- getPrivateAPI({ applicationContext }) {
393
- return async () => {
394
- return applicationContext.getPrivateApplicationAPI();
395
- };
396
- },
397
- getPublicAPI({ applicationContext }) {
398
- return async (appDefinitionId) => {
399
- const privateAPI = applicationContext.getPrivateAPI();
400
- return privateAPI.applicationManager.getPublicApplicationAPI(
401
- appDefinitionId
402
- );
403
- };
404
- },
405
- getAppInstance({ applicationContext }) {
406
- return async () => {
407
- const privateAPI = applicationContext.getPrivateAPI();
408
- const bindings = applicationContext.getBindings();
409
- return privateAPI.info.getAppInstance(bindings.appDefinitionId);
410
- };
101
+ class BaseSDKShape {
102
+ /**
103
+ * note, constructor might be called multiple times
104
+ * because of the context override
105
+ */
106
+ constructor(overrideApplicationContext = null) {
107
+ this.overrideApplicationContext = overrideApplicationContext;
108
+ }
109
+ getApplicationContext() {
110
+ return this.overrideApplicationContext ? this.overrideApplicationContext : editorPlatformContexts.ApplicationContext.getInstance();
411
111
  }
412
- });
413
- var index$4 = applicationShape.build();
112
+ async getEnvironmentContext() {
113
+ return (await this.getApplicationContext()).getEnvironmentContext();
114
+ }
115
+ async getPlatformPrivateAPI() {
116
+ return (await this.getApplicationContext()).getPrivateAPI();
117
+ }
118
+ async getContextBindings() {
119
+ return (await this.getApplicationContext()).getBindings();
120
+ }
121
+ withApplicationContext(applicationContext) {
122
+ return new this.constructor(applicationContext);
123
+ }
124
+ }
414
125
 
415
- const componentsShape = new PlatformSDKShape("components", {
416
- getSelectedComponents({ applicationContext }) {
417
- return async () => {
418
- const privateAPI = applicationContext.getPrivateAPI();
419
- const refs = await privateAPI.components.getSelectedComponents();
420
- return Promise.all(
421
- refs.map((ref) => privateAPI.components.getComponent(ref))
422
- );
423
- };
126
+ class ApplicationSDKShape extends BaseSDKShape {
127
+ async getPrivateAPI() {
128
+ return (await this.getApplicationContext()).getPrivateApplicationAPI();
129
+ }
130
+ async getPublicAPI(appDefinitionId) {
131
+ const privateAPI = await this.getPlatformPrivateAPI();
132
+ return privateAPI.applicationManager.getPublicApplicationAPI(
133
+ appDefinitionId
134
+ );
424
135
  }
425
- });
426
- var components = componentsShape.build();
136
+ async getAppInstance() {
137
+ const privateAPI = await this.getPlatformPrivateAPI();
138
+ const bindings = await this.getContextBindings();
139
+ return privateAPI.info.getAppInstance(bindings.appDefinitionId);
140
+ }
141
+ }
142
+ var index$5 = new PlatformSDKShape("application", ApplicationSDKShape).build();
427
143
 
428
- const eventsShape = new PlatformSDKShape("events", {
429
- addEventListener({ applicationContext }) {
430
- return async (name, cb) => {
431
- return applicationContext.getEvents().addEventListener(name, cb);
432
- };
144
+ class ComponentsSDKShape extends BaseSDKShape {
145
+ async getSelectedComponents() {
146
+ const privateAPI = await this.getPlatformPrivateAPI();
147
+ const refs = await privateAPI.components.getSelectedComponents();
148
+ return Promise.all(
149
+ refs.map((ref) => privateAPI.components.getComponent(ref))
150
+ );
433
151
  }
434
- });
435
- var index$3 = eventsShape.build();
152
+ }
153
+ var components = new PlatformSDKShape("components", ComponentsSDKShape).build();
436
154
 
437
- const infoShape = new PlatformSDKShape("info", {
438
- getViewMode({ applicationContext }) {
439
- return async () => {
440
- const privateAPI = applicationContext.getPrivateAPI();
441
- return privateAPI.info.getViewMode();
442
- };
443
- },
444
- getLanguageCode({ applicationContext }) {
445
- return async () => {
446
- const privateAPI = applicationContext.getPrivateAPI();
447
- return privateAPI.info.getLanguageCode();
448
- };
155
+ class EventsSDKShape extends BaseSDKShape {
156
+ async addEventListener(name, cb) {
157
+ return (await this.getApplicationContext()).getEvents().addEventListener(name, cb);
158
+ }
159
+ }
160
+ var index$4 = new PlatformSDKShape("events", EventsSDKShape).build();
161
+
162
+ class InfoSDKShape extends BaseSDKShape {
163
+ async getViewMode() {
164
+ const privateAPI = await this.getPlatformPrivateAPI();
165
+ return privateAPI.info.getViewMode();
166
+ }
167
+ async getLanguageCode() {
168
+ const privateAPI = await this.getPlatformPrivateAPI();
169
+ return privateAPI.info.getLanguageCode();
449
170
  }
450
- });
451
- var index$2 = infoShape.build();
171
+ }
172
+ var index$3 = new PlatformSDKShape("info", InfoSDKShape).build();
452
173
 
453
174
  var WidgetShapeErrorCode = /* @__PURE__ */ ((WidgetShapeErrorCode2) => {
454
175
  WidgetShapeErrorCode2["UndefinedCompRef"] = "UndefinedCompRef";
@@ -461,31 +182,28 @@ class WidgetShapeError extends publicEditorPlatformErrors.BaseError {
461
182
  }
462
183
  const createWidgetShapeError = publicEditorPlatformErrors.createErrorBuilder(WidgetShapeError);
463
184
 
464
- const getSelectedComponentRef = async () => {
465
- const selected = await components.getSelectedComponents();
466
- const compRef = selected[0]?.compRef;
467
- if (!compRef) {
468
- throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);
469
- }
470
- return compRef;
471
- };
472
- const widgetShape = new PlatformSDKShape("widget", {
473
- getProp({ applicationContext }) {
474
- return async (propName) => {
475
- const privateAPI = applicationContext.getPrivateAPI();
476
- const compRef = await getSelectedComponentRef();
477
- return privateAPI.customElement.getAttribute(compRef, propName);
478
- };
479
- },
480
- setProp({ applicationContext }) {
481
- return async (propName, value) => {
482
- const privateAPI = applicationContext.getPrivateAPI();
483
- const compRef = await getSelectedComponentRef();
484
- await privateAPI.customElement.setAttribute(compRef, propName, value);
485
- };
185
+ class WidgetSDKShape extends BaseSDKShape {
186
+ async getProp(propName) {
187
+ const privateAPI = await this.getPlatformPrivateAPI();
188
+ const compRef = await this.#getSelectedComponentRef();
189
+ return privateAPI.customElement.getAttribute(compRef, propName);
190
+ }
191
+ async setProp(propName, value) {
192
+ const privateAPI = await this.getPlatformPrivateAPI();
193
+ const compRef = await this.#getSelectedComponentRef();
194
+ await privateAPI.customElement.setAttribute(compRef, propName, value);
195
+ }
196
+ async #getSelectedComponentRef() {
197
+ const selected = await components.getSelectedComponents();
198
+ const compRef = selected[0]?.compRef;
199
+ if (!compRef) {
200
+ throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);
201
+ }
202
+ return compRef;
486
203
  }
487
- });
488
- var index$1 = widgetShape.build();
204
+ }
205
+ const widgetShape = new PlatformSDKShape("widget", WidgetSDKShape);
206
+ var index$2 = widgetShape.build();
489
207
 
490
208
  const UNDERLINE_DEFINITION = "underline";
491
209
  function extractFontVar(fontString) {
@@ -590,145 +308,125 @@ const fonts = {
590
308
  }
591
309
  }
592
310
  };
593
- const inputsShape = new PlatformSDKShape("inputs", {
594
- selectColor({ applicationContext }) {
595
- return async (value, options) => {
596
- const privateAPI = applicationContext.getPrivateAPI();
597
- let colorValue = parseColorString(value);
598
- let colorResult = colorValueToCSS(colorValue);
599
- await privateAPI.inputs.openColorPicker(
600
- {
601
- color: colorValue?.cssVariableName || colorValue?.theme || colorValue?.color
602
- },
603
- ({
311
+ class InputsSDKShape extends BaseSDKShape {
312
+ async selectColor(value, options) {
313
+ const privateAPI = await this.getPlatformPrivateAPI();
314
+ let colorValue = parseColorString(value);
315
+ let colorResult = colorValueToCSS(colorValue);
316
+ await privateAPI.inputs.openColorPicker(
317
+ {
318
+ color: colorValue?.cssVariableName || colorValue?.theme || colorValue?.color
319
+ },
320
+ ({
321
+ color,
322
+ theme,
323
+ cssVariableTheme
324
+ }) => {
325
+ colorValue = {
604
326
  color,
605
327
  theme,
606
- cssVariableTheme
607
- }) => {
608
- colorValue = {
609
- color,
610
- theme,
611
- cssVariableName: cssVariableTheme
612
- };
613
- colorResult = colorValueToCSS(colorValue);
614
- options?.onChange?.(colorResult);
615
- }
616
- );
617
- return colorResult;
618
- };
619
- },
620
- selectFont({ applicationContext }) {
621
- return async (value, options) => {
622
- const privateAPI = applicationContext.getPrivateAPI();
623
- const fontValue = parseFontString(value);
624
- let _value = value;
625
- await privateAPI.inputs.openFontPickerV2(
626
- {
627
- ...options,
628
- panelSectionsDefinition: {
629
- htmlTag: "hidden"
630
- },
631
- componentStyle: fonts.transformFontInternalValue(fontValue)
328
+ cssVariableName: cssVariableTheme
329
+ };
330
+ colorResult = colorValueToCSS(colorValue);
331
+ options?.onChange?.(colorResult);
332
+ }
333
+ );
334
+ return colorResult;
335
+ }
336
+ async selectFont(value, options) {
337
+ const privateAPI = await this.getPlatformPrivateAPI();
338
+ const fontValue = parseFontString(value);
339
+ let _value = value;
340
+ await privateAPI.inputs.openFontPickerV2(
341
+ {
342
+ ...options,
343
+ panelSectionsDefinition: {
344
+ htmlTag: "hidden"
632
345
  },
633
- (font, accessibility) => {
634
- _value = {
635
- font: fontValueToCSS(font),
636
- textDecoration: font.underline ? UNDERLINE_DEFINITION : void 0
637
- };
638
- options?.onChange?.(_value);
639
- }
640
- );
641
- return _value;
642
- };
346
+ componentStyle: fonts.transformFontInternalValue(fontValue)
347
+ },
348
+ (font, accessibility) => {
349
+ _value = {
350
+ font: fontValueToCSS(font),
351
+ textDecoration: font.underline ? UNDERLINE_DEFINITION : void 0
352
+ };
353
+ options?.onChange?.(_value);
354
+ }
355
+ );
356
+ return _value;
643
357
  }
644
- });
645
- var index = inputsShape.build();
358
+ }
359
+ var index$1 = new PlatformSDKShape("inputs", InputsSDKShape).build();
646
360
 
647
- const externalPanels = new PlatformSDKShape("externalPanels", {
648
- getData({ applicationContext }) {
649
- return async () => {
650
- const privateAPI = applicationContext.getPrivateAPI();
651
- return privateAPI.externalPanels.getData();
652
- };
653
- },
654
- setData({ applicationContext }) {
655
- return async (newData) => {
656
- const privateAPI = applicationContext.getPrivateAPI();
657
- return privateAPI.externalPanels.setData(newData);
658
- };
659
- },
660
- getStyle({ applicationContext }) {
661
- return async () => {
662
- const privateAPI = applicationContext.getPrivateAPI();
663
- return privateAPI.externalPanels.getStyle();
664
- };
665
- },
666
- setStyle({ applicationContext }) {
667
- return async (newStyle) => {
668
- const privateAPI = applicationContext.getPrivateAPI();
669
- return privateAPI.externalPanels.setStyle(newStyle);
670
- };
671
- },
672
- getTheme({ applicationContext }) {
673
- return async () => {
674
- const privateAPI = applicationContext.getPrivateAPI();
675
- return privateAPI.externalPanels.getTheme();
676
- };
677
- },
678
- selectMedia({ applicationContext }) {
361
+ class ExternalPanelsSDKShape extends BaseSDKShape {
362
+ async getData() {
363
+ const privateAPI = await this.getPlatformPrivateAPI();
364
+ return privateAPI.externalPanels.getData();
365
+ }
366
+ async setData(newData) {
367
+ const privateAPI = await this.getPlatformPrivateAPI();
368
+ return privateAPI.externalPanels.setData(newData);
369
+ }
370
+ async getStyle() {
371
+ const privateAPI = await this.getPlatformPrivateAPI();
372
+ return privateAPI.externalPanels.getStyle();
373
+ }
374
+ async setStyle(newStyle) {
375
+ const privateAPI = await this.getPlatformPrivateAPI();
376
+ return privateAPI.externalPanels.setStyle(newStyle);
377
+ }
378
+ async getTheme() {
379
+ const privateAPI = await this.getPlatformPrivateAPI();
380
+ return privateAPI.externalPanels.getTheme();
381
+ }
382
+ async selectMedia() {
383
+ const privateAPI = await this.getPlatformPrivateAPI();
384
+ return privateAPI.externalPanels.selectMedia();
385
+ }
386
+ async selectLink(...options) {
387
+ const privateAPI = await this.getPlatformPrivateAPI();
388
+ return privateAPI.externalPanels.selectLink(...options);
389
+ }
390
+ async selectColor(...options) {
679
391
  return async () => {
680
- const privateAPI = applicationContext.getPrivateAPI();
681
- return privateAPI.externalPanels.selectMedia();
682
- };
683
- },
684
- selectLink({ applicationContext }) {
685
- return async (...options) => {
686
- const privateAPI = applicationContext.getPrivateAPI();
687
- return privateAPI.externalPanels.selectLink(...options);
688
- };
689
- },
690
- selectColor({ applicationContext }) {
691
- return async (...options) => {
692
- const privateAPI = applicationContext.getPrivateAPI();
392
+ const privateAPI = await this.getPlatformPrivateAPI();
693
393
  return privateAPI.externalPanels.selectColor(...options);
694
394
  };
695
- },
696
- translate({ applicationContext }) {
697
- return async (key, values) => {
698
- const privateAPI = applicationContext.getPrivateAPI();
699
- return privateAPI.externalPanels.translate(key, values);
700
- };
701
395
  }
702
- });
703
- var externalPanels$1 = externalPanels.build();
396
+ async translate(key, values) {
397
+ const privateAPI = await this.getPlatformPrivateAPI();
398
+ return privateAPI.externalPanels.translate(key, values);
399
+ }
400
+ }
401
+ var index = new PlatformSDKShape(
402
+ "externalPanels",
403
+ ExternalPanelsSDKShape
404
+ ).build();
704
405
 
705
- const editorPlatformFrameHost = () => {
406
+ const frame = () => {
706
407
  const queryParams = new URLSearchParams(window.location.search);
707
408
  return {
708
409
  environment: {},
410
+ applicationContext: editorPlatformContexts.ApplicationContext.getInstance(),
709
411
  channel: {
710
412
  observeState: async () => {
711
413
  return { disconnect() {
712
414
  } };
713
415
  }
714
416
  },
715
- environmentContext: EnvironmentContext.getInstance(),
716
- applicationContext: ApplicationContext.getInstance(),
717
417
  essentials: queryParams.has("essentials") ? JSON.parse(queryParams.get("essentials")) : {}
718
418
  };
719
419
  };
720
-
721
- const editorPlatformWorkerHost = () => {
420
+ const worker = () => {
722
421
  return {
723
422
  environment: {},
423
+ applicationContext: editorPlatformContexts.ApplicationContext.getInstance(),
724
424
  channel: {
725
425
  observeState: async () => {
726
426
  return { disconnect() {
727
427
  } };
728
428
  }
729
- },
730
- environmentContext: EnvironmentContext.getInstance(),
731
- applicationContext: ApplicationContext.getInstance()
429
+ }
732
430
  };
733
431
  };
734
432
 
@@ -736,19 +434,19 @@ const editor = {
736
434
  host: () => {
737
435
  const isWorker = typeof importScripts === "function";
738
436
  if (isWorker) {
739
- return editorPlatformWorkerHost();
437
+ return worker();
740
438
  }
741
- return editorPlatformFrameHost();
439
+ return frame();
742
440
  },
743
441
  auth
744
442
  };
745
443
 
746
- exports.application = index$4;
444
+ exports.application = index$5;
747
445
  exports.components = components;
748
446
  exports.editor = editor;
749
- exports.events = index$3;
750
- exports.externalPanels = externalPanels$1;
751
- exports.info = index$2;
752
- exports.inputs = index;
753
- exports.widget = index$1;
447
+ exports.events = index$4;
448
+ exports.externalPanels = index;
449
+ exports.info = index$3;
450
+ exports.inputs = index$1;
451
+ exports.widget = index$2;
754
452
  //# sourceMappingURL=index.js.map