@servicetitan/web-components 40.3.0 → 40.4.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.
Files changed (48) hide show
  1. package/dist/common.d.ts +22 -6
  2. package/dist/common.d.ts.map +1 -1
  3. package/dist/common.js +7 -2
  4. package/dist/common.js.map +1 -1
  5. package/dist/globals.d.ts +9 -7
  6. package/dist/globals.d.ts.map +1 -1
  7. package/dist/globals.js +17 -6
  8. package/dist/globals.js.map +1 -1
  9. package/dist/loader.d.ts.map +1 -1
  10. package/dist/loader.js +22 -23
  11. package/dist/loader.js.map +1 -1
  12. package/dist/register.d.ts.map +1 -1
  13. package/dist/register.js +28 -5
  14. package/dist/register.js.map +1 -1
  15. package/dist/use-host-shared-dependencies.d.ts +7 -0
  16. package/dist/use-host-shared-dependencies.d.ts.map +1 -0
  17. package/dist/use-host-shared-dependencies.js +17 -0
  18. package/dist/use-host-shared-dependencies.js.map +1 -0
  19. package/dist/use-prefetch.d.ts.map +1 -1
  20. package/dist/use-prefetch.js +7 -8
  21. package/dist/use-prefetch.js.map +1 -1
  22. package/dist/utils/get-bundle-info.d.ts +6 -5
  23. package/dist/utils/get-bundle-info.d.ts.map +1 -1
  24. package/dist/utils/get-bundle-info.js +3 -3
  25. package/dist/utils/get-bundle-info.js.map +1 -1
  26. package/dist/utils/get-mfe-has-compatible-launchdarkly-version.d.ts +6 -6
  27. package/dist/utils/get-mfe-has-compatible-launchdarkly-version.d.ts.map +1 -1
  28. package/dist/utils/get-mfe-has-compatible-launchdarkly-version.js +7 -7
  29. package/dist/utils/get-mfe-has-compatible-launchdarkly-version.js.map +1 -1
  30. package/dist/utils/validate-bundle-info.d.ts +5 -5
  31. package/dist/utils/validate-bundle-info.d.ts.map +1 -1
  32. package/dist/utils/validate-bundle-info.js +6 -5
  33. package/dist/utils/validate-bundle-info.js.map +1 -1
  34. package/dist/utils/web-component.d.ts +4 -4
  35. package/dist/utils/web-component.d.ts.map +1 -1
  36. package/dist/utils/web-component.js +14 -9
  37. package/dist/utils/web-component.js.map +1 -1
  38. package/package.json +9 -9
  39. package/src/common.ts +27 -6
  40. package/src/globals.ts +26 -8
  41. package/src/loader.tsx +27 -35
  42. package/src/register.tsx +34 -7
  43. package/src/use-host-shared-dependencies.ts +26 -0
  44. package/src/use-prefetch.ts +6 -12
  45. package/src/utils/get-bundle-info.ts +9 -8
  46. package/src/utils/get-mfe-has-compatible-launchdarkly-version.ts +7 -7
  47. package/src/utils/validate-bundle-info.ts +9 -8
  48. package/src/utils/web-component.tsx +19 -13
package/src/globals.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
2
  // eslint-disable-next-line spaced-comment
3
3
  /// <reference types="vite/client" /> — provides types for import.meta.env
4
- import { ExposedDependencies } from '@servicetitan/startup-utils';
5
- import { ExposedInstanceDependencies } from './common';
4
+ import { SharedDependencies } from '@servicetitan/startup-utils';
5
+ import { SharedInstanceDependencies } from './common';
6
6
 
7
7
  declare global {
8
- export const EXPOSED_DEPENDENCIES: ExposedDependencies | undefined;
9
- export const EXPOSED_INSTANCE_DEPENDENCIES: ExposedInstanceDependencies | undefined;
8
+ export const SHARED_DEPENDENCIES: SharedDependencies | undefined;
9
+ export const SHARED_INSTANCE_DEPENDENCIES: SharedInstanceDependencies | undefined;
10
+ export const EXPOSED_DEPENDENCIES: SharedDependencies | undefined;
11
+ export const EXPOSED_INSTANCE_DEPENDENCIES: SharedInstanceDependencies | undefined;
10
12
  export const WEB_COMPONENT_NAME: string | undefined;
11
13
  }
