@wix/editor-application 1.338.0 → 1.340.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.
Files changed (38) hide show
  1. package/dist/cjs/environment-api/index.js +154 -65
  2. package/dist/cjs/environment-api/index.js.map +1 -1
  3. package/dist/cjs/index.js +109 -20
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/platform-frame/index.js +112 -45
  6. package/dist/cjs/platform-frame/index.js.map +1 -1
  7. package/dist/cjs/platform-frame-api/index.js +112 -45
  8. package/dist/cjs/platform-frame-api/index.js.map +1 -1
  9. package/dist/cjs/platform-worker/index.js +143 -65
  10. package/dist/cjs/platform-worker/index.js.map +1 -1
  11. package/dist/cjs/platform-worker-api/index.js +132 -54
  12. package/dist/cjs/platform-worker-api/index.js.map +1 -1
  13. package/dist/esm/environment-api/index.js +155 -66
  14. package/dist/esm/environment-api/index.js.map +1 -1
  15. package/dist/esm/index.js +110 -21
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/platform-frame/index.js +113 -46
  18. package/dist/esm/platform-frame/index.js.map +1 -1
  19. package/dist/esm/platform-frame-api/index.js +113 -46
  20. package/dist/esm/platform-frame-api/index.js.map +1 -1
  21. package/dist/esm/platform-worker/index.js +144 -66
  22. package/dist/esm/platform-worker/index.js.map +1 -1
  23. package/dist/esm/platform-worker-api/index.js +132 -54
  24. package/dist/esm/platform-worker-api/index.js.map +1 -1
  25. package/dist/statics/environment-api/index.js +157 -69
  26. package/dist/statics/environment-api/index.js.map +1 -1
  27. package/dist/statics/index.js +112 -24
  28. package/dist/statics/index.js.map +1 -1
  29. package/dist/statics/platform-frame/index.js +115 -49
  30. package/dist/statics/platform-frame/index.js.map +1 -1
  31. package/dist/statics/platform-frame-api/index.js +115 -49
  32. package/dist/statics/platform-frame-api/index.js.map +1 -1
  33. package/dist/statics/platform-worker/index.js +146 -69
  34. package/dist/statics/platform-worker/index.js.map +1 -1
  35. package/dist/statics/platform-worker-api/index.js +134 -57
  36. package/dist/statics/platform-worker-api/index.js.map +1 -1
  37. package/dist/types/index.d.ts +5 -4
  38. package/package.json +4 -3
@@ -1,11 +1,58 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@wix/editor-platform-transport'), require('@wix/public-editor-platform-events'), require('@wix/public-editor-platform-errors'), require('@wix/public-editor-platform-interfaces')) :
3
- typeof define === 'function' && define.amd ? define(['@wix/editor-platform-transport', '@wix/public-editor-platform-events', '@wix/public-editor-platform-errors', '@wix/public-editor-platform-interfaces'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.editorPlatformTransport, global.publicEditorPlatformEvents, global.publicEditorPlatformErrors));
5
- })(this, (function (editorPlatformTransport, publicEditorPlatformEvents, publicEditorPlatformErrors) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@wix/editor-platform-transport'), require('@wix/public-editor-platform-events'), require('@wix/sdk'), require('@wix/public-editor-platform-errors'), require('@wix/public-editor-platform-interfaces')) :
3
+ typeof define === 'function' && define.amd ? define(['@wix/editor-platform-transport', '@wix/public-editor-platform-events', '@wix/sdk', '@wix/public-editor-platform-errors', '@wix/public-editor-platform-interfaces'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.editorPlatformTransport, global.publicEditorPlatformEvents, global.sdk, global.publicEditorPlatformErrors));
5
+ })(this, (function (editorPlatformTransport, publicEditorPlatformEvents, sdk, publicEditorPlatformErrors) { 'use strict';
6
+
7
+ class WorkerEventsBridge {
8
+ constructor(platformAppEvents) {
9
+ this.platformAppEvents = platformAppEvents;
10
+ }
11
+ /**
12
+ * Notify by event from Worker Manager (platform infrastructure)
13
+ */
14
+ notify(event) {
15
+ switch (event.type) {
16
+ case publicEditorPlatformEvents.PlatformLifecycleEvent.EditorReady:
17
+ this.platformAppEvents.notify({
18
+ ...event,
19
+ // @ts-expect-error TODO: fix me
20
+ type: publicEditorPlatformEvents.PlatformAppEvent.EditorReady
21
+ });
22
+ break;
23
+ case publicEditorPlatformEvents.PlatformPrivateEvent.HostEvent:
24
+ this.platformAppEvents.notify({
25
+ ...event,
26
+ type: publicEditorPlatformEvents.PlatformAppEvent.HostEvent
27
+ });
28
+ break;
29
+ }
30
+ }
31
+ /**
32
+ * Subscribe to Worker (Application) event
33
+ */
34
+ subscribe(cb) {
35
+ this.platformAppEvents.subscribe((event) => {
36
+ cb(event);
37
+ });
38
+ }
39
+ }
40
+
41
+ var PlatformConsumerEnvironmentAPIType = /* @__PURE__ */ ((PlatformConsumerEnvironmentAPIType2) => {
42
+ PlatformConsumerEnvironmentAPIType2["Frame"] = "PLATFORM_FRAME_API";
43
+ PlatformConsumerEnvironmentAPIType2["Worker"] = "PLATFORM_WORKER_API";
44
+ return PlatformConsumerEnvironmentAPIType2;
45
+ })(PlatformConsumerEnvironmentAPIType || {});
46
+ class AbstractEnvironmentAPI {
47
+ constructor(env) {
48
+ this.env = env;
49
+ this.create();
50
+ }
51
+ }
6
52
 
7
53
  var EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {
8
54
  EditorPlatformApplicationContextErrorCode2["IncorrectEnvironment"] = "IncorrectEnvironment";
55
+ EditorPlatformApplicationContextErrorCode2["ClientAuthError"] = "ClientAuthError";
9
56
  return EditorPlatformApplicationContextErrorCode2;
10
57
  })(EditorPlatformApplicationContextErrorCode || {});
11
58
  class EditorPlatformApplicationContextError extends publicEditorPlatformErrors.BaseError {
@@ -168,6 +215,7 @@
168
215
  var PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {
169
216
  PlatformEnvironment2["Worker"] = "Worker";
170
217
  PlatformEnvironment2["Frame"] = "Frame";
218
+ PlatformEnvironment2["ComponentPanel"] = "ComponentPanel";
171
219
  return PlatformEnvironment2;
172
220
  })(PlatformEnvironment || {});
173
221
  class EnvironmentContext {
@@ -272,52 +320,59 @@
272
320
  return this.environment.getApplicationAPIs()[appDefinitionId];
273
321
  }
274
322
  }
275
-
276
- class WorkerEventsBridge {
277
- constructor(platformAppEvents) {
278
- this.platformAppEvents = platformAppEvents;
279
- }
280
- /**
281
- * Notify by event from Worker Manager (platform infrastructure)
282
- */
283
- notify(event) {
284
- switch (event.type) {
285
- case publicEditorPlatformEvents.PlatformLifecycleEvent.EditorReady:
286
- this.platformAppEvents.notify({
287
- ...event,
288
- // @ts-expect-error TODO: fix me
289
- type: publicEditorPlatformEvents.PlatformAppEvent.EditorReady
290
- });
291
- break;
292
- case publicEditorPlatformEvents.PlatformPrivateEvent.HostEvent:
293
- this.platformAppEvents.notify({
294
- ...event,
295
- type: publicEditorPlatformEvents.PlatformAppEvent.HostEvent
296
- });
297
- break;
323
+ const createSDKHost = (props) => {
324
+ const environmentContext = new EnvironmentContext({
325
+ environment: props.environment,
326
+ privateApi: props.privateAPI,
327
+ events: props.events ?? new publicEditorPlatformEvents.PlatformAppEventEmitter(),
328
+ applicationAPIs: props.applicationPrivateAPI ? {
329
+ [props.appDefinitionId]: props.applicationPrivateAPI
330
+ } : {}
331
+ });
332
+ const applicationContext = new ApplicationContext(
333
+ {
334
+ appDefinitionId: props.appDefinitionId,
335
+ appDefinitionName: ""
336
+ },
337
+ environmentContext
338
+ );
339
+ return {
340
+ environment: {},
341
+ channel: {
342
+ observeState: async () => {
343
+ return {
344
+ disconnect() {
345
+ }
346
+ };
347
+ }
348
+ },
349
+ environmentContext,
350
+ applicationContext
351
+ };
352
+ };
353
+ const auth = (appDefinitionId, privateAPI) => {
354
+ return {
355
+ getAuthHeaders: async () => {
356
+ if (!appDefinitionId) {
357
+ throw createEditorPlatformApplicationContextError(
358
+ EditorPlatformApplicationContextErrorCode.ClientAuthError
359
+ );
360
+ }
361
+ const authInstance = await privateAPI.info.getAppInstance(appDefinitionId);
362
+ if (authInstance === void 0) {
363
+ throw createEditorPlatformApplicationContextError(
364
+ EditorPlatformApplicationContextErrorCode.ClientAuthError,
365
+ "empty auth instance"
366
+ ).withAppDefinitionId(appDefinitionId);
367
+ }
368
+ return {
369
+ headers: {
370
+ Authorization: authInstance
371
+ }
372
+ };
298
373
  }
299
- }
300
- /**
301
- * Subscribe to Worker (Application) event
302
- */
303
- subscribe(cb) {
304
- this.platformAppEvents.subscribe((event) => {
305
- cb(event);
306
- });
307
- }
308
- }
309
-
310
- var PlatformConsumerEnvironmentAPIType = /* @__PURE__ */ ((PlatformConsumerEnvironmentAPIType2) => {
311
- PlatformConsumerEnvironmentAPIType2["Frame"] = "PLATFORM_FRAME_API";
312
- PlatformConsumerEnvironmentAPIType2["Worker"] = "PLATFORM_WORKER_API";
313
- return PlatformConsumerEnvironmentAPIType2;
314
- })(PlatformConsumerEnvironmentAPIType || {});
315
- class AbstractEnvironmentAPI {
316
- constructor(env) {
317
- this.env = env;
318
- this.create();
319
- }
320
- }
374
+ };
375
+ };
321
376
 
322
377
  const DESIGN_SYSTEM_STYLES_MAP = {
323
378
  classic: "https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css",
@@ -363,6 +418,17 @@
363
418
  appDefinitionId,
364
419
  appDefinitionName: ""
365
420
  });
421
+ const client = sdk.createClient({
422
+ auth: auth(appDefinitionId, privateAPI),
423
+ host: createSDKHost({
424
+ appDefinitionId,
425
+ privateAPI: this.#privateAPI,
426
+ environment: PlatformEnvironment.Frame,
427
+ events: this.#events,
428
+ applicationPrivateAPI: this.#applicationPrivateAPI
429
+ })
430
+ });
431
+ client.enableContext("global");
366
432
  }
