@seamapi/react 5.3.2 → 5.4.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.
Files changed (65) hide show
  1. package/README.md +66 -3
  2. package/dist/ecosystem.js +14 -14
  3. package/dist/ecosystem.js.map +1 -1
  4. package/dist/elements.js +21042 -19731
  5. package/dist/elements.js.map +1 -1
  6. package/ecosystem-react.d.ts +3 -0
  7. package/ecosystem-react.js +7 -0
  8. package/ecosystem-react.js.map +1 -0
  9. package/lib/seam/components/SupportedDevices/SupportedDevices.js +2 -4
  10. package/lib/seam/components/SupportedDevices/SupportedDevices.js.map +1 -1
  11. package/lib/seam/components/SupportedDevices/presentation.d.ts +1 -0
  12. package/lib/seam/components/SupportedDevices/presentation.js +3 -0
  13. package/lib/seam/components/SupportedDevices/presentation.js.map +1 -1
  14. package/lib/seam/ecosystem/EcosystemProvider.d.ts +4 -2
  15. package/lib/seam/ecosystem/EcosystemProvider.js +9 -6
  16. package/lib/seam/ecosystem/EcosystemProvider.js.map +1 -1
  17. package/lib/seam/ecosystem/client.d.ts +5 -1
  18. package/lib/seam/ecosystem/client.js +4 -2
  19. package/lib/seam/ecosystem/client.js.map +1 -1
  20. package/lib/seam/ecosystem/embed-resolution.d.ts +7 -0
  21. package/lib/seam/ecosystem/embed-resolution.js +18 -0
  22. package/lib/seam/ecosystem/embed-resolution.js.map +1 -0
  23. package/lib/seam/ecosystem/options.d.ts +6 -0
  24. package/lib/seam/ecosystem/options.js +13 -0
  25. package/lib/seam/ecosystem/options.js.map +1 -0
  26. package/lib/seam/ecosystem/prefetch-supported-devices.d.ts +14 -0
  27. package/lib/seam/ecosystem/prefetch-supported-devices.js +79 -0
  28. package/lib/seam/ecosystem/prefetch-supported-devices.js.map +1 -0
  29. package/lib/seam/ecosystem/queries.d.ts +17 -0
  30. package/lib/seam/ecosystem/queries.js +144 -0
  31. package/lib/seam/ecosystem/queries.js.map +1 -0
  32. package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.d.ts +5 -9
  33. package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js +7 -59
  34. package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js.map +1 -1
  35. package/lib/seam/ecosystem/use-ecosystem-manufacturers.d.ts +3 -3
  36. package/lib/seam/ecosystem/use-ecosystem-manufacturers.js +7 -41
  37. package/lib/seam/ecosystem/use-ecosystem-manufacturers.js.map +1 -1
  38. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.d.ts +2 -2
  39. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js +6 -40
  40. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js.map +1 -1
  41. package/lib/seam/ecosystem/use-embed-key-resolution.d.ts +4 -14
  42. package/lib/seam/ecosystem/use-embed-key-resolution.js +8 -43
  43. package/lib/seam/ecosystem/use-embed-key-resolution.js.map +1 -1
  44. package/lib/version.d.ts +1 -1
  45. package/lib/version.js +1 -1
  46. package/package.json +23 -10
  47. package/server.d.ts +2 -0
  48. package/server.js +3 -0
  49. package/server.js.map +1 -0
  50. package/src/ecosystem-react.ts +17 -0
  51. package/src/lib/ecosystem-element.tsx +4 -1
  52. package/src/lib/seam/components/SupportedDevices/SupportedDevices.tsx +2 -11
  53. package/src/lib/seam/components/SupportedDevices/presentation.ts +11 -0
  54. package/src/lib/seam/ecosystem/EcosystemProvider.tsx +17 -7
  55. package/src/lib/seam/ecosystem/client.ts +14 -2
  56. package/src/lib/seam/ecosystem/embed-resolution.ts +20 -0
  57. package/src/lib/seam/ecosystem/options.ts +21 -0
  58. package/src/lib/seam/ecosystem/prefetch-supported-devices.ts +150 -0
  59. package/src/lib/seam/ecosystem/queries.ts +204 -0
  60. package/src/lib/seam/ecosystem/use-ecosystem-device-model-summaries.ts +10 -79
  61. package/src/lib/seam/ecosystem/use-ecosystem-manufacturers.ts +9 -60
  62. package/src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts +10 -50
  63. package/src/lib/seam/ecosystem/use-embed-key-resolution.ts +11 -57
  64. package/src/lib/version.ts +1 -1
  65. package/src/server.ts +5 -0
@@ -1,14 +1,10 @@
1
- import type { DeviceModelSummary } from '../../../lib/seam/ecosystem/types.js';
2
- import type { UseEcosystemDeviceModelsParams } from '../../../lib/seam/ecosystem/use-ecosystem-device-models.js';
3
- import { type UseEcosystemQueryResult } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
1
+ import type { DeviceModelSummary } from './types.js';
2
+ import type { UseEcosystemDeviceModelsParams } from './use-ecosystem-device-models.js';
3
+ import { type UseEcosystemQueryResult } from './use-ecosystem-query-result.js';
4
4
  export type UseEcosystemDeviceModelSummariesParams = UseEcosystemDeviceModelsParams & {
5
5
  /** Fetch specific models, including accessories from other manufacturers. */
6
6
  slugs?: string[] | undefined;
7
7
  };
