@wix/cli-app 1.1.133 → 1.1.135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{AddPermissionCommand-TSG2QSBL.js → AddPermissionCommand-J747FJOD.js} +2 -2
- package/build/{DevCommand-7MZLBDES.js → DevCommand-WHO2FPZA.js} +11 -11
- package/build/{GenerateCommand-5UI54KBU.js → GenerateCommand-G7GZAQRU.js} +8 -8
- package/build/{LogsCommand-WFRYKHOJ.js → LogsCommand-UYRXNYT6.js} +4 -4
- package/build/PreviewCommand-AK7QEFIM.js +19 -0
- package/build/ReleaseCommand-DK24QEHP.js +23 -0
- package/build/{ServeCommand-H4SEVUAN.js → ServeCommand-P52GP36W.js} +4 -4
- package/build/{build-DSGVV5ZV.js → build-QHEECRN2.js} +6 -6
- package/build/{chunk-JL3LD5NY.js → chunk-3FSEHEJA.js} +3 -3
- package/build/{chunk-FLD47ENF.js → chunk-4GVN5OSZ.js} +105 -39
- package/build/{chunk-FLD47ENF.js.map → chunk-4GVN5OSZ.js.map} +1 -1
- package/build/{chunk-Z5ULQGAD.js → chunk-5I6K4LMZ.js} +15 -9
- package/build/{chunk-Z5ULQGAD.js.map → chunk-5I6K4LMZ.js.map} +1 -1
- package/build/{chunk-GD5PKY3K.js → chunk-CXBQHWIM.js} +2 -2
- package/build/{chunk-XLQ3FRLZ.js → chunk-HBEVHWYL.js} +30 -10
- package/build/{chunk-XLQ3FRLZ.js.map → chunk-HBEVHWYL.js.map} +1 -1
- package/build/{chunk-QYDPX5NW.js → chunk-HPHTU6UB.js} +3 -3
- package/build/{chunk-ANYJPSC5.js → chunk-I2JVZXWM.js} +2 -2
- package/build/{chunk-LXB667TS.js → chunk-IPSCL6EX.js} +4 -4
- package/build/{chunk-MNXUG25I.js → chunk-KJXVS3IU.js} +4 -4
- package/build/{chunk-5WFSVZ46.js → chunk-L6XIG76V.js} +3 -3
- package/build/{chunk-FDSIXM6K.js → chunk-MFPD7G6B.js} +2 -2
- package/build/{chunk-GWE3BRHX.js → chunk-P7IRRCF7.js} +4 -4
- package/build/chunk-P7IRRCF7.js.map +1 -0
- package/build/{chunk-CGB7ASKC.js → chunk-QVI67Q6A.js} +2 -2
- package/build/{chunk-Z4TJCHCK.js → chunk-RPHZ4OP3.js} +6 -4
- package/build/{chunk-Z4TJCHCK.js.map → chunk-RPHZ4OP3.js.map} +1 -1
- package/build/{chunk-DYQDQIEK.js → chunk-SMEOB2J6.js} +6 -6
- package/build/{chunk-LQ4UVRDE.js → chunk-V4VNLYCR.js} +2 -2
- package/build/{chunk-RD5ZK7QU.js → chunk-W6OUY5DV.js} +6 -6
- package/build/{chunk-ESWUL5ZX.js → chunk-Z6H5SRVH.js} +2 -2
- package/build/cloudflare-runtime/entry.js +3 -3
- package/build/cloudflare-runtime/getRegisteredExtensions.js +3 -3
- package/build/index.js +23 -23
- package/build/platform-sdk/{chunk-WBKL5IQV.js → chunk-RJD2G2AE.js} +2 -2
- package/build/platform-sdk/chunk-RJD2G2AE.js.map +1 -0
- package/build/platform-sdk/{chunk-R7FAXXP7.js → chunk-Y4HYNW3N.js} +1 -1
- package/build/platform-sdk/chunk-Y4HYNW3N.js.map +1 -0
- package/build/platform-sdk/dashboard.js +1 -1
- package/build/platform-sdk/editor.js +2 -2
- package/build/platform-sdk/editor.js.map +1 -1
- package/build/platform-sdk/sdk-context.js +1 -1
- package/build/platform-sdk/sdk-context.js.map +1 -1
- package/build/platform-sdk/site.js +1 -1
- package/build/{preview-2NDGCDVM.js → preview-3ABHWSP4.js} +13 -13
- package/build/{release-EYSGZ3OW.js → release-DZGPFN7M.js} +15 -15
- package/build/{render-command-5BZDYMWG.js → render-command-TDM7CFXE.js} +5 -5
- package/package.json +5 -5
- package/templates/custom-element/files/element.tsx.ejs +1 -1
- package/build/PreviewCommand-LL5LFTMH.js +0 -19
- package/build/ReleaseCommand-RKFXIF3L.js +0 -23
- package/build/chunk-GWE3BRHX.js.map +0 -1
- package/build/platform-sdk/chunk-R7FAXXP7.js.map +0 -1
- package/build/platform-sdk/chunk-WBKL5IQV.js.map +0 -1
- /package/build/{AddPermissionCommand-TSG2QSBL.js.map → AddPermissionCommand-J747FJOD.js.map} +0 -0
- /package/build/{DevCommand-7MZLBDES.js.map → DevCommand-WHO2FPZA.js.map} +0 -0
- /package/build/{GenerateCommand-5UI54KBU.js.map → GenerateCommand-G7GZAQRU.js.map} +0 -0
- /package/build/{LogsCommand-WFRYKHOJ.js.map → LogsCommand-UYRXNYT6.js.map} +0 -0
- /package/build/{PreviewCommand-LL5LFTMH.js.map → PreviewCommand-AK7QEFIM.js.map} +0 -0
- /package/build/{ReleaseCommand-RKFXIF3L.js.map → ReleaseCommand-DK24QEHP.js.map} +0 -0
- /package/build/{ServeCommand-H4SEVUAN.js.map → ServeCommand-P52GP36W.js.map} +0 -0
- /package/build/{build-DSGVV5ZV.js.map → build-QHEECRN2.js.map} +0 -0
- /package/build/{chunk-JL3LD5NY.js.map → chunk-3FSEHEJA.js.map} +0 -0
- /package/build/{chunk-GD5PKY3K.js.map → chunk-CXBQHWIM.js.map} +0 -0
- /package/build/{chunk-QYDPX5NW.js.map → chunk-HPHTU6UB.js.map} +0 -0
- /package/build/{chunk-ANYJPSC5.js.map → chunk-I2JVZXWM.js.map} +0 -0
- /package/build/{chunk-LXB667TS.js.map → chunk-IPSCL6EX.js.map} +0 -0
- /package/build/{chunk-MNXUG25I.js.map → chunk-KJXVS3IU.js.map} +0 -0
- /package/build/{chunk-5WFSVZ46.js.map → chunk-L6XIG76V.js.map} +0 -0
- /package/build/{chunk-FDSIXM6K.js.map → chunk-MFPD7G6B.js.map} +0 -0
- /package/build/{chunk-CGB7ASKC.js.map → chunk-QVI67Q6A.js.map} +0 -0
- /package/build/{chunk-DYQDQIEK.js.map → chunk-SMEOB2J6.js.map} +0 -0
- /package/build/{chunk-LQ4UVRDE.js.map → chunk-V4VNLYCR.js.map} +0 -0
- /package/build/{chunk-RD5ZK7QU.js.map → chunk-W6OUY5DV.js.map} +0 -0
- /package/build/{chunk-ESWUL5ZX.js.map → chunk-Z6H5SRVH.js.map} +0 -0
- /package/build/{preview-2NDGCDVM.js.map → preview-3ABHWSP4.js.map} +0 -0
- /package/build/{release-EYSGZ3OW.js.map → release-DZGPFN7M.js.map} +0 -0
- /package/build/{render-command-5BZDYMWG.js.map → render-command-TDM7CFXE.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-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/public-editor-platform-errors/src/BaseError.ts","../../../node_modules/@wix/public-editor-platform-errors/src/EditorPlatformInternalError.ts","../../../node_modules/@wix/editor-platform-contexts/src/errors.ts","../../../node_modules/@wix/editor-platform-contexts/src/ApplicationBoundEvents/transformEventPayload.ts","../../../node_modules/@wix/editor-platform-contexts/src/ApplicationBoundEvents/ApplicationBoundEvents.ts","../../../node_modules/@wix/editor-platform-contexts/src/contexts/ContextInjectionStatus.ts","../../../node_modules/@wix/editor-platform-contexts/src/contexts/EnvironmentContext.ts","../../../node_modules/@wix/editor-platform-contexts/src/contexts/ApplicationContext.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/hash.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-platform-environment-api/src/api/ApplicationEventsBridge/WorkerEventsBridge.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/AbstractEnvironmentAPI.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformFrameAPI/PlatformFrameAPI.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformApplicationContainer/errors.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformApplicationContainer/executeApplication.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformApplicationContainer/PlatformApplicationContainer.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformWorkerAPI.ts","../../../node_modules/@wix/editor-platform-environment-api/src/EditorPlatformContextEnvironment.ts","../../../node_modules/@wix/editor-platform-environment-api/src/errors.ts","../../../node_modules/@wix/editor-platform-environment-api/src/EditorPlatformEnvironmentProxy.ts","../../../node_modules/@wix/editor/node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/editor/node_modules/@wix/sdk-runtime/build/context-v2.js","../../../node_modules/@wix/editor/node_modules/@wix/sdk-runtime/build/host-modules.js","../../../node_modules/@wix/editor/src/env.ts","../../../node_modules/@wix/editor/src/auth.ts","../../../node_modules/@wix/editor/src/PlatformSDKShape.ts","../../../node_modules/@wix/editor/src/BaseSDKShape.ts","../../../node_modules/@wix/editor/src/application/index.ts","../../../node_modules/@wix/editor/src/events/index.ts","../../../node_modules/@wix/editor/src/elements/index.ts","../../../node_modules/@wix/editor/src/info/index.ts","../../../node_modules/@wix/editor/src/widget/errors.ts","../../../node_modules/@wix/editor/src/inputs/utils.ts","../../../node_modules/@wix/editor/src/widget/index.ts","../../../node_modules/@wix/editor/src/inputs/index.ts","../../../node_modules/@wix/editor/src/panels/index.ts","../../../node_modules/@wix/editor/src/modals/index.ts","../../../node_modules/@wix/editor/src/element/index.ts","../../../node_modules/@wix/editor/src/preferences/index.ts","../../../node_modules/@wix/editor/src/externalPanels/index.ts","../../../node_modules/@wix/editor/src/controllers/errors.ts","../../../node_modules/@wix/editor/src/controllers/index.ts","../../../node_modules/@wix/editor/src/bindings/index.ts","../../../node_modules/@wix/editor/src/bindingsProviders/index.ts","../../../node_modules/@wix/editor/src/adminHost.ts","../../../node_modules/@wix/editor/src/host.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 () {\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})();\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 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 editorType?: string;\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 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","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformContextErrorCode {\n IncorrectEnvironment = 'IncorrectEnvironment',\n}\n\nclass EditorPlatformContextError extends BaseError<EditorPlatformContextErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformContextErrorCode) {\n super(message, code, 'EP Context 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\nexport const createEditorPlatformContextError = createErrorBuilder<\n EditorPlatformContextErrorCode,\n EditorPlatformContextError\n>(EditorPlatformContextError);\n","import type { ComponentRef } from '@wix/public-editor-platform-interfaces';\nimport { AllowedEvents, AppEventPayload, PrivateAPIFixMe } from './types';\nimport { IElement } from '@wix/public-editor-platform-interfaces';\n\n// TODO: remove events shape and remove payload transformations\nexport async function transformEventPayload<T extends AllowedEvents>(\n eventPayload: Record<string, string>,\n privateAPI: PrivateAPIFixMe,\n): Promise<AppEventPayload<T>> {\n if (!eventPayload?.type) {\n return eventPayload as AppEventPayload<T>;\n }\n\n switch (eventPayload.type) {\n case 'componentSelectionChanged':\n const componentRefs = (eventPayload.componentRefs ||\n []) as unknown as ComponentRef[];\n\n const components = (await Promise.all(\n componentRefs.map((ref) => {\n return privateAPI.components.getComponent(ref);\n }),\n )) as IElement[];\n\n return {\n type: eventPayload.type,\n components,\n } as AppEventPayload<T>;\n\n default:\n return eventPayload as AppEventPayload<T>;\n }\n}\n","import {\n PlatformAppEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\nimport { AllowedEvents, AppEventPayload, PrivateAPIFixMe } from './types';\nimport { transformEventPayload } from './transformEventPayload';\n\nexport type OmitEventMeta<T> = T extends { meta: any } ? Omit<T, 'meta'> : T;\n\n/**\n * TODO: should not be in this package\n */\nexport class ApplicationBoundEvents {\n private events: PlatformAppEventEmitter;\n public subscribe;\n public commit;\n public startTransaction;\n public silent;\n\n constructor(\n private appDefinitionId: string | null,\n events: PlatformAppEventEmitter,\n private privateAPI: PrivateAPIFixMe,\n ) {\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\n public notify(event: OmitEventMeta<IPlatformAppEvent>) {\n this.events.notify({\n type: event.type,\n payload: event.payload,\n meta: {\n appDefinitionId: this.appDefinitionId,\n },\n } as IPlatformAppEvent);\n }\n\n notifyCustomEvent(type: string, payload: Record<string, string>) {\n this.notify({\n type: PlatformAppEvent.CustomEvent,\n payload: {\n ...payload,\n type,\n },\n });\n }\n\n /**\n * TODO: we should use same interface for all events\n * (subscribe vs addEventListener)\n */\n public addEventListener<EventType extends AllowedEvents>(\n eventType: EventType,\n fn: (payload: AppEventPayload<EventType>) => void,\n ) {\n return this.events.subscribe(async (event) => {\n const isAppMatch =\n event.meta?.appDefinitionId === this.appDefinitionId ||\n event.meta?.appDefinitionId === null;\n\n const transformPayload = () =>\n transformEventPayload<EventType>(event.payload, this.privateAPI);\n\n // as an exception to skip autocomplete\n if ((eventType as string) === '*') {\n fn(await transformPayload());\n /**\n * We need to check for app match here to not listen app's own events\n */\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","import {\n createEditorPlatformContextError,\n EditorPlatformContextErrorCode,\n} from '../errors';\n\nconst WAIT_INJECTED_TIMEOUT = 200;\nconst WAIT_INJECTED_RETRY_COUNT = 50;\n\nexport class ContextInjectionStatus {\n injectionUUID: string;\n injectionUUID_Deprecated: string;\n\n constructor(uuid: string) {\n this.injectionUUID_Deprecated = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;\n this.injectionUUID = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY#0.1`;\n\n const promise = this.#getGlobalInjectionPromise();\n\n if (!promise) {\n this.#createGlobalInjectionPromise();\n }\n }\n\n #getGlobalInjectionPromise() {\n // @ts-expect-error xxx\n const ref = globalThis[this.injectionUUID];\n return ref?.promise;\n }\n\n #createGlobalInjectionPromise() {\n let _resolve;\n\n const promise = new Promise<void>((resolve) => {\n _resolve = resolve;\n });\n\n // @ts-expect-error xxx\n globalThis[this.injectionUUID] = {\n promise,\n resolve: _resolve,\n };\n\n /**\n * as soon as new latest-version promise is created\n * override existing deprecated promise and resolve it\n * as soon as latest is resolved\n */\n // @ts-expect-error xxx\n globalThis[this.injectionUUID_Deprecated] = new Promise((resolve) => {\n promise.then(resolve);\n });\n }\n\n resolveInjected() {\n // @ts-expect-error xxx\n globalThis[this.injectionUUID]?.resolve();\n }\n\n waitInjected() {\n return new Promise<void>((resolve, reject) => {\n let injected = false;\n let timeoutId: ReturnType<typeof setTimeout>;\n let retryCount = 0;\n\n const timeout = () => {\n if (injected) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n retryCount++;\n\n if (retryCount < WAIT_INJECTED_RETRY_COUNT) {\n /**\n * just log that we are re-trying to connect (each 2 sec+-)\n */\n if (retryCount % 10 === 0) {\n console.log(\n createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'contexts are not resolved, still re-trying',\n ).withMessage(`try number ${retryCount}`).message,\n );\n }\n\n timeout();\n\n return;\n }\n\n if (!injected) {\n const error = createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'contexts are not resolved, threw by timeout',\n );\n\n reject(error);\n }\n }, WAIT_INJECTED_TIMEOUT);\n };\n\n timeout();\n\n this.#getGlobalInjectionPromise()?.then(() => {\n injected = true;\n clearTimeout(timeoutId);\n resolve();\n });\n });\n }\n}\n","import { PlatformAppEventEmitter } from '@wix/public-editor-platform-events';\nimport { WithPromiseFunctions } from '@wix/editor-platform-transport';\nimport {\n createEditorPlatformContextError,\n EditorPlatformContextErrorCode,\n} from '../errors';\nimport { ContextInjectionStatus } from './ContextInjectionStatus';\n\nexport type IPrivateAPIFixMe = any; // TODO: replace with the real type\n\nexport const ENVIRONMENT_CONTEXT_KEY = '__ENVIRONMENT_CONTEXT_KEY';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __ENVIRONMENT_CONTEXT_KEY: EnvironmentContext;\n}\n\nexport enum PlatformEnvironment {\n Worker = 'Worker',\n Frame = 'Frame',\n // TODO - rename to MainThread\n ComponentPanel = 'ComponentPanel',\n}\n\nexport interface IEnvironmentContext {\n environment: PlatformEnvironment;\n privateApi: WithPromiseFunctions<IPrivateAPIFixMe>;\n events: PlatformAppEventEmitter;\n /**\n * Probably, we need to rename this prop\n */\n applicationAPIs?: Record<string, any>;\n}\n\nexport class EnvironmentContext {\n private static status = new ContextInjectionStatus('environment');\n\n static async inject(context: IEnvironmentContext) {\n if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {\n throw createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'Environment context already exists and should not be overridden',\n );\n }\n\n globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);\n this.status.resolveInjected();\n }\n\n static async getInstance(): Promise<EnvironmentContext> {\n await this.status.waitInjected();\n return globalThis[ENVIRONMENT_CONTEXT_KEY];\n }\n\n constructor(private environmentContext: IEnvironmentContext) {}\n\n getPrivateAPI() {\n return this.environmentContext.privateApi;\n }\n\n getEvents() {\n return this.environmentContext.events;\n }\n\n getApplicationAPIs() {\n return this.environmentContext.applicationAPIs ?? {};\n }\n\n getEnvironment() {\n return this.environmentContext.environment;\n }\n}\n","import {\n createEditorPlatformContextError,\n EditorPlatformContextErrorCode,\n} from '../errors';\n\nimport { ApplicationBoundEvents } from '../ApplicationBoundEvents';\nimport { EnvironmentContext } from './EnvironmentContext';\nimport { ContextInjectionStatus } from './ContextInjectionStatus';\n\nexport const APPLICATION_CONTEXT_KEY = '__APPLICATION_CONTEXT_KEY';\ndeclare global {\n // eslint-disable-next-line no-var\n var __APPLICATION_CONTEXT_KEY: ApplicationContext;\n}\n\n/**\n * renamed: IApplicationContext\n * there is no sense to split context by application type or running context\n * - addon\n * - application\n * - builder component\n * - panel or whatever\n * sdk context should be a union of all available options\n */\nexport interface IPlatformSDKContext {\n manifestContextId?: string | null;\n appDefinitionId?: string | null;\n /**\n * TODO: get rid of data prop, use root props\n */\n data?: {\n toolPanelConfig: {\n url: string;\n width: string;\n height: string;\n initialPosition: {\n x: string;\n y: string;\n };\n };\n };\n}\n\nexport class ApplicationContext {\n private static status = new ContextInjectionStatus('application');\n\n /**\n * TODO: use generics for context type\n * - application\n * - editor\n */\n static async inject(context: IPlatformSDKContext) {\n // const environment = await EnvironmentContext.getInstance();\n\n // if (environment.getEnvironment() !== PlatformEnvironment.Frame) {\n // throw createEditorPlatformContextError(\n // EditorPlatformContextErrorCode.IncorrectEnvironment,\n // 'Application context can be injected only in frame environment',\n // );\n // }\n\n if (globalThis[APPLICATION_CONTEXT_KEY]) {\n throw createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'Application context already exists and should not be overridden',\n );\n }\n\n globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(\n context,\n await EnvironmentContext.getInstance(),\n );\n\n this.status.resolveInjected();\n }\n\n static async getInstance() {\n if (typeof __APPLICATION_CONTEXT_KEY !== 'undefined') {\n /**\n * NOTE it is taken not from global\n * __APPLICATION_CONTEXT_KEY is the variable which set during\n * application bundle execution using new Function() approach\n */\n return __APPLICATION_CONTEXT_KEY as ApplicationContext;\n }\n\n await this.status.waitInjected();\n\n return globalThis[APPLICATION_CONTEXT_KEY] as ApplicationContext;\n\n // const environment = await EnvironmentContext.getInstance();\n\n // if (environment.getEnvironment() === PlatformEnvironment.Frame) {\n // await this.status.waitInjected();\n // return globalThis[\n // APPLICATION_CONTEXT_KEY\n // ] as ApplicationContext<TContext>;\n // } else {\n // /**\n // * NOTE it is taken not from global\n // * __APPLICATION_CONTEXT_KEY is the variable which set during\n // * application bundle execution using new Function() approach\n // */\n // return __APPLICATION_CONTEXT_KEY as ApplicationContext<TContext>;\n // }\n }\n\n private events: ApplicationBoundEvents;\n\n constructor(\n private context: IPlatformSDKContext,\n private environment: EnvironmentContext,\n ) {\n this.events = new ApplicationBoundEvents(\n context.appDefinitionId ? context.appDefinitionId : null,\n this.environment.getEvents(),\n this.environment.getPrivateAPI(),\n );\n }\n\n getContext() {\n return this.context;\n }\n\n getAppDefinitionId() {\n return this.context.appDefinitionId;\n }\n\n getManifestContextId() {\n return this.context.manifestContextId;\n }\n\n getEvents() {\n return this.events;\n }\n\n getEnvironmentContext() {\n return this.environment;\n }\n\n getPrivateAPI() {\n return this.environment.getPrivateAPI();\n }\n\n getPrivateApplicationAPI() {\n const appDefinitionId = this.getAppDefinitionId();\n\n if (!appDefinitionId) {\n throw createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'appDefinitionId is not available',\n );\n }\n\n return this.environment.getApplicationAPIs()[appDefinitionId];\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","/**\n * it would be good to use performance.now()\n * but it some cases performance API is not available\n */\nexport function hash() {\n const _performance = globalThis['performance'];\n\n if (_performance && _performance.now) {\n return _performance.now();\n }\n\n let result = '';\n const characters =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n const charactersLength = characters.length;\n\n let counter = 0;\n\n const length = 10;\n while (counter < length) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n counter += 1;\n }\n\n return result;\n}\n","import { deserialize, serialize } from './serializer';\nimport { hash } from './hash';\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-${hash()}`;\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 enum HandshakeEvent_Deprecated {\n Greeting = 'Greeting',\n RequestPort = 'RequestPort',\n Port = 'Port',\n}\n\nexport type ConsumerEvent =\n | {\n type: HandshakeEvent.Ping;\n }\n | {\n type: HandshakeEvent.RequestPort;\n memberId: string;\n }\n /**\n * @deprecated\n * backward compatibility\n */\n | {\n type: HandshakeEvent_Deprecated.Greeting;\n memberId: string;\n }\n /**\n * @deprecated\n * backward compatibility\n */\n | {\n type: HandshakeEvent_Deprecated.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 {\n ConsumerEvent,\n HandshakeEvent,\n HandshakeEvent_Deprecated,\n HostEvent,\n} 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 /**\n * @deprecated\n * backward compatibility\n */\n case HandshakeEvent_Deprecated.Greeting: {\n if (!payload?.memberId && payload?.memberId === 'host') {\n return;\n }\n\n this.postMessage(\n JSON.stringify({\n memberId: 'host',\n type: HandshakeEvent_Deprecated.Greeting,\n }),\n );\n break;\n }\n\n /**\n * @deprecated\n * backward compatibility\n */\n case HandshakeEvent_Deprecated.RequestPort: {\n const messageChannel = this.#createMessageChannel();\n this.setActivePort(messageChannel?.port1);\n\n this.postMessage(\n JSON.stringify({\n memberId: 'host',\n targetMemberId: payload.memberId,\n type: HandshakeEvent_Deprecated.Port,\n }),\n messageChannel.port2,\n );\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 {\n HostEvent,\n HandshakeEvent,\n ConsumerEvent,\n HandshakeEvent_Deprecated,\n} from './events';\n\nimport {\n AbstractHandshake,\n IOnMessage,\n IPostMessage,\n} from './AbstractHandshake';\nimport { internalErrorMessage } from '../error';\nimport { hash } from '../hash';\n\nexport class ConsumerHandshake extends AbstractHandshake {\n #hostIsAlive = false;\n #memberId = `consumer-${hash()}`;\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 ApplicationEventsBridge {\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 {\n ApplicationContext,\n EnvironmentContext,\n PlatformEnvironment,\n} from '@wix/editor-platform-contexts';\nimport { PlatformAppEventEmitter } from '@wix/public-editor-platform-events';\nimport { IPrivateAPIFixMe } from './types';\nimport { IPlatformSDKContext } from '@wix/editor-platform-contexts';\n\nexport 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 TApiType extends PlatformConsumerEnvironmentAPIType,\n TEnv extends PlatformEnvironment,\n> {\n protected constructor(\n public type: TApiType,\n public envType: TEnv,\n ) {}\n\n abstract initEnvironment(props: unknown): void;\n\n async injectEnvironmentContext({\n events,\n privateApi,\n }: {\n events: PlatformAppEventEmitter;\n privateApi: IPrivateAPIFixMe;\n applicationAPIs?: Record<string, any>;\n }) {\n await EnvironmentContext.inject({\n environment: this.envType,\n events,\n privateApi,\n applicationAPIs: {},\n });\n }\n\n async injectApplicationContext(context: IPlatformSDKContext) {\n await ApplicationContext.inject(context);\n }\n}\n","import {\n IPlatformAppEvent,\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport {\n IPlatformSDKContext,\n PlatformEnvironment,\n} from '@wix/editor-platform-contexts';\n\nimport { ApplicationEventsBridge } from '../ApplicationEventsBridge';\nimport { IPrivateAPIFixMe } from '../types';\n\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\n\nconst DESIGN_SYSTEM_STYLES_MAP = {\n classic:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css',\n studio:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css',\n};\n\nexport class PlatformFrameAPI extends AbstractEnvironmentAPI<\n PlatformConsumerEnvironmentAPIType.Frame,\n PlatformEnvironment.Frame\n> {\n #events = new PlatformAppEventEmitter();\n #eventsBridge = new ApplicationEventsBridge(this.#events);\n #privateAPI: IPrivateAPIFixMe;\n #applicationPrivateAPI: any;\n\n constructor() {\n super(PlatformConsumerEnvironmentAPIType.Frame, PlatformEnvironment.Frame);\n\n this.#injectGlobalCSSTokens();\n }\n\n #injectGlobalCSSTokens() {\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 /**\n *\n * We need to introduce context versions\n * to simplify handling the backward compatibility issues\n */\n async initEnvironment(props: {\n // backward-compatibility\n appDefinitionId?: string;\n context: IPlatformSDKContext;\n privateAPI: IPrivateAPIFixMe;\n applicationPrivateAPI: any;\n }) {\n const { applicationPrivateAPI, privateAPI, context } = props;\n\n /**\n * backward-compatibility\n */\n const _appDefinitionId =\n props.context?.appDefinitionId ?? props.appDefinitionId;\n\n const _context = props.context\n ? props.context\n : {\n appDefinitionId: _appDefinitionId,\n };\n\n this.#applicationPrivateAPI = applicationPrivateAPI;\n this.#privateAPI = privateAPI;\n\n await this.injectEnvironmentContext({\n privateApi: privateAPI,\n events: this.#events,\n applicationAPIs: _appDefinitionId\n ? {\n [_appDefinitionId]: this.#applicationPrivateAPI,\n }\n : {},\n });\n\n await this.injectApplicationContext(_context);\n }\n\n notify(event: IPlatformPrivateEvent) {\n this.#eventsBridge.notify(event);\n }\n\n subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.#eventsBridge.subscribe(cb);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationContainerErrorCode {\n ApplicationLoadError = 'ApplicationLoadError',\n ApplicationFetchError = 'ApplicationFetchError',\n ApplicationExecuteError = 'ApplicationExecuteError',\n}\n\nclass EditorPlatformApplicationContainerError extends BaseError<EditorPlatformApplicationContainerErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(\n message: string,\n code: EditorPlatformApplicationContainerErrorCode,\n ) {\n super(message, code, 'EP Application Container 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 createEditorPlatformApplicationContainerError = createErrorBuilder<\n EditorPlatformApplicationContainerErrorCode,\n EditorPlatformApplicationContainerError\n>(EditorPlatformApplicationContainerError);\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-platform-contexts';\n\nimport type { EditorPlatformApplication } from '@wix/editor-application';\nimport {\n createEditorPlatformApplicationContainerError,\n EditorPlatformApplicationContainerErrorCode,\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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.ApplicationExecuteError,\n 'Application registry called more than once',\n ).withAppDefinitionId(spec.appDefinitionId);\n }\n\n if (_instance.type !== spec.type) {\n throw createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError,\n EditorPlatformApplicationContainerErrorCode,\n} from './errors';\nimport { EditorPlatformApplication } from '@wix/editor-application';\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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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","import { IApplicationSpec, IPrivateAPIFixMe } from '../types';\nimport {\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\nimport { PlatformEnvironment } from '@wix/editor-platform-contexts';\n\nimport { ApplicationEventsBridge } from '../ApplicationEventsBridge';\n\nimport { PlatformApplicationContainer } from './PlatformApplicationContainer';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\n\nexport class PlatformWorkerAPI extends AbstractEnvironmentAPI<\n PlatformConsumerEnvironmentAPIType.Worker,\n PlatformEnvironment.Worker\n> {\n #events = new PlatformAppEventEmitter();\n\n #eventsBridge = new ApplicationEventsBridge(this.#events);\n #container: PlatformApplicationContainer | null = null;\n #privateAPI: IPrivateAPIFixMe;\n\n #pendingWaiters: ((value: this) => void)[] = [];\n\n constructor() {\n super(\n PlatformConsumerEnvironmentAPIType.Worker,\n PlatformEnvironment.Worker,\n );\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 this.injectEnvironmentContext({\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 // TODO: should not be any waiters here\n // or should be implemented inside the events instances\n // collect queue until app is not ready\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 {\n IFrameConsumerEndpoint,\n WorkerConsumerEndpoint,\n} from '@wix/editor-platform-transport';\n\nimport {\n ApplicationContext,\n EnvironmentContext,\n} from '@wix/editor-platform-contexts';\nimport { PlatformWorkerAPI, PlatformFrameAPI } from './api';\nimport {\n createEditorPlatformEnvironmentAPIError,\n EditorPlatformEnvironmentAPIErrorErrorCode,\n} from './errors';\n\nconst GUARD_PROP = '$_EP_TRANSPORT_ENV_CONTEXT_GUARD';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var $_EP_TRANSPORT_ENV_CONTEXT_GUARD: boolean;\n}\n\nexport class EditorPlatformContextEnvironment {\n isEnvironmentApiExposed() {\n return !!globalThis[GUARD_PROP];\n }\n\n async getContexts() {\n const [environmentContext, applicationContext] = await Promise.all([\n EnvironmentContext.getInstance(),\n ApplicationContext.getInstance(),\n ]);\n\n return {\n environmentContext,\n applicationContext,\n };\n }\n\n expose() {\n if (this.isEnvironmentApiExposed()) {\n return;\n }\n\n const isWorker = typeof importScripts === 'function';\n const isIframe =\n globalThis.self && globalThis.top && globalThis.self !== globalThis.top;\n\n /**\n * TODO: we can try to split this code somehow\n * and load the only API according to the current env.\n */\n if (isWorker) {\n this.#exposeWorkerAPI();\n globalThis[GUARD_PROP] = true;\n } else if (isIframe) {\n this.#exposeFrameAPI();\n globalThis[GUARD_PROP] = true;\n } else {\n /**\n * we expose env APIs only from worker or frame\n * but we have some cases when our code runs in the main thread\n * for example – builder component panels.\n */\n // if (!shouldPreventErrorLogs) {\n // console.error(\n // createEditorPlatformEnvironmentAPIError(\n // EditorPlatformEnvironmentAPIErrorErrorCode.IncorrectExpose,\n // 'seems current code is running in the main thread, while it is expected to be in iframe or worker',\n // ),\n // );\n // }\n }\n }\n\n #exposeWorkerAPI() {\n WorkerConsumerEndpoint.exposeAPI(new PlatformWorkerAPI());\n }\n\n #exposeFrameAPI() {\n IFrameConsumerEndpoint.exposeAPI(new PlatformFrameAPI());\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformEnvironmentAPIErrorErrorCode {\n ProxyEnvironmentConnectTimeout = 'ProxyEnvironmentConnectTimeout',\n ProxyWaitAPITimeout = 'ProxyWaitAPITimeout',\n ProxyContextsError = 'ProxyContextsError',\n IncorrectExpose = 'IncorrectExpose',\n}\n\nclass EditorPlatformEnvironmentAPIError extends BaseError<EditorPlatformEnvironmentAPIErrorErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n }> = {};\n\n constructor(\n message: string,\n code: EditorPlatformEnvironmentAPIErrorErrorCode,\n ) {\n super(message, code, 'EP EnvironmentAPI 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\nexport const createEditorPlatformEnvironmentAPIError = createErrorBuilder<\n EditorPlatformEnvironmentAPIErrorErrorCode,\n EditorPlatformEnvironmentAPIError\n>(EditorPlatformEnvironmentAPIError);\n","import { WorkerHostEndpoint } from '@wix/editor-platform-transport';\nimport { EditorPlatformContextEnvironment } from './EditorPlatformContextEnvironment';\nimport {\n createEditorPlatformEnvironmentAPIError,\n EditorPlatformEnvironmentAPIErrorErrorCode,\n} from './errors';\nimport {\n createEditorPlatformInternalError,\n EditorPlatformInternalErrorCode,\n} from '@wix/public-editor-platform-errors';\nimport { PlatformConsumerEnvironmentAPIType } from './api';\n\nexport class EditorPlatformEnvironmentProxy {\n async iframe() {\n throw createEditorPlatformInternalError(\n EditorPlatformInternalErrorCode.UnexpectedError,\n 'not supported',\n );\n }\n\n async worker(worker: Worker) {\n const environment = new EditorPlatformContextEnvironment();\n\n if (!environment.isEnvironmentApiExposed()) {\n environment.expose();\n }\n\n const connectTimeoutId = setTimeout(() => {\n console.info(\n createEditorPlatformEnvironmentAPIError(\n EditorPlatformEnvironmentAPIErrorErrorCode.ProxyEnvironmentConnectTimeout,\n 'probably worker environment does not expose platform API or any SDK function is never used',\n ),\n );\n }, 2_000);\n\n WorkerHostEndpoint.connect(worker, async (transport) => {\n clearTimeout(connectTimeoutId);\n\n const waitAPITimeoutId = setTimeout(() => {\n console.error(\n createEditorPlatformEnvironmentAPIError(\n EditorPlatformEnvironmentAPIErrorErrorCode.ProxyWaitAPITimeout,\n ),\n );\n }, 2_000);\n\n const workerApi = await transport.waitAPI(\n PlatformConsumerEnvironmentAPIType.Worker,\n );\n\n clearTimeout(waitAPITimeoutId);\n\n try {\n const contexts = await environment.getContexts();\n\n await workerApi.injectEnvironmentContext({\n events: contexts.environmentContext.getEvents(),\n privateApi: contexts.environmentContext.getPrivateAPI(),\n applicationAPIs: contexts.environmentContext.getApplicationAPIs(),\n });\n\n await workerApi.injectApplicationContext(\n contexts.applicationContext.getContext(),\n );\n } catch (e: any) {\n throw createEditorPlatformEnvironmentAPIError(\n EditorPlatformEnvironmentAPIErrorErrorCode.ProxyContextsError,\n ).withParentError(e);\n }\n });\n }\n}\n","import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n getAuth() {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.auth;\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function getContextualAuth() {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.getAuth();\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n","import { contextualizeHostModuleV2 } from './context-v2.js';\nexport function createHostModule(hostModuleAPI) {\n return contextualizeHostModuleV2({\n __type: 'host',\n create: (host) => Object.entries(hostModuleAPI).reduce((acc, [key, fn]) => ({\n ...acc,\n [key]: fn(host),\n }), {}),\n }, Object.keys(hostModuleAPI));\n}\n","import { EditorPlatformContextEnvironment } from '@wix/editor-platform-environment-api';\n\nnew EditorPlatformContextEnvironment().expose();\n","import { ApplicationContext } from '@wix/editor-platform-contexts';\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\n/**\n * TODO: find a way to reuse implementation from PlatformInfra.getSDKAuth(...)\n * probably we should do it along with effort to support SDK shapes as placeholders,\n * when implementation is always injected from the main thread\n */\nexport const auth = () => {\n let instance: AccessToken;\n\n return {\n getAuthHeaders: async () => {\n const context = await ApplicationContext.getInstance();\n const appDefinitionId = context.getAppDefinitionId();\n const privateAPI = context.getPrivateAPI();\n\n if (!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 appDefinitionId,\n await privateAPI.info.getMetaSiteId(),\n );\n }\n\n if (!instance?.token) {\n console.error(\n createEditorPlatformSDKAuthError(\n EditorPlatformSDKAuthErrorCode.EmptyAppAuthInstance,\n ).withAppDefinitionId(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 { ApplicationContext } from '@wix/editor-platform-contexts';\nimport { createHostModule } from '@wix/sdk-runtime/host-modules';\nimport { Host } from '@wix/sdk-types';\n\ninterface IHostWithPlatformContexts {\n applicationContext?: Promise<ApplicationContext>;\n}\n\ntype MethodNames<T> = Extract<\n {\n [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n }[keyof T],\n string\n>;\n\ntype PickMethods<T, Keys extends keyof T> = {\n [K in Keys]: T[K];\n};\n\nexport class PlatformSDKShape<\n TShape extends new (...args: any[]) => any,\n TSelected extends MethodNames<InstanceType<TShape>> = never,\n> {\n constructor(\n private ShapeConstructor: TShape,\n private selectedMethods: TSelected[] = [],\n ) {}\n\n withPublicMethod<K extends MethodNames<InstanceType<TShape>>>(\n method: K,\n ): PlatformSDKShape<TShape, TSelected | K> {\n return new PlatformSDKShape(this.ShapeConstructor, [\n ...this.selectedMethods,\n method,\n ]);\n }\n\n build() {\n if (!this.selectedMethods.length) {\n throw new Error('methods are not defined for the SDK shape');\n }\n\n const sdk = this.selectedMethods.reduce(\n (acc, method) => {\n return {\n ...acc,\n [method]: (host: IHostWithPlatformContexts) => {\n const instance = new this.ShapeConstructor(\n host?.applicationContext,\n );\n\n if (!instance[method]) {\n return () => {\n console.error(`\"${method}\" is not defined in the SDK shape`);\n };\n }\n\n return instance[method].bind(instance);\n },\n };\n },\n {} as PickMethods<InstanceType<TShape>, TSelected>,\n );\n\n // @ts-expect-error\n return createHostModule<Host, InstanceType<TShape>>(sdk);\n }\n}\n","import { ApplicationContext } from '@wix/editor-platform-contexts';\nimport {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\n// export type IBaseSDKShape = new (\n// overrideApplicationContext?: Promise<ApplicationContext<any>>,\n// ) => any;\n\nexport enum BaseSDKErrorCode {\n ManifestContextIdRequired = 'ManifestContextIdRequired',\n}\n\nclass BaseSDKError extends BaseError<BaseSDKErrorCode> {\n constructor(message: string, code: BaseSDKErrorCode) {\n super(message, code, 'Base SDK Error');\n }\n}\n\nconst createBaseSDKError = createErrorBuilder<BaseSDKErrorCode, BaseSDKError>(\n BaseSDKError,\n);\n\nexport class BaseSDKShape {\n constructor(\n protected overriddenApplicationContext: Promise<ApplicationContext> | null = null,\n ) {}\n\n protected getApplicationContext() {\n return this.overriddenApplicationContext\n ? this.overriddenApplicationContext\n : ApplicationContext.getInstance();\n }\n\n protected async getAppDefinitionId() {\n return (await this.getApplicationContext()).getAppDefinitionId();\n }\n\n protected async getManifestContextId() {\n return (await this.getApplicationContext()).getManifestContextId();\n }\n\n protected async getRequiredManifestContextId() {\n const manifestContextId = await this.getManifestContextId();\n if (!manifestContextId) {\n throw createBaseSDKError(BaseSDKErrorCode.ManifestContextIdRequired);\n }\n\n return manifestContextId;\n }\n\n protected async getEnvironmentContext() {\n return (await this.getApplicationContext()).getEnvironmentContext();\n }\n\n protected async getPlatformPrivateAPI() {\n return (await this.getApplicationContext()).getPrivateAPI();\n }\n\n // NOTE: don't remove this for now\n // protected dep<TDep extends IBaseSDKShape>(Factory: TDep) {\n // let instance: InstanceType<TDep>;\n //\n // return () => {\n // if (!instance) {\n // instance = new Factory(this.getApplicationContext());\n // }\n //\n // return instance;\n // };\n // }\n}\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class ApplicationSDKShape extends BaseSDKShape {\n async getPrivateAPI<T>() {\n return (await this.getApplicationContext()).getPrivateApplicationAPI() as T;\n }\n\n async getPublicAPI<T>(appDefinitionId: string) {\n const privateAPI = await this.getPlatformPrivateAPI();\n\n return privateAPI.applicationManager.getPublicApplicationAPI(\n appDefinitionId,\n ) as Promise<T>;\n }\n\n async getAppInstance() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getAppInstance(await this.getAppDefinitionId());\n }\n}\n\nexport default new PlatformSDKShape(ApplicationSDKShape)\n .withPublicMethod('getPrivateAPI')\n .withPublicMethod('getPublicAPI')\n .withPublicMethod('getAppInstance')\n .build();\n","import { AppEventPayload, AllowedEvents } from '@wix/editor-platform-contexts';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\n// TODO: remove events shape and remove payload transformations\nexport class EventsSDKShape extends BaseSDKShape {\n async addEventListener(\n name: any,\n // TODO: fix types\n cb: (payload: AppEventPayload<AllowedEvents>) => void,\n ) {\n return (await this.getApplicationContext())\n .getEvents()\n .addEventListener(name, cb);\n }\n}\n\nexport default new PlatformSDKShape(EventsSDKShape)\n .withPublicMethod('addEventListener')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { EventsSDKShape } from '../events';\nimport { IElement } from '@wix/public-editor-platform-interfaces';\n\nexport class ElementsSDKShape extends BaseSDKShape {\n async getSelection() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n\n return Promise.all<IElement[]>(\n refs.map(\n (ref: any) => privateAPI.components.getComponent(ref) as IElement,\n ),\n );\n }\n\n async onSelectionChange(cb: (elements: IElement[]) => void) {\n const events = new EventsSDKShape(this.getApplicationContext());\n void events.addEventListener('componentSelectionChanged', (payload) => {\n // @ts-expect-error TODO: refactor events.\n cb(payload.components);\n });\n }\n}\n\nexport default new PlatformSDKShape(ElementsSDKShape)\n .withPublicMethod('onSelectionChange')\n .withPublicMethod('getSelection')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\ntype ThemeCustomProperty =\n | {\n type: string;\n value: string;\n displayName: string;\n }\n | { error: string };\n\ntype FontOption = {\n displayName: string;\n characterSets: string[];\n fontFamily: string;\n cssFontFamily: string;\n style: { weight: number; style: string }[];\n};\nexport class InfoSDKShape extends BaseSDKShape {\n async getViewMode() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getViewMode();\n }\n\n async getLanguageCode() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getLanguageCode();\n }\n\n async getSiteDirection() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getSiteDirection();\n }\n\n async siteHasCustomClasses() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.siteHasCustomClasses();\n }\n\n async getThemeCustomProperties(filter: {\n keys?: string[];\n }): Promise<Record<string, ThemeCustomProperty>> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getThemeCustomProperties(filter);\n }\n\n async getSiteFonts(filter: {\n keys?: string[];\n }): Promise<Record<string, FontOption>> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getSiteFonts(filter) as Record<string, FontOption>;\n }\n}\n\nexport default new PlatformSDKShape(InfoSDKShape)\n .withPublicMethod('getViewMode')\n .withPublicMethod('getLanguageCode')\n .withPublicMethod('getSiteDirection')\n .withPublicMethod('siteHasCustomClasses')\n .withPublicMethod('getThemeCustomProperties')\n .withPublicMethod('getSiteFonts')\n .build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum WidgetShapeErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n NotAvailableMethod = 'NotAvailableMethod',\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","export interface IFontValue {\n theme?: string;\n family?: string;\n size?: number;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n cssVariableName?: string;\n}\n\nexport interface FontPickerValue {\n font: string;\n textDecoration?: string;\n}\n\nexport const UNDERLINE_DEFINITION = 'underline';\n\nexport function getFontFamiliesFromFonts(fonts: string[]) {\n return fonts\n .map((font) => parseFontString({ font }).family)\n .filter(Boolean) as string[];\n}\n\nexport function 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 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","import { createWidgetShapeError, WidgetShapeErrorCode } from './errors';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { getFontFamiliesFromFonts } from '../inputs/utils';\nimport { ComponentRef } from '@wix/public-editor-platform-interfaces';\n\nexport class WidgetScopedSDK {\n constructor(\n private compRef: ComponentRef,\n private privateAPI: any,\n ) {}\n\n async getProp(propName: string): Promise<string> {\n const props = await this.privateAPI.refComponents.getProps(this.compRef);\n return props?.[propName];\n }\n\n async setProp(propName: string, value: string) {\n await this.privateAPI.refComponents.setProps(this.compRef, {\n [propName]: value,\n });\n }\n\n async getDesignPreset() {\n return this.privateAPI.designPresets.getDesignPresetName(this.compRef);\n }\n\n async setDesignPreset(designPresetName: string) {\n await this.privateAPI.designPresets.setDesignPresetByName(\n this.compRef,\n designPresetName,\n );\n }\n\n async getNestedWidget(selector: `#${string}`) {\n const childCompRef =\n await this.privateAPI.refComponents.findComponentBySelector(\n this.compRef,\n selector,\n );\n\n if (!childCompRef) {\n return null;\n }\n\n return new WidgetScopedSDK(childCompRef, this.privateAPI);\n }\n}\n\nexport class WidgetSDKShape extends BaseSDKShape {\n async #getSelectedComponentRef() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n const compRef = refs[0];\n\n if (!compRef) {\n throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n }\n\n async setPreloadFonts(fonts: string[]): Promise<void> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (await privateAPI.refComponents.isRefComponent(compRef)) {\n throw createWidgetShapeError(\n WidgetShapeErrorCode.NotAvailableMethod,\n 'not available for the current component type',\n );\n }\n\n const fontFamilies = getFontFamiliesFromFonts(fonts);\n\n await privateAPI.customElement.setPreloadFonts(compRef, fontFamilies);\n }\n\n async getProp(propName: string): Promise<string> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (await privateAPI.refComponents.isRefComponent(compRef)) {\n return new WidgetScopedSDK(compRef, privateAPI).getProp(propName);\n } else {\n return privateAPI.customElement.getAttribute(compRef, propName);\n }\n }\n\n async setProp(propName: string, value: string) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (await privateAPI.refComponents.isRefComponent(compRef)) {\n return new WidgetScopedSDK(compRef, privateAPI).setProp(propName, value);\n } else {\n await privateAPI.customElement.setAttribute(compRef, propName, value);\n }\n }\n\n async getDesignPreset() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (!(await privateAPI.refComponents.isRefComponent(compRef))) {\n throw createWidgetShapeError(\n WidgetShapeErrorCode.NotAvailableMethod,\n 'not available for the current component type',\n );\n }\n\n return new WidgetScopedSDK(compRef, privateAPI).getDesignPreset();\n }\n\n async setDesignPreset(designPresetName: string) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (!(await privateAPI.refComponents.isRefComponent(compRef))) {\n throw createWidgetShapeError(\n WidgetShapeErrorCode.NotAvailableMethod,\n 'not available for the current component type',\n );\n }\n\n return new WidgetScopedSDK(compRef, privateAPI).setDesignPreset(\n designPresetName,\n );\n }\n\n async getNestedWidget(selector: `#${string}`) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n return new WidgetScopedSDK(compRef, privateAPI).getNestedWidget(selector);\n }\n}\n\nconst widgetShape = new PlatformSDKShape(WidgetSDKShape)\n .withPublicMethod('getNestedWidget')\n .withPublicMethod('setDesignPreset')\n .withPublicMethod('getDesignPreset')\n .withPublicMethod('setProp')\n .withPublicMethod('getProp')\n .withPublicMethod('setPreloadFonts');\n\nexport default widgetShape.build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport {\n type IFontValue,\n type FontPickerValue,\n parseFontString,\n UNDERLINE_DEFINITION,\n} from './utils';\n\ninterface IColorValue {\n color: string;\n theme?: string;\n cssVariableName?: string;\n}\n\ntype IColorPickerValue = string | null | undefined;\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?: IColorPickerValue,\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\nexport class InputsSDKShape extends BaseSDKShape {\n async selectColor(\n value?: IColorPickerValue,\n options?: {\n onChange?: (value: IColorPickerValue) => void;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\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 || colorValue?.theme || 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 async selectFont(\n value?: FontPickerValue,\n options?: {\n onChange?: (value: FontPickerValue) => void;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\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\nexport default new PlatformSDKShape(InputsSDKShape)\n .withPublicMethod('selectColor')\n .withPublicMethod('selectFont')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class PanelsSDKShape extends BaseSDKShape {\n async openLanguageSupportPanel() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.panels.openLanguageSupportPanel();\n }\n\n async openFontsUploadPanel() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.panels.openFontsUploadPanel();\n }\n}\n\nexport default new PlatformSDKShape(PanelsSDKShape)\n .withPublicMethod('openLanguageSupportPanel')\n .withPublicMethod('openFontsUploadPanel')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class ModalsSDKShape extends BaseSDKShape {\n async openDashboardModal(options: {\n url: string;\n closeOtherPanels?: boolean;\n }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.panels.openDashboardPanel(\n await this.getAppDefinitionId(),\n options,\n );\n }\n}\n\nexport default new PlatformSDKShape(ModalsSDKShape)\n .withPublicMethod('openDashboardModal')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { ApplicationContext } from '@wix/editor-platform-contexts';\n\ninterface IFontFamily {\n family: string;\n weight: string;\n}\n\ninterface IFontWeight {\n weight: string;\n}\n\ntype IFontFamilyAndWeight = IFontFamily & IFontWeight;\n\ntype ISelectLinkSharedOptions = {\n origin?: string;\n};\nexport class ElementSDKShape extends BaseSDKShape {\n constructor(\n protected overriddenApplicationContext: Promise<ApplicationContext> | null = null,\n private childPath: number[] = [],\n ) {\n super(overriddenApplicationContext);\n }\n\n async getStyleDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getStyleDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getStyles(): Promise<{\n cssProperties: Record<string, string>;\n cssCustomProperties: Record<string, string>;\n }> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getStyles(\n manifestContextId,\n this.childPath,\n );\n }\n\n async setStyles({\n cssProperties,\n cssCustomProperties,\n }: {\n cssProperties?: Record<string, string>;\n cssCustomProperties?: Record<string, string>;\n } = {}): Promise<void> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.setStyles(\n manifestContextId,\n this.childPath,\n {\n cssProperties,\n cssCustomProperties,\n },\n );\n }\n\n async removeStyles(\n values: {\n cssPropertiesKeys?: string[];\n cssCustomPropertiesKeys?: string[];\n } = {},\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.removeStyles(\n manifestContextId,\n this.childPath,\n values,\n );\n }\n\n async getDataDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getDataDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getData() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getData(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getResolvedData({ dataItemKey }: { dataItemKey: string }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getResolvedData(\n manifestContextId,\n this.childPath,\n {\n dataItemKey,\n },\n );\n }\n\n async setData(values: {}) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.setData(\n manifestContextId,\n this.childPath,\n values,\n );\n }\n\n async getPresetDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getPresetDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getAppliedPreset() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getAppliedPreset(\n manifestContextId,\n this.childPath,\n );\n }\n\n async applyPreset(options: { key: string }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.applyPreset(\n manifestContextId,\n this.childPath,\n options,\n );\n }\n\n // TODO: group type should come from builder enum\n async getDisplayGroupDefinitions(options?: {\n filter?: { groupType?: string };\n }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getDisplayGroupDefinitions(\n manifestContextId,\n this.childPath,\n options,\n );\n }\n\n async getState() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getState(\n manifestContextId,\n this.childPath,\n );\n }\n\n async setState(stateKey: string | null) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.setState(\n manifestContextId,\n this.childPath,\n stateKey,\n );\n }\n\n async getStateDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getStateDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n /**\n * TODO: use type from the ManifestChangeDetection,\n * but type should be moved to editor-platform-public-interfaces\n */\n async onChange(\n cb: (patch: {\n type: 'cssProperties' | 'cssCustomProperties' | 'data' | 'manifest';\n value: unknown;\n }) => void,\n ): Promise<() => {}> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.onChange(\n manifestContextId,\n this.childPath,\n cb,\n );\n }\n\n async selectFont(\n params:\n | {\n styleItemKey: string;\n }\n // TODO: get type from common place https://wix.atlassian.net/browse/EP-6480\n | {\n selectedFontFamily?: IFontFamilyAndWeight;\n target?: HTMLElement;\n onChange?: (value: IFontFamilyAndWeight) => void;\n onPreview?: (value: IFontFamilyAndWeight) => void;\n },\n ) {\n try {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n const selectedFont = await privateAPI.builderComponent.selectFont(\n manifestContextId,\n this.childPath,\n {\n ...params,\n showWeights: true,\n },\n );\n return selectedFont;\n } catch (error) {\n // TODO: handle error https://wix.atlassian.net/browse/EP-6428\n }\n }\n\n async selectFontFamily(\n params:\n | {\n styleItemKey: string;\n }\n // TODO: get type from common place https://wix.atlassian.net/browse/EP-6480\n | {\n selectedFontFamily?: IFontFamily;\n target?: HTMLElement;\n onChange?: (value: IFontFamily) => void;\n onPreview?: (value: IFontFamily) => void;\n },\n ) {\n try {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n const selectedFont = await privateAPI.builderComponent.selectFont(\n manifestContextId,\n this.childPath,\n {\n ...params,\n showWeights: false,\n },\n );\n return selectedFont;\n } catch (error) {\n // TODO: handle error https://wix.atlassian.net/browse/EP-6428\n }\n }\n\n async selectMedia(\n params: // TODO: get type from common place https://wix.atlassian.net/browse/EP-6462\n | {\n dataItemKey: string;\n }\n | {\n isMultiSelect?: boolean;\n category?: string;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.selectMedia(\n manifestContextId,\n this.childPath,\n params,\n );\n }\n\n async selectLink(\n params:\n | {\n dataItemKey: string;\n options?: ISelectLinkSharedOptions;\n }\n | {\n value?: object;\n options?: ISelectLinkSharedOptions & {\n linkTypes?: string[];\n };\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.selectLink(\n manifestContextId,\n this.childPath,\n params,\n );\n }\n\n async selectColor(\n params:\n | { styleItemKey: string }\n // TODO: get the ColorPickerOptions from SDK types https://wix.atlassian.net/browse/EP-6433\n | {\n initialValue?: string;\n mode?: ('solid' | 'gradient')[];\n showBrand?: boolean;\n showCustom?: boolean;\n showAdvancedSettings?: boolean;\n showOpacity?: boolean;\n position?: { x: number; y: number };\n biData?: { origin: string };\n // TODO: Fix when public Color type is available https://wix.atlassian.net/browse/EP-6427\n onChange?: (color: string) => void;\n // TODO: Fix when public Color type is available https://wix.atlassian.net/browse/EP-6427\n onApply?: (color: string) => void;\n onClose?: () => void;\n onCancel?: () => void;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n try {\n const manifestContextId = await this.getRequiredManifestContextId();\n const selectedColor = await privateAPI.builderComponent.selectColor(\n manifestContextId,\n this.childPath,\n params,\n );\n return selectedColor;\n } catch (error) {\n // TODO: handle error https://wix.atlassian.net/browse/EP-6428\n }\n }\n\n async selectFontWeight(\n params:\n | {\n fontFamilyStyleItemKey: string;\n fontWeightStyleItemKey: string;\n }\n | {\n fontStyleItemKey: string;\n }\n | {\n fontFamily?: IFontFamily;\n target?: HTMLElement;\n onChange?: (value: IFontWeight) => void;\n },\n ): Promise<IFontWeight> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return {\n weight: await privateAPI.builderComponent.selectFontWeight(\n manifestContextId,\n this.childPath,\n params,\n ),\n };\n }\n\n async selectTextTheme(params: {\n target?: HTMLElement;\n initialValue?: {\n font?: string;\n color?: string;\n };\n }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.selectTextTheme(\n manifestContextId,\n params,\n );\n }\n}\n\nexport default new PlatformSDKShape(ElementSDKShape)\n .withPublicMethod('getDataDefinitions')\n .withPublicMethod('getData')\n .withPublicMethod('getResolvedData')\n .withPublicMethod('setData')\n .withPublicMethod('getStyleDefinitions')\n .withPublicMethod('getStyles')\n .withPublicMethod('setStyles')\n .withPublicMethod('removeStyles')\n .withPublicMethod('getPresetDefinitions')\n .withPublicMethod('getAppliedPreset')\n .withPublicMethod('applyPreset')\n .withPublicMethod('getDisplayGroupDefinitions')\n .withPublicMethod('getState')\n .withPublicMethod('setState')\n .withPublicMethod('onChange')\n .withPublicMethod('getStateDefinitions')\n .withPublicMethod('selectFont')\n .withPublicMethod('selectFontFamily')\n .withPublicMethod('selectMedia')\n .withPublicMethod('selectLink')\n .withPublicMethod('selectColor')\n .withPublicMethod('selectFontWeight')\n .withPublicMethod('selectTextTheme')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class PreferencesSDKShape extends BaseSDKShape {\n async get(keys: string[]) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.userPreferences.get(\n await this.getAppDefinitionId(),\n keys,\n );\n }\n\n async set(preferences: Record<string, any>) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.userPreferences.set(\n await this.getAppDefinitionId(),\n preferences,\n );\n }\n}\n\nexport default new PlatformSDKShape(PreferencesSDKShape)\n .withPublicMethod('set')\n .withPublicMethod('get')\n .build();\n","import {\n DsItem,\n BuilderStyle,\n StyleRef,\n OpenColorPickerFn,\n OpenLinkPanelFn,\n} from '@wix/public-editor-platform-interfaces';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class ExternalPanelsSDKShape extends BaseSDKShape {\n async getData() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.getData();\n }\n\n async setData(newData: DsItem) {\n const privateAPI = await this.getPlatformPrivateAPI();\n\n return privateAPI.externalPanels.setData(newData);\n }\n\n async getStyle() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.getStyle();\n }\n\n async setStyle(newStyle: Partial<BuilderStyle> | StyleRef) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.setStyle(newStyle);\n }\n\n async getTheme() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.getTheme();\n }\n\n async selectMedia() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.selectMedia();\n }\n\n async selectLink(...options: any): Promise<OpenLinkPanelFn> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.selectLink(...options);\n }\n\n async selectColor(...options: any): Promise<OpenColorPickerFn> {\n return async () => {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.selectColor(...options);\n };\n }\n\n async translate(key: string | string[], values?: Record<string, any>) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.translate(key, values);\n }\n}\n\nexport default new PlatformSDKShape(ExternalPanelsSDKShape)\n .withPublicMethod('getTheme')\n .withPublicMethod('getData')\n .withPublicMethod('getStyle')\n .withPublicMethod('selectColor')\n .withPublicMethod('selectLink')\n .withPublicMethod('selectMedia')\n .withPublicMethod('setData')\n .withPublicMethod('setStyle')\n .withPublicMethod('translate')\n .build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum ControllersErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n}\n\nclass ControllersError extends BaseError<ControllersErrorCode> {\n constructor(message: string, code: ControllersErrorCode) {\n super(message, code, 'Controllers Error');\n }\n}\n\nexport const createControllersError = createErrorBuilder<\n ControllersErrorCode,\n ControllersError\n>(ControllersError);\n","import { BaseSDKShape } from '../BaseSDKShape';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { ControllersErrorCode, createControllersError } from './errors';\n\ninterface AppController {\n type: string;\n settings: Record<string, any>;\n update: (settings: Record<string, any>) => void;\n}\n\nexport class ControllersSDKShape extends BaseSDKShape {\n async #getSelectedComponentRef() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n const compRef = refs[0];\n\n if (!compRef) {\n throw createControllersError(ControllersErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n }\n async get(): Promise<AppController[]> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.controllers.get(\n await this.getAppDefinitionId(),\n await this.#getSelectedComponentRef(),\n );\n }\n}\n\nexport default new PlatformSDKShape(ControllersSDKShape)\n .withPublicMethod('get')\n .build();\n","import { ComponentRef } from '@wix/public-editor-platform-interfaces';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport {\n BindingTarget,\n IBindingConnectionItem,\n IDataBindingItem,\n} from './types';\nexport class BindingConnectionItem {\n constructor(\n private privateAPI: any,\n private compRef: ComponentRef,\n private bindingTargetId: string,\n private config: string,\n ) {}\n\n public update(data: Partial<IDataBindingItem>) {\n return this.privateAPI.bindings.update(this.compRef, this.bindingTargetId, {\n config: data.config,\n role: data.role,\n });\n }\n\n public delete() {\n return this.privateAPI.bindings.delete(this.compRef, this.bindingTargetId);\n }\n\n get connectionConfig() {\n return this.config;\n }\n}\nexport class BindingsSDKShape extends BaseSDKShape {\n public async get(\n bindingTarget: BindingTarget,\n ): Promise<IBindingConnectionItem | null> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRefs = await privateAPI.components.getSelectedComponents();\n if (compRefs.length !== 1) {\n return null;\n }\n const [compRef] = compRefs;\n const dataBindingConfig = privateAPI.bindings.get(\n bindingTarget.id,\n compRef,\n );\n if (!dataBindingConfig) {\n return null;\n }\n\n return new BindingConnectionItem(\n privateAPI,\n compRef,\n bindingTarget.id,\n dataBindingConfig,\n );\n }\n}\n\nexport default new PlatformSDKShape(BindingsSDKShape)\n .withPublicMethod('get')\n .build();\n","import { ComponentRef } from '@wix/public-editor-platform-interfaces';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport {\n BindingTarget,\n IBindingsProvider,\n IDataBindingItem,\n} from '../bindings/types';\nimport { BindingConnectionItem } from '../bindings';\n\nclass BindingsProvider implements IBindingsProvider {\n constructor(\n private privateAPI: any,\n private compRef: ComponentRef,\n private dataItemTarget: BindingTarget,\n public name: string,\n ) {}\n\n public select() {\n return this.privateAPI.bindings.openDataBindingPanel(\n this.dataItemTarget.id,\n );\n }\n\n public createBinding(data: IDataBindingItem) {\n const created = this.privateAPI.bindings.create(this.compRef, {\n dataItemId: this.dataItemTarget.id,\n bindingItemType: 'dataBinding',\n ...data,\n });\n\n if (!created) {\n return null;\n }\n\n return new BindingConnectionItem(\n this.privateAPI,\n this.compRef,\n this.dataItemTarget.id,\n JSON.stringify(data),\n );\n }\n}\nexport class BindingsProvidersSDKShape extends BaseSDKShape {\n public async list(bindingTarget: BindingTarget) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRefs: ComponentRef[] =\n await privateAPI.components.getSelectedComponents();\n if (compRefs.length !== 1) {\n return [];\n }\n const [compRef] = compRefs;\n if (!(await privateAPI.bindings.canCreateBindingsProvider(compRef))) {\n return [];\n }\n\n return [\n new BindingsProvider(privateAPI, compRef!, bindingTarget, 'dataBinding'),\n ];\n }\n}\n\nexport default new PlatformSDKShape(BindingsProvidersSDKShape)\n .withPublicMethod('list')\n .build();\n","import type { ApplicationContext } from '@wix/editor-platform-contexts';\nimport type { AdminHost as AdminHostType } from '@wix/admin';\n\nexport interface AdminAPI extends NonNullable<AdminHostType['admin']> {}\n\nclass Admin implements AdminAPI {\n constructor(private applicationContext: Promise<ApplicationContext>) {}\n\n private async adminAPI(): Promise<AdminAPI> {\n const context = await this.applicationContext;\n const privateAPI = context.getPrivateAPI();\n const adminAPI = await privateAPI.admin;\n return adminAPI;\n }\n\n getContextIds: AdminAPI['getContextIds'] = () => {\n throw new Error('Not implemented yet');\n };\n\n openItemSelector: AdminAPI['openItemSelector'] = (_args) => {\n throw new Error('Not implemented yet');\n };\n}\n\nexport class AdminHost {\n #api: AdminAPI;\n\n getAPI(): AdminAPI {\n return this.#api;\n }\n\n constructor(applicationContext: Promise<ApplicationContext>) {\n this.#api = new Admin(applicationContext);\n }\n}\n","import type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\nimport { ApplicationContext } from '@wix/editor-platform-contexts';\nimport { getMonitoringClientFunction } from '@wix/monitoring-browser-sdk-host';\nimport { AdminHost, type AdminAPI } from './adminHost';\n\ndeclare global {\n interface Window {\n Sentry?: any;\n }\n}\n\nexport const frame = (): WixSDKTypes.Host & {\n admin: AdminAPI;\n applicationContext: Promise<ApplicationContext>;\n essentials: {\n language?: string;\n locale?: string;\n };\n} => {\n const queryParams = new URLSearchParams(window.location.search);\n const essentialsQueryParamValue = queryParams.has('essentials')\n ? JSON.parse(queryParams.get('essentials')!)\n : undefined;\n const { monitoring, ...essentials } = essentialsQueryParamValue || {};\n const appDefinitionId = queryParams.get('appDefinitionId')!;\n const { context, config } = monitoring || {};\n const getMonitoringClient = getMonitoringClientFunction({\n hostContext: { appId: appDefinitionId, ...context },\n monitoringConfig: config,\n sentrySDK: typeof window !== 'undefined' ? window.Sentry : undefined,\n });\n\n const applicationContext = ApplicationContext.getInstance();\n const adminHost = new AdminHost(applicationContext);\n\n return {\n environment: {},\n applicationContext,\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n getMonitoringClient,\n admin: adminHost.getAPI(),\n essentials,\n };\n};\n\nexport const worker = (): WixSDKTypes.Host & {\n admin: AdminAPI;\n applicationContext: Promise<ApplicationContext>;\n} => {\n const applicationContext = ApplicationContext.getInstance();\n const adminHost = new AdminHost(applicationContext);\n\n return {\n environment: {},\n applicationContext,\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n admin: adminHost.getAPI(),\n };\n};\n","import './env';\nimport { auth } from './auth';\n\nexport { default as application } from './application';\nexport { default as elements } from './elements';\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 panels } from './panels';\nexport { default as modals } from './modals';\nexport { default as element, ElementSDKShape } from './element';\nexport { default as preferences } from './preferences';\nexport { default as externalPanels } from './externalPanels';\nexport { default as controllers } from './controllers';\nexport { default as bindings } from './bindings';\nexport { default as bindingsProviders } from './bindingsProviders';\nexport { BaseSDKShape } from './BaseSDKShape';\nexport { PlatformSDKShape } from './PlatformSDKShape';\n\nimport * as host from './host';\n\nexport const editor = {\n host: () => {\n const isWorker = typeof importScripts === 'function';\n\n if (isWorker) {\n return host.worker();\n }\n\n return host.frame();\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":"sPAAA,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,GAAA,cACA,IAAIC,GAAmBD,GAAQA,EAAK,kBAAqB,OAAO,OAAU,SAASE,EAAGC,EAAGC,EAAGC,EAAI,CACxFA,IAAO,SAAWA,E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AOxJ,EAAiB,GAAGW,CAAQ,EAClD,iBAAkBqH,EAClB,UAAW,OAAO,OAAW,IAAc,OAAO,OAAS,MAAA,CAC5D,EAEKY,EAAqBhI,EAAmB,YAAY,EACpD6I,EAAY,IAAIX,GAAUF,CAAkB,EAE3C,MAAA,CACL,YAAa,CAAA,EACb,mBAAAA,EACA,QAAS,CACP,aAAc,UACL,CAAE,YAAa,CAAA,CAAG,EAC3B,EAEF,oBAAAW,EACA,MAAOE,EAAU,OAAO,EACxB,WAAAH,CAAA,CAEJ,EAEaI,GAAS,IAGjB,CACG,IAAAd,EAAqBhI,EAAmB,YAAY,EACpD6I,EAAY,IAAIX,GAAUF,CAAkB,EAE3C,MAAA,CACL,YAAa,CAAA,EACb,mBAAAA,EACA,QAAS,CACP,aAAc,UACL,CAAE,YAAa,CAAA,CAAG,EAC3B,EAEF,MAAOa,EAAU,OAAO,CAAA,CAE5B,EC5CaE,GAAS,CACpB,KAAM,IACa,OAAO,eAAkB,WAGjCC,GAAY,EAGdC,GAAW,EAEpB,KAAApJ,EACF,EC9BO,IAAMqJ,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","ownKeys","ar","mod","result","i","WixSDKTypes","EventType_1","_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","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","EditorPlatformContextErrorCode","EditorPlatformContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformContextError","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","__privateAdd","_ContextInjectionStatus_instances","__privateMethod","getGlobalInjectionPromise_fn","createGlobalInjectionPromise_fn","resolve","reject","injected","timeoutId","retryCount","timeout","error","_resolve","promise","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","environment","ApplicationContext","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","hash","_performance","result","characters","charactersLength","counter","length","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","hash","__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","ApplicationEventsBridge","platformAppEvents","event","PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","cb","PlatformConsumerEnvironmentAPIType","AbstractEnvironmentAPI","type","envType","events","privateApi","EnvironmentContext","context","ApplicationContext","DESIGN_SYSTEM_STYLES_MAP","PlatformFrameAPI","PlatformEnvironment","__privateAdd","_PlatformFrameAPI_instances","_events","PlatformAppEventEmitter","_eventsBridge","__privateGet","_privateAPI","_applicationPrivateAPI","__privateMethod","injectGlobalCSSTokens_fn","props","applicationPrivateAPI","privateAPI","_appDefinitionId","_context","__privateSet","host","url","isAlreadyLoaded","link","EditorPlatformApplicationContainerErrorCode","EditorPlatformApplicationContainerError","BaseError","message","code","__publicField","appDefinitionId","apiMethod","apiType","createEditorPlatformApplicationContainerError","createErrorBuilder","APPLICATION_REGISTRY_KEY","executeApplication","spec","bundle","executable","APPLICATION_CONTEXT_KEY","instance","applicationRegistryCallback","_instance","e","resolve","reject","unsubscribe","timeoutId","PlatformApplicationContainer","_apps","appSpec","appDefId","res","PlatformWorkerAPI","_container","_pendingWaiters","buildPrivateAPI","app","GUARD_PROP","EditorPlatformContextEnvironment","_EditorPlatformContextEnvironment_instances","environmentContext","applicationContext","isWorker","isIframe","exposeWorkerAPI_fn","exposeFrameAPI_fn","WorkerConsumerEndpoint","IFrameConsumerEndpoint","EditorPlatformEnvironmentAPIError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformEnvironmentAPIError","createErrorBuilder","wixContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext","contextualizeHostModuleV2","hostModule","props","prop","args","context","resolveContext","createHostModule","hostModuleAPI","contextualizeHostModuleV2","host","acc","key","fn","EditorPlatformContextEnvironment","EditorPlatformSDKAuthError","BaseError","message","code","__publicField","appDefinitionId","createEditorPlatformSDKAuthError","createErrorBuilder","hasEnoughTimeUntilExpiry","expires","expiryBuffer","now","expiryTime","ACCESS_TOKEN_EXPIRY_GRACE_PERIOD","auth","instance","context","ApplicationContext","privateAPI","PlatformSDKShape","_PlatformSDKShape","ShapeConstructor","selectedMethods","method","sdk","acc","host","createHostModule","BaseSDKError","createBaseSDKError","BaseSDKShape","overriddenApplicationContext","manifestContextId","ApplicationSDKShape","index$d","EventsSDKShape","name","cb","index$c","ElementsSDKShape","refs","ref","payload","index$b","InfoSDKShape","filter","index$a","WidgetShapeErrorCode","WidgetShapeError","createWidgetShapeError","UNDERLINE_DEFINITION","getFontFamiliesFromFonts","fonts","font","parseFontString","fontPickerValue","variableName","fallbackValue","extractFontVar","parts","i","part","fontString","trimmedFont","match","WidgetScopedSDK","_WidgetScopedSDK","compRef","propName","value","designPresetName","selector","childCompRef","WidgetSDKShape","__privateAdd","_WidgetSDKShape_instances","__privateMethod","getSelectedComponentRef_fn","fontFamilies","widgetShape","index$9","fontValueToCSS","fontValue","fontFamily","parseColorString","colorPickerValue","colorString","colorValueToCSS","colorValue","theme","cssVariableName","bold","italic","underline","rest","InputsSDKShape","options","colorResult","color","cssVariableTheme","_value","accessibility","index$8","PanelsSDKShape","index$7","ModalsSDKShape","index$6","ElementSDKShape","childPath","cssProperties","cssCustomProperties","values","dataItemKey","stateKey","params","index$5","PreferencesSDKShape","keys","preferences","index$4","ExternalPanelsSDKShape","newData","newStyle","key","index$3","ControllersErrorCode","ControllersError","createControllersError","ControllersSDKShape","_ControllersSDKShape_instances","index$2","BindingConnectionItem","bindingTargetId","config","data","BindingsSDKShape","bindingTarget","compRefs","dataBindingConfig","index$1","BindingsProvider","dataItemTarget","BindingsProvidersSDKShape","index","Admin","applicationContext","_args","AdminHost","_api","__privateSet","__privateGet","frame","queryParams","essentialsQueryParamValue","monitoring","essentials","getMonitoringClient","getMonitoringClientFunction","adminHost","worker","editor","host.worker","host.frame","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/index.js","../../../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/public-editor-platform-errors/src/BaseError.ts","../../../node_modules/@wix/public-editor-platform-errors/src/EditorPlatformInternalError.ts","../../../node_modules/@wix/editor-platform-contexts/src/errors.ts","../../../node_modules/@wix/editor-platform-contexts/src/ApplicationBoundEvents/transformEventPayload.ts","../../../node_modules/@wix/editor-platform-contexts/src/ApplicationBoundEvents/ApplicationBoundEvents.ts","../../../node_modules/@wix/editor-platform-contexts/src/contexts/ContextInjectionStatus.ts","../../../node_modules/@wix/editor-platform-contexts/src/contexts/EnvironmentContext.ts","../../../node_modules/@wix/editor-platform-contexts/src/contexts/ApplicationContext.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/hash.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-platform-environment-api/src/api/ApplicationEventsBridge/WorkerEventsBridge.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/AbstractEnvironmentAPI.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformFrameAPI/PlatformFrameAPI.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformApplicationContainer/errors.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformApplicationContainer/executeApplication.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformApplicationContainer/PlatformApplicationContainer.ts","../../../node_modules/@wix/editor-platform-environment-api/src/api/PlatformWorkerAPI/PlatformWorkerAPI.ts","../../../node_modules/@wix/editor-platform-environment-api/src/EditorPlatformContextEnvironment.ts","../../../node_modules/@wix/editor-platform-environment-api/src/errors.ts","../../../node_modules/@wix/editor-platform-environment-api/src/EditorPlatformEnvironmentProxy.ts","../../../node_modules/@wix/editor/node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/editor/node_modules/@wix/sdk-runtime/build/context-v2.js","../../../node_modules/@wix/editor/node_modules/@wix/sdk-runtime/build/host-modules.js","../../../node_modules/@wix/editor/src/env.ts","../../../node_modules/@wix/editor/src/auth.ts","../../../node_modules/@wix/editor/src/PlatformSDKShape.ts","../../../node_modules/@wix/editor/src/BaseSDKShape.ts","../../../node_modules/@wix/editor/src/application/index.ts","../../../node_modules/@wix/editor/src/events/index.ts","../../../node_modules/@wix/editor/src/elements/index.ts","../../../node_modules/@wix/editor/src/info/index.ts","../../../node_modules/@wix/editor/src/widget/errors.ts","../../../node_modules/@wix/editor/src/inputs/utils.ts","../../../node_modules/@wix/editor/src/widget/index.ts","../../../node_modules/@wix/editor/src/inputs/index.ts","../../../node_modules/@wix/editor/src/panels/index.ts","../../../node_modules/@wix/editor/src/modals/index.ts","../../../node_modules/@wix/editor/src/element/index.ts","../../../node_modules/@wix/editor/src/preferences/index.ts","../../../node_modules/@wix/editor/src/externalPanels/index.ts","../../../node_modules/@wix/editor/src/controllers/errors.ts","../../../node_modules/@wix/editor/src/controllers/index.ts","../../../node_modules/@wix/editor/src/bindings/index.ts","../../../node_modules/@wix/editor/src/bindingsProviders/index.ts","../../../node_modules/@wix/editor/src/workspaceHost.ts","../../../node_modules/@wix/editor/src/host.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 () {\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})();\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 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 editorType?: string;\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 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","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformContextErrorCode {\n IncorrectEnvironment = 'IncorrectEnvironment',\n}\n\nclass EditorPlatformContextError extends BaseError<EditorPlatformContextErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformContextErrorCode) {\n super(message, code, 'EP Context 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\nexport const createEditorPlatformContextError = createErrorBuilder<\n EditorPlatformContextErrorCode,\n EditorPlatformContextError\n>(EditorPlatformContextError);\n","import type { ComponentRef } from '@wix/public-editor-platform-interfaces';\nimport { AllowedEvents, AppEventPayload, PrivateAPIFixMe } from './types';\nimport { IElement } from '@wix/public-editor-platform-interfaces';\n\n// TODO: remove events shape and remove payload transformations\nexport async function transformEventPayload<T extends AllowedEvents>(\n eventPayload: Record<string, string>,\n privateAPI: PrivateAPIFixMe,\n): Promise<AppEventPayload<T>> {\n if (!eventPayload?.type) {\n return eventPayload as AppEventPayload<T>;\n }\n\n switch (eventPayload.type) {\n case 'componentSelectionChanged':\n const componentRefs = (eventPayload.componentRefs ||\n []) as unknown as ComponentRef[];\n\n const components = (await Promise.all(\n componentRefs.map((ref) => {\n return privateAPI.components.getComponent(ref);\n }),\n )) as IElement[];\n\n return {\n type: eventPayload.type,\n components,\n } as AppEventPayload<T>;\n\n default:\n return eventPayload as AppEventPayload<T>;\n }\n}\n","import {\n PlatformAppEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\nimport { AllowedEvents, AppEventPayload, PrivateAPIFixMe } from './types';\nimport { transformEventPayload } from './transformEventPayload';\n\nexport type OmitEventMeta<T> = T extends { meta: any } ? Omit<T, 'meta'> : T;\n\n/**\n * TODO: should not be in this package\n */\nexport class ApplicationBoundEvents {\n private events: PlatformAppEventEmitter;\n public subscribe;\n public commit;\n public startTransaction;\n public silent;\n\n constructor(\n private appDefinitionId: string | null,\n events: PlatformAppEventEmitter,\n private privateAPI: PrivateAPIFixMe,\n ) {\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\n public notify(event: OmitEventMeta<IPlatformAppEvent>) {\n this.events.notify({\n type: event.type,\n payload: event.payload,\n meta: {\n appDefinitionId: this.appDefinitionId,\n },\n } as IPlatformAppEvent);\n }\n\n notifyCustomEvent(type: string, payload: Record<string, string>) {\n this.notify({\n type: PlatformAppEvent.CustomEvent,\n payload: {\n ...payload,\n type,\n },\n });\n }\n\n /**\n * TODO: we should use same interface for all events\n * (subscribe vs addEventListener)\n */\n public addEventListener<EventType extends AllowedEvents>(\n eventType: EventType,\n fn: (payload: AppEventPayload<EventType>) => void,\n ) {\n return this.events.subscribe(async (event) => {\n const isAppMatch =\n event.meta?.appDefinitionId === this.appDefinitionId ||\n event.meta?.appDefinitionId === null;\n\n const transformPayload = () =>\n transformEventPayload<EventType>(event.payload, this.privateAPI);\n\n // as an exception to skip autocomplete\n if ((eventType as string) === '*') {\n fn(await transformPayload());\n /**\n * We need to check for app match here to not listen app's own events\n */\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","import {\n createEditorPlatformContextError,\n EditorPlatformContextErrorCode,\n} from '../errors';\n\nconst WAIT_INJECTED_TIMEOUT = 200;\nconst WAIT_INJECTED_RETRY_COUNT = 50;\n\nexport class ContextInjectionStatus {\n injectionUUID: string;\n injectionUUID_Deprecated: string;\n\n constructor(uuid: string) {\n this.injectionUUID_Deprecated = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;\n this.injectionUUID = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY#0.1`;\n\n const promise = this.#getGlobalInjectionPromise();\n\n if (!promise) {\n this.#createGlobalInjectionPromise();\n }\n }\n\n #getGlobalInjectionPromise() {\n // @ts-expect-error xxx\n const ref = globalThis[this.injectionUUID];\n return ref?.promise;\n }\n\n #createGlobalInjectionPromise() {\n let _resolve;\n\n const promise = new Promise<void>((resolve) => {\n _resolve = resolve;\n });\n\n // @ts-expect-error xxx\n globalThis[this.injectionUUID] = {\n promise,\n resolve: _resolve,\n };\n\n /**\n * as soon as new latest-version promise is created\n * override existing deprecated promise and resolve it\n * as soon as latest is resolved\n */\n // @ts-expect-error xxx\n globalThis[this.injectionUUID_Deprecated] = new Promise((resolve) => {\n promise.then(resolve);\n });\n }\n\n resolveInjected() {\n // @ts-expect-error xxx\n globalThis[this.injectionUUID]?.resolve();\n }\n\n waitInjected() {\n return new Promise<void>((resolve, reject) => {\n let injected = false;\n let timeoutId: ReturnType<typeof setTimeout>;\n let retryCount = 0;\n\n const timeout = () => {\n if (injected) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n retryCount++;\n\n if (retryCount < WAIT_INJECTED_RETRY_COUNT) {\n /**\n * just log that we are re-trying to connect (each 2 sec+-)\n */\n if (retryCount % 10 === 0) {\n console.log(\n createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'contexts are not resolved, still re-trying',\n ).withMessage(`try number ${retryCount}`).message,\n );\n }\n\n timeout();\n\n return;\n }\n\n if (!injected) {\n const error = createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'contexts are not resolved, threw by timeout',\n );\n\n reject(error);\n }\n }, WAIT_INJECTED_TIMEOUT);\n };\n\n timeout();\n\n this.#getGlobalInjectionPromise()?.then(() => {\n injected = true;\n clearTimeout(timeoutId);\n resolve();\n });\n });\n }\n}\n","import { PlatformAppEventEmitter } from '@wix/public-editor-platform-events';\nimport { WithPromiseFunctions } from '@wix/editor-platform-transport';\nimport {\n createEditorPlatformContextError,\n EditorPlatformContextErrorCode,\n} from '../errors';\nimport { ContextInjectionStatus } from './ContextInjectionStatus';\n\nexport type IPrivateAPIFixMe = any; // TODO: replace with the real type\n\nexport const ENVIRONMENT_CONTEXT_KEY = '__ENVIRONMENT_CONTEXT_KEY';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __ENVIRONMENT_CONTEXT_KEY: EnvironmentContext;\n}\n\nexport enum PlatformEnvironment {\n Worker = 'Worker',\n Frame = 'Frame',\n // TODO - rename to MainThread\n ComponentPanel = 'ComponentPanel',\n}\n\nexport interface IEnvironmentContext {\n environment: PlatformEnvironment;\n privateApi: WithPromiseFunctions<IPrivateAPIFixMe>;\n events: PlatformAppEventEmitter;\n /**\n * Probably, we need to rename this prop\n */\n applicationAPIs?: Record<string, any>;\n}\n\nexport class EnvironmentContext {\n private static status = new ContextInjectionStatus('environment');\n\n static async inject(context: IEnvironmentContext) {\n if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {\n throw createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'Environment context already exists and should not be overridden',\n );\n }\n\n globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);\n this.status.resolveInjected();\n }\n\n static async getInstance(): Promise<EnvironmentContext> {\n await this.status.waitInjected();\n return globalThis[ENVIRONMENT_CONTEXT_KEY];\n }\n\n constructor(private environmentContext: IEnvironmentContext) {}\n\n getPrivateAPI() {\n return this.environmentContext.privateApi;\n }\n\n getEvents() {\n return this.environmentContext.events;\n }\n\n getApplicationAPIs() {\n return this.environmentContext.applicationAPIs ?? {};\n }\n\n getEnvironment() {\n return this.environmentContext.environment;\n }\n}\n","import {\n createEditorPlatformContextError,\n EditorPlatformContextErrorCode,\n} from '../errors';\n\nimport { ApplicationBoundEvents } from '../ApplicationBoundEvents';\nimport { EnvironmentContext } from './EnvironmentContext';\nimport { ContextInjectionStatus } from './ContextInjectionStatus';\n\nexport const APPLICATION_CONTEXT_KEY = '__APPLICATION_CONTEXT_KEY';\ndeclare global {\n // eslint-disable-next-line no-var\n var __APPLICATION_CONTEXT_KEY: ApplicationContext;\n}\n\n/**\n * renamed: IApplicationContext\n * there is no sense to split context by application type or running context\n * - addon\n * - application\n * - builder component\n * - panel or whatever\n * sdk context should be a union of all available options\n */\nexport interface IPlatformSDKContext {\n manifestContextId?: string | null;\n appDefinitionId?: string | null;\n /**\n * TODO: get rid of data prop, use root props\n */\n data?: {\n toolPanelConfig: {\n url: string;\n width: string;\n height: string;\n initialPosition: {\n x: string;\n y: string;\n };\n };\n };\n}\n\nexport class ApplicationContext {\n private static status = new ContextInjectionStatus('application');\n\n /**\n * TODO: use generics for context type\n * - application\n * - editor\n */\n static async inject(context: IPlatformSDKContext) {\n // const environment = await EnvironmentContext.getInstance();\n\n // if (environment.getEnvironment() !== PlatformEnvironment.Frame) {\n // throw createEditorPlatformContextError(\n // EditorPlatformContextErrorCode.IncorrectEnvironment,\n // 'Application context can be injected only in frame environment',\n // );\n // }\n\n if (globalThis[APPLICATION_CONTEXT_KEY]) {\n throw createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'Application context already exists and should not be overridden',\n );\n }\n\n globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(\n context,\n await EnvironmentContext.getInstance(),\n );\n\n this.status.resolveInjected();\n }\n\n static async getInstance() {\n if (typeof __APPLICATION_CONTEXT_KEY !== 'undefined') {\n /**\n * NOTE it is taken not from global\n * __APPLICATION_CONTEXT_KEY is the variable which set during\n * application bundle execution using new Function() approach\n */\n return __APPLICATION_CONTEXT_KEY as ApplicationContext;\n }\n\n await this.status.waitInjected();\n\n return globalThis[APPLICATION_CONTEXT_KEY] as ApplicationContext;\n\n // const environment = await EnvironmentContext.getInstance();\n\n // if (environment.getEnvironment() === PlatformEnvironment.Frame) {\n // await this.status.waitInjected();\n // return globalThis[\n // APPLICATION_CONTEXT_KEY\n // ] as ApplicationContext<TContext>;\n // } else {\n // /**\n // * NOTE it is taken not from global\n // * __APPLICATION_CONTEXT_KEY is the variable which set during\n // * application bundle execution using new Function() approach\n // */\n // return __APPLICATION_CONTEXT_KEY as ApplicationContext<TContext>;\n // }\n }\n\n private events: ApplicationBoundEvents;\n\n constructor(\n private context: IPlatformSDKContext,\n private environment: EnvironmentContext,\n ) {\n this.events = new ApplicationBoundEvents(\n context.appDefinitionId ? context.appDefinitionId : null,\n this.environment.getEvents(),\n this.environment.getPrivateAPI(),\n );\n }\n\n getContext() {\n return this.context;\n }\n\n getAppDefinitionId() {\n return this.context.appDefinitionId;\n }\n\n getManifestContextId() {\n return this.context.manifestContextId;\n }\n\n getEvents() {\n return this.events;\n }\n\n getEnvironmentContext() {\n return this.environment;\n }\n\n getPrivateAPI() {\n return this.environment.getPrivateAPI();\n }\n\n getPrivateApplicationAPI() {\n const appDefinitionId = this.getAppDefinitionId();\n\n if (!appDefinitionId) {\n throw createEditorPlatformContextError(\n EditorPlatformContextErrorCode.IncorrectEnvironment,\n 'appDefinitionId is not available',\n );\n }\n\n return this.environment.getApplicationAPIs()[appDefinitionId];\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","/**\n * it would be good to use performance.now()\n * but it some cases performance API is not available\n */\nexport function hash() {\n const _performance = globalThis['performance'];\n\n if (_performance && _performance.now) {\n return _performance.now();\n }\n\n let result = '';\n const characters =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n const charactersLength = characters.length;\n\n let counter = 0;\n\n const length = 10;\n while (counter < length) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n counter += 1;\n }\n\n return result;\n}\n","import { deserialize, serialize } from './serializer';\nimport { hash } from './hash';\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-${hash()}`;\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 enum HandshakeEvent_Deprecated {\n Greeting = 'Greeting',\n RequestPort = 'RequestPort',\n Port = 'Port',\n}\n\nexport type ConsumerEvent =\n | {\n type: HandshakeEvent.Ping;\n }\n | {\n type: HandshakeEvent.RequestPort;\n memberId: string;\n }\n /**\n * @deprecated\n * backward compatibility\n */\n | {\n type: HandshakeEvent_Deprecated.Greeting;\n memberId: string;\n }\n /**\n * @deprecated\n * backward compatibility\n */\n | {\n type: HandshakeEvent_Deprecated.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 {\n ConsumerEvent,\n HandshakeEvent,\n HandshakeEvent_Deprecated,\n HostEvent,\n} 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 /**\n * @deprecated\n * backward compatibility\n */\n case HandshakeEvent_Deprecated.Greeting: {\n if (!payload?.memberId && payload?.memberId === 'host') {\n return;\n }\n\n this.postMessage(\n JSON.stringify({\n memberId: 'host',\n type: HandshakeEvent_Deprecated.Greeting,\n }),\n );\n break;\n }\n\n /**\n * @deprecated\n * backward compatibility\n */\n case HandshakeEvent_Deprecated.RequestPort: {\n const messageChannel = this.#createMessageChannel();\n this.setActivePort(messageChannel?.port1);\n\n this.postMessage(\n JSON.stringify({\n memberId: 'host',\n targetMemberId: payload.memberId,\n type: HandshakeEvent_Deprecated.Port,\n }),\n messageChannel.port2,\n );\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 {\n HostEvent,\n HandshakeEvent,\n ConsumerEvent,\n HandshakeEvent_Deprecated,\n} from './events';\n\nimport {\n AbstractHandshake,\n IOnMessage,\n IPostMessage,\n} from './AbstractHandshake';\nimport { internalErrorMessage } from '../error';\nimport { hash } from '../hash';\n\nexport class ConsumerHandshake extends AbstractHandshake {\n #hostIsAlive = false;\n #memberId = `consumer-${hash()}`;\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 ApplicationEventsBridge {\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 {\n ApplicationContext,\n EnvironmentContext,\n PlatformEnvironment,\n} from '@wix/editor-platform-contexts';\nimport { PlatformAppEventEmitter } from '@wix/public-editor-platform-events';\nimport { IPrivateAPIFixMe } from './types';\nimport { IPlatformSDKContext } from '@wix/editor-platform-contexts';\n\nexport 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 TApiType extends PlatformConsumerEnvironmentAPIType,\n TEnv extends PlatformEnvironment,\n> {\n protected constructor(\n public type: TApiType,\n public envType: TEnv,\n ) {}\n\n abstract initEnvironment(props: unknown): void;\n\n async injectEnvironmentContext({\n events,\n privateApi,\n }: {\n events: PlatformAppEventEmitter;\n privateApi: IPrivateAPIFixMe;\n applicationAPIs?: Record<string, any>;\n }) {\n await EnvironmentContext.inject({\n environment: this.envType,\n events,\n privateApi,\n applicationAPIs: {},\n });\n }\n\n async injectApplicationContext(context: IPlatformSDKContext) {\n await ApplicationContext.inject(context);\n }\n}\n","import {\n IPlatformAppEvent,\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n} from '@wix/public-editor-platform-events';\nimport {\n IPlatformSDKContext,\n PlatformEnvironment,\n} from '@wix/editor-platform-contexts';\n\nimport { ApplicationEventsBridge } from '../ApplicationEventsBridge';\nimport { IPrivateAPIFixMe } from '../types';\n\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\n\nconst DESIGN_SYSTEM_STYLES_MAP = {\n classic:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css',\n studio:\n 'https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css',\n};\n\nexport class PlatformFrameAPI extends AbstractEnvironmentAPI<\n PlatformConsumerEnvironmentAPIType.Frame,\n PlatformEnvironment.Frame\n> {\n #events = new PlatformAppEventEmitter();\n #eventsBridge = new ApplicationEventsBridge(this.#events);\n #privateAPI: IPrivateAPIFixMe;\n #applicationPrivateAPI: any;\n\n constructor() {\n super(PlatformConsumerEnvironmentAPIType.Frame, PlatformEnvironment.Frame);\n\n this.#injectGlobalCSSTokens();\n }\n\n #injectGlobalCSSTokens() {\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 /**\n *\n * We need to introduce context versions\n * to simplify handling the backward compatibility issues\n */\n async initEnvironment(props: {\n // backward-compatibility\n appDefinitionId?: string;\n context: IPlatformSDKContext;\n privateAPI: IPrivateAPIFixMe;\n applicationPrivateAPI: any;\n }) {\n const { applicationPrivateAPI, privateAPI, context } = props;\n\n /**\n * backward-compatibility\n */\n const _appDefinitionId =\n props.context?.appDefinitionId ?? props.appDefinitionId;\n\n const _context = props.context\n ? props.context\n : {\n appDefinitionId: _appDefinitionId,\n };\n\n this.#applicationPrivateAPI = applicationPrivateAPI;\n this.#privateAPI = privateAPI;\n\n await this.injectEnvironmentContext({\n privateApi: privateAPI,\n events: this.#events,\n applicationAPIs: _appDefinitionId\n ? {\n [_appDefinitionId]: this.#applicationPrivateAPI,\n }\n : {},\n });\n\n await this.injectApplicationContext(_context);\n }\n\n notify(event: IPlatformPrivateEvent) {\n this.#eventsBridge.notify(event);\n }\n\n subscribe(cb: (event: IPlatformAppEvent) => void) {\n this.#eventsBridge.subscribe(cb);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationContainerErrorCode {\n ApplicationLoadError = 'ApplicationLoadError',\n ApplicationFetchError = 'ApplicationFetchError',\n ApplicationExecuteError = 'ApplicationExecuteError',\n}\n\nclass EditorPlatformApplicationContainerError extends BaseError<EditorPlatformApplicationContainerErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(\n message: string,\n code: EditorPlatformApplicationContainerErrorCode,\n ) {\n super(message, code, 'EP Application Container 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 createEditorPlatformApplicationContainerError = createErrorBuilder<\n EditorPlatformApplicationContainerErrorCode,\n EditorPlatformApplicationContainerError\n>(EditorPlatformApplicationContainerError);\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-platform-contexts';\n\nimport type { EditorPlatformApplication } from '@wix/editor-application';\nimport {\n createEditorPlatformApplicationContainerError,\n EditorPlatformApplicationContainerErrorCode,\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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.ApplicationExecuteError,\n 'Application registry called more than once',\n ).withAppDefinitionId(spec.appDefinitionId);\n }\n\n if (_instance.type !== spec.type) {\n throw createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError,\n EditorPlatformApplicationContainerErrorCode,\n} from './errors';\nimport { EditorPlatformApplication } from '@wix/editor-application';\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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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 createEditorPlatformApplicationContainerError(\n EditorPlatformApplicationContainerErrorCode.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","import { IApplicationSpec, IPrivateAPIFixMe } from '../types';\nimport {\n IPlatformPrivateEvent,\n PlatformAppEventEmitter,\n IPlatformAppEvent,\n} from '@wix/public-editor-platform-events';\nimport { PlatformEnvironment } from '@wix/editor-platform-contexts';\n\nimport { ApplicationEventsBridge } from '../ApplicationEventsBridge';\n\nimport { PlatformApplicationContainer } from './PlatformApplicationContainer';\nimport {\n AbstractEnvironmentAPI,\n PlatformConsumerEnvironmentAPIType,\n} from '../AbstractEnvironmentAPI';\n\nexport class PlatformWorkerAPI extends AbstractEnvironmentAPI<\n PlatformConsumerEnvironmentAPIType.Worker,\n PlatformEnvironment.Worker\n> {\n #events = new PlatformAppEventEmitter();\n\n #eventsBridge = new ApplicationEventsBridge(this.#events);\n #container: PlatformApplicationContainer | null = null;\n #privateAPI: IPrivateAPIFixMe;\n\n #pendingWaiters: ((value: this) => void)[] = [];\n\n constructor() {\n super(\n PlatformConsumerEnvironmentAPIType.Worker,\n PlatformEnvironment.Worker,\n );\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 this.injectEnvironmentContext({\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 // TODO: should not be any waiters here\n // or should be implemented inside the events instances\n // collect queue until app is not ready\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 {\n IFrameConsumerEndpoint,\n WorkerConsumerEndpoint,\n} from '@wix/editor-platform-transport';\n\nimport {\n ApplicationContext,\n EnvironmentContext,\n} from '@wix/editor-platform-contexts';\nimport { PlatformWorkerAPI, PlatformFrameAPI } from './api';\nimport {\n createEditorPlatformEnvironmentAPIError,\n EditorPlatformEnvironmentAPIErrorErrorCode,\n} from './errors';\n\nconst GUARD_PROP = '$_EP_TRANSPORT_ENV_CONTEXT_GUARD';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var $_EP_TRANSPORT_ENV_CONTEXT_GUARD: boolean;\n}\n\nexport class EditorPlatformContextEnvironment {\n isEnvironmentApiExposed() {\n return !!globalThis[GUARD_PROP];\n }\n\n async getContexts() {\n const [environmentContext, applicationContext] = await Promise.all([\n EnvironmentContext.getInstance(),\n ApplicationContext.getInstance(),\n ]);\n\n return {\n environmentContext,\n applicationContext,\n };\n }\n\n expose() {\n if (this.isEnvironmentApiExposed()) {\n return;\n }\n\n const isWorker = typeof importScripts === 'function';\n const isIframe =\n globalThis.self && globalThis.top && globalThis.self !== globalThis.top;\n\n /**\n * TODO: we can try to split this code somehow\n * and load the only API according to the current env.\n */\n if (isWorker) {\n this.#exposeWorkerAPI();\n globalThis[GUARD_PROP] = true;\n } else if (isIframe) {\n this.#exposeFrameAPI();\n globalThis[GUARD_PROP] = true;\n } else {\n /**\n * we expose env APIs only from worker or frame\n * but we have some cases when our code runs in the main thread\n * for example – builder component panels.\n */\n // if (!shouldPreventErrorLogs) {\n // console.error(\n // createEditorPlatformEnvironmentAPIError(\n // EditorPlatformEnvironmentAPIErrorErrorCode.IncorrectExpose,\n // 'seems current code is running in the main thread, while it is expected to be in iframe or worker',\n // ),\n // );\n // }\n }\n }\n\n #exposeWorkerAPI() {\n WorkerConsumerEndpoint.exposeAPI(new PlatformWorkerAPI());\n }\n\n #exposeFrameAPI() {\n IFrameConsumerEndpoint.exposeAPI(new PlatformFrameAPI());\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformEnvironmentAPIErrorErrorCode {\n ProxyEnvironmentConnectTimeout = 'ProxyEnvironmentConnectTimeout',\n ProxyWaitAPITimeout = 'ProxyWaitAPITimeout',\n ProxyContextsError = 'ProxyContextsError',\n IncorrectExpose = 'IncorrectExpose',\n}\n\nclass EditorPlatformEnvironmentAPIError extends BaseError<EditorPlatformEnvironmentAPIErrorErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n }> = {};\n\n constructor(\n message: string,\n code: EditorPlatformEnvironmentAPIErrorErrorCode,\n ) {\n super(message, code, 'EP EnvironmentAPI 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\nexport const createEditorPlatformEnvironmentAPIError = createErrorBuilder<\n EditorPlatformEnvironmentAPIErrorErrorCode,\n EditorPlatformEnvironmentAPIError\n>(EditorPlatformEnvironmentAPIError);\n","import { WorkerHostEndpoint } from '@wix/editor-platform-transport';\nimport { EditorPlatformContextEnvironment } from './EditorPlatformContextEnvironment';\nimport {\n createEditorPlatformEnvironmentAPIError,\n EditorPlatformEnvironmentAPIErrorErrorCode,\n} from './errors';\nimport {\n createEditorPlatformInternalError,\n EditorPlatformInternalErrorCode,\n} from '@wix/public-editor-platform-errors';\nimport { PlatformConsumerEnvironmentAPIType } from './api';\n\nexport class EditorPlatformEnvironmentProxy {\n async iframe() {\n throw createEditorPlatformInternalError(\n EditorPlatformInternalErrorCode.UnexpectedError,\n 'not supported',\n );\n }\n\n async worker(worker: Worker) {\n const environment = new EditorPlatformContextEnvironment();\n\n if (!environment.isEnvironmentApiExposed()) {\n environment.expose();\n }\n\n const connectTimeoutId = setTimeout(() => {\n console.info(\n createEditorPlatformEnvironmentAPIError(\n EditorPlatformEnvironmentAPIErrorErrorCode.ProxyEnvironmentConnectTimeout,\n 'probably worker environment does not expose platform API or any SDK function is never used',\n ),\n );\n }, 2_000);\n\n WorkerHostEndpoint.connect(worker, async (transport) => {\n clearTimeout(connectTimeoutId);\n\n const waitAPITimeoutId = setTimeout(() => {\n console.error(\n createEditorPlatformEnvironmentAPIError(\n EditorPlatformEnvironmentAPIErrorErrorCode.ProxyWaitAPITimeout,\n ),\n );\n }, 2_000);\n\n const workerApi = await transport.waitAPI(\n PlatformConsumerEnvironmentAPIType.Worker,\n );\n\n clearTimeout(waitAPITimeoutId);\n\n try {\n const contexts = await environment.getContexts();\n\n await workerApi.injectEnvironmentContext({\n events: contexts.environmentContext.getEvents(),\n privateApi: contexts.environmentContext.getPrivateAPI(),\n applicationAPIs: contexts.environmentContext.getApplicationAPIs(),\n });\n\n await workerApi.injectApplicationContext(\n contexts.applicationContext.getContext(),\n );\n } catch (e: any) {\n throw createEditorPlatformEnvironmentAPIError(\n EditorPlatformEnvironmentAPIErrorErrorCode.ProxyContextsError,\n ).withParentError(e);\n }\n });\n }\n}\n","import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n getAuth() {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.auth;\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function getContextualAuth() {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.getAuth();\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => {\n // used by the CLI for webhook registration on build time\n return {\n slug: eventDefinition.type,\n };\n };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n","import { contextualizeHostModuleV2 } from './context-v2.js';\nexport function createHostModule(hostModuleAPI) {\n return contextualizeHostModuleV2({\n __type: 'host',\n create: (host) => Object.entries(hostModuleAPI).reduce((acc, [key, fn]) => ({\n ...acc,\n [key]: fn(host),\n }), {}),\n }, Object.keys(hostModuleAPI));\n}\n","import { EditorPlatformContextEnvironment } from '@wix/editor-platform-environment-api';\n\nnew EditorPlatformContextEnvironment().expose();\n","import { ApplicationContext } from '@wix/editor-platform-contexts';\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\n/**\n * TODO: find a way to reuse implementation from PlatformInfra.getSDKAuth(...)\n * probably we should do it along with effort to support SDK shapes as placeholders,\n * when implementation is always injected from the main thread\n */\nexport const auth = () => {\n let instance: AccessToken;\n\n return {\n getAuthHeaders: async () => {\n const context = await ApplicationContext.getInstance();\n const appDefinitionId = context.getAppDefinitionId();\n const privateAPI = context.getPrivateAPI();\n\n if (!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 appDefinitionId,\n await privateAPI.info.getMetaSiteId(),\n );\n }\n\n if (!instance?.token) {\n console.error(\n createEditorPlatformSDKAuthError(\n EditorPlatformSDKAuthErrorCode.EmptyAppAuthInstance,\n ).withAppDefinitionId(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 { ApplicationContext } from '@wix/editor-platform-contexts';\nimport { createHostModule } from '@wix/sdk-runtime/host-modules';\nimport { Host } from '@wix/sdk-types';\n\ninterface IHostWithPlatformContexts {\n applicationContext?: Promise<ApplicationContext>;\n}\n\ntype MethodNames<T> = Extract<\n {\n [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n }[keyof T],\n string\n>;\n\ntype PickMethods<T, Keys extends keyof T> = {\n [K in Keys]: T[K];\n};\n\nexport class PlatformSDKShape<\n TShape extends new (...args: any[]) => any,\n TSelected extends MethodNames<InstanceType<TShape>> = never,\n> {\n constructor(\n private ShapeConstructor: TShape,\n private selectedMethods: TSelected[] = [],\n ) {}\n\n withPublicMethod<K extends MethodNames<InstanceType<TShape>>>(\n method: K,\n ): PlatformSDKShape<TShape, TSelected | K> {\n return new PlatformSDKShape(this.ShapeConstructor, [\n ...this.selectedMethods,\n method,\n ]);\n }\n\n build() {\n if (!this.selectedMethods.length) {\n throw new Error('methods are not defined for the SDK shape');\n }\n\n const sdk = this.selectedMethods.reduce(\n (acc, method) => {\n return {\n ...acc,\n [method]: (host: IHostWithPlatformContexts) => {\n const instance = new this.ShapeConstructor(\n host?.applicationContext,\n );\n\n if (!instance[method]) {\n return () => {\n console.error(`\"${method}\" is not defined in the SDK shape`);\n };\n }\n\n return instance[method].bind(instance);\n },\n };\n },\n {} as PickMethods<InstanceType<TShape>, TSelected>,\n );\n\n // @ts-expect-error\n return createHostModule<Host, InstanceType<TShape>>(sdk);\n }\n}\n","import { ApplicationContext } from '@wix/editor-platform-contexts';\nimport {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\n// export type IBaseSDKShape = new (\n// overrideApplicationContext?: Promise<ApplicationContext<any>>,\n// ) => any;\n\nexport enum BaseSDKErrorCode {\n ManifestContextIdRequired = 'ManifestContextIdRequired',\n}\n\nclass BaseSDKError extends BaseError<BaseSDKErrorCode> {\n constructor(message: string, code: BaseSDKErrorCode) {\n super(message, code, 'Base SDK Error');\n }\n}\n\nconst createBaseSDKError = createErrorBuilder<BaseSDKErrorCode, BaseSDKError>(\n BaseSDKError,\n);\n\nexport class BaseSDKShape {\n constructor(\n protected overriddenApplicationContext: Promise<ApplicationContext> | null = null,\n ) {}\n\n protected getApplicationContext() {\n return this.overriddenApplicationContext\n ? this.overriddenApplicationContext\n : ApplicationContext.getInstance();\n }\n\n protected async getAppDefinitionId() {\n return (await this.getApplicationContext()).getAppDefinitionId();\n }\n\n protected async getManifestContextId() {\n return (await this.getApplicationContext()).getManifestContextId();\n }\n\n protected async getRequiredManifestContextId() {\n const manifestContextId = await this.getManifestContextId();\n if (!manifestContextId) {\n throw createBaseSDKError(BaseSDKErrorCode.ManifestContextIdRequired);\n }\n\n return manifestContextId;\n }\n\n protected async getEnvironmentContext() {\n return (await this.getApplicationContext()).getEnvironmentContext();\n }\n\n protected async getPlatformPrivateAPI() {\n return (await this.getApplicationContext()).getPrivateAPI();\n }\n\n // NOTE: don't remove this for now\n // protected dep<TDep extends IBaseSDKShape>(Factory: TDep) {\n // let instance: InstanceType<TDep>;\n //\n // return () => {\n // if (!instance) {\n // instance = new Factory(this.getApplicationContext());\n // }\n //\n // return instance;\n // };\n // }\n}\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class ApplicationSDKShape extends BaseSDKShape {\n async getPrivateAPI<T>() {\n return (await this.getApplicationContext()).getPrivateApplicationAPI() as T;\n }\n\n async getPublicAPI<T>(appDefinitionId: string) {\n const privateAPI = await this.getPlatformPrivateAPI();\n\n return privateAPI.applicationManager.getPublicApplicationAPI(\n appDefinitionId,\n ) as Promise<T>;\n }\n\n async getAppInstance() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getAppInstance(await this.getAppDefinitionId());\n }\n}\n\nexport default new PlatformSDKShape(ApplicationSDKShape)\n .withPublicMethod('getPrivateAPI')\n .withPublicMethod('getPublicAPI')\n .withPublicMethod('getAppInstance')\n .build();\n","import { AppEventPayload, AllowedEvents } from '@wix/editor-platform-contexts';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\n// TODO: remove events shape and remove payload transformations\nexport class EventsSDKShape extends BaseSDKShape {\n async addEventListener(\n name: any,\n // TODO: fix types\n cb: (payload: AppEventPayload<AllowedEvents>) => void,\n ) {\n return (await this.getApplicationContext())\n .getEvents()\n .addEventListener(name, cb);\n }\n}\n\nexport default new PlatformSDKShape(EventsSDKShape)\n .withPublicMethod('addEventListener')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { EventsSDKShape } from '../events';\nimport { IElement } from '@wix/public-editor-platform-interfaces';\n\nexport class ElementsSDKShape extends BaseSDKShape {\n async getSelection() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n\n return Promise.all<IElement[]>(\n refs.map(\n (ref: any) => privateAPI.components.getComponent(ref) as IElement,\n ),\n );\n }\n\n async onSelectionChange(cb: (elements: IElement[]) => void) {\n const events = new EventsSDKShape(this.getApplicationContext());\n void events.addEventListener('componentSelectionChanged', (payload) => {\n // @ts-expect-error TODO: refactor events.\n cb(payload.components);\n });\n }\n}\n\nexport default new PlatformSDKShape(ElementsSDKShape)\n .withPublicMethod('onSelectionChange')\n .withPublicMethod('getSelection')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\ntype ThemeCustomProperty =\n | {\n type: string;\n value: string;\n displayName: string;\n }\n | { error: string };\n\ntype FontOption = {\n displayName: string;\n characterSets: string[];\n fontFamily: string;\n cssFontFamily: string;\n style: { weight: number; style: string }[];\n};\nexport class InfoSDKShape extends BaseSDKShape {\n async getViewMode() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getViewMode();\n }\n\n async getLanguageCode() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getLanguageCode();\n }\n\n async getSiteDirection() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getSiteDirection();\n }\n\n async siteHasCustomClasses() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.siteHasCustomClasses();\n }\n\n async getThemeCustomProperties(filter: {\n keys?: string[];\n }): Promise<Record<string, ThemeCustomProperty>> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getThemeCustomProperties(filter);\n }\n\n async getSiteFonts(filter: {\n keys?: string[];\n }): Promise<Record<string, FontOption>> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.info.getSiteFonts(filter) as Record<string, FontOption>;\n }\n}\n\nexport default new PlatformSDKShape(InfoSDKShape)\n .withPublicMethod('getViewMode')\n .withPublicMethod('getLanguageCode')\n .withPublicMethod('getSiteDirection')\n .withPublicMethod('siteHasCustomClasses')\n .withPublicMethod('getThemeCustomProperties')\n .withPublicMethod('getSiteFonts')\n .build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum WidgetShapeErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n NotAvailableMethod = 'NotAvailableMethod',\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","export interface IFontValue {\n theme?: string;\n family?: string;\n size?: number;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n cssVariableName?: string;\n}\n\nexport interface FontPickerValue {\n font: string;\n textDecoration?: string;\n}\n\nexport const UNDERLINE_DEFINITION = 'underline';\n\nexport function getFontFamiliesFromFonts(fonts: string[]) {\n return fonts\n .map((font) => parseFontString({ font }).family)\n .filter(Boolean) as string[];\n}\n\nexport function 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 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","import { createWidgetShapeError, WidgetShapeErrorCode } from './errors';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { getFontFamiliesFromFonts } from '../inputs/utils';\nimport { ComponentRef } from '@wix/public-editor-platform-interfaces';\n\nexport class WidgetScopedSDK {\n constructor(\n private compRef: ComponentRef,\n private privateAPI: any,\n ) {}\n\n async getProp(propName: string): Promise<string> {\n const props = await this.privateAPI.refComponents.getProps(this.compRef);\n return props?.[propName];\n }\n\n async setProp(propName: string, value: string) {\n await this.privateAPI.refComponents.setProps(this.compRef, {\n [propName]: value,\n });\n }\n\n async getDesignPreset() {\n return this.privateAPI.designPresets.getDesignPresetName(this.compRef);\n }\n\n async setDesignPreset(designPresetName: string) {\n await this.privateAPI.designPresets.setDesignPresetByName(\n this.compRef,\n designPresetName,\n );\n }\n\n async getNestedWidget(selector: `#${string}`) {\n const childCompRef =\n await this.privateAPI.refComponents.findComponentBySelector(\n this.compRef,\n selector,\n );\n\n if (!childCompRef) {\n return null;\n }\n\n return new WidgetScopedSDK(childCompRef, this.privateAPI);\n }\n}\n\nexport class WidgetSDKShape extends BaseSDKShape {\n async #getSelectedComponentRef() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n const compRef = refs[0];\n\n if (!compRef) {\n throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n }\n\n async setPreloadFonts(fonts: string[]): Promise<void> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (await privateAPI.refComponents.isRefComponent(compRef)) {\n throw createWidgetShapeError(\n WidgetShapeErrorCode.NotAvailableMethod,\n 'not available for the current component type',\n );\n }\n\n const fontFamilies = getFontFamiliesFromFonts(fonts);\n\n await privateAPI.customElement.setPreloadFonts(compRef, fontFamilies);\n }\n\n async getProp(propName: string): Promise<string> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (await privateAPI.refComponents.isRefComponent(compRef)) {\n return new WidgetScopedSDK(compRef, privateAPI).getProp(propName);\n } else {\n return privateAPI.customElement.getAttribute(compRef, propName);\n }\n }\n\n async setProp(propName: string, value: string) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (await privateAPI.refComponents.isRefComponent(compRef)) {\n return new WidgetScopedSDK(compRef, privateAPI).setProp(propName, value);\n } else {\n await privateAPI.customElement.setAttribute(compRef, propName, value);\n }\n }\n\n async getDesignPreset() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (!(await privateAPI.refComponents.isRefComponent(compRef))) {\n throw createWidgetShapeError(\n WidgetShapeErrorCode.NotAvailableMethod,\n 'not available for the current component type',\n );\n }\n\n return new WidgetScopedSDK(compRef, privateAPI).getDesignPreset();\n }\n\n async setDesignPreset(designPresetName: string) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n if (!(await privateAPI.refComponents.isRefComponent(compRef))) {\n throw createWidgetShapeError(\n WidgetShapeErrorCode.NotAvailableMethod,\n 'not available for the current component type',\n );\n }\n\n return new WidgetScopedSDK(compRef, privateAPI).setDesignPreset(\n designPresetName,\n );\n }\n\n async getNestedWidget(selector: `#${string}`) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRef = await this.#getSelectedComponentRef();\n\n return new WidgetScopedSDK(compRef, privateAPI).getNestedWidget(selector);\n }\n}\n\nconst widgetShape = new PlatformSDKShape(WidgetSDKShape)\n .withPublicMethod('getNestedWidget')\n .withPublicMethod('setDesignPreset')\n .withPublicMethod('getDesignPreset')\n .withPublicMethod('setProp')\n .withPublicMethod('getProp')\n .withPublicMethod('setPreloadFonts');\n\nexport default widgetShape.build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport {\n type IFontValue,\n type FontPickerValue,\n parseFontString,\n UNDERLINE_DEFINITION,\n} from './utils';\n\ninterface IColorValue {\n color: string;\n theme?: string;\n cssVariableName?: string;\n}\n\ntype IColorPickerValue = string | null | undefined;\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?: IColorPickerValue,\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\nexport class InputsSDKShape extends BaseSDKShape {\n async selectColor(\n value?: IColorPickerValue,\n options?: {\n onChange?: (value: IColorPickerValue) => void;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\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 || colorValue?.theme || 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 async selectFont(\n value?: FontPickerValue,\n options?: {\n onChange?: (value: FontPickerValue) => void;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\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\nexport default new PlatformSDKShape(InputsSDKShape)\n .withPublicMethod('selectColor')\n .withPublicMethod('selectFont')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class PanelsSDKShape extends BaseSDKShape {\n async openLanguageSupportPanel() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.panels.openLanguageSupportPanel();\n }\n\n async openFontsUploadPanel() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.panels.openFontsUploadPanel();\n }\n}\n\nexport default new PlatformSDKShape(PanelsSDKShape)\n .withPublicMethod('openLanguageSupportPanel')\n .withPublicMethod('openFontsUploadPanel')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class ModalsSDKShape extends BaseSDKShape {\n async openDashboardModal(options: {\n url: string;\n closeOtherPanels?: boolean;\n }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.panels.openDashboardPanel(\n await this.getAppDefinitionId(),\n options,\n );\n }\n}\n\nexport default new PlatformSDKShape(ModalsSDKShape)\n .withPublicMethod('openDashboardModal')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { ApplicationContext } from '@wix/editor-platform-contexts';\n\ninterface IFontFamily {\n family: string;\n weight: string;\n}\n\ninterface IFontWeight {\n weight: string;\n}\n\ntype IFontFamilyAndWeight = IFontFamily & IFontWeight;\n\ntype ISelectLinkSharedOptions = {\n origin?: string;\n};\nexport class ElementSDKShape extends BaseSDKShape {\n constructor(\n protected overriddenApplicationContext: Promise<ApplicationContext> | null = null,\n private childPath: number[] = [],\n ) {\n super(overriddenApplicationContext);\n }\n\n async getStyleDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getStyleDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getStyles(): Promise<{\n cssProperties: Record<string, string>;\n cssCustomProperties: Record<string, string>;\n }> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getStyles(\n manifestContextId,\n this.childPath,\n );\n }\n\n async setStyles({\n cssProperties,\n cssCustomProperties,\n }: {\n cssProperties?: Record<string, string>;\n cssCustomProperties?: Record<string, string>;\n } = {}): Promise<void> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.setStyles(\n manifestContextId,\n this.childPath,\n {\n cssProperties,\n cssCustomProperties,\n },\n );\n }\n\n async removeStyles(\n values: {\n cssPropertiesKeys?: string[];\n cssCustomPropertiesKeys?: string[];\n } = {},\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.removeStyles(\n manifestContextId,\n this.childPath,\n values,\n );\n }\n\n async getDataDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getDataDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getData() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getData(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getResolvedData({ dataItemKey }: { dataItemKey: string }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getResolvedData(\n manifestContextId,\n this.childPath,\n {\n dataItemKey,\n },\n );\n }\n\n async setData(values: {}) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.setData(\n manifestContextId,\n this.childPath,\n values,\n );\n }\n\n async getPresetDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getPresetDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n async getAppliedPreset() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getAppliedPreset(\n manifestContextId,\n this.childPath,\n );\n }\n\n async applyPreset(options: { key: string }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.applyPreset(\n manifestContextId,\n this.childPath,\n options,\n );\n }\n\n // TODO: group type should come from builder enum\n async getDisplayGroupDefinitions(options?: {\n filter?: { groupType?: string };\n }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.getDisplayGroupDefinitions(\n manifestContextId,\n this.childPath,\n options,\n );\n }\n\n async getState() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getState(\n manifestContextId,\n this.childPath,\n );\n }\n\n async setState(stateKey: string | null) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.setState(\n manifestContextId,\n this.childPath,\n stateKey,\n );\n }\n\n async getStateDefinitions() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.getStateDefinitions(\n manifestContextId,\n this.childPath,\n );\n }\n\n /**\n * TODO: use type from the ManifestChangeDetection,\n * but type should be moved to editor-platform-public-interfaces\n */\n async onChange(\n cb: (patch: {\n type: 'cssProperties' | 'cssCustomProperties' | 'data' | 'manifest';\n value: unknown;\n }) => void,\n ): Promise<() => {}> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.onChange(\n manifestContextId,\n this.childPath,\n cb,\n );\n }\n\n async selectFont(\n params:\n | {\n styleItemKey: string;\n }\n // TODO: get type from common place https://wix.atlassian.net/browse/EP-6480\n | {\n selectedFontFamily?: IFontFamilyAndWeight;\n target?: HTMLElement;\n onChange?: (value: IFontFamilyAndWeight) => void;\n onPreview?: (value: IFontFamilyAndWeight) => void;\n },\n ) {\n try {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n const selectedFont = await privateAPI.builderComponent.selectFont(\n manifestContextId,\n this.childPath,\n {\n ...params,\n showWeights: true,\n },\n );\n return selectedFont;\n } catch (error) {\n // TODO: handle error https://wix.atlassian.net/browse/EP-6428\n }\n }\n\n async selectFontFamily(\n params:\n | {\n styleItemKey: string;\n }\n // TODO: get type from common place https://wix.atlassian.net/browse/EP-6480\n | {\n selectedFontFamily?: IFontFamily;\n target?: HTMLElement;\n onChange?: (value: IFontFamily) => void;\n onPreview?: (value: IFontFamily) => void;\n },\n ) {\n try {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n const selectedFont = await privateAPI.builderComponent.selectFont(\n manifestContextId,\n this.childPath,\n {\n ...params,\n showWeights: false,\n },\n );\n return selectedFont;\n } catch (error) {\n // TODO: handle error https://wix.atlassian.net/browse/EP-6428\n }\n }\n\n async selectMedia(\n params: // TODO: get type from common place https://wix.atlassian.net/browse/EP-6462\n | {\n dataItemKey: string;\n }\n | {\n isMultiSelect?: boolean;\n category?: string;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.selectMedia(\n manifestContextId,\n this.childPath,\n params,\n );\n }\n\n async selectLink(\n params:\n | {\n dataItemKey: string;\n options?: ISelectLinkSharedOptions;\n }\n | {\n value?: object;\n options?: ISelectLinkSharedOptions & {\n linkTypes?: string[];\n };\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n\n return privateAPI.builderComponent.selectLink(\n manifestContextId,\n this.childPath,\n params,\n );\n }\n\n async selectColor(\n params:\n | { styleItemKey: string }\n // TODO: get the ColorPickerOptions from SDK types https://wix.atlassian.net/browse/EP-6433\n | {\n initialValue?: string;\n mode?: ('solid' | 'gradient')[];\n showBrand?: boolean;\n showCustom?: boolean;\n showAdvancedSettings?: boolean;\n showOpacity?: boolean;\n position?: { x: number; y: number };\n biData?: { origin: string };\n // TODO: Fix when public Color type is available https://wix.atlassian.net/browse/EP-6427\n onChange?: (color: string) => void;\n // TODO: Fix when public Color type is available https://wix.atlassian.net/browse/EP-6427\n onApply?: (color: string) => void;\n onClose?: () => void;\n onCancel?: () => void;\n },\n ) {\n const privateAPI = await this.getPlatformPrivateAPI();\n try {\n const manifestContextId = await this.getRequiredManifestContextId();\n const selectedColor = await privateAPI.builderComponent.selectColor(\n manifestContextId,\n this.childPath,\n params,\n );\n return selectedColor;\n } catch (error) {\n // TODO: handle error https://wix.atlassian.net/browse/EP-6428\n }\n }\n\n async selectFontWeight(\n params:\n | {\n fontFamilyStyleItemKey: string;\n fontWeightStyleItemKey: string;\n }\n | {\n fontStyleItemKey: string;\n }\n | {\n fontFamily?: IFontFamily;\n target?: HTMLElement;\n onChange?: (value: IFontWeight) => void;\n },\n ): Promise<IFontWeight> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return {\n weight: await privateAPI.builderComponent.selectFontWeight(\n manifestContextId,\n this.childPath,\n params,\n ),\n };\n }\n\n async selectTextTheme(params: {\n target?: HTMLElement;\n initialValue?: {\n font?: string;\n color?: string;\n };\n }) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const manifestContextId = await this.getRequiredManifestContextId();\n return privateAPI.builderComponent.selectTextTheme(\n manifestContextId,\n params,\n );\n }\n}\n\nexport default new PlatformSDKShape(ElementSDKShape)\n .withPublicMethod('getDataDefinitions')\n .withPublicMethod('getData')\n .withPublicMethod('getResolvedData')\n .withPublicMethod('setData')\n .withPublicMethod('getStyleDefinitions')\n .withPublicMethod('getStyles')\n .withPublicMethod('setStyles')\n .withPublicMethod('removeStyles')\n .withPublicMethod('getPresetDefinitions')\n .withPublicMethod('getAppliedPreset')\n .withPublicMethod('applyPreset')\n .withPublicMethod('getDisplayGroupDefinitions')\n .withPublicMethod('getState')\n .withPublicMethod('setState')\n .withPublicMethod('onChange')\n .withPublicMethod('getStateDefinitions')\n .withPublicMethod('selectFont')\n .withPublicMethod('selectFontFamily')\n .withPublicMethod('selectMedia')\n .withPublicMethod('selectLink')\n .withPublicMethod('selectColor')\n .withPublicMethod('selectFontWeight')\n .withPublicMethod('selectTextTheme')\n .build();\n","import { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class PreferencesSDKShape extends BaseSDKShape {\n async get(keys: string[]) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.userPreferences.get(\n await this.getAppDefinitionId(),\n keys,\n );\n }\n\n async set(preferences: Record<string, any>) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.userPreferences.set(\n await this.getAppDefinitionId(),\n preferences,\n );\n }\n}\n\nexport default new PlatformSDKShape(PreferencesSDKShape)\n .withPublicMethod('set')\n .withPublicMethod('get')\n .build();\n","import {\n DsItem,\n BuilderStyle,\n StyleRef,\n OpenColorPickerFn,\n OpenLinkPanelFn,\n} from '@wix/public-editor-platform-interfaces';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { BaseSDKShape } from '../BaseSDKShape';\n\nexport class ExternalPanelsSDKShape extends BaseSDKShape {\n async getData() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.getData();\n }\n\n async setData(newData: DsItem) {\n const privateAPI = await this.getPlatformPrivateAPI();\n\n return privateAPI.externalPanels.setData(newData);\n }\n\n async getStyle() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.getStyle();\n }\n\n async setStyle(newStyle: Partial<BuilderStyle> | StyleRef) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.setStyle(newStyle);\n }\n\n async getTheme() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.getTheme();\n }\n\n async selectMedia() {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.selectMedia();\n }\n\n async selectLink(...options: any): Promise<OpenLinkPanelFn> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.selectLink(...options);\n }\n\n async selectColor(...options: any): Promise<OpenColorPickerFn> {\n return async () => {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.selectColor(...options);\n };\n }\n\n async translate(key: string | string[], values?: Record<string, any>) {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.externalPanels.translate(key, values);\n }\n}\n\nexport default new PlatformSDKShape(ExternalPanelsSDKShape)\n .withPublicMethod('getTheme')\n .withPublicMethod('getData')\n .withPublicMethod('getStyle')\n .withPublicMethod('selectColor')\n .withPublicMethod('selectLink')\n .withPublicMethod('selectMedia')\n .withPublicMethod('setData')\n .withPublicMethod('setStyle')\n .withPublicMethod('translate')\n .build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum ControllersErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n}\n\nclass ControllersError extends BaseError<ControllersErrorCode> {\n constructor(message: string, code: ControllersErrorCode) {\n super(message, code, 'Controllers Error');\n }\n}\n\nexport const createControllersError = createErrorBuilder<\n ControllersErrorCode,\n ControllersError\n>(ControllersError);\n","import { BaseSDKShape } from '../BaseSDKShape';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport { ControllersErrorCode, createControllersError } from './errors';\n\ninterface AppController {\n type: string;\n settings: Record<string, any>;\n update: (settings: Record<string, any>) => void;\n}\n\nexport class ControllersSDKShape extends BaseSDKShape {\n async #getSelectedComponentRef() {\n const privateAPI = await this.getPlatformPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n const compRef = refs[0];\n\n if (!compRef) {\n throw createControllersError(ControllersErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n }\n async get(): Promise<AppController[]> {\n const privateAPI = await this.getPlatformPrivateAPI();\n return privateAPI.controllers.get(\n await this.getAppDefinitionId(),\n await this.#getSelectedComponentRef(),\n );\n }\n}\n\nexport default new PlatformSDKShape(ControllersSDKShape)\n .withPublicMethod('get')\n .build();\n","import { ComponentRef } from '@wix/public-editor-platform-interfaces';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport {\n BindingTarget,\n IBindingConnectionItem,\n IDataBindingItem,\n} from './types';\nexport class BindingConnectionItem {\n constructor(\n private privateAPI: any,\n private compRef: ComponentRef,\n private bindingTargetId: string,\n private config: string,\n ) {}\n\n public update(data: Partial<IDataBindingItem>) {\n return this.privateAPI.bindings.update(this.compRef, this.bindingTargetId, {\n config: data.config,\n role: data.role,\n });\n }\n\n public delete() {\n return this.privateAPI.bindings.delete(this.compRef, this.bindingTargetId);\n }\n\n get connectionConfig() {\n return this.config;\n }\n}\nexport class BindingsSDKShape extends BaseSDKShape {\n public async get(\n bindingTarget: BindingTarget,\n ): Promise<IBindingConnectionItem | null> {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRefs = await privateAPI.components.getSelectedComponents();\n if (compRefs.length !== 1) {\n return null;\n }\n const [compRef] = compRefs;\n const dataBindingConfig = privateAPI.bindings.get(\n bindingTarget.id,\n compRef,\n );\n if (!dataBindingConfig) {\n return null;\n }\n\n return new BindingConnectionItem(\n privateAPI,\n compRef,\n bindingTarget.id,\n dataBindingConfig,\n );\n }\n}\n\nexport default new PlatformSDKShape(BindingsSDKShape)\n .withPublicMethod('get')\n .build();\n","import { ComponentRef } from '@wix/public-editor-platform-interfaces';\nimport { BaseSDKShape } from '../BaseSDKShape';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\nimport {\n BindingTarget,\n IBindingsProvider,\n IDataBindingItem,\n} from '../bindings/types';\nimport { BindingConnectionItem } from '../bindings';\n\nclass BindingsProvider implements IBindingsProvider {\n constructor(\n private privateAPI: any,\n private compRef: ComponentRef,\n private dataItemTarget: BindingTarget,\n public name: string,\n ) {}\n\n public select() {\n return this.privateAPI.bindings.openDataBindingPanel(\n this.dataItemTarget.id,\n );\n }\n\n public createBinding(data: IDataBindingItem) {\n const created = this.privateAPI.bindings.create(this.compRef, {\n dataItemId: this.dataItemTarget.id,\n bindingItemType: 'dataBinding',\n ...data,\n });\n\n if (!created) {\n return null;\n }\n\n return new BindingConnectionItem(\n this.privateAPI,\n this.compRef,\n this.dataItemTarget.id,\n JSON.stringify(data),\n );\n }\n}\nexport class BindingsProvidersSDKShape extends BaseSDKShape {\n public async list(bindingTarget: BindingTarget) {\n const privateAPI = await this.getPlatformPrivateAPI();\n const compRefs: ComponentRef[] =\n await privateAPI.components.getSelectedComponents();\n if (compRefs.length !== 1) {\n return [];\n }\n const [compRef] = compRefs;\n if (!(await privateAPI.bindings.canCreateBindingsProvider(compRef))) {\n return [];\n }\n\n return [\n new BindingsProvider(privateAPI, compRef!, bindingTarget, 'dataBinding'),\n ];\n }\n}\n\nexport default new PlatformSDKShape(BindingsProvidersSDKShape)\n .withPublicMethod('list')\n .build();\n","import type { ApplicationContext } from '@wix/editor-platform-contexts';\nimport type { WorkspaceHost as WorkspaceHostType } from '@wix/workspace';\n\nexport interface WorkspaceAPI\n extends NonNullable<WorkspaceHostType['workspace']> {}\n\nclass Workspace implements WorkspaceAPI {\n constructor(private applicationContext: Promise<ApplicationContext>) {}\n\n private async workspaceAPI(): Promise<WorkspaceAPI> {\n const context = await this.applicationContext;\n const privateAPI = context.getPrivateAPI();\n const workspaceAPI = await privateAPI.workspace;\n return workspaceAPI;\n }\n\n getContextIds: WorkspaceAPI['getContextIds'] = () => {\n throw new Error('Not implemented yet');\n };\n\n openItemSelector: WorkspaceAPI['openItemSelector'] = (_args) => {\n throw new Error('Not implemented yet');\n };\n}\n\nexport class WorkspaceHost {\n #api: WorkspaceAPI;\n\n getAPI(): WorkspaceAPI {\n return this.#api;\n }\n\n constructor(applicationContext: Promise<ApplicationContext>) {\n this.#api = new Workspace(applicationContext);\n }\n}\n","import type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\nimport { ApplicationContext } from '@wix/editor-platform-contexts';\nimport { getMonitoringClientFunction } from '@wix/monitoring-browser-sdk-host';\nimport { WorkspaceHost, type WorkspaceAPI } from './workspaceHost';\n\ndeclare global {\n interface Window {\n Sentry?: any;\n }\n}\n\nexport const frame = (): WixSDKTypes.Host & {\n workspace: WorkspaceAPI;\n applicationContext: Promise<ApplicationContext>;\n essentials: {\n language?: string;\n locale?: string;\n };\n} => {\n const queryParams = new URLSearchParams(window.location.search);\n const essentialsQueryParamValue = queryParams.has('essentials')\n ? JSON.parse(queryParams.get('essentials')!)\n : undefined;\n const { monitoring, ...essentials } = essentialsQueryParamValue || {};\n const appDefinitionId = queryParams.get('appDefinitionId')!;\n const { context, config } = monitoring || {};\n const getMonitoringClient = getMonitoringClientFunction({\n hostContext: { appId: appDefinitionId, ...context },\n monitoringConfig: config,\n sentrySDK: typeof window !== 'undefined' ? window.Sentry : undefined,\n });\n\n const applicationContext = ApplicationContext.getInstance();\n const workspaceHost = new WorkspaceHost(applicationContext);\n\n return {\n environment: {},\n applicationContext,\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n getMonitoringClient,\n workspace: workspaceHost.getAPI(),\n essentials,\n };\n};\n\nexport const worker = (): WixSDKTypes.Host & {\n workspace: WorkspaceAPI;\n applicationContext: Promise<ApplicationContext>;\n} => {\n const applicationContext = ApplicationContext.getInstance();\n const workspaceHost = new WorkspaceHost(applicationContext);\n\n return {\n environment: {},\n applicationContext,\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n workspace: workspaceHost.getAPI(),\n };\n};\n","import './env';\nimport { auth } from './auth';\n\nexport { default as application } from './application';\nexport { default as elements } from './elements';\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 panels } from './panels';\nexport { default as modals } from './modals';\nexport { default as element, ElementSDKShape } from './element';\nexport { default as preferences } from './preferences';\nexport { default as externalPanels } from './externalPanels';\nexport { default as controllers } from './controllers';\nexport { default as bindings } from './bindings';\nexport { default as bindingsProviders } from './bindingsProviders';\nexport { BaseSDKShape } from './BaseSDKShape';\nexport { PlatformSDKShape } from './PlatformSDKShape';\n\nimport * as host from './host';\n\nexport const editor = {\n host: () => {\n const isWorker = typeof importScripts === 'function';\n\n if (isWorker) {\n return host.worker();\n }\n\n return host.frame();\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":"sPAAA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c,QAAQ,CAClC","names":["require_EventType","__commonJSMin","exports","EventType","require_dist","__commonJSMin","exports","__createBinding","o","m","k","k2","desc","__setModuleDefault","v","__importStar","ownKeys","ar","mod","result","i","WixSDKTypes","EventType_1","_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","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","EditorPlatformContextErrorCode","EditorPlatformContextError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformContextError","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","__privateAdd","_ContextInjectionStatus_instances","__privateMethod","getGlobalInjectionPromise_fn","createGlobalInjectionPromise_fn","resolve","reject","injected","timeoutId","retryCount","timeout","error","_resolve","promise","ENVIRONMENT_CONTEXT_KEY","PlatformEnvironment","_EnvironmentContext","environmentContext","context","EnvironmentContext","APPLICATION_CONTEXT_KEY","_ApplicationContext","environment","ApplicationContext","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","hash","_performance","result","characters","charactersLength","counter","length","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","hash","__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","ApplicationEventsBridge","platformAppEvents","event","PlatformLifecycleEvent","PlatformAppEvent","PlatformPrivateEvent","cb","PlatformConsumerEnvironmentAPIType","AbstractEnvironmentAPI","type","envType","events","privateApi","EnvironmentContext","context","ApplicationContext","DESIGN_SYSTEM_STYLES_MAP","PlatformFrameAPI","PlatformEnvironment","__privateAdd","_PlatformFrameAPI_instances","_events","PlatformAppEventEmitter","_eventsBridge","__privateGet","_privateAPI","_applicationPrivateAPI","__privateMethod","injectGlobalCSSTokens_fn","props","applicationPrivateAPI","privateAPI","_appDefinitionId","_context","__privateSet","host","url","isAlreadyLoaded","link","EditorPlatformApplicationContainerErrorCode","EditorPlatformApplicationContainerError","BaseError","message","code","__publicField","appDefinitionId","apiMethod","apiType","createEditorPlatformApplicationContainerError","createErrorBuilder","APPLICATION_REGISTRY_KEY","executeApplication","spec","bundle","executable","APPLICATION_CONTEXT_KEY","instance","applicationRegistryCallback","_instance","e","resolve","reject","unsubscribe","timeoutId","PlatformApplicationContainer","_apps","appSpec","appDefId","res","PlatformWorkerAPI","_container","_pendingWaiters","buildPrivateAPI","app","GUARD_PROP","EditorPlatformContextEnvironment","_EditorPlatformContextEnvironment_instances","environmentContext","applicationContext","isWorker","isIframe","exposeWorkerAPI_fn","exposeFrameAPI_fn","WorkerConsumerEndpoint","IFrameConsumerEndpoint","EditorPlatformEnvironmentAPIError","BaseError","message","code","__publicField","url","appDefinitionId","createEditorPlatformEnvironmentAPIError","createErrorBuilder","wixContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext","contextualizeHostModuleV2","hostModule","props","prop","args","context","resolveContext","createHostModule","hostModuleAPI","contextualizeHostModuleV2","host","acc","key","fn","EditorPlatformContextEnvironment","EditorPlatformSDKAuthError","BaseError","message","code","__publicField","appDefinitionId","createEditorPlatformSDKAuthError","createErrorBuilder","hasEnoughTimeUntilExpiry","expires","expiryBuffer","now","expiryTime","ACCESS_TOKEN_EXPIRY_GRACE_PERIOD","auth","instance","context","ApplicationContext","privateAPI","PlatformSDKShape","_PlatformSDKShape","ShapeConstructor","selectedMethods","method","sdk","acc","host","createHostModule","BaseSDKError","createBaseSDKError","BaseSDKShape","overriddenApplicationContext","manifestContextId","ApplicationSDKShape","index$d","EventsSDKShape","name","cb","index$c","ElementsSDKShape","refs","ref","payload","index$b","InfoSDKShape","filter","index$a","WidgetShapeErrorCode","WidgetShapeError","createWidgetShapeError","UNDERLINE_DEFINITION","getFontFamiliesFromFonts","fonts","font","parseFontString","fontPickerValue","variableName","fallbackValue","extractFontVar","parts","i","part","fontString","trimmedFont","match","WidgetScopedSDK","_WidgetScopedSDK","compRef","propName","value","designPresetName","selector","childCompRef","WidgetSDKShape","__privateAdd","_WidgetSDKShape_instances","__privateMethod","getSelectedComponentRef_fn","fontFamilies","widgetShape","index$9","fontValueToCSS","fontValue","fontFamily","parseColorString","colorPickerValue","colorString","colorValueToCSS","colorValue","theme","cssVariableName","bold","italic","underline","rest","InputsSDKShape","options","colorResult","color","cssVariableTheme","_value","accessibility","index$8","PanelsSDKShape","index$7","ModalsSDKShape","index$6","ElementSDKShape","childPath","cssProperties","cssCustomProperties","values","dataItemKey","stateKey","params","index$5","PreferencesSDKShape","keys","preferences","index$4","ExternalPanelsSDKShape","newData","newStyle","key","index$3","ControllersErrorCode","ControllersError","createControllersError","ControllersSDKShape","_ControllersSDKShape_instances","index$2","BindingConnectionItem","bindingTargetId","config","data","BindingsSDKShape","bindingTarget","compRefs","dataBindingConfig","index$1","BindingsProvider","dataItemTarget","BindingsProvidersSDKShape","index","Workspace","applicationContext","_args","WorkspaceHost","_api","__privateSet","__privateGet","frame","queryParams","essentialsQueryParamValue","monitoring","essentials","getMonitoringClient","getMonitoringClientFunction","workspaceHost","worker","editor","host.worker","host.frame","enableClient","host","editor","auth","createClient"]}
|