12
14
 
@@ -25,7 +27,17 @@ function get<T>(fetch: () => T) {
25
27
  }
26
28
  }
27
29
 
28
- const _EXPOSED_DEPENDENCIES =
30
+ /*
31
+ * The EXPOSED_* fallbacks keep hosts working when they are built with a version of
32
+ * startup that predates the SHARED_* names.
33
+ */
34
+ const _SHARED_DEPENDENCIES =
35
+ get(() => {
36
+ return SHARED_DEPENDENCIES;
37
+ }) ??
38
+ get(() => {
39
+ return import.meta.env.SHARED_DEPENDENCIES;
40
+ }) ??
29
41
  get(() => {
30
42
  return EXPOSED_DEPENDENCIES;
31
43
  }) ??
@@ -40,7 +52,13 @@ const _WEB_COMPONENT_NAME =
40
52
  get(() => {
41
53
  return import.meta.env.WEB_COMPONENT_NAME;
42
54
  });
43
- const _EXPOSED_INSTANCE_DEPENDENCIES =
55
+ const _SHARED_INSTANCE_DEPENDENCIES =
56
+ get(() => {
57
+ return SHARED_INSTANCE_DEPENDENCIES;
58
+ }) ??
59
+ get(() => {
60
+ return import.meta.env.SHARED_INSTANCE_DEPENDENCIES;
61
+ }) ??
44
62
  get(() => {
45
63
  return EXPOSED_INSTANCE_DEPENDENCIES;
46
64
  }) ??
@@ -49,7 +67,7 @@ const _EXPOSED_INSTANCE_DEPENDENCIES =
49
67
  });
50
68
 
51
69
  export {
52
- _EXPOSED_DEPENDENCIES as EXPOSED_DEPENDENCIES,
53
- _EXPOSED_INSTANCE_DEPENDENCIES as EXPOSED_INSTANCE_DEPENDENCIES,
70
+ _SHARED_DEPENDENCIES as SHARED_DEPENDENCIES,
71
+ _SHARED_INSTANCE_DEPENDENCIES as SHARED_INSTANCE_DEPENDENCIES,
54
72
  _WEB_COMPONENT_NAME as WEB_COMPONENT_NAME,
55
73
  };
package/src/loader.tsx CHANGED
@@ -2,7 +2,7 @@ import { ErrorBoundary } from '@servicetitan/error-boundary';
2
2
  import { type LDService } from '@servicetitan/launchdarkly-service';
3
3
  import { Log } from '@servicetitan/log-service';
4
4
  import { useOptionalDependencies } from '@servicetitan/react-ioc';