8
8
  export type UseEcosystemDeviceModelSummariesData = DeviceModelSummary[];
9
- /**
10
- * Published device models in the slim summary shape from Ecosystem
11
- * `GET /v1/device_models/summaries/list` (no commerce data),
12
- * following pagination to return every matching model.
13
- */
14
- export declare function useEcosystemDeviceModelSummaries({ manufacturer, deviceType, provider, capability, slugs, enabled, }?: UseEcosystemDeviceModelSummariesParams): UseEcosystemQueryResult<'deviceModels', UseEcosystemDeviceModelSummariesData>;
9
+ /** Published slim summaries, following pagination to return every matching model. */
10
+ export declare function useEcosystemDeviceModelSummaries({ enabled, ...filters }?: UseEcosystemDeviceModelSummariesParams): UseEcosystemQueryResult<'deviceModels', UseEcosystemDeviceModelSummariesData>;
@@ -1,65 +1,13 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { EcosystemApiError, fetchEcosystem } from '../../../lib/seam/ecosystem/client.js';
3
- import { useEcosystemContext } from '../../../lib/seam/ecosystem/EcosystemProvider.js';
4
- import { retryEcosystemQuery, } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
5
- const pageSize = 500;
6
- const maxPages = 20;
7
- /**
8
- * Published device models in the slim summary shape from Ecosystem
9
- * `GET /v1/device_models/summaries/list` (no commerce data),
10
- * following pagination to return every matching model.
11
- */
12
- export function useEcosystemDeviceModelSummaries({ manufacturer = '', deviceType = '', provider = '', capability = '', slugs = [], enabled = true, } = {}) {
13
- const { embedKey, endpoint } = useEcosystemContext();
14
- const params = {
15
- manufacturer: manufacturer.trim(),
16
- device_type: deviceType.trim(),
17
- provider: provider.trim(),
18
- capability: capability.trim(),
19
- slugs: [
20
- ...new Set(slugs.map((slug) => slug.trim()).filter(Boolean)),
21
- ].sort(),
22
- };
2
+ import { useEcosystemContext } from './EcosystemProvider.js';
3
+ import { deviceModelSummariesQuery } from './queries.js';
4
+ import { retryEcosystemQuery, } from './use-ecosystem-query-result.js';
5
+ /** Published slim summaries, following pagination to return every matching model. */
6
+ export function useEcosystemDeviceModelSummaries({ enabled = true, ...filters } = {}) {
7
+ const context = useEcosystemContext();
23
8
  const { data, ...rest } = useQuery({
9
+ ...deviceModelSummariesQuery(context, filters),
24
10
  enabled,
25
- queryKey: [
26
- 'ecosystem',
27
- endpoint,
28
- embedKey ?? null,
29
- 'device_models',
30
- 'summaries',
31
- 'list',
32
- params,
33
- ],
34
- queryFn: async ({ signal }) => {
35
- const deviceModels = [];
36
- let pageCursor;
37
- for (let page = 0; page < maxPages; page++) {
38
- const res = await fetchEcosystem('device_models/summaries/list', {
39
- endpoint,
40
- embedKey,
41
- params: { ...params, limit: pageSize, page_cursor: pageCursor },
42
- signal,
43
- });
44
- deviceModels.push(...res.device_models);
45
- const { has_next_page: hasNextPage, next_page_cursor: nextPageCursor } = res.pagination;
46
- if (!hasNextPage)
47
- return deviceModels;
48
- if (nextPageCursor == null || nextPageCursor === pageCursor) {
49
- throw new EcosystemApiError({
50
- status: 502,
51
- type: 'pagination_incomplete',
52
- message: 'The device catalog returned an invalid page cursor.',
53
- });
54
- }
55
- pageCursor = nextPageCursor;
56
- }
57
- throw new EcosystemApiError({
58
- status: 502,
59
- type: 'pagination_incomplete',
60
- message: 'The device catalog exceeded the supported number of pages.',
61
- });
62
- },
63
11
  retry: retryEcosystemQuery,
64
12
  });
65
13
  return { ...rest, deviceModels: data };
@@ -1 +1 @@
1
- {"version":3,"file":"use-ecosystem-device-model-summaries.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-ecosystem-device-model-summaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAM7E,OAAO,EACL,mBAAmB,GAEpB,MAAM,kDAAkD,CAAA;AAUzD,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,MAAM,QAAQ,GAAG,EAAE,CAAA;AAEnB;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,EAC/C,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,EAAE,EACf,QAAQ,GAAG,EAAE,EACb,UAAU,GAAG,EAAE,EACf,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,IAAI,MAC4B,EAAE;IAI5C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,CAAA;IAEpD,MAAM,MAAM,GAAG;QACb,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE;QACjC,WAAW,EAAE,UAAU,CAAC,IAAI,EAAE;QAC9B,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE;QAC7B,KAAK,EAAE;YACL,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SAC7D,CAAC,IAAI,EAAE;KACT,CAAA;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAGhC;QACA,OAAO;QACP,QAAQ,EAAE;YACR,WAAW;YACX,QAAQ;YACR,QAAQ,IAAI,IAAI;YAChB,eAAe;YACf,WAAW;YACX,MAAM;YACN,MAAM;SACP;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,YAAY,GAAyB,EAAE,CAAA;YAC7C,IAAI,UAA8B,CAAA;YAClC,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAG,MAAM,cAAc,CAC9B,8BAA8B,EAC9B;oBACE,QAAQ;oBACR,QAAQ;oBACR,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE;oBAC/D,MAAM;iBACP,CACF,CAAA;gBACD,YAAY,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,CAAA;gBACvC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,GACpE,GAAG,CAAC,UAAU,CAAA;gBAChB,IAAI,CAAC,WAAW;oBAAE,OAAO,YAAY,CAAA;gBACrC,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,KAAK,UAAU,EAAE,CAAC;oBAC5D,MAAM,IAAI,iBAAiB,CAAC;wBAC1B,MAAM,EAAE,GAAG;wBACX,IAAI,EAAE,uBAAuB;wBAC7B,OAAO,EAAE,qDAAqD;qBAC/D,CAAC,CAAA;gBACJ,CAAC;gBACD,UAAU,GAAG,cAAc,CAAA;YAC7B,CAAC;YACD,MAAM,IAAI,iBAAiB,CAAC;gBAC1B,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,4DAA4D;aACtE,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AACxC,CAAC"}
1
+ {"version":3,"file":"use-ecosystem-device-model-summaries.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-ecosystem-device-model-summaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAGxD,OAAO,EACL,mBAAmB,GAEpB,MAAM,iCAAiC,CAAA;AAUxC,qFAAqF;AACrF,MAAM,UAAU,gCAAgC,CAAC,EAC/C,OAAO,GAAG,IAAI,EACd,GAAG,OAAO,KACgC,EAAE;IAI5C,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;QACjC,GAAG,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC;QAC9C,OAAO;QACP,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AACxC,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Manufacturer } from '../../../lib/seam/ecosystem/types.js';
2
- import { type UseEcosystemQueryResult } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
1
+ import type { Manufacturer } from './types.js';
2
+ import { type UseEcosystemQueryResult } from './use-ecosystem-query-result.js';
3
3
  export interface UseEcosystemManufacturersParams {
4
4
  /** Only manufacturers with these slugs. */
5
5
  slugs?: string[] | undefined;
@@ -7,5 +7,5 @@ export interface UseEcosystemManufacturersParams {
7
7
  enabled?: boolean | undefined;
8
8
  }
9
9
  export type UseEcosystemManufacturersData = Manufacturer[];
10
- /** Published manufacturers from Ecosystem `GET /v1/manufacturers/list`. */
10
+ /** Published manufacturers, following pagination to return every matching manufacturer. */
11
11
  export declare function useEcosystemManufacturers({ slugs, enabled, }?: UseEcosystemManufacturersParams): UseEcosystemQueryResult<'manufacturers', UseEcosystemManufacturersData>;
@@ -1,47 +1,13 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { fetchEcosystem, } from '../../../lib/seam/ecosystem/client.js';
3
- import { useEcosystemContext } from '../../../lib/seam/ecosystem/EcosystemProvider.js';
4
- import { retryEcosystemQuery, } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
5
- const pageSize = 500;
6
- const maxPages = 10;
7
- /** Published manufacturers from Ecosystem `GET /v1/manufacturers/list`. */
2
+ import { useEcosystemContext } from './EcosystemProvider.js';
3
+ import { manufacturersQuery } from './queries.js';
4
+ import { retryEcosystemQuery, } from './use-ecosystem-query-result.js';
5
+ /** Published manufacturers, following pagination to return every matching manufacturer. */
8
6
  export function useEcosystemManufacturers({ slugs, enabled = true, } = {}) {
9
- const { embedKey, endpoint } = useEcosystemContext();
10
- const sortedSlugs = slugs == null
11
- ? null
12
- : [...new Set(slugs)].sort((a, b) => a.localeCompare(b));
7
+ const context = useEcosystemContext();
13
8
  const { data, ...rest } = useQuery({
14
- enabled: enabled && (sortedSlugs == null || sortedSlugs.length > 0),
15
- queryKey: [
16
- 'ecosystem',
17
- endpoint,
18
- embedKey ?? null,
19
- 'manufacturers',
20
- 'list',
21
- { slugs: sortedSlugs },
22
- ],
23
- queryFn: async ({ signal }) => {
24
- const manufacturers = [];
25
- let pageCursor;
26
- for (let page = 0; page < maxPages; page++) {
27
- const res = await fetchEcosystem('manufacturers/list', {
28
- endpoint,
29
- embedKey,
30
- params: {
31
- slugs: sortedSlugs ?? undefined,
32
- limit: pageSize,
33
- page_cursor: pageCursor,
34
- },
35
- signal,
36
- });
37
- manufacturers.push(...res.manufacturers);
38
- const { has_next_page: hasNextPage, next_page_cursor: nextPageCursor } = res.pagination;
39
- if (!hasNextPage || nextPageCursor == null)
40
- break;
41
- pageCursor = nextPageCursor;
42
- }
43
- return manufacturers;
44
- },
9
+ ...manufacturersQuery(context, slugs),
10
+ enabled: enabled && (slugs == null || slugs.length > 0),
45
11
  retry: retryEcosystemQuery,
46
12
  });
47
13
  return { ...rest, manufacturers: data };
@@ -1 +1 @@
1
- {"version":3,"file":"use-ecosystem-manufacturers.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-ecosystem-manufacturers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAEL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAK7E,OAAO,EACL,mBAAmB,GAEpB,MAAM,kDAAkD,CAAA;AAWzD,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,MAAM,QAAQ,GAAG,EAAE,CAAA;AAEnB,2EAA2E;AAC3E,MAAM,UAAU,yBAAyB,CAAC,EACxC,KAAK,EACL,OAAO,GAAG,IAAI,MACqB,EAAE;IAIrC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,CAAA;IAEpD,MAAM,WAAW,GACf,KAAK,IAAI,IAAI;QACX,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IAE5D,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAGhC;QACA,OAAO,EAAE,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QACnE,QAAQ,EAAE;YACR,WAAW;YACX,QAAQ;YACR,QAAQ,IAAI,IAAI;YAChB,eAAe;YACf,MAAM;YACN,EAAE,KAAK,EAAE,WAAW,EAAE;SACvB;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,aAAa,GAAmB,EAAE,CAAA;YACxC,IAAI,UAA8B,CAAA;YAClC,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAG,MAAM,cAAc,CAC9B,oBAAoB,EACpB;oBACE,QAAQ;oBACR,QAAQ;oBACR,MAAM,EAAE;wBACN,KAAK,EAAE,WAAW,IAAI,SAAS;wBAC/B,KAAK,EAAE,QAAQ;wBACf,WAAW,EAAE,UAAU;qBACxB;oBACD,MAAM;iBACP,CACF,CAAA;gBACD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,CAAA;gBACxC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,GACpE,GAAG,CAAC,UAAU,CAAA;gBAChB,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,IAAI;oBAAE,MAAK;gBACjD,UAAU,GAAG,cAAc,CAAA;YAC7B,CAAC;YACD,OAAO,aAAa,CAAA;QACtB,CAAC;QACD,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC"}
1
+ {"version":3,"file":"use-ecosystem-manufacturers.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-ecosystem-manufacturers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EACL,mBAAmB,GAEpB,MAAM,iCAAiC,CAAA;AAWxC,2FAA2F;AAC3F,MAAM,UAAU,yBAAyB,CAAC,EACxC,KAAK,EACL,OAAO,GAAG,IAAI,MACqB,EAAE;IAIrC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;QACjC,GAAG,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC;QACrC,OAAO,EAAE,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACvD,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ProviderRequirements } from '../../../lib/seam/ecosystem/types.js';
2
- import { type UseEcosystemQueryResult } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
1
+ import type { ProviderRequirements } from './types.js';
2
+ import { type UseEcosystemQueryResult } from './use-ecosystem-query-result.js';
3
3
  /** Fetch provider branding, integration status, and legacy free-text requirements. */
4
4
  export declare function useEcosystemProviderRequirements(slugs: string[]): UseEcosystemQueryResult<'providers', ProviderRequirements[]>;
@@ -1,47 +1,13 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { EcosystemApiError, fetchEcosystem } from '../../../lib/seam/ecosystem/client.js';
3
- import { useEcosystemContext } from '../../../lib/seam/ecosystem/EcosystemProvider.js';
4
- import { retryEcosystemQuery, } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
2
+ import { useEcosystemContext } from './EcosystemProvider.js';
3
+ import { providerRequirementsQuery } from './queries.js';
4
+ import { retryEcosystemQuery, } from './use-ecosystem-query-result.js';
5
5
  /** Fetch provider branding, integration status, and legacy free-text requirements. */
6
6
  export function useEcosystemProviderRequirements(slugs) {
7
- const { endpoint, embedKey } = useEcosystemContext();
8
- const sortedSlugs = [...new Set(slugs)].sort();
7
+ const context = useEcosystemContext();
9
8
  const { data, ...rest } = useQuery({
10
- enabled: sortedSlugs.length > 0,
11
- queryKey: [
12
- 'ecosystem',
13
- endpoint,
14
- embedKey ?? null,
15
- 'providers',
16
- 'list',
17
- { slugs: sortedSlugs },
18
- ],
19
- queryFn: async ({ signal }) => {
20
- const providers = [];
21
- const seen = new Set();
22
- let cursor;
23
- for (let page = 0; page < 10; page++) {
24
- const res = await fetchEcosystem('providers/list', {
25
- endpoint,
26
- embedKey,
27
- signal,
28
- params: { slugs: sortedSlugs, limit: 500, page_cursor: cursor },
29
- });
30
- providers.push(...res.providers);
31
- if (!res.pagination.has_next_page)
32
- return providers;
33
- const next = res.pagination.next_page_cursor;
34
- if (next == null || seen.has(next))
35
- break;
36
- seen.add(next);
37
- cursor = next;
38
- }
39
- throw new EcosystemApiError({
40
- status: 502,
41
- type: 'pagination_incomplete',
42
- message: 'The provider catalog returned incomplete requirements.',
43
- });
44
- },
9
+ ...providerRequirementsQuery(context, slugs),
10
+ enabled: slugs.length > 0,
45
11
  retry: retryEcosystemQuery,
46
12
  });
47
13
  return { ...rest, providers: data };
@@ -1 +1 @@
1
- {"version":3,"file":"use-ecosystem-provider-requirements.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAK7E,OAAO,EACL,mBAAmB,GAEpB,MAAM,kDAAkD,CAAA;AAEzD,sFAAsF;AACtF,MAAM,UAAU,gCAAgC,CAC9C,KAAe;IAEf,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,CAAA;IACpD,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAChC;QACE,OAAO,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC;QAC/B,QAAQ,EAAE;YACR,WAAW;YACX,QAAQ;YACR,QAAQ,IAAI,IAAI;YAChB,WAAW;YACX,MAAM;YACN,EAAE,KAAK,EAAE,WAAW,EAAE;SACvB;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,SAAS,GAA2B,EAAE,CAAA;YAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;YAC9B,IAAI,MAA0B,CAAA;YAC9B,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;gBACrC,MAAM,GAAG,GAAG,MAAM,cAAc,CAC9B,gBAAgB,EAChB;oBACE,QAAQ;oBACR,QAAQ;oBACR,MAAM;oBACN,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE;iBAChE,CACF,CAAA;gBACD,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;gBAChC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa;oBAAE,OAAO,SAAS,CAAA;gBACnD,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAA;gBAC5C,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,MAAK;gBACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBACd,MAAM,GAAG,IAAI,CAAA;YACf,CAAC;YACD,MAAM,IAAI,iBAAiB,CAAC;gBAC1B,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,wDAAwD;aAClE,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,EAAE,mBAAmB;KAC3B,CACF,CAAA;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;AACrC,CAAC"}
1
+ {"version":3,"file":"use-ecosystem-provider-requirements.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EACL,mBAAmB,GAEpB,MAAM,iCAAiC,CAAA;AAExC,sFAAsF;AACtF,MAAM,UAAU,gCAAgC,CAC9C,KAAe;IAEf,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;QACjC,GAAG,yBAAyB,CAAC,OAAO,EAAE,KAAK,CAAC;QAC5C,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;QACzB,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;AACrC,CAAC"}
@@ -1,20 +1,10 @@
1
- import type { EmbedResolution } from '../../../lib/seam/ecosystem/types.js';
2
- import { type UseEcosystemQueryResult } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
1
+ import type { EmbedResolution } from './types.js';
2
+ import { type UseEcosystemQueryResult } from './use-ecosystem-query-result.js';
3
+ export { getEmbedKeyManufacturer } from './embed-resolution.js';
3
4
  export interface UseEmbedKeyResolutionParams {
4
5
  /** Resolve the partner's capability exclusions for this capability. */
5
6
  capability?: string | undefined;
6
7
  }
7
8
  export type UseEmbedKeyResolutionData = EmbedResolution;
8
- /**
9
- * Validates the provider's embed key against the page origin with
10
- * Ecosystem `GET /v1/embed/resolve` and returns the key's public record
11
- * and, for partner keys, what the partner's widgets must not show.
12
- * Disabled when there is no embed key.
13
- */
9
+ /** Validates the embed key and resolves its manufacturer scope and exclusions. */
14
10
  export declare function useEmbedKeyResolution({ capability, }?: UseEmbedKeyResolutionParams): UseEcosystemQueryResult<'embedResolution', UseEmbedKeyResolutionData>;
15
- /**
16
- * The manufacturer an embed key is scoped to, if any.
17
- * Prefers the `manufacturer_context` Ecosystem returns for manufacturer keys (DEVDB-439),
18
- * and falls back to the key's own `manufacturer_slug`.
19
- */
20
- export declare const getEmbedKeyManufacturer: (resolution: EmbedResolution | null | undefined) => string | null;
@@ -1,51 +1,16 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { fetchEcosystem, } from '../../../lib/seam/ecosystem/client.js';
3
- import { useEcosystemContext } from '../../../lib/seam/ecosystem/EcosystemProvider.js';
4
- import { retryEcosystemQuery, } from '../../../lib/seam/ecosystem/use-ecosystem-query-result.js';
5
- /**
6
- * Validates the provider's embed key against the page origin with
7
- * Ecosystem `GET /v1/embed/resolve` and returns the key's public record
8
- * and, for partner keys, what the partner's widgets must not show.
9
- * Disabled when there is no embed key.
10
- */
2
+ import { useEcosystemContext } from './EcosystemProvider.js';
3
+ import { embedResolutionQuery } from './queries.js';
4
+ import { retryEcosystemQuery, } from './use-ecosystem-query-result.js';
5
+ export { getEmbedKeyManufacturer } from './embed-resolution.js';
6
+ /** Validates the embed key and resolves its manufacturer scope and exclusions. */
11
7
  export function useEmbedKeyResolution({ capability = '', } = {}) {
12
- const { embedKey, endpoint } = useEcosystemContext();
13
- const params = { capability: capability.trim() };
8
+ const context = useEcosystemContext();
14
9
  const { data, ...rest } = useQuery({
15
- enabled: embedKey != null,
16
- queryKey: [
17
- 'ecosystem',
18
- endpoint,
19
- embedKey ?? null,
20
- 'embed',
21
- 'resolve',
22
- params,
23
- ],
24
- queryFn: async ({ signal }) => await fetchEcosystem('embed/resolve', {
25
- endpoint,
26
- embedKey,
27
- params,
28
- signal,
29
- }),
10
+ ...embedResolutionQuery(context, capability),
11
+ enabled: context.embedKey != null,
30
12
  retry: retryEcosystemQuery,
31
13
  });
32
14
  return { ...rest, embedResolution: data };
33
15
  }
34
- /**
35
- * The manufacturer an embed key is scoped to, if any.
36
- * Prefers the `manufacturer_context` Ecosystem returns for manufacturer keys (DEVDB-439),
37
- * and falls back to the key's own `manufacturer_slug`.
38
- */
39
- export const getEmbedKeyManufacturer = (resolution) => {
40
- if (resolution == null)
41
- return null;
42
- const contextSlug = resolution.manufacturer_context?.manufacturer_slug;
43
- if (contextSlug != null && contextSlug.length > 0)
44
- return contextSlug;
45
- const { owner_kind: ownerKind, manufacturer_slug: slug } = resolution.embed_key;
46
- if (ownerKind === 'manufacturer' && slug != null && slug.length > 0) {
47
- return slug;
48
- }
49
- return null;
50
- };
51
16
  //# sourceMappingURL=use-embed-key-resolution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-embed-key-resolution.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-embed-key-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAEL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAE7E,OAAO,EACL,mBAAmB,GAEpB,MAAM,kDAAkD,CAAA;AASzD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,UAAU,GAAG,EAAE,MACgB,EAAE;IAIjC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,CAAA;IAEpD,MAAM,MAAM,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,CAAA;IAEhD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAGhC;QACA,OAAO,EAAE,QAAQ,IAAI,IAAI;QACzB,QAAQ,EAAE;YACR,WAAW;YACX,QAAQ;YACR,QAAQ,IAAI,IAAI;YAChB,OAAO;YACP,SAAS;YACT,MAAM;SACP;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAC5B,MAAM,cAAc,CAAkB,eAAe,EAAE;YACrD,QAAQ;YACR,QAAQ;YACR,MAAM;YACN,MAAM;SACP,CAAC;QACJ,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAA;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,UAA8C,EAC/B,EAAE;IACjB,IAAI,UAAU,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACnC,MAAM,WAAW,GAAG,UAAU,CAAC,oBAAoB,EAAE,iBAAiB,CAAA;IACtE,IAAI,WAAW,IAAI,IAAI,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,WAAW,CAAA;IACrE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,GACtD,UAAU,CAAC,SAAS,CAAA;IACtB,IAAI,SAAS,KAAK,cAAc,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
1
+ {"version":3,"file":"use-embed-key-resolution.js","sourceRoot":"","sources":["../../../src/lib/seam/ecosystem/use-embed-key-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,OAAO,EACL,mBAAmB,GAEpB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAS/D,kFAAkF;AAClF,MAAM,UAAU,qBAAqB,CAAC,EACpC,UAAU,GAAG,EAAE,MACgB,EAAE;IAIjC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAA;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;QACjC,GAAG,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC;QAC5C,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI;QACjC,KAAK,EAAE,mBAAmB;KAC3B,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAA;AAC3C,CAAC"}
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const seamapiReactVersion = "5.3.2";
1
+ declare const seamapiReactVersion = "5.4.1";
2
2
  export default seamapiReactVersion;
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '5.3.2';
1
+ const seamapiReactVersion = '5.4.1';
2
2
  export default seamapiReactVersion;
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/react",
3
- "version": "5.3.2",
3
+ "version": "5.4.1",
4
4
  "description": "Seam Components.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -24,6 +24,14 @@
24
24
  },
25
25
  "./index.css": {
26
26
  "import": "./dist/index.css"
27
+ },
28
+ "./ecosystem-react.js": {
29
+ "types": "./ecosystem-react.d.ts",
30
+ "import": "./ecosystem-react.js"
31
+ },
32
+ "./server.js": {
33
+ "types": "./server.d.ts",
34
+ "import": "./server.js"
27
35
  }
28
36
  },
29
37
  "module": "index.js",
@@ -45,6 +53,12 @@
45
53
  "email": "devops@getseam.com"
46
54
  },
47
55
  "files": [
56
+ "server.js",
57
+ "server.js.map",
58
+ "server.d.ts",
59
+ "ecosystem-react.js",
60
+ "ecosystem-react.js.map",
61
+ "ecosystem-react.d.ts",
48
62
  "index.js",
49
63
  "index.js.map",
50
64
  "index.d.ts",
@@ -65,14 +79,13 @@
65
79
  "start": "concurrently --raw --kill-others npm:examples:storybook npm:storybook",
66
80
  "dev": "npm run start",
67
81
  "build": "npm run build:entrypoints",
68
- "prebuild": "del 'index.*' 'hooks.*' lib dist",
69
- "postbuild": "concurrently --raw --group 'node ./index.js' 'node ./hooks.js'",
82
+ "prebuild": "del 'index.*' 'hooks.*' 'ecosystem-react.*' 'server.*' lib dist",
83
+ "postbuild": "concurrently --raw --group 'node ./index.js' 'node ./hooks.js' 'node ./ecosystem-react.js' 'node ./server.js' 'tsx ./postbuild.ts'",
70
84
  "build:entrypoints": "npm run build:js",
71
85
  "prebuild:entrypoints": "npm run build:css",
72
86
  "postbuild:entrypoints": "npm run build:elements && npm run build:ecosystem",
73
87
  "build:elements": "vite build",
74
88
  "build:ecosystem": "vite build --mode ecosystem",
75
- "size": "tsx ./size.ts",
76
89
  "build:js": "tsc --project tsconfig.build.json",
77
90
  "postbuild:js": "tsc-alias --project tsconfig.build.json",
78
91
  "build:css": "sass --load-path=node_modules src/index.scss:dist/index.css",
@@ -171,10 +184,10 @@
171
184
  "@types/uuid": "^10.0.0",
172
185
  "@vercel/node": "^3.0.7",
173
186
  "@vitejs/plugin-react": "^4.0.0",
174
- "@vitest/coverage-v8": "^0.34.4",
175
- "@vitest/ui": "^0.34.4",
187
+ "@vitest/coverage-v8": "^3.2.6",
188
+ "@vitest/ui": "^3.2.6",
176
189
  "concurrently": "^9.1.0",
177
- "copy-webpack-plugin": "^11.0.0",
190
+ "copy-webpack-plugin": "^14.0.0",
178
191
  "del-cli": "^6.0.0",
179
192
  "eslint": "^8.9.0",
180
193
  "eslint-config-prettier": "^9.0.0",
@@ -187,7 +200,7 @@
187
200
  "eslint-plugin-unused-imports": "^3.0.0",
188
201
  "execa": "^9.5.1",
189
202
  "fast-glob": "^3.2.12",
190
- "happy-dom": "^12.10.3",
203
+ "happy-dom": "^21.0.4",
191
204
  "http-proxy-middleware": "^2.0.6",
192
205
  "prettier": "^3.0.0",
193
206
  "react": "^18.2.0",
@@ -201,9 +214,9 @@
201
214
  "tsx": "^4.6.2",
202
215
  "typedoc": "^0.26.11",
203
216
  "typescript": "~5.3.0",
204
- "vite": "^5.1.6",
217
+ "vite": "^6.4.4",
205
218
  "vite-tsconfig-paths": "^4.0.8",
206
- "vitest": "^0.34.4",
219
+ "vitest": "^3.2.6",
207
220
  "zustand-hoist": "^2.0.0"
208
221
  }
209
222
  }
package/server.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { EcosystemApiError } from './lib/seam/ecosystem/client.js';
2
+ export { prefetchSupportedDevices, type PrefetchSupportedDevicesOptions, } from './lib/seam/ecosystem/prefetch-supported-devices.js';
package/server.js ADDED
@@ -0,0 +1,3 @@
1
+ export { EcosystemApiError } from './lib/seam/ecosystem/client.js';
2
+ export { prefetchSupportedDevices, } from './lib/seam/ecosystem/prefetch-supported-devices.js';
3
+ //# sourceMappingURL=server.js.map
package/server.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EACL,wBAAwB,GAEzB,MAAM,oDAAoD,CAAA"}
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+
3
+ // Native React entry point, including the Next.js client boundary, without
4
+ // registering custom elements or importing the Seam API client.
5
+ export {
6
+ CompatibleApps,
7
+ type CompatibleAppsProps,
8
+ } from './lib/seam/components/CompatibleApps/CompatibleApps.js'
9
+ export {
10
+ SupportedDevices,
11
+ type SupportedDevicesProps,
12
+ } from './lib/seam/components/SupportedDevices/SupportedDevices.js'
13
+ export {
14
+ type EcosystemOptions,
15
+ EcosystemProvider,
16
+ type EcosystemProviderProps,
17
+ } from './lib/seam/ecosystem/EcosystemProvider.js'
@@ -28,7 +28,10 @@ export interface EcosystemElementDefinition {
28
28
  props?: Record<string, PropType>
29
29
  }
30
30
 
31
- type ProviderProps = Omit<EcosystemProviderProps, 'children'>
31
+ type ProviderProps = Omit<
32
+ EcosystemProviderProps,
33
+ 'children' | 'dehydratedState'
34
+ >
32
35
 
33
36
  const providerProps: Record<keyof ProviderProps, PropType> = {
34
37
  embedKey: 'string',
@@ -36,7 +36,7 @@ import {
36
36
  import { AccessoryCatalog } from './AccessoryCatalog.js'
37
37
  import { CapabilityFilter } from './CapabilityFilter.js'
38
38
  import { CapabilityLegend } from './DeviceRow.js'
39
- import { presentDevice } from './presentation.js'
39
+ import { getAccessorySlugs, presentDevice } from './presentation.js'
40
40
 
41
41
  export interface SupportedDevicesProps {
42
42
  /**
@@ -160,16 +160,7 @@ export function SupportedDevices({
160
160
  [presentedDevices]
161
161
  )
162
162
  const accessorySlugs = useMemo(
163
- () =>
164
- presentedDevices.flatMap((device) =>
165
- device.providers
166
- .filter((provider) => provider.integrationStatus !== 'unsupported')
167
- .flatMap((provider) =>
168
- provider.requirements.flatMap(
169
- (requirement) => requirement.deviceSlugs ?? []
170
- )
171
- )
172
- ),
163
+ () => getAccessorySlugs(presentedDevices),
173
164
  [presentedDevices]
174
165
  )
175
166
 
@@ -31,6 +31,17 @@ export interface PresentedDevice {
31
31
  providers: PresentedProvider[]
32
32
  }
33
33
 
34
+ export const getAccessorySlugs = (devices: PresentedDevice[]): string[] =>
35
+ devices.flatMap((device) =>
36
+ device.providers
37
+ .filter((provider) => provider.integrationStatus !== 'unsupported')
38
+ .flatMap((provider) =>
39
+ provider.requirements.flatMap(
40
+ (requirement) => requirement.deviceSlugs ?? []
41
+ )
42
+ )
43
+ )
44
+
34
45
  interface PresentedProvider extends ProviderRef {
35
46
  logos?: DeviceAsset[]
36
47
  primary: boolean
@@ -1,4 +1,6 @@
1
1
  import {
2
+ type DehydratedState,
3
+ HydrationBoundary,
2
4
  QueryClient,
3
5
  QueryClientContext,
4
6
  QueryClientProvider,
@@ -8,6 +10,7 @@ import {
8
10
  type PropsWithChildren,
9
11
  useContext,
10
12
  useMemo,
13
+ useState,
11
14
  } from 'react'
12
15
 
13
16
  import { defaultEcosystemEndpoint } from 'lib/seam/ecosystem/client.js'
@@ -36,13 +39,13 @@ export interface EcosystemProviderProps
36
39
  extends EcosystemOptions,
37
40
  PropsWithChildren {
38
41
  queryClient?: QueryClient | undefined
42
+ /** Server data returned by `prefetchSupportedDevices` from `@seamapi/react/server.js`. */
43
+ dehydratedState?: DehydratedState | undefined
39
44
  disableCssInjection?: boolean | undefined
40
45
  disableFontInjection?: boolean | undefined
41
46
  unminifiyCss?: boolean | undefined
42
47
  }
43
48
 
44
- const defaultQueryClient = new QueryClient()
45
-
46
49
  /**
47
50
  * Provides the Seam Ecosystem context for `CompatibleApps` and `SupportedDevices`.
48
51
  *
@@ -53,6 +56,7 @@ const defaultQueryClient = new QueryClient()
53
56
  export function EcosystemProvider({
54
57
  children,
55
58
  queryClient,
59
+ dehydratedState,
56
60
  disableCssInjection = false,
57
61
  disableFontInjection = false,
58
62
  unminifiyCss = false,
@@ -62,6 +66,8 @@ export function EcosystemProvider({
62
66
  useSeamFont({ disabled: disableFontInjection })
63
67
 
64
68
  const queryClientFromContext = useContext(QueryClientContext)
69
+ // Each server render gets its own fallback cache; never share request data.
70
+ const [fallbackQueryClient] = useState(() => new QueryClient())
65
71
 
66
72
  return (
67
73
  <div className={seamComponentsClassName}>
@@ -69,13 +75,17 @@ export function EcosystemProvider({
69
75
  client={
70
76
  queryClient ??
71
77
  queryClientFromContext ??
72
- globalThis.seamQueryClient ??
73
- defaultQueryClient
78
+ (typeof window === 'undefined'
79
+ ? undefined
80
+ : globalThis.seamQueryClient) ??
81
+ fallbackQueryClient
74
82
  }
75
83
  >
76
- <EcosystemContextProvider {...options}>
77
- {children}
78
- </EcosystemContextProvider>
84
+ <HydrationBoundary state={dehydratedState}>
85
+ <EcosystemContextProvider {...options}>
86
+ {children}
87
+ </EcosystemContextProvider>
88
+ </HydrationBoundary>
79
89
  </QueryClientProvider>
80
90
  </div>
81
91
  )