@squide/firefly-rsbuild-storybook 1.0.2 → 1.0.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-rsbuild-storybook
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`992dd28`](https://github.com/workleap/wl-squide/commit/992dd28ce8aa03559c556f24df4ebc9c3129c943)]:
8
+ - @squide/firefly@16.1.4
9
+ - @squide/env-vars@1.4.12
10
+ - @squide/launch-darkly@1.0.3
11
+ - @squide/msw@4.0.10
12
+
13
+ ## 1.0.3
14
+
15
+ ### Patch Changes
16
+
17
+ - [#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 an initialization log and now accept optional loggers.
18
+
19
+ - Updated dependencies [[`b114284`](https://github.com/workleap/wl-squide/commit/b114284529ff87e719d594d9612a52b1935a0bb2)]:
20
+ - @squide/firefly@16.1.3
21
+
3
22
  ## 1.0.2
4
23
 
5
24
  ### Patch Changes
@@ -1,5 +1,6 @@
1
1
  import { EnvironmentVariables } from "@squide/env-vars";
2
2
  import { FireflyRuntime, ModuleRegisterFunction } from "@squide/firefly";
3
+ import { RootLogger } from "@workleap/logging";
3
4
  import { LDClient, LDFlagValue } from "launchdarkly-js-client-sdk";
4
5
  import { StorybookRuntime } from "./StorybookRuntime.ts";
5
6
  export interface InitializeFireflyForStorybookOptions {
@@ -7,5 +8,6 @@ export interface InitializeFireflyForStorybookOptions {
7
8
  environmentVariables?: EnvironmentVariables;
8
9
  featureFlags?: Map<string, LDFlagValue> | Record<string, LDFlagValue>;
9
10
  launchDarklyClient?: LDClient;
11
+ loggers?: RootLogger[];
10
12
  }
11
13
  export declare function initializeFireflyForStorybook(options?: InitializeFireflyForStorybookOptions): Promise<StorybookRuntime>;
@@ -16,21 +16,49 @@ import { StorybookRuntime } from "./StorybookRuntime.js";
16
16
 
17
17
 
18
18
 
19
+ function logInitializationState(runtime, options, plugins) {
20
+ const { localModules, environmentVariables, featureFlags, launchDarklyClient } = options;
21
+ const scope = runtime.logger.startScope("[squide] Initializing the application.");
22
+ try {
23
+ scope.information("[squide] Mode: development");
24
+ if (localModules) {
25
+ scope.withText("[squide] Local modules:").withObject(localModules).information();
26
+ }
27
+ scope.information("[squide] Use MSW: Yes");
28
+ if (environmentVariables && Object.keys(environmentVariables).length > 0) {
29
+ scope.withText("[squide] Environment variables:").withObject(environmentVariables).information();
30
+ }
31
+ if (featureFlags) {
32
+ scope.withText("[squide] Feature flags:").withObject(featureFlags).information();
33
+ }
34
+ if (launchDarklyClient) {
35
+ scope.withText("[squide] LaunchDarkly client:").withObject(launchDarklyClient).information();
36
+ }
37
+ if (plugins.length > 0) {
38
+ scope.withText("[squide] Plugins:").withObject(plugins).information();
39
+ }
40
+ } finally{
41
+ scope.end();
42
+ }
43
+ }
19
44
  async function initializeFireflyForStorybook(options = {}) {
20
- const { localModules, environmentVariables, featureFlags = {}, launchDarklyClient } = options;
45
+ const { localModules, environmentVariables, featureFlags = {}, launchDarklyClient, loggers } = options;
46
+ const plugins = [
47
+ (x)=>new MswPlugin(x),
48
+ (x)=>new EnvironmentVariablesPlugin(x, {
49
+ variables: environmentVariables
50
+ }),
51
+ (x)=>new LaunchDarklyPlugin(x, // 1- If no client is provided create it.
52
+ // 2- If feature flags are provided and it's an instance of Map, use the argument.
53
+ // 3- If feature flags are provided (or the default value) and it's an object literal, convert the object to a Map instance.
54
+ launchDarklyClient ?? new InMemoryLaunchDarklyClient(featureFlags instanceof Map ? featureFlags : new Map(Object.entries(featureFlags))))
55
+ ];
21
56
  const runtime = new StorybookRuntime({
22
57
  mode: "development",
23
- plugins: [
24
- (x)=>new MswPlugin(x),
25
- (x)=>new EnvironmentVariablesPlugin(x, {
26
- variables: environmentVariables
27
- }),
28
- (x)=>new LaunchDarklyPlugin(x, // 1- If no client is provided create it.
29
- // 2- If feature flags are provided and it's an instance of Map, use the argument.
30
- // 3- If feature flags are provided (or the default value) and it's an object literal, convert the object to a Map instance.
31
- launchDarklyClient ?? new InMemoryLaunchDarklyClient(featureFlags instanceof Map ? featureFlags : new Map(Object.entries(featureFlags))))
32
- ]
58
+ plugins,
59
+ loggers
33
60
  });
61
+ logInitializationState(runtime, options, plugins);
34
62
  if (localModules && localModules.length > 0) {
35
63
  await runtime.moduleManager.registerModules([
36
64
  ...toLocalModuleDefinitions(localModules)
@@ -1 +1 @@
1
- {"version":3,"file":"initializeFireflyForStorybook.js","sources":["../src/initializeFireflyForStorybook.ts"],"sourcesContent":["import { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { FireflyRuntime, InMemoryLaunchDarklyClient, LaunchDarklyPlugin, ModuleRegisterFunction, toLocalModuleDefinitions } from \"@squide/firefly\";\nimport { MswPlugin } from \"@squide/msw\";\nimport { LDClient, LDFlagValue } from \"launchdarkly-js-client-sdk\";\nimport { StorybookRuntime } from \"./StorybookRuntime.ts\";\n\nexport interface InitializeFireflyForStorybookOptions {\n localModules?: ModuleRegisterFunction<FireflyRuntime>[];\n environmentVariables?: EnvironmentVariables;\n featureFlags?: Map<string, LDFlagValue> | Record<string, LDFlagValue>;\n launchDarklyClient?: LDClient;\n}\n\nexport async function initializeFireflyForStorybook(options: InitializeFireflyForStorybookOptions = {}) {\n const {\n localModules,\n environmentVariables,\n featureFlags = {},\n launchDarklyClient\n } = options;\n\n const runtime = new StorybookRuntime({\n mode: \"development\",\n plugins: [\n x => new MswPlugin(x),\n x => new EnvironmentVariablesPlugin(x, {\n variables: environmentVariables\n }),\n x => new LaunchDarklyPlugin(\n x,\n // 1- If no client is provided create it.\n // 2- If feature flags are provided and it's an instance of Map, use the argument.\n // 3- If feature flags are provided (or the default value) and it's an object literal, convert the object to a Map instance.\n launchDarklyClient ?? new InMemoryLaunchDarklyClient(featureFlags instanceof Map\n ? featureFlags\n : new Map<string, LDFlagValue>(Object.entries(featureFlags))\n )\n )\n ]\n });\n\n if (localModules && localModules.length > 0) {\n await runtime.moduleManager.registerModules([\n ...toLocalModuleDefinitions(localModules)\n ]);\n }\n\n return runtime;\n}\n"],"names":["EnvironmentVariablesPlugin","InMemoryLaunchDarklyClient","LaunchDarklyPlugin","toLocalModuleDefinitions","MswPlugin","StorybookRuntime","initializeFireflyForStorybook","options","localModules","environmentVariables","featureFlags","launchDarklyClient","runtime","x","Map","Object"],"mappings":";;;;;;;;;;;;;;AAAoF;AAC+D;AAC3G;AAEiB;AASlD,eAAeM,8BAA8BC,UAAgD,CAAC,CAAC;IAClG,MAAM,EACFC,YAAY,EACZC,oBAAoB,EACpBC,eAAe,CAAC,CAAC,EACjBC,kBAAkB,EACrB,GAAGJ;IAEJ,MAAMK,UAAU,IAAIP,gBAAgBA,CAAC;QACjC,MAAM;QACN,SAAS;YACLQ,CAAAA,IAAK,IAAIT,SAASA,CAACS;YACnBA,CAAAA,IAAK,IAAIb,0BAA0BA,CAACa,GAAG;oBACnC,WAAWJ;gBACf;YACAI,CAAAA,IAAK,IAAIX,kBAAkBA,CACvBW,GACA,yCAAyC;gBACzC,kFAAkF;gBAClF,4HAA4H;gBAC5HF,sBAAsB,IAAIV,0BAA0BA,CAACS,wBAAwBI,MACvEJ,eACA,IAAII,IAAyBC,OAAO,OAAO,CAACL;SAGzD;IACL;IAEA,IAAIF,gBAAgBA,aAAa,MAAM,GAAG,GAAG;QACzC,MAAMI,QAAQ,aAAa,CAAC,eAAe,CAAC;eACrCT,wBAAwBA,CAACK;SAC/B;IACL;IAEA,OAAOI;AACX"}
1
+ {"version":3,"file":"initializeFireflyForStorybook.js","sources":["../src/initializeFireflyForStorybook.ts"],"sourcesContent":["import { EnvironmentVariables, EnvironmentVariablesPlugin } from \"@squide/env-vars\";\nimport { FireflyRuntime, InMemoryLaunchDarklyClient, LaunchDarklyPlugin, ModuleRegisterFunction, PluginFactory, toLocalModuleDefinitions } from \"@squide/firefly\";\nimport { MswPlugin } from \"@squide/msw\";\nimport { RootLogger } from \"@workleap/logging\";\nimport { LDClient, LDFlagValue } from \"launchdarkly-js-client-sdk\";\nimport { StorybookRuntime } from \"./StorybookRuntime.ts\";\n\nexport interface InitializeFireflyForStorybookOptions {\n localModules?: ModuleRegisterFunction<FireflyRuntime>[];\n environmentVariables?: EnvironmentVariables;\n featureFlags?: Map<string, LDFlagValue> | Record<string, LDFlagValue>;\n launchDarklyClient?: LDClient;\n loggers?: RootLogger[];\n}\n\nfunction logInitializationState(\n runtime: FireflyRuntime,\n options: InitializeFireflyForStorybookOptions,\n plugins: PluginFactory<FireflyRuntime>[]\n) {\n const {\n localModules,\n environmentVariables,\n featureFlags,\n launchDarklyClient\n } = options;\n const scope = (runtime.logger as RootLogger).startScope(\"[squide] Initializing the application.\");\n\n try {\n scope.information(\"[squide] Mode: development\");\n\n if (localModules) {\n scope\n .withText(\"[squide] Local modules:\")\n .withObject(localModules)\n .information();\n }\n\n scope.information(\"[squide] Use MSW: Yes\");\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 (featureFlags) {\n scope\n .withText(\"[squide] Feature flags:\")\n .withObject(featureFlags)\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\nexport async function initializeFireflyForStorybook(options: InitializeFireflyForStorybookOptions = {}) {\n const {\n localModules,\n environmentVariables,\n featureFlags = {},\n launchDarklyClient,\n loggers\n } = options;\n\n const plugins: PluginFactory<FireflyRuntime>[] = [\n x => new MswPlugin(x),\n x => new EnvironmentVariablesPlugin(x, {\n variables: environmentVariables\n }),\n x => new LaunchDarklyPlugin(\n x,\n // 1- If no client is provided create it.\n // 2- If feature flags are provided and it's an instance of Map, use the argument.\n // 3- If feature flags are provided (or the default value) and it's an object literal, convert the object to a Map instance.\n launchDarklyClient ?? new InMemoryLaunchDarklyClient(featureFlags instanceof Map\n ? featureFlags\n : new Map<string, LDFlagValue>(Object.entries(featureFlags))\n )\n )\n ];\n\n const runtime = new StorybookRuntime({\n mode: \"development\",\n plugins,\n loggers\n });\n\n logInitializationState(runtime, options, plugins);\n\n if (localModules && localModules.length > 0) {\n await runtime.moduleManager.registerModules([\n ...toLocalModuleDefinitions(localModules)\n ]);\n }\n\n return runtime;\n}\n"],"names":["EnvironmentVariablesPlugin","InMemoryLaunchDarklyClient","LaunchDarklyPlugin","toLocalModuleDefinitions","MswPlugin","StorybookRuntime","logInitializationState","runtime","options","plugins","localModules","environmentVariables","featureFlags","launchDarklyClient","scope","Object","initializeFireflyForStorybook","loggers","x","Map"],"mappings":";;;;;;;;;;;;;;AAAoF;AAC8E;AAC1H;AAGiB;AAUzD,SAASM,uBACLC,OAAuB,EACvBC,OAA6C,EAC7CC,OAAwC;IAExC,MAAM,EACFC,YAAY,EACZC,oBAAoB,EACpBC,YAAY,EACZC,kBAAkB,EACrB,GAAGL;IACJ,MAAMM,QAASP,QAAQ,MAAM,CAAgB,UAAU,CAAC;IAExD,IAAI;QACAO,MAAM,WAAW,CAAC;QAElB,IAAIJ,cAAc;YACdI,MACK,QAAQ,CAAC,2BACT,UAAU,CAACJ,cACX,WAAW;QACpB;QAEAI,MAAM,WAAW,CAAC;QAElB,IAAIH,wBAAwBI,OAAO,IAAI,CAACJ,sBAAsB,MAAM,GAAG,GAAG;YACtEG,MACK,QAAQ,CAAC,mCACT,UAAU,CAACH,sBACX,WAAW;QACpB;QAEA,IAAIC,cAAc;YACdE,MACK,QAAQ,CAAC,2BACT,UAAU,CAACF,cACX,WAAW;QACpB;QAEA,IAAIC,oBAAoB;YACpBC,MACK,QAAQ,CAAC,iCACT,UAAU,CAACD,oBACX,WAAW;QACpB;QAEA,IAAIJ,QAAQ,MAAM,GAAG,GAAG;YACpBK,MACK,QAAQ,CAAC,qBACT,UAAU,CAACL,SACX,WAAW;QACpB;IACJ,SAAU;QACNK,MAAM,GAAG;IACb;AACJ;AAEO,eAAeE,8BAA8BR,UAAgD,CAAC,CAAC;IAClG,MAAM,EACFE,YAAY,EACZC,oBAAoB,EACpBC,eAAe,CAAC,CAAC,EACjBC,kBAAkB,EAClBI,OAAO,EACV,GAAGT;IAEJ,MAAMC,UAA2C;QAC7CS,CAAAA,IAAK,IAAId,SAASA,CAACc;QACnBA,CAAAA,IAAK,IAAIlB,0BAA0BA,CAACkB,GAAG;gBACnC,WAAWP;YACf;QACAO,CAAAA,IAAK,IAAIhB,kBAAkBA,CACvBgB,GACA,yCAAyC;YACzC,kFAAkF;YAClF,4HAA4H;YAC5HL,sBAAsB,IAAIZ,0BAA0BA,CAACW,wBAAwBO,MACvEP,eACA,IAAIO,IAAyBJ,OAAO,OAAO,CAACH;KAGzD;IAED,MAAML,UAAU,IAAIF,gBAAgBA,CAAC;QACjC,MAAM;QACNI;QACAQ;IACJ;IAEAX,uBAAuBC,SAASC,SAASC;IAEzC,IAAIC,gBAAgBA,aAAa,MAAM,GAAG,GAAG;QACzC,MAAMH,QAAQ,aAAa,CAAC,eAAe,CAAC;eACrCJ,wBAAwBA,CAACO;SAC/B;IACL;IAEA,OAAOH;AACX"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly-rsbuild-storybook",
3
3
  "author": "Workleap",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "description": "Squide firefly helpers for Storybook and Rsbuild.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -46,10 +46,10 @@
46
46
  "dependencies": {
47
47
  "@workleap-telemetry/core": "^1.0.6",
48
48
  "@workleap/logging": "^1.3.3",
49
- "@squide/env-vars": "1.4.11",
50
- "@squide/firefly": "16.1.2",
51
- "@squide/launch-darkly": "1.0.2",
52
- "@squide/msw": "4.0.9"
49
+ "@squide/env-vars": "1.4.12",
50
+ "@squide/firefly": "16.1.4",
51
+ "@squide/launch-darkly": "1.0.3",
52
+ "@squide/msw": "4.0.10"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@eslint/js": "9.39.1",
@@ -1,6 +1,7 @@
1
1
  import { EnvironmentVariables, EnvironmentVariablesPlugin } from "@squide/env-vars";
2
- import { FireflyRuntime, InMemoryLaunchDarklyClient, LaunchDarklyPlugin, ModuleRegisterFunction, toLocalModuleDefinitions } from "@squide/firefly";
2
+ import { FireflyRuntime, InMemoryLaunchDarklyClient, LaunchDarklyPlugin, ModuleRegisterFunction, PluginFactory, toLocalModuleDefinitions } from "@squide/firefly";
3
3
  import { MswPlugin } from "@squide/msw";
4
+ import { RootLogger } from "@workleap/logging";
4
5
  import { LDClient, LDFlagValue } from "launchdarkly-js-client-sdk";
5
6
  import { StorybookRuntime } from "./StorybookRuntime.ts";
6
7
 
@@ -9,6 +10,64 @@ export interface InitializeFireflyForStorybookOptions {
9
10
  environmentVariables?: EnvironmentVariables;
10
11
  featureFlags?: Map<string, LDFlagValue> | Record<string, LDFlagValue>;
11
12
  launchDarklyClient?: LDClient;
13
+ loggers?: RootLogger[];
14
+ }
15
+
16
+ function logInitializationState(
17
+ runtime: FireflyRuntime,
18
+ options: InitializeFireflyForStorybookOptions,
19
+ plugins: PluginFactory<FireflyRuntime>[]
20
+ ) {
21
+ const {
22
+ localModules,
23
+ environmentVariables,
24
+ featureFlags,
25
+ launchDarklyClient
26
+ } = options;
27
+ const scope = (runtime.logger as RootLogger).startScope("[squide] Initializing the application.");
28
+
29
+ try {
30
+ scope.information("[squide] Mode: development");
31
+
32
+ if (localModules) {
33
+ scope
34
+ .withText("[squide] Local modules:")
35
+ .withObject(localModules)
36
+ .information();
37
+ }
38
+
39
+ scope.information("[squide] Use MSW: Yes");
40
+
41
+ if (environmentVariables && Object.keys(environmentVariables).length > 0) {
42
+ scope
43
+ .withText("[squide] Environment variables:")
44
+ .withObject(environmentVariables)
45
+ .information();
46
+ }
47
+
48
+ if (featureFlags) {
49
+ scope
50
+ .withText("[squide] Feature flags:")
51
+ .withObject(featureFlags)
52
+ .information();
53
+ }
54
+
55
+ if (launchDarklyClient) {
56
+ scope
57
+ .withText("[squide] LaunchDarkly client:")
58
+ .withObject(launchDarklyClient)
59
+ .information();
60
+ }
61
+
62
+ if (plugins.length > 0) {
63
+ scope
64
+ .withText("[squide] Plugins:")
65
+ .withObject(plugins)
66
+ .information();
67
+ }
68
+ } finally {
69
+ scope.end();
70
+ }
12
71
  }
13
72
 
14
73
  export async function initializeFireflyForStorybook(options: InitializeFireflyForStorybookOptions = {}) {
@@ -16,29 +75,35 @@ export async function initializeFireflyForStorybook(options: InitializeFireflyFo
16
75
  localModules,
17
76
  environmentVariables,
18
77
  featureFlags = {},
19
- launchDarklyClient
78
+ launchDarklyClient,
79
+ loggers
20
80
  } = options;
21
81
 
82
+ const plugins: PluginFactory<FireflyRuntime>[] = [
83
+ x => new MswPlugin(x),
84
+ x => new EnvironmentVariablesPlugin(x, {
85
+ variables: environmentVariables
86
+ }),
87
+ x => new LaunchDarklyPlugin(
88
+ x,
89
+ // 1- If no client is provided create it.
90
+ // 2- If feature flags are provided and it's an instance of Map, use the argument.
91
+ // 3- If feature flags are provided (or the default value) and it's an object literal, convert the object to a Map instance.
92
+ launchDarklyClient ?? new InMemoryLaunchDarklyClient(featureFlags instanceof Map
93
+ ? featureFlags
94
+ : new Map<string, LDFlagValue>(Object.entries(featureFlags))
95
+ )
96
+ )
97
+ ];
98
+
22
99
  const runtime = new StorybookRuntime({
23
100
  mode: "development",
24
- plugins: [
25
- x => new MswPlugin(x),
26
- x => new EnvironmentVariablesPlugin(x, {
27
- variables: environmentVariables
28
- }),
29
- x => new LaunchDarklyPlugin(
30
- x,
31
- // 1- If no client is provided create it.
32
- // 2- If feature flags are provided and it's an instance of Map, use the argument.
33
- // 3- If feature flags are provided (or the default value) and it's an object literal, convert the object to a Map instance.
34
- launchDarklyClient ?? new InMemoryLaunchDarklyClient(featureFlags instanceof Map
35
- ? featureFlags
36
- : new Map<string, LDFlagValue>(Object.entries(featureFlags))
37
- )
38
- )
39
- ]
101
+ plugins,
102
+ loggers
40
103
  });
41
104
 
105
+ logInitializationState(runtime, options, plugins);
106
+
42
107
  if (localModules && localModules.length > 0) {
43
108
  await runtime.moduleManager.registerModules([
44
109
  ...toLocalModuleDefinitions(localModules)