367
433
  notify(event) {
368
434
  this.#eventsBridge.notify(event);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../editor-platform-application-context/dist/esm/index.js","../../../src/Events/WorkerEventsBridge.ts","../../../src/PlatformEnvironmentAPI/AbstractEnvironmentAPI.ts","../../../src/PlatformEnvironmentAPI/PlatformFrameAPI/PlatformFrameAPI.ts","../../../src/errors.ts","../../../src/platform-frame.ts"],"sourcesContent":["import { createErrorBuilder, BaseError } from '@wix/public-editor-platform-errors';\nimport { PlatformAppEvent } from '@wix/public-editor-platform-events';\n\nvar EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {\n EditorPlatformApplicationContextErrorCode2[\"IncorrectEnvironment\"] = \"IncorrectEnvironment\";\n return EditorPlatformApplicationContextErrorCode2;\n})(EditorPlatformApplicationContextErrorCode || {});\nclass EditorPlatformApplicationContextError extends BaseError {\n state = {};\n constructor(message, code) {\n super(message, code, \"Editor Platform Application Context Error\");\n }\n withUrl(url) {\n this.state = { ...this.state, url };\n return this;\n }\n withAppDefinitionId(appDefinitionId) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n}\nconst createEditorPlatformApplicationContextError = createErrorBuilder(EditorPlatformApplicationContextError);\n\nasync function transformEventPayload(eventPayload, privateAPI) {\n if (!eventPayload?.type) {\n return eventPayload;\n }\n switch (eventPayload.type) {\n case \"componentSelectionChanged\":\n const componentRefs = eventPayload.componentRefs || [];\n const components = await Promise.all(\n componentRefs.map((ref) => {\n return privateAPI.components.getComponent(ref);\n })\n );\n return {\n type: eventPayload.type,\n components\n };\n default:\n return eventPayload;\n }\n}\n\nclass ApplicationBoundEvents {\n constructor(appDefinitionId, events, privateAPI) {\n this.appDefinitionId = appDefinitionId;\n this.privateAPI = privateAPI;\n this.events = events;\n this.subscribe = events.subscribe.bind(events);\n this.commit = events.commit.bind(events);\n this.startTransaction = events.startTransaction.bind(events);\n this.silent = events.silent.bind(events);\n }\n events;\n subscribe;\n commit;\n startTransaction;\n silent;\n notify(event) {\n this.events.notify({\n type: event.type,\n payload: event.payload,\n meta: {\n appDefinitionId: this.appDefinitionId\n }\n });\n }\n notifyCustomEvent(type, payload) {\n this.notify({\n type: PlatformAppEvent.CustomEvent,\n payload: {\n ...payload,\n type\n }\n });\n }\n /**\n * TODO: we should use same interface for all events\n * (subscribe vs addEventListener)\n */\n addEventListener(eventType, fn) {\n return this.events.subscribe(async (event) => {\n const isAppMatch = event.meta?.appDefinitionId === this.appDefinitionId || event.meta?.appDefinitionId === null;\n const transformPayload = () => transformEventPayload(event.payload, this.privateAPI);\n if (eventType === \"*\") {\n fn(await transformPayload());\n } else if (event.type === PlatformAppEvent.CustomEvent) {\n if (eventType === event.payload?.type && !isAppMatch) {\n fn(await transformPayload());\n }\n } else if (event.type === PlatformAppEvent.HostEvent) {\n if (eventType === event.payload?.type && isAppMatch) {\n fn(await transformPayload());\n }\n }\n });\n }\n}\n\nconst WAIT_INJECTED_TIMEOUT = 200;\nconst WAIT_INJECTED_RETRY_COUNT = 50;\nclass ContextInjectionStatus {\n _resolveContextInjected = () => {\n };\n _isInjected = false;\n key;\n constructor(uuid) {\n this.key = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;\n if (!globalThis[this.key]) {\n globalThis[this.key] = new Promise((resolve) => {\n this._resolveContextInjected = () => {\n this._isInjected = true;\n resolve();\n };\n });\n }\n }\n isInjected() {\n return !!this._isInjected;\n }\n resolveInjected() {\n this._resolveContextInjected?.();\n }\n waitInjected() {\n return new Promise((resolve, reject) => {\n let injected = false;\n let timeoutId;\n let retryCount = 0;\n const timeout = () => {\n if (injected) {\n return;\n }\n timeoutId = setTimeout(() => {\n retryCount++;\n if (retryCount < WAIT_INJECTED_RETRY_COUNT) {\n if (retryCount % 10 === 0) {\n console.log(\n createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"contexts are not resolved, still re-trying\"\n ).withMessage(`try number ${retryCount}`).message\n );\n }\n timeout();\n return;\n }\n if (!injected) {\n const error = createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"contexts are not resolved, threw by timeout\"\n );\n reject(error);\n }\n }, WAIT_INJECTED_TIMEOUT);\n };\n timeout();\n const _waitContextInjectedPromise = globalThis[this.key];\n _waitContextInjectedPromise.then(() => {\n injected = true;\n clearTimeout(timeoutId);\n resolve();\n });\n });\n }\n}\n\nconst ENVIRONMENT_CONTEXT_KEY = \"__ENVIRONMENT_CONTEXT_KEY\";\nvar PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {\n PlatformEnvironment2[\"Worker\"] = \"Worker\";\n PlatformEnvironment2[\"Frame\"] = \"Frame\";\n return PlatformEnvironment2;\n})(PlatformEnvironment || {});\nclass EnvironmentContext {\n constructor(environmentContext) {\n this.environmentContext = environmentContext;\n }\n static status = new ContextInjectionStatus(\"environment\");\n static async inject(context) {\n if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Environment context already exists and should not be overridden\"\n );\n }\n globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);\n this.status.resolveInjected();\n }\n static async getInstance() {\n await this.status.waitInjected();\n return globalThis[ENVIRONMENT_CONTEXT_KEY];\n }\n getPrivateAPI() {\n return this.environmentContext.privateApi;\n }\n getEvents() {\n return this.environmentContext.events;\n }\n getApplicationAPIs() {\n return this.environmentContext.applicationAPIs ?? {};\n }\n getEnvironment() {\n return this.environmentContext.environment;\n }\n}\n\nconst APPLICATION_CONTEXT_KEY = \"__APPLICATION_CONTEXT_KEY\";\nclass ApplicationContext {\n constructor(applicationContext, environment) {\n this.applicationContext = applicationContext;\n this.environment = environment;\n this.events = new ApplicationBoundEvents(\n this.applicationContext.appDefinitionId,\n this.environment.getEvents(),\n this.environment.getPrivateAPI()\n );\n }\n static status = new ContextInjectionStatus(\"application\");\n /**\n * TODO: use generics for context type\n * - application\n * - editor\n */\n static async inject(context) {\n const environment = await EnvironmentContext.getInstance();\n if (environment.getEnvironment() !== PlatformEnvironment.Frame) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Application context can be injected only in frame environment\"\n );\n }\n if (globalThis[APPLICATION_CONTEXT_KEY]) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Application context already exists and should not be overridden\"\n );\n }\n globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(\n context,\n await EnvironmentContext.getInstance()\n );\n this.status.resolveInjected();\n }\n static async getInstance() {\n const environment = await EnvironmentContext.getInstance();\n if (environment.getEnvironment() === PlatformEnvironment.Frame) {\n await this.status.waitInjected();\n return globalThis[APPLICATION_CONTEXT_KEY];\n } else {\n return __APPLICATION_CONTEXT_KEY;\n }\n }\n events;\n getAppDefinitionId() {\n return this.applicationContext.appDefinitionId;\n }\n getBindings() {\n return this.applicationContext;\n }\n getEvents() {\n return this.events;\n }\n getPrivateAPI() {\n return this.environment.getPrivateAPI();\n }\n getPrivateApplicationAPI() {\n const appDefinitionId = this.getAppDefinitionId();\n if (!appDefinitionId) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"appDefinitionId is not available\"\n );\n }\n return this.environment.getApplicationAPIs()[appDefinitionId];\n }\n}\n\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\n//# sourceMappingURL=index.js.map\n","import {\n IPlatformPrivateEvent,\n PlatformLifecycleEvent,\n PlatformPrivateEvent,\n // --\n IPlatformAppEvent,\n PlatformAppEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\n\n/**\n * The events bridge between platform events (private) and app events\n */\nexport class WorkerEventsBridge {\n constructor(private platformAppEvents: PlatformAppEventEmitter) {}\n\n /**\n * Notify by event from Worker Manager (platform infrastructure)\n */\n public notify(event: IPlatformPrivateEvent) {\n switch (event.type) {\n case PlatformLifecycleEvent.EditorReady:\n this.platformAppEvents.notify({\n ...event,\n // @ts-expect-error TODO: fix me\n type: PlatformAppEvent.EditorReady,\n });\n break;\n case PlatformPrivateEvent.HostEvent:\n this.platformAppEvents.notify({\n ...event,\n type: PlatformAppEvent.HostEvent,\n });\n break;\n }\n }\n\n /**\n * Subscribe to Worker (Application) event\n */\n public subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.platformAppEvents.subscribe((event) => {\n cb(event);\n });\n }\n}\n","export enum PlatformConsumerEnvironmentAPIType {\n Frame = 'PLATFORM_FRAME_API',\n Worker = 'PLATFORM_WORKER_API',\n}\n\n/**\n * rename these entities -> API to Env\n */\nexport abstract class AbstractEnvironmentAPI<\n TEnv extends PlatformConsumerEnvironmentAPIType,\n> {\n /**\n * NOTE: we can't `type` declare getter within current abstract class\n * because then after transferring API between threads this getter becomes promise,\n * which is not expected\n *\n * get type() {\n * return this.env;\n * }\n */\n public abstract type: TEnv;\n\n protected constructor(protected env: TEnv) {\n this.create();\n }\n\n abstract create(): void;\n abstract initEnvironment(props: unknown): void;\n}\n","import { IPrivateAPIFixMe } from '../../types';\n\nimport {\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\nimport {\n EnvironmentContext,\n ApplicationContext,\n PlatformEnvironment,\n} from '@wix/editor-application-context';\n\nimport { WorkerEventsBridge } from '../../Events';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\n\nconst DESIGN_SYSTEM_STYLES_MAP = {\n classic:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css',\n studio:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css',\n};\n\nexport class PlatformFrameAPI extends AbstractEnvironmentAPI<PlatformConsumerEnvironmentAPIType.Frame> {\n public type: PlatformConsumerEnvironmentAPIType.Frame =\n PlatformConsumerEnvironmentAPIType.Frame;\n\n #events = new PlatformAppEventEmitter();\n #eventsBridge = new WorkerEventsBridge(this.#events);\n #privateAPI: IPrivateAPIFixMe;\n #applicationPrivateAPI: any;\n\n constructor() {\n super(PlatformConsumerEnvironmentAPIType.Frame);\n }\n\n create() {\n if (typeof globalThis?.document?.head?.prepend === 'function') {\n const params = new URL(globalThis.location.href).searchParams;\n\n // TODO: check all possible editorType values\n const host =\n params.get('editorType') === 'CLASSIC' ? 'classic' : 'studio';\n\n const url = DESIGN_SYSTEM_STYLES_MAP[host];\n\n const isAlreadyLoaded =\n url &&\n !!document.querySelectorAll(`link[type=\"text/css\"][href=\"${url}\"]`)\n ?.length;\n\n if (url && !isAlreadyLoaded) {\n const link: HTMLLinkElement = document.createElement('link');\n\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('type', 'text/css');\n link.setAttribute('href', url);\n\n globalThis.document.head.prepend(link);\n }\n }\n }\n\n async initEnvironment(props: {\n appDefinitionId: string;\n privateAPI: IPrivateAPIFixMe;\n applicationPrivateAPI: any;\n }) {\n const { applicationPrivateAPI, privateAPI, appDefinitionId } = props;\n\n this.#applicationPrivateAPI = applicationPrivateAPI;\n this.#privateAPI = privateAPI;\n\n await EnvironmentContext.inject({\n environment: PlatformEnvironment.Frame,\n privateApi: privateAPI,\n events: this.#events,\n applicationAPIs: {\n [appDefinitionId]: this.#applicationPrivateAPI,\n },\n });\n\n await ApplicationContext.inject({\n appDefinitionId,\n appDefinitionName: '',\n });\n }\n\n notify(event: IPlatformPrivateEvent) {\n this.#eventsBridge.notify(event);\n }\n\n subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.#eventsBridge.subscribe(cb);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationErrorCode {\n ApplicationRuntimeError = 'ApplicationRuntimeError',\n ApplicationCreationError = 'ApplicationCreationError',\n ApplicationLoadError = 'ApplicationLoadError',\n ApplicationFetchError = 'ApplicationFetchError',\n ApplicationExecuteError = 'ApplicationExecuteError',\n ApplicationWasRemoved = 'ApplicationWasRemoved',\n UndefinedApiMethod = 'UndefinedApiMethod',\n ApplicationIsNotMutable = 'ApplicationIsNotMutable',\n FailedToGetPrivateAPI = 'FailedToGetPrivateAPI',\n}\n\nclass EditorPlatformApplicationError extends BaseError<EditorPlatformApplicationErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformApplicationErrorCode) {\n super(message, code, 'Editor Platform Application Error');\n }\n\n withUrl(url: string) {\n this.state = { ...this.state, url };\n return this;\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n\n withApiMethod(apiMethod: string) {\n this.state = { ...this.state, apiMethod };\n return this;\n }\n\n withApiType(apiType: string) {\n this.state = { ...this.state, apiType };\n return this;\n }\n}\n\nexport const createEditorPlatformApplicationError = createErrorBuilder<\n EditorPlatformApplicationErrorCode,\n EditorPlatformApplicationError\n>(EditorPlatformApplicationError);\n","import { IFrameConsumerChannel } from '@wix/editor-platform-transport';\nimport { PlatformFrameAPI } from './PlatformEnvironmentAPI';\n\nconst channel = new IFrameConsumerChannel();\nchannel.expose(new PlatformFrameAPI());\n"],"names":["BaseError","createErrorBuilder","PlatformAppEvent","PlatformLifecycleEvent","PlatformPrivateEvent","PlatformConsumerEnvironmentAPIType","PlatformAppEventEmitter","IFrameConsumerChannel"],"mappings":";;;;;;EAGA,IAAI,yCAAA,qBAA8D,0CAA+C,KAAA;EAC/G,EAAA,0CAAA,CAA2C,sBAAsB,CAAI,GAAA,sBAAA,CAAA;EACrE,EAAO,OAAA,0CAAA,CAAA;EACT,CAAG,EAAA,yCAAA,IAA6C,EAAE,CAAA,CAAA;EAClD,MAAM,8CAA8CA,oCAAU,CAAA;EAAA,EAC5D,QAAQ,EAAC,CAAA;EAAA,EACT,WAAA,CAAY,SAAS,IAAM,EAAA;EACzB,IAAM,KAAA,CAAA,OAAA,EAAS,MAAM,2CAA2C,CAAA,CAAA;EAAA,GAClE;EAAA,EACA,QAAQ,GAAK,EAAA;EACX,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,GAAI,EAAA,CAAA;EA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AAO,OAAA,IAAA,CAAA;EAAA,GACT;EAAA,EAEA,oBAAoB,eAAyB,EAAA;EAC3C,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,eAAgB,EAAA,CAAA;EAC9C,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EAAA,EAEA,cAAc,SAAmB,EAAA;EAC/B,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,SAAU,EAAA,CAAA;EACxC,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EAAA,EAEA,YAAY,OAAiB,EAAA;EAC3B,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,OAAQ,EAAA,CAAA;EACtC,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EACF,CAAA;AAEoDC,gDAGlD,8BAA8B;;EClDhC,MAAM,OAAA,GAAU,IAAIM,6CAAsB,EAAA,CAAA;EAC1C,OAAQ,CAAA,MAAA,CAAO,IAAI,gBAAA,EAAkB,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/Events/WorkerEventsBridge.ts","../../../src/PlatformEnvironmentAPI/AbstractEnvironmentAPI.ts","../../../../editor-platform-application-context/dist/esm/index.js","../../../src/PlatformEnvironmentAPI/PlatformFrameAPI/PlatformFrameAPI.ts","../../../src/errors.ts","../../../src/platform-frame.ts"],"sourcesContent":["import {\n IPlatformPrivateEvent,\n PlatformLifecycleEvent,\n PlatformPrivateEvent,\n // --\n IPlatformAppEvent,\n PlatformAppEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\n\n/**\n * The events bridge between platform events (private) and app events\n */\nexport class WorkerEventsBridge {\n constructor(private platformAppEvents: PlatformAppEventEmitter) {}\n\n /**\n * Notify by event from Worker Manager (platform infrastructure)\n */\n public notify(event: IPlatformPrivateEvent) {\n switch (event.type) {\n case PlatformLifecycleEvent.EditorReady:\n this.platformAppEvents.notify({\n ...event,\n // @ts-expect-error TODO: fix me\n type: PlatformAppEvent.EditorReady,\n });\n break;\n case PlatformPrivateEvent.HostEvent:\n this.platformAppEvents.notify({\n ...event,\n type: PlatformAppEvent.HostEvent,\n });\n break;\n }\n }\n\n /**\n * Subscribe to Worker (Application) event\n */\n public subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.platformAppEvents.subscribe((event) => {\n cb(event);\n });\n }\n}\n","export enum PlatformConsumerEnvironmentAPIType {\n Frame = 'PLATFORM_FRAME_API',\n Worker = 'PLATFORM_WORKER_API',\n}\n\n/**\n * rename these entities -> API to Env\n */\nexport abstract class AbstractEnvironmentAPI<\n TEnv extends PlatformConsumerEnvironmentAPIType,\n> {\n /**\n * NOTE: we can't `type` declare getter within current abstract class\n * because then after transferring API between threads this getter becomes promise,\n * which is not expected\n *\n * get type() {\n * return this.env;\n * }\n */\n public abstract type: TEnv;\n\n protected constructor(protected env: TEnv) {\n this.create();\n }\n\n abstract create(): void;\n abstract initEnvironment(props: unknown): void;\n}\n","import { createErrorBuilder, BaseError } from '@wix/public-editor-platform-errors';\nimport { PlatformAppEvent, PlatformAppEventEmitter } from '@wix/public-editor-platform-events';\n\nvar EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {\n EditorPlatformApplicationContextErrorCode2[\"IncorrectEnvironment\"] = \"IncorrectEnvironment\";\n EditorPlatformApplicationContextErrorCode2[\"ClientAuthError\"] = \"ClientAuthError\";\n return EditorPlatformApplicationContextErrorCode2;\n})(EditorPlatformApplicationContextErrorCode || {});\nclass EditorPlatformApplicationContextError extends BaseError {\n state = {};\n constructor(message, code) {\n super(message, code, \"Editor Platform Application Context Error\");\n }\n withUrl(url) {\n this.state = { ...this.state, url };\n return this;\n }\n withAppDefinitionId(appDefinitionId) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n}\nconst createEditorPlatformApplicationContextError = createErrorBuilder(EditorPlatformApplicationContextError);\n\nasync function transformEventPayload(eventPayload, privateAPI) {\n if (!eventPayload?.type) {\n return eventPayload;\n }\n switch (eventPayload.type) {\n case \"componentSelectionChanged\":\n const componentRefs = eventPayload.componentRefs || [];\n const components = await Promise.all(\n componentRefs.map((ref) => {\n return privateAPI.components.getComponent(ref);\n })\n );\n return {\n type: eventPayload.type,\n components\n };\n default:\n return eventPayload;\n }\n}\n\nclass ApplicationBoundEvents {\n constructor(appDefinitionId, events, privateAPI) {\n this.appDefinitionId = appDefinitionId;\n this.privateAPI = privateAPI;\n this.events = events;\n this.subscribe = events.subscribe.bind(events);\n this.commit = events.commit.bind(events);\n this.startTransaction = events.startTransaction.bind(events);\n this.silent = events.silent.bind(events);\n }\n events;\n subscribe;\n commit;\n startTransaction;\n silent;\n notify(event) {\n this.events.notify({\n type: event.type,\n payload: event.payload,\n meta: {\n appDefinitionId: this.appDefinitionId\n }\n });\n }\n notifyCustomEvent(type, payload) {\n this.notify({\n type: PlatformAppEvent.CustomEvent,\n payload: {\n ...payload,\n type\n }\n });\n }\n /**\n * TODO: we should use same interface for all events\n * (subscribe vs addEventListener)\n */\n addEventListener(eventType, fn) {\n return this.events.subscribe(async (event) => {\n const isAppMatch = event.meta?.appDefinitionId === this.appDefinitionId || event.meta?.appDefinitionId === null;\n const transformPayload = () => transformEventPayload(event.payload, this.privateAPI);\n if (eventType === \"*\") {\n fn(await transformPayload());\n } else if (event.type === PlatformAppEvent.CustomEvent) {\n if (eventType === event.payload?.type && !isAppMatch) {\n fn(await transformPayload());\n }\n } else if (event.type === PlatformAppEvent.HostEvent) {\n if (eventType === event.payload?.type && isAppMatch) {\n fn(await transformPayload());\n }\n }\n });\n }\n}\n\nconst WAIT_INJECTED_TIMEOUT = 200;\nconst WAIT_INJECTED_RETRY_COUNT = 50;\nclass ContextInjectionStatus {\n _resolveContextInjected = () => {\n };\n _isInjected = false;\n key;\n constructor(uuid) {\n this.key = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;\n if (!globalThis[this.key]) {\n globalThis[this.key] = new Promise((resolve) => {\n this._resolveContextInjected = () => {\n this._isInjected = true;\n resolve();\n };\n });\n }\n }\n isInjected() {\n return !!this._isInjected;\n }\n resolveInjected() {\n this._resolveContextInjected?.();\n }\n waitInjected() {\n return new Promise((resolve, reject) => {\n let injected = false;\n let timeoutId;\n let retryCount = 0;\n const timeout = () => {\n if (injected) {\n return;\n }\n timeoutId = setTimeout(() => {\n retryCount++;\n if (retryCount < WAIT_INJECTED_RETRY_COUNT) {\n if (retryCount % 10 === 0) {\n console.log(\n createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"contexts are not resolved, still re-trying\"\n ).withMessage(`try number ${retryCount}`).message\n );\n }\n timeout();\n return;\n }\n if (!injected) {\n const error = createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"contexts are not resolved, threw by timeout\"\n );\n reject(error);\n }\n }, WAIT_INJECTED_TIMEOUT);\n };\n timeout();\n const _waitContextInjectedPromise = globalThis[this.key];\n _waitContextInjectedPromise.then(() => {\n injected = true;\n clearTimeout(timeoutId);\n resolve();\n });\n });\n }\n}\n\nconst ENVIRONMENT_CONTEXT_KEY = \"__ENVIRONMENT_CONTEXT_KEY\";\nvar PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {\n PlatformEnvironment2[\"Worker\"] = \"Worker\";\n PlatformEnvironment2[\"Frame\"] = \"Frame\";\n PlatformEnvironment2[\"ComponentPanel\"] = \"ComponentPanel\";\n return PlatformEnvironment2;\n})(PlatformEnvironment || {});\nclass EnvironmentContext {\n constructor(environmentContext) {\n this.environmentContext = environmentContext;\n }\n static status = new ContextInjectionStatus(\"environment\");\n static async inject(context) {\n if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Environment context already exists and should not be overridden\"\n );\n }\n globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);\n this.status.resolveInjected();\n }\n static async getInstance() {\n await this.status.waitInjected();\n return globalThis[ENVIRONMENT_CONTEXT_KEY];\n }\n getPrivateAPI() {\n return this.environmentContext.privateApi;\n }\n getEvents() {\n return this.environmentContext.events;\n }\n getApplicationAPIs() {\n return this.environmentContext.applicationAPIs ?? {};\n }\n getEnvironment() {\n return this.environmentContext.environment;\n }\n}\n\nconst APPLICATION_CONTEXT_KEY = \"__APPLICATION_CONTEXT_KEY\";\nclass ApplicationContext {\n constructor(applicationContext, environment) {\n this.applicationContext = applicationContext;\n this.environment = environment;\n this.events = new ApplicationBoundEvents(\n this.applicationContext.appDefinitionId,\n this.environment.getEvents(),\n this.environment.getPrivateAPI()\n );\n }\n static status = new ContextInjectionStatus(\"application\");\n /**\n * TODO: use generics for context type\n * - application\n * - editor\n */\n static async inject(context) {\n const environment = await EnvironmentContext.getInstance();\n if (environment.getEnvironment() !== PlatformEnvironment.Frame) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Application context can be injected only in frame environment\"\n );\n }\n if (globalThis[APPLICATION_CONTEXT_KEY]) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Application context already exists and should not be overridden\"\n );\n }\n globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(\n context,\n await EnvironmentContext.getInstance()\n );\n this.status.resolveInjected();\n }\n static async getInstance() {\n const environment = await EnvironmentContext.getInstance();\n if (environment.getEnvironment() === PlatformEnvironment.Frame) {\n await this.status.waitInjected();\n return globalThis[APPLICATION_CONTEXT_KEY];\n } else {\n return __APPLICATION_CONTEXT_KEY;\n }\n }\n events;\n getAppDefinitionId() {\n return this.applicationContext.appDefinitionId;\n }\n getBindings() {\n return this.applicationContext;\n }\n getEvents() {\n return this.events;\n }\n getPrivateAPI() {\n return this.environment.getPrivateAPI();\n }\n getPrivateApplicationAPI() {\n const appDefinitionId = this.getAppDefinitionId();\n if (!appDefinitionId) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"appDefinitionId is not available\"\n );\n }\n return this.environment.getApplicationAPIs()[appDefinitionId];\n }\n}\n\nconst createSDKHost = (props) => {\n const environmentContext = new EnvironmentContext({\n environment: props.environment,\n privateApi: props.privateAPI,\n events: props.events ?? new PlatformAppEventEmitter(),\n applicationAPIs: props.applicationPrivateAPI ? {\n [props.appDefinitionId]: props.applicationPrivateAPI\n } : {}\n });\n const applicationContext = new ApplicationContext(\n {\n appDefinitionId: props.appDefinitionId,\n appDefinitionName: \"\"\n },\n environmentContext\n );\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return {\n disconnect() {\n }\n };\n }\n },\n environmentContext,\n applicationContext\n };\n};\n\nconst auth = (appDefinitionId, privateAPI) => {\n return {\n getAuthHeaders: async () => {\n if (!appDefinitionId) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.ClientAuthError\n );\n }\n const authInstance = await privateAPI.info.getAppInstance(appDefinitionId);\n if (authInstance === void 0) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.ClientAuthError,\n \"empty auth instance\"\n ).withAppDefinitionId(appDefinitionId);\n }\n return {\n headers: {\n Authorization: authInstance\n }\n };\n }\n };\n};\n\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment, auth, createSDKHost };\n//# sourceMappingURL=index.js.map\n","import { IPrivateAPIFixMe } from '../../types';\n\nimport {\n IPlatformAppEvent,\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport { createClient } from '@wix/sdk';\n\nimport { WorkerEventsBridge } from '../../Events';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\nimport {\n ApplicationContext,\n createSDKHost,\n auth,\n EnvironmentContext,\n PlatformEnvironment,\n} from '@wix/editor-application-context';\n\nconst DESIGN_SYSTEM_STYLES_MAP = {\n classic:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css',\n studio:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css',\n};\n\nexport class PlatformFrameAPI extends AbstractEnvironmentAPI<PlatformConsumerEnvironmentAPIType.Frame> {\n public type: PlatformConsumerEnvironmentAPIType.Frame =\n PlatformConsumerEnvironmentAPIType.Frame;\n\n #events = new PlatformAppEventEmitter();\n #eventsBridge = new WorkerEventsBridge(this.#events);\n #privateAPI: IPrivateAPIFixMe;\n #applicationPrivateAPI: any;\n\n constructor() {\n super(PlatformConsumerEnvironmentAPIType.Frame);\n }\n\n create() {\n if (typeof globalThis?.document?.head?.prepend === 'function') {\n const params = new URL(globalThis.location.href).searchParams;\n\n // TODO: check all possible editorType values\n const host =\n params.get('editorType') === 'CLASSIC' ? 'classic' : 'studio';\n\n const url = DESIGN_SYSTEM_STYLES_MAP[host];\n\n const isAlreadyLoaded =\n url &&\n !!document.querySelectorAll(`link[type=\"text/css\"][href=\"${url}\"]`)\n ?.length;\n\n if (url && !isAlreadyLoaded) {\n const link: HTMLLinkElement = document.createElement('link');\n\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('type', 'text/css');\n link.setAttribute('href', url);\n\n globalThis.document.head.prepend(link);\n }\n }\n }\n\n async initEnvironment(props: {\n appDefinitionId: string;\n privateAPI: IPrivateAPIFixMe;\n applicationPrivateAPI: any;\n }) {\n const { applicationPrivateAPI, privateAPI, appDefinitionId } = props;\n\n this.#applicationPrivateAPI = applicationPrivateAPI;\n this.#privateAPI = privateAPI;\n\n await EnvironmentContext.inject({\n environment: PlatformEnvironment.Frame,\n privateApi: privateAPI,\n events: this.#events,\n applicationAPIs: {\n [appDefinitionId]: this.#applicationPrivateAPI,\n },\n });\n\n await ApplicationContext.inject({\n appDefinitionId,\n appDefinitionName: '',\n });\n\n /**\n * https://github.com/wix-private/public-sdk?tab=readme-ov-file#providing-a-contextual-wixclient\n * init wix client and its contexts,\n * so sdk shapes will be able to use these client instance our of the box\n */\n const client = createClient({\n auth: auth(appDefinitionId, privateAPI),\n host: createSDKHost({\n appDefinitionId,\n privateAPI: this.#privateAPI,\n environment: PlatformEnvironment.Frame,\n events: this.#events,\n applicationPrivateAPI: this.#applicationPrivateAPI,\n }),\n });\n\n client.enableContext('global');\n }\n\n notify(event: IPlatformPrivateEvent) {\n this.#eventsBridge.notify(event);\n }\n\n subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.#eventsBridge.subscribe(cb);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationErrorCode {\n ApplicationRuntimeError = 'ApplicationRuntimeError',\n ApplicationCreationError = 'ApplicationCreationError',\n ApplicationLoadError = 'ApplicationLoadError',\n ApplicationFetchError = 'ApplicationFetchError',\n ApplicationExecuteError = 'ApplicationExecuteError',\n ApplicationWasRemoved = 'ApplicationWasRemoved',\n UndefinedApiMethod = 'UndefinedApiMethod',\n ApplicationIsNotMutable = 'ApplicationIsNotMutable',\n FailedToGetPrivateAPI = 'FailedToGetPrivateAPI',\n ClientAuthError = 'ClientAuthError',\n}\n\nclass EditorPlatformApplicationError extends BaseError<EditorPlatformApplicationErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformApplicationErrorCode) {\n super(message, code, 'Editor Platform Application Error');\n }\n\n withUrl(url: string) {\n this.state = { ...this.state, url };\n return this;\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n\n withApiMethod(apiMethod: string) {\n this.state = { ...this.state, apiMethod };\n return this;\n }\n\n withApiType(apiType: string) {\n this.state = { ...this.state, apiType };\n return this;\n }\n}\n\nexport const createEditorPlatformApplicationError = createErrorBuilder<\n EditorPlatformApplicationErrorCode,\n EditorPlatformApplicationError\n>(EditorPlatformApplicationError);\n","import { IFrameConsumerChannel } from '@wix/editor-platform-transport';\nimport { PlatformFrameAPI } from './PlatformEnvironmentAPI';\n\nconst channel = new IFrameConsumerChannel();\nchannel.expose(new PlatformFrameAPI());\n"],"names":["PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","PlatformConsumerEnvironmentAPIType","BaseError","createErrorBuilder","PlatformAppEventEmitter","createClient","IFrameConsumerChannel"],"mappings":";;;;;;EAaO,MAAM,kBAAmB,CAAA;EAAA,EAC9B,YAAoB,iBAA4C,EAAA;EAA5C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA,CAAA;EAAA,GAA6C;EAAA;EAAA;EAAA;EAAA,EAK1D,OAAO,KAA8B,EAAA;EAC1C,IAAA,QAAQ,MAAM,IAAM;EAAA,MAClB,KAAKA,iDAAuB,CAAA,WAAA;EAC1B,QAAA,IAAA,CAAK,kBAAkB,MAAO,CAAA;EAAA,UAC5B,GAAG,KAAA;EAAA;EAAA,UAEH,MAAMC,2CAAiB,CAAA,WAAA;EAAA,SACxB,CAAA,CAAA;EACD,QAAA,MAAA;EAAA,MACF,KAAKC,+CAAqB,CAAA,SAAA;EACxB,QAAA,IAAA,CAAK,kBAAkB,MAAO,CAAA;EAAA,UAC5B,GAAG,KAAA;EAAA,UACH,MAAMD,2CAAiB,CAAA,SAAA;EAAA,SACxB,CAAA,CAAA;EACD,QAAA,MAAA;EAAA,KACJ;EAAA,GACF;EAAA;EAAA;EAAA;EAAA,EAKO,UAAU,EAAwC,EAAA;EACvD,IAAK,IAAA,CAAA,iBAAA,CAAkB,SAAU,CAAA,CAAC,KAAU,KAAA;EAC1C,MAAA,EAAA,CAAG,KAAK,CAAA,CAAA;EAAA,KACT,CAAA,CAAA;EAAA,GACH;EACF;;EC7CY,IAAA,kCAAA,qBAAAE,mCAAL,KAAA;EACL,EA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AA;EAAA,GACjC;EACF;;ECrGA,MAAM,uCAAuCH,oCAA8C,CAAA;EAAA,EACzF,QAKK,EAAC,CAAA;EAAA,EAEN,WAAA,CAAY,SAAiB,IAA0C,EAAA;EACrE,IAAM,KAAA,CAAA,OAAA,EAAS,MAAM,mCAAmC,CAAA,CAAA;EAAA,GAC1D;EAAA,EAEA,QAAQ,GAAa,EAAA;EACnB,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,GAAI,EAAA,CAAA;EAClC,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EAAA,EAEA,oBAAoB,eAAyB,EAAA;EAC3C,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,eAAgB,EAAA,CAAA;EAC9C,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EAAA,EAEA,cAAc,SAAmB,EAAA;EAC/B,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,SAAU,EAAA,CAAA;EACxC,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EAAA,EAEA,YAAY,OAAiB,EAAA;EAC3B,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,OAAQ,EAAA,CAAA;EACtC,IAAO,OAAA,IAAA,CAAA;EAAA,GACT;EACF,CAAA;AAEoDC,gDAGlD,8BAA8B;;ECnDhC,MAAM,OAAA,GAAU,IAAIG,6CAAsB,EAAA,CAAA;EAC1C,OAAQ,CAAA,MAAA,CAAO,IAAI,gBAAA,EAAkB,CAAA;;;;;;"}
@@ -1,11 +1,58 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@wix/public-editor-platform-events'), require('@wix/public-editor-platform-errors')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@wix/public-editor-platform-events', '@wix/public-editor-platform-errors'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["platform-frame-api"] = {}, global.publicEditorPlatformEvents, global.publicEditorPlatformErrors));
5
- })(this, (function (exports, publicEditorPlatformEvents, publicEditorPlatformErrors) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@wix/public-editor-platform-events'), require('@wix/sdk'), require('@wix/public-editor-platform-errors')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@wix/public-editor-platform-events', '@wix/sdk', '@wix/public-editor-platform-errors'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["platform-frame-api"] = {}, global.publicEditorPlatformEvents, global.sdk, global.publicEditorPlatformErrors));
5
+ })(this, (function (exports, publicEditorPlatformEvents, sdk, publicEditorPlatformErrors) { 'use strict';
6
+
7
+ class WorkerEventsBridge {
8
+ constructor(platformAppEvents) {
9
+ this.platformAppEvents = platformAppEvents;
10
+ }
11
+ /**
12
+ * Notify by event from Worker Manager (platform infrastructure)
13
+ */
14
+ notify(event) {
15
+ switch (event.type) {
16
+ case publicEditorPlatformEvents.PlatformLifecycleEvent.EditorReady:
17
+ this.platformAppEvents.notify({
18
+ ...event,
19
+ // @ts-expect-error TODO: fix me
20
+ type: publicEditorPlatformEvents.PlatformAppEvent.EditorReady
21
+ });
22
+ break;
23
+ case publicEditorPlatformEvents.PlatformPrivateEvent.HostEvent:
24
+ this.platformAppEvents.notify({
25
+ ...event,
26
+ type: publicEditorPlatformEvents.PlatformAppEvent.HostEvent
27
+ });
28
+ break;
29
+ }
30
+ }
31
+ /**
32
+ * Subscribe to Worker (Application) event
33
+ */
34
+ subscribe(cb) {
35
+ this.platformAppEvents.subscribe((event) => {
36
+ cb(event);
37
+ });
38
+ }
39
+ }
40
+
41
+ var PlatformConsumerEnvironmentAPIType = /* @__PURE__ */ ((PlatformConsumerEnvironmentAPIType2) => {
42
+ PlatformConsumerEnvironmentAPIType2["Frame"] = "PLATFORM_FRAME_API";
43
+ PlatformConsumerEnvironmentAPIType2["Worker"] = "PLATFORM_WORKER_API";
44
+ return PlatformConsumerEnvironmentAPIType2;
45
+ })(PlatformConsumerEnvironmentAPIType || {});
46
+ class AbstractEnvironmentAPI {
47
+ constructor(env) {
48
+ this.env = env;
49
+ this.create();
50
+ }
51
+ }
6
52
 
7
53
  var EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {
8
54
  EditorPlatformApplicationContextErrorCode2["IncorrectEnvironment"] = "IncorrectEnvironment";
55
+ EditorPlatformApplicationContextErrorCode2["ClientAuthError"] = "ClientAuthError";
9
56
  return EditorPlatformApplicationContextErrorCode2;
10
57
  })(EditorPlatformApplicationContextErrorCode || {});
11
58
  class EditorPlatformApplicationContextError extends publicEditorPlatformErrors.BaseError {
@@ -168,6 +215,7 @@
168
215
  var PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {
169
216
  PlatformEnvironment2["Worker"] = "Worker";
170
217
  PlatformEnvironment2["Frame"] = "Frame";
218
+ PlatformEnvironment2["ComponentPanel"] = "ComponentPanel";
171
219
  return PlatformEnvironment2;
172
220
  })(PlatformEnvironment || {});
173
221
  class EnvironmentContext {
@@ -272,52 +320,59 @@
272
320
  return this.environment.getApplicationAPIs()[appDefinitionId];
273
321
  }
274
322
  }
275
-
276
- class WorkerEventsBridge {
277
- constructor(platformAppEvents) {
278
- this.platformAppEvents = platformAppEvents;
279
- }
280
- /**
281
- * Notify by event from Worker Manager (platform infrastructure)
282
- */
283
- notify(event) {
284
- switch (event.type) {
285
- case publicEditorPlatformEvents.PlatformLifecycleEvent.EditorReady:
286
- this.platformAppEvents.notify({
287
- ...event,
288
- // @ts-expect-error TODO: fix me
289
- type: publicEditorPlatformEvents.PlatformAppEvent.EditorReady
290
- });
291
- break;
292
- case publicEditorPlatformEvents.PlatformPrivateEvent.HostEvent:
293
- this.platformAppEvents.notify({
294
- ...event,
295
- type: publicEditorPlatformEvents.PlatformAppEvent.HostEvent
296
- });
297
- break;
323
+ const createSDKHost = (props) => {
324
+ const environmentContext = new EnvironmentContext({
325
+ environment: props.environment,
326
+ privateApi: props.privateAPI,
327
+ events: props.events ?? new publicEditorPlatformEvents.PlatformAppEventEmitter(),
328
+ applicationAPIs: props.applicationPrivateAPI ? {
329
+ [props.appDefinitionId]: props.applicationPrivateAPI
330
+ } : {}
331
+ });
332
+ const applicationContext = new ApplicationContext(
333
+ {
334
+ appDefinitionId: props.appDefinitionId,
335
+ appDefinitionName: ""
336
+ },
337
+ environmentContext
338
+ );
339
+ return {
340
+ environment: {},
341
+ channel: {
342
+ observeState: async () => {
343
+ return {
344
+ disconnect() {
345
+ }
346
+ };
347
+ }
348
+ },
349
+ environmentContext,
350
+ applicationContext
351
+ };
352
+ };
353
+ const auth = (appDefinitionId, privateAPI) => {
354
+ return {
355
+ getAuthHeaders: async () => {
356
+ if (!appDefinitionId) {
357
+ throw createEditorPlatformApplicationContextError(
358
+ EditorPlatformApplicationContextErrorCode.ClientAuthError
359
+ );
360
+ }
361
+ const authInstance = await privateAPI.info.getAppInstance(appDefinitionId);
362
+ if (authInstance === void 0) {
363
+ throw createEditorPlatformApplicationContextError(
364
+ EditorPlatformApplicationContextErrorCode.ClientAuthError,
365
+ "empty auth instance"
366
+ ).withAppDefinitionId(appDefinitionId);
367
+ }
368
+ return {
369
+ headers: {
370
+ Authorization: authInstance
371
+ }
372
+ };
298
373
  }
299
- }
300
- /**
301
- * Subscribe to Worker (Application) event
302
- */
303
- subscribe(cb) {
304
- this.platformAppEvents.subscribe((event) => {
305
- cb(event);
306
- });
307
- }
308
- }
309
-
310
- var PlatformConsumerEnvironmentAPIType = /* @__PURE__ */ ((PlatformConsumerEnvironmentAPIType2) => {
311
- PlatformConsumerEnvironmentAPIType2["Frame"] = "PLATFORM_FRAME_API";
312
- PlatformConsumerEnvironmentAPIType2["Worker"] = "PLATFORM_WORKER_API";
313
- return PlatformConsumerEnvironmentAPIType2;
314
- })(PlatformConsumerEnvironmentAPIType || {});
315
- class AbstractEnvironmentAPI {
316
- constructor(env) {
317
- this.env = env;
318
- this.create();
319
- }
320
- }
374
+ };
375
+ };
321
376
 
322
377
  const DESIGN_SYSTEM_STYLES_MAP = {
323
378
  classic: "https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css",
@@ -363,6 +418,17 @@
363
418
  appDefinitionId,
364
419
  appDefinitionName: ""
365
420
  });
421
+ const client = sdk.createClient({
422
+ auth: auth(appDefinitionId, privateAPI),
423
+ host: createSDKHost({
424
+ appDefinitionId,
425
+ privateAPI: this.#privateAPI,
426
+ environment: PlatformEnvironment.Frame,
427
+ events: this.#events,
428
+ applicationPrivateAPI: this.#applicationPrivateAPI
429
+ })
430
+ });
431
+ client.enableContext("global");
366
432
  }
367
433
  notify(event) {
368
434
  this.#eventsBridge.notify(event);