@wix/cli-app 1.1.52 → 1.1.55

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 (102) hide show
  1. package/README.md +45 -0
  2. package/build/{CreateVersionCommand-HVC5JTAL.js → CreateVersionCommand-XTZT5DED.js} +2 -2
  3. package/build/{DevCommand-RTZ66W3P.js → DevCommand-Q5XLAGMG.js} +2 -2
  4. package/build/DevCommand-Q5XLAGMG.js.map +1 -0
  5. package/build/GenerateCommand-HNFICZJA.js +128 -0
  6. package/build/{GenerateCommand-J4FYPLSB.js.map → GenerateCommand-HNFICZJA.js.map} +1 -1
  7. package/build/LogsCommand-XJHE75L2.js +4 -0
  8. package/build/LogsCommand-XJHE75L2.js.map +1 -0
  9. package/build/PreviewCommand-JKPFMGWV.js +4 -0
  10. package/build/ServeCommand-CPZOI7DC.js +4 -0
  11. package/build/ServeCommand-CPZOI7DC.js.map +1 -0
  12. package/build/build-3RXHADZD.js +4 -0
  13. package/build/build-3RXHADZD.js.map +1 -0
  14. package/build/chunk-2FB5F5QF.js +4 -0
  15. package/build/{chunk-2R6WOCA4.js → chunk-4BHNJVL2.js} +2 -2
  16. package/build/{chunk-KNH7RNAZ.js → chunk-5OZZ7R6I.js} +2 -2
  17. package/build/chunk-5OZZ7R6I.js.map +1 -0
  18. package/build/{chunk-6ZJVIMV7.js → chunk-6HSUK2A2.js} +2 -2
  19. package/build/{chunk-EWA6OFAF.js → chunk-7VOKCPZP.js} +3 -3
  20. package/build/{chunk-EWA6OFAF.js.map → chunk-7VOKCPZP.js.map} +1 -1
  21. package/build/{chunk-2LPICRGU.js → chunk-B4SDDVMV.js} +2 -2
  22. package/build/{chunk-UKELYG5A.js → chunk-C4SXZWXS.js} +2 -2
  23. package/build/{chunk-NEWE3FX5.js → chunk-FKBCPMYK.js} +3 -3
  24. package/build/chunk-FKBCPMYK.js.map +1 -0
  25. package/build/chunk-FMIXY6J5.js +115 -0
  26. package/build/chunk-FMIXY6J5.js.map +1 -0
  27. package/build/chunk-GWU77DPO.js +4 -0
  28. package/build/chunk-GWU77DPO.js.map +1 -0
  29. package/build/{chunk-CMBEPCWL.js → chunk-HDXLQ34N.js} +2 -2
  30. package/build/chunk-JXE3LQ2S.js +100 -0
  31. package/build/chunk-JXE3LQ2S.js.map +1 -0
  32. package/build/chunk-K2A77MMN.js +4 -0
  33. package/build/chunk-K2A77MMN.js.map +1 -0
  34. package/build/{chunk-WRYRVOZP.js → chunk-KG7BHEJG.js} +2 -2
  35. package/build/chunk-LJEYXY4V.js +4 -0
  36. package/build/chunk-LJEYXY4V.js.map +1 -0
  37. package/build/{chunk-ATQCL6AZ.js → chunk-N5D4TFKX.js} +177 -126
  38. package/build/chunk-N5D4TFKX.js.map +1 -0
  39. package/build/{chunk-2YXY5Y3Z.js → chunk-QOUZ6J7N.js} +2 -2
  40. package/build/{chunk-FMTROGFZ.js → chunk-X4BLMM2K.js} +2 -2
  41. package/build/chunk-X4BLMM2K.js.map +1 -0
  42. package/build/cloudflare-runtime/entry.js +308 -49
  43. package/build/cloudflare-runtime/getRegisteredExtensions.js +307 -48
  44. package/build/index.js +2 -2
  45. package/build/index.js.map +1 -1
  46. package/build/platform-sdk/{chunk-RE2R2PA6.js → chunk-GZP4Z76C.js} +2 -2
  47. package/build/platform-sdk/chunk-KGLNBMRO.js +2 -0
  48. package/build/platform-sdk/chunk-KGLNBMRO.js.map +1 -0
  49. package/build/platform-sdk/dashboard.js +1 -1
  50. package/build/platform-sdk/editor.js +2 -2
  51. package/build/platform-sdk/editor.js.map +1 -1
  52. package/build/platform-sdk/site.js +1 -1
  53. package/build/platform-sdk/site.js.map +1 -1
  54. package/build/preview-TM7JAWFS.js +4 -0
  55. package/build/preview-TM7JAWFS.js.map +1 -0
  56. package/build/render-command-QEQ3L7OX.js +4 -0
  57. package/build/render-command-QEQ3L7OX.js.map +1 -0
  58. package/internal/component-hmr-wrapper.tsx +9 -9
  59. package/package.json +8 -7
  60. package/templates/dashboard-plugin/files/plugin.tsx.ejs +8 -18
  61. package/templates/site-plugin/files/plugin.tsx.ejs +1 -1
  62. package/build/DevCommand-RTZ66W3P.js.map +0 -1
  63. package/build/GenerateCommand-J4FYPLSB.js +0 -128
  64. package/build/LogsCommand-J3PHRUGE.js +0 -4
  65. package/build/LogsCommand-J3PHRUGE.js.map +0 -1
  66. package/build/PreviewCommand-JYIGS25E.js +0 -4
  67. package/build/ServeCommand-LEJRJ2CR.js +0 -4
  68. package/build/ServeCommand-LEJRJ2CR.js.map +0 -1
  69. package/build/build-YPC7VLOB.js +0 -4
  70. package/build/build-YPC7VLOB.js.map +0 -1
  71. package/build/chunk-522ULCVX.js +0 -100
  72. package/build/chunk-522ULCVX.js.map +0 -1
  73. package/build/chunk-ATQCL6AZ.js.map +0 -1
  74. package/build/chunk-FMTROGFZ.js.map +0 -1
  75. package/build/chunk-KNH7RNAZ.js.map +0 -1
  76. package/build/chunk-MXLCRTVZ.js +0 -4
  77. package/build/chunk-NEWE3FX5.js.map +0 -1
  78. package/build/chunk-RWTMPGYF.js +0 -4
  79. package/build/chunk-RWTMPGYF.js.map +0 -1
  80. package/build/chunk-WLHVYK7Z.js +0 -4
  81. package/build/chunk-WLHVYK7Z.js.map +0 -1
  82. package/build/chunk-X3ZYER2U.js +0 -115
  83. package/build/chunk-X3ZYER2U.js.map +0 -1
  84. package/build/chunk-ZCIEKIRM.js +0 -4
  85. package/build/chunk-ZCIEKIRM.js.map +0 -1
  86. package/build/platform-sdk/chunk-3TJ2D6DS.js +0 -2
  87. package/build/platform-sdk/chunk-3TJ2D6DS.js.map +0 -1
  88. package/build/preview-VAP5AF4W.js +0 -4
  89. package/build/preview-VAP5AF4W.js.map +0 -1
  90. package/build/render-command-NE2QILSS.js +0 -4
  91. package/build/render-command-NE2QILSS.js.map +0 -1
  92. /package/build/{CreateVersionCommand-HVC5JTAL.js.map → CreateVersionCommand-XTZT5DED.js.map} +0 -0
  93. /package/build/{PreviewCommand-JYIGS25E.js.map → PreviewCommand-JKPFMGWV.js.map} +0 -0
  94. /package/build/{chunk-MXLCRTVZ.js.map → chunk-2FB5F5QF.js.map} +0 -0
  95. /package/build/{chunk-2R6WOCA4.js.map → chunk-4BHNJVL2.js.map} +0 -0
  96. /package/build/{chunk-6ZJVIMV7.js.map → chunk-6HSUK2A2.js.map} +0 -0
  97. /package/build/{chunk-2LPICRGU.js.map → chunk-B4SDDVMV.js.map} +0 -0
  98. /package/build/{chunk-UKELYG5A.js.map → chunk-C4SXZWXS.js.map} +0 -0
  99. /package/build/{chunk-CMBEPCWL.js.map → chunk-HDXLQ34N.js.map} +0 -0
  100. /package/build/{chunk-WRYRVOZP.js.map → chunk-KG7BHEJG.js.map} +0 -0
  101. /package/build/{chunk-2YXY5Y3Z.js.map → chunk-QOUZ6J7N.js.map} +0 -0
  102. /package/build/platform-sdk/{chunk-RE2R2PA6.js.map → chunk-GZP4Z76C.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/@wix/public-editor-platform-interfaces/dist/EventType.js","../../../node_modules/@wix/public-editor-platform-interfaces/dist/index.js","../../../node_modules/@wix/public-editor-platform-errors/src/BaseError.ts","../../../node_modules/@wix/public-editor-platform-errors/src/EditorPlatformInternalError.ts","../../../node_modules/@wix/public-editor-platform-events/src/EventEmitter.ts","../../../node_modules/@wix/public-editor-platform-events/src/PlatformPrivateEventEmitter.ts","../../../node_modules/@wix/public-editor-platform-events/src/PlatformAppEventEmitter.ts","../../../node_modules/@wix/public-editor-platform-events/src/DMEventsBridge.ts","../../../node_modules/@wix/editor-platform-transport/src/error.ts","../../../node_modules/@wix/editor-platform-transport/src/serializer/utils.ts","../../../node_modules/@wix/editor-platform-transport/src/serializer/encoders.ts","../../../node_modules/@wix/editor-platform-transport/src/serializer/serializer.ts","../../../node_modules/@wix/editor-platform-transport/src/Message.ts","../../../node_modules/@wix/editor-platform-transport/src/ThreadChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/ConsumerChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/HostChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/HandshakeStrategy/AbstractHandshake.ts","../../../node_modules/@wix/editor-platform-transport/src/HandshakeStrategy/BothDirectionalHandshake.ts","../../../node_modules/@wix/editor-platform-transport/src/factories/IFrameConsumerChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/factories/IFrameHostChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/factories/WorkerConsumerChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/factories/WorkerHostChannel.ts","../../../node_modules/@wix/editor-application/src/Events/WorkerEventsBridge.ts","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/AbstractEnvironmentAPI.ts","../../../node_modules/@wix/editor-platform-application-context/dist/esm/index.js","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/PlatformFrameAPI/PlatformFrameAPI.ts","../../../node_modules/@wix/editor-application/src/Events/WorkerEventsBridge.ts","../../../node_modules/@wix/editor-platform-application-context/dist/esm/index.js","../../../node_modules/@wix/editor-application/src/errors.ts","../../../node_modules/@wix/editor-application/src/PlatformApplicationContainer/executeApplication.ts","../../../node_modules/@wix/editor-application/src/PlatformApplicationContainer/PlatformApplicationContainer.ts","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/AbstractEnvironmentAPI.ts","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/PlatformWorkerAPI/PlatformWorkerAPI.ts","../../../node_modules/@wix/editor-platform-application-context/dist/esm/index.js","../../../node_modules/@wix/editor/src/auth.ts","../../../node_modules/@wix/editor/src/env.ts","../../../node_modules/@wix/editor/src/PlatformSDKShape.ts","../../../node_modules/@wix/editor/src/application/index.ts","../../../node_modules/@wix/editor/src/components/index.ts","../../../node_modules/@wix/editor/src/events/index.ts","../../../node_modules/@wix/editor/src/info/index.ts","../../../node_modules/@wix/editor/src/widget/errors.ts","../../../node_modules/@wix/editor/src/widget/index.ts","../../../node_modules/@wix/editor/src/inputs/index.ts","../../../node_modules/@wix/editor/src/editorPlatformFrameHost.ts","../../../node_modules/@wix/editor/src/editorPlatformWorkerHost.ts","../../../node_modules/@wix/editor/src/index.ts","../src/editor.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.EventType = void 0;\n/**\n * Duplicated types from editor-platform-sdk-types/src/events/EventType.ts\n * to allow use them in public packages\n */\nvar EventType;\n(function (EventType) {\n EventType[\"removeAppCompleted\"] = \"removeAppCompleted\";\n EventType[\"componentSelectionChanged\"] = \"componentSelectionChanged\";\n EventType[\"appInstalled\"] = \"appInstalled\";\n EventType[\"appUpdateCompleted\"] = \"appUpdateCompleted\";\n})(EventType || (exports.EventType = EventType = {}));\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.EventType = exports.WixSDKTypes = void 0;\nconst WixSDKTypes = __importStar(require(\"@wix/sdk-types\"));\nexports.WixSDKTypes = WixSDKTypes;\nvar EventType_1 = require(\"./EventType\");\nObject.defineProperty(exports, \"EventType\", { enumerable: true, get: function () { return EventType_1.EventType; } });\n","export abstract class BaseError<TErrorCode> extends Error {\n protected state: Record<string, string> = {};\n\n displayName: string;\n prefix: string;\n errorMessage: string;\n\n parent: Error | BaseError<TErrorCode> | undefined;\n\n messages: string[][] = [];\n\n public code: TErrorCode;\n\n protected constructor(_message: string, _code: TErrorCode, _prefix: string) {\n const message = _message ? ` ${_message}` : '';\n const displayName = `[${_prefix}]#${_code}`;\n\n super(`${displayName}.${message}`);\n\n this.displayName = displayName;\n this.errorMessage = _message;\n this.prefix = _prefix;\n this.code = _code;\n\n this.name = displayName;\n\n Object.defineProperty(this, 'message', {\n get: () => {\n return this.getDisplayMessage();\n },\n });\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, BaseError);\n }\n }\n\n get parentError(): BaseError<any> | null {\n const parent = this.parent;\n\n if (!parent) {\n return null;\n }\n\n if (this.parent instanceof BaseError) {\n return this.parent;\n }\n\n const displayName = parent.name ?? '[Unknown Error]';\n\n return {\n getBreadcrumbs() {\n return [displayName];\n },\n getMessage() {\n return [displayName, parent.message ?? 'unknown error message'].join(\n '\\n',\n );\n },\n } as unknown as BaseError<any>;\n }\n\n /**\n * Returns formatted error message with breadcrumbs\n */\n getDisplayMessage() {\n const breadcrumbs = this.parentError ? this.getBreadcrumbs() : [];\n\n return [breadcrumbs.join(' -> '), this.getMessage()]\n .filter((x) => x.trim().length)\n .join('\\n');\n }\n\n /**\n * Returns formatted error message\n */\n getMessage() {\n const state = Object.entries(this.state)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(` – ${key}: ${value}`);\n }\n return acc;\n }, [] as string[])\n .join('\\n');\n\n const messages = this.messages\n .reduce((acc, _messages) => {\n acc.push(` - ${_messages.join(' ')}`);\n\n return acc;\n }, [] as string[])\n .join('\\n');\n\n const parentError = this.parentError;\n\n const parentErrorMessage: string = parentError\n ? ['', parentError.getMessage(), ''].join('\\n')\n : '';\n\n const thrownErrorMessage = this.errorMessage\n ? `${this.displayName}: ${this.errorMessage}`\n : this.displayName;\n\n return [parentErrorMessage, thrownErrorMessage, state, messages]\n .filter((x) => x.trim().length)\n .join('\\n');\n }\n\n getBreadcrumbs(): string[] {\n const parentError = this.parentError;\n\n if (!parentError) {\n return [this.displayName];\n }\n\n return [...parentError.getBreadcrumbs(), this.displayName];\n }\n\n public withParentError(e: Error | BaseError<any>) {\n this.parent = e;\n return this;\n }\n\n public withMessage(...messages: string[]) {\n this.messages.push(messages);\n return this;\n }\n}\n\nexport function createErrorBuilder<TCode, TFactory extends BaseError<TCode>>(\n factory: new (...args: any) => TFactory,\n) {\n return function throwException(code: TCode, message = '') {\n const instance = new factory(message, code);\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(instance, throwException);\n }\n\n return instance;\n };\n}\n","import { BaseError, createErrorBuilder } from './BaseError';\n\nexport enum EditorPlatformInternalErrorCode {\n UnexpectedError = 'UnexpectedError',\n}\n\nclass EditorPlatformInternalError extends BaseError<EditorPlatformInternalErrorCode> {\n state: Partial<{\n host: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformInternalErrorCode) {\n super(message, code, 'Editor Platform Internal Error');\n }\n\n withHost(host: string) {\n this.state = { ...this.state, host };\n return this;\n }\n}\n\nexport const createEditorPlatformInternalError = createErrorBuilder<\n EditorPlatformInternalErrorCode,\n EditorPlatformInternalError\n>(EditorPlatformInternalError);\n","export class EventEmitter<TEvent = any> {\n static biEvents = {\n PLATFORM_WORKER_SPAWN: 123,\n PLATFORM_APP_RUNNER_INIT_APP_API: 124,\n PLATFORM_APP_RUNNER_RUN_APP: 125,\n PLATFORM_APP_RUNNER_REMOVE_APP: 126,\n PLATFORM_WORKER_APP_BUNDLE_LOAD: 127,\n PLATFORM_WORKER_APP_BUNDLE_EXECUTE: 128,\n PLATFORM_IFRAME_INIT: 129,\n PLATFORM_APP_API_INIT: 130,\n PLATFORM_APP_API_GET: 131,\n };\n\n static EventSteps = {\n Start: 'start',\n End: 'end',\n Error: 'error',\n };\n\n private uid = 0;\n private callbacks: Map<any, (event: TEvent) => void> = new Map();\n private inTransaction = false;\n private isSilent = false;\n private queue: TEvent[] = [];\n\n silent(isSilent = true) {\n this.isSilent = isSilent;\n }\n\n startTransaction() {\n this.inTransaction = true;\n }\n\n commit() {\n this.inTransaction = false;\n\n const queue = this.queue;\n this.queue = [];\n\n if (!this.isSilent) {\n queue.forEach((event) => {\n this.notify(event);\n });\n }\n }\n\n notify(event: TEvent) {\n if (this.isSilent) {\n return;\n }\n\n if (this.inTransaction) {\n this.queue.push(event);\n } else {\n this.callbacks.forEach((callback) => {\n callback(event);\n });\n }\n }\n\n subscribe(callback: (event: TEvent) => void) {\n const uid = this.uid++;\n\n this.callbacks.set(uid, callback);\n\n return () => {\n this.callbacks.delete(uid);\n };\n }\n\n notifyWithStep(event: TEvent, step: string) {\n this.notify({\n ...event,\n meta: {\n ...(event as any).meta,\n step,\n },\n });\n }\n\n async withEvent<TResult = any>(\n event: TEvent,\n cb: () => TResult | Promise<TResult>,\n ): Promise<TResult> {\n // TODO: wrap with try/catch\n let result = cb();\n\n if (result && result.hasOwnProperty('then')) {\n try {\n this.notifyWithStep(event, EventEmitter.EventSteps.Start);\n\n result = await result;\n\n this.notifyWithStep(event, EventEmitter.EventSteps.End);\n\n return result;\n } catch (e) {\n this.notifyWithStep(\n {\n ...event,\n meta: {\n ...(event as any).meta,\n error: e,\n },\n },\n EventEmitter.EventSteps.Error,\n );\n\n throw e;\n }\n } else {\n this.notify(event);\n\n return result;\n }\n }\n}\n","import { EventEmitter } from './EventEmitter';\nimport { IPlatformPrivateEventBase } from './events';\n\nexport enum PlatformPrivateEvent {\n WorkerSpawn = 'WorkerSpawn',\n HostEvent = 'HostEvent',\n ApplicationsSpecsReceived = 'ApplicationsSpecsReceived',\n InitApplicationApi = 'InitApplicationApi',\n RunApplication = 'RunApplication',\n getApplicationApi = 'getApplicationApi',\n IframeInit = 'IframeInit',\n}\n\nexport enum PlatformLifecycleEvent {\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformWorkerSpawnEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.WorkerSpawn,\n { url: string },\n {\n bi: {\n workerId: string;\n strategy: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyLifecycleEvent = IPlatformPrivateEventBase<\n PlatformLifecycleEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformHostEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.HostEvent,\n {\n type: string;\n },\n { appDefinitionId: string; intent: string }\n>;\n\nexport type IPlatformApplicationsSpecsReceived = IPlatformPrivateEventBase<\n PlatformPrivateEvent.ApplicationsSpecsReceived,\n {\n appDefinitionIds: string[];\n },\n {}\n>;\n\nexport type IPlatformRunApplication = IPlatformPrivateEventBase<\n PlatformPrivateEvent.RunApplication,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appType?: string;\n appDefId?: string;\n };\n }\n>;\n\nexport type IPlatformGetApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.getApplicationApi,\n {},\n {\n bi: {\n targetAppDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformInitApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.InitApplicationApi,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformIframeInit = IPlatformPrivateEventBase<\n PlatformPrivateEvent.IframeInit,\n {},\n {\n bi: {\n frameUrl: string;\n iframeId: string;\n };\n }\n>;\n\nexport type IPlatformPrivateEvent =\n | IPlatformWorkerSpawnEvent\n | IPlatformEditorReadyLifecycleEvent\n | IPlatformHostEvent\n | IPlatformApplicationsSpecsReceived\n | IPlatformRunApplication\n | IPlatformGetApplicationApi\n | IPlatformInitApplicationApi\n | IPlatformIframeInit;\n\nclass PlatformPrivateEventFactories {\n public createWorkerSpawnEvent({\n url,\n workerId,\n strategy,\n }: {\n url: string;\n workerId: string;\n strategy: string;\n }): IPlatformWorkerSpawnEvent {\n return {\n type: PlatformPrivateEvent.WorkerSpawn,\n payload: {\n url,\n },\n meta: {\n bi: {\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n workerId,\n strategy,\n },\n },\n };\n }\n\n public createRunApplicationEvent(app: {\n appDefinitionId: string;\n type: string;\n }): IPlatformRunApplication {\n return {\n type: PlatformPrivateEvent.RunApplication,\n payload: {\n appDefinitionId: app.appDefinitionId,\n },\n meta: {\n bi: {\n appType: app.type,\n appDefId: app.appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents\n .PLATFORM_APP_RUNNER_RUN_APP,\n },\n },\n };\n }\n\n public createGetApplicationApiEvent(\n targetAppDefId: string,\n scope: 'private' | 'public',\n ): IPlatformGetApplicationApi {\n return {\n type: PlatformPrivateEvent.getApplicationApi,\n payload: {},\n meta: {\n bi: {\n targetAppDefId,\n scope,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_GET,\n },\n },\n };\n }\n\n public createInitApplicationApiEvent(\n appDefinitionId: string,\n ): IPlatformInitApplicationApi {\n return {\n type: PlatformPrivateEvent.InitApplicationApi,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n appDefId: appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n },\n },\n };\n }\n\n public createIframeInitEvent(\n frameUrl: string,\n iframeId: string,\n ): IPlatformIframeInit {\n return {\n type: PlatformPrivateEvent.IframeInit,\n payload: {},\n meta: {\n bi: {\n frameUrl,\n iframeId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_IFRAME_INIT,\n },\n },\n };\n }\n}\n\nexport class PlatformPrivateEventEmitter extends EventEmitter<IPlatformPrivateEvent> {\n public factories = new PlatformPrivateEventFactories();\n\n notify(event: IPlatformPrivateEvent) {\n super.notify(event);\n }\n}\n","import { EventEmitter } from './EventEmitter';\n\nimport { IPlatformAppEventBase, IPlatformEventBase } from './events';\n\nexport enum PlatformAppEvent {\n ApplicationInit = 'ApplicationInit',\n ApplicationExecute = 'ApplicationExecute',\n ApplicationRemoved = 'ApplicationRemoved',\n ApplicationLoad = 'ApplicationLoad',\n ApplicationApiInit = 'ApplicationApiInit',\n CustomEvent = 'CustomEvent',\n HostEvent = 'HostEvent',\n\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformAppInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationInit,\n {},\n {}\n>;\n\nexport type IPlatformAppCustomEvent = IPlatformAppEventBase<\n PlatformAppEvent.CustomEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppHostEvent = IPlatformAppEventBase<\n PlatformAppEvent.HostEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppExecuteEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationExecute,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyEvent = IPlatformEventBase<\n PlatformAppEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformApplicationRemovedEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationRemoved,\n {},\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformAppLoadEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationLoad,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformApplicationApiInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationApiInit,\n {},\n {\n bi: {\n appDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformAppEvent =\n | IPlatformAppInitEvent\n | IPlatformAppCustomEvent\n | IPlatformAppHostEvent\n | IPlatformAppExecuteEvent\n | IPlatformAppLoadEvent\n | IPlatformApplicationRemovedEvent\n | IPlatformApplicationApiInitEvent;\n\nclass PlatformAppEventsFactories {\n public createApplicationRemovedEvent(\n appDefinitionId: string,\n ): IPlatformApplicationRemovedEvent {\n return {\n type: PlatformAppEvent.ApplicationRemoved,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n appDefId: appDefinitionId,\n },\n },\n };\n }\n\n public createApplicationLoadEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppLoadEvent {\n return {\n type: PlatformAppEvent.ApplicationLoad,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_LOAD,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationExecuteEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppExecuteEvent {\n return {\n type: PlatformAppEvent.ApplicationExecute,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_EXECUTE,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationApiInitEvent(\n appDefinitionId: string,\n scope: 'private' | 'public',\n ): IPlatformApplicationApiInitEvent {\n return {\n type: PlatformAppEvent.ApplicationApiInit,\n payload: { appDefinitionId },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n appDefId: appDefinitionId,\n scope,\n },\n },\n };\n }\n}\n\nexport class PlatformAppEventEmitter extends EventEmitter<IPlatformAppEvent> {\n public factories = new PlatformAppEventsFactories();\n}\n","import { EventType } from '@wix/public-editor-platform-interfaces';\nimport {\n IPlatformHostEvent,\n PlatformPrivateEvent,\n PlatformPrivateEventEmitter,\n} from './PlatformPrivateEventEmitter';\n\n/**\n * The events bridge between DM and private events\n */\nexport class DMEventsBridge {\n static allowedEvents = [\n EventType.componentSelectionChanged,\n EventType.appInstalled,\n EventType.appUpdateCompleted,\n EventType.removeAppCompleted,\n ];\n\n private mapToPlatformHostEvent(event: any): IPlatformHostEvent {\n if (typeof event === 'string') {\n try {\n event = JSON.parse(event);\n } catch (e) {\n // TODO: log error\n }\n }\n\n return {\n type: PlatformPrivateEvent.HostEvent,\n payload: {\n type: event.args.eventType,\n ...event.args.eventPayload,\n },\n meta: {\n appDefinitionId: event.appDefinitionId ?? null,\n intent: event.intent,\n },\n };\n }\n\n constructor(private events: PlatformPrivateEventEmitter) {}\n\n /**\n * Notify by event from Worker Manager (platform infrastructure)\n */\n public notify(_event: any) {\n const event = this.mapToPlatformHostEvent(_event);\n if (\n DMEventsBridge.allowedEvents.includes(event.payload.type as EventType)\n ) {\n this.events.notify(event);\n }\n }\n}\n","export const errorMessage = (message: string) => {\n return `\"editor-platform-transport\": ${message}`;\n};\nexport const internalErrorMessage = (message: string) => {\n return errorMessage(`[Internal Error] ${message}`);\n};\n","export const FUNCTION_MARKER = 'ƒ';\nexport const ACCESSOR_MARKER = '∂';\nexport const ACCESSOR_GET_POINTER = '_get_';\nexport const ACCESSOR_SET_POINTER = '_set_';\nexport const WITH_ACCESSOR_INDICATOR = '+';\nexport const NO_ACCESSOR_INDICATOR = '-';\nexport const PATH_SEPARATOR = '·';\nexport const ENCODER_MARKER = '×';\nexport const ENCODER_EMPTY_MARKER = '°';\nexport const extractPointer = (pointer: string) =>\n pointer[0] === ENCODER_MARKER ? '' : pointer;\n\nexport const isFinalNode = (instance: unknown) => {\n return (\n instance === null ||\n typeof instance === 'undefined' ||\n typeof instance === 'symbol' ||\n typeof instance === 'number' ||\n typeof instance === 'boolean' ||\n typeof instance === 'function' ||\n typeof instance === 'string'\n );\n};\nexport const isSerializableType = (instance: unknown) => {\n return (\n !!instance &&\n typeof instance === 'object' &&\n !Array.isArray(instance) &&\n !(instance instanceof Date) &&\n !(instance instanceof Set) &&\n !(instance instanceof Map)\n );\n};\n\nexport const beautifyPath = (path: string) =>\n beautifyBreadcrumbs(path.split(PATH_SEPARATOR));\nexport const beautifyBreadcrumbs = (breadcrumbs: string[]) =>\n breadcrumbs.map(extractPointer).filter(Boolean).join('.');\n","import { ENCODER_EMPTY_MARKER } from './utils';\n\nfunction createStructureEncoder<TMarker extends string, TInstance>(\n marker: TMarker,\n config: {\n shouldUse: (instance: unknown) => boolean;\n serialize: (\n instance: TInstance,\n next: (key: string, value?: any) => void,\n ) => void;\n deserialize: {\n create: () => TInstance;\n has: (instance: TInstance, key: string) => boolean;\n append: (instance: TInstance, key: string, value: any) => void;\n };\n },\n) {\n return {\n marker,\n ...config,\n };\n}\n\nexport const arrayEncoder = createStructureEncoder<'A', any[]>('A', {\n shouldUse: (instance) => Array.isArray(instance),\n serialize: (instance, next) => {\n if (!instance.length) {\n next('', ENCODER_EMPTY_MARKER);\n } else {\n instance.forEach((value, index) => {\n next(`${index}`, value);\n });\n }\n },\n deserialize: {\n create: () => [],\n has: (instance, key) =>\n !(typeof instance[key as unknown as number] === 'undefined'),\n append: (instance, _key, value) => {\n instance.push(value);\n },\n },\n});\n\nexport const mapEncoder = createStructureEncoder<'M', Map<any, any>>('M', {\n shouldUse: (instance: unknown) => instance instanceof Map,\n serialize: (instance, next) => {\n instance.forEach((value, key) => {\n next(key, value);\n });\n },\n deserialize: {\n create: () => new Map(),\n has: (instance, key) => instance.has(key),\n append: (instance, key, value) => {\n instance.set(key, value);\n },\n },\n});\n\nexport const setEncoder = createStructureEncoder<'S', Set<any>>('S', {\n shouldUse: (instance) => instance instanceof Set,\n serialize: (instance, next) => {\n let index = 0;\n instance.forEach((value) => {\n next(`${index++}`, value);\n });\n },\n deserialize: {\n create: () => new Set(),\n has: (instance, key) => instance.has(key),\n append: (instance, _key, value) => {\n instance.add(value);\n },\n },\n});\n\nexport const objectEncoder = createStructureEncoder<'O', Record<string, any>>(\n 'O',\n {\n shouldUse: (instance) => typeof instance === 'object',\n serialize: (root, next) => {\n const forEachMember = (instance: Record<string, any>) => {\n const keys = Reflect.ownKeys(instance);\n\n const members = keys\n .filter((key) => {\n return key !== 'constructor';\n })\n .filter((key) => {\n return typeof key !== 'symbol';\n });\n\n if (!members.length) {\n next('', ENCODER_EMPTY_MARKER);\n } else {\n members\n .filter((key) => {\n return key !== 'constructor';\n })\n .filter((key) => {\n return typeof key !== 'symbol';\n })\n .forEach((key) => {\n const value = Reflect.get(root, key);\n\n next(key as string, value);\n });\n }\n\n const parent = Reflect.getPrototypeOf(instance);\n if (!parent || parent?.hasOwnProperty('__proto__')) {\n return;\n }\n\n forEachMember(parent);\n };\n\n forEachMember(root);\n },\n deserialize: {\n create: () => ({}),\n has: (instance, key) => !!instance[key],\n append: (instance, key, value) => {\n instance[key] = value;\n },\n },\n },\n);\n","import { errorMessage } from '../error';\nimport {\n ACCESSOR_GET_POINTER,\n ACCESSOR_MARKER,\n ACCESSOR_SET_POINTER,\n beautifyBreadcrumbs,\n beautifyPath,\n ENCODER_EMPTY_MARKER,\n ENCODER_MARKER,\n extractPointer,\n FUNCTION_MARKER,\n isFinalNode,\n isSerializableType,\n NO_ACCESSOR_INDICATOR,\n PATH_SEPARATOR,\n WITH_ACCESSOR_INDICATOR,\n} from './utils';\nimport {\n arrayEncoder,\n mapEncoder,\n objectEncoder,\n setEncoder,\n} from './encoders';\n\n/**\n * { a:1,b:2, c:[1, {d:5}] }\n * =>\n * {\n * type: 'object',\n * data: [['a', 1], ['b', 2], ['#c.0', 1], ['c.#1.d', 5]]\n * }\n */\nexport interface ISerializedPayload {\n data: [string, string | number | boolean | null | undefined][];\n}\n\nexport type IRegisterFunctionMarker = (\n path: string,\n value: (...args: any) => any,\n) => void;\n\nexport type IReplaceFunctionMarker = (path: string) => (props: any[]) => any;\n\nconst encoders = [arrayEncoder, setEncoder, mapEncoder];\n\nfunction getDescriptor(obj: any, key: string) {\n let _instance = obj;\n\n while (_instance) {\n const descriptor = Object.getOwnPropertyDescriptor(_instance, key);\n if (descriptor) {\n return descriptor;\n }\n\n _instance = Reflect.getPrototypeOf(_instance);\n }\n\n return null;\n}\n\nfunction forEachMember(\n root: any,\n callback: (\n breadcrumbs: string[],\n config: {\n context: {};\n pointer: string;\n value: any;\n },\n ) => void,\n) {\n const ancestors = new WeakMap<any, string[]>();\n const getContextPointer = (breadcrumbs: string[]) => {\n const _breadcrumbs = breadcrumbs\n .slice(1) // TODO\n .map(extractPointer)\n .filter(Boolean);\n\n return _breadcrumbs.slice(1).reduce<any>(\n (acc, pointer) => {\n return {\n context: acc.context[acc.pointer],\n pointer,\n };\n },\n {\n context: root,\n pointer: _breadcrumbs[0],\n },\n );\n };\n\n const iterateStructure = (instance: any, breadcrumbs: string[] = []) => {\n if (ancestors.has(instance)) {\n const hasDuplicates = ancestors\n .get(instance)\n ?.some((p) => breadcrumbs.join('.').startsWith(p));\n\n if (hasDuplicates) {\n callback(breadcrumbs, {\n ...getContextPointer(breadcrumbs),\n value: '[Circular]',\n });\n return;\n }\n }\n\n if (instance && !isFinalNode(instance)) {\n if (ancestors.has(instance)) {\n ancestors.set(instance, []);\n }\n\n ancestors.set(instance, [\n ...(ancestors.get(instance) ?? []),\n breadcrumbs.join('.'),\n ]);\n }\n\n if (isFinalNode(instance)) {\n callback(breadcrumbs, {\n ...getContextPointer(breadcrumbs),\n value: instance,\n });\n return;\n }\n\n const encoder =\n encoders.find((_encoder) => _encoder.shouldUse(instance)) ??\n objectEncoder;\n\n if (encoder) {\n encoder.serialize(instance, (key, value) => {\n iterateStructure(value, [\n ...breadcrumbs,\n `${ENCODER_MARKER}${encoder.marker}`,\n key,\n ]);\n });\n\n return;\n }\n };\n\n return iterateStructure(root);\n}\n\nexport const serialize = (\n input: any,\n registerFunctionMarker: IRegisterFunctionMarker,\n): ISerializedPayload => {\n if (!isSerializableType(input)) {\n throw new Error(\n errorMessage('only objects are serializable at the root level'),\n );\n }\n\n const buffer: ISerializedPayload = {\n data: [],\n };\n\n const appendValue = (path: string, value: any) => {\n buffer.data.push([path, value]);\n };\n\n const appendFunction = (\n path: string,\n config: {\n context: any;\n pointer: string;\n },\n ) => {\n registerFunctionMarker(beautifyPath(path), (...args: any[]) => {\n return config.context[config.pointer](...args);\n });\n\n appendValue(path, FUNCTION_MARKER);\n };\n\n forEachMember(input, (breadcrumbs, { value, context, pointer }) => {\n const path = breadcrumbs.slice(1).join(PATH_SEPARATOR);\n\n const descriptor = getDescriptor(context, pointer);\n\n if (descriptor?.get || descriptor?.set) {\n if (descriptor?.get) {\n registerFunctionMarker(\n beautifyBreadcrumbs([...breadcrumbs, ACCESSOR_GET_POINTER]),\n () => (context as unknown as any)[pointer],\n );\n }\n if (descriptor?.set) {\n registerFunctionMarker(\n beautifyBreadcrumbs([...breadcrumbs, ACCESSOR_SET_POINTER]),\n (_value: any) => {\n (context as unknown as any)[pointer] = _value;\n },\n );\n }\n const marker = [\n descriptor?.get ? WITH_ACCESSOR_INDICATOR : NO_ACCESSOR_INDICATOR,\n descriptor?.set ? WITH_ACCESSOR_INDICATOR : NO_ACCESSOR_INDICATOR,\n ];\n\n appendValue(path, `${ACCESSOR_MARKER}${marker.join('')}`);\n } else if (typeof value === 'function') {\n appendFunction(path, { context, pointer });\n } else {\n appendValue(path, value);\n }\n });\n\n return buffer;\n};\n\nexport const deserialize = (\n input: ISerializedPayload,\n replaceFunctionMarker: IReplaceFunctionMarker,\n) => {\n if (typeof input !== 'object' || input === null) {\n return input;\n }\n\n return input.data.reduce<any>(\n (acc, [breadcrumbs, value]) => {\n let pointer = acc;\n\n const pointers = breadcrumbs.split(PATH_SEPARATOR);\n\n let encoder = objectEncoder as any;\n\n let key = null as any;\n\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < pointers.length; i++) {\n const point = pointers[i]!;\n if (point[0] === ENCODER_MARKER) {\n const has = encoder.deserialize.has(pointer, key);\n\n encoder = [objectEncoder, ...encoders].find(\n (_iterator) => _iterator.marker === point[1],\n );\n\n if (!encoder) {\n throw new Error(errorMessage(`unknown marker \"${point[1]}\"`));\n }\n\n if (!has) {\n pointer[key] = encoder.deserialize.create();\n }\n\n pointer = pointer[key];\n } else {\n key = point;\n }\n }\n\n if (value?.toString() === ENCODER_EMPTY_MARKER) {\n return acc;\n } else if (value?.toString() === FUNCTION_MARKER) {\n encoder.deserialize.append(\n pointer,\n key,\n replaceFunctionMarker(beautifyBreadcrumbs(pointers)),\n );\n } else if (value?.toString()[0] === ACCESSOR_MARKER) {\n const hasGetter = value?.toString()[1] === WITH_ACCESSOR_INDICATOR;\n const hasSetter = value?.toString()[2] === WITH_ACCESSOR_INDICATOR;\n\n const descriptor: PropertyDescriptor = {};\n if (hasGetter) {\n const getter = replaceFunctionMarker(\n beautifyBreadcrumbs([...pointers, ACCESSOR_GET_POINTER]),\n );\n\n descriptor.get = () => (getter as any)();\n }\n\n if (hasSetter) {\n descriptor.set = replaceFunctionMarker(\n beautifyBreadcrumbs([...pointers, ACCESSOR_SET_POINTER]),\n );\n }\n\n Object.defineProperty(pointer, key!, descriptor);\n } else {\n encoder.deserialize.append(pointer, key, value);\n }\n\n return acc;\n },\n // TODO: define as enumrable\n {\n [Symbol('transferred object')]: `${(\n JSON.stringify(input.data).length / 1024\n ).toFixed(2)}Kb`,\n },\n );\n};\n","import { deserialize, serialize } from './serializer';\n\nexport const enum MessageType {\n ExposeAPI = 'ExposeAPI',\n Call = 'Call',\n Response = 'Response',\n Cleanup = 'Cleanup',\n}\n\nexport type IRegisterMessageFunctionMarker = (\n correlationId: string,\n path: string,\n value: (...args: any) => any,\n) => void;\n\nexport type IReplaceMessageFunctionMarker = (\n correlationId: string,\n path: string,\n) => (props: any[]) => any;\n\nexport const noopFunctionReplacer = () => () => {};\n\nexport class Message<\n TPayload extends Record<string, any> = Record<string, any>,\n> {\n public readonly correlationId = `M-${performance.now()}`;\n public parentCorrelationId?: string;\n\n constructor(\n public type: MessageType,\n public payload: TPayload,\n ) {}\n\n public withParentCorrelationId(correlationId: string) {\n this.parentCorrelationId = correlationId;\n return this;\n }\n\n public serialize(registerFunctionMarker: IRegisterMessageFunctionMarker) {\n return JSON.stringify({\n parentCorrelationId: this.parentCorrelationId,\n correlationId: this.correlationId,\n type: this.type,\n payload: serialize(this.payload, (path, value) => {\n registerFunctionMarker(this.correlationId, path, value);\n }),\n });\n }\n\n static fromEvent(\n data: string,\n replaceFunctionMarker: IReplaceMessageFunctionMarker,\n ) {\n const parsed = JSON.parse(data);\n\n return new Message(\n parsed.type,\n deserialize(parsed.payload, (breadcrumbs) => {\n return replaceFunctionMarker(parsed.correlationId, breadcrumbs);\n }),\n ).withParentCorrelationId(parsed.correlationId);\n }\n}\n\nexport class MessageCleanup extends Message<{\n functionMarkerKey: string;\n callId?: string;\n}> {\n constructor(payload: typeof MessageCleanup.prototype.payload) {\n super(MessageType.Cleanup, payload);\n }\n}\n\nexport class MessageResponse extends Message<{\n callId: string;\n response: any;\n}> {\n constructor(payload: typeof MessageResponse.prototype.payload) {\n super(MessageType.Response, payload);\n }\n}\n\nexport class MessageResponseError extends Message<{\n callId: string;\n errorMessage: string;\n errorStack?: string;\n}> {\n constructor(payload: typeof MessageResponseError.prototype.payload) {\n super(MessageType.Response, payload);\n }\n}\n\nexport class MessageCall extends Message<{\n callId: string;\n functionMarkerKey: string;\n props: any[];\n}> {\n constructor(payload: typeof MessageCall.prototype.payload) {\n super(MessageType.Call, payload);\n }\n}\n\nexport class MessageExposeAPI extends Message<\n {\n type: string;\n } & Record<string, any>\n> {\n constructor(payload: typeof MessageExposeAPI.prototype.payload) {\n super(MessageType.ExposeAPI, payload);\n }\n}\n","import {\n Message,\n MessageCall,\n MessageCleanup,\n MessageExposeAPI,\n MessageResponse,\n MessageResponseError,\n MessageType,\n} from './Message';\nimport { errorMessage, internalErrorMessage } from './error';\nimport { AbstractHandshake } from './HandshakeStrategy';\n\nconst buildFunctionMarkerKey = (correlationId: string, path: string) => {\n return `${correlationId}_${path}`;\n};\n\nexport type IMessageCallbacks = Partial<{\n [MessageType.Cleanup]: (message: MessageCleanup) => void;\n [MessageType.Response]: (\n message: MessageResponse | MessageResponseError,\n ) => void;\n [MessageType.Call]: (message: MessageCall) => void;\n [MessageType.ExposeAPI]: (message: MessageExposeAPI) => void;\n}>;\n\nexport abstract class ThreadChannel {\n protected abstract port: MessagePort | undefined;\n protected abstract messageEvents: IMessageCallbacks;\n\n #registry = new FinalizationRegistry<{\n functionMarkerKey: string;\n callId?: string;\n }>((params) => {\n this.postMessage(new MessageCleanup(params));\n });\n\n #messageEvents: IMessageCallbacks = {\n [MessageType.Cleanup]: (message) => {\n const functionMarkerKey = message.payload.functionMarkerKey;\n const callId = message.payload.callId;\n\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this.#functionMarkers[functionMarkerKey];\n\n if (callId) {\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this.#pendingFunctionResponse[callId];\n }\n },\n /**\n * Return function response between threads\n */\n [MessageType.Response]: async (message) => {\n const callId = message.payload.callId;\n const _errorMessage = (message as MessageResponseError).payload\n .errorMessage;\n\n if (_errorMessage) {\n const errorStack = (message as MessageResponseError).payload.errorStack;\n\n if (errorStack) {\n const error = new Error(_errorMessage);\n error.stack = (message as MessageResponseError).payload.errorStack;\n\n this.#pendingFunctionResponse[callId]?.reject(error);\n } else {\n this.#pendingFunctionResponse[callId]?.reject(_errorMessage);\n }\n } else {\n const response = (message as MessageResponse).payload.response;\n this.#pendingFunctionResponse[callId]?.resolve(response);\n }\n\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this.#pendingFunctionResponse[callId];\n },\n /**\n * Calling function between threads\n */\n [MessageType.Call]: async (message) => {\n const functionMarkerKey = message.payload.functionMarkerKey;\n const marker = this.#functionMarkers[functionMarkerKey];\n\n if (!marker) {\n this.postMessage(\n new MessageResponseError({\n callId: message.payload.callId,\n errorMessage: errorMessage('function is not available'),\n }),\n );\n\n return;\n }\n\n /**\n * TODO: for debugging purposes – check if original function still exists\n */\n try {\n const response = await marker.value(...(message.payload.props ?? []));\n\n this.postMessage(\n new MessageResponse({\n callId: message.payload.callId,\n response,\n }),\n );\n } catch (error: unknown) {\n this.postMessage(\n new MessageResponseError({\n callId: message.payload.callId,\n /**\n * for better DX we need to pass Error object to keep stack trace available\n * but in some cases our custom error messages are not serialized correctly\n */\n errorMessage: (error as Error).message,\n errorStack: (error as Error).stack,\n }),\n );\n }\n },\n };\n\n #functionMarkers: Record<\n string,\n {\n path: string;\n value: (...args: any) => any;\n }\n > = {};\n\n #pendingFunctionResponse: Record<\n string,\n { resolve: Function; reject: Function }\n > = {};\n\n protected queue: Message[] = [];\n\n protected isConnected = false;\n\n protected constructor(private handshake: AbstractHandshake) {}\n\n abstract init(): Promise<void>;\n\n protected async run(port?: MessagePort) {\n return this.handshake.run(port);\n }\n\n protected registerMessageListener() {\n if (!this.port) {\n throw new Error(\n internalErrorMessage(\n 'it is not possible to listen on port events because port is not defined',\n ),\n );\n }\n\n this.port.onmessage = (e) => {\n this.onMessage(e);\n };\n }\n\n protected onMessage(event: MessageEvent) {\n const message = Message.fromEvent(event.data, (correlationId, path) => {\n const replacedFunction = this.replaceTransferredFunction(\n correlationId,\n path,\n );\n\n this.#registry.register(replacedFunction, {\n functionMarkerKey: buildFunctionMarkerKey(correlationId, path),\n // callId: message.payload?.callId,\n });\n\n return replacedFunction;\n });\n\n this.#messageEvents[message.type]?.(message);\n this.messageEvents[message.type]?.(message);\n }\n\n protected postMessage(message: Message) {\n if (!this.port) {\n throw new Error(\n internalErrorMessage(\n 'it is not possible to post message on port because port is not defined',\n ),\n );\n }\n\n this.port.postMessage(\n message.serialize(this.registerTransferredFunction.bind(this)),\n );\n }\n\n registerTransferredFunction(\n correlationId: string,\n path: string,\n value: (...args: any) => any,\n ) {\n const functionMarkerKey = buildFunctionMarkerKey(correlationId, path);\n\n this.#functionMarkers[functionMarkerKey] = {\n path,\n value,\n };\n }\n\n replaceTransferredFunction(correlationId: string, path: string) {\n return (...props: any[]) => {\n const callId = `CALL-${crypto.randomUUID()}`;\n\n this.postMessage(\n new MessageCall({\n callId,\n functionMarkerKey: buildFunctionMarkerKey(correlationId, path),\n props,\n }),\n );\n\n return new Promise((resolve, reject) => {\n // TODO: check never resolved promise\n this.#pendingFunctionResponse[callId] = { resolve, reject };\n });\n };\n }\n\n protected flush() {\n if (!this.port) {\n return;\n }\n\n this.queue.forEach((message) => {\n this.postMessage(message);\n });\n\n this.queue = [];\n }\n}\n","import { Message, MessageType } from './Message';\nimport { IMessageCallbacks, ThreadChannel } from './ThreadChannel';\nimport { errorMessage, internalErrorMessage } from './error';\nimport { AbstractHandshake } from './HandshakeStrategy';\n\nexport class ConsumerChannel extends ThreadChannel {\n protected port: MessagePort | undefined = undefined;\n\n protected messageEvents: IMessageCallbacks = {};\n\n constructor(handshake: AbstractHandshake) {\n super(handshake);\n void this.init();\n }\n\n async init() {\n const port = await this.run();\n if (port) {\n this.port = port;\n this.registerMessageListener();\n /**\n * flush all messages which were stored\n * before handshake is done\n */\n this.flush();\n } else {\n console.error(\n internalErrorMessage(\n 'consumer did not receive message port from the host',\n ),\n );\n }\n }\n\n public expose(instance: any) {\n if (!instance.type) {\n throw new Error(\n errorMessage('wrong exposed API instance, \"type\" property is required'),\n );\n }\n\n this.queue.push(new Message(MessageType.ExposeAPI, instance));\n this.flush();\n }\n}\n","import { MessageType } from './Message';\nimport { IMessageCallbacks, ThreadChannel } from './ThreadChannel';\nimport { AbstractHandshake } from './HandshakeStrategy';\n\nexport type WithPromiseFunctions<T> = {\n [K in keyof T]: T[K] extends (...args: infer Args) => infer Result\n ? (...args: Args) => Promise<WithPromiseFunctions<Result>>\n : T[K] extends Record<string, unknown>\n ? WithPromiseFunctions<T[K]>\n : T[K];\n};\n\nexport class HostChannel extends ThreadChannel {\n #consumerAPIInstances: Record<string, any> = {};\n #consumerAPIInstancesResolvers: {\n type: string;\n cb: (instance: any) => void;\n }[] = [];\n\n #messageChannel = new MessageChannel();\n protected port = this.#messageChannel.port1;\n\n protected messageEvents: IMessageCallbacks = {\n [MessageType.ExposeAPI]: (message) => {\n const pendingTypeInstances = this.#consumerAPIInstancesResolvers.filter(\n ({ type }) => type === message.payload.type,\n );\n\n this.#consumerAPIInstancesResolvers =\n this.#consumerAPIInstancesResolvers.filter(\n ({ type }) => type !== message.payload.type,\n );\n\n pendingTypeInstances.forEach(({ cb }) => {\n cb(message.payload);\n });\n },\n };\n\n constructor(handshake: AbstractHandshake) {\n super(handshake);\n void this.init();\n }\n\n async init() {\n await this.run(this.#messageChannel.port2);\n this.registerMessageListener();\n }\n\n public waitAPI<TInstance = any>(\n type: string,\n ): Promise<WithPromiseFunctions<TInstance>> {\n return new Promise((resolve) => {\n this.onAPICallback<TInstance>(type, (_workerApi) => {\n resolve(_workerApi);\n });\n });\n }\n\n public onAPICallback<TInstance = any>(\n type: string,\n cb: (instance: WithPromiseFunctions<TInstance>) => void,\n ) {\n if (this.#consumerAPIInstances[type]) {\n cb(this.#consumerAPIInstances[type]);\n return;\n }\n\n this.#consumerAPIInstancesResolvers.push({\n type,\n cb,\n });\n }\n}\n","export abstract class AbstractHandshake {\n constructor(\n protected communicationAPI: {\n postMessage: (message: string, ports: MessagePort[]) => void;\n onMessage: (cb: (event: MessageEvent) => void) => () => void;\n },\n ) {}\n\n // abstract iframe: {\n // host: (frame: HTMLIFrameElement) => AbstractHandshake;\n // consumer: () => AbstractHandshake;\n // };\n //\n // abstract worker: {\n // host: (worker: Worker) => AbstractHandshake;\n // consumer: () => AbstractHandshake;\n // };\n\n abstract run(port: MessagePort | undefined): Promise<MessagePort | undefined>;\n}\n","import { internalErrorMessage } from '../error';\nimport { AbstractHandshake } from './AbstractHandshake';\n\nenum MemberType {\n Consumer = 'Consumer',\n Host = 'Host',\n}\n\nenum HandshakeMessageType {\n Greeting = 'Greeting',\n Port = 'Port',\n RequestPort = 'RequestPort',\n}\n\nexport class BothDirectionalHandshake extends AbstractHandshake {\n static iframe = {\n host: (frame: HTMLIFrameElement) => {\n return new BothDirectionalHandshake({\n postMessage: (message, ports) => {\n const contentWindow = frame.contentWindow;\n if (!contentWindow) {\n // in 99% cases it means iframe was removed from the DOM\n return;\n }\n\n contentWindow!.postMessage(message, '*', ports);\n },\n onMessage: (cb) => {\n const _cb = (event: MessageEvent) => {\n if (\n event.origin !== new URL(frame.src).origin ||\n frame.contentWindow !== event.source\n ) {\n return;\n }\n // TODO: check origin and host\n // to be sure this is the same iframe we are expecting\n\n cb(event);\n };\n\n globalThis!.addEventListener('message', _cb);\n return () => globalThis!.removeEventListener('message', _cb);\n },\n });\n },\n consumer: () => {\n return new BothDirectionalHandshake({\n postMessage: (message) => {\n globalThis.parent.postMessage(message, '*');\n },\n onMessage: (cb) => {\n globalThis.addEventListener('message', cb);\n\n return () => {\n globalThis.removeEventListener('message', cb);\n };\n },\n });\n },\n };\n static worker = {\n host: (worker: Worker) => {\n return new BothDirectionalHandshake({\n postMessage: (message, ports) => {\n worker.postMessage(message, ports);\n },\n onMessage: (cb) => {\n worker.addEventListener('message', cb);\n return () => worker.removeEventListener('message', cb);\n },\n });\n },\n consumer: () => {\n return new BothDirectionalHandshake({\n postMessage: (message) => {\n globalThis.postMessage(message);\n },\n onMessage: (cb) => {\n globalThis.addEventListener('message', cb);\n\n return () => {\n globalThis.removeEventListener('message', cb);\n };\n },\n });\n },\n };\n\n #unsubscribe?: () => void;\n #isConnected = false;\n #correlationId: string | null = null;\n\n run(port: MessagePort | undefined) {\n return new Promise<MessagePort | undefined>((resolve) => {\n if (port) {\n this.#startAsHost(port, () => resolve(undefined));\n } else {\n this.#startAsConsumer(resolve);\n }\n });\n }\n\n #startAsHost(port: MessagePort, resolve: () => void) {\n if (this.#isConnected) {\n return;\n }\n\n if (!port) {\n throw new Error(\n internalErrorMessage('port should exists on host handshake'),\n );\n }\n\n const memberId = `${MemberType.Host}-${performance.now()}`;\n\n /**\n * send the Greeting message at the start\n */\n this.communicationAPI.postMessage(\n JSON.stringify({\n memberId,\n type: HandshakeMessageType.Greeting,\n }),\n [],\n );\n\n this.#subscribe(memberId, (message) => {\n if (this.#isConnected) {\n return;\n }\n\n switch (message.type) {\n /**\n * on Greeting event from consumer response with Greeting from host\n * Consumer should send RequestPort event\n */\n case HandshakeMessageType.Greeting: {\n this.communicationAPI.postMessage(\n JSON.stringify({\n memberId,\n type: HandshakeMessageType.Greeting,\n }),\n [],\n );\n\n break;\n }\n /**\n * on RequestPort event from consumer\n * response with the port\n */\n case HandshakeMessageType.RequestPort: {\n this.#isConnected = true;\n\n this.communicationAPI.postMessage(\n JSON.stringify({\n memberId,\n targetMemberId: message.memberId,\n type: HandshakeMessageType.Port,\n }),\n [port],\n );\n\n this.#unsubscribe?.();\n resolve();\n\n break;\n }\n }\n });\n }\n\n #startAsConsumer(resolve: (port?: MessagePort) => void) {\n if (this.#isConnected) {\n return;\n }\n\n const memberId = `${MemberType.Consumer}-${performance.now()}`;\n\n /**\n * send the Greeting message at the start\n */\n this.communicationAPI.postMessage(\n JSON.stringify({\n memberId,\n type: HandshakeMessageType.Greeting,\n }),\n [],\n );\n\n this.#subscribe(memberId, (message, port) => {\n if (this.#isConnected) {\n return;\n }\n\n switch (message.type) {\n /**\n * on Greeting from host\n * response with simple RequestPort\n */\n case HandshakeMessageType.Greeting: {\n this.communicationAPI.postMessage(\n JSON.stringify({\n memberId,\n type: HandshakeMessageType.RequestPort,\n }),\n [],\n );\n\n break;\n }\n /**\n * on Port from host\n * consumer should receive the port\n */\n case HandshakeMessageType.Port: {\n if (message.targetMemberId !== memberId) {\n return;\n }\n\n this.#isConnected = true;\n this.#unsubscribe?.();\n resolve(port);\n\n break;\n }\n }\n });\n }\n\n #subscribe(memberId: string, cb: (data: any, port?: MessagePort) => void) {\n this.#unsubscribe?.();\n\n this.#unsubscribe = this.communicationAPI.onMessage((event) => {\n try {\n const message =\n typeof event.data === 'string' ? JSON.parse(event.data) : ({} as any);\n\n if (!message.memberId || message.memberId === memberId) {\n return;\n }\n\n cb(message, event.ports[0]);\n } catch (e: unknown) {\n console.error(e);\n }\n });\n }\n}\n","import { BothDirectionalHandshake } from '../HandshakeStrategy';\nimport { ConsumerChannel } from '../ConsumerChannel';\n\nexport class IFrameConsumerChannel extends ConsumerChannel {\n constructor() {\n super(BothDirectionalHandshake.iframe.consumer());\n }\n}\n","import { BothDirectionalHandshake } from '../HandshakeStrategy';\nimport { HostChannel } from '../HostChannel';\n\nexport class IFrameHostChannel extends HostChannel {\n constructor(frame: HTMLIFrameElement) {\n super(BothDirectionalHandshake.iframe.host(frame));\n }\n}\n","import { ConsumerChannel } from '../ConsumerChannel';\nimport { BothDirectionalHandshake } from '../HandshakeStrategy';\n\nexport class WorkerConsumerChannel extends ConsumerChannel {\n constructor() {\n super(BothDirectionalHandshake.worker.consumer());\n }\n}\n","import { BothDirectionalHandshake } from '../HandshakeStrategy';\nimport { HostChannel } from '../HostChannel';\n\nexport class WorkerHostChannel extends HostChannel {\n constructor(worker: Worker) {\n super(BothDirectionalHandshake.worker.host(worker));\n }\n}\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 { 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 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\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\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';\n\nimport { WorkerEventsBridge } from '../../Events';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\nimport {\n ApplicationContext,\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 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 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","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 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\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\n//# sourceMappingURL=index.js.map\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 {\n PlatformAppEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport {\n APPLICATION_CONTEXT_KEY,\n EnvironmentContext,\n ApplicationContext,\n} from '@wix/editor-application-context';\n\nimport type { EditorPlatformApplication } from '../EditorPlatformApplication';\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { IApplicationSpec } from '../types';\n\nexport const APPLICATION_REGISTRY_KEY = '__APPLICATION_REGISTRY_KEY';\n\nexport type IApplicationRegistry = (\n _instance: EditorPlatformApplication,\n) => void;\n\nexport async function executeApplication(\n events: PlatformAppEventEmitter,\n spec: IApplicationSpec,\n bundle: string,\n): Promise<{\n instance: EditorPlatformApplication;\n}> {\n // eslint-disable-next-line no-new-func\n const executable = new Function(\n APPLICATION_CONTEXT_KEY,\n APPLICATION_REGISTRY_KEY,\n bundle,\n );\n\n let instance: EditorPlatformApplication | undefined;\n\n const applicationRegistryCallback: IApplicationRegistry = (_instance) => {\n if (instance) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application registry called more than once',\n ).withAppDefinitionId(spec.appDefinitionId);\n }\n\n if (_instance.type !== spec.type) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application has different type',\n )\n .withMessage('expected type', spec.type)\n .withMessage('received type', _instance.type);\n }\n\n instance = _instance;\n };\n\n try {\n const context = { ...spec };\n\n executable.call(\n null,\n new ApplicationContext(context, await EnvironmentContext.getInstance()),\n applicationRegistryCallback,\n );\n } catch (e: unknown) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n (e as Error).message,\n )\n .withAppDefinitionId(spec.appDefinitionId)\n .withParentError(e as Error);\n }\n\n return new Promise((resolve, reject) => {\n const unsubscribe = events.subscribe((event) => {\n const timeoutId = setTimeout(() => {\n clearTimeout(timeoutId);\n unsubscribe();\n\n if (!instance) {\n reject(\n createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application registry was not called, threw by timeout',\n ).withAppDefinitionId(spec.appDefinitionId),\n );\n }\n }, 5000);\n\n if (\n event.type === PlatformAppEvent.ApplicationInit &&\n event.meta.appDefinitionId === spec.appDefinitionId\n ) {\n clearTimeout(timeoutId);\n unsubscribe();\n\n if (!instance) {\n reject(\n createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application registry was not called',\n ).withAppDefinitionId(spec.appDefinitionId),\n );\n }\n\n resolve({ instance: instance! });\n }\n });\n });\n}\n","import {\n PlatformAppEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport { EventType } from '@wix/public-editor-platform-interfaces';\n\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { EditorPlatformApplication } from '../EditorPlatformApplication';\nimport { type IApplicationSpec, type IPrivateAPIFixMe } from '../types';\nimport { executeApplication } from './executeApplication';\n\nexport class PlatformApplicationContainer {\n #apps: Record<string, EditorPlatformApplication> = {};\n\n readonly #privateAPI: IPrivateAPIFixMe;\n readonly #events: PlatformAppEventEmitter;\n\n constructor(privateApi: IPrivateAPIFixMe, events: PlatformAppEventEmitter) {\n this.#privateAPI = privateApi;\n this.#events = events;\n\n this.#events.subscribe((event) => {\n switch (event.type) {\n case PlatformAppEvent.HostEvent: {\n if (event.payload.type === EventType.removeAppCompleted) {\n void this.#events.withEvent(\n this.#events.factories.createApplicationRemovedEvent(\n event.payload.appDefinitionId!,\n ),\n () => {\n return this.removeApplication(event.payload.appDefinitionId!);\n },\n );\n }\n break;\n }\n }\n });\n }\n\n public async runApplication(appSpec: IApplicationSpec) {\n const bundle = await this.loadApplication(appSpec);\n const instance = await this.executeApplication(appSpec, bundle);\n\n this.setApplication(appSpec.appDefinitionId, instance);\n\n return instance;\n }\n\n private setApplication(\n appDefId: string,\n instance: EditorPlatformApplication,\n ) {\n this.#apps[appDefId] = instance;\n\n void this.#events.withEvent(\n this.#events.factories.createApplicationApiInitEvent(\n appDefId,\n // TODO: both types are set here...\n // @ts-expect-error TODO: fix me\n instance?.api?.private ? 'private' : 'public',\n ),\n () => {\n // NOTE: sometimes I saw this method was called while application was not executed\n this.#privateAPI.applicationManager.setApplication(instance);\n },\n );\n }\n\n public getApplication(appDefId: string) {\n return this.#apps[appDefId];\n }\n\n public getAppDefinitionIds() {\n return Object.keys(this.#apps);\n }\n\n private removeApplication(appDefinitionId: string) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.#apps[appDefinitionId];\n }\n\n private async loadApplication(appSpec: IApplicationSpec) {\n const url = appSpec.url;\n\n return this.#events.withEvent(\n this.#events.factories.createApplicationLoadEvent(appSpec, url),\n\n async () => {\n try {\n return await this.loadApplicationBundle(url);\n } catch (e) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationLoadError,\n )\n .withUrl(url)\n .withAppDefinitionId(appSpec.appDefinitionId)\n .withParentError(e as any);\n }\n },\n );\n }\n\n private async loadApplicationBundle(url: string) {\n /**\n * NOTE: we don't use wix http client here\n * because this code is public, while http client is private\n */\n const res = await fetch(url, {\n method: 'GET',\n });\n\n const isSuccessfulResponse = res.status >= 200 && res.status <= 299;\n\n if (!isSuccessfulResponse) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationFetchError,\n ).withUrl(url);\n }\n\n return res.text();\n }\n\n private async executeApplication(appSpec: IApplicationSpec, bundle: string) {\n return this.#events.withEvent(\n this.#events.factories.createApplicationExecuteEvent(\n appSpec,\n appSpec.url,\n ),\n async () => {\n const { instance } = await executeApplication(\n this.#events,\n appSpec,\n bundle,\n );\n return instance;\n },\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 { IApplicationSpec, IPrivateAPIFixMe } from '../../types';\nimport {\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\n\nimport { WorkerEventsBridge } from '../../Events';\n\nimport { PlatformApplicationContainer } from '../../PlatformApplicationContainer';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\nimport {\n EnvironmentContext,\n PlatformEnvironment,\n} from '@wix/editor-application-context';\n\nexport class PlatformWorkerAPI extends AbstractEnvironmentAPI<PlatformConsumerEnvironmentAPIType.Worker> {\n public type: PlatformConsumerEnvironmentAPIType.Worker =\n PlatformConsumerEnvironmentAPIType.Worker;\n\n #events = new PlatformAppEventEmitter();\n\n #eventsBridge = new WorkerEventsBridge(this.#events);\n #container: PlatformApplicationContainer | null = null;\n #privateAPI: IPrivateAPIFixMe;\n\n #pendingWaiters: ((value: this) => void)[] = [];\n\n constructor() {\n super(PlatformConsumerEnvironmentAPIType.Worker);\n }\n\n create() {}\n\n async initEnvironment(props: {\n // TODO: should be Promise response in types\n buildPrivateAPI: (config: any) => IPrivateAPIFixMe;\n }) {\n const { buildPrivateAPI } = props;\n this.#privateAPI = await buildPrivateAPI({\n // TODO: should be per application (within the container before app execution)\n type: 'EDITOR_ADDON',\n });\n\n await EnvironmentContext.inject({\n environment: PlatformEnvironment.Worker,\n events: this.#events,\n privateApi: this.#privateAPI,\n applicationAPIs: {},\n });\n\n this.#container = new PlatformApplicationContainer(\n this.#privateAPI,\n this.#events,\n );\n\n this.#pendingWaiters.forEach((res) => res(this));\n }\n\n async notify(event: IPlatformPrivateEvent) {\n await this.waitReady();\n\n this.#eventsBridge.notify(event);\n }\n\n subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.#eventsBridge.subscribe(cb);\n }\n\n async runApplication(app: IApplicationSpec) {\n await this.waitReady();\n\n await this.#container!.runApplication(app);\n }\n\n public waitReady(): Promise<this> {\n return new Promise((res) => {\n if (this.#privateAPI) {\n return res(this);\n }\n\n this.#pendingWaiters.push(res);\n });\n }\n}\n","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 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\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\n//# sourceMappingURL=index.js.map\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\nimport { AccessToken } from '@wix/public-editor-platform-interfaces';\n\nexport enum EditorPlatformSDKAuthErrorCode {\n EmptyAppAuthInstance = 'EmptyAppAuthInstance',\n EmptyAppDefinitionId = 'EmptyAppDefinitionId',\n}\n\nclass EditorPlatformSDKAuthError extends BaseError<EditorPlatformSDKAuthErrorCode> {\n state: Partial<{\n appDefinitionId: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformSDKAuthErrorCode) {\n super(message, code, 'Auth Strategy Error');\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n}\n\nexport const createEditorPlatformSDKAuthError = createErrorBuilder<\n EditorPlatformSDKAuthErrorCode,\n EditorPlatformSDKAuthError\n>(EditorPlatformSDKAuthError);\n\nfunction hasEnoughTimeUntilExpiry(\n expires: Date | undefined,\n expiryBuffer: number,\n) {\n const now = Date.now();\n const expiryTime = expires ? new Date(expires).getTime() : null;\n return expiryTime && expiryTime - now > expiryBuffer;\n}\n\nconst ACCESS_TOKEN_EXPIRY_GRACE_PERIOD = 30 * 60 * 1000; // half an hour\n\nexport const auth = () => {\n let instance: AccessToken;\n\n return {\n getAuthHeaders: async () => {\n const context = await ApplicationContext.getInstance();\n const bindings = context.getBindings();\n const privateAPI = context.getPrivateAPI();\n\n if (!bindings.appDefinitionId) {\n throw createEditorPlatformSDKAuthError(\n EditorPlatformSDKAuthErrorCode.EmptyAppDefinitionId,\n );\n }\n\n if (\n !instance ||\n hasEnoughTimeUntilExpiry(\n instance.expires,\n ACCESS_TOKEN_EXPIRY_GRACE_PERIOD,\n )\n ) {\n instance = await privateAPI.auth.getAccessToken(\n bindings.appDefinitionId,\n await privateAPI.info.getMetaSiteId(),\n );\n }\n\n if (!instance?.token) {\n console.error(\n createEditorPlatformSDKAuthError(\n EditorPlatformSDKAuthErrorCode.EmptyAppAuthInstance,\n ).withAppDefinitionId(bindings.appDefinitionId),\n );\n\n return {\n headers: {\n Authorization: '',\n },\n };\n }\n\n return {\n headers: {\n Authorization: instance.token,\n },\n };\n },\n };\n};\n","import {\n IFrameConsumerChannel,\n WorkerConsumerChannel,\n} from '@wix/editor-platform-transport';\nimport { PlatformFrameAPI } from '@wix/editor-application/platform-frame-api';\nimport { PlatformWorkerAPI } from '@wix/editor-application/platform-worker-api';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var _EP_TRANSPORT_INIT_KEY: boolean;\n}\n\nconst INIT_KEY = '_EP_TRANSPORT_INIT_KEY';\n\n/**\n * small workaround to run init only for a one time\n */\nif (!globalThis[INIT_KEY]) {\n const isWorker = typeof importScripts === 'function';\n\n /**\n * TODO: probably we can try to split this code somehow\n * and load the only API according to the current env.\n */\n if (isWorker) {\n const channel = new WorkerConsumerChannel();\n channel.expose(new PlatformWorkerAPI());\n } else {\n const channel = new IFrameConsumerChannel();\n channel.expose(new PlatformFrameAPI());\n }\n\n globalThis[INIT_KEY] = true;\n}\n","import './env';\n\nimport { createHostModule, HostModule } from '@wix/sdk-runtime/host-modules';\nimport { Host } from '@wix/sdk-types';\nimport {\n ApplicationContext,\n EnvironmentContext,\n IAddonContext,\n IEditorApplicationContext,\n} from '@wix/editor-application-context';\n\ninterface IHostContexts {\n environmentContext: EnvironmentContext;\n applicationContext: ApplicationContext<\n IEditorApplicationContext | IAddonContext\n >;\n}\n\ntype UnwrapShape<T> = {\n [K in keyof T]: T[K] extends (contexts: IHostContexts) => infer R ? R : never;\n};\n\nexport class PlatformSDKShape<\n TShape extends Record<\n string,\n (contexts: IHostContexts) => (...args: any[]) => any\n >,\n> {\n constructor(\n public namespace: string,\n private shape: TShape,\n ) {\n // Object.assign(this.shape, {\n // [Symbol(`platform-sdk-shape-namespace`)]: this.namespace,\n // });\n }\n\n build() {\n return createHostModule<Host, TShape>(\n Object.fromEntries(\n Object.entries(this.shape).map(([key, value]) => [\n key,\n (host: IHostContexts) => {\n /**\n * this is case when shapes are used as a host modules,\n * meaning without calling the createClient, and use one from the context\n */\n if (host?.environmentContext && host?.applicationContext) {\n return async (...args: any) => {\n const [environmentContext, applicationContext] =\n await Promise.all([\n host.environmentContext,\n host.applicationContext,\n ]);\n\n return value({\n environmentContext,\n applicationContext,\n })(...args);\n };\n }\n\n /**\n * the fallback to platform's contexts\n * if for some reason they are not available at the host.\n * for instance:\n * - `createClient` is not created or created with a wrong configuration\n */\n return async (...args: any) => {\n const [environmentContext, applicationContext] =\n await Promise.all([\n EnvironmentContext.getInstance(),\n ApplicationContext.getInstance(),\n ]);\n\n return value({\n environmentContext,\n applicationContext,\n })(...args);\n };\n },\n ]),\n ) as unknown as { [K in keyof TShape]: () => TShape[K] },\n ) as UnwrapShape<TShape> & HostModule<UnwrapShape<TShape>, Host>;\n }\n}\n","import { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst applicationShape = new PlatformSDKShape('application', {\n getPrivateAPI({ applicationContext }) {\n return async <TApplicationPrivateAPI = any>() => {\n return applicationContext.getPrivateApplicationAPI() as TApplicationPrivateAPI;\n };\n },\n\n getPublicAPI({ applicationContext }) {\n return async <TApplicationPrivateAPI>(appDefinitionId: string) => {\n const privateAPI = applicationContext.getPrivateAPI();\n\n return privateAPI.applicationManager.getPublicApplicationAPI(\n appDefinitionId,\n ) as TApplicationPrivateAPI;\n };\n },\n\n getAppInstance({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n const bindings = applicationContext.getBindings();\n\n return privateAPI.info.getAppInstance(bindings.appDefinitionId);\n };\n },\n});\n\nexport default applicationShape.build();\n","import { IComponent } from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst componentsShape = new PlatformSDKShape('components', {\n getSelectedComponents({ applicationContext }) {\n return async (): Promise<IComponent[]> => {\n const privateAPI = applicationContext.getPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n\n return Promise.all(\n refs.map((ref: any) => privateAPI.components.getComponent(ref)),\n );\n };\n },\n});\n\nexport default componentsShape.build();\n","import {\n AppEventPayload,\n AllowedEvents,\n} from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst eventsShape = new PlatformSDKShape('events', {\n addEventListener({ applicationContext }) {\n return async (\n name: any,\n // TODO: fix types\n cb: (payload: AppEventPayload<AllowedEvents>) => void,\n ) => {\n return applicationContext.getEvents().addEventListener(name, cb);\n };\n },\n});\n\nexport default eventsShape.build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst infoShape = new PlatformSDKShape('info', {\n getViewMode({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.info.getViewMode();\n };\n },\n\n getLanguageCode({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.info.getLanguageCode();\n };\n },\n});\n\nexport default infoShape.build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum WidgetShapeErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n}\n\nclass WidgetShapeError extends BaseError<WidgetShapeErrorCode> {\n constructor(message: string, code: WidgetShapeErrorCode) {\n super(message, code, 'Widget Error');\n }\n}\n\nexport const createWidgetShapeError = createErrorBuilder<\n WidgetShapeErrorCode,\n WidgetShapeError\n>(WidgetShapeError);\n","import components from '../components';\nimport { createWidgetShapeError, WidgetShapeErrorCode } from './errors';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst getSelectedComponentRef = async () => {\n const selected = await components.getSelectedComponents();\n const compRef = selected[0]?.compRef;\n\n if (!compRef) {\n throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n};\n\nconst widgetShape = new PlatformSDKShape('widget', {\n getProp({ applicationContext }) {\n return async (propName: string): Promise<string> => {\n const privateAPI = applicationContext.getPrivateAPI();\n const compRef = await getSelectedComponentRef();\n\n return privateAPI.customElement.getAttribute(compRef, propName);\n };\n },\n setProp({ applicationContext }) {\n return async (propName: string, value: string): Promise<void> => {\n const privateAPI = applicationContext.getPrivateAPI();\n const compRef = await getSelectedComponentRef();\n\n await privateAPI.customElement.setAttribute(compRef, propName, value);\n };\n },\n});\n\nexport default widgetShape.build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { FontPickerOptions } from '@wix/editor-platform-sdk-types';\n\ninterface IColorValue {\n color: string;\n theme?: string;\n cssVariableName?: string;\n}\n\ninterface IFontValue {\n theme?: string;\n family?: string;\n size?: number;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n cssVariableName?: string;\n}\n\ninterface FontPickerValue {\n font: string;\n textDecoration?: string;\n}\n\ntype ColorPickerValue = string | null | undefined;\n\nconst UNDERLINE_DEFINITION = 'underline';\n\nfunction extractFontVar(fontString: string) {\n const trimmedFont = fontString.trim();\n const match = trimmedFont.match(/var\\((--[\\w-]+),\\s*(.+)\\)/);\n\n if (match) {\n return {\n variableName: match[1],\n fallbackValue: match[2]?.trim() ?? '',\n };\n } else {\n return {\n variableName: undefined,\n fallbackValue: trimmedFont,\n };\n }\n}\n\nfunction parseFontString(fontPickerValue?: FontPickerValue) {\n const font: IFontValue = {\n family: undefined,\n size: undefined,\n };\n\n if (fontPickerValue?.font) {\n const { variableName, fallbackValue } = extractFontVar(\n fontPickerValue.font,\n );\n font.cssVariableName = variableName;\n const parts = fallbackValue.match(/(?:([\"']).*?\\1|\\S)+/g) || [];\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n\n switch (part) {\n case 'bold':\n font.bold = true;\n break;\n case 'italic':\n font.italic = true;\n break;\n default:\n if (part?.endsWith('px')) {\n font.size = parseInt(part, 10);\n } else if (i === parts.length - 1) {\n font.family = part;\n } else {\n font.family = (font.family || '') + ' ' + part;\n }\n }\n }\n }\n if (fontPickerValue?.textDecoration) {\n font.underline = fontPickerValue.textDecoration === UNDERLINE_DEFINITION;\n }\n // since we wrap it with \"\" in the font string, we need to remove it\n font.family = font.family?.trim().replace(/['\"]+/g, '');\n\n return font;\n}\n\nfunction fontValueToCSS(fontValue: IFontValue): string {\n return `${\n fontValue.cssVariableName ? `var(${fontValue.cssVariableName}, ` : ''\n }${fontValue.italic ? 'italic ' : ''}${fontValue.bold ? 'bold ' : ''}${fontValue.size || 16}px ${\n // wrap each font family with quotes\n fontValue.family\n ?.split(',')\n .map((fontFamily) => `\"${fontFamily.replace(/['\"]+/g, '')}\"`)\n .join(',') || 'serif'\n }${fontValue.cssVariableName ? ')' : ''}`;\n}\n\nfunction parseColorString(\n colorPickerValue?: ColorPickerValue,\n): IColorValue | null {\n if (!colorPickerValue) {\n return null;\n }\n const colorString = colorPickerValue!;\n const match = colorString.match(/var\\((--[\\w-]+),\\s*(.+)\\)/);\n\n if (match) {\n return {\n cssVariableName: match[1],\n color: match[2]!,\n };\n } else {\n return {\n color: colorString,\n };\n }\n}\n\nfunction colorValueToCSS(colorValue?: IColorValue | null): string {\n if (!colorValue) {\n return '';\n }\n return colorValue.cssVariableName\n ? `var(${colorValue.cssVariableName}, ${colorValue.color})`\n : colorValue.color;\n}\n\ntype IFontValueInternal = {\n preset?: string;\n editorKey?: string;\n family?: string;\n size?: number;\n style: {\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n };\n htmlTag?: string;\n};\n\nconst fonts = {\n transformFontInternalValue: (value?: IFontValue): IFontValueInternal => {\n if (value) {\n const { theme, cssVariableName, bold, italic, underline, ...rest } =\n value;\n\n return {\n ...rest,\n style: {\n bold,\n italic,\n underline,\n },\n editorKey: cssVariableName || theme || '',\n };\n } else {\n return {\n editorKey: 'font_7',\n family: 'helvetica-w01-roman',\n size: 16,\n style: {},\n };\n }\n },\n};\n\nconst inputsShape = new PlatformSDKShape('inputs', {\n selectColor({ applicationContext }) {\n return async (\n value?: ColorPickerValue,\n options?: {\n onChange?: (value: ColorPickerValue) => void;\n },\n ): Promise<ColorPickerValue> => {\n const privateAPI = applicationContext.getPrivateAPI() as any;\n\n let colorValue: IColorValue | null = parseColorString(value);\n let colorResult = colorValueToCSS(colorValue);\n\n await privateAPI.inputs.openColorPicker(\n {\n color:\n colorValue?.cssVariableName ||\n colorValue?.theme ||\n colorValue?.color,\n },\n ({\n color,\n theme,\n cssVariableTheme,\n }: {\n color: string;\n theme: string;\n cssVariableTheme: string;\n isHover: boolean;\n }) => {\n colorValue = {\n color,\n theme,\n cssVariableName: cssVariableTheme,\n };\n colorResult = colorValueToCSS(colorValue);\n options?.onChange?.(colorResult);\n },\n );\n\n return colorResult;\n };\n },\n\n selectFont({ applicationContext }) {\n return async (\n value?: FontPickerValue,\n options?: {\n title?: string;\n panelSectionsDefinition?: Omit<\n FontPickerOptions['panelSectionsDefinition'],\n 'htmlTag'\n >;\n fontMaxSize?: number;\n fontMinSize?: number;\n onChange?: (value: FontPickerValue) => void;\n },\n ): Promise<FontPickerValue | undefined> => {\n const privateAPI = applicationContext.getPrivateAPI() as any;\n const fontValue = parseFontString(value);\n let _value = value;\n\n await privateAPI.inputs.openFontPickerV2(\n {\n ...options,\n panelSectionsDefinition: {\n ...options?.panelSectionsDefinition,\n htmlTag: 'hidden',\n },\n componentStyle: fonts.transformFontInternalValue(fontValue),\n },\n (font: IFontValue, accessibility: any) => {\n _value = {\n font: fontValueToCSS(font),\n textDecoration: font.underline ? UNDERLINE_DEFINITION : undefined,\n };\n options?.onChange?.(_value);\n },\n );\n\n return _value;\n };\n },\n});\n\nexport default inputsShape.build();\n","import type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\nimport {\n ApplicationContext,\n EnvironmentContext,\n} from '@wix/editor-application-context';\n\nexport const editorPlatformFrameHost = (): WixSDKTypes.Host & {\n environmentContext: Promise<EnvironmentContext>;\n applicationContext: Promise<ApplicationContext<any>>;\n essentials: {\n language?: string;\n locale?: string;\n };\n} => {\n const queryParams = new URLSearchParams(window.location.search);\n\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n environmentContext: EnvironmentContext.getInstance(),\n applicationContext: ApplicationContext.getInstance(),\n essentials: queryParams.has('essentials')\n ? JSON.parse(queryParams.get('essentials')!)\n : {},\n };\n};\n","import type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\nimport {\n ApplicationContext,\n EnvironmentContext,\n} from '@wix/editor-application-context';\n\nexport const editorPlatformWorkerHost = (): WixSDKTypes.Host & {\n environmentContext: Promise<EnvironmentContext>;\n applicationContext: Promise<ApplicationContext<any>>;\n} => {\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n environmentContext: EnvironmentContext.getInstance(),\n applicationContext: ApplicationContext.getInstance(),\n };\n};\n","import { auth } from './auth';\n\nexport { default as application } from './application';\nexport { default as components } from './components';\nexport { default as events } from './events';\nexport { default as info } from './info';\nexport { default as widget } from './widget';\nexport { default as inputs } from './inputs';\n\nimport { editorPlatformFrameHost } from './editorPlatformFrameHost';\nimport { editorPlatformWorkerHost } from './editorPlatformWorkerHost';\n\nexport const editor = {\n host: () => {\n const isWorker = typeof importScripts === 'function';\n\n if (isWorker) {\n return editorPlatformWorkerHost();\n }\n\n return editorPlatformFrameHost();\n },\n auth,\n};\n","import { editor } from '@wix/editor';\nimport { createClient } from '@wix/sdk';\n\nexport const enableClient = () => {\n const host = editor.host();\n const auth = editor.auth();\n\n const wixClient = createClient({\n auth,\n host,\n });\n wixClient.enableContext('module');\n};\n"],"mappings":"8LAAA,IAAAA,GAAAC,GAAAC,IAAA,cACA,OAAO,eAAeA,GAAS,aAAc,CAAE,MAAO,EAAK,CAAC,EAC5DA,GAAQ,UAAY,OAKpB,IAA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B,GAAS,WAAWI,CAAM,CAAA,CAC5B,EAGKA,CAAA,CACT,CAEJ,CAAC,EAEDE,GAAeP,GAAY,MAAM,ECxPpBQ,GAA0B,IAOlC,CACH,IAAMC,EAAc,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAEvD,MAAA,CACL,YAAa,CAAA,EACb,QAAS,CACP,aAAc,UACL,CAAE,YAAa,CAAA,CAAG,EAC3B,EAEF,mBAAoBrF,EAAmB,YAAY,EACnD,mBAAoBK,EAAmB,YAAY,EACnD,WAAYgF,EAAY,IAAI,YAAY,EACpC,KAAK,MAAMA,EAAY,IAAI,YAAY,CAAE,EACzC,CAAA,CAAC,CAET,ECvBaC,GAA2B,KAI/B,CACL,YAAa,CAAA,EACb,QAAS,CACP,aAAc,UACL,CAAE,YAAa,CAAA,CAAG,EAC3B,EAEF,mBAAoBtF,EAAmB,YAAY,EACnD,mBAAoBK,EAAmB,YAAY,CAAA,GCN1CkF,GAAS,CACpB,KAAM,IACa,OAAO,eAAkB,WAGjCD,GAAyB,EAG3BF,GAAwB,EAEjC,KAAAtE,EACF,ECpBO,IAAM0E,GAAe,IAAM,CAChC,IAAMC,EAAOC,GAAO,KAAK,EACnBC,EAAOD,GAAO,KAAK,EAEPE,GAAa,CAC7B,KAAAD,EACA,KAAAF,CACF,CAAC,EACS,cAAc,QAAQ,CAClC","names":["require_EventType","__commonJSMin","exports","EventType","require_dist","__commonJSMin","exports","__createBinding","o","m","k","k2","desc","__setModuleDefault","v","__importStar","mod","result","WixSDKTypes","EventType_1","BaseError","_BaseError","_message","_code","_prefix","message","displayName","__publicField","parent","x","state","acc","key","value","messages","_messages","parentError","parentErrorMessage","thrownErrorMessage","createErrorBuilder","factory","throwException","code","instance","EditorPlatformInternalError","BaseError","message","code","__publicField","host","createEditorPlatformInternalError","createErrorBuilder","_EventEmitter","__publicField","isSilent","queue","event","callback","uid","step","cb","result","e","EventEmitter","PlatformPrivateEvent","PlatformLifecycleEvent","PlatformAppEvent","PlatformAppEventsFactories","appDefinitionId","PlatformAppEventEmitter","app","url","scope","EventEmitter","__publicField","_DMEventsBridge","events","event","PlatformPrivateEvent","_event","DMEventsBridge","errorMessage","message","internalErrorMessage","FUNCTION_MARKER","ACCESSOR_MARKER","ACCESSOR_GET_POINTER","ACCESSOR_SET_POINTER","WITH_ACCESSOR_INDICATOR","NO_ACCESSOR_INDICATOR","PATH_SEPARATOR","ENCODER_MARKER","ENCODER_EMPTY_MARKER","extractPointer","pointer","isFinalNode","instance","isSerializableType","beautifyPath","path","beautifyBreadcrumbs","breadcrumbs","createStructureEncoder","marker","config","arrayEncoder","next","value","index","key","_key","mapEncoder","setEncoder","objectEncoder","root","forEachMember","members","parent","encoders","getDescriptor","obj","_instance","descriptor","callback","ancestors","getContextPointer","_breadcrumbs","acc","iterateStructure","p","encoder","_encoder","serialize","input","registerFunctionMarker","buffer","appendValue","appendFunction","args","context","_value","deserialize","replaceFunctionMarker","pointers","i","point","has","_iterator","hasGetter","hasSetter","getter","MessageType","Message","_Message","type","payload","__publicField","correlationId","data","parsed","MessageCleanup","MessageResponse","MessageResponseError","MessageCall","buildFunctionMarkerKey","_registry","_messageEvents","_functionMarkers","_pendingFunctionResponse","ThreadChannel","handshake","__privateAdd","params","functionMarkerKey","callId","__privateGet","_errorMessage","error","response","port","e","event","replacedFunction","props","resolve","reject","ConsumerChannel","AbstractHandshake","communicationAPI","_unsubscribe","_isConnected","_correlationId","_BothDirectionalHandshake_instances","startAsHost_fn","startAsConsumer_fn","subscribe_fn","_BothDirectionalHandshake","__privateAdd","port","resolve","__privateMethod","__privateGet","internalErrorMessage","memberId","message","_a","__privateSet","cb","event","e","__publicField","frame","ports","contentWindow","_cb","worker","BothDirectionalHandshake","IFrameConsumerChannel","ConsumerChannel","WorkerConsumerChannel","ConsumerChannel","BothDirectionalHandshake","WorkerEventsBridge","platformAppEvents","event","PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","cb","PlatformConsumerEnvironmentAPIType","AbstractEnvironmentAPI","env","EditorPlatformApplicationContextErrorCode","EditorPlatformApplicationContextErrorCode2","EditorPlatformApplicationContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformApplicationContextError","createErrorBuilder","transformEventPayload","eventPayload","privateAPI","componentRefs","components","ref","ApplicationBoundEvents","events","type","payload","eventType","fn","isAppMatch","transformPayload","WAIT_INJECTED_TIMEOUT","WAIT_INJECTED_RETRY_COUNT","ContextInjectionStatus","uuid","resolve","reject","injected","timeoutId","retryCount","timeout","error","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","PlatformEnvironment2","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","applicationContext","environment","ApplicationContext","DESIGN_SYSTEM_STYLES_MAP","PlatformFrameAPI","__privateAdd","_events","PlatformAppEventEmitter","_eventsBridge","__privateGet","_privateAPI","_applicationPrivateAPI","host","isAlreadyLoaded","link","props","applicationPrivateAPI","__privateSet","WorkerEventsBridge","platformAppEvents","event","PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","cb","EditorPlatformApplicationContextErrorCode","EditorPlatformApplicationContextErrorCode2","EditorPlatformApplicationContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformApplicationContextError","createErrorBuilder","transformEventPayload","eventPayload","privateAPI","componentRefs","components","ref","ApplicationBoundEvents","events","type","payload","eventType","fn","isAppMatch","transformPayload","WAIT_INJECTED_TIMEOUT","WAIT_INJECTED_RETRY_COUNT","ContextInjectionStatus","uuid","resolve","reject","injected","timeoutId","retryCount","timeout","error","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","PlatformEnvironment2","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","applicationContext","environment","ApplicationContext","EditorPlatformApplicationErrorCode","EditorPlatformApplicationError","apiMethod","apiType","createEditorPlatformApplicationError","APPLICATION_REGISTRY_KEY","executeApplication","spec","bundle","executable","instance","applicationRegistryCallback","_instance","e","unsubscribe","PlatformApplicationContainer","privateApi","__privateAdd","_apps","_privateAPI","_events","__privateSet","__privateGet","appSpec","appDefId","res","PlatformConsumerEnvironmentAPIType","AbstractEnvironmentAPI","env","PlatformWorkerAPI","PlatformAppEventEmitter","_eventsBridge","_container","_pendingWaiters","props","buildPrivateAPI","app","EditorPlatformApplicationContextErrorCode","EditorPlatformApplicationContextErrorCode2","EditorPlatformApplicationContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformApplicationContextError","createErrorBuilder","transformEventPayload","eventPayload","privateAPI","componentRefs","components","ref","ApplicationBoundEvents","events","event","type","payload","PlatformAppEvent","eventType","fn","isAppMatch","transformPayload","WAIT_INJECTED_TIMEOUT","WAIT_INJECTED_RETRY_COUNT","ContextInjectionStatus","uuid","resolve","reject","injected","timeoutId","retryCount","timeout","error","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","PlatformEnvironment2","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","applicationContext","environment","ApplicationContext","EditorPlatformSDKAuthError","createEditorPlatformSDKAuthError","hasEnoughTimeUntilExpiry","expires","expiryBuffer","now","expiryTime","ACCESS_TOKEN_EXPIRY_GRACE_PERIOD","auth","instance","bindings","INIT_KEY","WorkerConsumerChannel","PlatformWorkerAPI","IFrameConsumerChannel","PlatformFrameAPI","PlatformSDKShape","namespace","shape","createHostModule","key","value","host","args","applicationShape","index$4","componentsShape","refs","eventsShape","name","cb","index$3","infoShape","index$2","WidgetShapeErrorCode","WidgetShapeError","createWidgetShapeError","getSelectedComponentRef","compRef","widgetShape","propName","index$1","UNDERLINE_DEFINITION","extractFontVar","fontString","trimmedFont","match","parseFontString","fontPickerValue","font","variableName","fallbackValue","parts","i","part","fontValueToCSS","fontValue","fontFamily","parseColorString","colorPickerValue","colorString","colorValueToCSS","colorValue","fonts","theme","cssVariableName","bold","italic","underline","rest","inputsShape","options","colorResult","color","cssVariableTheme","_value","accessibility","index","editorPlatformFrameHost","queryParams","editorPlatformWorkerHost","editor","enableClient","host","editor","auth","createClient"]}
1
+ {"version":3,"sources":["../../../node_modules/@wix/public-editor-platform-interfaces/dist/EventType.js","../../../node_modules/@wix/public-editor-platform-interfaces/dist/Inputs.js","../../../node_modules/@wix/public-editor-platform-interfaces/dist/index.js","../../../node_modules/@wix/public-editor-platform-errors/src/BaseError.ts","../../../node_modules/@wix/public-editor-platform-errors/src/EditorPlatformInternalError.ts","../../../node_modules/@wix/public-editor-platform-events/src/EventEmitter.ts","../../../node_modules/@wix/public-editor-platform-events/src/PlatformPrivateEventEmitter.ts","../../../node_modules/@wix/public-editor-platform-events/src/PlatformAppEventEmitter.ts","../../../node_modules/@wix/public-editor-platform-events/src/DMEventsBridge.ts","../../../node_modules/@wix/editor-platform-transport/src/error.ts","../../../node_modules/@wix/editor-platform-transport/src/serializer/utils.ts","../../../node_modules/@wix/editor-platform-transport/src/serializer/encoders.ts","../../../node_modules/@wix/editor-platform-transport/src/serializer/serializer.ts","../../../node_modules/@wix/editor-platform-transport/src/Message.ts","../../../node_modules/@wix/editor-platform-transport/src/ThreadChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/ConsumerChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/HostChannel.ts","../../../node_modules/@wix/editor-platform-transport/src/Handshake/events.ts","../../../node_modules/@wix/editor-platform-transport/src/Handshake/AbstractHandshake.ts","../../../node_modules/@wix/editor-platform-transport/src/Handshake/HostHandshake.ts","../../../node_modules/@wix/editor-platform-transport/src/Handshake/ConsumerHandshake.ts","../../../node_modules/@wix/editor-platform-transport/src/endpoints/AbstractEndpoint.ts","../../../node_modules/@wix/editor-platform-transport/src/endpoints/IFrameConsumerEndpoint.ts","../../../node_modules/@wix/editor-platform-transport/src/endpoints/IFrameHostEndpoint.ts","../../../node_modules/@wix/editor-platform-transport/src/endpoints/WorkerConsumerEndpoint.ts","../../../node_modules/@wix/editor-platform-transport/src/endpoints/WorkerHostEndpoint.ts","../../../node_modules/@wix/editor-application/src/Events/WorkerEventsBridge.ts","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/AbstractEnvironmentAPI.ts","../../../node_modules/@wix/editor-platform-application-context/dist/esm/index.js","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/PlatformFrameAPI/PlatformFrameAPI.ts","../../../node_modules/@wix/editor-application/src/Events/WorkerEventsBridge.ts","../../../node_modules/@wix/editor-platform-application-context/dist/esm/index.js","../../../node_modules/@wix/editor-application/src/errors.ts","../../../node_modules/@wix/editor-application/src/PlatformApplicationContainer/executeApplication.ts","../../../node_modules/@wix/editor-application/src/PlatformApplicationContainer/PlatformApplicationContainer.ts","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/AbstractEnvironmentAPI.ts","../../../node_modules/@wix/editor-application/src/PlatformEnvironmentAPI/PlatformWorkerAPI/PlatformWorkerAPI.ts","../../../node_modules/@wix/editor-platform-application-context/dist/esm/index.js","../../../node_modules/@wix/editor/src/auth.ts","../../../node_modules/@wix/editor/src/env.ts","../../../node_modules/@wix/editor/src/PlatformSDKShape.ts","../../../node_modules/@wix/editor/src/application/index.ts","../../../node_modules/@wix/editor/src/components/index.ts","../../../node_modules/@wix/editor/src/events/index.ts","../../../node_modules/@wix/editor/src/info/index.ts","../../../node_modules/@wix/editor/src/widget/errors.ts","../../../node_modules/@wix/editor/src/widget/index.ts","../../../node_modules/@wix/editor/src/inputs/index.ts","../../../node_modules/@wix/editor/src/externalPanels.ts","../../../node_modules/@wix/editor/src/editorPlatformFrameHost.ts","../../../node_modules/@wix/editor/src/editorPlatformWorkerHost.ts","../../../node_modules/@wix/editor/src/index.ts","../src/editor.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.EventType = void 0;\n/**\n * Duplicated types from editor-platform-sdk-types/src/events/EventType.ts\n * to allow use them in public packages\n */\nvar EventType;\n(function (EventType) {\n EventType[\"removeAppCompleted\"] = \"removeAppCompleted\";\n EventType[\"componentSelectionChanged\"] = \"componentSelectionChanged\";\n EventType[\"appInstalled\"] = \"appInstalled\";\n EventType[\"appUpdateCompleted\"] = \"appUpdateCompleted\";\n})(EventType || (exports.EventType = EventType = {}));\n","\"use strict\";\n/**\n * Duplicated types from editor-platform-private-api / HostAPIBase.ts\n * to allow use them in public packages\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || (function () {\n var ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n };\n return function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n };\n})();\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.EventType = exports.WixSDKTypes = void 0;\nconst WixSDKTypes = __importStar(require(\"@wix/sdk-types\"));\nexports.WixSDKTypes = WixSDKTypes;\nvar EventType_1 = require(\"./EventType\");\nObject.defineProperty(exports, \"EventType\", { enumerable: true, get: function () { return EventType_1.EventType; } });\n__exportStar(require(\"./Inputs\"), exports);\n","export abstract class BaseError<TErrorCode> extends Error {\n protected state: Record<string, string> = {};\n\n displayName: string;\n prefix: string;\n errorMessage: string;\n\n parent: Error | BaseError<TErrorCode> | undefined;\n\n messages: string[][] = [];\n\n public code: TErrorCode;\n\n protected constructor(_message: string, _code: TErrorCode, _prefix: string) {\n const message = _message ? ` ${_message}` : '';\n const displayName = `[${_prefix}]#${_code}`;\n\n super(`${displayName}.${message}`);\n\n this.displayName = displayName;\n this.errorMessage = _message;\n this.prefix = _prefix;\n this.code = _code;\n\n this.name = displayName;\n\n Object.defineProperty(this, 'message', {\n get: () => {\n return this.getDisplayMessage();\n },\n });\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, BaseError);\n }\n }\n\n get parentError(): BaseError<any> | null {\n const parent = this.parent;\n\n if (!parent) {\n return null;\n }\n\n if (this.parent instanceof BaseError) {\n return this.parent;\n }\n\n const displayName = parent.name ?? '[Unknown Error]';\n\n return {\n getBreadcrumbs() {\n return [displayName];\n },\n getMessage() {\n return [displayName, parent.message ?? 'unknown error message'].join(\n '\\n',\n );\n },\n } as unknown as BaseError<any>;\n }\n\n /**\n * Returns formatted error message with breadcrumbs\n */\n getDisplayMessage() {\n const breadcrumbs = this.parentError ? this.getBreadcrumbs() : [];\n\n return [breadcrumbs.join(' -> '), this.getMessage()]\n .filter((x) => x.trim().length)\n .join('\\n');\n }\n\n /**\n * Returns formatted error message\n */\n getMessage() {\n const state = Object.entries(this.state)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(` – ${key}: ${value}`);\n }\n return acc;\n }, [] as string[])\n .join('\\n');\n\n const messages = this.messages\n .reduce((acc, _messages) => {\n acc.push(` - ${_messages.join(' ')}`);\n\n return acc;\n }, [] as string[])\n .join('\\n');\n\n const parentError = this.parentError;\n\n const parentErrorMessage: string = parentError\n ? ['', parentError.getMessage(), ''].join('\\n')\n : '';\n\n const thrownErrorMessage = this.errorMessage\n ? `${this.displayName}: ${this.errorMessage}`\n : this.displayName;\n\n return [parentErrorMessage, thrownErrorMessage, state, messages]\n .filter((x) => x.trim().length)\n .join('\\n');\n }\n\n getBreadcrumbs(): string[] {\n const parentError = this.parentError;\n\n if (!parentError) {\n return [this.displayName];\n }\n\n return [...parentError.getBreadcrumbs(), this.displayName];\n }\n\n public withParentError(e: Error | BaseError<any>) {\n this.parent = e;\n return this;\n }\n\n public withMessage(...messages: string[]) {\n this.messages.push(messages);\n return this;\n }\n}\n\nexport function createErrorBuilder<TCode, TFactory extends BaseError<TCode>>(\n factory: new (...args: any) => TFactory,\n) {\n return function throwException(code: TCode, message = '') {\n const instance = new factory(message, code);\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(instance, throwException);\n }\n\n return instance;\n };\n}\n","import { BaseError, createErrorBuilder } from './BaseError';\n\nexport enum EditorPlatformInternalErrorCode {\n UnexpectedError = 'UnexpectedError',\n}\n\nclass EditorPlatformInternalError extends BaseError<EditorPlatformInternalErrorCode> {\n state: Partial<{\n host: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformInternalErrorCode) {\n super(message, code, 'Editor Platform Internal Error');\n }\n\n withHost(host: string) {\n this.state = { ...this.state, host };\n return this;\n }\n}\n\nexport const createEditorPlatformInternalError = createErrorBuilder<\n EditorPlatformInternalErrorCode,\n EditorPlatformInternalError\n>(EditorPlatformInternalError);\n","export class EventEmitter<TEvent = any> {\n static biEvents = {\n PLATFORM_WORKER_SPAWN: 123,\n PLATFORM_APP_RUNNER_INIT_APP_API: 124,\n PLATFORM_APP_RUNNER_RUN_APP: 125,\n PLATFORM_APP_RUNNER_REMOVE_APP: 126,\n PLATFORM_WORKER_APP_BUNDLE_LOAD: 127,\n PLATFORM_WORKER_APP_BUNDLE_EXECUTE: 128,\n PLATFORM_IFRAME_INIT: 129,\n PLATFORM_APP_API_INIT: 130,\n PLATFORM_APP_API_GET: 131,\n };\n\n static EventSteps = {\n Start: 'start',\n End: 'end',\n Error: 'error',\n };\n\n private uid = 0;\n private callbacks: Map<any, (event: TEvent) => void> = new Map();\n private inTransaction = false;\n private isSilent = false;\n private queue: TEvent[] = [];\n\n silent(isSilent = true) {\n this.isSilent = isSilent;\n }\n\n startTransaction() {\n this.inTransaction = true;\n }\n\n commit() {\n this.inTransaction = false;\n\n const queue = this.queue;\n this.queue = [];\n\n if (!this.isSilent) {\n queue.forEach((event) => {\n this.notify(event);\n });\n }\n }\n\n notify(event: TEvent) {\n if (this.isSilent) {\n return;\n }\n\n if (this.inTransaction) {\n this.queue.push(event);\n } else {\n this.callbacks.forEach((callback) => {\n callback(event);\n });\n }\n }\n\n subscribe(callback: (event: TEvent) => void) {\n const uid = this.uid++;\n\n this.callbacks.set(uid, callback);\n\n return () => {\n this.callbacks.delete(uid);\n };\n }\n\n notifyWithStep(event: TEvent, step: string) {\n this.notify({\n ...event,\n meta: {\n ...(event as any).meta,\n step,\n },\n });\n }\n\n async withEvent<TResult = any>(\n event: TEvent,\n cb: () => TResult | Promise<TResult>,\n ): Promise<TResult> {\n // TODO: wrap with try/catch\n let result = cb();\n\n if (result && result.hasOwnProperty('then')) {\n try {\n this.notifyWithStep(event, EventEmitter.EventSteps.Start);\n\n result = await result;\n\n this.notifyWithStep(event, EventEmitter.EventSteps.End);\n\n return result;\n } catch (e) {\n this.notifyWithStep(\n {\n ...event,\n meta: {\n ...(event as any).meta,\n error: e,\n },\n },\n EventEmitter.EventSteps.Error,\n );\n\n throw e;\n }\n } else {\n this.notify(event);\n\n return result;\n }\n }\n}\n","import { EventEmitter } from './EventEmitter';\nimport { IPlatformPrivateEventBase } from './events';\n\nexport enum PlatformPrivateEvent {\n WorkerSpawn = 'WorkerSpawn',\n HostEvent = 'HostEvent',\n ApplicationsSpecsReceived = 'ApplicationsSpecsReceived',\n InitApplicationApi = 'InitApplicationApi',\n RunApplication = 'RunApplication',\n getApplicationApi = 'getApplicationApi',\n IframeInit = 'IframeInit',\n}\n\nexport enum PlatformLifecycleEvent {\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformWorkerSpawnEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.WorkerSpawn,\n { url: string },\n {\n bi: {\n workerId: string;\n strategy: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyLifecycleEvent = IPlatformPrivateEventBase<\n PlatformLifecycleEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformHostEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.HostEvent,\n {\n type: string;\n },\n { appDefinitionId: string; intent: string }\n>;\n\nexport type IPlatformApplicationsSpecsReceived = IPlatformPrivateEventBase<\n PlatformPrivateEvent.ApplicationsSpecsReceived,\n {\n appDefinitionIds: string[];\n },\n {}\n>;\n\nexport type IPlatformRunApplication = IPlatformPrivateEventBase<\n PlatformPrivateEvent.RunApplication,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appType?: string;\n appDefId?: string;\n };\n }\n>;\n\nexport type IPlatformGetApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.getApplicationApi,\n {},\n {\n bi: {\n targetAppDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformInitApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.InitApplicationApi,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformIframeInit = IPlatformPrivateEventBase<\n PlatformPrivateEvent.IframeInit,\n {},\n {\n bi: {\n frameUrl: string;\n iframeId: string;\n };\n }\n>;\n\nexport type IPlatformPrivateEvent =\n | IPlatformWorkerSpawnEvent\n | IPlatformEditorReadyLifecycleEvent\n | IPlatformHostEvent\n | IPlatformApplicationsSpecsReceived\n | IPlatformRunApplication\n | IPlatformGetApplicationApi\n | IPlatformInitApplicationApi\n | IPlatformIframeInit;\n\nclass PlatformPrivateEventFactories {\n public createWorkerSpawnEvent({\n url,\n workerId,\n strategy,\n }: {\n url: string;\n workerId: string;\n strategy: string;\n }): IPlatformWorkerSpawnEvent {\n return {\n type: PlatformPrivateEvent.WorkerSpawn,\n payload: {\n url,\n },\n meta: {\n bi: {\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n workerId,\n strategy,\n },\n },\n };\n }\n\n public createRunApplicationEvent(app: {\n appDefinitionId: string;\n type: string;\n }): IPlatformRunApplication {\n return {\n type: PlatformPrivateEvent.RunApplication,\n payload: {\n appDefinitionId: app.appDefinitionId,\n },\n meta: {\n bi: {\n appType: app.type,\n appDefId: app.appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents\n .PLATFORM_APP_RUNNER_RUN_APP,\n },\n },\n };\n }\n\n public createGetApplicationApiEvent(\n targetAppDefId: string,\n scope: 'private' | 'public',\n ): IPlatformGetApplicationApi {\n return {\n type: PlatformPrivateEvent.getApplicationApi,\n payload: {},\n meta: {\n bi: {\n targetAppDefId,\n scope,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_GET,\n },\n },\n };\n }\n\n public createInitApplicationApiEvent(\n appDefinitionId: string,\n ): IPlatformInitApplicationApi {\n return {\n type: PlatformPrivateEvent.InitApplicationApi,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n appDefId: appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n },\n },\n };\n }\n\n public createIframeInitEvent(\n frameUrl: string,\n iframeId: string,\n ): IPlatformIframeInit {\n return {\n type: PlatformPrivateEvent.IframeInit,\n payload: {},\n meta: {\n bi: {\n frameUrl,\n iframeId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_IFRAME_INIT,\n },\n },\n };\n }\n}\n\nexport class PlatformPrivateEventEmitter extends EventEmitter<IPlatformPrivateEvent> {\n public factories = new PlatformPrivateEventFactories();\n\n notify(event: IPlatformPrivateEvent) {\n super.notify(event);\n }\n}\n","import { EventEmitter } from './EventEmitter';\n\nimport { IPlatformAppEventBase, IPlatformEventBase } from './events';\n\nexport enum PlatformAppEvent {\n ApplicationInit = 'ApplicationInit',\n ApplicationExecute = 'ApplicationExecute',\n ApplicationRemoved = 'ApplicationRemoved',\n ApplicationLoad = 'ApplicationLoad',\n ApplicationApiInit = 'ApplicationApiInit',\n CustomEvent = 'CustomEvent',\n HostEvent = 'HostEvent',\n\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformAppInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationInit,\n {},\n {}\n>;\n\nexport type IPlatformAppCustomEvent = IPlatformAppEventBase<\n PlatformAppEvent.CustomEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppHostEvent = IPlatformAppEventBase<\n PlatformAppEvent.HostEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppExecuteEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationExecute,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyEvent = IPlatformEventBase<\n PlatformAppEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformApplicationRemovedEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationRemoved,\n {},\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformAppLoadEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationLoad,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformApplicationApiInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationApiInit,\n {},\n {\n bi: {\n appDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformAppEvent =\n | IPlatformAppInitEvent\n | IPlatformAppCustomEvent\n | IPlatformAppHostEvent\n | IPlatformAppExecuteEvent\n | IPlatformAppLoadEvent\n | IPlatformApplicationRemovedEvent\n | IPlatformApplicationApiInitEvent;\n\nclass PlatformAppEventsFactories {\n public createApplicationRemovedEvent(\n appDefinitionId: string,\n ): IPlatformApplicationRemovedEvent {\n return {\n type: PlatformAppEvent.ApplicationRemoved,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n appDefId: appDefinitionId,\n },\n },\n };\n }\n\n public createApplicationLoadEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppLoadEvent {\n return {\n type: PlatformAppEvent.ApplicationLoad,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_LOAD,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationExecuteEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppExecuteEvent {\n return {\n type: PlatformAppEvent.ApplicationExecute,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_EXECUTE,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationApiInitEvent(\n appDefinitionId: string,\n scope: 'private' | 'public',\n ): IPlatformApplicationApiInitEvent {\n return {\n type: PlatformAppEvent.ApplicationApiInit,\n payload: { appDefinitionId },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n appDefId: appDefinitionId,\n scope,\n },\n },\n };\n }\n}\n\nexport class PlatformAppEventEmitter extends EventEmitter<IPlatformAppEvent> {\n public factories = new PlatformAppEventsFactories();\n}\n","import { EventType } from '@wix/public-editor-platform-interfaces';\nimport {\n IPlatformHostEvent,\n PlatformPrivateEvent,\n PlatformPrivateEventEmitter,\n} from './PlatformPrivateEventEmitter';\n\n/**\n * The events bridge between DM and private events\n */\nexport class DMEventsBridge {\n static allowedEvents = [\n EventType.componentSelectionChanged,\n EventType.appInstalled,\n EventType.appUpdateCompleted,\n EventType.removeAppCompleted,\n ];\n\n private mapToPlatformHostEvent(event: any): IPlatformHostEvent {\n if (typeof event === 'string') {\n try {\n event = JSON.parse(event);\n } catch (e) {\n // TODO: log error\n }\n }\n\n return {\n type: PlatformPrivateEvent.HostEvent,\n payload: {\n type: event.args.eventType,\n ...event.args.eventPayload,\n },\n meta: {\n appDefinitionId: event.appDefinitionId ?? null,\n intent: event.intent,\n },\n };\n }\n\n constructor(private events: PlatformPrivateEventEmitter) {}\n\n /**\n * Notify by event from Worker Manager (platform infrastructure)\n */\n public notify(_event: any) {\n const event = this.mapToPlatformHostEvent(_event);\n if (\n DMEventsBridge.allowedEvents.includes(event.payload.type as EventType)\n ) {\n this.events.notify(event);\n }\n }\n}\n","export const errorMessage = (message: string) => {\n return `\"editor-platform-transport\": ${message}`;\n};\n\nexport const internalErrorMessage = (message: string) => {\n return errorMessage(`[Internal Error] ${message}`);\n};\n","export const FUNCTION_MARKER = 'ƒ';\nexport const ACCESSOR_MARKER = '∂';\nexport const ACCESSOR_GET_POINTER = '_get_';\nexport const ACCESSOR_SET_POINTER = '_set_';\nexport const WITH_ACCESSOR_INDICATOR = '+';\nexport const NO_ACCESSOR_INDICATOR = '-';\nexport const PATH_SEPARATOR = '·';\nexport const ENCODER_MARKER = '×';\nexport const ENCODER_EMPTY_MARKER = '°';\n\nexport const extractPointer = (pointer: string) =>\n pointer[0] === ENCODER_MARKER ? '' : pointer;\n\nexport const isFinalNode = (instance: unknown) => {\n return (\n instance === null ||\n typeof instance === 'undefined' ||\n typeof instance === 'symbol' ||\n typeof instance === 'number' ||\n typeof instance === 'boolean' ||\n typeof instance === 'function' ||\n typeof instance === 'string'\n );\n};\n\nexport const isSerializableType = (instance: unknown) => {\n return (\n !!instance &&\n typeof instance === 'object' &&\n !Array.isArray(instance) &&\n !(instance instanceof Date) &&\n !(instance instanceof Set) &&\n !(instance instanceof Map)\n );\n};\n\nexport const beautifyPath = (path: string) =>\n beautifyBreadcrumbs(path.split(PATH_SEPARATOR));\nexport const beautifyBreadcrumbs = (breadcrumbs: string[]) =>\n breadcrumbs.map(extractPointer).filter(Boolean).join('.');\n","import { ENCODER_EMPTY_MARKER } from './utils';\n\nfunction createStructureEncoder<TMarker extends string, TInstance>(\n marker: TMarker,\n config: {\n shouldUse: (instance: unknown) => boolean;\n serialize: (\n instance: TInstance,\n next: (key: string, value?: any) => void,\n ) => void;\n deserialize: {\n create: () => TInstance;\n has: (instance: TInstance, key: string) => boolean;\n append: (instance: TInstance, key: string, value: any) => void;\n };\n },\n) {\n return {\n marker,\n ...config,\n };\n}\n\nexport const arrayEncoder = createStructureEncoder<'A', any[]>('A', {\n shouldUse: (instance) => Array.isArray(instance),\n serialize: (instance, next) => {\n if (!instance.length) {\n next('', ENCODER_EMPTY_MARKER);\n } else {\n instance.forEach((value, index) => {\n next(`${index}`, value);\n });\n }\n },\n deserialize: {\n create: () => [],\n has: (instance, key) =>\n !(typeof instance[key as unknown as number] === 'undefined'),\n append: (instance, _key, value) => {\n instance.push(value);\n },\n },\n});\n\nexport const mapEncoder = createStructureEncoder<'M', Map<any, any>>('M', {\n shouldUse: (instance: unknown) => instance instanceof Map,\n serialize: (instance, next) => {\n instance.forEach((value, key) => {\n next(key, value);\n });\n },\n deserialize: {\n create: () => new Map(),\n has: (instance, key) => instance.has(key),\n append: (instance, key, value) => {\n instance.set(key, value);\n },\n },\n});\n\nexport const setEncoder = createStructureEncoder<'S', Set<any>>('S', {\n shouldUse: (instance) => instance instanceof Set,\n serialize: (instance, next) => {\n let index = 0;\n instance.forEach((value) => {\n next(`${index++}`, value);\n });\n },\n deserialize: {\n create: () => new Set(),\n has: (instance, key) => instance.has(key),\n append: (instance, _key, value) => {\n instance.add(value);\n },\n },\n});\n\nexport const objectEncoder = createStructureEncoder<'O', Record<string, any>>(\n 'O',\n {\n shouldUse: (instance) => typeof instance === 'object',\n serialize: (root, next) => {\n const forEachMember = (instance: Record<string, any>) => {\n const keys = Reflect.ownKeys(instance);\n\n const members = keys\n .filter((key) => {\n return key !== 'constructor';\n })\n .filter((key) => {\n return typeof key !== 'symbol';\n });\n\n if (!members.length) {\n next('', ENCODER_EMPTY_MARKER);\n } else {\n members\n .filter((key) => {\n return key !== 'constructor';\n })\n .filter((key) => {\n return typeof key !== 'symbol';\n })\n .forEach((key) => {\n const value = Reflect.get(root, key);\n\n next(key as string, value);\n });\n }\n\n const parent = Reflect.getPrototypeOf(instance);\n if (!parent || parent?.hasOwnProperty('__proto__')) {\n return;\n }\n\n forEachMember(parent);\n };\n\n forEachMember(root);\n },\n deserialize: {\n create: () => ({}),\n has: (instance, key) => !!instance[key],\n append: (instance, key, value) => {\n instance[key] = value;\n },\n },\n },\n);\n","import { errorMessage } from '../error';\nimport {\n ACCESSOR_GET_POINTER,\n ACCESSOR_MARKER,\n ACCESSOR_SET_POINTER,\n beautifyBreadcrumbs,\n beautifyPath,\n ENCODER_EMPTY_MARKER,\n ENCODER_MARKER,\n extractPointer,\n FUNCTION_MARKER,\n isFinalNode,\n isSerializableType,\n NO_ACCESSOR_INDICATOR,\n PATH_SEPARATOR,\n WITH_ACCESSOR_INDICATOR,\n} from './utils';\nimport {\n arrayEncoder,\n mapEncoder,\n objectEncoder,\n setEncoder,\n} from './encoders';\n\n/**\n * { a:1,b:2, c:[1, {d:5}] }\n * =>\n * {\n * type: 'object',\n * data: [['a', 1], ['b', 2], ['#c.0', 1], ['c.#1.d', 5]]\n * }\n */\nexport interface ISerializedPayload {\n data: [string, string | number | boolean | null | undefined][];\n}\n\nexport type IRegisterFunctionMarker = (\n path: string,\n value: (...args: any) => any,\n) => void;\n\nexport type IReplaceFunctionMarker = (path: string) => (props: any[]) => any;\n\nconst encoders = [arrayEncoder, setEncoder, mapEncoder];\n\nfunction getDescriptor(obj: any, key: string) {\n let _instance = obj;\n\n while (_instance) {\n const descriptor = Object.getOwnPropertyDescriptor(_instance, key);\n if (descriptor) {\n return descriptor;\n }\n\n _instance = Reflect.getPrototypeOf(_instance);\n }\n\n return null;\n}\n\nfunction forEachMember(\n root: any,\n callback: (\n breadcrumbs: string[],\n config: {\n context: {};\n pointer: string;\n value: any;\n },\n ) => void,\n) {\n const ancestors = new WeakMap<any, string[]>();\n const getContextPointer = (breadcrumbs: string[]) => {\n const _breadcrumbs = breadcrumbs\n .slice(1) // TODO\n .map(extractPointer)\n .filter(Boolean);\n\n return _breadcrumbs.slice(1).reduce<any>(\n (acc, pointer) => {\n return {\n context: acc.context[acc.pointer],\n pointer,\n };\n },\n {\n context: root,\n pointer: _breadcrumbs[0],\n },\n );\n };\n\n const iterateStructure = (instance: any, breadcrumbs: string[] = []) => {\n if (ancestors.has(instance)) {\n const hasDuplicates = ancestors\n .get(instance)\n ?.some((p) => breadcrumbs.join('.').startsWith(p));\n\n if (hasDuplicates) {\n callback(breadcrumbs, {\n ...getContextPointer(breadcrumbs),\n value: '[Circular]',\n });\n return;\n }\n }\n\n if (instance && !isFinalNode(instance)) {\n if (ancestors.has(instance)) {\n ancestors.set(instance, []);\n }\n\n ancestors.set(instance, [\n ...(ancestors.get(instance) ?? []),\n breadcrumbs.join('.'),\n ]);\n }\n\n if (isFinalNode(instance)) {\n callback(breadcrumbs, {\n ...getContextPointer(breadcrumbs),\n value: instance,\n });\n return;\n }\n\n const encoder =\n encoders.find((_encoder) => _encoder.shouldUse(instance)) ??\n objectEncoder;\n\n if (encoder) {\n encoder.serialize(instance, (key, value) => {\n iterateStructure(value, [\n ...breadcrumbs,\n `${ENCODER_MARKER}${encoder.marker}`,\n key,\n ]);\n });\n\n return;\n }\n };\n\n return iterateStructure(root);\n}\n\nexport const serialize = (\n input: any,\n registerFunctionMarker: IRegisterFunctionMarker,\n): ISerializedPayload => {\n if (!isSerializableType(input)) {\n throw new Error(\n errorMessage('only objects are serializable at the root level'),\n );\n }\n\n const buffer: ISerializedPayload = {\n data: [],\n };\n\n const appendValue = (path: string, value: any) => {\n buffer.data.push([path, value]);\n };\n\n const appendFunction = (\n path: string,\n config: {\n context: any;\n pointer: string;\n },\n ) => {\n registerFunctionMarker(beautifyPath(path), (...args: any[]) => {\n return config.context[config.pointer](...args);\n });\n\n appendValue(path, FUNCTION_MARKER);\n };\n\n forEachMember(input, (breadcrumbs, { value, context, pointer }) => {\n const path = breadcrumbs.slice(1).join(PATH_SEPARATOR);\n\n const descriptor = getDescriptor(context, pointer);\n\n if (descriptor?.get || descriptor?.set) {\n if (descriptor?.get) {\n registerFunctionMarker(\n beautifyBreadcrumbs([...breadcrumbs, ACCESSOR_GET_POINTER]),\n () => (context as unknown as any)[pointer],\n );\n }\n if (descriptor?.set) {\n registerFunctionMarker(\n beautifyBreadcrumbs([...breadcrumbs, ACCESSOR_SET_POINTER]),\n (_value: any) => {\n (context as unknown as any)[pointer] = _value;\n },\n );\n }\n const marker = [\n descriptor?.get ? WITH_ACCESSOR_INDICATOR : NO_ACCESSOR_INDICATOR,\n descriptor?.set ? WITH_ACCESSOR_INDICATOR : NO_ACCESSOR_INDICATOR,\n ];\n\n appendValue(path, `${ACCESSOR_MARKER}${marker.join('')}`);\n } else if (typeof value === 'function') {\n appendFunction(path, { context, pointer });\n } else {\n appendValue(path, value);\n }\n });\n\n return buffer;\n};\n\nexport const deserialize = (\n input: ISerializedPayload,\n replaceFunctionMarker: IReplaceFunctionMarker,\n) => {\n if (typeof input !== 'object' || input === null) {\n return input;\n }\n\n return input.data.reduce<any>(\n (acc, [breadcrumbs, value]) => {\n let pointer = acc;\n\n const pointers = breadcrumbs.split(PATH_SEPARATOR);\n\n let encoder = objectEncoder as any;\n\n let key = null as any;\n\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < pointers.length; i++) {\n const point = pointers[i]!;\n if (point[0] === ENCODER_MARKER) {\n const has = encoder.deserialize.has(pointer, key);\n\n encoder = [objectEncoder, ...encoders].find(\n (_iterator) => _iterator.marker === point[1],\n );\n\n if (!encoder) {\n throw new Error(errorMessage(`unknown marker \"${point[1]}\"`));\n }\n\n if (!has) {\n pointer[key] = encoder.deserialize.create();\n }\n\n pointer = pointer[key];\n } else {\n key = point;\n }\n }\n\n if (value?.toString() === ENCODER_EMPTY_MARKER) {\n return acc;\n } else if (value?.toString() === FUNCTION_MARKER) {\n encoder.deserialize.append(\n pointer,\n key,\n replaceFunctionMarker(beautifyBreadcrumbs(pointers)),\n );\n } else if (value?.toString()[0] === ACCESSOR_MARKER) {\n const hasGetter = value?.toString()[1] === WITH_ACCESSOR_INDICATOR;\n const hasSetter = value?.toString()[2] === WITH_ACCESSOR_INDICATOR;\n\n const descriptor: PropertyDescriptor = {};\n if (hasGetter) {\n const getter = replaceFunctionMarker(\n beautifyBreadcrumbs([...pointers, ACCESSOR_GET_POINTER]),\n );\n\n descriptor.get = () => (getter as any)();\n }\n\n if (hasSetter) {\n descriptor.set = replaceFunctionMarker(\n beautifyBreadcrumbs([...pointers, ACCESSOR_SET_POINTER]),\n );\n }\n\n Object.defineProperty(pointer, key!, descriptor);\n } else {\n encoder.deserialize.append(pointer, key, value);\n }\n\n return acc;\n },\n // TODO: define as enumrable\n {\n [Symbol('transferred object')]: `${(\n JSON.stringify(input.data).length / 1024\n ).toFixed(2)}Kb`,\n },\n );\n};\n","import { deserialize, serialize } from './serializer';\n\nexport const enum MessageType {\n ExposeAPI = 'ExposeAPI',\n Call = 'Call',\n Response = 'Response',\n Cleanup = 'Cleanup',\n}\n\nexport type IRegisterMessageFunctionMarker = (\n correlationId: string,\n path: string,\n value: (...args: any) => any,\n) => void;\n\nexport type IReplaceMessageFunctionMarker = (\n correlationId: string,\n path: string,\n) => (props: any[]) => any;\n\nexport const noopFunctionReplacer = () => () => {};\n\nexport class Message<\n TPayload extends Record<string, any> = Record<string, any>,\n> {\n public readonly correlationId = `M-${performance.now()}`;\n public parentCorrelationId?: string;\n\n constructor(\n public type: MessageType,\n public payload: TPayload,\n ) {}\n\n public withParentCorrelationId(correlationId: string) {\n this.parentCorrelationId = correlationId;\n return this;\n }\n\n public serialize(registerFunctionMarker: IRegisterMessageFunctionMarker) {\n return JSON.stringify({\n parentCorrelationId: this.parentCorrelationId,\n correlationId: this.correlationId,\n type: this.type,\n payload: serialize(this.payload, (path, value) => {\n registerFunctionMarker(this.correlationId, path, value);\n }),\n });\n }\n\n static fromEvent(\n data: string,\n replaceFunctionMarker: IReplaceMessageFunctionMarker,\n ) {\n const parsed = JSON.parse(data);\n\n return new Message(\n parsed.type,\n deserialize(parsed.payload, (breadcrumbs) => {\n return replaceFunctionMarker(parsed.correlationId, breadcrumbs);\n }),\n ).withParentCorrelationId(parsed.correlationId);\n }\n}\n\nexport class MessageCleanup extends Message<{\n functionMarkerKey: string;\n callId?: string;\n}> {\n constructor(payload: typeof MessageCleanup.prototype.payload) {\n super(MessageType.Cleanup, payload);\n }\n}\n\nexport class MessageResponse extends Message<{\n callId: string;\n response: any;\n}> {\n constructor(payload: typeof MessageResponse.prototype.payload) {\n super(MessageType.Response, payload);\n }\n}\n\nexport class MessageResponseError extends Message<{\n callId: string;\n errorMessage: string;\n errorStack?: string;\n}> {\n constructor(payload: typeof MessageResponseError.prototype.payload) {\n super(MessageType.Response, payload);\n }\n}\n\nexport class MessageCall extends Message<{\n callId: string;\n functionMarkerKey: string;\n props: any[];\n}> {\n constructor(payload: typeof MessageCall.prototype.payload) {\n super(MessageType.Call, payload);\n }\n}\n\nexport class MessageExposeAPI extends Message<\n {\n type: string;\n } & Record<string, any>\n> {\n constructor(payload: typeof MessageExposeAPI.prototype.payload) {\n super(MessageType.ExposeAPI, payload);\n }\n}\n","import {\n Message,\n MessageCall,\n MessageCleanup,\n MessageExposeAPI,\n MessageResponse,\n MessageResponseError,\n MessageType,\n} from './Message';\nimport { errorMessage } from './error';\n\nconst buildFunctionMarkerKey = (correlationId: string, path: string) => {\n return `${correlationId}_${path}`;\n};\n\nexport type IMessageCallbacks = Partial<{\n [MessageType.Cleanup]: (message: MessageCleanup) => void;\n [MessageType.Response]: (\n message: MessageResponse | MessageResponseError,\n ) => void;\n [MessageType.Call]: (message: MessageCall) => void;\n [MessageType.ExposeAPI]: (message: MessageExposeAPI) => void;\n}>;\n\nexport abstract class ThreadChannel {\n protected abstract messageEvents: IMessageCallbacks;\n\n #registry = new FinalizationRegistry<{\n functionMarkerKey: string;\n callId?: string;\n }>((params) => {\n this.postMessage(new MessageCleanup(params));\n });\n\n #messageEvents: IMessageCallbacks = {\n [MessageType.Cleanup]: (message) => {\n const functionMarkerKey = message.payload.functionMarkerKey;\n const callId = message.payload.callId;\n\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this.#functionMarkers[functionMarkerKey];\n\n if (callId) {\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this.#pendingFunctionResponse[callId];\n }\n },\n /**\n * Return function response between threads\n */\n [MessageType.Response]: async (message) => {\n const callId = message.payload.callId;\n const _errorMessage = (message as MessageResponseError).payload\n .errorMessage;\n\n if (_errorMessage) {\n const errorStack = (message as MessageResponseError).payload.errorStack;\n\n if (errorStack) {\n const error = new Error(_errorMessage);\n error.stack = (message as MessageResponseError).payload.errorStack;\n\n this.#pendingFunctionResponse[callId]?.reject(error);\n } else {\n this.#pendingFunctionResponse[callId]?.reject(_errorMessage);\n }\n } else {\n const response = (message as MessageResponse).payload.response;\n this.#pendingFunctionResponse[callId]?.resolve(response);\n }\n\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this.#pendingFunctionResponse[callId];\n },\n /**\n * Calling function between threads\n */\n [MessageType.Call]: async (message) => {\n const functionMarkerKey = message.payload.functionMarkerKey;\n const marker = this.#functionMarkers[functionMarkerKey];\n\n if (!marker) {\n this.postMessage(\n new MessageResponseError({\n callId: message.payload.callId,\n errorMessage: errorMessage('function is not available'),\n }),\n );\n\n return;\n }\n\n /**\n * TODO: for debugging purposes – check if original function still exists\n */\n try {\n const response = await marker.value(...(message.payload.props ?? []));\n\n this.postMessage(\n new MessageResponse({\n callId: message.payload.callId,\n response,\n }),\n );\n } catch (error: unknown) {\n this.postMessage(\n new MessageResponseError({\n callId: message.payload.callId,\n /**\n * for better DX we need to pass Error object to keep stack trace available\n * but in some cases our custom error messages are not serialized correctly\n */\n errorMessage: (error as Error).message,\n errorStack: (error as Error).stack,\n }),\n );\n }\n },\n };\n\n #functionMarkers: Record<\n string,\n {\n path: string;\n value: (...args: any) => any;\n }\n > = {};\n\n #pendingFunctionResponse: Record<\n string,\n { resolve: Function; reject: Function }\n > = {};\n\n protected queue: Message[] = [];\n\n constructor(protected port: MessagePort) {\n this.port.onmessage = (event) => {\n this.onMessage(event);\n };\n }\n\n protected onMessage(event: MessageEvent) {\n const message = Message.fromEvent(event.data, (correlationId, path) => {\n const replacedFunction = this.replaceTransferredFunction(\n correlationId,\n path,\n );\n\n this.#registry.register(replacedFunction, {\n functionMarkerKey: buildFunctionMarkerKey(correlationId, path),\n // callId: message.payload?.callId,\n });\n\n return replacedFunction;\n });\n\n this.#messageEvents[message.type]?.(message);\n this.messageEvents[message.type]?.(message);\n }\n\n protected postMessage(message: Message) {\n this.port.postMessage(\n message.serialize(this.registerTransferredFunction.bind(this)),\n );\n }\n\n registerTransferredFunction(\n correlationId: string,\n path: string,\n value: (...args: any) => any,\n ) {\n const functionMarkerKey = buildFunctionMarkerKey(correlationId, path);\n\n this.#functionMarkers[functionMarkerKey] = {\n path,\n value,\n };\n }\n\n replaceTransferredFunction(correlationId: string, path: string) {\n return (...props: any[]) => {\n const callId = `CALL-${crypto.randomUUID()}`;\n\n this.postMessage(\n new MessageCall({\n callId,\n functionMarkerKey: buildFunctionMarkerKey(correlationId, path),\n props,\n }),\n );\n\n return new Promise((resolve, reject) => {\n // TODO: check never resolved promise\n this.#pendingFunctionResponse[callId] = { resolve, reject };\n });\n };\n }\n\n protected flush() {\n this.queue.forEach((message) => {\n this.postMessage(message);\n });\n\n this.queue = [];\n }\n\n /**\n * TODO:\n * before message port is disposed\n * we need to cleanup all pending promises (probably reject or cancel with AbortController)\n * note, this function should be async, and we need\n * to wait it before dispose port and create a new port\n */\n // shutdown() {\n // this.postMessage(new MessageShutdown());\n //\n // Object.keys(this.#pendingFunctionResponse).forEach((key) => {\n // const value = this.#pendingFunctionResponse[key]\n // if (value && value.reject && value.resolve) {\n // value.reject(new Error('transport port shutdown'));\n // }\n // })\n // }\n}\n","import { errorMessage } from './error';\nimport { Message, MessageType } from './Message';\nimport { IMessageCallbacks, ThreadChannel } from './ThreadChannel';\n\nexport class ConsumerChannel extends ThreadChannel {\n protected messageEvents: IMessageCallbacks = {};\n\n public expose(instance: any) {\n if (!instance.type) {\n throw new Error(\n errorMessage('wrong exposed API instance, \"type\" property is required'),\n );\n }\n\n this.queue.push(new Message(MessageType.ExposeAPI, instance));\n this.flush();\n }\n}\n","import { MessageType } from './Message';\nimport { IMessageCallbacks, ThreadChannel } from './ThreadChannel';\n\nexport type WithPromiseFunctions<T> = {\n [K in keyof T]: T[K] extends (...args: infer Args) => infer Result\n ? (...args: Args) => Promise<WithPromiseFunctions<Result>>\n : T[K] extends Record<string, unknown>\n ? WithPromiseFunctions<T[K]>\n : T[K];\n};\n\nexport class HostChannel extends ThreadChannel {\n #consumerAPIInstances: Record<string, any> = {};\n #consumerAPIInstancesResolvers: {\n type: string;\n cb: (instance: any) => void;\n }[] = [];\n\n protected messageEvents: IMessageCallbacks = {\n [MessageType.ExposeAPI]: (message) => {\n const pendingTypeInstances = this.#consumerAPIInstancesResolvers.filter(\n ({ type }) => type === message.payload.type,\n );\n\n this.#consumerAPIInstancesResolvers =\n this.#consumerAPIInstancesResolvers.filter(\n ({ type }) => type !== message.payload.type,\n );\n\n pendingTypeInstances.forEach(({ cb }) => {\n cb(message.payload);\n });\n },\n };\n\n public waitAPI<TInstance = any>(\n type: string,\n ): Promise<WithPromiseFunctions<TInstance>> {\n return new Promise((resolve) => {\n this.onAPICallback<TInstance>(type, (_workerApi) => {\n resolve(_workerApi);\n });\n });\n }\n\n public onAPICallback<TInstance = any>(\n type: string,\n cb: (instance: WithPromiseFunctions<TInstance>) => void,\n ) {\n if (this.#consumerAPIInstances[type]) {\n cb(this.#consumerAPIInstances[type]);\n return;\n }\n\n this.#consumerAPIInstancesResolvers.push({\n type,\n cb,\n });\n }\n}\n","// be sure event names are uniq\nexport enum HandshakeEvent {\n Ping = 'EDITOR_PLATFORM_TRANSPORT_EVENT:__Ping',\n RequestPort = 'EDITOR_PLATFORM_TRANSPORT_EVENT:__RequestPort',\n Pong = 'EDITOR_PLATFORM_TRANSPORT_EVENT:__Pong',\n Port = 'EDITOR_PLATFORM_TRANSPORT_EVENT:__Port',\n}\n\nexport type ConsumerEvent =\n | {\n type: HandshakeEvent.Ping;\n }\n | {\n type: HandshakeEvent.RequestPort;\n memberId: string;\n };\n\nexport type HostEvent =\n | {\n type: HandshakeEvent.Pong;\n }\n | {\n type: HandshakeEvent.Port;\n targetMemberId: string;\n };\n","import { internalErrorMessage } from '../error';\n\nexport type ConnectionReadyCallback = (port: MessagePort) => void;\n\nexport type IPostMessage = (message: string, port?: MessagePort) => void;\nexport type IOnMessage = (listener: MessageEventListener) => void;\n\ntype MessageEventListener = (message: MessageEvent) => void;\n\nexport abstract class AbstractHandshake {\n #listeners = new Set<ConnectionReadyCallback>();\n #activePort?: MessagePort;\n\n protected constructor(\n protected postMessage: IPostMessage,\n protected onMessage: IOnMessage,\n ) {}\n\n #notifyHandshakeListeners() {\n const port = this.#activePort;\n\n if (!port) {\n console.warn(\n internalErrorMessage(\n 'port is required no notify onHandshake listeners',\n ),\n );\n return;\n }\n\n this.#listeners.forEach((cb) => cb(port));\n }\n\n protected setActivePort(port: MessagePort) {\n this.dispose();\n\n this.#activePort = port;\n this.#notifyHandshakeListeners();\n }\n\n protected dispose() {\n if (this.#activePort) {\n this.#activePort.close();\n this.#activePort.onmessage = null;\n }\n }\n\n public onHandshake(callback: ConnectionReadyCallback) {\n this.#listeners.add(callback);\n\n return () => {\n this.#listeners.delete(callback);\n };\n }\n}\n","import { ConsumerEvent, HandshakeEvent, HostEvent } from './events';\nimport {\n AbstractHandshake,\n IOnMessage,\n IPostMessage,\n} from './AbstractHandshake';\n\nexport class HostHandshake extends AbstractHandshake {\n #messageChannel?: MessageChannel;\n\n constructor(postMessage: IPostMessage, onMessage: IOnMessage) {\n super(postMessage, onMessage);\n\n this.#initHandshake();\n this.#onConsumerPing();\n }\n\n #initHandshake() {\n this.onMessage((event) => {\n try {\n const payload: ConsumerEvent = JSON.parse(event.data);\n\n switch (payload.type) {\n case HandshakeEvent.Ping: {\n this.#onConsumerPing();\n break;\n }\n\n case HandshakeEvent.RequestPort: {\n this.#onConsumerRequestPort(payload.memberId);\n break;\n }\n }\n } catch (e) {\n // skip unnecessary events\n }\n });\n }\n\n #onConsumerPing() {\n const payload: HostEvent = {\n type: HandshakeEvent.Pong,\n };\n\n this.postMessage(JSON.stringify(payload));\n }\n\n #onConsumerRequestPort(memberId: string) {\n const messageChannel = this.#createMessageChannel();\n this.setActivePort(messageChannel?.port1);\n\n const payload: HostEvent = {\n type: HandshakeEvent.Port,\n targetMemberId: memberId,\n };\n\n this.postMessage(JSON.stringify(payload), messageChannel.port2);\n }\n\n #createMessageChannel() {\n if (this.#messageChannel) {\n this.#messageChannel.port1.close();\n this.#messageChannel.port1.onmessage = null;\n }\n\n this.#messageChannel = new MessageChannel();\n return this.#messageChannel;\n }\n}\n","import { HostEvent, HandshakeEvent, ConsumerEvent } from './events';\n\nimport {\n AbstractHandshake,\n IOnMessage,\n IPostMessage,\n} from './AbstractHandshake';\nimport { internalErrorMessage } from '../error';\n\nexport class ConsumerHandshake extends AbstractHandshake {\n #hostIsAlive = false;\n #memberId = `consumer-${performance.now()}`;\n\n constructor(postMessage: IPostMessage, onMessage: IOnMessage) {\n super(postMessage, onMessage);\n\n this.#initHandshake();\n\n const payload: ConsumerEvent = {\n type: HandshakeEvent.Ping,\n };\n\n postMessage(JSON.stringify(payload));\n }\n\n #initHandshake() {\n this.onMessage((event) => {\n try {\n const payload: HostEvent = JSON.parse(event.data);\n\n switch (payload.type) {\n case HandshakeEvent.Pong: {\n this.#onHostPing();\n break;\n }\n\n case HandshakeEvent.Port: {\n this.#onHostPort(payload.targetMemberId, event.ports?.[0]);\n break;\n }\n }\n } catch (e) {\n // skip unnecessary events\n }\n });\n }\n\n #onHostPing() {\n if (this.#hostIsAlive) {\n return;\n }\n\n this.#hostIsAlive = true;\n\n const payload: ConsumerEvent = {\n type: HandshakeEvent.RequestPort,\n memberId: this.#memberId,\n };\n\n this.postMessage(JSON.stringify(payload));\n }\n\n #onHostPort(targetMemberId: string, port?: MessagePort) {\n if (targetMemberId !== this.#memberId) {\n return;\n }\n\n if (!port) {\n throw new Error(internalErrorMessage('no port at consumer handshake'));\n }\n\n this.setActivePort(port);\n }\n}\n","import { ConsumerHandshake, HostHandshake } from '../Handshake';\n\nexport abstract class AbstractHostEndpoint {\n abstract handshake: HostHandshake;\n\n get onConnect() {\n return this.handshake.onHandshake.bind(this.handshake);\n }\n}\n\nexport abstract class AbstractConsumerEndpoint {\n abstract handshake: ConsumerHandshake;\n\n get onConnect() {\n return this.handshake.onHandshake.bind(this.handshake);\n }\n}\n","import { ConsumerHandshake } from '../Handshake';\nimport { AbstractConsumerEndpoint } from './AbstractEndpoint';\nimport { ConsumerChannel } from '../ConsumerChannel';\n\nexport class IFrameConsumerEndpoint extends AbstractConsumerEndpoint {\n static exposeAPI<TApi>(instance: TApi) {\n const consumer = new IFrameConsumerEndpoint();\n\n consumer.onConnect((port) => {\n const transport = new ConsumerChannel(port);\n transport.expose(instance);\n });\n }\n\n handshake = new ConsumerHandshake(\n (message) => {\n globalThis.parent.postMessage(message, '*');\n },\n (listener) => {\n globalThis.addEventListener('message', listener);\n },\n );\n}\n","import { HostHandshake } from '../Handshake';\nimport { AbstractHostEndpoint } from './AbstractEndpoint';\nimport { HostChannel } from '../HostChannel';\n\n// TODO: endpoint\nexport class IFrameHostEndpoint extends AbstractHostEndpoint {\n static connect(\n iframe: HTMLIFrameElement,\n cb: (transport: HostChannel) => void,\n ) {\n const host = new IFrameHostEndpoint(iframe);\n\n host.onConnect((port) => {\n const instance = new HostChannel(port);\n cb(instance);\n });\n }\n\n handshake: HostHandshake;\n\n constructor(private iframe: HTMLIFrameElement) {\n super();\n\n this.handshake = new HostHandshake(\n (message, port) => {\n if (port) {\n this.iframe.contentWindow?.postMessage(message, '*', [port]);\n } else {\n this.iframe.contentWindow?.postMessage(message, '*');\n }\n },\n (listener) => {\n globalThis.addEventListener('message', listener);\n },\n );\n }\n}\n","import { ConsumerHandshake } from '../Handshake';\nimport { AbstractConsumerEndpoint } from './AbstractEndpoint';\nimport { ConsumerChannel } from '../ConsumerChannel';\n\nexport class WorkerConsumerEndpoint extends AbstractConsumerEndpoint {\n static exposeAPI<TApi>(instance: TApi) {\n const consumer = new WorkerConsumerEndpoint();\n\n consumer.onConnect((port) => {\n const transport = new ConsumerChannel(port);\n transport.expose(instance);\n });\n }\n\n handshake = new ConsumerHandshake(\n (msg) => {\n globalThis.postMessage(msg);\n },\n (listener) => {\n globalThis.addEventListener('message', listener);\n },\n );\n}\n","import { HostHandshake } from '../Handshake';\nimport { AbstractHostEndpoint } from './AbstractEndpoint';\nimport { HostChannel } from '../HostChannel';\n\nexport class WorkerHostEndpoint extends AbstractHostEndpoint {\n static connect(worker: Worker, cb: (transport: HostChannel) => void) {\n const host = new WorkerHostEndpoint(worker);\n\n host.onConnect((port) => {\n const instance = new HostChannel(port);\n cb(instance);\n });\n }\n\n handshake: HostHandshake;\n\n constructor(private worker: Worker) {\n super();\n\n this.handshake = new HostHandshake(\n (message, port) => {\n if (port) {\n this.worker.postMessage(message, [port]);\n } else {\n this.worker.postMessage(message);\n }\n },\n (listener) => {\n this.worker.addEventListener('message', listener);\n },\n );\n }\n}\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 { 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 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\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\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';\n\nimport { WorkerEventsBridge } from '../../Events';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\nimport {\n ApplicationContext,\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 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 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","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 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\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\n//# sourceMappingURL=index.js.map\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 {\n PlatformAppEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport {\n APPLICATION_CONTEXT_KEY,\n EnvironmentContext,\n ApplicationContext,\n} from '@wix/editor-application-context';\n\nimport type { EditorPlatformApplication } from '../EditorPlatformApplication';\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { IApplicationSpec } from '../types';\n\nexport const APPLICATION_REGISTRY_KEY = '__APPLICATION_REGISTRY_KEY';\n\nexport type IApplicationRegistry = (\n _instance: EditorPlatformApplication,\n) => void;\n\nexport async function executeApplication(\n events: PlatformAppEventEmitter,\n spec: IApplicationSpec,\n bundle: string,\n): Promise<{\n instance: EditorPlatformApplication;\n}> {\n // eslint-disable-next-line no-new-func\n const executable = new Function(\n APPLICATION_CONTEXT_KEY,\n APPLICATION_REGISTRY_KEY,\n bundle,\n );\n\n let instance: EditorPlatformApplication | undefined;\n\n const applicationRegistryCallback: IApplicationRegistry = (_instance) => {\n if (instance) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application registry called more than once',\n ).withAppDefinitionId(spec.appDefinitionId);\n }\n\n if (_instance.type !== spec.type) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application has different type',\n )\n .withMessage('expected type', spec.type)\n .withMessage('received type', _instance.type);\n }\n\n instance = _instance;\n };\n\n try {\n const context = { ...spec };\n\n executable.call(\n null,\n new ApplicationContext(context, await EnvironmentContext.getInstance()),\n applicationRegistryCallback,\n );\n } catch (e: unknown) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n (e as Error).message,\n )\n .withAppDefinitionId(spec.appDefinitionId)\n .withParentError(e as Error);\n }\n\n return new Promise((resolve, reject) => {\n const unsubscribe = events.subscribe((event) => {\n const timeoutId = setTimeout(() => {\n clearTimeout(timeoutId);\n unsubscribe();\n\n if (!instance) {\n reject(\n createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application registry was not called, threw by timeout',\n ).withAppDefinitionId(spec.appDefinitionId),\n );\n }\n }, 5000);\n\n if (\n event.type === PlatformAppEvent.ApplicationInit &&\n event.meta.appDefinitionId === spec.appDefinitionId\n ) {\n clearTimeout(timeoutId);\n unsubscribe();\n\n if (!instance) {\n reject(\n createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationExecuteError,\n 'Application registry was not called',\n ).withAppDefinitionId(spec.appDefinitionId),\n );\n }\n\n resolve({ instance: instance! });\n }\n });\n });\n}\n","import {\n PlatformAppEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport { EventType } from '@wix/public-editor-platform-interfaces';\n\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { EditorPlatformApplication } from '../EditorPlatformApplication';\nimport { type IApplicationSpec, type IPrivateAPIFixMe } from '../types';\nimport { executeApplication } from './executeApplication';\n\nexport class PlatformApplicationContainer {\n #apps: Record<string, EditorPlatformApplication> = {};\n\n readonly #privateAPI: IPrivateAPIFixMe;\n readonly #events: PlatformAppEventEmitter;\n\n constructor(privateApi: IPrivateAPIFixMe, events: PlatformAppEventEmitter) {\n this.#privateAPI = privateApi;\n this.#events = events;\n\n this.#events.subscribe((event) => {\n switch (event.type) {\n case PlatformAppEvent.HostEvent: {\n if (event.payload.type === EventType.removeAppCompleted) {\n void this.#events.withEvent(\n this.#events.factories.createApplicationRemovedEvent(\n event.payload.appDefinitionId!,\n ),\n () => {\n return this.removeApplication(event.payload.appDefinitionId!);\n },\n );\n }\n break;\n }\n }\n });\n }\n\n public async runApplication(appSpec: IApplicationSpec) {\n const bundle = await this.loadApplication(appSpec);\n const instance = await this.executeApplication(appSpec, bundle);\n\n this.setApplication(appSpec.appDefinitionId, instance);\n\n return instance;\n }\n\n private setApplication(\n appDefId: string,\n instance: EditorPlatformApplication,\n ) {\n this.#apps[appDefId] = instance;\n\n void this.#events.withEvent(\n this.#events.factories.createApplicationApiInitEvent(\n appDefId,\n // TODO: both types are set here...\n // @ts-expect-error TODO: fix me\n instance?.api?.private ? 'private' : 'public',\n ),\n () => {\n // NOTE: sometimes I saw this method was called while application was not executed\n this.#privateAPI.applicationManager.setApplication(instance);\n },\n );\n }\n\n public getApplication(appDefId: string) {\n return this.#apps[appDefId];\n }\n\n public getAppDefinitionIds() {\n return Object.keys(this.#apps);\n }\n\n private removeApplication(appDefinitionId: string) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.#apps[appDefinitionId];\n }\n\n private async loadApplication(appSpec: IApplicationSpec) {\n const url = appSpec.url;\n\n return this.#events.withEvent(\n this.#events.factories.createApplicationLoadEvent(appSpec, url),\n\n async () => {\n try {\n return await this.loadApplicationBundle(url);\n } catch (e) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationLoadError,\n )\n .withUrl(url)\n .withAppDefinitionId(appSpec.appDefinitionId)\n .withParentError(e as any);\n }\n },\n );\n }\n\n private async loadApplicationBundle(url: string) {\n /**\n * NOTE: we don't use wix http client here\n * because this code is public, while http client is private\n */\n const res = await fetch(url, {\n method: 'GET',\n });\n\n const isSuccessfulResponse = res.status >= 200 && res.status <= 299;\n\n if (!isSuccessfulResponse) {\n throw createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationFetchError,\n ).withUrl(url);\n }\n\n return res.text();\n }\n\n private async executeApplication(appSpec: IApplicationSpec, bundle: string) {\n return this.#events.withEvent(\n this.#events.factories.createApplicationExecuteEvent(\n appSpec,\n appSpec.url,\n ),\n async () => {\n const { instance } = await executeApplication(\n this.#events,\n appSpec,\n bundle,\n );\n return instance;\n },\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 { IApplicationSpec, IPrivateAPIFixMe } from '../../types';\nimport {\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\n\nimport { WorkerEventsBridge } from '../../Events';\n\nimport { PlatformApplicationContainer } from '../../PlatformApplicationContainer';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\nimport {\n EnvironmentContext,\n PlatformEnvironment,\n} from '@wix/editor-application-context';\n\nexport class PlatformWorkerAPI extends AbstractEnvironmentAPI<PlatformConsumerEnvironmentAPIType.Worker> {\n public type: PlatformConsumerEnvironmentAPIType.Worker =\n PlatformConsumerEnvironmentAPIType.Worker;\n\n #events = new PlatformAppEventEmitter();\n\n #eventsBridge = new WorkerEventsBridge(this.#events);\n #container: PlatformApplicationContainer | null = null;\n #privateAPI: IPrivateAPIFixMe;\n\n #pendingWaiters: ((value: this) => void)[] = [];\n\n constructor() {\n super(PlatformConsumerEnvironmentAPIType.Worker);\n }\n\n create() {}\n\n async initEnvironment(props: {\n // TODO: should be Promise response in types\n buildPrivateAPI: (config: any) => IPrivateAPIFixMe;\n }) {\n const { buildPrivateAPI } = props;\n this.#privateAPI = await buildPrivateAPI({\n // TODO: should be per application (within the container before app execution)\n type: 'EDITOR_ADDON',\n });\n\n await EnvironmentContext.inject({\n environment: PlatformEnvironment.Worker,\n events: this.#events,\n privateApi: this.#privateAPI,\n applicationAPIs: {},\n });\n\n this.#container = new PlatformApplicationContainer(\n this.#privateAPI,\n this.#events,\n );\n\n this.#pendingWaiters.forEach((res) => res(this));\n }\n\n async notify(event: IPlatformPrivateEvent) {\n await this.waitReady();\n\n this.#eventsBridge.notify(event);\n }\n\n subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.#eventsBridge.subscribe(cb);\n }\n\n async runApplication(app: IApplicationSpec) {\n await this.waitReady();\n\n await this.#container!.runApplication(app);\n }\n\n public waitReady(): Promise<this> {\n return new Promise((res) => {\n if (this.#privateAPI) {\n return res(this);\n }\n\n this.#pendingWaiters.push(res);\n });\n }\n}\n","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 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\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\n//# sourceMappingURL=index.js.map\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\nimport { AccessToken } from '@wix/public-editor-platform-interfaces';\n\nexport enum EditorPlatformSDKAuthErrorCode {\n EmptyAppAuthInstance = 'EmptyAppAuthInstance',\n EmptyAppDefinitionId = 'EmptyAppDefinitionId',\n}\n\nclass EditorPlatformSDKAuthError extends BaseError<EditorPlatformSDKAuthErrorCode> {\n state: Partial<{\n appDefinitionId: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformSDKAuthErrorCode) {\n super(message, code, 'Auth Strategy Error');\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n}\n\nexport const createEditorPlatformSDKAuthError = createErrorBuilder<\n EditorPlatformSDKAuthErrorCode,\n EditorPlatformSDKAuthError\n>(EditorPlatformSDKAuthError);\n\nfunction hasEnoughTimeUntilExpiry(\n expires: Date | undefined,\n expiryBuffer: number,\n) {\n const now = Date.now();\n const expiryTime = expires ? new Date(expires).getTime() : null;\n return expiryTime && expiryTime - now > expiryBuffer;\n}\n\nconst ACCESS_TOKEN_EXPIRY_GRACE_PERIOD = 30 * 60 * 1000; // half an hour\n\nexport const auth = () => {\n let instance: AccessToken;\n\n return {\n getAuthHeaders: async () => {\n const context = await ApplicationContext.getInstance();\n const bindings = context.getBindings();\n const privateAPI = context.getPrivateAPI();\n\n if (!bindings.appDefinitionId) {\n throw createEditorPlatformSDKAuthError(\n EditorPlatformSDKAuthErrorCode.EmptyAppDefinitionId,\n );\n }\n\n if (\n !instance ||\n hasEnoughTimeUntilExpiry(\n instance.expires,\n ACCESS_TOKEN_EXPIRY_GRACE_PERIOD,\n )\n ) {\n instance = await privateAPI.auth.getAccessToken(\n bindings.appDefinitionId,\n await privateAPI.info.getMetaSiteId(),\n );\n }\n\n if (!instance?.token) {\n console.error(\n createEditorPlatformSDKAuthError(\n EditorPlatformSDKAuthErrorCode.EmptyAppAuthInstance,\n ).withAppDefinitionId(bindings.appDefinitionId),\n );\n\n return {\n headers: {\n Authorization: '',\n },\n };\n }\n\n return {\n headers: {\n Authorization: instance.token,\n },\n };\n },\n };\n};\n","import {\n IFrameConsumerEndpoint,\n WorkerConsumerEndpoint,\n} from '@wix/editor-platform-transport';\nimport { PlatformFrameAPI } from '@wix/editor-application/platform-frame-api';\nimport { PlatformWorkerAPI } from '@wix/editor-application/platform-worker-api';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var _EP_TRANSPORT_INIT_KEY: boolean;\n}\n\nconst INIT_KEY = '_EP_TRANSPORT_INIT_KEY';\n\n/**\n * small workaround to run init only for a one time\n */\nif (!globalThis[INIT_KEY]) {\n const isWorker = typeof importScripts === 'function';\n\n /**\n * TODO: probably we can try to split this code somehow\n * and load the only API according to the current env.\n */\n if (isWorker) {\n WorkerConsumerEndpoint.exposeAPI(new PlatformWorkerAPI());\n } else {\n IFrameConsumerEndpoint.exposeAPI(new PlatformFrameAPI());\n }\n\n globalThis[INIT_KEY] = true;\n}\n","import './env';\n\nimport { createHostModule, HostModule } from '@wix/sdk-runtime/host-modules';\nimport { Host } from '@wix/sdk-types';\nimport {\n ApplicationContext,\n EnvironmentContext,\n IAddonContext,\n IEditorApplicationContext,\n} from '@wix/editor-application-context';\n\ninterface IHostContexts {\n environmentContext: EnvironmentContext;\n applicationContext: ApplicationContext<\n IEditorApplicationContext | IAddonContext\n >;\n}\n\ntype UnwrapShape<T> = {\n [K in keyof T]: T[K] extends (contexts: IHostContexts) => infer R ? R : never;\n};\n\nexport class PlatformSDKShape<\n TShape extends Record<\n string,\n (contexts: IHostContexts) => (...args: any[]) => any\n >,\n> {\n constructor(\n public namespace: string,\n private shape: TShape,\n ) {\n // Object.assign(this.shape, {\n // [Symbol(`platform-sdk-shape-namespace`)]: this.namespace,\n // });\n }\n\n build() {\n return createHostModule<Host, TShape>(\n Object.fromEntries(\n Object.entries(this.shape).map(([key, value]) => [\n key,\n (host: IHostContexts) => {\n /**\n * this is case when shapes are used as a host modules,\n * meaning without calling the createClient, and use one from the context\n */\n if (host?.environmentContext && host?.applicationContext) {\n return async (...args: any) => {\n const [environmentContext, applicationContext] =\n await Promise.all([\n host.environmentContext,\n host.applicationContext,\n ]);\n\n return value({\n environmentContext,\n applicationContext,\n })(...args);\n };\n }\n\n /**\n * the fallback to platform's contexts\n * if for some reason they are not available at the host.\n * for instance:\n * - `createClient` is not created or created with a wrong configuration\n */\n return async (...args: any) => {\n const [environmentContext, applicationContext] =\n await Promise.all([\n EnvironmentContext.getInstance(),\n ApplicationContext.getInstance(),\n ]);\n\n return value({\n environmentContext,\n applicationContext,\n })(...args);\n };\n },\n ]),\n ) as unknown as { [K in keyof TShape]: () => TShape[K] },\n ) as UnwrapShape<TShape> & HostModule<UnwrapShape<TShape>, Host>;\n }\n}\n","import { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst applicationShape = new PlatformSDKShape('application', {\n getPrivateAPI({ applicationContext }) {\n return async <TApplicationPrivateAPI = any>() => {\n return applicationContext.getPrivateApplicationAPI() as TApplicationPrivateAPI;\n };\n },\n\n getPublicAPI({ applicationContext }) {\n return async <TApplicationPrivateAPI>(appDefinitionId: string) => {\n const privateAPI = applicationContext.getPrivateAPI();\n\n return privateAPI.applicationManager.getPublicApplicationAPI(\n appDefinitionId,\n ) as TApplicationPrivateAPI;\n };\n },\n\n getAppInstance({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n const bindings = applicationContext.getBindings();\n\n return privateAPI.info.getAppInstance(bindings.appDefinitionId);\n };\n },\n});\n\nexport default applicationShape.build();\n","import { IComponent } from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst componentsShape = new PlatformSDKShape('components', {\n getSelectedComponents({ applicationContext }) {\n return async (): Promise<IComponent[]> => {\n const privateAPI = applicationContext.getPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n\n return Promise.all(\n refs.map((ref: any) => privateAPI.components.getComponent(ref)),\n );\n };\n },\n});\n\nexport default componentsShape.build();\n","import {\n AppEventPayload,\n AllowedEvents,\n} from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst eventsShape = new PlatformSDKShape('events', {\n addEventListener({ applicationContext }) {\n return async (\n name: any,\n // TODO: fix types\n cb: (payload: AppEventPayload<AllowedEvents>) => void,\n ) => {\n return applicationContext.getEvents().addEventListener(name, cb);\n };\n },\n});\n\nexport default eventsShape.build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst infoShape = new PlatformSDKShape('info', {\n getViewMode({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.info.getViewMode();\n };\n },\n\n getLanguageCode({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.info.getLanguageCode();\n };\n },\n});\n\nexport default infoShape.build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum WidgetShapeErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n}\n\nclass WidgetShapeError extends BaseError<WidgetShapeErrorCode> {\n constructor(message: string, code: WidgetShapeErrorCode) {\n super(message, code, 'Widget Error');\n }\n}\n\nexport const createWidgetShapeError = createErrorBuilder<\n WidgetShapeErrorCode,\n WidgetShapeError\n>(WidgetShapeError);\n","import components from '../components';\nimport { createWidgetShapeError, WidgetShapeErrorCode } from './errors';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst getSelectedComponentRef = async () => {\n const selected = await components.getSelectedComponents();\n const compRef = selected[0]?.compRef;\n\n if (!compRef) {\n throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n};\n\nconst widgetShape = new PlatformSDKShape('widget', {\n getProp({ applicationContext }) {\n return async (propName: string): Promise<string> => {\n const privateAPI = applicationContext.getPrivateAPI();\n const compRef = await getSelectedComponentRef();\n\n return privateAPI.customElement.getAttribute(compRef, propName);\n };\n },\n setProp({ applicationContext }) {\n return async (propName: string, value: string): Promise<void> => {\n const privateAPI = applicationContext.getPrivateAPI();\n const compRef = await getSelectedComponentRef();\n\n await privateAPI.customElement.setAttribute(compRef, propName, value);\n };\n },\n});\n\nexport default widgetShape.build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { FontPickerOptions } from '@wix/editor-platform-sdk-types';\n\ninterface IColorValue {\n color: string;\n theme?: string;\n cssVariableName?: string;\n}\n\ninterface IFontValue {\n theme?: string;\n family?: string;\n size?: number;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n cssVariableName?: string;\n}\n\ninterface FontPickerValue {\n font: string;\n textDecoration?: string;\n}\n\ntype ColorPickerValue = string | null | undefined;\n\nconst UNDERLINE_DEFINITION = 'underline';\n\nfunction extractFontVar(fontString: string) {\n const trimmedFont = fontString.trim();\n const match = trimmedFont.match(/var\\((--[\\w-]+),\\s*(.+)\\)/);\n\n if (match) {\n return {\n variableName: match[1],\n fallbackValue: match[2]?.trim() ?? '',\n };\n } else {\n return {\n variableName: undefined,\n fallbackValue: trimmedFont,\n };\n }\n}\n\nfunction parseFontString(fontPickerValue?: FontPickerValue) {\n const font: IFontValue = {\n family: undefined,\n size: undefined,\n };\n\n if (fontPickerValue?.font) {\n const { variableName, fallbackValue } = extractFontVar(\n fontPickerValue.font,\n );\n font.cssVariableName = variableName;\n const parts = fallbackValue.match(/(?:([\"']).*?\\1|\\S)+/g) || [];\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n\n switch (part) {\n case 'bold':\n font.bold = true;\n break;\n case 'italic':\n font.italic = true;\n break;\n default:\n if (part?.endsWith('px')) {\n font.size = parseInt(part, 10);\n } else if (i === parts.length - 1) {\n font.family = part;\n } else {\n font.family = (font.family || '') + ' ' + part;\n }\n }\n }\n }\n if (fontPickerValue?.textDecoration) {\n font.underline = fontPickerValue.textDecoration === UNDERLINE_DEFINITION;\n }\n // since we wrap it with \"\" in the font string, we need to remove it\n font.family = font.family?.trim().replace(/['\"]+/g, '');\n\n return font;\n}\n\nfunction fontValueToCSS(fontValue: IFontValue): string {\n return `${\n fontValue.cssVariableName ? `var(${fontValue.cssVariableName}, ` : ''\n }${fontValue.italic ? 'italic ' : ''}${fontValue.bold ? 'bold ' : ''}${fontValue.size || 16}px ${\n // wrap each font family with quotes\n fontValue.family\n ?.split(',')\n .map((fontFamily) => `\"${fontFamily.replace(/['\"]+/g, '')}\"`)\n .join(',') || 'serif'\n }${fontValue.cssVariableName ? ')' : ''}`;\n}\n\nfunction parseColorString(\n colorPickerValue?: ColorPickerValue,\n): IColorValue | null {\n if (!colorPickerValue) {\n return null;\n }\n const colorString = colorPickerValue!;\n const match = colorString.match(/var\\((--[\\w-]+),\\s*(.+)\\)/);\n\n if (match) {\n return {\n cssVariableName: match[1],\n color: match[2]!,\n };\n } else {\n return {\n color: colorString,\n };\n }\n}\n\nfunction colorValueToCSS(colorValue?: IColorValue | null): string {\n if (!colorValue) {\n return '';\n }\n return colorValue.cssVariableName\n ? `var(${colorValue.cssVariableName}, ${colorValue.color})`\n : colorValue.color;\n}\n\ntype IFontValueInternal = {\n preset?: string;\n editorKey?: string;\n family?: string;\n size?: number;\n style: {\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n };\n htmlTag?: string;\n};\n\nconst fonts = {\n transformFontInternalValue: (value?: IFontValue): IFontValueInternal => {\n if (value) {\n const { theme, cssVariableName, bold, italic, underline, ...rest } =\n value;\n\n return {\n ...rest,\n style: {\n bold,\n italic,\n underline,\n },\n editorKey: cssVariableName || theme || '',\n };\n } else {\n return {\n editorKey: 'font_7',\n family: 'helvetica-w01-roman',\n size: 16,\n style: {},\n };\n }\n },\n};\n\nconst inputsShape = new PlatformSDKShape('inputs', {\n selectColor({ applicationContext }) {\n return async (\n value?: ColorPickerValue,\n options?: {\n onChange?: (value: ColorPickerValue) => void;\n },\n ): Promise<ColorPickerValue> => {\n const privateAPI = applicationContext.getPrivateAPI() as any;\n\n let colorValue: IColorValue | null = parseColorString(value);\n let colorResult = colorValueToCSS(colorValue);\n\n await privateAPI.inputs.openColorPicker(\n {\n color:\n colorValue?.cssVariableName ||\n colorValue?.theme ||\n colorValue?.color,\n },\n ({\n color,\n theme,\n cssVariableTheme,\n }: {\n color: string;\n theme: string;\n cssVariableTheme: string;\n isHover: boolean;\n }) => {\n colorValue = {\n color,\n theme,\n cssVariableName: cssVariableTheme,\n };\n colorResult = colorValueToCSS(colorValue);\n options?.onChange?.(colorResult);\n },\n );\n\n return colorResult;\n };\n },\n\n selectFont({ applicationContext }) {\n return async (\n value?: FontPickerValue,\n options?: {\n onChange?: (value: FontPickerValue) => void;\n },\n ): Promise<FontPickerValue | undefined> => {\n const privateAPI = applicationContext.getPrivateAPI() as any;\n const fontValue = parseFontString(value);\n let _value = value;\n\n await privateAPI.inputs.openFontPickerV2(\n {\n ...options,\n panelSectionsDefinition: {\n htmlTag: 'hidden',\n },\n componentStyle: fonts.transformFontInternalValue(fontValue),\n },\n (font: IFontValue, accessibility: any) => {\n _value = {\n font: fontValueToCSS(font),\n textDecoration: font.underline ? UNDERLINE_DEFINITION : undefined,\n };\n options?.onChange?.(_value);\n },\n );\n\n return _value;\n };\n },\n});\n\nexport default inputsShape.build();\n","import {\n DsItem,\n Style,\n StyleRef,\n OpenColorPickerFn,\n OpenLinkPanelFn,\n} from '@wix/public-editor-platform-interfaces';\nimport { PlatformSDKShape } from './PlatformSDKShape';\n\nconst externalPanels = new PlatformSDKShape('externalPanels', {\n getData({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.getData();\n };\n },\n setData({ applicationContext }) {\n return async (newData: DsItem) => {\n const privateAPI = applicationContext.getPrivateAPI();\n\n return privateAPI.externalPanels.setData(newData);\n };\n },\n getStyle({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.getStyle();\n };\n },\n setStyle({ applicationContext }) {\n return async (newStyle: Style | StyleRef) => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.setStyle(newStyle);\n };\n },\n getTheme({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.getTheme();\n };\n },\n selectMedia({ applicationContext }) {\n return async () => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.selectMedia();\n };\n },\n selectLink({ applicationContext }): OpenLinkPanelFn {\n return async (...options) => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.selectLink(...options);\n };\n },\n selectColor({ applicationContext }): OpenColorPickerFn {\n return async (...options) => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.selectColor(...options);\n };\n },\n translate({ applicationContext }) {\n return async (key: string | string[], values?: Record<string, any>) => {\n const privateAPI = applicationContext.getPrivateAPI();\n return privateAPI.externalPanels.translate(key, values);\n };\n },\n});\n\nexport default externalPanels.build();\n","import type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\nimport {\n ApplicationContext,\n EnvironmentContext,\n} from '@wix/editor-application-context';\n\nexport const editorPlatformFrameHost = (): WixSDKTypes.Host & {\n environmentContext: Promise<EnvironmentContext>;\n applicationContext: Promise<ApplicationContext<any>>;\n essentials: {\n language?: string;\n locale?: string;\n };\n} => {\n const queryParams = new URLSearchParams(window.location.search);\n\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n environmentContext: EnvironmentContext.getInstance(),\n applicationContext: ApplicationContext.getInstance(),\n essentials: queryParams.has('essentials')\n ? JSON.parse(queryParams.get('essentials')!)\n : {},\n };\n};\n","import type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\nimport {\n ApplicationContext,\n EnvironmentContext,\n} from '@wix/editor-application-context';\n\nexport const editorPlatformWorkerHost = (): WixSDKTypes.Host & {\n environmentContext: Promise<EnvironmentContext>;\n applicationContext: Promise<ApplicationContext<any>>;\n} => {\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n environmentContext: EnvironmentContext.getInstance(),\n applicationContext: ApplicationContext.getInstance(),\n };\n};\n","import { auth } from './auth';\n\nexport { default as application } from './application';\nexport { default as components } from './components';\nexport { default as events } from './events';\nexport { default as info } from './info';\nexport { default as widget } from './widget';\nexport { default as inputs } from './inputs';\nexport { default as externalPanels } from './externalPanels';\n\nimport { editorPlatformFrameHost } from './editorPlatformFrameHost';\nimport { editorPlatformWorkerHost } from './editorPlatformWorkerHost';\n\nexport const editor = {\n host: () => {\n const isWorker = typeof importScripts === 'function';\n\n if (isWorker) {\n return editorPlatformWorkerHost();\n }\n\n return editorPlatformFrameHost();\n },\n auth,\n};\n","import { editor } from '@wix/editor';\nimport { createClient } from '@wix/sdk';\n\nexport const enableClient = () => {\n const host = editor.host();\n const auth = editor.auth();\n\n const wixClient = createClient({\n auth,\n host,\n });\n wixClient.enableContext('module');\n};\n"],"mappings":"8LAAA,IAAAA,GAAAC,GAAAC,IAAA,cACA,OAAO,eAAeA,GAAS,aAAc,CAAE,MAAO,EAAK,CAAC,EAC5DA,GAAQ,UAAY,OAKpB,IAAIC,IACH,SAAUA,EAAW,CAClBA,EAAU,mBAAwB,qBAClCA,EAAU,0BAA+B,4BACzCA,EAAU,aAAkB,eAC5BA,EAAU,mBAAwB,oBACtC,GAAGA,KAAcD,GAAQ,UAAYC,GAAY,CAAC,EAAE,ICbpD,IAAAC,GAAAC,GAAAC,IAAA,cAKA,OAAO,eAAeA,GAAS,aAAc,CAAE,MAAO,EAAK,CAAC,ICL5D,IAAAC,GAAAC,GAAAC,GAAA,cACA,IAAIC,GAAmBD,GAAQA,EAAK,kBAAqB,OAAO,OAAU,SAASE,EAAGC,EAAGC,EAAGC,EAAI,CACxFA,IAAO,SAAWA,EAAKD,GAC3B,IAAIE,EAAO,OAAO,yBAAyBH,EAAGC,CAAC,GAC3C,CAACE,IAAS,QAASA,EAAO,CAACH,EAAE,WAAaG,EAAK,UAAYA,EAAK,iBAClEA,EAAO,CAAE,WAAY,GAAM,IAAK,UAAW,CAAE,OAAOH,EAAEC,CAAC,CAAG,CAAE,GAE9D,OAAO,eAAeF,EAAGG,EAAIC,CAAI,CACrC,EAAM,SAASJ,EAAGC,EAAGC,EAAGC,EAAI,CACpBA,IAAO,SAAWA,EAAKD,GAC3BF,EAAEG,CAAE,EAAIF,EAAEC,CAAC,CACf,GACIG,GAAsBP,GAAQA,EAAK,qBAAwB,OAAO,OAAU,SAASE,EAAGM,EAAG,CAC3F,OAAO,eAAeN,EAAG,UAAW,CAAE,WAAY,GAAM,MAAOM,CAAE,CAAC,CACtE,EAAK,SAASN,EAAGM,EAAG,CAChB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yB,EAG3BF,GAAwB,EAEjC,KAAA3E,EACF,ECrBO,IAAM+E,GAAe,IAAM,CAChC,IAAMC,EAAOC,GAAO,KAAK,EACnBC,EAAOD,GAAO,KAAK,EAEPE,GAAa,CAC7B,KAAAD,EACA,KAAAF,CACF,CAAC,EACS,cAAc,QAAQ,CAClC","names":["require_EventType","__commonJSMin","exports","EventType","require_Inputs","__commonJSMin","exports","require_dist","__commonJSMin","exports","__createBinding","o","m","k","k2","desc","__setModuleDefault","v","__importStar","ownKeys","ar","mod","result","i","__exportStar","p","WixSDKTypes","EventType_1","BaseError","_BaseError","_message","_code","_prefix","message","displayName","__publicField","parent","x","state","acc","key","value","messages","_messages","parentError","parentErrorMessage","thrownErrorMessage","createErrorBuilder","factory","throwException","code","instance","EditorPlatformInternalError","BaseError","message","code","__publicField","host","createEditorPlatformInternalError","createErrorBuilder","_EventEmitter","__publicField","isSilent","queue","event","callback","uid","step","cb","result","e","EventEmitter","PlatformPrivateEvent","PlatformLifecycleEvent","PlatformAppEvent","PlatformAppEventsFactories","appDefinitionId","PlatformAppEventEmitter","app","url","scope","EventEmitter","__publicField","_DMEventsBridge","events","event","PlatformPrivateEvent","_event","DMEventsBridge","errorMessage","message","internalErrorMessage","FUNCTION_MARKER","ACCESSOR_MARKER","ACCESSOR_GET_POINTER","ACCESSOR_SET_POINTER","WITH_ACCESSOR_INDICATOR","NO_ACCESSOR_INDICATOR","PATH_SEPARATOR","ENCODER_MARKER","ENCODER_EMPTY_MARKER","extractPointer","pointer","isFinalNode","instance","isSerializableType","beautifyPath","path","beautifyBreadcrumbs","breadcrumbs","createStructureEncoder","marker","config","arrayEncoder","next","value","index","key","_key","mapEncoder","setEncoder","objectEncoder","root","forEachMember","members","parent","encoders","getDescriptor","obj","_instance","descriptor","callback","ancestors","getContextPointer","_breadcrumbs","acc","iterateStructure","p","encoder","_encoder","serialize","input","registerFunctionMarker","buffer","appendValue","appendFunction","args","context","_value","deserialize","replaceFunctionMarker","pointers","i","point","has","_iterator","hasGetter","hasSetter","getter","MessageType","Message","_Message","type","payload","__publicField","correlationId","data","parsed","MessageCleanup","MessageResponse","MessageResponseError","MessageCall","buildFunctionMarkerKey","_registry","_messageEvents","_functionMarkers","_pendingFunctionResponse","ThreadChannel","port","__privateAdd","params","functionMarkerKey","callId","__privateGet","_errorMessage","error","response","event","replacedFunction","props","resolve","reject","ConsumerChannel","HandshakeEvent","_listeners","_activePort","_AbstractHandshake_instances","notifyHandshakeListeners_fn","AbstractHandshake","postMessage","onMessage","__privateAdd","port","__privateSet","__privateMethod","__privateGet","callback","internalErrorMessage","cb","_hostIsAlive","_memberId","_ConsumerHandshake_instances","initHandshake_fn","onHostPing_fn","onHostPort_fn","ConsumerHandshake","AbstractHandshake","postMessage","onMessage","__privateAdd","__privateMethod","payload","HandshakeEvent","event","__privateGet","__privateSet","targetMemberId","port","internalErrorMessage","AbstractConsumerEndpoint","IFrameConsumerEndpoint","_IFrameConsumerEndpoint","__publicField","ConsumerHandshake","message","listener","instance","port","ConsumerChannel","WorkerConsumerEndpoint","_WorkerConsumerEndpoint","AbstractConsumerEndpoint","__publicField","ConsumerHandshake","msg","listener","instance","port","ConsumerChannel","WorkerEventsBridge","platformAppEvents","event","PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","cb","PlatformConsumerEnvironmentAPIType","AbstractEnvironmentAPI","env","EditorPlatformApplicationContextErrorCode","EditorPlatformApplicationContextErrorCode2","EditorPlatformApplicationContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformApplicationContextError","createErrorBuilder","transformEventPayload","eventPayload","privateAPI","componentRefs","components","ref","ApplicationBoundEvents","events","type","payload","eventType","fn","isAppMatch","transformPayload","WAIT_INJECTED_TIMEOUT","WAIT_INJECTED_RETRY_COUNT","ContextInjectionStatus","uuid","resolve","reject","injected","timeoutId","retryCount","timeout","error","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","PlatformEnvironment2","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","applicationContext","environment","ApplicationContext","DESIGN_SYSTEM_STYLES_MAP","PlatformFrameAPI","__privateAdd","_events","PlatformAppEventEmitter","_eventsBridge","__privateGet","_privateAPI","_applicationPrivateAPI","host","isAlreadyLoaded","link","props","applicationPrivateAPI","__privateSet","WorkerEventsBridge","platformAppEvents","event","PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","cb","EditorPlatformApplicationContextErrorCode","EditorPlatformApplicationContextErrorCode2","EditorPlatformApplicationContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformApplicationContextError","createErrorBuilder","transformEventPayload","eventPayload","privateAPI","componentRefs","components","ref","ApplicationBoundEvents","events","type","payload","eventType","fn","isAppMatch","transformPayload","WAIT_INJECTED_TIMEOUT","WAIT_INJECTED_RETRY_COUNT","ContextInjectionStatus","uuid","resolve","reject","injected","timeoutId","retryCount","timeout","error","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","PlatformEnvironment2","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","applicationContext","environment","ApplicationContext","EditorPlatformApplicationErrorCode","EditorPlatformApplicationError","apiMethod","apiType","createEditorPlatformApplicationError","APPLICATION_REGISTRY_KEY","executeApplication","spec","bundle","executable","instance","applicationRegistryCallback","_instance","e","unsubscribe","PlatformApplicationContainer","privateApi","__privateAdd","_apps","_privateAPI","_events","__privateSet","__privateGet","appSpec","appDefId","res","PlatformConsumerEnvironmentAPIType","AbstractEnvironmentAPI","env","PlatformWorkerAPI","PlatformAppEventEmitter","_eventsBridge","_container","_pendingWaiters","props","buildPrivateAPI","app","EditorPlatformApplicationContextErrorCode","EditorPlatformApplicationContextErrorCode2","EditorPlatformApplicationContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformApplicationContextError","createErrorBuilder","transformEventPayload","eventPayload","privateAPI","componentRefs","components","ref","ApplicationBoundEvents","events","event","type","payload","PlatformAppEvent","eventType","fn","isAppMatch","transformPayload","WAIT_INJECTED_TIMEOUT","WAIT_INJECTED_RETRY_COUNT","ContextInjectionStatus","uuid","resolve","reject","injected","timeoutId","retryCount","timeout","error","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","PlatformEnvironment2","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","applicationContext","environment","ApplicationContext","EditorPlatformSDKAuthError","createEditorPlatformSDKAuthError","hasEnoughTimeUntilExpiry","expires","expiryBuffer","now","expiryTime","ACCESS_TOKEN_EXPIRY_GRACE_PERIOD","auth","instance","bindings","INIT_KEY","WorkerConsumerEndpoint","PlatformWorkerAPI","IFrameConsumerEndpoint","PlatformFrameAPI","PlatformSDKShape","namespace","shape","createHostModule","key","value","host","args","applicationShape","index$4","componentsShape","refs","eventsShape","name","cb","index$3","infoShape","index$2","WidgetShapeErrorCode","WidgetShapeError","createWidgetShapeError","getSelectedComponentRef","compRef","widgetShape","propName","index$1","UNDERLINE_DEFINITION","extractFontVar","fontString","trimmedFont","match","parseFontString","fontPickerValue","font","variableName","fallbackValue","parts","i","part","fontValueToCSS","fontValue","fontFamily","parseColorString","colorPickerValue","colorString","colorValueToCSS","colorValue","fonts","theme","cssVariableName","bold","italic","underline","rest","inputsShape","options","colorResult","color","cssVariableTheme","_value","accessibility","index","externalPanels","newData","newStyle","values","externalPanels$1","editorPlatformFrameHost","queryParams","editorPlatformWorkerHost","editor","enableClient","host","editor","auth","createClient"]}