@servicetitan/web-components 40.0.0 → 40.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.
@@ -16,7 +16,6 @@ interface GetBundleInfoProps {
16
16
  export declare function getBundleInfo({ cache, mainPackageUrl, fallbackPackageUrl, exposedDependencies, exposedInstanceDependencies, isHeadless, signal, retries, onRequestError, }: GetBundleInfoProps): Promise<{
17
17
  bundledWith: Record<string, string | undefined> | undefined;
18
18
  cacheHit: boolean | undefined;
19
- disposer: () => void;
20
19
  mfeSupportsRerendering: boolean;
21
20
  mfeHasUniqueChunkNamespace: boolean;
22
21
  mfeHasCompatibleLaunchDarklyVersion: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"get-bundle-info.d.ts","sourceRoot":"","sources":["../../src/utils/get-bundle-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,6BAA6B,CAAC;AAGxF,OAAO,EAAE,2BAA2B,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AAI/E,OAAO,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AAMjE,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC;AAEnE,UAAU,kBAAkB;IACxB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB;AAED,wBAAsB,aAAa,CAAC,EAChC,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAwB,EACxB,2BAAgC,EAChC,UAAU,EACV,MAAM,EACN,OAAO,EACP,cAAc,GACjB,EAAE,kBAAkB;;;;;;;;;;;;;;;;;GA+FpB"}
1
+ {"version":3,"file":"get-bundle-info.d.ts","sourceRoot":"","sources":["../../src/utils/get-bundle-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,6BAA6B,CAAC;AAExF,OAAO,EAAE,2BAA2B,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AAI/E,OAAO,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AAMjE,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC;AAEnE,UAAU,kBAAkB;IACxB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB;AAED,wBAAsB,aAAa,CAAC,EAChC,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAwB,EACxB,2BAAgC,EAChC,UAAU,EACV,MAAM,EACN,OAAO,EACP,cAAc,GACjB,EAAE,kBAAkB;;;;;;;;;;;;;;;;GAqFpB"}
@@ -1,5 +1,4 @@
1
1
  import { getVersionMismatches } from '@servicetitan/startup-utils';
2
- import get from 'lodash.get';
3
2
  import semver from 'semver';
4
3
  import { getJson } from '../common';
5
4
  import { getCacheSetting } from './get-cache-setting';
@@ -51,14 +50,6 @@ export async function getBundleInfo({ cache, mainPackageUrl, fallbackPackageUrl,
51
50
  } else {
52
51
  entrypoints = await getEntrypoints(`${bundleBaseUrl}/entrypoints.json`, requestCache);
53
52
  }
54
- const disposer = ()=>{
55
- if (resolvedBundleType === 'light') {
56
- const path = Object.values(sharedDependencies).shift();
57
- if (path) {
58
- get(window, path).getStorage().clear(name);
59
- }
60
- }
61
- };
62
53
  let baseUrl = bundleBaseUrl;
63
54
  // Per-MFE dev-server port only happens during local development
64
55
  if (process.env.NODE_ENV !== 'production' && entrypoints.port) {
@@ -74,7 +65,6 @@ export async function getBundleInfo({ cache, mainPackageUrl, fallbackPackageUrl,
74
65
  return {
75
66
  bundledWith,
76
67
  cacheHit,
77
- disposer,
78
68
  mfeSupportsRerendering: getMFESupportsRerendering(bundledWith, dependencies),
79
69
  mfeHasUniqueChunkNamespace: getMFEHasUniqueChunkNamespace(bundledWith),
80
70
  mfeHasCompatibleLaunchDarklyVersion: getMFEHasCompatibleLaunchDarklyVersion(bundledWith, exposedInstanceDependencies),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/get-bundle-info.ts"],"sourcesContent":["import { ExposedDependencies, getVersionMismatches } from '@servicetitan/startup-utils';\nimport get from 'lodash.get';\nimport semver from 'semver';\nimport { ExposedInstanceDependencies, getJson, GetJsonError } from '../common';\nimport type { Metadata } from '../types';\nimport { getCacheSetting } from './get-cache-setting';\nimport { getCachedMetadata } from './get-cached-metadata';\nimport { EntryPoints, getEntrypoints } from './get-entry-points';\nimport { getMFEHasCompatibleLaunchDarklyVersion } from './get-mfe-has-compatible-launchdarkly-version';\nimport { getMFEHasUniqueChunkNamespace } from './get-mfe-has-unique-chunk-namespace';\nimport { getMFESupportsRerendering } from './get-mfe-supports-rerendering';\nimport { getMFESupportsVersionedLDClient } from './get-mfe-supports-versioned-ld-client';\n\nexport type BundleInfo = Awaited<ReturnType<typeof getBundleInfo>>;\n\ninterface GetBundleInfoProps {\n cache: boolean | number;\n exposedDependencies?: ExposedDependencies;\n exposedInstanceDependencies?: ExposedInstanceDependencies;\n fallbackPackageUrl?: string;\n isHeadless?: boolean;\n mainPackageUrl: string;\n onRequestError?: (error: GetJsonError) => void;\n retries?: number;\n signal?: AbortSignal;\n}\n\nexport async function getBundleInfo({\n cache,\n mainPackageUrl,\n fallbackPackageUrl,\n exposedDependencies = {},\n exposedInstanceDependencies = {},\n isHeadless,\n signal,\n retries,\n onRequestError,\n}: GetBundleInfoProps) {\n const {\n cacheHit,\n data: metadata,\n url: packageUrl,\n } = await getCachedMetadata({\n cache,\n fallbackPackageUrl,\n mainPackageUrl,\n onRequestError,\n retries,\n signal,\n });\n\n const { bundledWith, name, sharedDependencies } = metadata;\n const exactPackageUrl = packageUrl.replace('/dist/metadata.json', '');\n const requestCache = getCacheSetting(exactPackageUrl);\n\n let dependencies: NonNullable<Metadata['dependencies']>;\n if (metadata.dependencies) {\n dependencies = metadata.dependencies;\n } else {\n const { data: packageJson } = await getJson(`${exactPackageUrl}/package.json`, {\n cache: requestCache,\n retries,\n signal,\n });\n\n dependencies = packageJson.dependencies;\n }\n\n let mismatch: ReturnType<typeof getVersionMismatches>;\n let resolvedBundleType: 'headless' | 'light' | 'full';\n\n if (isHeadless) {\n resolvedBundleType = 'headless';\n } else {\n mismatch = getVersionMismatches(exposedDependencies, dependencies, sharedDependencies);\n const startupVersion = bundledWith?.['@servicetitan/startup'];\n const supportLightBundles = !!startupVersion && semver.gte(startupVersion, '17.0.0');\n const embed = !mismatch && supportLightBundles;\n resolvedBundleType = embed ? 'light' : 'full';\n }\n\n const bundleBaseUrl = `${exactPackageUrl}/dist/bundle/${resolvedBundleType}`;\n\n let entrypoints: EntryPoints;\n if (metadata.entrypoints?.[resolvedBundleType]) {\n entrypoints = metadata.entrypoints[resolvedBundleType];\n } else {\n entrypoints = await getEntrypoints(`${bundleBaseUrl}/entrypoints.json`, requestCache);\n }\n\n const disposer = () => {\n if (resolvedBundleType === 'light') {\n const path = Object.values<string>(sharedDependencies).shift();\n if (path) {\n get(window, path).getStorage().clear(name);\n }\n }\n };\n\n let baseUrl = bundleBaseUrl;\n // Per-MFE dev-server port only happens during local development\n if (process.env.NODE_ENV !== 'production' && entrypoints.port) {\n const url = new URL(baseUrl);\n url.port = String(entrypoints.port);\n baseUrl = url.toString();\n }\n\n const urls: EntryPoints = {\n css: entrypoints.css.map(path => `${baseUrl}/${path}`),\n js: entrypoints.js.map(path => `${baseUrl}/${path}`),\n };\n\n const elementName = resolvedBundleType === 'headless' ? `headless-${name}` : name;\n\n return {\n bundledWith,\n cacheHit,\n disposer,\n mfeSupportsRerendering: getMFESupportsRerendering(bundledWith, dependencies),\n mfeHasUniqueChunkNamespace: getMFEHasUniqueChunkNamespace(bundledWith),\n mfeHasCompatibleLaunchDarklyVersion: getMFEHasCompatibleLaunchDarklyVersion(\n bundledWith,\n exposedInstanceDependencies\n ),\n mfeSupportsVersionedLDClient: getMFESupportsVersionedLDClient(bundledWith),\n mismatch,\n resolvedBundleType,\n urls,\n WebComponent: elementName,\n version: metadata.version,\n module: entrypoints.module,\n };\n}\n"],"names":["getVersionMismatches","get","semver","getJson","getCacheSetting","getCachedMetadata","getEntrypoints","getMFEHasCompatibleLaunchDarklyVersion","getMFEHasUniqueChunkNamespace","getMFESupportsRerendering","getMFESupportsVersionedLDClient","getBundleInfo","cache","mainPackageUrl","fallbackPackageUrl","exposedDependencies","exposedInstanceDependencies","isHeadless","signal","retries","onRequestError","metadata","cacheHit","data","url","packageUrl","bundledWith","name","sharedDependencies","exactPackageUrl","replace","requestCache","dependencies","packageJson","mismatch","resolvedBundleType","startupVersion","supportLightBundles","gte","embed","bundleBaseUrl","entrypoints","disposer","path","Object","values","shift","window","getStorage","clear","baseUrl","process","env","NODE_ENV","port","URL","String","toString","urls","css","map","js","elementName","mfeSupportsRerendering","mfeHasUniqueChunkNamespace","mfeHasCompatibleLaunchDarklyVersion","mfeSupportsVersionedLDClient","WebComponent","version","module"],"mappings":"AAAA,SAA8BA,oBAAoB,Q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BAAwBtD,0BAA0BiB,aAAaM;QAC/DgC,4BAA4BxD,8BAA8BkB;QAC1DuC,qCAAqC1D,uCACjCmB,aACAV;QAEJkD,8BAA8BxD,gCAAgCgB;QAC9DQ;QACAC;QACAuB;QACAS,cAAcL;QACdM,SAAS/C,SAAS+C,OAAO;QACzBC,QAAQ5B,YAAY4B,MAAM;IAC9B;AACJ"}
1
+ {"version":3,"sources":["../../src/utils/get-bundle-info.ts"],"sourcesContent":["import { ExposedDependencies, getVersionMismatches } from '@servicetitan/startup-utils';\nimport semver from 'semver';\nimport { ExposedInstanceDependencies, getJson, GetJsonError } from '../common';\nimport type { Metadata } from '../types';\nimport { getCacheSetting } from './get-cache-setting';\nimport { getCachedMetadata } from './get-cached-metadata';\nimport { EntryPoints, getEntrypoints } from './get-entry-points';\nimport { getMFEHasCompatibleLaunchDarklyVersion } from './get-mfe-has-compatible-launchdarkly-version';\nimport { getMFEHasUniqueChunkNamespace } from './get-mfe-has-unique-chunk-namespace';\nimport { getMFESupportsRerendering } from './get-mfe-supports-rerendering';\nimport { getMFESupportsVersionedLDClient } from './get-mfe-supports-versioned-ld-client';\n\nexport type BundleInfo = Awaited<ReturnType<typeof getBundleInfo>>;\n\ninterface GetBundleInfoProps {\n cache: boolean | number;\n exposedDependencies?: ExposedDependencies;\n exposedInstanceDependencies?: ExposedInstanceDependencies;\n fallbackPackageUrl?: string;\n isHeadless?: boolean;\n mainPackageUrl: string;\n onRequestError?: (error: GetJsonError) => void;\n retries?: number;\n signal?: AbortSignal;\n}\n\nexport async function getBundleInfo({\n cache,\n mainPackageUrl,\n fallbackPackageUrl,\n exposedDependencies = {},\n exposedInstanceDependencies = {},\n isHeadless,\n signal,\n retries,\n onRequestError,\n}: GetBundleInfoProps) {\n const {\n cacheHit,\n data: metadata,\n url: packageUrl,\n } = await getCachedMetadata({\n cache,\n fallbackPackageUrl,\n mainPackageUrl,\n onRequestError,\n retries,\n signal,\n });\n\n const { bundledWith, name, sharedDependencies } = metadata;\n const exactPackageUrl = packageUrl.replace('/dist/metadata.json', '');\n const requestCache = getCacheSetting(exactPackageUrl);\n\n let dependencies: NonNullable<Metadata['dependencies']>;\n if (metadata.dependencies) {\n dependencies = metadata.dependencies;\n } else {\n const { data: packageJson } = await getJson(`${exactPackageUrl}/package.json`, {\n cache: requestCache,\n retries,\n signal,\n });\n\n dependencies = packageJson.dependencies;\n }\n\n let mismatch: ReturnType<typeof getVersionMismatches>;\n let resolvedBundleType: 'headless' | 'light' | 'full';\n\n if (isHeadless) {\n resolvedBundleType = 'headless';\n } else {\n mismatch = getVersionMismatches(exposedDependencies, dependencies, sharedDependencies);\n const startupVersion = bundledWith?.['@servicetitan/startup'];\n const supportLightBundles = !!startupVersion && semver.gte(startupVersion, '17.0.0');\n const embed = !mismatch && supportLightBundles;\n resolvedBundleType = embed ? 'light' : 'full';\n }\n\n const bundleBaseUrl = `${exactPackageUrl}/dist/bundle/${resolvedBundleType}`;\n\n let entrypoints: EntryPoints;\n if (metadata.entrypoints?.[resolvedBundleType]) {\n entrypoints = metadata.entrypoints[resolvedBundleType];\n } else {\n entrypoints = await getEntrypoints(`${bundleBaseUrl}/entrypoints.json`, requestCache);\n }\n\n let baseUrl = bundleBaseUrl;\n // Per-MFE dev-server port only happens during local development\n if (process.env.NODE_ENV !== 'production' && entrypoints.port) {\n const url = new URL(baseUrl);\n url.port = String(entrypoints.port);\n baseUrl = url.toString();\n }\n\n const urls: EntryPoints = {\n css: entrypoints.css.map(path => `${baseUrl}/${path}`),\n js: entrypoints.js.map(path => `${baseUrl}/${path}`),\n };\n\n const elementName = resolvedBundleType === 'headless' ? `headless-${name}` : name;\n\n return {\n bundledWith,\n cacheHit,\n mfeSupportsRerendering: getMFESupportsRerendering(bundledWith, dependencies),\n mfeHasUniqueChunkNamespace: getMFEHasUniqueChunkNamespace(bundledWith),\n mfeHasCompatibleLaunchDarklyVersion: getMFEHasCompatibleLaunchDarklyVersion(\n bundledWith,\n exposedInstanceDependencies\n ),\n mfeSupportsVersionedLDClient: getMFESupportsVersionedLDClient(bundledWith),\n mismatch,\n resolvedBundleType,\n urls,\n WebComponent: elementName,\n version: metadata.version,\n module: entrypoints.module,\n };\n}\n"],"names":["getVersionMismatches","semver","getJson","getCacheSetting","getCachedMetadata","getEntrypoints","getMFEHasCompatibleLaunchDarklyVersion","getMFEHasUniqueChunkNamespace","getMFESupportsRerendering","getMFESupportsVersionedLDClient","getBundleInfo","cache","mainPackageUrl","fallbackPackageUrl","exposedDependencies","exposedInstanceDependencies","isHeadless","signal","retries","onRequestError","metadata","cacheHit","data","url","packageUrl","bundledWith","name","sharedDependencies","exactPackageUrl","replace","requestCache","dependencies","packageJson","mismatch","resolvedBundleType","startupVersion","supportLightBundles","gte","embed","bundleBaseUrl","entrypoints","baseUrl","process","env","NODE_ENV","port","URL","String","toString","urls","css","map","path","js","elementName","mfeSupportsRerendering","mfeHasUniqueChunkNamespace","mfeHasCompatibleLaunchDarklyVersion","mfeSupportsVersionedLDClient","WebComponent","version","module"],"mappings":"AAAA,SAA8BA,oBAAoB,QAAQ,8BAA8B;AACxF,OAAOC,YAAY,SAAS;AAC5B,SAAsCC,OAAO,QAAsB,YAAY;AAE/E,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAAsBC,cAAc,QAAQ,qBAAqB;AACjE,SAASC,sCAAsC,QAAQ,gDAAgD;AACvG,SAASC,6BAA6B,QAAQ,uCAAuC;AACrF,SAASC,yBAAyB,QAAQ,iCAAiC;AAC3E,SAASC,+BAA+B,QAAQ,yCAAyC;AAgBzF,OAAO,eAAeC,cAAc,EAChCC,KAAK,EACLC,cAAc,EACdC,kBAAkB,EAClBC,sBAAsB,CAAC,CAAC,EACxBC,8BAA8B,CAAC,CAAC,EAChCC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,cAAc,EACG;QA+CbC;IA9CJ,MAAM,EACFC,QAAQ,EACRC,MAAMF,QAAQ,EACdG,KAAKC,UAA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,EAAE,mBAAmB,CAAC;IAC1C,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,IAWzC,oCAAoC,eAAe,6CA6D9D"}
1
+ {"version":3,"file":"web-component.d.ts","sourceRoot":"","sources":["../../src/utils/web-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,2BAA2B,EAAiB,MAAM,WAAW,CAAC;AAEvE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,UAAU,iBAAiB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,IAUzC,oCAAoC,eAAe,6CA0D9D"}
@@ -6,7 +6,7 @@ import { getElementName } from './get-element-name';
6
6
  export function webComponent(props) {
7
7
  var _bundleInfo_bundledWith;
8
8
  const { basename, bundleInfo, eventBus, exposedDependencies, ldService, logService } = props;
9
- const { WebComponent, resolvedBundleType, disposer, mfeSupportsRerendering, version } = bundleInfo;
9
+ const { WebComponent, resolvedBundleType, mfeSupportsRerendering, version } = bundleInfo;
10
10
  const elementName = getElementName(bundleInfo);
11
11
  const exposedInstanceDependencies = ensureLDVersion(props.exposedInstanceDependencies, (_bundleInfo_bundledWith = bundleInfo.bundledWith) === null || _bundleInfo_bundledWith === void 0 ? void 0 : _bundleInfo_bundledWith['launchdarkly-js-client-sdk']);
12
12
  return ({ LoadingFallback, ...innerProps })=>{
@@ -23,9 +23,6 @@ export function webComponent(props) {
23
23
  basename,
24
24
  onReady: ()=>{
25
25
  setIsLoading(false);
26
- },
27
- onDispose: ()=>{
28
- disposer();
29
26
  }
30
27
  });
31
28
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/web-component.tsx"],"sourcesContent":["import { type LDService } from '@servicetitan/launchdarkly-service';\nimport { Log } from '@servicetitan/log-service';\nimport { useOptionalDependencies } from '@servicetitan/react-ioc';\nimport { ExposedDependencies } from '@servicetitan/startup-utils';\nimport { Fragment, useMemo, useState } from 'react';\nimport { ExposedInstanceDependencies, IWebComponent } from '../common';\nimport { MFEContextData } from '../contexts/mfe-data-context';\nimport { EventBus } from '../event-bus';\nimport { HistoryManager } from '../history-manager';\nimport { LoaderDataProps } from '../loader';\nimport { BundleInfo } from './get-bundle-info';\nimport { getElementName } from './get-element-name';\n\ninterface WebComponentProps {\n basename?: string;\n bundleInfo: BundleInfo;\n eventBus: EventBus;\n exposedDependencies?: ExposedDependencies;\n exposedInstanceDependencies?: ExposedInstanceDependencies;\n ldService?: LDService;\n logService?: Log;\n}\n\nexport function webComponent(props: WebComponentProps) {\n const { basename, bundleInfo, eventBus, exposedDependencies, ldService, logService } = props;\n const { WebComponent, resolvedBundleType, disposer, mfeSupportsRerendering, version } =\n bundleInfo;\n const elementName = getElementName(bundleInfo);\n\n const exposedInstanceDependencies = ensureLDVersion(\n props.exposedInstanceDependencies,\n bundleInfo.bundledWith?.['launchdarkly-js-client-sdk']\n );\n\n return ({ LoadingFallback, ...innerProps }: LoaderDataProps) => {\n const [isLoading, setIsLoading] = useState(true);\n const [historyManager] = useOptionalDependencies(HistoryManager);\n\n const handleRef = (webComponent: IWebComponent | null) => {\n webComponent?.provide({\n ldService,\n logService,\n historyManager,\n exposedDependencies,\n exposedInstanceDependencies,\n eventBus,\n basename,\n onReady: () => {\n setIsLoading(false);\n },\n onDispose: () => {\n disposer();\n },\n });\n };\n\n // Stringify data object so that it can be passed as a data-attribute\n const stringifiedData = useMemo(() => JSON.stringify(innerProps.data), [innerProps.data]);\n\n /*\n * Set key for rendering the web component so that if the data from the Host change,\n * and the MFE's version of startup doesn't support watching for data changes, then\n * the web component will be re-mounted whenever the data changes.\n * This is only used as a fallback when the MFE's version is older.\n */\n const key = mfeSupportsRerendering ? undefined : stringifiedData;\n const dataAttrs = useMemo(() => composeDataAttributes(innerProps.data), [innerProps.data]);\n const styleUrls = getStyleUrls(bundleInfo);\n\n return (\n <Fragment>\n {isLoading && <LoadingFallback />}\n <WebComponent\n key={key}\n ref={handleRef}\n class={innerProps.className}\n {...(styleUrls && { 'style-urls': styleUrls })}\n /*\n * Continue to spread data as separate data attributes for backwards compatibility,\n * in case the Host has updated web-components, but the MFE has not\n */\n {...dataAttrs}\n data-mfe-data={stringifiedData}\n data-mfe-name={elementName}\n {...(version && { 'data-mfe-version': version })}\n // @ts-expect-error style exists on HTMLElement\n style={\n isLoading || resolvedBundleType === 'headless'\n ? { display: 'none' }\n : undefined\n }\n />\n </Fragment>\n );\n };\n}\n\n/*\n * Convert camelCase data props to kebab-case data attributes, prepended with data-\n * Ex: fooBar -> data-foo-bar\n */\nfunction composeDataAttributes(data: MFEContextData<{}> | undefined = {}) {\n return Object.fromEntries(\n Object.entries(data).map(([key, value]) => [\n 'data-' + key.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()),\n value,\n ])\n );\n}\n\nfunction ensureLDVersion(\n exposedInstanceDependencies: ExposedInstanceDependencies = {},\n version?: string\n) {\n if (version && !exposedInstanceDependencies.launchDarkly?.ldService) {\n return { ...exposedInstanceDependencies, launchDarkly: { version } };\n }\n return exposedInstanceDependencies;\n}\n\nfunction getStyleUrls({ urls }: Pick<BundleInfo, 'urls'>) {\n if (urls.css.length) {\n return encodeURIComponent(JSON.stringify(urls.css));\n }\n}\n"],"names":["useOptionalDependencies","Fragment","useMemo","useState","HistoryManager","getElementName","webComponent","props","bundleInfo","basename","eventBus","exposedDependencies","ldService","logService","WebComponent","resolvedBundleType","disposer","mfeSupportsRerendering","version","elementName","exposedInstanceDependencies","ensureLDVersion","bundledWith","LoadingFallback","innerProps","isLoading","setIsLoading","historyManager","handleRef","provide","onReady","onDispose","stringifiedData","JSON","stringify","data","key","undefined","dataAttrs","composeDataAttributes","styleUrls","getStyleUrls","ref","class","className","data-mfe-data","data-mfe-name","style","display","Object","fromEntries","entries","map","value","replace","letter","toLowerCase","launchDarkly","urls","css","length","encodeURIComponent"],"mappings":";AAEA,SAASA,uBAAuB,QAAQ,0BAA0B;AAElE,SAASC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAIpD,SAASC,cAAc,QAAQ,qBAAqB;AAGpD,SAASC,cAAc,QAAQ,qBAAqB;AAYpD,OAAO,SAASC,aAAaC,KAAwB;QAQ7CC;IAPJ,MAAM,EAAEC,QAAQ,EAAED,UAAU,EAAEE,QAAQ,EAAEC,mBAAmB,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGN;IACvF,MAAM,EAAEO,YAAY,EAAEC,kBAAkB,EAAEC,QAAQ,EAAEC,sBAAsB,EAAEC,OAAO,EAAE,GACjFV;IACJ,MAAMW,cAAcd,eAAeG;IAEnC,MAAMY,8BAA8BC,gBAChCd,MAAMa,2BAA2B,GACjCZ,0BAAAA,WAAWc,WAAW,cAAtBd,8CAAAA,uBAAwB,CAAC,6BAA6B;IAG1D,OAAO,CAAC,EAAEe,eAAe,EAAE,GAAGC,YAA6B;QACvD,MAAM,CAACC,WAAWC,aAAa,GAAGvB,SAAS;QAC3C,MAAM,CAACwB,eAAe,GAAG3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BAA4BqC,YAAY,cAAxCrC,gEAAAA,0CAA0CR,SAAS,GAAE;QACjE,OAAO;YAAE,GAAGQ,2BAA2B;YAAEqC,cAAc;gBAAEvC;YAAQ;QAAE;IACvE;IACA,OAAOE;AACX;AAEA,SAASqB,aAAa,EAAEiB,IAAI,EAA4B;IACpD,IAAIA,KAAKC,GAAG,CAACC,MAAM,EAAE;QACjB,OAAOC,mBAAmB5B,KAAKC,SAAS,CAACwB,KAAKC,GAAG;IACrD;AACJ"}
1
+ {"version":3,"sources":["../../src/utils/web-component.tsx"],"sourcesContent":["import { type LDService } from '@servicetitan/launchdarkly-service';\nimport { Log } from '@servicetitan/log-service';\nimport { useOptionalDependencies } from '@servicetitan/react-ioc';\nimport { ExposedDependencies } from '@servicetitan/startup-utils';\nimport { Fragment, useMemo, useState } from 'react';\nimport { ExposedInstanceDependencies, IWebComponent } from '../common';\nimport { MFEContextData } from '../contexts/mfe-data-context';\nimport { EventBus } from '../event-bus';\nimport { HistoryManager } from '../history-manager';\nimport { LoaderDataProps } from '../loader';\nimport { BundleInfo } from './get-bundle-info';\nimport { getElementName } from './get-element-name';\n\ninterface WebComponentProps {\n basename?: string;\n bundleInfo: BundleInfo;\n eventBus: EventBus;\n exposedDependencies?: ExposedDependencies;\n exposedInstanceDependencies?: ExposedInstanceDependencies;\n ldService?: LDService;\n logService?: Log;\n}\n\nexport function webComponent(props: WebComponentProps) {\n const { basename, bundleInfo, eventBus, exposedDependencies, ldService, logService } = props;\n const { WebComponent, resolvedBundleType, mfeSupportsRerendering, version } = bundleInfo;\n const elementName = getElementName(bundleInfo);\n\n const exposedInstanceDependencies = ensureLDVersion(\n props.exposedInstanceDependencies,\n bundleInfo.bundledWith?.['launchdarkly-js-client-sdk']\n );\n\n return ({ LoadingFallback, ...innerProps }: LoaderDataProps) => {\n const [isLoading, setIsLoading] = useState(true);\n const [historyManager] = useOptionalDependencies(HistoryManager);\n\n const handleRef = (webComponent: IWebComponent | null) => {\n webComponent?.provide({\n ldService,\n logService,\n historyManager,\n exposedDependencies,\n exposedInstanceDependencies,\n eventBus,\n basename,\n onReady: () => {\n setIsLoading(false);\n },\n });\n };\n\n // Stringify data object so that it can be passed as a data-attribute\n const stringifiedData = useMemo(() => JSON.stringify(innerProps.data), [innerProps.data]);\n\n /*\n * Set key for rendering the web component so that if the data from the Host change,\n * and the MFE's version of startup doesn't support watching for data changes, then\n * the web component will be re-mounted whenever the data changes.\n * This is only used as a fallback when the MFE's version is older.\n */\n const key = mfeSupportsRerendering ? undefined : stringifiedData;\n const dataAttrs = useMemo(() => composeDataAttributes(innerProps.data), [innerProps.data]);\n const styleUrls = getStyleUrls(bundleInfo);\n\n return (\n <Fragment>\n {isLoading && <LoadingFallback />}\n <WebComponent\n key={key}\n ref={handleRef}\n class={innerProps.className}\n {...(styleUrls && { 'style-urls': styleUrls })}\n /*\n * Continue to spread data as separate data attributes for backwards compatibility,\n * in case the Host has updated web-components, but the MFE has not\n */\n {...dataAttrs}\n data-mfe-data={stringifiedData}\n data-mfe-name={elementName}\n {...(version && { 'data-mfe-version': version })}\n // @ts-expect-error style exists on HTMLElement\n style={\n isLoading || resolvedBundleType === 'headless'\n ? { display: 'none' }\n : undefined\n }\n />\n </Fragment>\n );\n };\n}\n\n/*\n * Convert camelCase data props to kebab-case data attributes, prepended with data-\n * Ex: fooBar -> data-foo-bar\n */\nfunction composeDataAttributes(data: MFEContextData<{}> | undefined = {}) {\n return Object.fromEntries(\n Object.entries(data).map(([key, value]) => [\n 'data-' + key.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()),\n value,\n ])\n );\n}\n\nfunction ensureLDVersion(\n exposedInstanceDependencies: ExposedInstanceDependencies = {},\n version?: string\n) {\n if (version && !exposedInstanceDependencies.launchDarkly?.ldService) {\n return { ...exposedInstanceDependencies, launchDarkly: { version } };\n }\n return exposedInstanceDependencies;\n}\n\nfunction getStyleUrls({ urls }: Pick<BundleInfo, 'urls'>) {\n if (urls.css.length) {\n return encodeURIComponent(JSON.stringify(urls.css));\n }\n}\n"],"names":["useOptionalDependencies","Fragment","useMemo","useState","HistoryManager","getElementName","webComponent","props","bundleInfo","basename","eventBus","exposedDependencies","ldService","logService","WebComponent","resolvedBundleType","mfeSupportsRerendering","version","elementName","exposedInstanceDependencies","ensureLDVersion","bundledWith","LoadingFallback","innerProps","isLoading","setIsLoading","historyManager","handleRef","provide","onReady","stringifiedData","JSON","stringify","data","key","undefined","dataAttrs","composeDataAttributes","styleUrls","getStyleUrls","ref","class","className","data-mfe-data","data-mfe-name","style","display","Object","fromEntries","entries","map","value","replace","letter","toLowerCase","launchDarkly","urls","css","length","encodeURIComponent"],"mappings":";AAEA,SAASA,uBAAuB,QAAQ,0BAA0B;AAElE,SAASC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAIpD,SAASC,cAAc,QAAQ,qBAAqB;AAGpD,SAASC,cAAc,QAAQ,qBAAqB;AAYpD,OAAO,SAASC,aAAaC,KAAwB;QAO7CC;IANJ,MAAM,EAAEC,QAAQ,EAAED,UAAU,EAAEE,QAAQ,EAAEC,mBAAmB,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGN;IACvF,MAAM,EAAEO,YAAY,EAAEC,kBAAkB,EAAEC,sBAAsB,EAAEC,OAAO,EAAE,GAAGT;IAC9E,MAAMU,cAAcb,eAAeG;IAEnC,MAAMW,8BAA8BC,gBAChCb,MAAMY,2BAA2B,GACjCX,0BAAAA,WAAWa,WAAW,cAAtBb,8CAAAA,uBAAwB,CAAC,6BAA6B;IAG1D,OAAO,CAAC,EAAEc,eAAe,EAAE,GAAGC,YAA6B;QACvD,MAAM,CAACC,WAAWC,aAAa,GAAGtB,SAAS;QAC3C,MAAM,CAACuB,eAAe,GAAG1B,wBAAwBI;QAEjD,MAAMuB,YAAY,CAACrB;YACfA,yBAAAA,mCAAAA,aAAcsB,OAAO,CAAC;gBAClBhB;gBACAC;gBACAa;gBACAf;gBACAQ;gBACAT;gBACAD;gBACAoB,SAA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,IAAI,EAA4B;IACpD,IAAIA,KAAKC,GAAG,CAACC,MAAM,EAAE;QACjB,OAAOC,mBAAmB5B,KAAKC,SAAS,CAACwB,KAAKC,GAAG;IACrD;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/web-components",
3
- "version": "40.0.0",
3
+ "version": "40.1.0",
4
4
  "description": "Framework to build, register, and load Microfrontends into host applications",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/uikit/web-components",
6
6
  "repository": {
@@ -31,37 +31,35 @@
31
31
  "src"
32
32
  ],
33
33
  "dependencies": {
34
- "@servicetitan/error-boundary": "40.0.0",
35
- "@servicetitan/startup-utils": "40.0.0",
36
- "lodash.get": "~4.4.2",
34
+ "@servicetitan/error-boundary": "40.1.0",
35
+ "@servicetitan/startup-utils": "40.1.0",
37
36
  "mitt": "~3.0.1",
38
37
  "semver": "~7.8.5"
39
38
  },
40
39
  "devDependencies": {
41
- "@servicetitan/anvil2": "^3.13.7",
40
+ "@servicetitan/anvil2": "^3.15.0",
42
41
  "@servicetitan/design-system": "~14.5.3",
43
- "@servicetitan/launchdarkly-service": "40.0.0",
44
- "@servicetitan/log-service": "40.0.0",
45
- "@servicetitan/react-ioc": "40.0.0",
42
+ "@servicetitan/launchdarkly-service": "40.1.0",
43
+ "@servicetitan/log-service": "40.1.0",
44
+ "@servicetitan/react-ioc": "40.1.0",
46
45
  "@testing-library/dom": "^10.4.2",
47
46
  "@testing-library/jest-dom": "^7.0.1",
48
47
  "@testing-library/react": "^16.3.3",
49
48
  "@types/history": "~4.7.10",
50
- "@types/lodash.get": "~4.4.6",
51
49
  "@types/react": "~18.3.3",
52
50
  "@types/react-dom": "~18.3.0",
53
51
  "@types/semver": "~7.7.1",
54
52
  "history": "~4.10.1",
55
53
  "react": "~18.3.1",
56
54
  "react-dom": "~18.3.1",
57
- "shadow-dom-testing-library": "^1.14.1"
55
+ "shadow-dom-testing-library": "^1.14.2"
58
56
  },
59
57
  "peerDependencies": {
60
58
  "@servicetitan/anvil2": ">=1.5.0",
61
59
  "@servicetitan/design-system": ">=14.5.3",
62
- "@servicetitan/launchdarkly-service": "40.0.0",
63
- "@servicetitan/log-service": "40.0.0",
64
- "@servicetitan/react-ioc": "40.0.0",
60
+ "@servicetitan/launchdarkly-service": "40.1.0",
61
+ "@servicetitan/log-service": "40.1.0",
62
+ "@servicetitan/react-ioc": "40.1.0",
65
63
  "history": "~4.10.1",
66
64
  "react": ">=17.0.2",
67
65
  "react-dom": ">=17.0.2"
@@ -862,45 +862,6 @@ describe('[web-components] Loader', () => {
862
862
  });
863
863
  });
864
864
 
865
- describe('when onDispose is called from the web component', () => {
866
- async function onDisposeSetup() {
867
- await webComponentReadySetup();
868
- webComponentState.onDispose!();
869
- }
870
-
871
- const clearSpy = jest.fn();
872
-
873
- beforeEach(() => {
874
- Object.defineProperty(window, 'SharedDependencies.ServiceTitan.DesignSystem', {
875
- value: {
876
- getStorage: () => ({
877
- clear: clearSpy,
878
- }),
879
- },
880
- configurable: true,
881
- });
882
- });
883
-
884
- test('storage is not cleared', async () => {
885
- await onDisposeSetup();
886
- expect(clearSpy).not.toHaveBeenCalledWith(WEB_COMPONENT_NAME);
887
- });
888
-
889
- describe('when peerDependencies are provided', () => {
890
- beforeEach(() => {
891
- metadata.sharedDependencies = {
892
- '@servicetitan/design-system':
893
- 'SharedDependencies.ServiceTitan.DesignSystem',
894
- };
895
- });
896
-
897
- test('storage is cleared', async () => {
898
- await onDisposeSetup();
899
- expect(clearSpy).toHaveBeenCalledWith(WEB_COMPONENT_NAME);
900
- });
901
- });
902
- });
903
-
904
865
  describe('when a script tag (without a webComponent data attr) for this bundle is in the DOM before Loader is rendered', () => {
905
866
  const originalOnloadSpy = jest.fn();
906
867
 
@@ -44,7 +44,6 @@ describe('[web-components] loadScripts', () => {
44
44
  bundleInfo = {
45
45
  bundledWith: undefined,
46
46
  cacheHit: undefined,
47
- disposer: () => {},
48
47
  mfeSupportsRerendering: false,
49
48
  mfeHasUniqueChunkNamespace: false,
50
49
  mfeHasCompatibleLaunchDarklyVersion: false,
@@ -1,5 +1,4 @@
1
1
  import { ExposedDependencies, getVersionMismatches } from '@servicetitan/startup-utils';
2
- import get from 'lodash.get';
3
2
  import semver from 'semver';
4
3
  import { ExposedInstanceDependencies, getJson, GetJsonError } from '../common';
5
4
  import type { Metadata } from '../types';
@@ -88,15 +87,6 @@ export async function getBundleInfo({
88
87
  entrypoints = await getEntrypoints(`${bundleBaseUrl}/entrypoints.json`, requestCache);
89
88
  }
90
89
 
91
- const disposer = () => {
92
- if (resolvedBundleType === 'light') {
93
- const path = Object.values<string>(sharedDependencies).shift();
94
- if (path) {
95
- get(window, path).getStorage().clear(name);
96
- }
97
- }
98
- };
99
-
100
90
  let baseUrl = bundleBaseUrl;
101
91
  // Per-MFE dev-server port only happens during local development
102
92
  if (process.env.NODE_ENV !== 'production' && entrypoints.port) {
@@ -115,7 +105,6 @@ export async function getBundleInfo({
115
105
  return {
116
106
  bundledWith,
117
107
  cacheHit,
118
- disposer,
119
108
  mfeSupportsRerendering: getMFESupportsRerendering(bundledWith, dependencies),
120
109
  mfeHasUniqueChunkNamespace: getMFEHasUniqueChunkNamespace(bundledWith),
121
110
  mfeHasCompatibleLaunchDarklyVersion: getMFEHasCompatibleLaunchDarklyVersion(
@@ -23,8 +23,7 @@ interface WebComponentProps {
23
23
 
24
24
  export function webComponent(props: WebComponentProps) {
25
25
  const { basename, bundleInfo, eventBus, exposedDependencies, ldService, logService } = props;
26
- const { WebComponent, resolvedBundleType, disposer, mfeSupportsRerendering, version } =
27
- bundleInfo;
26
+ const { WebComponent, resolvedBundleType, mfeSupportsRerendering, version } = bundleInfo;
28
27
  const elementName = getElementName(bundleInfo);
29
28
 
30
29
  const exposedInstanceDependencies = ensureLDVersion(
@@ -48,9 +47,6 @@ export function webComponent(props: WebComponentProps) {
48
47
  onReady: () => {
49
48
  setIsLoading(false);
50
49
  },
51
- onDispose: () => {
52
- disposer();
53
- },
54
50
  });
55
51
  };
56
52