@servicetitan/web-components 22.21.0 → 22.21.1

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.
@@ -0,0 +1,2 @@
1
+ export declare const handlers: never[];
2
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/__mocks__/handlers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,SAAK,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const handlers = [];
2
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/__mocks__/handlers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const server: import("msw/lib/glossary-de6278a9").K;
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/__mocks__/server.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,uCAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { setupServer } from 'msw/node';
2
+ import { handlers } from './handlers';
3
+ export const server = setupServer(...handlers);
4
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/__mocks__/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC"}
@@ -14,8 +14,14 @@ export function getMFESupportsRerendering(bundledWith, dependencies) {
14
14
  return !!((_b = (_a = isSupportedVersion(bundledWith === null || bundledWith === void 0 ? void 0 : bundledWith['@servicetitan/web-components'])) !== null && _a !== void 0 ? _a : isSupportedVersion(dependencies === null || dependencies === void 0 ? void 0 : dependencies['@servicetitan/web-components'])) !== null && _b !== void 0 ? _b : isSupportedVersion(bundledWith === null || bundledWith === void 0 ? void 0 : bundledWith['@servicetitan/startup']));
15
15
  }
16
16
  function isSupportedVersion(version) {
17
- if (version) {
18
- return semver.gte(version, '22.12.0');
17
+ try {
18
+ const minVersion = version && semver.minVersion(version);
19
+ if (minVersion) {
20
+ return semver.gte(minVersion, '22.12.0');
21
+ }
22
+ }
23
+ catch (e) {
24
+ return undefined;
19
25
  }
20
26
  }
21
27
  //# sourceMappingURL=get-mfe-supports-rerendering.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-mfe-supports-rerendering.js","sourceRoot":"","sources":["../src/get-mfe-supports-rerendering.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CACrC,WAAoC,EACpC,YAAsC;;IAEtC,OAAO,CAAC,CAAC,CACL,MAAA,MAAA,kBAAkB,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,8BAA8B,CAAC,CAAC,mCACjE,kBAAkB,CAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,8BAA8B,CAAC,CAAC,mCAClE,kBAAkB,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,uBAAuB,CAAC,CAAC,CAC7D,CAAC;AACN,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IACxC,IAAI,OAAO,EAAE;QACT,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;KACzC;AACL,CAAC"}
1
+ {"version":3,"file":"get-mfe-supports-rerendering.js","sourceRoot":"","sources":["../src/get-mfe-supports-rerendering.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CACrC,WAAoC,EACpC,YAAsC;;IAEtC,OAAO,CAAC,CAAC,CACL,MAAA,MAAA,kBAAkB,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,8BAA8B,CAAC,CAAC,mCACjE,kBAAkB,CAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,8BAA8B,CAAC,CAAC,mCAClE,kBAAkB,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,uBAAuB,CAAC,CAAC,CAC7D,CAAC;AACN,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IACxC,IAAI;QACA,MAAM,UAAU,GAAG,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,UAAU,EAAE;YACZ,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;SAC5C;KACJ;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,SAAS,CAAC;KACpB;AACL,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Context used to pass data from the host to the MFEs
3
+ */
4
+ /// <reference types="react" />
5
+ declare type JSONPrimitive = string | number | boolean | null | undefined;
6
+ declare type JSON = {
7
+ [key: string]: JSONPrimitive | JSON[] | JSON;
8
+ };
9
+ export declare type MFEContextData<T> = {
10
+ [P in keyof T]: T[P] extends JSONPrimitive ? T[P] : T[P] extends (infer U)[] ? MFEContextData<U>[] : T[P] extends JSON ? MFEContextData<T[P]> : never;
11
+ };
12
+ export interface MFEMetadata {
13
+ shadowRoot: ShadowRoot;
14
+ portalShadowRoot: ShadowRoot;
15
+ }
16
+ export declare type MFEProps<T = {}> = {
17
+ metadata: MFEMetadata;
18
+ } & T;
19
+ export declare const MFEDataContext: import("react").Context<JSON>;
20
+ export declare function useMFEDataContext<T extends MFEContextData<T>>(): MFEProps<T>;
21
+ export {};
22
+ //# sourceMappingURL=mfe-data-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-data-context.d.ts","sourceRoot":"","sources":["../src/mfe-data-context.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAIH,aAAK,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAGlE,aAAK,IAAI,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;CAAE,CAAC;AAG7D,oBAAY,cAAc,CAAC,CAAC,IAAI;KAC3B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,GACpC,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACxB,cAAc,CAAC,CAAC,CAAC,EAAE,GACnB,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GACjB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACpB,KAAK;CACd,CAAC;AAEF,MAAM,WAAW,WAAW;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,EAAE,UAAU,CAAC;CAChC;AAED,oBAAY,QAAQ,CAAC,CAAC,GAAG,EAAE,IAAI;IAC3B,QAAQ,EAAE,WAAW,CAAC;CACzB,GAAG,CAAC,CAAC;AAEN,eAAO,MAAM,cAAc,+BAA0B,CAAC;AAEtD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,iBAI5D"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Context used to pass data from the host to the MFEs
3
+ */
4
+ import { createContext, useContext } from 'react';
5
+ export const MFEDataContext = createContext({});
6
+ export function useMFEDataContext() {
7
+ const context = useContext(MFEDataContext);
8
+ return context;
9
+ }
10
+ //# sourceMappingURL=mfe-data-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-data-context.js","sourceRoot":"","sources":["../src/mfe-data-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AA2BlD,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAO,EAAE,CAAC,CAAC;AAEtD,MAAM,UAAU,iBAAiB;IAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAgB,CAAC;IAE1D,OAAO,OAAO,CAAC;AACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/web-components",
3
- "version": "22.21.0",
3
+ "version": "22.21.1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,6 +51,5 @@
51
51
  },
52
52
  "cli": {
53
53
  "webpack": false
54
- },
55
- "gitHead": "729b7ca4eb38c323ac538a73573cadd54a4ff839"
54
+ }
56
55
  }