5
- import { ExposedDependencies } from '@servicetitan/startup-utils';
5
+ import { SharedDependencies } from '@servicetitan/startup-utils';
6
6
  import {
7
7
  ReactElement,
8
8
  ReactNode,
@@ -14,16 +14,11 @@ import {
14
14
  useMemo,
15
15
  useRef,
16
16
  } from 'react';
17
- import {
18
- EXPOSED_DEPENDENCIES_TOKEN,
19
- EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
20
- ExposedInstanceDependencies,
21
- GetJsonError,
22
- } from './common';
17
+ import { GetJsonError, SharedInstanceDependencies } from './common';
23
18
  import { MFEContextData } from './contexts/mfe-data-context';
24
19
  import { Delayed } from './delayed';
25
20
  import { EVENT_BUS_TOKEN, EventBus } from './event-bus';
26
- import { EXPOSED_DEPENDENCIES, EXPOSED_INSTANCE_DEPENDENCIES } from './globals';
21
+ import { useHostSharedDependencies } from './use-host-shared-dependencies';
27
22
  import {
28
23
  getBundleInfo,
29
24
  getLDServiceToken,
@@ -76,11 +71,8 @@ const UnrestrictedLoader = <T,>(props: UnrestrictedLoaderProps<T>, ref: Ref<Load
76
71
  const { loadingFallback, loadingFallbackDelayed = true } = props;
77
72
 
78
73
  const bus = useEventBus();
79
- const [logService, exposedDependencies = EXPOSED_DEPENDENCIES, eventBus = bus] =
80
- useOptionalDependencies(Log, EXPOSED_DEPENDENCIES_TOKEN, EVENT_BUS_TOKEN);
81
- let [exposedInstanceDependencies = EXPOSED_INSTANCE_DEPENDENCIES] = useOptionalDependencies(
82
- EXPOSED_INSTANCE_DEPENDENCIES_TOKEN
83
- );
74
+ const [logService, eventBus = bus] = useOptionalDependencies(Log, EVENT_BUS_TOKEN);
75
+ const [hostSharedDependencies, sharedInstanceDependencies] = useHostSharedDependencies();
84
76
  const [ldService] = useOptionalDependencies(getLDServiceToken() ?? Symbol());
85
77
 
86
78
  const LoadingFallback = useMemo(() => {
@@ -93,9 +85,9 @@ const UnrestrictedLoader = <T,>(props: UnrestrictedLoaderProps<T>, ref: Ref<Load
93
85
  return getFallback(props.errorFallback, message);
94
86
  }, [props.errorFallback, src]);
95
87
 
96
- exposedInstanceDependencies = useMemo(
97
- () => ensureLDService(exposedInstanceDependencies, ldService),
98
- [exposedInstanceDependencies, ldService]
88
+ const sharedInstanceDependenciesWithLD = useMemo(
89
+ () => ensureLDService(sharedInstanceDependencies, ldService),
90
+ [sharedInstanceDependencies, ldService]
99
91
  );
100
92
 
101
93
  const Loader = useMemo(
@@ -103,8 +95,8 @@ const UnrestrictedLoader = <T,>(props: UnrestrictedLoaderProps<T>, ref: Ref<Load
103
95
  lazyWebComponent({
104
96
  basename,
105
97
  cache,
106
- exposedDependencies,
107
- exposedInstanceDependencies,
98
+ hostSharedDependencies,
99
+ sharedInstanceDependencies: sharedInstanceDependenciesWithLD,
108
100
  eventBus,
109
101
  fallbackSrc,
110
102
  isHeadless,
@@ -116,8 +108,8 @@ const UnrestrictedLoader = <T,>(props: UnrestrictedLoaderProps<T>, ref: Ref<Load
116
108
  [
117
109
  basename,
118
110
  cache,
119
- exposedDependencies,
120
- exposedInstanceDependencies,
111
+ hostSharedDependencies,
112
+ sharedInstanceDependenciesWithLD,
121
113
  eventBus,
122
114
  fallbackSrc,
123
115
  isHeadless,
@@ -148,8 +140,8 @@ export const Loader = forwardRef(UnrestrictedLoader) as <T = {}>(
148
140
  ) => ReturnType<typeof UnrestrictedLoader>;
149
141
 
150
142
  type LazyLoaderProps = UnrestrictedLoaderProps<any> & {
151
- exposedDependencies?: ExposedDependencies;
152
- exposedInstanceDependencies?: ExposedInstanceDependencies;
143
+ hostSharedDependencies?: SharedDependencies;
144
+ sharedInstanceDependencies?: SharedInstanceDependencies;
153
145
  eventBus: EventBus;
154
146
  logService?: Log;
155
147
  cache: Required<UnrestrictedLoaderProps<any>>['cache'];
@@ -159,8 +151,8 @@ function lazyWebComponent(props: LazyLoaderProps) {
159
151
  const {
160
152
  basename,
161
153
  cache,
162
- exposedDependencies,
163
- exposedInstanceDependencies,
154
+ hostSharedDependencies,
155
+ sharedInstanceDependencies,
164
156
  eventBus,
165
157
  fallbackSrc,
166
158
  isHeadless,
@@ -180,22 +172,22 @@ function lazyWebComponent(props: LazyLoaderProps) {
180
172
  mainPackageUrl: src,
181
173
  fallbackPackageUrl: fallbackSrc,
182
174
  isHeadless,
183
- exposedDependencies,
184
- exposedInstanceDependencies,
175
+ hostSharedDependencies,
176
+ sharedInstanceDependencies,
185
177
  retries,
186
178
  onRequestError,
187
179
  });
188
180
 
189
181
  validateBundleInfo(bundleInfo, {
190
- exposedDependencies,
191
- exposedInstanceDependencies,
182
+ hostSharedDependencies,
183
+ sharedInstanceDependencies,
192
184
  logService,
193
185
  packageUrl: src,
194
186
  });
195
187
 
196
188
  await loadScripts(bundleInfo);
197
189
 
198
- const hostLDService = exposedInstanceDependencies?.launchDarkly?.ldService;
190
+ const hostLDService = sharedInstanceDependencies?.launchDarkly?.ldService;
199
191
  const hostSupportsVersionedLDClient = typeof hostLDService?.getVersionClient === 'function';
200
192
  const ldService =
201
193
  bundleInfo.mfeHasCompatibleLaunchDarklyVersion ||
@@ -208,8 +200,8 @@ function lazyWebComponent(props: LazyLoaderProps) {
208
200
  basename,
209
201
  bundleInfo,
210
202
  eventBus,
211
- exposedDependencies,
212
- exposedInstanceDependencies,
203
+ hostSharedDependencies,
204
+ sharedInstanceDependencies,
213
205
  ldService,
214
206
  logService,
215
207
  }),
@@ -231,14 +223,14 @@ function isLocalHost(source: string) {
231
223
  }
232
224
 
233
225
  function ensureLDService(
234
- exposedInstanceDependencies?: ExposedInstanceDependencies,
226
+ sharedInstanceDependencies?: SharedInstanceDependencies,
235
227
  ldService?: LDService
236
228
  ) {
237
- const launchDarkly = exposedInstanceDependencies?.launchDarkly;
229
+ const launchDarkly = sharedInstanceDependencies?.launchDarkly;
238
230
  if (launchDarkly?.version && !launchDarkly.ldService && ldService) {
239
- return { ...exposedInstanceDependencies, launchDarkly: { ...launchDarkly, ldService } };
231
+ return { ...sharedInstanceDependencies, launchDarkly: { ...launchDarkly, ldService } };
240
232
  }
241
- return exposedInstanceDependencies;
233
+ return sharedInstanceDependencies;
242
234
  }
243
235
 
244
236
  function useEventBus() {
package/src/register.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type LDService } from '@servicetitan/launchdarkly-service';
2
2
  import { Log } from '@servicetitan/log-service';
3
3
  import { Provider } from '@servicetitan/react-ioc';
4
- import { ExposedDependencies } from '@servicetitan/startup-utils';
4
+ import { SharedDependencies } from '@servicetitan/startup-utils';
5
5
  import { ComponentType, FC, ReactElement, useEffect } from 'react';
6
6
  import { Anvil1Providers } from './anvil1-providers';
7
7
  import { Anvil2Providers } from './anvil2-providers';
@@ -10,10 +10,12 @@ import {
10
10
  Entries,
11
11
  EXPOSED_DEPENDENCIES_TOKEN,
12
12
  EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
13
- ExposedInstanceDependencies,
14
13
  IS_WEB_COMPONENT_TOKEN,
15
14
  IWebComponent,
16
15
  RENDER_ROOT_TOKEN,
16
+ SHARED_DEPENDENCIES_TOKEN,
17
+ SHARED_INSTANCE_DEPENDENCIES_TOKEN,
18
+ SharedInstanceDependencies,
17
19
  } from './common';
18
20
  import { MFEDataContext } from './contexts/mfe-data-context';
19
21
  import { MFEMetadataContext } from './contexts/mfe-metadata-context';
@@ -39,6 +41,19 @@ function createLink(url: string, onLoad: () => void) {
39
41
 
40
42
  const Placeholder: FC = () => <div style={{ display: 'none' }} />;
41
43
 
44
+ /*
45
+ * Hosts built with older versions of web-components only send the deprecated
46
+ * `exposedDependencies` and `exposedInstanceDependencies` entries.
47
+ */
48
+ function normalizeEntries(entries: Entries): Entries {
49
+ const { exposedDependencies, exposedInstanceDependencies, ...rest } = entries;
50
+ return {
51
+ ...rest,
52
+ sharedDependencies: rest.sharedDependencies ?? exposedDependencies,
53
+ sharedInstanceDependencies: rest.sharedInstanceDependencies ?? exposedInstanceDependencies,
54
+ };
55
+ }
56
+
42
57
  export interface RegisterOptions {
43
58
  legacyRoot?: boolean;
44
59
  sharedDependenciesNames?: string[];
@@ -61,8 +76,8 @@ export function register(Component: ComponentType, light: boolean, options?: Reg
61
76
  private ldService?: LDService;
62
77
  private logService?: Log;
63
78
  private historyManager?: HistoryManager;
64
- private exposedDependencies?: ExposedDependencies;
65
- private exposedInstanceDependencies?: ExposedInstanceDependencies;
79
+ private sharedDependencies?: SharedDependencies;
80
+ private sharedInstanceDependencies?: SharedInstanceDependencies;
66
81
  private eventBus?: EventBus;
67
82
  private basename?: string;
68
83
  private onReady?: () => void;
@@ -146,7 +161,7 @@ export function register(Component: ComponentType, light: boolean, options?: Reg
146
161
  }
147
162
 
148
163
  provide = (entries: Entries) => {
149
- for (const [key, value] of Object.entries(entries)) {
164
+ for (const [key, value] of Object.entries(normalizeEntries(entries))) {
150
165
  this[key as keyof IWebComponent] = value;
151
166
  }
152
167
 
@@ -223,13 +238,25 @@ export function register(Component: ComponentType, light: boolean, options?: Reg
223
238
  provide: HistoryManager,
224
239
  useValue: this.historyManager,
225
240
  },
241
+ {
242
+ provide: SHARED_DEPENDENCIES_TOKEN,
243
+ useValue: this.sharedDependencies,
244
+ },
245
+ {
246
+ provide: SHARED_INSTANCE_DEPENDENCIES_TOKEN,
247
+ useValue: this.sharedInstanceDependencies,
248
+ },
249
+ /*
250
+ * Deprecated tokens, still provided for consumers and nested
251
+ * loaders built with older versions of web-components
252
+ */
226
253
  {
227
254
  provide: EXPOSED_DEPENDENCIES_TOKEN,
228
- useValue: this.exposedDependencies,
255
+ useValue: this.sharedDependencies,
229
256
  },
230
257
  {
231
258
  provide: EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
232
- useValue: this.exposedInstanceDependencies,
259
+ useValue: this.sharedInstanceDependencies,
233
260
  },
234
261
  { provide: BASENAME_TOKEN, useValue: this.basename },
235
262
  { provide: EVENT_BUS_TOKEN, useValue: this.eventBus },
@@ -0,0 +1,26 @@
1
+ import { useOptionalDependencies } from '@servicetitan/react-ioc';
2
+ import {
3
+ EXPOSED_DEPENDENCIES_TOKEN,
4
+ EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
5
+ SHARED_DEPENDENCIES_TOKEN,
6
+ SHARED_INSTANCE_DEPENDENCIES_TOKEN,
7
+ } from './common';
8
+ import { SHARED_DEPENDENCIES, SHARED_INSTANCE_DEPENDENCIES } from './globals';
9
+
10
+ /**
11
+ * Resolves the host's shared dependencies from the DI container, falling back to the
12
+ * deprecated EXPOSED_* tokens (still provided by consumers and older versions of
13
+ * web-components) and then to the build-time globals.
14
+ */
15
+ export function useHostSharedDependencies() {
16
+ const [shared, deprecatedShared, instance, deprecatedInstance] = useOptionalDependencies(
17
+ SHARED_DEPENDENCIES_TOKEN,
18
+ EXPOSED_DEPENDENCIES_TOKEN,
19
+ SHARED_INSTANCE_DEPENDENCIES_TOKEN,
20
+ EXPOSED_INSTANCE_DEPENDENCIES_TOKEN
21
+ );
22
+ return [
23
+ shared ?? deprecatedShared ?? SHARED_DEPENDENCIES,
24
+ instance ?? deprecatedInstance ?? SHARED_INSTANCE_DEPENDENCIES,
25
+ ] as const;
26
+ }
@@ -1,9 +1,8 @@
1
1
  import { Log } from '@servicetitan/log-service';
2
2
  import { useOptionalDependencies } from '@servicetitan/react-ioc';
3
3
  import { useCallback, useMemo } from 'react';
4
- import { EXPOSED_DEPENDENCIES_TOKEN, EXPOSED_INSTANCE_DEPENDENCIES_TOKEN } from './common';
5
- import { EXPOSED_DEPENDENCIES, EXPOSED_INSTANCE_DEPENDENCIES } from './globals';
6
4
  import { LoaderProps } from './loader';
5
+ import { useHostSharedDependencies } from './use-host-shared-dependencies';
7
6
  import { getBundleInfo, supportsPrefetch } from './utils';
8
7
 
9
8
  /**
@@ -11,19 +10,14 @@ import { getBundleInfo, supportsPrefetch } from './utils';
11
10
  * so that Loader can load it faster later.
12
11
  */
13
12
  export function usePrefetch() {
14
- const [logService, exposedDependencies = EXPOSED_DEPENDENCIES] = useOptionalDependencies(
15
- Log,
16
- EXPOSED_DEPENDENCIES_TOKEN
17
- );
18
- const [exposedInstanceDependencies = EXPOSED_INSTANCE_DEPENDENCIES] = useOptionalDependencies(
19
- EXPOSED_INSTANCE_DEPENDENCIES_TOKEN
20
- );
13
+ const [logService] = useOptionalDependencies(Log);
14
+ const [hostSharedDependencies, sharedInstanceDependencies] = useHostSharedDependencies();
21
15
  const prefetch = useCallback(
22
16
  async (src: string, { cache = -1 }: Pick<LoaderProps<any>, 'cache'> = {}) => {
23
17
  try {
24
18
  const bundleInfo = await getBundleInfo({
25
- exposedDependencies,
26
- exposedInstanceDependencies,
19
+ hostSharedDependencies,
20
+ sharedInstanceDependencies,
27
21
  mainPackageUrl: src,
28
22
  cache,
29
23
  retries: 0,
@@ -50,7 +44,7 @@ export function usePrefetch() {
50
44
  });
51
45
  }
52
46
  },
53
- [logService, exposedDependencies, exposedInstanceDependencies]
47
+ [logService, hostSharedDependencies, sharedInstanceDependencies]
54
48
  );
55
49
 
56
50
  return useMemo(() => ({ prefetch }), [prefetch]);
@@ -1,6 +1,6 @@
1
- import { ExposedDependencies, getVersionMismatches } from '@servicetitan/startup-utils';
1
+ import { getVersionMismatches, SharedDependencies } from '@servicetitan/startup-utils';
2
2
  import semver from 'semver';
3
- import { ExposedInstanceDependencies, getJson, GetJsonError } from '../common';
3
+ import { getJson, GetJsonError, SharedInstanceDependencies } from '../common';
4
4
  import { getMFEMaybeUsesKendoGrid } from '../patches/kendo-scrollbar-width';
5
5
  import type { Metadata } from '../types';
6
6
  import { getCacheSetting } from './get-cache-setting';
@@ -15,8 +15,9 @@ export type BundleInfo = Awaited<ReturnType<typeof getBundleInfo>>;
15
15
 
16
16
  interface GetBundleInfoProps {
17
17
  cache: boolean | number;
18
- exposedDependencies?: ExposedDependencies;
19
- exposedInstanceDependencies?: ExposedInstanceDependencies;
18
+ /** The host's shared dependencies and their versions. */
19
+ hostSharedDependencies?: SharedDependencies;
20
+ sharedInstanceDependencies?: SharedInstanceDependencies;
20
21
  fallbackPackageUrl?: string;
21
22
  isHeadless?: boolean;
22
23
  mainPackageUrl: string;
@@ -28,8 +29,8 @@ export async function getBundleInfo({
28
29
  cache,
29
30
  mainPackageUrl,
30
31
  fallbackPackageUrl,
31
- exposedDependencies = {},
32
- exposedInstanceDependencies = {},
32
+ hostSharedDependencies = {},
33
+ sharedInstanceDependencies = {},
33
34
  isHeadless,
34
35
  retries,
35
36
  onRequestError,
@@ -68,7 +69,7 @@ export async function getBundleInfo({
68
69
  if (isHeadless) {
69
70
  resolvedBundleType = 'headless';
70
71
  } else {
71
- mismatch = getVersionMismatches(exposedDependencies, dependencies, sharedDependencies);
72
+ mismatch = getVersionMismatches(hostSharedDependencies, dependencies, sharedDependencies);
72
73
  const startupVersion = bundledWith?.['@servicetitan/startup'];
73
74
  const supportLightBundles = !!startupVersion && semver.gte(startupVersion, '17.0.0');
74
75
  const embed = !mismatch && supportLightBundles;
@@ -106,7 +107,7 @@ export async function getBundleInfo({
106
107
  mfeHasUniqueChunkNamespace: getMFEHasUniqueChunkNamespace(bundledWith),
107
108
  mfeHasCompatibleLaunchDarklyVersion: getMFEHasCompatibleLaunchDarklyVersion(
108
109
  bundledWith,
109
- exposedInstanceDependencies
110
+ sharedInstanceDependencies
110
111
  ),
111
112
  mfeSupportsVersionedLDClient: getMFESupportsVersionedLDClient(bundledWith),
112
113
  mfeMaybeUsesKendoGrid: getMFEMaybeUsesKendoGrid(dependencies),
@@ -1,19 +1,19 @@
1
- import { ExposedInstanceDependencies } from '../common';
1
+ import { SharedInstanceDependencies } from '../common';
2
2
  import type { Metadata } from '../types';
3
3
 
4
4
  /**
5
- * @param bundledWith THe MFE's metadata.bundledWith.
6
- * @param exposedInstanceDependencies The hosts's EXPOSED_INSTANCE_DEPENDENCIES, if any.
5
+ * @param bundledWith The MFE's metadata.bundledWith.
6
+ * @param sharedInstanceDependencies The host's SHARED_INSTANCE_DEPENDENCIES, if any.
7
7
  * @returns Returns true when host and MFE use compatible version of LaunchDarkly
8
- * and returns false when host and MGE use incompatible version.
9
- * Returns undefined when either the host or MFE doesn't expose LaunchDarkly.
8
+ * and returns false when host and MFE use incompatible version.
9
+ * Returns undefined when either the host or MFE doesn't share LaunchDarkly.
10
10
  */
11
11
  export function getMFEHasCompatibleLaunchDarklyVersion(
12
12
  bundledWith: Metadata['bundledWith'],
13
- exposedInstanceDependencies: ExposedInstanceDependencies
13
+ sharedInstanceDependencies: SharedInstanceDependencies
14
14
  ) {
15
15
  const mfeVersion = bundledWith?.['launchdarkly-js-client-sdk'];
16
- const hostVersion = exposedInstanceDependencies.launchDarkly?.version;
16
+ const hostVersion = sharedInstanceDependencies.launchDarkly?.version;
17
17
  if (hostVersion && mfeVersion) {
18
18
  return hostVersion === mfeVersion;
19
19
  }
@@ -1,17 +1,17 @@
1
1
  import { Log } from '@servicetitan/log-service';
2
- import { ExposedDependencies } from '@servicetitan/startup-utils';
3
- import { ExposedInstanceDependencies } from '../common';
2
+ import { SharedDependencies } from '@servicetitan/startup-utils';
3
+ import { SharedInstanceDependencies } from '../common';
4
4
  import { BundleInfo } from './get-bundle-info';
5
5
 
6
6
  interface Context {
7
- exposedDependencies?: ExposedDependencies;
8
- exposedInstanceDependencies?: ExposedInstanceDependencies;
7
+ hostSharedDependencies?: SharedDependencies;
8
+ sharedInstanceDependencies?: SharedInstanceDependencies;
9
9
  logService?: Log;
10
10
  packageUrl: string;
11
11
  }
12
12
  export function validateBundleInfo(
13
13
  { mismatch, mfeHasCompatibleLaunchDarklyVersion }: BundleInfo,
14
- { exposedDependencies = {}, exposedInstanceDependencies, logService, packageUrl }: Context
14
+ { hostSharedDependencies = {}, sharedInstanceDependencies, logService, packageUrl }: Context
15
15
  ) {
16
16
  if (!logService) {
17
17
  return;
@@ -19,11 +19,12 @@ export function validateBundleInfo(
19
19
 
20
20
  if (mismatch) {
21
21
  const data = { package: packageUrl, dependencies: JSON.stringify(mismatch) };
22
- if (Object.keys(exposedDependencies).length === 0) {
22
+ if (Object.keys(hostSharedDependencies).length === 0) {
23
23
  logService.warning({
24
+ // Legacy category name kept so existing log monitors keep matching
24
25
  category: 'MicroFrontends.NoExposedDependencies',
25
26
  message:
26
- 'Cannot use light bundle because the host is not exposing dependencies or the list of shared dependencies is empty.',
27
+ 'Cannot use light bundle because the host is not providing shared dependencies or the list of shared dependencies is empty.',
27
28
  data,
28
29
  });
29
30
  } else {
@@ -43,7 +44,7 @@ export function validateBundleInfo(
43
44
  if (mfeHasCompatibleLaunchDarklyVersion === false) {
44
45
  const data = {
45
46
  package: packageUrl,
46
- hostVersion: exposedInstanceDependencies?.launchDarkly?.version ?? '',
47
+ hostVersion: sharedInstanceDependencies?.launchDarkly?.version ?? '',
47
48
  };
48
49
  logService.warning({
49
50
  category: 'MicroFrontends.LaunchDarklyMismatch',
@@ -1,9 +1,9 @@
1
1
  import { type LDService } from '@servicetitan/launchdarkly-service';
2
2
  import { Log } from '@servicetitan/log-service';
3
3
  import { useOptionalDependencies } from '@servicetitan/react-ioc';
4
- import { ExposedDependencies } from '@servicetitan/startup-utils';
4
+ import { SharedDependencies } from '@servicetitan/startup-utils';
5
5
  import { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react';
6
- import { ExposedInstanceDependencies, IWebComponent } from '../common';
6
+ import { IWebComponent, SharedInstanceDependencies } from '../common';
7
7
  import { MFEContextData } from '../contexts/mfe-data-context';
8
8
  import { EventBus } from '../event-bus';
9
9
  import { HistoryManager } from '../history-manager';
@@ -16,14 +16,14 @@ interface WebComponentProps {
16
16
  basename?: string;
17
17
  bundleInfo: BundleInfo;
18
18
  eventBus: EventBus;
19
- exposedDependencies?: ExposedDependencies;
20
- exposedInstanceDependencies?: ExposedInstanceDependencies;
19
+ hostSharedDependencies?: SharedDependencies;
20
+ sharedInstanceDependencies?: SharedInstanceDependencies;
21
21
  ldService?: LDService;
22
22
  logService?: Log;
23
23
  }
24
24
 
25
25
  export function webComponent(props: WebComponentProps) {
26
- const { basename, bundleInfo, eventBus, exposedDependencies, ldService, logService } = props;
26
+ const { basename, bundleInfo, eventBus, hostSharedDependencies, ldService, logService } = props;
27
27
  const {
28
28
  WebComponent,
29
29
  resolvedBundleType,
@@ -33,8 +33,8 @@ export function webComponent(props: WebComponentProps) {
33
33
  } = bundleInfo;
34
34
  const elementName = getElementName(bundleInfo);
35
35
 
36
- const exposedInstanceDependencies = ensureLDVersion(
37
- props.exposedInstanceDependencies,
36
+ const sharedInstanceDependencies = ensureLDVersion(
37
+ props.sharedInstanceDependencies,
38
38
  bundleInfo.bundledWith?.['launchdarkly-js-client-sdk']
39
39
  );
40
40
 
@@ -49,8 +49,14 @@ export function webComponent(props: WebComponentProps) {
49
49
  ldService,
50
50
  logService,
51
51
  historyManager,
52
- exposedDependencies,
53
- exposedInstanceDependencies,
52
+ sharedDependencies: hostSharedDependencies,
53
+ sharedInstanceDependencies,
54
+ /*
55
+ * Continue to pass the deprecated names for backwards compatibility,
56
+ * in case the Host has updated web-components, but the MFE has not
57
+ */
58
+ exposedDependencies: hostSharedDependencies,
59
+ exposedInstanceDependencies: sharedInstanceDependencies,
54
60
  eventBus,
55
61
  basename,
56
62
  onReady: () => {
@@ -122,13 +128,13 @@ function composeDataAttributes(data: MFEContextData<{}> | undefined = {}) {
122
128
  }
123
129
 
124
130
  function ensureLDVersion(
125
- exposedInstanceDependencies: ExposedInstanceDependencies = {},
131
+ sharedInstanceDependencies: SharedInstanceDependencies = {},
126
132
  version?: string
127
133
  ) {
128
- if (version && !exposedInstanceDependencies.launchDarkly?.ldService) {
129
- return { ...exposedInstanceDependencies, launchDarkly: { version } };
134
+ if (version && !sharedInstanceDependencies.launchDarkly?.ldService) {
135
+ return { ...sharedInstanceDependencies, launchDarkly: { version } };
130
136
  }
131
- return exposedInstanceDependencies;
137
+ return sharedInstanceDependencies;
132
138
  }
133
139
 
134
140
  function getStyleUrls({ urls }: Pick<BundleInfo, 'urls'>) {