@squide/firefly 13.3.1 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/dist/AppRouterReducer.js +6 -15
- package/dist/AppRouterReducer.js.map +1 -1
- package/dist/AppRouterStore.d.ts +3 -3
- package/dist/AppRouterStore.js.map +1 -1
- package/dist/FireflyRuntime.d.ts +22 -5
- package/dist/FireflyRuntime.js +34 -11
- package/dist/FireflyRuntime.js.map +1 -1
- package/dist/honeycomb/activeSpan.d.ts +2 -2
- package/dist/honeycomb/activeSpan.js.map +1 -1
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +1 -1
- package/dist/honeycomb/registerHoneycombInstrumentation.js +153 -62
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/package.json +17 -17
- package/src/AppRouterReducer.ts +6 -21
- package/src/AppRouterStore.ts +4 -4
- package/src/FireflyRuntime.tsx +50 -12
- package/src/honeycomb/activeSpan.ts +2 -2
- package/src/honeycomb/registerHoneycombInstrumentation.ts +218 -61
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.1.0",
|
|
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": {
|
|
@@ -29,34 +29,34 @@
|
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@opentelemetry/api": "^1.9.0",
|
|
32
|
-
"@tanstack/react-query": "^5.
|
|
33
|
-
"msw": "^2.
|
|
32
|
+
"@tanstack/react-query": "^5.87.1",
|
|
33
|
+
"msw": "^2.11.1",
|
|
34
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
35
35
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
36
|
-
"react-router": "^7.
|
|
36
|
+
"react-router": "^7.8.2"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@workleap/logging": "^1.
|
|
40
|
-
"uuid": "^
|
|
41
|
-
"@squide/core": "
|
|
42
|
-
"@squide/module-federation": "
|
|
43
|
-
"@squide/
|
|
44
|
-
"@squide/
|
|
39
|
+
"@workleap/logging": "^1.3.0",
|
|
40
|
+
"uuid": "^12.0.0",
|
|
41
|
+
"@squide/core": "6.1.0",
|
|
42
|
+
"@squide/module-federation": "7.0.1",
|
|
43
|
+
"@squide/msw": "4.0.1",
|
|
44
|
+
"@squide/react-router": "8.1.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@rsbuild/core": "1.4
|
|
48
|
-
"@rslib/core": "0.
|
|
47
|
+
"@rsbuild/core": "1.5.4",
|
|
48
|
+
"@rslib/core": "0.12.4",
|
|
49
49
|
"@testing-library/react": "16.3.0",
|
|
50
|
-
"@types/react": "19.1.
|
|
51
|
-
"@types/react-dom": "19.1.
|
|
52
|
-
"@typescript-eslint/parser": "8.
|
|
53
|
-
"@vitejs/plugin-react": "
|
|
50
|
+
"@types/react": "19.1.12",
|
|
51
|
+
"@types/react-dom": "19.1.9",
|
|
52
|
+
"@typescript-eslint/parser": "8.42.0",
|
|
53
|
+
"@vitejs/plugin-react": "5.0.2",
|
|
54
54
|
"@workleap/eslint-plugin": "3.5.0",
|
|
55
55
|
"@workleap/rslib-configs": "1.1.0",
|
|
56
56
|
"@workleap/typescript-configs": "3.0.4",
|
|
57
57
|
"eslint": "8.57.0",
|
|
58
58
|
"happy-dom": "18.0.1",
|
|
59
|
-
"typescript": "5.
|
|
59
|
+
"typescript": "5.9.2",
|
|
60
60
|
"vitest": "3.2.4"
|
|
61
61
|
},
|
|
62
62
|
"sideEffects": false,
|
package/src/AppRouterReducer.ts
CHANGED
|
@@ -188,16 +188,11 @@ export function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue:
|
|
|
188
188
|
dispatch({ type: "modules-registered" });
|
|
189
189
|
|
|
190
190
|
logger
|
|
191
|
-
.withText("[squide]"
|
|
192
|
-
.withText("Modules are registered", {
|
|
191
|
+
.withText("[squide] Modules are registered.", {
|
|
193
192
|
style: {
|
|
194
|
-
color: "
|
|
195
|
-
backgroundColor: "green"
|
|
193
|
+
color: "green"
|
|
196
194
|
}
|
|
197
195
|
})
|
|
198
|
-
.withText(".", {
|
|
199
|
-
leadingSpace: false
|
|
200
|
-
})
|
|
201
196
|
.information();
|
|
202
197
|
|
|
203
198
|
return true;
|
|
@@ -211,16 +206,11 @@ export function useModuleRegistrationStatusDispatcher(areModulesRegisteredValue:
|
|
|
211
206
|
dispatch({ type: "modules-ready" });
|
|
212
207
|
|
|
213
208
|
logger
|
|
214
|
-
.withText("[squide]"
|
|
215
|
-
.withText("Modules are ready", {
|
|
209
|
+
.withText("[squide] Modules are ready.", {
|
|
216
210
|
style: {
|
|
217
|
-
color: "
|
|
218
|
-
backgroundColor: "green"
|
|
211
|
+
color: "green"
|
|
219
212
|
}
|
|
220
213
|
})
|
|
221
|
-
.withText(".", {
|
|
222
|
-
leadingSpace: false
|
|
223
|
-
})
|
|
224
214
|
.information();
|
|
225
215
|
|
|
226
216
|
return true;
|
|
@@ -258,16 +248,11 @@ export function useMswStatusDispatcher(isMswReadyValue: boolean, dispatch: AppRo
|
|
|
258
248
|
dispatch({ type: "msw-ready" });
|
|
259
249
|
|
|
260
250
|
logger
|
|
261
|
-
.withText("[squide]"
|
|
262
|
-
.withText("MSW is ready", {
|
|
251
|
+
.withText("[squide] MSW is ready.", {
|
|
263
252
|
style: {
|
|
264
|
-
color: "
|
|
265
|
-
backgroundColor: "green"
|
|
253
|
+
color: "green"
|
|
266
254
|
}
|
|
267
255
|
})
|
|
268
|
-
.withText(".", {
|
|
269
|
-
leadingSpace: false
|
|
270
|
-
})
|
|
271
256
|
.information();
|
|
272
257
|
|
|
273
258
|
return true;
|
package/src/AppRouterStore.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// access to the state and ease the integration with third-party libraries such as the Platform Widgets.
|
|
3
3
|
// Eventually, AppRouterReducer should be deprecated in favor of this new AppRouterStore.
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { Logger } from "@workleap/logging";
|
|
6
6
|
import type { AppRouterAction, AppRouterState } from "./AppRouterReducer.ts";
|
|
7
7
|
|
|
8
8
|
export type AppRouterStoreState = Omit<AppRouterState, "waitForMsw" | "waitForPublicData" | "waitForProtectedData">;
|
|
@@ -13,9 +13,9 @@ export class AppRouterStore {
|
|
|
13
13
|
#state: AppRouterStoreState;
|
|
14
14
|
|
|
15
15
|
readonly #listeners = new Set<AppRouterStoreListenerFunction>();
|
|
16
|
-
readonly #logger:
|
|
16
|
+
readonly #logger: Logger;
|
|
17
17
|
|
|
18
|
-
constructor(initialialState: AppRouterStoreState, logger:
|
|
18
|
+
constructor(initialialState: AppRouterStoreState, logger: Logger) {
|
|
19
19
|
this.#state = initialialState;
|
|
20
20
|
this.#logger = logger;
|
|
21
21
|
}
|
|
@@ -160,7 +160,7 @@ export class AppRouterStore {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export function createAppRouterStore(logger:
|
|
163
|
+
export function createAppRouterStore(logger: Logger) {
|
|
164
164
|
const initialState: AppRouterStoreState = {
|
|
165
165
|
areModulesRegistered: false,
|
|
166
166
|
areModulesReady: false,
|
package/src/FireflyRuntime.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { RegisterRouteOptions, RuntimeOptions } from "@squide/core";
|
|
1
|
+
import type { RegisterRouteOptions, RuntimeMethodOptions, RuntimeOptions } from "@squide/core";
|
|
2
2
|
import { MswPlugin, MswPluginName } from "@squide/msw";
|
|
3
|
-
import { ReactRouterRuntime, type Route } from "@squide/react-router";
|
|
3
|
+
import { type IReactRouterRuntime, ReactRouterRuntime, ReactRouterRuntimeScope, type Route } from "@squide/react-router";
|
|
4
|
+
import type { Logger } from "@workleap/logging";
|
|
4
5
|
import type { RequestHandler } from "msw";
|
|
5
6
|
import { getAreModulesRegistered } from "./AppRouterReducer.ts";
|
|
6
7
|
import { type AppRouterStore, createAppRouterStore } from "./AppRouterStore.ts";
|
|
@@ -9,9 +10,18 @@ export interface FireflyRuntimeOptions extends RuntimeOptions {
|
|
|
9
10
|
useMsw?: boolean;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export interface RegisterRequestHandlersOptions extends RuntimeMethodOptions {}
|
|
14
|
+
|
|
15
|
+
export interface IFireflyRuntime extends IReactRouterRuntime {
|
|
16
|
+
registerRequestHandlers: (handlers: RequestHandler[]) => void;
|
|
17
|
+
get requestHandlers(): RequestHandler[];
|
|
18
|
+
get appRouterStore(): AppRouterStore;
|
|
19
|
+
get isMswEnabled(): boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class FireflyRuntime extends ReactRouterRuntime implements IFireflyRuntime {
|
|
23
|
+
protected _appRouterStore: AppRouterStore;
|
|
24
|
+
protected _useMsw: boolean;
|
|
15
25
|
|
|
16
26
|
constructor({ plugins, useMsw, ...options }: FireflyRuntimeOptions = {}) {
|
|
17
27
|
if (useMsw) {
|
|
@@ -23,20 +33,21 @@ export class FireflyRuntime extends ReactRouterRuntime {
|
|
|
23
33
|
...options
|
|
24
34
|
});
|
|
25
35
|
|
|
26
|
-
this
|
|
36
|
+
this._useMsw = true;
|
|
27
37
|
} else {
|
|
28
38
|
super({
|
|
29
39
|
plugins,
|
|
30
40
|
...options
|
|
31
41
|
});
|
|
32
42
|
|
|
33
|
-
this
|
|
43
|
+
this._useMsw = false;
|
|
34
44
|
}
|
|
35
45
|
|
|
36
|
-
this
|
|
46
|
+
this._appRouterStore = createAppRouterStore(this._logger);
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
registerRequestHandlers(handlers: RequestHandler[]) {
|
|
49
|
+
registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
|
|
50
|
+
const logger = this._getLogger(options);
|
|
40
51
|
const mswPlugin = this.getPlugin(MswPluginName) as MswPlugin;
|
|
41
52
|
|
|
42
53
|
if (!mswPlugin) {
|
|
@@ -47,7 +58,9 @@ export class FireflyRuntime extends ReactRouterRuntime {
|
|
|
47
58
|
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.");
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
mswPlugin.registerRequestHandlers(handlers
|
|
61
|
+
mswPlugin.registerRequestHandlers(handlers, {
|
|
62
|
+
logger
|
|
63
|
+
});
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
// Must define a return type otherwise we get an "error TS2742: The inferred type of 'requestHandlers' cannot be named" error.
|
|
@@ -70,10 +83,35 @@ export class FireflyRuntime extends ReactRouterRuntime {
|
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
get appRouterStore() {
|
|
73
|
-
return this
|
|
86
|
+
return this._appRouterStore;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get isMswEnabled() {
|
|
90
|
+
return this._useMsw;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
startScope(logger: Logger): FireflyRuntime {
|
|
94
|
+
return (new FireflyRuntimeScope(this, logger) as unknown) as FireflyRuntime;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class FireflyRuntimeScope<TRuntime extends FireflyRuntime = FireflyRuntime> extends ReactRouterRuntimeScope<TRuntime> implements IFireflyRuntime {
|
|
99
|
+
registerRequestHandlers(handlers: RequestHandler[], options: RegisterRequestHandlersOptions = {}) {
|
|
100
|
+
this._runtime.registerRequestHandlers(handlers, {
|
|
101
|
+
...options,
|
|
102
|
+
logger: this._getLogger(options)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get requestHandlers(): RequestHandler[] {
|
|
107
|
+
return this._runtime.requestHandlers;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get appRouterStore() {
|
|
111
|
+
return this._runtime.appRouterStore;
|
|
74
112
|
}
|
|
75
113
|
|
|
76
114
|
get isMswEnabled() {
|
|
77
|
-
return this
|
|
115
|
+
return this._runtime.isMswEnabled;
|
|
78
116
|
}
|
|
79
117
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Span } from "@opentelemetry/api";
|
|
2
2
|
import { isPlainObject } from "@squide/core";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Logger } from "@workleap/logging";
|
|
4
4
|
import { v4 as uuidv4 } from "uuid";
|
|
5
5
|
import { createTraceContextId } from "./createTraceContextId.ts";
|
|
6
6
|
|
|
@@ -97,7 +97,7 @@ export function popActiveSpan(span: ActiveSpan) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export function createOverrideFetchRequestSpanWithActiveSpanContext(logger:
|
|
100
|
+
export function createOverrideFetchRequestSpanWithActiveSpanContext(logger: Logger) {
|
|
101
101
|
return (span: Span, request: Request | RequestInit) => {
|
|
102
102
|
const activeSpan = getActiveSpan();
|
|
103
103
|
|