@squide/firefly-module-federation 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @squide/msw
2
+
3
+ ## Usage
4
+
5
+ View the [user's documentation](https://workleap.github.io/wl-squide/).
6
+
7
+ ## 🤝 Contributing
8
+
9
+ View the [contributor's documentation](../../CONTRIBUTING.md).
10
+
11
+ ## License
12
+
13
+ Copyright © 2024, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/workleap/workleap-license/blob/master/LICENSE.
@@ -0,0 +1,11 @@
1
+ import { Plugin, RegisterModulesOptions, type Runtime } from "@squide/core";
2
+ import { FireflyPlugin, FireflyRuntime } from "@squide/firefly";
3
+ import { HoneycombTrackingUnmanagedErrorHandler, type GetSpanFunction } from "@squide/firefly/internal";
4
+ import { RemoteDefinition } from "./RemoteDefinition.ts";
5
+ export declare const ModuleFederationPluginName = "module-federation-plugin";
6
+ export declare class ModuleFederationPlugin extends Plugin<FireflyRuntime> implements FireflyPlugin {
7
+ constructor(runtime: FireflyRuntime);
8
+ registerRemoteModules<TContext = unknown>(remotes: RemoteDefinition[], options?: RegisterModulesOptions<TContext>): Promise<import("@squide/core").ModuleRegistrationError[]>;
9
+ registerHoneycombTrackingListeners(getBootstrappingSpan: GetSpanFunction, getDeferredRegistrationsUpdateSpan: GetSpanFunction, onUnmanagedError: HoneycombTrackingUnmanagedErrorHandler): (error: unknown) => void;
10
+ }
11
+ export declare function getModuleFederationPlugin(runtime: Runtime): ModuleFederationPlugin;
@@ -0,0 +1,191 @@
1
+ import { loadRemote } from "@module-federation/enhanced/runtime";
2
+ import { Plugin, isNil } from "@squide/core";
3
+ import { addProtectedListener, endActiveSpan, getTracer, startActiveChildSpan, startChildSpan, traceError } from "@squide/firefly/internal";
4
+ import { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistry, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationStartedEvent } from "./RemoteModuleRegistry.js";
5
+
6
+ ;// CONCATENATED MODULE: external "@module-federation/enhanced/runtime"
7
+
8
+ ;// CONCATENATED MODULE: external "@squide/core"
9
+
10
+ ;// CONCATENATED MODULE: external "@squide/firefly/internal"
11
+
12
+ ;// CONCATENATED MODULE: external "./RemoteModuleRegistry.js"
13
+
14
+ ;// CONCATENATED MODULE: ./src/ModuleFederationPlugin.ts
15
+
16
+
17
+
18
+
19
+ const ModuleFederationPluginName = "module-federation-plugin";
20
+ class ModuleFederationPlugin extends Plugin {
21
+ constructor(runtime){
22
+ super(ModuleFederationPluginName, runtime);
23
+ this._runtime.moduleManager.addModuleRegistry(new RemoteModuleRegistry((remoteName, moduleName)=>loadRemote(`${remoteName}/${moduleName}`)));
24
+ }
25
+ registerRemoteModules(remotes, options) {
26
+ return this._runtime.moduleManager.registerModules(remotes.map((x)=>({
27
+ definition: x,
28
+ registryId: RemoteModuleRegistryId
29
+ })), options);
30
+ }
31
+ registerHoneycombTrackingListeners(getBootstrappingSpan, getDeferredRegistrationsUpdateSpan, onUnmanagedError) {
32
+ let remoteModuleRegistrationSpan;
33
+ let remoteModuleDeferredRegistrationSpan;
34
+ let remoteModuleDeferredRegistrationsUpdateSpan;
35
+ const handleUnmanagedError = (error)=>{
36
+ if (remoteModuleRegistrationSpan) {
37
+ remoteModuleRegistrationSpan.end();
38
+ }
39
+ if (remoteModuleDeferredRegistrationSpan) {
40
+ remoteModuleDeferredRegistrationSpan.end();
41
+ }
42
+ if (remoteModuleDeferredRegistrationsUpdateSpan) {
43
+ remoteModuleDeferredRegistrationsUpdateSpan.instance.end();
44
+ }
45
+ onUnmanagedError(error);
46
+ };
47
+ addProtectedListener(this._runtime, RemoteModulesRegistrationStartedEvent, (payload)=>{
48
+ const bootstrappingSpan = getBootstrappingSpan();
49
+ const attributes = {
50
+ "app.squide.remote_count": payload.remoteCount
51
+ };
52
+ if (bootstrappingSpan) {
53
+ bootstrappingSpan.addEvent("remote-module-registration-started", attributes);
54
+ }
55
+ remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context)=>{
56
+ return getTracer().startSpan("remote-module-registration", {
57
+ ...options,
58
+ attributes
59
+ }, context);
60
+ });
61
+ }, {
62
+ once: true,
63
+ onError: handleUnmanagedError
64
+ });
65
+ addProtectedListener(this._runtime, RemoteModulesRegistrationCompletedEvent, (payload)=>{
66
+ const bootstrappingSpan = getBootstrappingSpan();
67
+ if (bootstrappingSpan) {
68
+ bootstrappingSpan.addEvent("remote-module-registration-completed", {
69
+ "app.squide.remote_count": payload.remoteCount
70
+ });
71
+ }
72
+ if (remoteModuleRegistrationSpan) {
73
+ remoteModuleRegistrationSpan.end();
74
+ }
75
+ }, {
76
+ once: true,
77
+ onError: handleUnmanagedError
78
+ });
79
+ // Can occur multiple times.
80
+ addProtectedListener(this._runtime, RemoteModuleRegistrationFailedEvent, (payload)=>{
81
+ const registrationError = payload;
82
+ if (remoteModuleRegistrationSpan) {
83
+ traceError(remoteModuleRegistrationSpan, registrationError);
84
+ }
85
+ }, {
86
+ onError: handleUnmanagedError
87
+ });
88
+ addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload)=>{
89
+ const bootstrappingSpan = getBootstrappingSpan();
90
+ const attributes = {
91
+ "app.squide.registration_count": payload.registrationCount
92
+ };
93
+ if (bootstrappingSpan) {
94
+ bootstrappingSpan.addEvent("remote-module-deferred-registration-started", attributes);
95
+ }
96
+ remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context)=>{
97
+ return getTracer().startSpan("remote-module-deferred-registration", {
98
+ ...options,
99
+ attributes
100
+ }, context);
101
+ });
102
+ }, {
103
+ once: true,
104
+ onError: handleUnmanagedError
105
+ });
106
+ addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload)=>{
107
+ const bootstrappingSpan = getBootstrappingSpan();
108
+ if (bootstrappingSpan) {
109
+ bootstrappingSpan.addEvent("remote-module-deferred-registration-completed", {
110
+ "app.squide.registration_count": payload.registrationCount
111
+ });
112
+ }
113
+ if (remoteModuleDeferredRegistrationSpan) {
114
+ remoteModuleDeferredRegistrationSpan.end();
115
+ }
116
+ }, {
117
+ once: true,
118
+ onError: handleUnmanagedError
119
+ });
120
+ // Can occur multiple times.
121
+ addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload)=>{
122
+ const registrationError = payload;
123
+ if (remoteModuleDeferredRegistrationSpan) {
124
+ traceError(remoteModuleDeferredRegistrationSpan, registrationError);
125
+ }
126
+ }, {
127
+ onError: handleUnmanagedError
128
+ });
129
+ // Can occur multiple times.
130
+ addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload)=>{
131
+ const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();
132
+ const attributes = {
133
+ "app.squide.registration_count": payload.registrationCount
134
+ };
135
+ if (deferredRegistrationsUpdateSpan) {
136
+ deferredRegistrationsUpdateSpan.addEvent("remote-module-deferred-registrations-update-started", attributes);
137
+ }
138
+ remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context)=>{
139
+ const name = "remote-module-deferred-registrations-update";
140
+ const span = getTracer().startSpan(name, {
141
+ attributes,
142
+ ...options
143
+ }, context);
144
+ return {
145
+ name,
146
+ span
147
+ };
148
+ });
149
+ }, {
150
+ onError: handleUnmanagedError
151
+ });
152
+ // Can occur multiple times.
153
+ addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload)=>{
154
+ const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();
155
+ if (deferredRegistrationsUpdateSpan) {
156
+ deferredRegistrationsUpdateSpan.addEvent("remote-module-deferred-registrations-update-completed", {
157
+ "app.squide.registration_count": payload.registrationCount
158
+ });
159
+ }
160
+ if (remoteModuleDeferredRegistrationsUpdateSpan) {
161
+ endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);
162
+ }
163
+ }, {
164
+ onError: handleUnmanagedError
165
+ });
166
+ // Can occur multiple times.
167
+ addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload)=>{
168
+ const registrationError = payload;
169
+ if (remoteModuleDeferredRegistrationsUpdateSpan) {
170
+ traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);
171
+ }
172
+ }, {
173
+ onError: handleUnmanagedError
174
+ });
175
+ // Cleanup the spans if the root tracking is failing.
176
+ return (error)=>{
177
+ handleUnmanagedError(error);
178
+ };
179
+ }
180
+ }
181
+ function getModuleFederationPlugin(runtime) {
182
+ const plugin = runtime.getPlugin(ModuleFederationPluginName);
183
+ if (isNil(plugin)) {
184
+ throw new Error("[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime.");
185
+ }
186
+ return plugin;
187
+ }
188
+
189
+ export { ModuleFederationPlugin, ModuleFederationPluginName, getModuleFederationPlugin };
190
+
191
+ //# sourceMappingURL=ModuleFederationPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleFederationPlugin.js","sources":["../src/ModuleFederationPlugin.ts"],"sourcesContent":["import { loadRemote as loadModuleFederationRemote } from \"@module-federation/enhanced/runtime\";\nimport { Span } from \"@opentelemetry/api\";\nimport { isNil, Plugin, RegisterModulesOptions, type Runtime } from \"@squide/core\";\nimport { FireflyPlugin, FireflyRuntime } from \"@squide/firefly\";\nimport { ActiveSpan, addProtectedListener, endActiveSpan, getTracer, HoneycombTrackingUnmanagedErrorHandler, startActiveChildSpan, startChildSpan, traceError, type GetSpanFunction } from \"@squide/firefly/internal\";\nimport { RemoteDefinition } from \"./RemoteDefinition.ts\";\nimport { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationError, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistry, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationCompletedEventPayload, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationStartedEventPayload, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEventPayload, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationCompletedEventPayload, RemoteModulesRegistrationStartedEvent, RemoteModulesRegistrationStartedEventPayload } from \"./RemoteModuleRegistry.ts\";\n\nexport const ModuleFederationPluginName = \"module-federation-plugin\";\n\nexport class ModuleFederationPlugin extends Plugin<FireflyRuntime> implements FireflyPlugin {\n constructor(runtime: FireflyRuntime) {\n super(ModuleFederationPluginName, runtime);\n\n this._runtime.moduleManager.addModuleRegistry(new RemoteModuleRegistry((remoteName, moduleName) => loadModuleFederationRemote(`${remoteName}/${moduleName}`)));\n }\n\n registerRemoteModules<TContext = unknown>(remotes: RemoteDefinition[], options?: RegisterModulesOptions<TContext>) {\n return this._runtime.moduleManager.registerModules(remotes.map(x => ({\n definition: x,\n registryId: RemoteModuleRegistryId\n })), options);\n }\n\n registerHoneycombTrackingListeners(\n getBootstrappingSpan: GetSpanFunction,\n getDeferredRegistrationsUpdateSpan: GetSpanFunction,\n onUnmanagedError: HoneycombTrackingUnmanagedErrorHandler\n ) {\n let remoteModuleRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n\n const handleUnmanagedError = (error: unknown) => {\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n remoteModuleDeferredRegistrationsUpdateSpan.instance.end();\n }\n\n onUnmanagedError(error);\n };\n\n addProtectedListener(this._runtime, RemoteModulesRegistrationStartedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n const attributes = {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-started\", attributes);\n }\n\n remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-registration\", { ...options, attributes }, context);\n });\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-completed\", {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount\n });\n }\n\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleRegistrationSpan) {\n traceError(remoteModuleRegistrationSpan, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationSpan) {\n traceError(remoteModuleDeferredRegistrationSpan, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();\n\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"remote-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Cleanup the spans if the root tracking is failing.\n return (error: unknown) => {\n handleUnmanagedError(error);\n };\n }\n}\n\nexport function getModuleFederationPlugin(runtime: Runtime) {\n const plugin = runtime.getPlugin(ModuleFederationPluginName);\n\n if (isNil(plugin)) {\n throw new Error(\"[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime.\");\n }\n\n return plugin as ModuleFederationPlugin;\n}\n"],"names":["loadRemote","loadModuleFederationRemote","isNil","Plugin","addProtectedListener","endActiveSpan","getTracer","startActiveChildSpan","startChildSpan","traceError","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModuleRegistry","RemoteModuleRegistryId","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent","ModuleFederationPluginName","ModuleFederationPlugin","runtime","remoteName","moduleName","remotes","options","x","getBootstrappingSpan","getDeferredRegistrationsUpdateSpan","onUnmanagedError","remoteModuleRegistrationSpan","remoteModuleDeferredRegistrationSpan","remoteModuleDeferredRegistrationsUpdateSpan","handleUnmanagedError","error","payload","bootstrappingSpan","attributes","context","registrationError","deferredRegistrationsUpdateSpan","name","span","getModuleFederationPlugin","plugin","Error"],"mappings":";;;;;;;;;;;;;;AAA+F;AAEZ;AAEmI;AAE6oB;AAE51B,MAAMqB,6BAA6B,2BAA2B;AAE9D,MAAMC,+BAA+BnB,MAAMA;IAC9C,YAAYoB,OAAuB,CAAE;QACjC,KAAK,CAACF,4BAA4BE;QAElC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAIV,oBAAoBA,CAAC,CAACW,YAAYC,aAAexB,UAA0BA,CAAC,GAAGuB,WAAW,CAAC,EAAEC,YAAY;IAC/J;IAEA,sBAA0CC,OAA2B,EAAEC,OAA0C,EAAE;QAC/G,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,eAAe,CAACD,QAAQ,GAAG,CAACE,CAAAA,IAAM;gBACjE,YAAYA;gBACZ,YAAYd,sBAAsBA;YACtC,KAAKa;IACT;IAEA,mCACIE,oBAAqC,EACrCC,kCAAmD,EACnDC,gBAAwD,EAC1D;QACE,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QAEJ,MAAMC,uBAAuB,CAACC;YAC1B,IAAIJ,8BAA8B;gBAC9BA,6BAA6B,GAAG;YACpC;YAEA,IAAIC,sCAAsC;gBACtCA,qCAAqC,GAAG;YAC5C;YAEA,IAAIC,6CAA6C;gBAC7CA,4CAA4C,QAAQ,CAAC,GAAG;YAC5D;YAEAH,iBAAiBK;QACrB;QAEAhC,oBAAoBA,CAAC,IAAI,CAAC,QAAQ,EAAEgB,qCAAqCA,EAAE,CAACiB;YACxE,MAAMC,oBAAoBT;YAE1B,MAAMU,aAAa;gBACf,2BAA4BF,QAAyD,WAAW;YAC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b;QAEA,4BAA4B;QAC5B/B,oBAAoBA,CAAC,IAAI,CAAC,QAAQ,EAAEO,iDAAiDA,EAAE,CAAC0B;YACpF,MAAMI,oBAAoBJ;YAE1B,IAAIH,6CAA6C;gBAC7CzB,UAAUA,CAACyB,4CAA4C,QAAQ,EAAEO;YACrE;QACJ,GAAG;YACC,SAASN;QACb;QAEA,qDAAqD;QACrD,OAAO,CAACC;YACJD,qBAAqBC;QACzB;IACJ;AACJ;AAEO,SAASS,0BAA0BtB,OAAgB;IACtD,MAAMuB,SAASvB,QAAQ,SAAS,CAACF;IAEjC,IAAInB,KAAKA,CAAC4C,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
@@ -0,0 +1,3 @@
1
+ export interface RemoteDefinition extends Record<string, unknown> {
2
+ name: string;
3
+ }
@@ -0,0 +1,6 @@
1
+
2
+ ;// CONCATENATED MODULE: ./src/RemoteDefinition.ts
3
+
4
+
5
+
6
+ //# sourceMappingURL=RemoteDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteDefinition.js","sources":["../src/RemoteDefinition.ts"],"sourcesContent":["export interface RemoteDefinition extends Record<string, unknown> {\n // The name of the remote module.\n name: string;\n}\n\n"],"names":[],"mappings":";;AAGC"}
@@ -0,0 +1,53 @@
1
+ import { ModuleRegistrationError, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from "@squide/core";
2
+ import type { RemoteDefinition } from "./RemoteDefinition.ts";
3
+ export declare const RemoteModuleRegistryId = "remote";
4
+ export declare const RemoteModulesRegistrationStartedEvent = "squide-remote-modules-registration-started";
5
+ export declare const RemoteModulesRegistrationCompletedEvent = "squide-remote-modules-registration-completed";
6
+ export declare const RemoteModuleRegistrationFailedEvent = "squide-remote-module-registration-failed";
7
+ export declare const RemoteModulesDeferredRegistrationStartedEvent = "squide-remote-modules-deferred-registration-started";
8
+ export declare const RemoteModulesDeferredRegistrationCompletedEvent = "squide-remote-modules-deferred-registration-completed";
9
+ export declare const RemoteModuleDeferredRegistrationFailedEvent = "squide-some-remote-module-deferred-registration-failed";
10
+ export declare const RemoteModulesDeferredRegistrationsUpdateStartedEvent = "squide-remote-modules-deferred-registrations-update-started";
11
+ export declare const RemoteModulesDeferredRegistrationsUpdateCompletedEvent = "squide-remote-modules-deferred-registrations-update-completed-started";
12
+ export declare const RemoteModuleDeferredRegistrationUpdateFailedEvent = "squide-remote-module-deferred-registration-update-failed";
13
+ export interface RemoteModulesRegistrationStartedEventPayload {
14
+ remoteCount: number;
15
+ }
16
+ export interface RemoteModulesRegistrationCompletedEventPayload {
17
+ remoteCount: number;
18
+ }
19
+ export interface RemoteModulesDeferredRegistrationStartedEventPayload {
20
+ registrationCount: number;
21
+ }
22
+ export interface RemoteModulesDeferredRegistrationCompletedEventPayload {
23
+ registrationCount: number;
24
+ }
25
+ export interface RemoteModulesDeferredRegistrationsUpdateStartedEventPayload {
26
+ registrationCount: number;
27
+ }
28
+ export interface RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload {
29
+ registrationCount: number;
30
+ }
31
+ type LoadRemoteFunction = (remoteName: string, moduleName: string) => Promise<any>;
32
+ export declare class RemoteModuleRegistrationError extends ModuleRegistrationError {
33
+ #private;
34
+ constructor(message: string, remoteName: string, moduleName: string, options?: ErrorOptions);
35
+ get remoteName(): string;
36
+ get moduleName(): string;
37
+ }
38
+ export declare class RemoteModuleRegistry implements ModuleRegistry {
39
+ #private;
40
+ constructor(loadRemote: LoadRemoteFunction);
41
+ get id(): string;
42
+ registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(remotes: RemoteDefinition[], runtime: TRuntime, { context }?: RegisterModulesOptions<TContext>): Promise<RemoteModuleRegistrationError[]>;
43
+ registerDeferredRegistrations<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime): Promise<RemoteModuleRegistrationError[]>;
44
+ updateDeferredRegistrations<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime): Promise<RemoteModuleRegistrationError[]>;
45
+ registerStatusChangedListener(callback: ModuleRegistrationStatusChangedListener): void;
46
+ removeStatusChangedListener(callback: ModuleRegistrationStatusChangedListener): void;
47
+ get registrationStatus(): ModuleRegistrationStatus;
48
+ }
49
+ export declare function toRemoteModuleDefinitions(remotes: RemoteDefinition[]): {
50
+ definition: RemoteDefinition;
51
+ registryId: string;
52
+ }[];
53
+ export {};
@@ -0,0 +1,268 @@
1
+ import { ModuleRegistrationError, isFunction, isNil, registerModule } from "@squide/core";
2
+ // The require scope
3
+ var __webpack_require__ = {};
4
+
5
+ // webpack/runtime/has_own_property
6
+ (() => {
7
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
8
+ })();
9
+
10
+ ;// CONCATENATED MODULE: external "@squide/core"
11
+
12
+ ;// CONCATENATED MODULE: ./src/RemoteModuleRegistry.ts
13
+
14
+ const RemoteModuleRegistryId = "remote";
15
+ const RemoteModulesRegistrationStartedEvent = "squide-remote-modules-registration-started";
16
+ const RemoteModulesRegistrationCompletedEvent = "squide-remote-modules-registration-completed";
17
+ const RemoteModuleRegistrationFailedEvent = "squide-remote-module-registration-failed";
18
+ const RemoteModulesDeferredRegistrationStartedEvent = "squide-remote-modules-deferred-registration-started";
19
+ const RemoteModulesDeferredRegistrationCompletedEvent = "squide-remote-modules-deferred-registration-completed";
20
+ const RemoteModuleDeferredRegistrationFailedEvent = "squide-some-remote-module-deferred-registration-failed";
21
+ const RemoteModulesDeferredRegistrationsUpdateStartedEvent = "squide-remote-modules-deferred-registrations-update-started";
22
+ const RemoteModulesDeferredRegistrationsUpdateCompletedEvent = "squide-remote-modules-deferred-registrations-update-completed-started";
23
+ const RemoteModuleDeferredRegistrationUpdateFailedEvent = "squide-remote-module-deferred-registration-update-failed";
24
+ const RemoteRegisterModuleName = "register";
25
+ class RemoteModuleRegistrationError extends ModuleRegistrationError {
26
+ #remoteName;
27
+ #moduleName;
28
+ constructor(message, remoteName, moduleName, options){
29
+ super(message, options);
30
+ this.#remoteName = remoteName;
31
+ this.#moduleName = moduleName;
32
+ }
33
+ get remoteName() {
34
+ return this.#remoteName;
35
+ }
36
+ get moduleName() {
37
+ return this.#moduleName;
38
+ }
39
+ }
40
+ class RemoteModuleRegistry {
41
+ #registrationStatus = "none";
42
+ #deferredRegistrations = [];
43
+ #loadRemote;
44
+ #statusChangedListeners = new Set();
45
+ constructor(loadRemote){
46
+ this.#loadRemote = loadRemote;
47
+ }
48
+ get id() {
49
+ return RemoteModuleRegistryId;
50
+ }
51
+ #logSharedScope(logger) {
52
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
53
+ // @ts-ignore
54
+ if (__webpack_require__.S) {
55
+ logger.debug("[squide] Module Federation shared scope is available:", // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
+ // @ts-ignore
57
+ __webpack_require__.S.default);
58
+ }
59
+ }
60
+ async registerModules(remotes, runtime, { context } = {}) {
61
+ const errors = [];
62
+ if (this.#registrationStatus !== "none") {
63
+ throw new Error("[squide] The registerRemoteModules function can only be called once.");
64
+ }
65
+ if (remotes.length > 0) {
66
+ runtime.logger.information(`[squide] Found ${remotes.length} remote module${remotes.length !== 1 ? "s" : ""} to register.`);
67
+ this.#setRegistrationStatus("registering-modules");
68
+ runtime.eventBus.dispatch(RemoteModulesRegistrationStartedEvent, {
69
+ remoteCount: remotes.length
70
+ });
71
+ let completedCount = 0;
72
+ await Promise.allSettled(remotes.map(async (x, index)=>{
73
+ const remoteName = x.name;
74
+ const loggerScope = runtime.logger.startScope(`[squide] ${index + 1}/${remotes.length} Loading module "${RemoteRegisterModuleName}" of remote "${remoteName}".`);
75
+ const runtimeScope = runtime.startScope(loggerScope);
76
+ try {
77
+ const module = await this.#loadRemote(remoteName, RemoteRegisterModuleName);
78
+ if (isNil(module.register)) {
79
+ throw new Error(`[squide] A "register" function is not available for module "${RemoteRegisterModuleName}" of remote "${remoteName}". Make sure your remote "./register.[js,jsx,ts.tsx]" file export a function named "register".`);
80
+ }
81
+ loggerScope.debug("[squide] Registering module...");
82
+ const optionalDeferredRegistration = await registerModule(module.register, runtimeScope, context);
83
+ if (isFunction(optionalDeferredRegistration)) {
84
+ this.#deferredRegistrations.push({
85
+ remoteName: x.name,
86
+ index: `${index + 1}/${remotes.length}`,
87
+ fct: optionalDeferredRegistration
88
+ });
89
+ }
90
+ completedCount += 1;
91
+ loggerScope.information("[squide] Successfully registered remote module.", {
92
+ style: {
93
+ color: "green"
94
+ }
95
+ });
96
+ loggerScope.end({
97
+ labelStyle: {
98
+ color: "green"
99
+ }
100
+ });
101
+ } catch (error) {
102
+ loggerScope.withText("[squide] An error occured while registering the remote module.").withError(error).error();
103
+ loggerScope.end({
104
+ labelStyle: {
105
+ color: "red"
106
+ }
107
+ });
108
+ errors.push(new RemoteModuleRegistrationError(`An error occured while registering module "${RemoteRegisterModuleName}" of remote "${remoteName}".`, remoteName, RemoteRegisterModuleName, {
109
+ cause: error
110
+ }));
111
+ }
112
+ }));
113
+ if (errors.length > 0) {
114
+ errors.forEach((x)=>{
115
+ runtime.eventBus.dispatch(RemoteModuleRegistrationFailedEvent, x);
116
+ });
117
+ }
118
+ // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.
119
+ runtime.eventBus.dispatch(RemoteModulesRegistrationCompletedEvent, {
120
+ remoteCount: completedCount
121
+ });
122
+ this.#setRegistrationStatus(this.#deferredRegistrations.length > 0 ? "modules-registered" : "ready");
123
+ // After introducting the "setRegistrationStatus" method, TypeScript seems to think that the only possible
124
+ // values for registrationStatus is "none" and now complains about the lack of overlapping between "none" and "ready".
125
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
126
+ // @ts-ignore
127
+ if (this.#registrationStatus === "ready") {
128
+ this.#logSharedScope(runtime.logger);
129
+ }
130
+ } else {
131
+ // There's no modules to register, it can be considered as ready.
132
+ this.#setRegistrationStatus("ready");
133
+ }
134
+ return errors;
135
+ }
136
+ async registerDeferredRegistrations(data, runtime) {
137
+ const errors = [];
138
+ if (this.#registrationStatus === "ready" && this.#deferredRegistrations.length === 0) {
139
+ // No deferred registrations were returned by the remote modules, skip this phase.
140
+ return errors;
141
+ }
142
+ if (this.#registrationStatus === "none" || this.#registrationStatus === "registering-modules") {
143
+ throw new Error("[squide] The registerDeferredRegistrations function can only be called once the remote modules are registered.");
144
+ }
145
+ if (this.#registrationStatus !== "modules-registered") {
146
+ throw new Error("[squide] The registerDeferredRegistrations function can only be called once.");
147
+ }
148
+ this.#setRegistrationStatus("registering-deferred-registration");
149
+ runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationStartedEvent, {
150
+ registrationCount: this.#deferredRegistrations.length
151
+ });
152
+ let completedCount = 0;
153
+ await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister })=>{
154
+ const loggerScope = runtime.logger.startScope(`[squide] ${index} Registering the deferred registrations for module "${RemoteRegisterModuleName}" of remote "${remoteName}".`);
155
+ const runtimeScope = runtime.startScope(loggerScope);
156
+ loggerScope.withText("Data:").withObject(data).debug();
157
+ try {
158
+ await deferredRegister(runtimeScope, data, "register");
159
+ completedCount += 1;
160
+ } catch (error) {
161
+ loggerScope.withText("[squide] An error occured while registering the deferred registrations.").withError(error).error();
162
+ loggerScope.end({
163
+ labelStyle: {
164
+ color: "red"
165
+ }
166
+ });
167
+ errors.push(new RemoteModuleRegistrationError(`An error occured while registering the deferred registrations for module "${RemoteRegisterModuleName}" of remote "${remoteName}".`, remoteName, RemoteRegisterModuleName, {
168
+ cause: error
169
+ }));
170
+ }
171
+ loggerScope.information("[squide] Successfully registered deferred registrations.", {
172
+ style: {
173
+ color: "green"
174
+ }
175
+ });
176
+ loggerScope.end({
177
+ labelStyle: {
178
+ color: "green"
179
+ }
180
+ });
181
+ }));
182
+ if (errors.length > 0) {
183
+ errors.forEach((x)=>{
184
+ runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationFailedEvent, x);
185
+ });
186
+ }
187
+ // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.
188
+ runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationCompletedEvent, {
189
+ registrationCount: completedCount
190
+ });
191
+ this.#setRegistrationStatus("ready");
192
+ this.#logSharedScope(runtime.logger);
193
+ return errors;
194
+ }
195
+ async updateDeferredRegistrations(data, runtime) {
196
+ const errors = [];
197
+ if (this.#registrationStatus !== "ready") {
198
+ throw new Error("[squide] The updateDeferredRegistrations function can only be called once the remote modules are ready.");
199
+ }
200
+ runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateStartedEvent, {
201
+ registrationCount: this.#deferredRegistrations.length
202
+ });
203
+ let completedCount = 0;
204
+ await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister })=>{
205
+ const loggerScope = runtime.logger.startScope(`[squide] ${index} Updating the deferred registrations for module "${RemoteRegisterModuleName}" of remote "${remoteName}".`);
206
+ const runtimeScope = runtime.startScope(loggerScope);
207
+ loggerScope.withText("Data:").withObject(data).debug();
208
+ try {
209
+ await deferredRegister(runtimeScope, data, "update");
210
+ completedCount += 1;
211
+ } catch (error) {
212
+ loggerScope.withText("[squide] An error occured while updating the deferred registrations.").withError(error).error();
213
+ loggerScope.end({
214
+ labelStyle: {
215
+ color: "red"
216
+ }
217
+ });
218
+ errors.push(new RemoteModuleRegistrationError(`An error occured while updating the deferred registrations for module "${RemoteRegisterModuleName}" of remote "${remoteName}".`, remoteName, RemoteRegisterModuleName, {
219
+ cause: error
220
+ }));
221
+ }
222
+ loggerScope.information("[squide] Successfully updated the deferred registrations.", {
223
+ style: {
224
+ color: "green"
225
+ }
226
+ });
227
+ loggerScope.end({
228
+ labelStyle: {
229
+ color: "green"
230
+ }
231
+ });
232
+ }));
233
+ if (errors.length > 0) {
234
+ errors.forEach((x)=>{
235
+ runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationUpdateFailedEvent, x);
236
+ });
237
+ }
238
+ runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, {
239
+ registrationCount: completedCount
240
+ });
241
+ return errors;
242
+ }
243
+ registerStatusChangedListener(callback) {
244
+ this.#statusChangedListeners.add(callback);
245
+ }
246
+ removeStatusChangedListener(callback) {
247
+ this.#statusChangedListeners.delete(callback);
248
+ }
249
+ #setRegistrationStatus(status) {
250
+ this.#registrationStatus = status;
251
+ this.#statusChangedListeners.forEach((x)=>{
252
+ x();
253
+ });
254
+ }
255
+ get registrationStatus() {
256
+ return this.#registrationStatus;
257
+ }
258
+ }
259
+ function toRemoteModuleDefinitions(remotes) {
260
+ return remotes.map((x)=>({
261
+ definition: x,
262
+ registryId: RemoteModuleRegistryId
263
+ }));
264
+ }
265
+
266
+ export { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationError, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistry, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationStartedEvent, toRemoteModuleDefinitions };
267
+
268
+ //# sourceMappingURL=RemoteModuleRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteModuleRegistry.js","sources":["webpack/runtime/has_own_property","../src/RemoteModuleRegistry.ts"],"sourcesContent":["__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { isFunction, isNil, ModuleRegistrationError, registerModule, type DeferredRegistrationFunction, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from \"@squide/core\";\nimport type { Logger, RootLogger } from \"@workleap/logging\";\nimport type { RemoteDefinition } from \"./RemoteDefinition.ts\";\n\nexport const RemoteModuleRegistryId = \"remote\";\n\nexport const RemoteModulesRegistrationStartedEvent = \"squide-remote-modules-registration-started\";\nexport const RemoteModulesRegistrationCompletedEvent = \"squide-remote-modules-registration-completed\";\nexport const RemoteModuleRegistrationFailedEvent = \"squide-remote-module-registration-failed\";\n\nexport const RemoteModulesDeferredRegistrationStartedEvent = \"squide-remote-modules-deferred-registration-started\";\nexport const RemoteModulesDeferredRegistrationCompletedEvent = \"squide-remote-modules-deferred-registration-completed\";\nexport const RemoteModuleDeferredRegistrationFailedEvent = \"squide-some-remote-module-deferred-registration-failed\";\n\nexport const RemoteModulesDeferredRegistrationsUpdateStartedEvent = \"squide-remote-modules-deferred-registrations-update-started\";\nexport const RemoteModulesDeferredRegistrationsUpdateCompletedEvent = \"squide-remote-modules-deferred-registrations-update-completed-started\";\nexport const RemoteModuleDeferredRegistrationUpdateFailedEvent = \"squide-remote-module-deferred-registration-update-failed\";\n\nexport interface RemoteModulesRegistrationStartedEventPayload {\n remoteCount: number;\n}\n\nexport interface RemoteModulesRegistrationCompletedEventPayload {\n remoteCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationStartedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationCompletedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationsUpdateStartedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload {\n registrationCount: number;\n}\n\nconst RemoteRegisterModuleName = \"register\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LoadRemoteFunction = (remoteName: string, moduleName: string) => Promise<any>;\n\ninterface DeferredRegistration<TRuntime extends Runtime = Runtime, TData = unknown> {\n remoteName: string;\n index: string;\n fct: DeferredRegistrationFunction<TRuntime, TData>;\n}\n\nexport class RemoteModuleRegistrationError extends ModuleRegistrationError {\n readonly #remoteName: string;\n readonly #moduleName: string;\n\n constructor(message: string, remoteName: string, moduleName: string, options?: ErrorOptions) {\n super(message, options);\n\n this.#remoteName = remoteName;\n this.#moduleName = moduleName;\n }\n\n get remoteName() {\n return this.#remoteName;\n }\n\n get moduleName() {\n return this.#moduleName;\n }\n}\n\nexport class RemoteModuleRegistry implements ModuleRegistry {\n #registrationStatus: ModuleRegistrationStatus = \"none\";\n\n readonly #deferredRegistrations: DeferredRegistration[] = [];\n readonly #loadRemote: LoadRemoteFunction;\n readonly #statusChangedListeners = new Set<ModuleRegistrationStatusChangedListener>();\n\n constructor(loadRemote: LoadRemoteFunction) {\n this.#loadRemote = loadRemote;\n }\n\n get id() {\n return RemoteModuleRegistryId;\n }\n\n #logSharedScope(logger: Logger) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (__webpack_share_scopes__) {\n logger.debug(\n \"[squide] Module Federation shared scope is available:\",\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n __webpack_share_scopes__.default\n );\n }\n }\n\n async registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(remotes: RemoteDefinition[], runtime: TRuntime, { context }: RegisterModulesOptions<TContext> = {}) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus !== \"none\") {\n throw new Error(\"[squide] The registerRemoteModules function can only be called once.\");\n }\n\n if (remotes.length > 0) {\n runtime.logger.information(`[squide] Found ${remotes.length} remote module${remotes.length !== 1 ? \"s\" : \"\"} to register.`);\n\n this.#setRegistrationStatus(\"registering-modules\");\n\n runtime.eventBus.dispatch(RemoteModulesRegistrationStartedEvent, {\n remoteCount: remotes.length\n } satisfies RemoteModulesRegistrationStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(remotes.map(async (x, index) => {\n const remoteName = x.name;\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index + 1}/${remotes.length} Loading module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n try {\n const module = await this.#loadRemote(remoteName, RemoteRegisterModuleName);\n\n if (isNil(module.register)) {\n throw new Error(`[squide] A \"register\" function is not available for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\". Make sure your remote \"./register.[js,jsx,ts.tsx]\" file export a function named \"register\".`);\n }\n\n loggerScope.debug(\"[squide] Registering module...\");\n\n const optionalDeferredRegistration = await registerModule<TRuntime, TContext, TData>(module.register, runtimeScope as TRuntime, context);\n\n if (isFunction(optionalDeferredRegistration)) {\n this.#deferredRegistrations.push({\n remoteName: x.name,\n index: `${index + 1}/${remotes.length}`,\n fct: optionalDeferredRegistration as DeferredRegistrationFunction\n });\n }\n\n completedCount += 1;\n\n loggerScope.information(\"[squide] Successfully registered remote module.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while registering the remote module.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while registering module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleRegistrationFailedEvent, x);\n });\n }\n\n // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.\n runtime.eventBus.dispatch(RemoteModulesRegistrationCompletedEvent, {\n remoteCount: completedCount\n } satisfies RemoteModulesRegistrationCompletedEventPayload);\n\n this.#setRegistrationStatus(this.#deferredRegistrations.length > 0 ? \"modules-registered\" : \"ready\");\n\n // After introducting the \"setRegistrationStatus\" method, TypeScript seems to think that the only possible\n // values for registrationStatus is \"none\" and now complains about the lack of overlapping between \"none\" and \"ready\".\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (this.#registrationStatus === \"ready\") {\n this.#logSharedScope(runtime.logger);\n }\n } else {\n // There's no modules to register, it can be considered as ready.\n this.#setRegistrationStatus(\"ready\");\n }\n\n return errors;\n }\n\n async registerDeferredRegistrations<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus === \"ready\" && this.#deferredRegistrations.length === 0) {\n // No deferred registrations were returned by the remote modules, skip this phase.\n return errors;\n }\n\n if (this.#registrationStatus === \"none\" || this.#registrationStatus === \"registering-modules\") {\n throw new Error(\"[squide] The registerDeferredRegistrations function can only be called once the remote modules are registered.\");\n }\n\n if (this.#registrationStatus !== \"modules-registered\") {\n throw new Error(\"[squide] The registerDeferredRegistrations function can only be called once.\");\n }\n\n this.#setRegistrationStatus(\"registering-deferred-registration\");\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationStartedEvent, {\n registrationCount: this.#deferredRegistrations.length\n } satisfies RemoteModulesDeferredRegistrationStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister }) => {\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index} Registering the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n loggerScope\n .withText(\"Data:\")\n .withObject(data)\n .debug();\n\n try {\n await deferredRegister(runtimeScope, data, \"register\");\n\n completedCount += 1;\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while registering the deferred registrations.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while registering the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n\n loggerScope.information(\"[squide] Successfully registered deferred registrations.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationFailedEvent, x);\n });\n }\n\n // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationCompletedEvent, {\n registrationCount: completedCount\n } satisfies RemoteModulesDeferredRegistrationCompletedEventPayload);\n\n this.#setRegistrationStatus(\"ready\");\n this.#logSharedScope(runtime.logger);\n\n return errors;\n }\n\n async updateDeferredRegistrations<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus !== \"ready\") {\n throw new Error(\"[squide] The updateDeferredRegistrations function can only be called once the remote modules are ready.\");\n }\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateStartedEvent, {\n registrationCount: this.#deferredRegistrations.length\n } satisfies RemoteModulesDeferredRegistrationsUpdateStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister }) => {\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index} Updating the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n loggerScope\n .withText(\"Data:\")\n .withObject(data)\n .debug();\n\n try {\n await deferredRegister(runtimeScope, data, \"update\");\n\n completedCount += 1;\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while updating the deferred registrations.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while updating the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n\n loggerScope.information(\"[squide] Successfully updated the deferred registrations.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationUpdateFailedEvent, x);\n });\n }\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, {\n registrationCount: completedCount\n } satisfies RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload);\n\n return errors;\n }\n\n registerStatusChangedListener(callback: ModuleRegistrationStatusChangedListener) {\n this.#statusChangedListeners.add(callback);\n }\n\n removeStatusChangedListener(callback: ModuleRegistrationStatusChangedListener) {\n this.#statusChangedListeners.delete(callback);\n }\n\n #setRegistrationStatus(status: ModuleRegistrationStatus) {\n this.#registrationStatus = status;\n\n this.#statusChangedListeners.forEach(x => {\n x();\n });\n }\n\n get registrationStatus() {\n return this.#registrationStatus;\n }\n}\n\nexport function toRemoteModuleDefinitions(remotes: RemoteDefinition[]) {\n return remotes.map(x => ({\n definition: x,\n registryId: RemoteModuleRegistryId\n }));\n}\n"],"names":["isFunction","isNil","ModuleRegistrationError","registerModule","RemoteModuleRegistryId","RemoteModulesRegistrationStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModuleRegistrationFailedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModuleDeferredRegistrationFailedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteRegisterModuleName","RemoteModuleRegistrationError","message","remoteName","moduleName","options","RemoteModuleRegistry","Set","loadRemote","logger","__webpack_share_scopes__","remotes","runtime","context","errors","Error","completedCount","Promise","x","index","loggerScope","runtimeScope","module","optionalDeferredRegistration","error","data","deferredRegister","callback","status","toRemoteModuleDefinitions"],"mappings":";;;;;;AAAA,wF;;;;;;ACA0Q;AAInQ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