@servicetitan/web-components 33.1.1 → 34.0.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 (87) hide show
  1. package/dist/common.d.ts +1 -4
  2. package/dist/common.d.ts.map +1 -1
  3. package/dist/common.js +4 -4
  4. package/dist/common.js.map +1 -1
  5. package/dist/contexts/tests/mfe-data-context.test.js.map +1 -1
  6. package/dist/contexts/tests/mfe-metadata-context.test.js.map +1 -1
  7. package/dist/event-bus.d.ts.map +1 -1
  8. package/dist/event-bus.js.map +1 -1
  9. package/dist/globals.d.ts +2 -1
  10. package/dist/globals.d.ts.map +1 -1
  11. package/dist/globals.js +1 -1
  12. package/dist/globals.js.map +1 -1
  13. package/dist/headless-loader.d.ts.map +1 -1
  14. package/dist/headless-loader.js.map +1 -1
  15. package/dist/history-manager.d.ts.map +1 -1
  16. package/dist/history-manager.js.map +1 -1
  17. package/dist/loader.d.ts.map +1 -1
  18. package/dist/loader.js +4 -5
  19. package/dist/loader.js.map +1 -1
  20. package/dist/register-headless.d.ts.map +1 -1
  21. package/dist/register-headless.js.map +1 -1
  22. package/dist/register.d.ts.map +1 -1
  23. package/dist/register.js +5 -6
  24. package/dist/register.js.map +1 -1
  25. package/dist/render.js +1 -1
  26. package/dist/render.js.map +1 -1
  27. package/dist/use-prefetch.d.ts.map +1 -1
  28. package/dist/use-prefetch.js.map +1 -1
  29. package/dist/utils/get-bundle-info.d.ts +2 -1
  30. package/dist/utils/get-bundle-info.d.ts.map +1 -1
  31. package/dist/utils/get-bundle-info.js +4 -4
  32. package/dist/utils/get-bundle-info.js.map +1 -1
  33. package/dist/utils/get-entry-points.js +1 -1
  34. package/dist/utils/get-entry-points.js.map +1 -1
  35. package/dist/utils/get-ld-service-token.js +1 -1
  36. package/dist/utils/get-ld-service-token.js.map +1 -1
  37. package/dist/utils/get-mfe-supports-rerendering.js +1 -1
  38. package/dist/utils/get-mfe-supports-rerendering.js.map +1 -1
  39. package/dist/utils/index.d.ts +0 -1
  40. package/dist/utils/index.d.ts.map +1 -1
  41. package/dist/utils/index.js +0 -1
  42. package/dist/utils/index.js.map +1 -1
  43. package/dist/utils/validate-bundle-info.d.ts +2 -1
  44. package/dist/utils/validate-bundle-info.d.ts.map +1 -1
  45. package/dist/utils/validate-bundle-info.js +2 -2
  46. package/dist/utils/validate-bundle-info.js.map +1 -1
  47. package/dist/utils/web-component.d.ts +4 -3
  48. package/dist/utils/web-component.d.ts.map +1 -1
  49. package/dist/utils/web-component.js +2 -2
  50. package/dist/utils/web-component.js.map +1 -1
  51. package/package.json +15 -13
  52. package/src/__mocks__/test-component.tsx +1 -1
  53. package/src/__tests__/delayed.test.tsx +0 -1
  54. package/src/__tests__/event-bus.test.ts +1 -1
  55. package/src/__tests__/loader.test.tsx +7 -6
  56. package/src/__tests__/register-anvil2.test.tsx +0 -1
  57. package/src/__tests__/register-headless.test.tsx +0 -1
  58. package/src/__tests__/register.test.tsx +1 -1
  59. package/src/__tests__/use-prefetch.test.tsx +2 -2
  60. package/src/common.ts +3 -12
  61. package/src/contexts/tests/mfe-data-context.test.tsx +1 -1
  62. package/src/contexts/tests/mfe-metadata-context.test.tsx +1 -1
  63. package/src/event-bus.ts +0 -1
  64. package/src/globals.ts +2 -1
  65. package/src/headless-loader.tsx +1 -1
  66. package/src/history-manager.ts +1 -2
  67. package/src/loader.tsx +7 -8
  68. package/src/register-headless.ts +1 -1
  69. package/src/register.tsx +6 -7
  70. package/src/use-prefetch.ts +1 -1
  71. package/src/utils/__tests__/get-mfe-supports-rerendering.test.ts +1 -1
  72. package/src/utils/get-bundle-info.ts +6 -7
  73. package/src/utils/index.ts +0 -1
  74. package/src/utils/validate-bundle-info.ts +2 -1
  75. package/src/utils/web-component.tsx +6 -6
  76. package/dist/utils/get-version-mismatches.d.ts +0 -6
  77. package/dist/utils/get-version-mismatches.d.ts.map +0 -1
  78. package/dist/utils/get-version-mismatches.js +0 -30
  79. package/dist/utils/get-version-mismatches.js.map +0 -1
  80. package/dist/utils/is-compatible.d.ts +0 -2
  81. package/dist/utils/is-compatible.d.ts.map +0 -1
  82. package/dist/utils/is-compatible.js +0 -31
  83. package/dist/utils/is-compatible.js.map +0 -1
  84. package/src/utils/__tests__/get-version-mismatches.test.ts +0 -86
  85. package/src/utils/__tests__/is-compatible.test.ts +0 -91
  86. package/src/utils/get-version-mismatches.ts +0 -36
  87. package/src/utils/is-compatible.ts +0 -37