@@ -17,6 +17,12 @@ describe(`[web-components] ${getMFESupportsRerendering.name}`, () => {
17
17
  });
18
18
  }
19
19
 
20
+ function itRaises(error: any) {
21
+ test(`raises ${error.name}`, () => {
22
+ expect(() => subject()).toThrow(error);
23
+ });
24
+ }
25
+
20
26
  function subject() {
21
27
  return getMFESupportsRerendering(metadata.bundledWith, metadata.dependencies);
22
28
  }
@@ -41,6 +47,13 @@ describe(`[web-components] ${getMFESupportsRerendering.name}`, () => {
41
47
  const dependencies: { name: string; version: string; expected: boolean }[] = [
42
48
  { name: 'web-components', version: '22.11.0', expected: false },
43
49
  { name: 'web-components', version: '22.12.0', expected: true },
50
+ /*
51
+ * The reason we expect this to be false is because we do not know the true version
52
+ * of web-components when there is a semver range. We can only assume that it is the
53
+ * lowest version in the range.
54
+ */
55
+ { name: 'web-components', version: '^22.11.0', expected: false },
56
+ { name: 'web-components', version: '~22.12.0', expected: true },
44
57
  ];
45
58
 
46
59
  describe.each(dependencies)(
@@ -73,4 +86,14 @@ describe(`[web-components] ${getMFESupportsRerendering.name}`, () => {
73
86
  });
74
87
  itReturns(false);
75
88
  });
89
+
90
+ const deps: ['bundledWith' | 'dependencies', string][] = [
91
+ ['bundledWith', '@servicetitan/web-components'],
92
+ ['dependencies', '@servicetitan/web-components'],
93
+ ['bundledWith', '@servicetitan/startup'],
94
+ ];
95
+ describe.each(deps)(`when %s[%s] version is not a semver`, (key, depName) => {
96
+ beforeEach(() => (metadata[key][depName] = 'foobar'));
97
+ itRaises(TypeError);
98
+ });
76
99
  });
@@ -23,7 +23,8 @@ export function getMFESupportsRerendering(
23
23
  }
24
24
 
25
25
  function isSupportedVersion(version?: string) {
26
- if (version) {
27
- return semver.gte(version, '22.12.0');
26
+ const minVersion = version && semver.minVersion(version);
27
+ if (minVersion) {
28
+ return semver.gte(minVersion, '22.12.0');
28
29
  }
29
30
  }