@squide/firefly 16.1.2 → 16.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 16.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#365](https://github.com/workleap/wl-squide/pull/365) [`992dd28`](https://github.com/workleap/wl-squide/commit/992dd28ce8aa03559c556f24df4ebc9c3129c943) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Added memoize to the plugin retrieval code.
8
+
9
+ - Updated dependencies [[`992dd28`](https://github.com/workleap/wl-squide/commit/992dd28ce8aa03559c556f24df4ebc9c3129c943)]:
10
+ - @squide/core@6.1.9
11
+ - @squide/env-vars@1.4.12
12
+ - @squide/launch-darkly@1.0.3
13
+ - @squide/msw@4.0.10
14
+ - @squide/react-router@8.1.9
15
+
16
+ ## 16.1.3
17
+
18
+ ### Patch Changes
19
+
20
+ - [#363](https://github.com/workleap/wl-squide/pull/363) [`b114284`](https://github.com/workleap/wl-squide/commit/b114284529ff87e719d594d9612a52b1935a0bb2) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Added a log when the application is initialized with the provided arguments.
21
+
3
22
  ## 16.1.2
4
23
 
5
24
  ### Patch Changes
@@ -44,8 +44,7 @@ class FireflyRuntime extends ReactRouterRuntime {
44
44
  return this.#isMswEnabled;
45
45
  }
46
46
  get mswState() {
47
- const plugin = getMswPlugin(this);
48
- return plugin.mswState;
47
+ return getMswPlugin(this).mswState;
49
48
  }
50
49
  registerRequestHandlers(handlers, options = {}) {
51
50
  const logger = this._getLogger(options);
@@ -59,24 +58,19 @@ class FireflyRuntime extends ReactRouterRuntime {
59
58
  }
60
59
  // Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
61
60
  get requestHandlers() {
62
- const plugin = getMswPlugin(this);
63
- return plugin.requestHandlers;
61
+ return getMswPlugin(this).requestHandlers;
64
62
  }
65
63
  getEnvironmentVariable(key) {
66
- const plugin = getEnvironmentVariablesPlugin(this);
67
- return plugin.getVariable(key);
64
+ return getEnvironmentVariablesPlugin(this).getVariable(key);
68
65
  }
69
66
  get environmentVariables() {
70
- const plugin = getEnvironmentVariablesPlugin(this);
71
- return plugin.getVariables();
67
+ return getEnvironmentVariablesPlugin(this).getVariables();
72
68
  }
73
69
  registerEnvironmentVariable(key, value) {
74
- const plugin = getEnvironmentVariablesPlugin(this);
75
- return plugin.registerVariable(key, value);
70
+ return getEnvironmentVariablesPlugin(this).registerVariable(key, value);
76
71
  }
77
72
  registerEnvironmentVariables(variables) {
78
- const plugin = getEnvironmentVariablesPlugin(this);
79
- return plugin.registerVariables(variables);
73
+ return getEnvironmentVariablesPlugin(this).registerVariables(variables);
80
74
  }
81
75
  get appRouterStore() {
82
76
  return this.#appRouterStore;
@@ -1 +1 @@
1
- {"version":3,"file":"FireflyRuntime.js","sources":["../src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from \"@squide/core\";\nimport { EnvironmentVariableKey, EnvironmentVariables, getEnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { FeatureFlagKey, FeatureFlags, FeatureFlagSetSnapshot, getLaunchDarklyPlugin, LaunchDarklyPluginName } from \"@squide/launch-darkly\";\nimport { getMswPlugin, MswPluginName, MswState } from \"@squide/msw\";\nimport { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from \"@squide/react-router\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport type { RequestHandler } from \"msw\";\nimport { type AppRouterStore, createAppRouterStore } from \"./AppRouterStore.ts\";\n\nexport interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = FireflyRuntime> extends RuntimeOptions<TRuntime> {\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n}\n\nexport interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {}\n\nexport interface IFireflyRuntime extends IReactRouterRuntime {\n get isMswEnabled(): boolean;\n get mswState(): MswState;\n registerRequestHandlers: (handlers: RequestHandler[]) => void;\n get requestHandlers(): RequestHandler[];\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]): void;\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;\n getEnvironmentVariable<T extends EnvironmentVariableKey>(key: T): EnvironmentVariables[T];\n get environmentVariables(): EnvironmentVariables;\n get appRouterStore(): AppRouterStore;\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;\n get isLaunchDarklyEnabled(): boolean;\n get launchDarklyClient(): LDClient;\n get featureFlags(): FeatureFlags;\n getFeatureFlag(key: string, defaultValue?: unknown): unknown;\n get featureFlagSetSnapshot(): FeatureFlagSetSnapshot;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {\n readonly #appRouterStore: AppRouterStore;\n readonly #honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;\n readonly #isMswEnabled: boolean;\n readonly #isLaunchDarklyEnabled: boolean;\n\n constructor(options: FireflyRuntimeOptions = {}) {\n const {\n honeycombInstrumentationClient\n } = options;\n\n super(options);\n\n this.#appRouterStore = createAppRouterStore(this._logger);\n this.#honeycombInstrumentationClient = honeycombInstrumentationClient;\n this.#isMswEnabled = this._plugins.some(x => x.name === MswPluginName);\n this.#isLaunchDarklyEnabled = this._plugins.some(x => x.name === LaunchDarklyPluginName);\n }\n\n registerRoute(route: Route, options: RegisterRouteOptions = {}) {\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n super.registerRoute(route, options);\n }\n\n get isMswEnabled() {\n return this.#isMswEnabled;\n }\n\n get mswState() {\n const plugin = getMswPlugin(this);\n\n return plugin.mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n const logger = this._getLogger(options);\n const plugin = getMswPlugin(this);\n\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n plugin.registerRequestHandlers(handlers, {\n logger\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n const plugin = getMswPlugin(this);\n\n return plugin.requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n const plugin = getEnvironmentVariablesPlugin(this);\n\n return plugin.getVariable(key);\n }\n\n get environmentVariables() {\n const plugin = getEnvironmentVariablesPlugin(this);\n\n return plugin.getVariables();\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n const plugin = getEnvironmentVariablesPlugin(this);\n\n return plugin.registerVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n const plugin = getEnvironmentVariablesPlugin(this);\n\n return plugin.registerVariables(variables);\n }\n\n get appRouterStore() {\n return this.#appRouterStore;\n }\n\n get honeycombInstrumentationClient() {\n return this.#honeycombInstrumentationClient;\n }\n\n get isLaunchDarklyEnabled() {\n return this.#isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return getLaunchDarklyPlugin(this).client;\n }\n\n get featureFlags() {\n return this.featureFlagSetSnapshot.value;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n return getLaunchDarklyPlugin(this).getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return getLaunchDarklyPlugin(this).featureFlagSetSnapshot;\n }\n\n startScope(logger: Logger): TRuntime {\n return (new FireflyRuntimeScope(this, logger) as unknown) as TRuntime;\n }\n}\n\nexport class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {\n get isMswEnabled() {\n return this._runtime.isMswEnabled;\n }\n\n get mswState() {\n return this._runtime.mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n this._runtime.registerRequestHandlers(handlers, {\n ...options,\n logger: this._getLogger(options)\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return this._runtime.requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return this._runtime.getEnvironmentVariable(key);\n }\n\n get environmentVariables() {\n return this._runtime.environmentVariables;\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n this._runtime.registerEnvironmentVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n this._runtime.registerEnvironmentVariables(variables);\n }\n\n get appRouterStore(): AppRouterStore {\n throw new Error(\"[squide] Cannot retrieve the app router store from a runtime scope instance.\");\n }\n\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient {\n throw new Error(\"[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.\");\n }\n\n get isLaunchDarklyEnabled() {\n return this._runtime.isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return this._runtime.launchDarklyClient;\n }\n\n get featureFlags() {\n return this._runtime.featureFlags;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n // The error is because the FeatureFlags interface is empty as it is expected to be augmented by the\n // consumer application.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return this._runtime.getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return this._runtime.featureFlagSetSnapshot;\n }\n}\n"],"names":["getEnvironmentVariablesPlugin","getLaunchDarklyPlugin","LaunchDarklyPluginName","getMswPlugin","MswPluginName","ReactRouterRuntime","ReactRouterRuntimeScope","createAppRouterStore","FireflyRuntime","options","honeycombInstrumentationClient","x","route","Error","plugin","handlers","logger","key","value","variables","defaultValue","FireflyRuntimeScope"],"mappings":";;;;;;;;;;;;;;;;;AAC+G;AAC6B;AACxE;AACqD;AAKzC;AA0BhF,8DAA8D;AACvD,MAAMQ,uBAA8DH,kBAAkBA;IAChF,eAAe,CAAiB;IAChC,+BAA+B,CAAoD;IACnF,aAAa,CAAU;IACvB,sBAAsB,CAAU;IAEzC,YAAYI,UAAiC,CAAC,CAAC,CAAE;QAC7C,MAAM,EACFC,8BAA8B,EACjC,GAAGD;QAEJ,KAAK,CAACA;QAEN,IAAI,CAAC,eAAe,GAAGF,oBAAoBA,CAAC,IAAI,CAAC,OAAO;QACxD,IAAI,CAAC,+BAA+B,GAAGG;QACvC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACC,CAAAA,IAAKA,EAAE,IAAI,KAAKP,aAAaA;QACrE,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACO,CAAAA,IAAKA,EAAE,IAAI,KAAKT,sBAAsBA;IAC3F;IAEA,cAAcU,KAAY,EAAEH,UAAgC,CAAC,CAAC,EAAE;QAC5D,IAAI,IAAI,CAAC,aAAa,CAAC,uBAAuB,IAAI;YAC9C,MAAM,IAAII,MAAM;QACpB;QAEA,KAAK,CAAC,cAAcD,OAAOH;IAC/B;IAEA,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,IAAI,WAAW;QACX,MAAMK,SAASX,YAAYA,CAAC,IAAI;QAEhC,OAAOW,OAAO,QAAQ;I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AI,eAAe;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY;IACrC;IAEA,eAAyCI,GAAM,EAAEG,YAA8B,EAAE;QAC7E,oGAAoG;QACpG,wBAAwB;QACxB,6DAA6D;QAC7D,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAACH,KAAKG;IAC7C;IAEA,IAAI,yBAAyB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB;IAC/C;AACJ"}
1
+ {"version":3,"file":"FireflyRuntime.js","sources":["../src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from \"@squide/core\";\nimport { EnvironmentVariableKey, EnvironmentVariables, getEnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { FeatureFlagKey, FeatureFlags, FeatureFlagSetSnapshot, getLaunchDarklyPlugin, LaunchDarklyPluginName } from \"@squide/launch-darkly\";\nimport { getMswPlugin, MswPluginName, MswState } from \"@squide/msw\";\nimport { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from \"@squide/react-router\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport type { RequestHandler } from \"msw\";\nimport { type AppRouterStore, createAppRouterStore } from \"./AppRouterStore.ts\";\n\nexport interface FireflyRuntimeOptions<TRuntime extends FireflyRuntime = FireflyRuntime> extends RuntimeOptions<TRuntime> {\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n}\n\nexport interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {}\n\nexport interface IFireflyRuntime extends IReactRouterRuntime {\n get isMswEnabled(): boolean;\n get mswState(): MswState;\n registerRequestHandlers: (handlers: RequestHandler[]) => void;\n get requestHandlers(): RequestHandler[];\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]): void;\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;\n getEnvironmentVariable<T extends EnvironmentVariableKey>(key: T): EnvironmentVariables[T];\n get environmentVariables(): EnvironmentVariables;\n get appRouterStore(): AppRouterStore;\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;\n get isLaunchDarklyEnabled(): boolean;\n get launchDarklyClient(): LDClient;\n get featureFlags(): FeatureFlags;\n getFeatureFlag(key: string, defaultValue?: unknown): unknown;\n get featureFlagSetSnapshot(): FeatureFlagSetSnapshot;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {\n readonly #appRouterStore: AppRouterStore;\n readonly #honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;\n readonly #isMswEnabled: boolean;\n readonly #isLaunchDarklyEnabled: boolean;\n\n constructor(options: FireflyRuntimeOptions = {}) {\n const {\n honeycombInstrumentationClient\n } = options;\n\n super(options);\n\n this.#appRouterStore = createAppRouterStore(this._logger);\n this.#honeycombInstrumentationClient = honeycombInstrumentationClient;\n this.#isMswEnabled = this._plugins.some(x => x.name === MswPluginName);\n this.#isLaunchDarklyEnabled = this._plugins.some(x => x.name === LaunchDarklyPluginName);\n }\n\n registerRoute(route: Route, options: RegisterRouteOptions = {}) {\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register a route once the modules are registered. Are you trying to register a route in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n super.registerRoute(route, options);\n }\n\n get isMswEnabled() {\n return this.#isMswEnabled;\n }\n\n get mswState() {\n return getMswPlugin(this).mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n const logger = this._getLogger(options);\n const plugin = getMswPlugin(this);\n\n if (this.moduleManager.getAreModulesRegistered()) {\n throw new Error(\"[squide] Cannot register an MSW request handlers once the modules are registered. Are you trying to register an MSW request handler in a deferred registration function? Only navigation items can be registered in a deferred registration function.\");\n }\n\n plugin.registerRequestHandlers(handlers, {\n logger\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return getMswPlugin(this).requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return getEnvironmentVariablesPlugin(this).getVariable(key);\n }\n\n get environmentVariables() {\n return getEnvironmentVariablesPlugin(this).getVariables();\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n return getEnvironmentVariablesPlugin(this).registerVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n return getEnvironmentVariablesPlugin(this).registerVariables(variables);\n }\n\n get appRouterStore() {\n return this.#appRouterStore;\n }\n\n get honeycombInstrumentationClient() {\n return this.#honeycombInstrumentationClient;\n }\n\n get isLaunchDarklyEnabled() {\n return this.#isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return getLaunchDarklyPlugin(this).client;\n }\n\n get featureFlags() {\n return this.featureFlagSetSnapshot.value;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n return getLaunchDarklyPlugin(this).getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return getLaunchDarklyPlugin(this).featureFlagSetSnapshot;\n }\n\n startScope(logger: Logger): TRuntime {\n return (new FireflyRuntimeScope(this, logger) as unknown) as TRuntime;\n }\n}\n\nexport class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {\n get isMswEnabled() {\n return this._runtime.isMswEnabled;\n }\n\n get mswState() {\n return this._runtime.mswState;\n }\n\n registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {\n this._runtime.registerRequestHandlers(handlers, {\n ...options,\n logger: this._getLogger(options)\n });\n }\n\n // Must define a return type otherwise we get an \"error TS2742: The inferred type of 'requestHandlers' cannot be named\" error.\n get requestHandlers(): RequestHandler[] {\n return this._runtime.requestHandlers;\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return this._runtime.getEnvironmentVariable(key);\n }\n\n get environmentVariables() {\n return this._runtime.environmentVariables;\n }\n\n registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {\n this._runtime.registerEnvironmentVariable(key, value);\n }\n\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {\n this._runtime.registerEnvironmentVariables(variables);\n }\n\n get appRouterStore(): AppRouterStore {\n throw new Error(\"[squide] Cannot retrieve the app router store from a runtime scope instance.\");\n }\n\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient {\n throw new Error(\"[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.\");\n }\n\n get isLaunchDarklyEnabled() {\n return this._runtime.isLaunchDarklyEnabled;\n }\n\n get launchDarklyClient() {\n return this._runtime.launchDarklyClient;\n }\n\n get featureFlags() {\n return this._runtime.featureFlags;\n }\n\n getFeatureFlag<T extends FeatureFlagKey>(key: T, defaultValue?: FeatureFlags[T]) {\n // The error is because the FeatureFlags interface is empty as it is expected to be augmented by the\n // consumer application.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return this._runtime.getFeatureFlag(key, defaultValue);\n }\n\n get featureFlagSetSnapshot() {\n return this._runtime.featureFlagSetSnapshot;\n }\n}\n"],"names":["getEnvironmentVariablesPlugin","getLaunchDarklyPlugin","LaunchDarklyPluginName","getMswPlugin","MswPluginName","ReactRouterRuntime","ReactRouterRuntimeScope","createAppRouterStore","FireflyRuntime","options","honeycombInstrumentationClient","x","route","Error","handlers","logger","plugin","key","value","variables","defaultValue","FireflyRuntimeScope"],"mappings":";;;;;;;;;;;;;;;;;AAC+G;AAC6B;AACxE;AACqD;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,UAAU;YAC5C,GAAGL,OAAO;YACV,QAAQ,IAAI,CAAC,UAAU,CAACA;QAC5B;IACJ;IAEA,8HAA8H;IAC9H,IAAI,kBAAoC;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe;IACxC;IAEA,uBAAuBQ,GAA2B,EAAE;QAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAACA;IAChD;IAEA,IAAI,uBAAuB;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,oBAAoB;IAC7C;IAEA,4BAA8DA,GAAM,EAAEC,KAA8B,EAAE;QAClG,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAACD,KAAKC;IACnD;IAEA,6BAA6BC,SAAwC,EAAE;QACnE,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAACA;IAC/C;IAEA,IAAI,iBAAiC;QACjC,MAAM,IAAIN,MAAM;IACpB;IAEA,IAAI,iCAAwE;QACxE,MAAM,IAAIA,MAAM;IACpB;IAEA,IAAI,wBAAwB;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,qBAAqB;IAC9C;IAEA,IAAI,qBAAqB;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB;IAC3C;IAEA,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY;IACrC;IAEA,eAAyCI,GAAM,EAAEG,YAA8B,EAAE;QAC7E,oGAAoG;QACpG,wBAAwB;QACxB,6DAA6D;QAC7D,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAACH,KAAKG;IAC7C;IAEA,IAAI,yBAAyB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB;IAC/C;AACJ"}
@@ -54,13 +54,41 @@ function bootstrap(runtime, modulesDefinitions, options = {}) {
54
54
  }
55
55
  });
56
56
  }
57
+ function logInitializationState(runtime, options, plugins) {
58
+ const { mode, localModules, moduleDefinitions, useMsw, environmentVariables, honeycombInstrumentationClient, launchDarklyClient } = options;
59
+ const scope = runtime.logger.startScope("[squide] Initializing the application.");
60
+ try {
61
+ scope.information(`[squide] Mode: ${mode ?? "development"}`);
62
+ if (localModules) {
63
+ scope.withText("[squide] Local modules:").withObject(localModules).information();
64
+ }
65
+ if (moduleDefinitions) {
66
+ scope.withText("[squide] Module definitions:").withObject(moduleDefinitions).information();
67
+ }
68
+ scope.information(`[squide] Use MSW: ${useMsw ? "Yes" : "No"}`);
69
+ if (environmentVariables && Object.keys(environmentVariables).length > 0) {
70
+ scope.withText("[squide] Environment variables:").withObject(environmentVariables).information();
71
+ }
72
+ if (honeycombInstrumentationClient) {
73
+ scope.withText("[squide] Honeycomb instrumentation client:").withObject(honeycombInstrumentationClient).information();
74
+ }
75
+ if (launchDarklyClient) {
76
+ scope.withText("[squide] LaunchDarkly client:").withObject(launchDarklyClient).information();
77
+ }
78
+ if (plugins.length > 0) {
79
+ scope.withText("[squide] Plugins:").withObject(plugins).information();
80
+ }
81
+ } finally{
82
+ scope.end();
83
+ }
84
+ }
57
85
  let hasExecuted = false;
58
86
  // Should only be used by tests.
59
87
  function __resetHasExecutedGuard() {
60
88
  hasExecuted = false;
61
89
  }
62
90
  function initializeFirefly(options = {}) {
63
- const { mode, localModules = [], moduleDefinitions = [], useMsw, plugins = [], environmentVariables, honeycombInstrumentationClient, launchDarklyClient, loggers, onError } = options;
91
+ const { mode, localModules = [], moduleDefinitions = [], useMsw, environmentVariables, honeycombInstrumentationClient, launchDarklyClient, plugins = [], loggers, onError } = options;
64
92
  if (hasExecuted) {
65
93
  throw new Error("[squide] A squide application can only be initialized once. Did you call the \"initializeSquide\" function twice?");
66
94
  }
@@ -82,6 +110,7 @@ function initializeFirefly(options = {}) {
82
110
  ...plugins
83
111
  ]
84
112
  });
113
+ logInitializationState(runtime, options, plugins);
85
114
  initializeHoneycomb(runtime).catch((error)=>{
86
115
  if (onError) {
87
116
  onError(error);
@@ -1 +1 @@
1
- {"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { isFunction } from \"@squide/core/internal\";\nimport { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { LaunchDarklyPlugin } from \"@squide/launch-darkly\";\nimport { MswPlugin } from \"@squide/msw\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\nimport { initializeHoneycomb } from \"./honeycomb/initializeHoneycomb.ts\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: (ModuleRegisterFunction<TRuntime, TContext, TData> | undefined)[];\n moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];\n useMsw?: boolean;\n environmentVariables?: Partial<EnvironmentVariables>;\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n launchDarklyClient?: LDClient;\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(\n runtime: TRuntime,\n modulesDefinitions: (ModuleDefinition<TRuntime, TContext, TData> | undefined)[],\n options: Omit<InitializeFireflyOptions<TRuntime, TContext, TData>, \"localModules\" | \"moduleDefinitions\"> = {}\n) {\n const {\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n runtime.moduleManager.registerModules(\n modulesDefinitions.filter((x): x is ModuleDefinition => Boolean(x)),\n { context }\n ).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n if (runtime.isMswEnabled) {\n runtime.mswState.setAsReady();\n }\n })\n .catch((error: unknown) => {\n runtime.logger\n .withText(\"[squide] An error occured while starting MSW.\")\n .withError(error as Error)\n .error();\n });\n }\n\n if (onError) {\n results.forEach(error => {\n onError(error);\n });\n }\n });\n}\n\nlet hasExecuted = false;\n\n// Should only be used by tests.\nexport function __resetHasExecutedGuard() {\n hasExecuted = false;\n}\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n localModules = [],\n moduleDefinitions = [],\n useMsw,\n plugins = [],\n environmentVariables,\n honeycombInstrumentationClient,\n launchDarklyClient,\n loggers,\n onError\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n if (useMsw) {\n plugins.push(x => new MswPlugin(x));\n }\n\n if (launchDarklyClient) {\n plugins.push(x => new LaunchDarklyPlugin(x, launchDarklyClient));\n }\n\n const runtime = new FireflyRuntime({\n mode,\n honeycombInstrumentationClient,\n loggers,\n plugins: [\n x => new EnvironmentVariablesPlugin(x, {\n variables: environmentVariables\n }),\n ...plugins\n ]\n });\n\n initializeHoneycomb(runtime)\n .catch((error: unknown) => {\n if (onError) {\n onError(error);\n }\n })\n .finally(() => {\n bootstrap(\n runtime,\n [...moduleDefinitions, ...toLocalModuleDefinitions(localModules)],\n options\n );\n });\n\n return runtime;\n}\n"],"names":["toLocalModuleDefinitions","isFunction","EnvironmentVariablesPlugin","LaunchDarklyPlugin","MswPlugin","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","bootstrap","runtime","modulesDefinitions","options","startMsw","onError","context","x","Boolean","results","Error","error","hasExecuted","__resetHasExecutedGuard","initializeFirefly","mode","localModules","moduleDefinitions","useMsw","plugins","environmentVariables","honeycombInstrumentationClient","launchDarklyClient","loggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAoI;AACjF;AACiC;AACzB;AACnB;AAG0C;AACT;AAElE,MAAMO,uCAAuC,mCAAmC;AAiBhF,SAASC,UACZC,OAAiB,EACjBC,kBAA+E,EAC/EC,UAA2G,CAAC,CAAC;IAE7G,MAAM,EACFC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACV,GAAGH;IAEJF,QAAQ,QAAQ,CAAC,QAAQ,CAACF;IAE1BE,QAAQ,aAAa,CAAC,eAAe,CACjCC,mBAAmB,MAAM,CAAC,CAACK,IAA6BC,QAAQD,KAChE;QAAED;IAAQ,GACZ,IAAI,CAACG,CAAAA;QACH,IAAIR,QAAQ,YAAY,EAAE;YACtB,IAAI,CAACR,UAAUA,CAACW,WAAW;gBACvB,MAAM,IAAIM,MAAM;YACpB;YAEAN,SAASH,SACJ,IAAI,CAAC;gBACF,IAAIA,QAAQ,YAAY,EAAE;oBACtBA,QAAQ,QAAQ,CAAC,UAAU;gBAC/B;YACJ,GACC,KAAK,CAAC,CAACU;gBACJV,QAAQ,MAAM,CACT,QAAQ,CAAC,iDACT,SAAS,CAACU,OACV,KAAK;YACd;QACR;QAEA,IAAIN,SAAS;YACTI,QAAQ,OAAO,CAACE,CAAAA;gBACZN,QAAQM;YACZ;QACJ;IACJ;AACJ;AAEA,IAAIC,cAAc;AAElB,gCAAgC;AACzB,SAASC;IACZD,cAAc;AAClB;AAEO,SAASE,kBAAuDX,UAAqE,CAAC,CAAC;IAC1I,MAAM,EACFY,IAAI,EACJC,eAAe,EAAE,EACjBC,oBAAoB,EAAE,EACtBC,MAAM,EACNC,UAAU,EAAE,EACZC,oBAAoB,EACpBC,8BAA8B,EAC9BC,kBAAkB,EAClBC,OAAO,EACPlB,OAAO,EACV,GAAGF;IAEJ,IAAIS,aAAa;QACb,MAAM,IAAIF,MAAM;IACpB;IAEAE,cAAc;IAEd,IAAIM,QAAQ;QACRC,QAAQ,IAAI,CAACZ,CAAAA,IAAK,IAAIX,SAASA,CAACW;IACpC;IAEA,IAAIe,oBAAoB;QACpBH,QAAQ,IAAI,CAACZ,CAAAA,IAAK,IAAIZ,kBAAkBA,CAACY,GAAGe;IAChD;IAEA,MAAMrB,UAAU,IAAIJ,cAAcA,CAAC;QAC/BkB;QACAM;QACAE;QACA,SAAS;YACLhB,CAAAA,IAAK,IAAIb,0BAA0BA,CAACa,GAAG;oBACnC,WAAWa;gBACf;eACGD;SACN;IACL;IAEArB,mBAAmBA,CAACG,SACf,KAAK,CAAC,CAACU;QACJ,IAAIN,SAAS;YACTA,QAAQM;QACZ;IACJ,GACC,OAAO,CAAC;QACLX,UACIC,SACA;eAAIgB;eAAsBzB,wBAAwBA,CAACwB;SAAc,EACjEb;IAER;IAEJ,OAAOF;AACX"}
1
+ {"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { ModuleDefinition, PluginFactory, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { isFunction } from \"@squide/core/internal\";\nimport { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { LaunchDarklyPlugin } from \"@squide/launch-darkly\";\nimport { MswPlugin } from \"@squide/msw\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\nimport { RootLogger } from \"@workleap/logging\";\nimport { LDClient } from \"launchdarkly-js-client-sdk\";\nimport { FireflyRuntime, type FireflyRuntimeOptions } from \"./FireflyRuntime.tsx\";\nimport { initializeHoneycomb } from \"./honeycomb/initializeHoneycomb.ts\";\n\nexport const ApplicationBootstrappingStartedEvent = \"squide-app-bootstrapping-started\";\n\nexport type OnInitializationErrorFunction = (error: unknown) => void;\n\nexport type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) => Promise<void>;\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {\n localModules?: (ModuleRegisterFunction<TRuntime, TContext, TData> | undefined)[];\n moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];\n useMsw?: boolean;\n environmentVariables?: Partial<EnvironmentVariables>;\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\n launchDarklyClient?: LDClient;\n startMsw?: StartMswFunction<FireflyRuntime>;\n onError?: OnInitializationErrorFunction;\n}\n\nexport function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TContext = unknown, TData = unknown>(\n runtime: TRuntime,\n modulesDefinitions: (ModuleDefinition<TRuntime, TContext, TData> | undefined)[],\n options: Omit<InitializeFireflyOptions<TRuntime, TContext, TData>, \"localModules\" | \"moduleDefinitions\"> = {}\n) {\n const {\n startMsw,\n onError,\n context\n } = options;\n\n runtime.eventBus.dispatch(ApplicationBootstrappingStartedEvent);\n\n runtime.moduleManager.registerModules(\n modulesDefinitions.filter((x): x is ModuleDefinition => Boolean(x)),\n { context }\n ).then(results => {\n if (runtime.isMswEnabled) {\n if (!isFunction(startMsw)) {\n throw new Error(\"[squide] When MSW is enabled, the \\\"startMsw\\\" function must be provided.\");\n }\n\n startMsw(runtime)\n .then(() => {\n if (runtime.isMswEnabled) {\n runtime.mswState.setAsReady();\n }\n })\n .catch((error: unknown) => {\n runtime.logger\n .withText(\"[squide] An error occured while starting MSW.\")\n .withError(error as Error)\n .error();\n });\n }\n\n if (onError) {\n results.forEach(error => {\n onError(error);\n });\n }\n });\n}\n\nfunction logInitializationState<TContext = unknown, TData = unknown>(\n runtime: FireflyRuntime,\n options: InitializeFireflyOptions<FireflyRuntime, TContext, TData>,\n plugins: PluginFactory<FireflyRuntime>[]\n) {\n const {\n mode,\n localModules,\n moduleDefinitions,\n useMsw,\n environmentVariables,\n honeycombInstrumentationClient,\n launchDarklyClient\n } = options;\n const scope = (runtime.logger as RootLogger).startScope(\"[squide] Initializing the application.\");\n\n try {\n scope.information(`[squide] Mode: ${mode ?? \"development\"}`);\n\n if (localModules) {\n scope\n .withText(\"[squide] Local modules:\")\n .withObject(localModules)\n .information();\n }\n\n if (moduleDefinitions) {\n scope\n .withText(\"[squide] Module definitions:\")\n .withObject(moduleDefinitions)\n .information();\n }\n\n scope.information(`[squide] Use MSW: ${useMsw ? \"Yes\" : \"No\"}`);\n\n if (environmentVariables && Object.keys(environmentVariables).length > 0) {\n scope\n .withText(\"[squide] Environment variables:\")\n .withObject(environmentVariables)\n .information();\n }\n\n if (honeycombInstrumentationClient) {\n scope\n .withText(\"[squide] Honeycomb instrumentation client:\")\n .withObject(honeycombInstrumentationClient)\n .information();\n }\n\n if (launchDarklyClient) {\n scope\n .withText(\"[squide] LaunchDarkly client:\")\n .withObject(launchDarklyClient)\n .information();\n }\n\n if (plugins.length > 0) {\n scope\n .withText(\"[squide] Plugins:\")\n .withObject(plugins)\n .information();\n }\n } finally {\n scope.end();\n }\n}\n\nlet hasExecuted = false;\n\n// Should only be used by tests.\nexport function __resetHasExecutedGuard() {\n hasExecuted = false;\n}\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n mode,\n localModules = [],\n moduleDefinitions = [],\n useMsw,\n environmentVariables,\n honeycombInstrumentationClient,\n launchDarklyClient,\n plugins = [],\n loggers,\n onError\n } = options;\n\n if (hasExecuted) {\n throw new Error(\"[squide] A squide application can only be initialized once. Did you call the \\\"initializeSquide\\\" function twice?\");\n }\n\n hasExecuted = true;\n\n if (useMsw) {\n plugins.push(x => new MswPlugin(x));\n }\n\n if (launchDarklyClient) {\n plugins.push(x => new LaunchDarklyPlugin(x, launchDarklyClient));\n }\n\n const runtime = new FireflyRuntime({\n mode,\n honeycombInstrumentationClient,\n loggers,\n plugins: [\n x => new EnvironmentVariablesPlugin(x, {\n variables: environmentVariables\n }),\n ...plugins\n ]\n });\n\n logInitializationState(runtime, options, plugins);\n\n initializeHoneycomb(runtime)\n .catch((error: unknown) => {\n if (onError) {\n onError(error);\n }\n })\n .finally(() => {\n bootstrap(\n runtime,\n [...moduleDefinitions, ...toLocalModuleDefinitions(localModules)],\n options\n );\n });\n\n return runtime;\n}\n"],"names":["toLocalModuleDefinitions","isFunction","EnvironmentVariablesPlugin","LaunchDarklyPlugin","MswPlugin","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","bootstrap","runtime","modulesDefinitions","options","startMsw","onError","context","x","Boolean","results","Error","error","logInitializationState","plugins","mode","localModules","moduleDefinitions","useMsw","environmentVariables","honeycombInstrumentationClient","launchDarklyClient","scope","Object","hasExecuted","__resetHasExecutedGuard","initializeFirefly","loggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAmJ;AAChG;AACiC;AACzB;AACnB;AAI0C;AACT;AAElE,MAAMO,uCAAuC,mCAAmC;AAiBhF,SAASC,UACZC,OAAiB,EACjBC,kBAA+E,EAC/EC,UAA2G,CAAC,CAAC;IAE7G,MAAM,EACFC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACV,GAAGH;IAEJF,QAAQ,QAAQ,CAAC,QAAQ,CAACF;IAE1BE,QAAQ,aAAa,CAAC,eAAe,CACjCC,mBAAmB,MAAM,CAAC,CAACK,IAA6BC,QAAQD,KAChE;QAAED;IAAQ,GACZ,IAAI,CAACG,CAAAA;QACH,IAAIR,QAAQ,YAAY,EAAE;YACtB,IAAI,CAACR,UAAUA,CAACW,WAAW;gBACvB,MAAM,IAAIM,MAAM;YACpB;YAEAN,SAASH,SACJ,IAAI,CAAC;gBACF,IAAIA,QAAQ,YAAY,EAAE;oBACtBA,QAAQ,QAAQ,CAAC,UAAU;gBAC/B;YACJ,GACC,KAAK,CAAC,CAACU;gBACJV,QAAQ,MAAM,CACT,QAAQ,CAAC,iDACT,SAAS,CAACU,O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EACjBC,oBAAoB,EAAE,EACtBC,MAAM,EACNC,oBAAoB,EACpBC,8BAA8B,EAC9BC,kBAAkB,EAClBP,UAAU,EAAE,EACZa,OAAO,EACPrB,OAAO,EACV,GAAGF;IAEJ,IAAIoB,aAAa;QACb,MAAM,IAAIb,MAAM;IACpB;IAEAa,cAAc;IAEd,IAAIN,QAAQ;QACRJ,QAAQ,IAAI,CAACN,CAAAA,IAAK,IAAIX,SAASA,CAACW;IACpC;IAEA,IAAIa,oBAAoB;QACpBP,QAAQ,IAAI,CAACN,CAAAA,IAAK,IAAIZ,kBAAkBA,CAACY,GAAGa;IAChD;IAEA,MAAMnB,UAAU,IAAIJ,cAAcA,CAAC;QAC/BiB;QACAK;QACAO;QACA,SAAS;YACLnB,CAAAA,IAAK,IAAIb,0BAA0BA,CAACa,GAAG;oBACnC,WAAWW;gBACf;eACGL;SACN;IACL;IAEAD,uBAAuBX,SAASE,SAASU;IAEzCf,mBAAmBA,CAACG,SACf,KAAK,CAAC,CAACU;QACJ,IAAIN,SAAS;YACTA,QAAQM;QACZ;IACJ,GACC,OAAO,CAAC;QACLX,UACIC,SACA;eAAIe;eAAsBxB,wBAAwBA,CAACuB;SAAc,EACjEZ;IAER;IAEJ,OAAOF;AACX"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "16.1.2",
4
+ "version": "16.1.4",
5
5
  "description": "Squide bundle for the firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -49,11 +49,11 @@
49
49
  "@workleap-telemetry/core": "^1.0.6",
50
50
  "@workleap/logging": "^1.3.3",
51
51
  "uuid": "^13.0.0",
52
- "@squide/core": "6.1.8",
53
- "@squide/env-vars": "1.4.11",
54
- "@squide/launch-darkly": "1.0.2",
55
- "@squide/msw": "4.0.9",
56
- "@squide/react-router": "8.1.8"
52
+ "@squide/core": "6.1.9",
53
+ "@squide/env-vars": "1.4.12",
54
+ "@squide/launch-darkly": "1.0.3",
55
+ "@squide/msw": "4.0.10",
56
+ "@squide/react-router": "8.1.9"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "9.39.1",
@@ -66,9 +66,7 @@ export class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends React
66
66
  }
67
67
 
68
68
  get mswState() {
69
- const plugin = getMswPlugin(this);
70
-
71
- return plugin.mswState;
69
+ return getMswPlugin(this).mswState;
72
70
  }
73
71
 
74
72
  registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
@@ -86,33 +84,23 @@ export class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends React
86
84
 
87
85
  // Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
88
86
  get requestHandlers(): RequestHandler[] {
89
- const plugin = getMswPlugin(this);
90
-
91
- return plugin.requestHandlers;
87
+ return getMswPlugin(this).requestHandlers;
92
88
  }
93
89
 
94
90
  getEnvironmentVariable(key: EnvironmentVariableKey) {
95
- const plugin = getEnvironmentVariablesPlugin(this);
96
-
97
- return plugin.getVariable(key);
91
+ return getEnvironmentVariablesPlugin(this).getVariable(key);
98
92
  }
99
93
 
100
94
  get environmentVariables() {
101
- const plugin = getEnvironmentVariablesPlugin(this);
102
-
103
- return plugin.getVariables();
95
+ return getEnvironmentVariablesPlugin(this).getVariables();
104
96
  }
105
97
 
106
98
  registerEnvironmentVariable<T extends EnvironmentVariableKey>(key: T, value: EnvironmentVariables[T]) {
107
- const plugin = getEnvironmentVariablesPlugin(this);
108
-
109
- return plugin.registerVariable(key, value);
99
+ return getEnvironmentVariablesPlugin(this).registerVariable(key, value);
110
100
  }
111
101
 
112
102
  registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {
113
- const plugin = getEnvironmentVariablesPlugin(this);
114
-
115
- return plugin.registerVariables(variables);
103
+ return getEnvironmentVariablesPlugin(this).registerVariables(variables);
116
104
  }
117
105
 
118
106
  get appRouterStore() {
@@ -1,9 +1,10 @@
1
- import { ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
1
+ import { ModuleDefinition, PluginFactory, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
2
2
  import { isFunction } from "@squide/core/internal";
3
3
  import { EnvironmentVariables, EnvironmentVariablesPlugin } from "@squide/env-vars";
4
4
  import { LaunchDarklyPlugin } from "@squide/launch-darkly";
5
5
  import { MswPlugin } from "@squide/msw";
6
6
  import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
7
+ import { RootLogger } from "@workleap/logging";
7
8
  import { LDClient } from "launchdarkly-js-client-sdk";
8
9
  import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
9
10
  import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.ts";
@@ -69,6 +70,73 @@ export function bootstrap<TRuntime extends FireflyRuntime = FireflyRuntime, TCon
69
70
  });
70
71
  }
71
72
 
73
+ function logInitializationState<TContext = unknown, TData = unknown>(
74
+ runtime: FireflyRuntime,
75
+ options: InitializeFireflyOptions<FireflyRuntime, TContext, TData>,
76
+ plugins: PluginFactory<FireflyRuntime>[]
77
+ ) {
78
+ const {
79
+ mode,
80
+ localModules,
81
+ moduleDefinitions,
82
+ useMsw,
83
+ environmentVariables,
84
+ honeycombInstrumentationClient,
85
+ launchDarklyClient
86
+ } = options;
87
+ const scope = (runtime.logger as RootLogger).startScope("[squide] Initializing the application.");
88
+
89
+ try {
90
+ scope.information(`[squide] Mode: ${mode ?? "development"}`);
91
+
92
+ if (localModules) {
93
+ scope
94
+ .withText("[squide] Local modules:")
95
+ .withObject(localModules)
96
+ .information();
97
+ }
98
+
99
+ if (moduleDefinitions) {
100
+ scope
101
+ .withText("[squide] Module definitions:")
102
+ .withObject(moduleDefinitions)
103
+ .information();
104
+ }
105
+
106
+ scope.information(`[squide] Use MSW: ${useMsw ? "Yes" : "No"}`);
107
+
108
+ if (environmentVariables && Object.keys(environmentVariables).length > 0) {
109
+ scope
110
+ .withText("[squide] Environment variables:")
111
+ .withObject(environmentVariables)
112
+ .information();
113
+ }
114
+
115
+ if (honeycombInstrumentationClient) {
116
+ scope
117
+ .withText("[squide] Honeycomb instrumentation client:")
118
+ .withObject(honeycombInstrumentationClient)
119
+ .information();
120
+ }
121
+
122
+ if (launchDarklyClient) {
123
+ scope
124
+ .withText("[squide] LaunchDarkly client:")
125
+ .withObject(launchDarklyClient)
126
+ .information();
127
+ }
128
+
129
+ if (plugins.length > 0) {
130
+ scope
131
+ .withText("[squide] Plugins:")
132
+ .withObject(plugins)
133
+ .information();
134
+ }
135
+ } finally {
136
+ scope.end();
137
+ }
138
+ }
139
+
72
140
  let hasExecuted = false;
73
141
 
74
142
  // Should only be used by tests.
@@ -82,10 +150,10 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
82
150
  localModules = [],
83
151
  moduleDefinitions = [],
84
152
  useMsw,
85
- plugins = [],
86
153
  environmentVariables,
87
154
  honeycombInstrumentationClient,
88
155
  launchDarklyClient,
156
+ plugins = [],
89
157
  loggers,
90
158
  onError
91
159
  } = options;
@@ -116,6 +184,8 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
116
184
  ]
117
185
  });
118
186
 
187
+ logInitializationState(runtime, options, plugins);
188
+
119
189
  initializeHoneycomb(runtime)
120
190
  .catch((error: unknown) => {
121
191
  if (onError) {