@@ -1,7 +1,6 @@
1
1
  import '@testing-library/jest-dom';
2
2
  import { render, within } from '@testing-library/react';
3
3
  import { Fragment } from 'react';
4
-
5
4
  import { expectStylesInDom, MockComponent, registerComponent } from '../__mocks__';
6
5
 
7
6
  function mockComponent(name: string) {
@@ -1,6 +1,5 @@
1
1
  import '@testing-library/jest-dom';
2
2
  import { render, waitFor } from '@testing-library/react';
3
-
4
3
  import { Entries, IWebComponent } from '../common';
5
4
  import { HeadlessCallback } from '../register-headless';
6
5
 
@@ -4,8 +4,8 @@ import { act, render } from '@testing-library/react';
4
4
  // @ts-ignore because Jest mistakenly complains that "'shadow-dom-testing-library' cannot be imported using this construct".
5
5
  import { screen } from 'shadow-dom-testing-library';
6
6
 
7
- import { IWebComponent } from '../common';
8
7
  import { expectStylesInDom, MockComponent, registerComponent } from '../__mocks__';
8
+ import { IWebComponent } from '../common';
9
9
 
10
10
  describe('[web-components] register', () => {
11
11
  const baseComponentName = 'mock-app';
@@ -1,8 +1,7 @@
1
- import { FC, PropsWithChildren } from 'react';
2
1
  import { Log } from '@servicetitan/log-service';
3
2
  import { Provider } from '@servicetitan/react-ioc';
4
3
  import { renderHook } from '@testing-library/react';
5
- import { getBundleInfo, supportsPrefetch } from '../utils';
4
+ import { FC, PropsWithChildren } from 'react';
6
5
  import {
7
6
  EXPOSED_DEPENDENCIES_TOKEN,
8
7
  EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
@@ -10,6 +9,7 @@ import {
10
9
  ExposedInstanceDependencies,
11
10
  } from '../common';
12
11
  import { usePrefetch } from '../use-prefetch';
12
+ import { getBundleInfo, supportsPrefetch } from '../utils';
13
13
 
14
14
  jest.mock('../utils', () => ({
15
15
  ...jest.requireActual('../utils'),
package/src/common.ts CHANGED
@@ -1,20 +1,11 @@
1
- import { useRef } from 'react';
2
-
3
- import { symbolToken } from '@servicetitan/react-ioc';
4
1
  import { type LDService } from '@servicetitan/launchdarkly-service';
5
2
  import { Log } from '@servicetitan/log-service';
6
-
3
+ import { symbolToken } from '@servicetitan/react-ioc';
4
+ import { ExposedDependencies } from '@servicetitan/startup-utils';
5
+ import { useRef } from 'react';
7
6
  import { EventBus } from './event-bus';
8
7
  import { HistoryManager } from './history-manager';
9
8
 
10
- export type ExposedDependencies = Record<
11
- string,
12
- {
13
- version: string;
14
- variable: string;
15
- }
16
- >;
17
-
18
9
  export interface ExposedInstanceDependencies {
19
10
  launchDarkly?: { version: string; ldService?: LDService };
20
11
  }
@@ -1,5 +1,5 @@
1
- import { FC, PropsWithChildren } from 'react';
2
1
  import { renderHook } from '@testing-library/react';
2
+ import { FC, PropsWithChildren } from 'react';
3
3
  import { MFEDataContext, useMFEDataContext } from '../mfe-data-context';
4
4
 
5
5
  describe(`[web-components] ${useMFEDataContext.name}`, () => {
@@ -1,5 +1,5 @@
1
- import { FC, PropsWithChildren } from 'react';
2
1
  import { renderHook } from '@testing-library/react';
2
+ import { FC, PropsWithChildren } from 'react';
3
3
  import { MFEMetadataContext, useMFEMetadataContext } from '../mfe-metadata-context';
4
4
 
5
5
  describe(`[web-components] ${useMFEMetadataContext.name}`, () => {
package/src/event-bus.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { symbolToken, SymbolToken } from '@servicetitan/react-ioc';
2
2
  import mitt from 'mitt';
3
-
4
3
  import { JSON, Serializable } from './types';
5
4
 
6
5
  export const EVENT_BUS_TOKEN = symbolToken<EventBus>('EVENT_BUS_TOKEN');
package/src/globals.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import { ExposedDependencies, ExposedInstanceDependencies } from './common';
2
+ import { ExposedDependencies } from '@servicetitan/startup-utils';
3
+ import { ExposedInstanceDependencies } from './common';
3
4
 
4
5
  declare global {
5
6
  export const EXPOSED_DEPENDENCIES: ExposedDependencies | undefined;
@@ -1,4 +1,4 @@
1
- import { UnrestrictedLoaderProps, Loader } from './loader';
1
+ import { Loader, UnrestrictedLoaderProps } from './loader';
2
2
 
3
3
  type HeadlessLoaderProps<T> = Pick<
4
4
  UnrestrictedLoaderProps<T>,
@@ -1,6 +1,5 @@
1
- import { History, Location, UnregisterCallback } from 'history';
2
-
3
1
  import { injectable } from '@servicetitan/react-ioc';
2
+ import { History, Location, UnregisterCallback } from 'history';
4
3
 
5
4
  @injectable()
6
5
  export class HistoryManager {
package/src/loader.tsx CHANGED
@@ -1,3 +1,8 @@
1
+ import { ErrorBoundary } from '@servicetitan/error-boundary';
2
+ import { type LDService } from '@servicetitan/launchdarkly-service';
3
+ import { Log } from '@servicetitan/log-service';
4
+ import { useOptionalDependencies } from '@servicetitan/react-ioc';
5
+ import { ExposedDependencies } from '@servicetitan/startup-utils';
1
6
  import {
2
7
  ReactElement,
3
8
  ReactNode,
@@ -10,29 +15,23 @@ import {
10
15
  useMemo,
11
16
  useRef,
12
17
  } from 'react';
13
- import { ErrorBoundary } from '@servicetitan/error-boundary';
14
- import { type LDService } from '@servicetitan/launchdarkly-service';
15
- import { Log } from '@servicetitan/log-service';
16
- import { useOptionalDependencies } from '@servicetitan/react-ioc';
17
-
18
18
  import {
19
19
  EXPOSED_DEPENDENCIES_TOKEN,
20
20
  EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
21
- ExposedDependencies,
22
21
  ExposedInstanceDependencies,
23
22
  GetJsonError,
24
23
  useCancelation,
25
24
  } from './common';
26
25
  import { MFEContextData } from './contexts/mfe-data-context';
27
26
  import { Delayed } from './delayed';
28
- import { EventBus, EVENT_BUS_TOKEN } from './event-bus';
27
+ import { EVENT_BUS_TOKEN, EventBus } from './event-bus';
29
28
  import { EXPOSED_DEPENDENCIES, EXPOSED_INSTANCE_DEPENDENCIES } from './globals';
30
29
  import {
31
30
  BundleInfo,
32
31
  getBundleInfo,
33
32
  getLDServiceToken,
34
- validateBundleInfo,
35
33
  loadScripts,
34
+ validateBundleInfo,
36
35
  webComponent,
37
36
  } from './utils';
38
37
 
@@ -1,7 +1,7 @@
1
1
  import type { LDService } from '@servicetitan/launchdarkly-service';
2
+ import type { Log } from '@servicetitan/log-service';
2
3
  import type { Entries, IWebComponent } from './common';
3
4
  import type { EventBus } from './event-bus';
4
- import type { Log } from '@servicetitan/log-service';
5
5
  import { Serializable } from './types';
6
6
 
7
7
  type HeadlessCallbackArgs<TMfeData, TEventBus extends EventBus = EventBus> = Pick<
package/src/register.tsx CHANGED
@@ -1,22 +1,21 @@
1
- import { FC, ComponentType, ReactElement, useEffect } from 'react';
2
1
  import { type LDService } from '@servicetitan/launchdarkly-service';
3
2
  import { Log } from '@servicetitan/log-service';
4
3
  import { Provider } from '@servicetitan/react-ioc';
5
-
4
+ import { ExposedDependencies } from '@servicetitan/startup-utils';
5
+ import { ComponentType, FC, ReactElement, useEffect } from 'react';
6
6
  import {
7
7
  BASENAME_TOKEN,
8
+ Entries,
8
9
  EXPOSED_DEPENDENCIES_TOKEN,
9
10
  EXPOSED_INSTANCE_DEPENDENCIES_TOKEN,
10
- IS_WEB_COMPONENT_TOKEN,
11
- RENDER_ROOT_TOKEN,
12
- Entries,
13
- ExposedDependencies,
14
11
  ExposedInstanceDependencies,
12
+ IS_WEB_COMPONENT_TOKEN,
15
13
  IWebComponent,
14
+ RENDER_ROOT_TOKEN,
16
15
  } from './common';
17
16
  import { MFEDataContext } from './contexts/mfe-data-context';
18
17
  import { MFEMetadataContext } from './contexts/mfe-metadata-context';
19
- import { EventBus, EVENT_BUS_TOKEN } from './event-bus';
18
+ import { EVENT_BUS_TOKEN, EventBus } from './event-bus';
20
19
  import { WEB_COMPONENT_NAME } from './globals';
21
20
  import { HistoryManager } from './history-manager';
22
21
  import { render } from './render';
@@ -1,8 +1,8 @@
1
1
  import { Log } from '@servicetitan/log-service';
2
2
  import { useOptionalDependencies } from '@servicetitan/react-ioc';
3
3
  import { EXPOSED_DEPENDENCIES_TOKEN, EXPOSED_INSTANCE_DEPENDENCIES_TOKEN } from './common';
4
- import { getBundleInfo, supportsPrefetch } from './utils';
5
4
  import { LoaderProps } from './loader';
5
+ import { getBundleInfo, supportsPrefetch } from './utils';
6
6
 
7
7
  /**
8
8
  * Prefetch and cache bundle info for a given MFE, so that Loader can load it faster later.
@@ -1,5 +1,5 @@
1
- import { getMFESupportsRerendering } from '../get-mfe-supports-rerendering';
2
1
  import { Metadata } from '../get-bundle-info';
2
+ import { getMFESupportsRerendering } from '../get-mfe-supports-rerendering';
3
3
 
4
4
  describe(`[web-components] ${getMFESupportsRerendering.name}`, () => {
5
5
  let metadata: Required<Pick<Metadata, 'bundledWith' | 'dependencies'>>;
@@ -1,15 +1,14 @@
1
- import semver from 'semver';
1
+ import { ExposedDependencies, getVersionMismatches } from '@servicetitan/startup-utils';
2
2
  import get from 'lodash.get';
3
-
4
- import { ExposedDependencies, ExposedInstanceDependencies, getJson, GetJsonError } from '../common';
5
- import { getCachedMetadata } from './get-cached-metadata';
3
+ import semver from 'semver';
4
+ import { ExposedInstanceDependencies, getJson, GetJsonError } from '../common';
5
+ import type { Metadata } from '../types';
6
6
  import { getCacheSetting } from './get-cache-setting';
7
+ import { getCachedMetadata } from './get-cached-metadata';
7
8
  import { EntryPoints, getEntrypoints } from './get-entry-points';
8
9
  import { getMFEHasCompatibleLaunchDarklyVersion } from './get-mfe-has-compatible-launchdarkly-version';
9
- import { getMFESupportsRerendering } from './get-mfe-supports-rerendering';
10
10
  import { getMFEHasUniqueChunkNamespace } from './get-mfe-has-unique-chunk-namespace';
11
- import { getVersionMismatches } from './get-version-mismatches';
12
- import type { Metadata } from '../types';
11
+ import { getMFESupportsRerendering } from './get-mfe-supports-rerendering';
13
12
 
14
13
  export type BundleInfo = Awaited<ReturnType<typeof getBundleInfo>>;
15
14
 
@@ -3,7 +3,6 @@ export * from './get-element-name';
3
3
  export * from './get-entry-points';
4
4
  export * from './get-ld-service-token';
5
5
  export * from './get-mfe-supports-rerendering';
6
- export * from './get-version-mismatches';
7
6
  export * from './is-versioned-url';
8
7
  export * from './load-scripts';
9
8
  export * from './supports-prefetch';
@@ -1,5 +1,6 @@
1
1
  import { Log } from '@servicetitan/log-service';
2
- import { ExposedDependencies, ExposedInstanceDependencies } from '../common';
2
+ import { ExposedDependencies } from '@servicetitan/startup-utils';
3
+ import { ExposedInstanceDependencies } from '../common';
3
4
  import { BundleInfo } from './get-bundle-info';
4
5
 
5
6
  interface Context {
@@ -1,15 +1,15 @@
1
- import { Fragment, useMemo, useState } from 'react';
2
- import { Log } from '@servicetitan/log-service';
3
1
  import { type LDService } from '@servicetitan/launchdarkly-service';
2
+ import { Log } from '@servicetitan/log-service';
4
3
  import { useOptionalDependencies } from '@servicetitan/react-ioc';
5
-
6
- import { ExposedDependencies, ExposedInstanceDependencies, IWebComponent } from '../common';
4
+ import { ExposedDependencies } from '@servicetitan/startup-utils';
5
+ import { Fragment, useMemo, useState } from 'react';
6
+ import { ExposedInstanceDependencies, IWebComponent } from '../common';
7
7
  import { MFEContextData } from '../contexts/mfe-data-context';
8
8
  import { EventBus } from '../event-bus';
9
- import { BundleInfo } from './get-bundle-info';
10
- import { getElementName } from './get-element-name';
11
9
  import { HistoryManager } from '../history-manager';
12
10
  import { LoaderDataProps } from '../loader';
11
+ import { BundleInfo } from './get-bundle-info';
12
+ import { getElementName } from './get-element-name';
13
13
 
14
14
  interface WebComponentProps {
15
15
  basename?: string;
@@ -1,6 +0,0 @@
1
- import { ExposedDependencies } from '../common';
2
- export declare const getVersionMismatches: (exposedDependencies: ExposedDependencies, dependencies: Record<string, string>, sharedDependencies: Record<string, string>) => Record<string, {
3
- host: string;
4
- package: string;
5
- }> | undefined;
6
- //# sourceMappingURL=get-version-mismatches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-version-mismatches.d.ts","sourceRoot":"","sources":["../../src/utils/get-version-mismatches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGhD,eAAO,MAAM,oBAAoB,GAC7B,qBAAqB,mBAAmB,EACxC,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,oBAAoB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;UAeT,MAAM;aAAW,MAAM;cAc3D,CAAC"}
@@ -1,30 +0,0 @@
1
- import { isCompatible } from './is-compatible';
2
- export const getVersionMismatches = (exposedDependencies, dependencies, sharedDependencies)=>{
3
- const mismatch = Object.entries(exposedDependencies).reduce((result, [dependency, { version: hostVersion }])=>{
4
- const packageVersion = dependencies[dependency];
5
- if (packageVersion && !!sharedDependencies[dependency] && !isCompatible(hostVersion, packageVersion)) {
6
- result[dependency] = {
7
- host: hostVersion,
8
- package: packageVersion
9
- };
10
- }
11
- return result;
12
- }, {});
13
- for (const [dependency, variable] of Object.entries(sharedDependencies)){
14
- const packageVersion = dependencies[dependency];
15
- if (!exposedDependencies[dependency]) {
16
- mismatch[dependency] = {
17
- host: 'missing',
18
- package: packageVersion
19
- };
20
- } else if (exposedDependencies[dependency].variable !== variable) {
21
- mismatch[dependency] = {
22
- host: 'wrong global variable',
23
- package: packageVersion
24
- };
25
- }
26
- }
27
- return Object.keys(mismatch).length ? mismatch : undefined;
28
- };
29
-
30
- //# sourceMappingURL=get-version-mismatches.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/get-version-mismatches.ts"],"sourcesContent":["import { ExposedDependencies } from '../common';\nimport { isCompatible } from './is-compatible';\n\nexport const getVersionMismatches = (\n exposedDependencies: ExposedDependencies,\n dependencies: Record<string, string>,\n sharedDependencies: Record<string, string>\n) => {\n const mismatch = Object.entries(exposedDependencies).reduce(\n (result, [dependency, { version: hostVersion }]) => {\n const packageVersion = dependencies[dependency];\n if (\n packageVersion &&\n !!sharedDependencies[dependency] &&\n !isCompatible(hostVersion, packageVersion)\n ) {\n result[dependency] = { host: hostVersion, package: packageVersion };\n }\n\n return result;\n },\n {} as Record<string, { host: string; package: string }>\n );\n\n for (const [dependency, variable] of Object.entries(sharedDependencies)) {\n const packageVersion = dependencies[dependency];\n\n if (!exposedDependencies[dependency]) {\n mismatch[dependency] = { host: 'missing', package: packageVersion };\n } else if (exposedDependencies[dependency].variable !== variable) {\n mismatch[dependency] = { host: 'wrong global variable', package: packageVersion };\n }\n }\n\n return Object.keys(mismatch).length ? mismatch : undefined;\n};\n"],"names":["isCompatible","getVersionMismatches","exposedDependencies","dependencies","sharedDependencies","mismatch","Object","entries","reduce","result","dependency","version","hostVersion","packageVersion","host","package","variable","keys","length","undefined"],"mappings":"AACA,SAASA,YAAY,QAAQ,kBAAkB;AAE/C,OAAO,MAAMC,uBAAuB,CAChCC,qBACAC,cACAC;IAEA,MAAMC,WAAWC,OAAOC,OAAO,CAACL,qBAAqBM,MAAM,CACvD,CAACC,QAAQ,CAACC,YAAY,EAAEC,SAASC,WAAW,EAAE,CAAC;QAC3C,MAAMC,iBAAiBV,YAAY,CAACO,WAAW;QAC/C,IACIG,kBACA,CAAC,CAACT,kBAAkB,CAACM,WAAW,IAChC,CAACV,aAAaY,aAAaC,iBAC7B;YACEJ,MAAM,CAACC,WAAW,GAAG;gBAAEI,MAAMF;gBAAaG,SAASF;YAAe;QACtE;QAEA,OAAOJ;IACX,GACA,CAAC;IAGL,KAAK,MAAM,CAACC,YAAYM,SAAS,IAAIV,OAAOC,OAAO,CAACH,oBAAqB;QACrE,MAAMS,iBAAiBV,YAAY,CAACO,WAAW;QAE/C,IAAI,CAACR,mBAAmB,CAACQ,WAAW,EAAE;YAClCL,QAAQ,CAACK,WAAW,GAAG;gBAAEI,MAAM;gBAAWC,SAASF;YAAe;QACtE,OAAO,IAAIX,mBAAmB,CAACQ,WAAW,CAACM,QAAQ,KAAKA,UAAU;YAC9DX,QAAQ,CAACK,WAAW,GAAG;gBAAEI,MAAM;gBAAyBC,SAASF;YAAe;QACpF;IACJ;IAEA,OAAOP,OAAOW,IAAI,CAACZ,UAAUa,MAAM,GAAGb,WAAWc;AACrD,EAAE"}
@@ -1,2 +0,0 @@
1
- export declare function isCompatible(hostVersion: string, packageVersion: string): boolean;
2
- //# sourceMappingURL=is-compatible.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-compatible.d.ts","sourceRoot":"","sources":["../../src/utils/is-compatible.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAkCvE"}
@@ -1,31 +0,0 @@
1
- import semver from 'semver';
2
- export function isCompatible(hostVersion, packageVersion) {
3
- if (hostVersion === packageVersion) {
4
- return true;
5
- }
6
- if (hostVersion === '*') {
7
- return false;
8
- }
9
- if (packageVersion === '*') {
10
- return true;
11
- }
12
- // host and package have exact non-equal versions
13
- if (semver.valid(hostVersion) && semver.valid(packageVersion)) {
14
- return false;
15
- }
16
- // exact package version couldn't be compatible with host range
17
- if (semver.validRange(hostVersion) && semver.valid(packageVersion)) {
18
- return false;
19
- }
20
- // exact host version must be in package range
21
- if (semver.valid(hostVersion) && semver.validRange(packageVersion)) {
22
- return semver.satisfies(hostVersion, packageVersion);
23
- }
24
- // host range must be fully included in package range
25
- if (semver.validRange(hostVersion) && semver.validRange(packageVersion)) {
26
- return semver.subset(hostVersion, packageVersion);
27
- }
28
- return false;
29
- }
30
-
31
- //# sourceMappingURL=is-compatible.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/is-compatible.ts"],"sourcesContent":["import semver from 'semver';\n\nexport function isCompatible(hostVersion: string, packageVersion: string) {\n if (hostVersion === packageVersion) {\n return true;\n }\n\n if (hostVersion === '*') {\n return false;\n }\n\n if (packageVersion === '*') {\n return true;\n }\n\n // host and package have exact non-equal versions\n if (semver.valid(hostVersion) && semver.valid(packageVersion)) {\n return false;\n }\n\n // exact package version couldn't be compatible with host range\n if (semver.validRange(hostVersion) && semver.valid(packageVersion)) {\n return false;\n }\n\n // exact host version must be in package range\n if (semver.valid(hostVersion) && semver.validRange(packageVersion)) {\n return semver.satisfies(hostVersion, packageVersion);\n }\n\n // host range must be fully included in package range\n if (semver.validRange(hostVersion) && semver.validRange(packageVersion)) {\n return semver.subset(hostVersion, packageVersion);\n }\n\n return false;\n}\n"],"names":["semver","isCompatible","hostVersion","packageVersion","valid","validRange","satisfies","subset"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAE5B,OAAO,SAASC,aAAaC,WAAmB,EAAEC,cAAsB;IACpE,IAAID,gBAAgBC,gBAAgB;QAChC,OAAO;IACX;IAEA,IAAID,gBAAgB,KAAK;QACrB,OAAO;IACX;IAEA,IAAIC,mBAAmB,KAAK;QACxB,OAAO;IACX;IAEA,iDAAiD;IACjD,IAAIH,OAAOI,KAAK,CAACF,gBAAgBF,OAAOI,KAAK,CAACD,iBAAiB;QAC3D,OAAO;IACX;IAEA,+DAA+D;IAC/D,IAAIH,OAAOK,UAAU,CAACH,gBAAgBF,OAAOI,KAAK,CAACD,iBAAiB;QAChE,OAAO;IACX;IAEA,8CAA8C;IAC9C,IAAIH,OAAOI,KAAK,CAACF,gBAAgBF,OAAOK,UAAU,CAACF,iBAAiB;QAChE,OAAOH,OAAOM,SAAS,CAACJ,aAAaC;IACzC;IAEA,qDAAqD;IACrD,IAAIH,OAAOK,UAAU,CAACH,gBAAgBF,OAAOK,UAAU,CAACF,iBAAiB;QACrE,OAAOH,OAAOO,MAAM,CAACL,aAAaC;IACtC;IAEA,OAAO;AACX"}
@@ -1,86 +0,0 @@
1
- import { ExposedDependencies } from '../../common';
2
- import { getVersionMismatches } from '../get-version-mismatches';
3
-
4
- describe(`[web-components] ${getVersionMismatches.name}`, () => {
5
- let sharedDependencies: Record<string, string> = {};
6
- let dependencies: Record<string, string> = {};
7
- let exposedDependencies: ExposedDependencies = {};
8
-
9
- beforeEach(() => {
10
- sharedDependencies = {
11
- '@servicetitan/design-system': 'SharedDependencies.ServiceTitan.DesignSystem',
12
- };
13
-
14
- dependencies = {
15
- '@servicetitan/design-system': '~11.8.0',
16
- };
17
-
18
- exposedDependencies = {
19
- '@servicetitan/design-system': {
20
- version: '~11.8.0',
21
- variable: 'SharedDependencies.ServiceTitan.DesignSystem',
22
- },
23
- };
24
- });
25
-
26
- function itReturnsNoMismatches() {
27
- test('returns no mismatches', () => {
28
- expect(
29
- getVersionMismatches(exposedDependencies, dependencies, sharedDependencies)
30
- ).toEqual(undefined);
31
- });
32
- }
33
-
34
- itReturnsNoMismatches();
35
-
36
- describe('when there is a versions mismatch', () => {
37
- beforeEach(() => (dependencies['@servicetitan/design-system'] = '~12.0.0'));
38
-
39
- test('returns the mismatch', () => {
40
- expect(
41
- getVersionMismatches(exposedDependencies, dependencies, sharedDependencies)
42
- ).toEqual({
43
- '@servicetitan/design-system': {
44
- host: '~11.8.0',
45
- package: '~12.0.0',
46
- },
47
- });
48
- });
49
-
50
- describe('when the mismatch is not a shared dependency', () => {
51
- beforeEach(() => (sharedDependencies = {}));
52
-
53
- itReturnsNoMismatches();
54
- });
55
- });
56
-
57
- describe('when a dependency is missing from exposed dependencies', () => {
58
- beforeEach(() => delete exposedDependencies['@servicetitan/design-system']);
59
-
60
- test('returns an object citing the dependency is missing from the host', () => {
61
- expect(
62
- getVersionMismatches(exposedDependencies, dependencies, sharedDependencies)
63
- ).toEqual({
64
- '@servicetitan/design-system': {
65
- host: 'missing',
66
- package: '~11.8.0',
67
- },
68
- });
69
- });
70
- });
71
-
72
- describe('when a variable does not match', () => {
73
- beforeEach(() => (exposedDependencies['@servicetitan/design-system'].variable = 'foo'));
74
-
75
- test('returns an object citing the variable is wrong', () => {
76
- expect(
77
- getVersionMismatches(exposedDependencies, dependencies, sharedDependencies)
78
- ).toEqual({
79
- '@servicetitan/design-system': {
80
- host: 'wrong global variable',
81
- package: '~11.8.0',
82
- },
83
- });
84
- });
85
- });
86
- });
@@ -1,91 +0,0 @@
1
- import { isCompatible } from '../is-compatible';
2
-
3
- describe(`[web-components] ${isCompatible.name}`, () => {
4
- let hostVersion: string;
5
- let packageVersion: string;
6
-
7
- beforeEach(() => {
8
- hostVersion = 'foo';
9
- packageVersion = 'bar';
10
- });
11
-
12
- function returnsFalse() {
13
- test('returns false', () => {
14
- expect(isCompatible(hostVersion, packageVersion)).toBe(false);
15
- });
16
- }
17
-
18
- function returnsTrue() {
19
- test('returns true', () => {
20
- expect(isCompatible(hostVersion, packageVersion)).toBe(true);
21
- });
22
- }
23
-
24
- returnsFalse();
25
-
26
- describe('when versions are equal', () => {
27
- beforeEach(() => {
28
- hostVersion = '1.0.0';
29
- packageVersion = '1.0.0';
30
- });
31
- returnsTrue();
32
- });
33
-
34
- describe("when hostVersion is '*'", () => {
35
- beforeEach(() => (hostVersion = '*'));
36
- returnsFalse();
37
- });
38
-
39
- describe("when packageVersion is '*'", () => {
40
- beforeEach(() => (packageVersion = '*'));
41
- returnsTrue();
42
- });
43
-
44
- describe('when versions are both exact SemVers and not equal', () => {
45
- beforeEach(() => {
46
- hostVersion = '1.0.0';
47
- packageVersion = '1.2.0';
48
- });
49
- returnsFalse();
50
- });
51
-
52
- describe('when hostVersion is a SemVer range and packageVersion is an exact SemVer', () => {
53
- beforeEach(() => {
54
- hostVersion = '^1.0.0';
55
- packageVersion = '1.2.0';
56
- });
57
- returnsFalse();
58
- });
59
-
60
- describe('when hostVersion is an exact SemVer that falls within the packageVersion SemVer range', () => {
61
- beforeEach(() => {
62
- hostVersion = '1.2.0';
63
- packageVersion = '^1.0.0';
64
- });
65
- returnsTrue();
66
- });
67
-
68
- describe('when hostVersion is an exact SemVer that does not fall within the packageVersion SemVer range', () => {
69
- beforeEach(() => {
70
- hostVersion = '1.2.0';
71
- packageVersion = '~1.0.0';
72
- });
73
- returnsFalse();
74
- });
75
-
76
- describe('when hostVersion is a SemVer range that falls within the packageVersion SemVer range', () => {
77
- beforeEach(() => {
78
- hostVersion = '~1.2.0';
79
- packageVersion = '^1.0.0';
80
- });
81
- returnsTrue();
82
- });
83
-
84
- describe('when hostVersion is an exact SemVer that does not fall within the packageVersion SemVer range', () => {
85
- beforeEach(() => {
86
- hostVersion = '^1.2.0';
87
- packageVersion = '~1.0.0';
88
- });
89
- returnsFalse();
90
- });
91
- });
@@ -1,36 +0,0 @@
1
- import { ExposedDependencies } from '../common';
2
- import { isCompatible } from './is-compatible';
3
-
4
- export const getVersionMismatches = (
5
- exposedDependencies: ExposedDependencies,
6
- dependencies: Record<string, string>,
7
- sharedDependencies: Record<string, string>
8
- ) => {
9
- const mismatch = Object.entries(exposedDependencies).reduce(
10
- (result, [dependency, { version: hostVersion }]) => {
11
- const packageVersion = dependencies[dependency];
12
- if (
13
- packageVersion &&
14
- !!sharedDependencies[dependency] &&
15
- !isCompatible(hostVersion, packageVersion)
16
- ) {
17
- result[dependency] = { host: hostVersion, package: packageVersion };
18
- }
19
-
20
- return result;
21
- },
22
- {} as Record<string, { host: string; package: string }>
23
- );
24
-
25
- for (const [dependency, variable] of Object.entries(sharedDependencies)) {
26
- const packageVersion = dependencies[dependency];
27
-
28
- if (!exposedDependencies[dependency]) {
29
- mismatch[dependency] = { host: 'missing', package: packageVersion };
30
- } else if (exposedDependencies[dependency].variable !== variable) {
31
- mismatch[dependency] = { host: 'wrong global variable', package: packageVersion };
32
- }
33
- }
34
-
35
- return Object.keys(mismatch).length ? mismatch : undefined;
36
- };
@@ -1,37 +0,0 @@
1
- import semver from 'semver';
2
-
3
- export function isCompatible(hostVersion: string, packageVersion: string) {
4
- if (hostVersion === packageVersion) {
5
- return true;
6
- }
7
-
8
- if (hostVersion === '*') {
9
- return false;
10
- }
11
-
12
- if (packageVersion === '*') {
13
- return true;
14
- }
15
-
16
- // host and package have exact non-equal versions
17
- if (semver.valid(hostVersion) && semver.valid(packageVersion)) {
18
- return false;
19
- }
20
-
21
- // exact package version couldn't be compatible with host range
22
- if (semver.validRange(hostVersion) && semver.valid(packageVersion)) {
23
- return false;
24
- }
25
-
26
- // exact host version must be in package range
27
- if (semver.valid(hostVersion) && semver.validRange(packageVersion)) {
28
- return semver.satisfies(hostVersion, packageVersion);
29
- }
30
-
31
- // host range must be fully included in package range
32
- if (semver.validRange(hostVersion) && semver.validRange(packageVersion)) {
33
- return semver.subset(hostVersion, packageVersion);
34
- }
35
-
36
- return false;
37
- }