@squide/firefly 16.0.0 → 16.0.1
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 +12 -0
- package/dist/FireflyRuntime.d.ts +18 -5
- package/dist/FireflyRuntime.js +52 -28
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/initializeFirefly.d.ts +2 -0
- package/dist/initializeFirefly.js +11 -2
- package/dist/initializeFirefly.js.map +1 -1
- package/package.json +10 -4
- package/src/FireflyRuntime.tsx +70 -33
- package/src/index.ts +17 -1
- package/src/initializeFirefly.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @squide/firefly
|
|
2
2
|
|
|
3
|
+
## 16.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#342](https://github.com/workleap/wl-squide/pull/342) [`3be4070`](https://github.com/workleap/wl-squide/commit/3be4070d2d647804903b5cc01113e20d5d71cb11) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Minor fine tuning following v16 release.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`3be4070`](https://github.com/workleap/wl-squide/commit/3be4070d2d647804903b5cc01113e20d5d71cb11)]:
|
|
10
|
+
- @squide/env-vars@1.4.8
|
|
11
|
+
- @squide/core@6.1.5
|
|
12
|
+
- @squide/msw@4.0.6
|
|
13
|
+
- @squide/react-router@8.1.5
|
|
14
|
+
|
|
3
15
|
## 16.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/FireflyRuntime.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from "@squide/core";
|
|
2
|
+
import { EnvironmentVariableKey, EnvironmentVariables, EnvironmentVariableValue } from "@squide/env-vars";
|
|
2
3
|
import { MswState } from "@squide/msw";
|
|
3
4
|
import { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from "@squide/react-router";
|
|
4
5
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
@@ -14,20 +15,28 @@ export interface IFireflyRuntime extends IReactRouterRuntime {
|
|
|
14
15
|
getMswState(): MswState;
|
|
15
16
|
registerRequestHandlers: (handlers: RequestHandler[]) => void;
|
|
16
17
|
get requestHandlers(): RequestHandler[];
|
|
17
|
-
get appRouterStore(): AppRouterStore;
|
|
18
18
|
get isMswEnabled(): boolean;
|
|
19
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
20
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
21
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): EnvironmentVariableValue;
|
|
22
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
23
|
+
get appRouterStore(): AppRouterStore;
|
|
19
24
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;
|
|
20
25
|
}
|
|
21
26
|
export declare class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends ReactRouterRuntime<TRuntime> implements IFireflyRuntime {
|
|
22
27
|
protected _appRouterStore: AppRouterStore;
|
|
23
28
|
protected _honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;
|
|
24
|
-
constructor(
|
|
29
|
+
constructor(options?: FireflyRuntimeOptions);
|
|
30
|
+
registerRoute(route: Route, options?: RegisterRouteOptions): void;
|
|
25
31
|
getMswState(): MswState;
|
|
26
32
|
registerRequestHandlers(handlers: RequestHandler[], options?: RegisterRequestHandlersOptions): void;
|
|
27
33
|
get requestHandlers(): RequestHandler[];
|
|
28
|
-
registerRoute(route: Route, options?: RegisterRouteOptions): void;
|
|
29
|
-
get appRouterStore(): AppRouterStore;
|
|
30
34
|
get isMswEnabled(): boolean;
|
|
35
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): never;
|
|
36
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
37
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
38
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
39
|
+
get appRouterStore(): AppRouterStore;
|
|
31
40
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;
|
|
32
41
|
startScope(logger: Logger): TRuntime;
|
|
33
42
|
}
|
|
@@ -35,7 +44,11 @@ export declare class FireflyRuntimeScope<TRuntime extends FireflyRuntime = Firef
|
|
|
35
44
|
getMswState(): MswState;
|
|
36
45
|
registerRequestHandlers(handlers: RequestHandler[], options?: RegisterRequestHandlersOptions): void;
|
|
37
46
|
get requestHandlers(): RequestHandler[];
|
|
38
|
-
get appRouterStore(): AppRouterStore;
|
|
39
47
|
get isMswEnabled(): boolean;
|
|
48
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
49
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): never;
|
|
50
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
51
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
52
|
+
get appRouterStore(): AppRouterStore;
|
|
40
53
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient;
|
|
41
54
|
}
|
package/dist/FireflyRuntime.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEnvironmentVariablesPlugin } from "@squide/env-vars";
|
|
2
|
+
import { MswPluginName, getMswPlugin } from "@squide/msw";
|
|
2
3
|
import { ReactRouterRuntime, ReactRouterRuntimeScope } from "@squide/react-router";
|
|
3
4
|
import { createAppRouterStore } from "./AppRouterStore.js";
|
|
4
5
|
|
|
6
|
+
;// CONCATENATED MODULE: external "@squide/env-vars"
|
|
7
|
+
|
|
5
8
|
;// CONCATENATED MODULE: external "@squide/msw"
|
|
6
9
|
|
|
7
10
|
;// CONCATENATED MODULE: external "@squide/react-router"
|
|
@@ -12,55 +15,64 @@ import { createAppRouterStore } from "./AppRouterStore.js";
|
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
|
|
18
|
+
|
|
15
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
20
|
class FireflyRuntime extends ReactRouterRuntime {
|
|
17
21
|
_appRouterStore;
|
|
18
22
|
_honeycombInstrumentationClient;
|
|
19
|
-
constructor(
|
|
23
|
+
constructor(options = {}){
|
|
24
|
+
const { honeycombInstrumentationClient } = options;
|
|
20
25
|
super(options);
|
|
21
26
|
this._appRouterStore = createAppRouterStore(this._logger);
|
|
22
27
|
this._honeycombInstrumentationClient = honeycombInstrumentationClient;
|
|
23
28
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
throw new Error("[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
29
|
+
registerRoute(route, options = {}) {
|
|
30
|
+
if (this.moduleManager.getAreModulesRegistered()) {
|
|
31
|
+
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.");
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
super.registerRoute(route, options);
|
|
34
|
+
}
|
|
35
|
+
getMswState() {
|
|
36
|
+
const plugin = getMswPlugin(this);
|
|
37
|
+
return plugin.mswState;
|
|
30
38
|
}
|
|
31
39
|
registerRequestHandlers(handlers, options = {}) {
|
|
32
40
|
const logger = this._getLogger(options);
|
|
33
|
-
const
|
|
34
|
-
if (!mswPlugin) {
|
|
35
|
-
throw new Error("[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
36
|
-
}
|
|
41
|
+
const plugin = getMswPlugin(this);
|
|
37
42
|
if (this.moduleManager.getAreModulesRegistered()) {
|
|
38
43
|
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.");
|
|
39
44
|
}
|
|
40
|
-
|
|
45
|
+
plugin.registerRequestHandlers(handlers, {
|
|
41
46
|
logger
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
49
|
// Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
|
|
45
50
|
get requestHandlers() {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
throw new Error("[squide] Cannot retrieve MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
49
|
-
}
|
|
50
|
-
return mswPlugin.requestHandlers;
|
|
51
|
+
const plugin = getMswPlugin(this);
|
|
52
|
+
return plugin.requestHandlers;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
get isMswEnabled() {
|
|
55
|
+
return this._plugins.some((x)=>x.name === MswPluginName);
|
|
56
|
+
}
|
|
57
|
+
getEnvironmentVariable(key) {
|
|
58
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
59
|
+
return plugin.getVariable(key);
|
|
60
|
+
}
|
|
61
|
+
getEnvironmentVariables() {
|
|
62
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
63
|
+
return plugin.getVariables();
|
|
64
|
+
}
|
|
65
|
+
registerEnvironmentVariable(key, value) {
|
|
66
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
67
|
+
return plugin.registerVariable(key, value);
|
|
68
|
+
}
|
|
69
|
+
registerEnvironmentVariables(variables) {
|
|
70
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
71
|
+
return plugin.registerVariables(variables);
|
|
57
72
|
}
|
|
58
73
|
get appRouterStore() {
|
|
59
74
|
return this._appRouterStore;
|
|
60
75
|
}
|
|
61
|
-
get isMswEnabled() {
|
|
62
|
-
return this._plugins.some((x)=>x.name === MswPluginName);
|
|
63
|
-
}
|
|
64
76
|
get honeycombInstrumentationClient() {
|
|
65
77
|
return this._honeycombInstrumentationClient;
|
|
66
78
|
}
|
|
@@ -82,12 +94,24 @@ class FireflyRuntimeScope extends ReactRouterRuntimeScope {
|
|
|
82
94
|
get requestHandlers() {
|
|
83
95
|
return this._runtime.requestHandlers;
|
|
84
96
|
}
|
|
85
|
-
get appRouterStore() {
|
|
86
|
-
throw new Error("[squide] Cannot retrieve the app router store from a runtime scope instance.");
|
|
87
|
-
}
|
|
88
97
|
get isMswEnabled() {
|
|
89
98
|
return this._runtime.isMswEnabled;
|
|
90
99
|
}
|
|
100
|
+
getEnvironmentVariables() {
|
|
101
|
+
return this._runtime.getEnvironmentVariables();
|
|
102
|
+
}
|
|
103
|
+
getEnvironmentVariable(key) {
|
|
104
|
+
return this._runtime.getEnvironmentVariable(key);
|
|
105
|
+
}
|
|
106
|
+
registerEnvironmentVariable(key, value) {
|
|
107
|
+
this._runtime.registerEnvironmentVariable(key, value);
|
|
108
|
+
}
|
|
109
|
+
registerEnvironmentVariables(variables) {
|
|
110
|
+
this._runtime.registerEnvironmentVariables(variables);
|
|
111
|
+
}
|
|
112
|
+
get appRouterStore() {
|
|
113
|
+
throw new Error("[squide] Cannot retrieve the app router store from a runtime scope instance.");
|
|
114
|
+
}
|
|
91
115
|
get honeycombInstrumentationClient() {
|
|
92
116
|
throw new Error("[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.");
|
|
93
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FireflyRuntime.js","sources":["../src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from \"@squide/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"FireflyRuntime.js","sources":["../src/FireflyRuntime.tsx"],"sourcesContent":["import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from \"@squide/core\";\nimport { EnvironmentVariableKey, EnvironmentVariables, EnvironmentVariableValue, getEnvironmentVariablesPlugin } from \"@squide/env-vars\";\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 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 getMswState(): MswState;\n registerRequestHandlers: (handlers: RequestHandler[]) => void;\n get requestHandlers(): RequestHandler[];\n get isMswEnabled(): boolean;\n registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;\n registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;\n getEnvironmentVariable(key: EnvironmentVariableKey): EnvironmentVariableValue;\n getEnvironmentVariables(): EnvironmentVariables;\n get appRouterStore(): AppRouterStore;\n get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;\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 protected _appRouterStore: AppRouterStore;\n protected _honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;\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 }\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 getMswState() {\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 get isMswEnabled() {\n return this._plugins.some(x => x.name === MswPluginName);\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n const plugin = getEnvironmentVariablesPlugin(this);\n\n return plugin.getVariable(key);\n }\n\n getEnvironmentVariables() {\n const plugin = getEnvironmentVariablesPlugin(this);\n\n return plugin.getVariables();\n }\n\n registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue) {\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 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 getMswState() {\n return this._runtime.getMswState();\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 get isMswEnabled() {\n return this._runtime.isMswEnabled;\n }\n\n getEnvironmentVariables() {\n return this._runtime.getEnvironmentVariables();\n }\n\n getEnvironmentVariable(key: EnvironmentVariableKey) {\n return this._runtime.getEnvironmentVariable(key);\n }\n\n registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue) {\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"],"names":["getEnvironmentVariablesPlugin","getMswPlugin","MswPluginName","ReactRouterRuntime","ReactRouterRuntimeScope","createAppRouterStore","FireflyRuntime","options","honeycombInstrumentationClient","route","Error","plugin","handlers","logger","x","key","value","variables","FireflyRuntimeScope"],"mappings":";;;;;;;;;;;;;;AACyI;AACrE;AACqD;AAIzC;AAqBhF,8DAA8D;AACvD,MAAMM,uBAA8DH,kBAAkBA;IAC/E,gBAAgC;IAChC,gCAAmF;IAE7F,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;IAC3C;IAEA,cAAcC,KAAY,EAAEF,UAAgC,CAAC,CAAC,EAAE;QAC5D,IAAI,IAAI,CAAC,aAAa,CAAC,uBAAuB,IAAI;YAC9C,MAAM,IAAIG,MAAM;QACpB;QAEA,KAAK,CAAC,cAAcD,OAAOF;IAC/B;IAEA,cAAc;QACV,MAAMI,SAASV,YAAYA,CAAC,IAAI;QAEhC,OAAOU,OAAO,QAAQ;IAC1B;IAEA,wBAAwBC,QAA0B,EAAEL,UAA0C,CAAC,CAAC,EAAE;QAC9F,MAAMM,SAAS,IAAI,CAAC,UAAU,CAACN;QAC/B,MAAMI,SAASV,YAAYA,CAAC,IAAI;QAEhC,IAAI,IAAI,CAAC,aAAa,CAAC,uBAAuB,IAAI;YAC9C,MAAM,IAAIS,MAAM;QACpB;QAEAC,OAAO,uBAAuB,CAACC,UAAU;YACrCC;QACJ;IACJ;IAEA,8HAA8H;IAC9H,IAAI,kBAAoC;QACpC,MAAMF,SAASV,YAAYA,CAAC,IAAI;QAEhC,OAAOU,OAAO,eAAe;IACjC;IAEA,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACG,CAAAA,IAAKA,EAAE,IAAI,KAAKZ,aAAaA;IAC3D;IAEA,uBAAuBa,GAA2B,EAAE;QAChD,MAAMJ,SAASX,6BAA6BA,CAAC,IAAI;QAEjD,OAAOW,OAAO,WAAW,CAACI;IAC9B;IAEA,0BAA0B;QACtB,MAAMJ,SAASX,6BAA6BA,CAAC,IAAI;QAEjD,OAAOW,OAAO,YAAY;IAC9B;IAEA,4BAA4BI,GAA2B,EAAEC,KAA+B,EAAE;QACtF,MAAML,SAASX,6BAA6BA,CAAC,IAAI;QAEjD,OAAOW,OAAO,gBAAgB,CAACI,KAAKC;IACxC;IAEA,6BAA6BC,SAAwC,EAAE;QACnE,MAAMN,SAASX,6BAA6BA,CAAC,IAAI;QAEjD,OAAOW,OAAO,iBAAiB,CAACM;IACpC;IAEA,IAAI,iBAAiB;QACjB,OAAO,IAAI,CAAC,eAAe;IAC/B;IAEA,IAAI,iCAAiC;QACjC,OAAO,IAAI,CAAC,+BAA+B;IAC/C;IAEA,WAAWJ,MAAc,EAAY;QACjC,OAAQ,IAAIK,oBAAoB,IAAI,EAAEL;IAC1C;AACJ;AAEO,MAAMK,4BAA8Ed,uBAAuBA;IAC9G,cAAc;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW;IACpC;IAEA,wBAAwBQ,QAA0B,EAAEL,UAA0C,CAAC,CAAC,EAAE;QAC9F,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAACK,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,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY;IACrC;IAEA,0BAA0B;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,uBAAuB;IAChD;IAEA,uBAAuBQ,GAA2B,EAAE;QAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAACA;IAChD;IAEA,4BAA4BA,GAA2B,EAAEC,KAA+B,EAAE;QACtF,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,IAAIP,MAAM;IACpB;IAEA,IAAI,iCAAwE;QACxE,MAAM,IAAIA,MAAM;IACpB;AACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "@squide/core";
|
|
2
|
-
export
|
|
2
|
+
export { EnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables, type EnvironmentVariableKey, type EnvironmentVariables, type EnvironmentVariablesPluginOptions, type EnvironmentVariableValue } from "@squide/env-vars";
|
|
3
|
+
export { MswPlugin, MswState, type MswPluginOptions, type MswPluginRegisterRequestHandlersOptions, type MswReadyListener, type MswStateOptions } from "@squide/msw";
|
|
3
4
|
export * from "@squide/react-router";
|
|
4
5
|
export type { FireflyPlugin } from "./FireflyPlugin.ts";
|
|
5
6
|
export * from "./FireflyProvider.tsx";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { EnvironmentVariablesPlugin, useEnvironmentVariable, useEnvironmentVariables } from "@squide/env-vars";
|
|
2
|
+
import { MswPlugin, MswState } from "@squide/msw";
|
|
1
3
|
import { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent } from "./AppRouterReducer.js";
|
|
2
4
|
export * from "@squide/core";
|
|
3
|
-
export * from "@squide/msw";
|
|
4
5
|
export * from "@squide/react-router";
|
|
5
6
|
export * from "./FireflyProvider.js";
|
|
6
7
|
export * from "./FireflyRuntime.js";
|
|
@@ -24,6 +25,10 @@ export * from "./useStrictRegistrationMode.js";
|
|
|
24
25
|
export * from "./useUpdateDeferredRegistrations.js";
|
|
25
26
|
export * from "./initializeFirefly.js";
|
|
26
27
|
|
|
28
|
+
;// CONCATENATED MODULE: external "@squide/env-vars"
|
|
29
|
+
|
|
30
|
+
;// CONCATENATED MODULE: external "@squide/msw"
|
|
31
|
+
|
|
27
32
|
;// CONCATENATED MODULE: external "./AppRouterReducer.js"
|
|
28
33
|
|
|
29
34
|
;// CONCATENATED MODULE: ./src/index.ts
|
|
@@ -53,6 +58,7 @@ export * from "./initializeFirefly.js";
|
|
|
53
58
|
|
|
54
59
|
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
|
|
62
|
+
export { ActiveRouteIsProtectedEvent, ActiveRouteIsPublicEvent, ApplicationBoostrappedEvent, DeferredRegistrationsUpdatedEvent, EnvironmentVariablesPlugin, ModulesReadyEvent, ModulesRegisteredEvent, MswPlugin, MswReadyEvent, MswState, ProtectedDataReadyEvent, ProtectedDataUpdatedEvent, PublicDataReadyEvent, PublicDataUpdatedEvent, useEnvironmentVariable, useEnvironmentVariables };
|
|
57
63
|
|
|
58
64
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@squide/core\";\nexport {\n EnvironmentVariablesPlugin,\n useEnvironmentVariable,\n useEnvironmentVariables,\n type EnvironmentVariableKey,\n type EnvironmentVariables,\n type EnvironmentVariablesPluginOptions,\n type EnvironmentVariableValue\n} from \"@squide/env-vars\";\nexport {\n MswPlugin,\n MswState,\n type MswPluginOptions,\n type MswPluginRegisterRequestHandlersOptions,\n type MswReadyListener,\n type MswStateOptions\n} from \"@squide/msw\";\nexport * from \"@squide/react-router\";\n\nexport type { FireflyPlugin } from \"./FireflyPlugin.ts\";\nexport * from \"./FireflyProvider.tsx\";\nexport * from \"./FireflyRuntime.tsx\";\n\nexport * from \"./AppRouter.tsx\";\nexport {\n ActiveRouteIsProtectedEvent,\n ActiveRouteIsPublicEvent,\n ApplicationBoostrappedEvent,\n DeferredRegistrationsUpdatedEvent,\n ModulesReadyEvent,\n ModulesRegisteredEvent,\n MswReadyEvent,\n ProtectedDataReadyEvent,\n ProtectedDataUpdatedEvent,\n PublicDataReadyEvent,\n PublicDataUpdatedEvent\n} from \"./AppRouterReducer.ts\";\n\nexport * from \"./AppRouterStore.ts\";\nexport * from \"./GlobalDataQueriesError.ts\";\nexport * from \"./useCanFetchProtectedData.ts\";\nexport * from \"./useCanFetchPublicData.ts\";\nexport * from \"./useCanRegisterDeferredRegistrations.ts\";\nexport * from \"./useCanUpdateDeferredRegistrations.ts\";\nexport * from \"./useDeferredRegistrations.ts\";\nexport * from \"./useIsActiveRouteProtected.ts\";\nexport * from \"./useIsBootstrapping.ts\";\nexport * from \"./useNavigationItems.ts\";\nexport * from \"./useProtectedDataHandler.ts\";\nexport * from \"./useProtectedDataQueries.ts\";\nexport * from \"./usePublicDataHandler.ts\";\nexport * from \"./usePublicDataQueries.ts\";\nexport * from \"./useRegisterDeferredRegistrations.ts\";\nexport * from \"./useStrictRegistrationMode.ts\";\nexport * from \"./useUpdateDeferredRegistrations.ts\";\n\nexport * from \"./initializeFirefly.ts\";\n\n"],"names":["EnvironmentVariablesPlugin","useEnvironmentVariable","useEnvironmentVariables","MswPlugin","MswState","ActiveRouteIsProtectedEvent","ActiveRouteIsPublicEvent","ApplicationBoostrappedEvent","DeferredRegistrationsUpdatedEvent","ModulesReadyEvent","ModulesRegisteredEvent","MswReadyEvent","ProtectedDataReadyEvent","ProtectedDataUpdatedEvent","PublicDataReadyEvent","PublicDataUpdatedEvent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA6B;AASH;AAQL;AACgB;AAGC;AACD;AAEL;AAaD;AAEK;AACQ;AACE;AACH;AACc;AACF;AACT;AACC;AACP;AACA;AACK;AACA;AACH;AACA;AACY;AACP;AACK;AAEb"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ModuleDefinition, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
|
|
2
|
+
import { EnvironmentVariables } from "@squide/env-vars";
|
|
2
3
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
3
4
|
import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
|
|
4
5
|
export declare const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
@@ -8,6 +9,7 @@ export interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TCont
|
|
|
8
9
|
localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];
|
|
9
10
|
moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];
|
|
10
11
|
useMsw?: boolean;
|
|
12
|
+
environmentVariables?: Partial<EnvironmentVariables>;
|
|
11
13
|
honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
|
|
12
14
|
startMsw?: StartMswFunction<FireflyRuntime>;
|
|
13
15
|
onError?: OnInitializationErrorFunction;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { isFunction, toLocalModuleDefinitions } from "@squide/core";
|
|
2
|
+
import { EnvironmentVariablesPlugin } from "@squide/env-vars";
|
|
2
3
|
import { MswPlugin } from "@squide/msw";
|
|
3
4
|
import { FireflyRuntime } from "./FireflyRuntime.js";
|
|
4
5
|
import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.js";
|
|
5
6
|
|
|
6
7
|
;// CONCATENATED MODULE: external "@squide/core"
|
|
7
8
|
|
|
9
|
+
;// CONCATENATED MODULE: external "@squide/env-vars"
|
|
10
|
+
|
|
8
11
|
;// CONCATENATED MODULE: external "@squide/msw"
|
|
9
12
|
|
|
10
13
|
;// CONCATENATED MODULE: external "./FireflyRuntime.js"
|
|
@@ -16,6 +19,7 @@ import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.js";
|
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
|
|
22
|
+
|
|
19
23
|
const ApplicationBootstrappingStartedEvent = "squide-app-bootstrapping-started";
|
|
20
24
|
function bootstrap(runtime, modulesDefinitions, options = {}) {
|
|
21
25
|
const { startMsw, onError, context } = options;
|
|
@@ -48,7 +52,7 @@ function __resetHasExecutedGuard() {
|
|
|
48
52
|
hasExecuted = false;
|
|
49
53
|
}
|
|
50
54
|
function initializeFirefly(options = {}) {
|
|
51
|
-
const { mode, localModules = [], moduleDefinitions = [], useMsw, plugins = [], honeycombInstrumentationClient, loggers, onError } = options;
|
|
55
|
+
const { mode, localModules = [], moduleDefinitions = [], useMsw, plugins = [], environmentVariables, honeycombInstrumentationClient, loggers, onError } = options;
|
|
52
56
|
if (hasExecuted) {
|
|
53
57
|
throw new Error("[squide] A squide application can only be initialized once. Did you call the \"initializeSquide\" function twice?");
|
|
54
58
|
}
|
|
@@ -60,7 +64,12 @@ function initializeFirefly(options = {}) {
|
|
|
60
64
|
mode,
|
|
61
65
|
honeycombInstrumentationClient,
|
|
62
66
|
loggers,
|
|
63
|
-
plugins
|
|
67
|
+
plugins: [
|
|
68
|
+
(x)=>new EnvironmentVariablesPlugin(x, {
|
|
69
|
+
variables: environmentVariables
|
|
70
|
+
}),
|
|
71
|
+
...plugins
|
|
72
|
+
]
|
|
64
73
|
});
|
|
65
74
|
initializeHoneycomb(runtime).catch((error)=>{
|
|
66
75
|
if (onError) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { isFunction, ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { MswPlugin } from \"@squide/msw\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\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>[];\n moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];\n useMsw?: boolean;\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\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>[],\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(modulesDefinitions, { 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.getMswState().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 honeycombInstrumentationClient,\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 const runtime = new FireflyRuntime({\n mode,\n honeycombInstrumentationClient,\n loggers,\n plugins\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":["isFunction","toLocalModuleDefinitions","MswPlugin","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","bootstrap","runtime","modulesDefinitions","options","startMsw","onError","context","results","Error","error","hasExecuted","__resetHasExecutedGuard","initializeFirefly","mode","localModules","moduleDefinitions","useMsw","plugins","honeycombInstrumentationClient","loggers","x"],"mappings":"
|
|
1
|
+
{"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { isFunction, ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from \"@squide/core\";\nimport { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { MswPlugin } from \"@squide/msw\";\nimport type { HoneycombInstrumentationPartialClient } from \"@workleap-telemetry/core\";\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>[];\n moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];\n useMsw?: boolean;\n environmentVariables?: Partial<EnvironmentVariables>;\n honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;\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>[],\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(modulesDefinitions, { 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.getMswState().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 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 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":["isFunction","toLocalModuleDefinitions","EnvironmentVariablesPlugin","MswPlugin","FireflyRuntime","initializeHoneycomb","ApplicationBootstrappingStartedEvent","bootstrap","runtime","modulesDefinitions","options","startMsw","onError","context","results","Error","error","hasExecuted","__resetHasExecutedGuard","initializeFirefly","mode","localModules","moduleDefinitions","useMsw","plugins","environmentVariables","honeycombInstrumentationClient","loggers","x"],"mappings":";;;;;;;;;;;;;;;;;AAAgJ;AAC5D;AAC5C;AAE0C;AACT;AAElE,MAAMM,uCAAuC,mCAAmC;AAgBhF,SAASC,UACZC,OAAiB,EACjBC,kBAAiE,EACjEC,UAA2G,CAAC,CAAC;IAE7G,MAAM,EACFC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACV,GAAGH;IAEJF,QAAQ,QAAQ,CAAC,QAAQ,CAACF;IAE1BE,QAAQ,aAAa,CAAC,eAAe,CAACC,oBAAoB;QAAEI;IAAQ,GAC/D,IAAI,CAACC,CAAAA;QACF,IAAIN,QAAQ,YAAY,EAAE;YACtB,IAAI,CAACR,UAAUA,CAACW,WAAW;gBACvB,MAAM,IAAII,MAAM;YACpB;YAEAJ,SAASH,SACJ,IAAI,CAAC;gBACF,IAAIA,QAAQ,YAAY,EAAE;oBACtBA,QAAQ,WAAW,GAAG,UAAU;gBACpC;YACJ,GACC,KAAK,CAAC,CAACQ;gBACJR,QAAQ,MAAM,CACT,QAAQ,CAAC,iDACT,SAAS,CAACQ,OACV,KAAK;YACd;QACR;QAEA,IAAIJ,SAAS;YACTE,QAAQ,OAAO,CAACE,CAAAA;gBACZJ,QAAQI;YACZ;QACJ;IACJ;AACR;AAEA,IAAIC,cAAc;AAElB,gCAAgC;AACzB,SAASC;IACZD,cAAc;AAClB;AAEO,SAASE,kBAAuDT,UAAqE,CAAC,CAAC;IAC1I,MAAM,EACFU,IAAI,EACJC,eAAe,EAAE,EACjBC,oBAAoB,EAAE,EACtBC,MAAM,EACNC,UAAU,EAAE,EACZC,oBAAoB,EACpBC,8BAA8B,EAC9BC,OAAO,EACPf,OAAO,EACV,GAAGF;IAEJ,IAAIO,aAAa;QACb,MAAM,IAAIF,MAAM;IACpB;IAEAE,cAAc;IAEd,IAAIM,QAAQ;QACRC,QAAQ,IAAI,CAACI,CAAAA,IAAK,IAAIzB,SAASA,CAACyB;IACpC;IAEA,MAAMpB,UAAU,IAAIJ,cAAcA,CAAC;QAC/BgB;QACAM;QACAC;QACA,SAAS;YACLC,CAAAA,IAAK,IAAI1B,0BAA0BA,CAAC0B,GAAG;oBACnC,WAAWH;gBACf;eACGD;SACN;IACL;IAEAnB,mBAAmBA,CAACG,SACf,KAAK,CAAC,CAACQ;QACJ,IAAIJ,SAAS;YACTA,QAAQI;QACZ;IACJ,GACC,OAAO,CAAC;QACLT,UACIC,SACA;eAAIc;eAAsBrB,wBAAwBA,CAACoB;SAAc,EACjEX;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.0.
|
|
4
|
+
"version": "16.0.1",
|
|
5
5
|
"description": "Helpers to facilitate the creation of an application with the Squide firefly technology stack.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -39,13 +39,19 @@
|
|
|
39
39
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
40
40
|
"react-router": "^7.9.6"
|
|
41
41
|
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"@opentelemetry/api": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
42
47
|
"dependencies": {
|
|
43
48
|
"@workleap-telemetry/core": "^1.0.4",
|
|
44
49
|
"@workleap/logging": "^1.3.2",
|
|
45
50
|
"uuid": "^13.0.0",
|
|
46
|
-
"@squide/
|
|
47
|
-
"@squide/msw": "4.0.
|
|
48
|
-
"@squide/react-router": "8.1.
|
|
51
|
+
"@squide/env-vars": "1.4.8",
|
|
52
|
+
"@squide/msw": "4.0.6",
|
|
53
|
+
"@squide/react-router": "8.1.5",
|
|
54
|
+
"@squide/core": "6.1.5"
|
|
49
55
|
},
|
|
50
56
|
"devDependencies": {
|
|
51
57
|
"@eslint/js": "9.39.1",
|
package/src/FireflyRuntime.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from "@squide/core";
|
|
2
|
-
import {
|
|
2
|
+
import { EnvironmentVariableKey, EnvironmentVariables, EnvironmentVariableValue, getEnvironmentVariablesPlugin } from "@squide/env-vars";
|
|
3
|
+
import { getMswPlugin, MswPluginName, MswState } from "@squide/msw";
|
|
3
4
|
import { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from "@squide/react-router";
|
|
4
5
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
5
6
|
import type { Logger } from "@workleap/logging";
|
|
@@ -16,8 +17,12 @@ export interface IFireflyRuntime extends IReactRouterRuntime {
|
|
|
16
17
|
getMswState(): MswState;
|
|
17
18
|
registerRequestHandlers: (handlers: RequestHandler[]) => void;
|
|
18
19
|
get requestHandlers(): RequestHandler[];
|
|
19
|
-
get appRouterStore(): AppRouterStore;
|
|
20
20
|
get isMswEnabled(): boolean;
|
|
21
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue): void;
|
|
22
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>): void;
|
|
23
|
+
getEnvironmentVariable(key: EnvironmentVariableKey): EnvironmentVariableValue;
|
|
24
|
+
getEnvironmentVariables(): EnvironmentVariables;
|
|
25
|
+
get appRouterStore(): AppRouterStore;
|
|
21
26
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient | undefined;
|
|
22
27
|
}
|
|
23
28
|
|
|
@@ -26,65 +31,81 @@ export class FireflyRuntime<TRuntime extends FireflyRuntime = any> extends React
|
|
|
26
31
|
protected _appRouterStore: AppRouterStore;
|
|
27
32
|
protected _honeycombInstrumentationClient: HoneycombInstrumentationPartialClient | undefined;
|
|
28
33
|
|
|
29
|
-
constructor(
|
|
34
|
+
constructor(options: FireflyRuntimeOptions = {}) {
|
|
35
|
+
const {
|
|
36
|
+
honeycombInstrumentationClient
|
|
37
|
+
} = options;
|
|
38
|
+
|
|
30
39
|
super(options);
|
|
31
40
|
|
|
32
41
|
this._appRouterStore = createAppRouterStore(this._logger);
|
|
33
42
|
this._honeycombInstrumentationClient = honeycombInstrumentationClient;
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!mswPlugin) {
|
|
40
|
-
throw new Error("[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
45
|
+
registerRoute(route: Route, options: RegisterRouteOptions = {}) {
|
|
46
|
+
if (this.moduleManager.getAreModulesRegistered()) {
|
|
47
|
+
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.");
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
|
|
50
|
+
super.registerRoute(route, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getMswState() {
|
|
54
|
+
const plugin = getMswPlugin(this);
|
|
55
|
+
|
|
56
|
+
return plugin.mswState;
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
|
|
47
60
|
const logger = this._getLogger(options);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
if (!mswPlugin) {
|
|
51
|
-
throw new Error("[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the \"useMsw\" option?");
|
|
52
|
-
}
|
|
61
|
+
const plugin = getMswPlugin(this);
|
|
53
62
|
|
|
54
63
|
if (this.moduleManager.getAreModulesRegistered()) {
|
|
55
64
|
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.");
|
|
56
65
|
}
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
plugin.registerRequestHandlers(handlers, {
|
|
59
68
|
logger
|
|
60
69
|
});
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
// Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
|
|
64
73
|
get requestHandlers(): RequestHandler[] {
|
|
65
|
-
const
|
|
74
|
+
const plugin = getMswPlugin(this);
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
76
|
+
return plugin.requestHandlers;
|
|
77
|
+
}
|
|
70
78
|
|
|
71
|
-
|
|
79
|
+
get isMswEnabled() {
|
|
80
|
+
return this._plugins.some(x => x.name === MswPluginName);
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
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.");
|
|
77
|
-
}
|
|
83
|
+
getEnvironmentVariable(key: EnvironmentVariableKey) {
|
|
84
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
78
85
|
|
|
79
|
-
|
|
86
|
+
return plugin.getVariable(key);
|
|
80
87
|
}
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
getEnvironmentVariables() {
|
|
90
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
91
|
+
|
|
92
|
+
return plugin.getVariables();
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue) {
|
|
96
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
97
|
+
|
|
98
|
+
return plugin.registerVariable(key, value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {
|
|
102
|
+
const plugin = getEnvironmentVariablesPlugin(this);
|
|
103
|
+
|
|
104
|
+
return plugin.registerVariables(variables);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get appRouterStore() {
|
|
108
|
+
return this._appRouterStore;
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
get honeycombInstrumentationClient() {
|
|
@@ -113,14 +134,30 @@ export class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntim
|
|
|
113
134
|
return this._runtime.requestHandlers;
|
|
114
135
|
}
|
|
115
136
|
|
|
116
|
-
get appRouterStore(): AppRouterStore {
|
|
117
|
-
throw new Error("[squide] Cannot retrieve the app router store from a runtime scope instance.");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
137
|
get isMswEnabled() {
|
|
121
138
|
return this._runtime.isMswEnabled;
|
|
122
139
|
}
|
|
123
140
|
|
|
141
|
+
getEnvironmentVariables() {
|
|
142
|
+
return this._runtime.getEnvironmentVariables();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getEnvironmentVariable(key: EnvironmentVariableKey) {
|
|
146
|
+
return this._runtime.getEnvironmentVariable(key);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
registerEnvironmentVariable(key: EnvironmentVariableKey, value: EnvironmentVariableValue) {
|
|
150
|
+
this._runtime.registerEnvironmentVariable(key, value);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
registerEnvironmentVariables(variables: Partial<EnvironmentVariables>) {
|
|
154
|
+
this._runtime.registerEnvironmentVariables(variables);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get appRouterStore(): AppRouterStore {
|
|
158
|
+
throw new Error("[squide] Cannot retrieve the app router store from a runtime scope instance.");
|
|
159
|
+
}
|
|
160
|
+
|
|
124
161
|
get honeycombInstrumentationClient(): HoneycombInstrumentationPartialClient {
|
|
125
162
|
throw new Error("[squide] Cannot retrieve the Honeycomb instrumentation client from a runtime scope instance.");
|
|
126
163
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
export * from "@squide/core";
|
|
2
|
-
export
|
|
2
|
+
export {
|
|
3
|
+
EnvironmentVariablesPlugin,
|
|
4
|
+
useEnvironmentVariable,
|
|
5
|
+
useEnvironmentVariables,
|
|
6
|
+
type EnvironmentVariableKey,
|
|
7
|
+
type EnvironmentVariables,
|
|
8
|
+
type EnvironmentVariablesPluginOptions,
|
|
9
|
+
type EnvironmentVariableValue
|
|
10
|
+
} from "@squide/env-vars";
|
|
11
|
+
export {
|
|
12
|
+
MswPlugin,
|
|
13
|
+
MswState,
|
|
14
|
+
type MswPluginOptions,
|
|
15
|
+
type MswPluginRegisterRequestHandlersOptions,
|
|
16
|
+
type MswReadyListener,
|
|
17
|
+
type MswStateOptions
|
|
18
|
+
} from "@squide/msw";
|
|
3
19
|
export * from "@squide/react-router";
|
|
4
20
|
|
|
5
21
|
export type { FireflyPlugin } from "./FireflyPlugin.ts";
|
package/src/initializeFirefly.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isFunction, ModuleDefinition, toLocalModuleDefinitions, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
|
|
2
|
+
import { EnvironmentVariables, EnvironmentVariablesPlugin } from "@squide/env-vars";
|
|
2
3
|
import { MswPlugin } from "@squide/msw";
|
|
3
4
|
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
4
5
|
import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
|
|
@@ -14,6 +15,7 @@ export interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TCont
|
|
|
14
15
|
localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];
|
|
15
16
|
moduleDefinitions?: ModuleDefinition<TRuntime, TContext, TData>[];
|
|
16
17
|
useMsw?: boolean;
|
|
18
|
+
environmentVariables?: Partial<EnvironmentVariables>;
|
|
17
19
|
honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
|
|
18
20
|
startMsw?: StartMswFunction<FireflyRuntime>;
|
|
19
21
|
onError?: OnInitializationErrorFunction;
|
|
@@ -75,6 +77,7 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
75
77
|
moduleDefinitions = [],
|
|
76
78
|
useMsw,
|
|
77
79
|
plugins = [],
|
|
80
|
+
environmentVariables,
|
|
78
81
|
honeycombInstrumentationClient,
|
|
79
82
|
loggers,
|
|
80
83
|
onError
|
|
@@ -94,7 +97,12 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
94
97
|
mode,
|
|
95
98
|
honeycombInstrumentationClient,
|
|
96
99
|
loggers,
|
|
97
|
-
plugins
|
|
100
|
+
plugins: [
|
|
101
|
+
x => new EnvironmentVariablesPlugin(x, {
|
|
102
|
+
variables: environmentVariables
|
|
103
|
+
}),
|
|
104
|
+
...plugins
|
|
105
|
+
]
|
|
98
106
|
});
|
|
99
107
|
|
|
100
108
|
initializeHoneycomb(runtime)
|