@hubspot/ui-extensions 0.12.2 → 0.12.3

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 (102) hide show
  1. package/dist/__tests__/crm/utils/fetchAssociations.spec.js +1 -1
  2. package/dist/__tests__/crm/utils/fetchCrmProperties.spec.js +1 -1
  3. package/dist/crm/hooks/useAssociations.d.ts +1 -1
  4. package/dist/crm/hooks/useAssociations.js +2 -2
  5. package/dist/crm/hooks/useCrmProperties.d.ts +1 -1
  6. package/dist/crm/hooks/useCrmProperties.js +2 -2
  7. package/dist/crm/utils/fetchAssociations.d.ts +1 -1
  8. package/dist/crm/utils/fetchAssociations.js +0 -1
  9. package/dist/crm/utils/fetchCrmProperties.js +0 -1
  10. package/dist/experimental/pages/index.d.ts +4 -0
  11. package/dist/experimental/pages/index.js +3 -0
  12. package/dist/hs-internal/__tests__/createRemoteComponentInternal.spec.js +4 -4
  13. package/dist/hubspot.js +0 -1
  14. package/dist/internal/global-utils.d.ts +1 -1
  15. package/dist/internal/hook-utils.d.ts +3 -3
  16. package/dist/shared/remoteComponents.d.ts +4 -2
  17. package/dist/shared/remoteComponents.js +4 -0
  18. package/dist/shared/types/components/accordion.d.ts +2 -2
  19. package/dist/shared/types/components/alert.d.ts +2 -2
  20. package/dist/shared/types/components/app-home-header-actions.d.ts +3 -3
  21. package/dist/shared/types/components/button-row.d.ts +2 -2
  22. package/dist/shared/types/components/button.d.ts +3 -3
  23. package/dist/shared/types/components/card.d.ts +2 -2
  24. package/dist/shared/types/components/chart.d.ts +1 -1
  25. package/dist/shared/types/components/description-list.d.ts +2 -2
  26. package/dist/shared/types/components/divider.d.ts +1 -1
  27. package/dist/shared/types/components/dropdown.d.ts +2 -3
  28. package/dist/shared/types/components/empty-state.d.ts +2 -2
  29. package/dist/shared/types/components/error-state.d.ts +2 -2
  30. package/dist/shared/types/components/form.d.ts +3 -3
  31. package/dist/shared/types/components/heading.d.ts +2 -2
  32. package/dist/shared/types/components/icon.d.ts +3 -3
  33. package/dist/shared/types/components/iframe.d.ts +1 -1
  34. package/dist/shared/types/components/illustration.d.ts +1 -1
  35. package/dist/shared/types/components/image.d.ts +2 -2
  36. package/dist/shared/types/components/inputs.d.ts +1 -1
  37. package/dist/shared/types/components/layouts.d.ts +2 -2
  38. package/dist/shared/types/components/link.d.ts +3 -3
  39. package/dist/shared/types/components/list.d.ts +2 -2
  40. package/dist/shared/types/components/loading-spinner.d.ts +1 -1
  41. package/dist/shared/types/components/modal.d.ts +2 -2
  42. package/dist/shared/types/components/panel.d.ts +2 -2
  43. package/dist/shared/types/components/progress-bar.d.ts +1 -1
  44. package/dist/shared/types/components/score.d.ts +2 -2
  45. package/dist/shared/types/components/selects.d.ts +1 -1
  46. package/dist/shared/types/components/spacer.d.ts +1 -1
  47. package/dist/shared/types/components/statistics.d.ts +2 -2
  48. package/dist/shared/types/components/status-tag.d.ts +2 -2
  49. package/dist/shared/types/components/step-indicator.d.ts +1 -1
  50. package/dist/shared/types/components/table.d.ts +2 -2
  51. package/dist/shared/types/components/tabs.d.ts +2 -2
  52. package/dist/shared/types/components/tag.d.ts +3 -3
  53. package/dist/shared/types/components/text.d.ts +2 -2
  54. package/dist/shared/types/components/tile.d.ts +2 -2
  55. package/dist/shared/types/components/toggle.d.ts +1 -1
  56. package/dist/shared/types/components/toggleInputs.d.ts +1 -1
  57. package/dist/shared/types/components/tooltip.d.ts +2 -2
  58. package/dist/shared/types/crm.d.ts +2 -2
  59. package/dist/shared/types/experimental.d.ts +1 -1
  60. package/dist/shared/types/extend.d.ts +2 -2
  61. package/dist/shared/types/extension-points.d.ts +4 -5
  62. package/dist/shared/types/pages/app-pages-types.d.ts +75 -0
  63. package/dist/shared/types/pages/app-pages-types.js +1 -0
  64. package/dist/shared/types/pages/components/index.d.ts +2 -0
  65. package/dist/shared/types/pages/components/index.js +1 -0
  66. package/dist/shared/types/pages/components/page-link.d.ts +23 -0
  67. package/dist/shared/types/pages/components/page-link.js +1 -0
  68. package/dist/shared/types/pages/components/page-routes.d.ts +115 -0
  69. package/dist/shared/types/pages/components/page-routes.js +1 -0
  70. package/dist/shared/types/shared.d.ts +15 -1
  71. package/dist/shared/types/worker-globals.d.ts +17 -3
  72. package/dist/shared/utils/remote-component-registry.d.ts +1 -1
  73. package/dist/testing/__tests__/isMatch.spec.js +1 -1
  74. package/dist/testing/__tests__/mocks.runServerlessFunction.spec.js +1 -1
  75. package/dist/testing/__tests__/mocks.useAssociations.spec.js +2 -2
  76. package/dist/testing/__tests__/mocks.useCrmProperties.spec.js +2 -2
  77. package/dist/testing/__tests__/mocks.useExtensionActions.spec.js +1 -1
  78. package/dist/testing/__tests__/mocks.useExtensionApi.spec.js +1 -1
  79. package/dist/testing/__tests__/mocks.useExtensionContext.spec.js +1 -1
  80. package/dist/testing/internal/convert.d.ts +1 -1
  81. package/dist/testing/internal/convert.js +4 -5
  82. package/dist/testing/internal/debug.d.ts +1 -1
  83. package/dist/testing/internal/element.d.ts +1 -1
  84. package/dist/testing/internal/errors.d.ts +2 -2
  85. package/dist/testing/internal/fragment.d.ts +1 -1
  86. package/dist/testing/internal/match.d.ts +2 -2
  87. package/dist/testing/internal/mocks/index.d.ts +3 -3
  88. package/dist/testing/internal/mocks/index.js +1 -1
  89. package/dist/testing/internal/mocks/mock-extension-point-api.d.ts +2 -1
  90. package/dist/testing/internal/mocks/mock-extension-point-api.js +1 -1
  91. package/dist/testing/internal/mocks/mock-hooks.d.ts +1 -1
  92. package/dist/testing/internal/text.d.ts +2 -2
  93. package/dist/testing/internal/type-utils-internal.d.ts +2 -2
  94. package/dist/testing/internal/types-internal.d.ts +6 -6
  95. package/dist/testing/render.d.ts +2 -2
  96. package/dist/testing/render.js +5 -6
  97. package/dist/testing/type-utils.d.ts +1 -1
  98. package/dist/testing/type-utils.js +1 -1
  99. package/dist/testing/types.d.ts +9 -9
  100. package/dist/testing/utils.d.ts +1 -1
  101. package/dist/testing/utils.js +1 -1
  102. package/package.json +31 -23
@@ -1,10 +1,9 @@
1
- import { ComponentType } from 'react';
2
- import { TypesOfReadOnlyArray } from './shared.ts';
3
- import type { AppHomeContext, BaseContext, CrmContext } from './context.ts';
1
+ import type { ComponentType } from 'react';
4
2
  import type { AppHomeActions, CrmHostActions, SettingsActions, UiePlatformActions } from './actions.ts';
5
- import type { CrmPropertyListProps, CrmAssociationTableProps, CrmDataHighlightProps, CrmReportProps, CrmAssociationPivotProps, CrmAssociationPropertyListProps, CrmAssociationStageTrackerProps, CrmSimpleDeadlineProps, CrmRelativeTimelineProps, CrmStageTrackerProps, CrmStatisticsProps, CrmActionButtonProps, CrmActionLinkProps, CrmCardActionsProps } from './crm.ts';
6
- import type { SettingsContext, GenericContext } from './context.ts';
3
+ import type { AppHomeContext, BaseContext, CrmContext, GenericContext, SettingsContext } from './context.ts';
4
+ import type { CrmActionButtonProps, CrmActionLinkProps, CrmAssociationPivotProps, CrmAssociationPropertyListProps, CrmAssociationStageTrackerProps, CrmAssociationTableProps, CrmCardActionsProps, CrmDataHighlightProps, CrmPropertyListProps, CrmRelativeTimelineProps, CrmReportProps, CrmSimpleDeadlineProps, CrmStageTrackerProps, CrmStatisticsProps } from './crm.ts';
7
5
  import type { ServerlessFuncRunner } from './http-requests.ts';
6
+ import type { TypesOfReadOnlyArray } from './shared.ts';
8
7
  /** @ignore */
9
8
  export type ExtensionPointAction = (...args: any[]) => Promise<any> | void;
10
9
  /** @ignore */
@@ -0,0 +1,75 @@
1
+ import type { ComponentType, ReactElement } from 'react';
2
+ import type { EmptyProps, ReactFragmentProps } from '../shared.ts';
3
+ import type { PageRoutesProps } from './components/page-routes.ts';
4
+ /**
5
+ * The props type for a PageRouter component.
6
+ */
7
+ export type PageRouterProps = EmptyProps;
8
+ /**
9
+ * Represents the current page route that has been matched by the page router.
10
+ */
11
+ export interface MatchedPageRoute {
12
+ /**
13
+ * The id of the route that has been matched.
14
+ */
15
+ routeId?: string;
16
+ /**
17
+ * The path of the route that has been matched.
18
+ */
19
+ path: string;
20
+ /**
21
+ * The parameters of the route that has been matched.
22
+ */
23
+ params: Record<string, string>;
24
+ }
25
+ /**
26
+ * The component type for the page router that handles rendering matched routes.
27
+ *
28
+ * @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
29
+ */
30
+ export type PageRouterComponent = ComponentType<PageRouterProps>;
31
+ /**
32
+ * The function type for [createPageRouter](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/app-pages/reference#createpagerouter).
33
+ *
34
+ * Example usage:
35
+ *
36
+ * ```tsx
37
+ * const PageRouter = createPageRouter(
38
+ * <PageRoutes layoutComponent={AppLayout}>
39
+ * <PageRoutes.IndexRoute component={HomePage} id="home" />
40
+ * <PageRoutes.Route path="/docs" component={DocsPage} />
41
+ * <PageRoutes path="/customers" layoutComponent={CustomersLayout}>
42
+ * <PageRoutes.IndexRoute component={ListCustomersPage} />
43
+ * <PageRoutes.Route path="/:customerId" component={ViewCustomerPage} />
44
+ * </PageRoutes>
45
+ * <PageRoutes.AnyRoute component={NotFoundPage} />
46
+ * </PageRoutes>
47
+ * );
48
+ *
49
+ * function AppPages() {
50
+ * return <PageRouter />;
51
+ * }
52
+ *
53
+ * hubspot.extend<"pages">(() => <AppPages />);
54
+ * ```
55
+ *
56
+ * @param routes The routes to render.
57
+ * @returns The page router component.
58
+ *
59
+ * @experimental This function is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
60
+ */
61
+ export type CreatePageRouterFunction = (reactPageRoutesElement: ReactElement<PageRoutesProps> | ReactElement<ReactFragmentProps>) => PageRouterComponent;
62
+ /**
63
+ * The function type for [usePageRoute](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/app-pages/reference#usepageroute).
64
+ *
65
+ * Example usage:
66
+ *
67
+ * ```tsx
68
+ * const pageRoute = usePageRoute();
69
+ * ```
70
+ *
71
+ * @returns The current page route.
72
+ *
73
+ * @experimental This hook is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
74
+ */
75
+ export type UsePageRouteHook = () => MatchedPageRoute;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export type * from './page-link.ts';
2
+ export type * from './page-routes.ts';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { BaseComponentProps } from '../../shared.ts';
3
+ /**
4
+ * The props type for [PageLink](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-link).
5
+ *
6
+ * @category Component Props
7
+ */
8
+ export interface PageLinkProps extends BaseComponentProps {
9
+ /**
10
+ * The path to navigate to when the link is clicked. Supports path parameters (e.g. `/view-contact/:contactId`).
11
+ */
12
+ to: string;
13
+ /**
14
+ * Values for path parameters and query string entries.
15
+ * Parameters matching `:paramName` tokens in `to` are substituted into the path.
16
+ * Any remaining parameters are appended as query string entries.
17
+ */
18
+ params?: Record<string, string>;
19
+ /**
20
+ * The content to render inside the link.
21
+ */
22
+ children: ReactNode;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,115 @@
1
+ import type { ComponentType, ReactNode } from 'react';
2
+ import type { EmptyProps } from '../../shared.ts';
3
+ /**
4
+ * The props type for the layout component of [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes).
5
+ */
6
+ export interface PageRoutesLayoutProps {
7
+ /**
8
+ * The content to render inside the layout.
9
+ */
10
+ children: ReactNode;
11
+ }
12
+ interface BaseRouteProps {
13
+ /**
14
+ * The component to render when the route is matched.
15
+ */
16
+ component: ComponentType<EmptyProps>;
17
+ /**
18
+ * A unique identifier for the route.
19
+ */
20
+ id?: string;
21
+ }
22
+ /**
23
+ * The props type for [PageRoutes.IndexRoute](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes-indexroute).
24
+ */
25
+ export type IndexRouteProps = BaseRouteProps;
26
+ /**
27
+ * The props type for [PageRoutes.Route](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes-route).
28
+ */
29
+ export interface RouteProps extends BaseRouteProps {
30
+ /**
31
+ * The path pattern of the route to match.
32
+ */
33
+ path: string;
34
+ }
35
+ /**
36
+ * The props type for [PageRoutes.AnyRoute](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes-anyroute).
37
+ */
38
+ export type AnyRouteProps = BaseRouteProps;
39
+ /**
40
+ * The component type for the layout component of [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes).
41
+ */
42
+ export type PageRoutesLayoutComponent = ComponentType<PageRoutesLayoutProps>;
43
+ /**
44
+ * The props type for [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes).
45
+ */
46
+ export interface PageRoutesProps {
47
+ /**
48
+ * The path pattern of the route to include with all nested routes.
49
+ */
50
+ path?: string;
51
+ /**
52
+ * The component to render for the layout of the page routes.
53
+ */
54
+ layoutComponent?: PageRoutesLayoutComponent;
55
+ /**
56
+ * The nested route definitions.
57
+ */
58
+ children: ReactNode;
59
+ }
60
+ /**
61
+ * Used as a descriptor for a collection of page routes.
62
+ *
63
+ * Example usage:
64
+ *
65
+ * ```tsx
66
+ * const PageRouter = createPageRouter(<PageRoutes>
67
+ * <PageRoutes.IndexRoute component={HomePage} />
68
+ * <PageRoutes.Route path="/docs" component={DocsPage} />
69
+ * <PageRoutes.AnyRoute component={NotFoundPage} />
70
+ * </PageRoutes>);
71
+ * ```
72
+ *
73
+ * See [PageRoutes](https://developers.hubspot.com/docs/apps/developer-platform/add-features/ui-extensibility/ui-components/app-page-components/page-routes#pageroutes) for more information.
74
+ *
75
+ * @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
76
+ */
77
+ export interface PageRoutesComponent {
78
+ (props: PageRoutesProps): null;
79
+ /**
80
+ * Used as a descriptor for an index (i.e., "/") route.
81
+ *
82
+ * Example usage:
83
+ *
84
+ * ```tsx
85
+ * <PageRoutes.IndexRoute component={HomePage} />
86
+ * ```
87
+ *
88
+ * @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
89
+ */
90
+ IndexRoute: (props: IndexRouteProps) => null;
91
+ /**
92
+ * Used as a descriptor for a route with a path pattern.
93
+ *
94
+ * Example usage:
95
+ *
96
+ * ```tsx
97
+ * <PageRoutes.Route path="/docs" component={DocsPage} />
98
+ * ```
99
+ * @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
100
+ */
101
+ Route: (props: RouteProps) => null;
102
+ /**
103
+ * Used as a descriptor for a route that matches any path.
104
+ *
105
+ * Example usage:
106
+ *
107
+ * ```tsx
108
+ * <PageRoutes.AnyRoute component={NotFoundPage} />
109
+ * ```
110
+ *
111
+ * @experimental This component is experimental. Avoid using it in production due to potential breaking changes. Your feedback is valuable for improvements. Stay tuned for updates.
112
+ */
113
+ AnyRoute: (props: AnyRouteProps) => null;
114
+ }
115
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { ReactElement, ComponentType, ReactNode } from 'react';
1
+ import type { ComponentType, ReactElement, ReactNode } from 'react';
2
2
  export type UnknownComponentProps = Record<string, any>;
3
3
  /**
4
4
  * Represents a HubSpot-provided React component.
@@ -255,3 +255,17 @@ export interface BaseComponentProps {
255
255
  */
256
256
  testId?: string;
257
257
  }
258
+ export type EmptyProps = Record<string, never>;
259
+ /**
260
+ * Represents the current page location and its parameters. This is used to support app page routing.
261
+ */
262
+ export interface AppPageLocation {
263
+ path: string;
264
+ params: Record<string, string>;
265
+ }
266
+ /**
267
+ * The props type for a React fragment component.
268
+ */
269
+ export interface ReactFragmentProps {
270
+ children?: ReactNode | undefined;
271
+ }
@@ -1,6 +1,8 @@
1
- import { Logger } from './logger.ts';
2
- import { HubspotExtendFunction } from './extend.ts';
3
- import type { ExtensionPoints, ExtensionPointApiContext, ExtensionPointApiActions, ExtensionPointFullApi } from './extension-points.ts';
1
+ import type { HubspotExtendFunction } from './extend.ts';
2
+ import type { ExtensionPointApiActions, ExtensionPointApiContext, ExtensionPointFullApi, ExtensionPoints } from './extension-points.ts';
3
+ import type { Logger } from './logger.ts';
4
+ import type { CreatePageRouterFunction, UsePageRouteHook } from './pages/app-pages-types.ts';
5
+ import type { PageRoutesComponent } from './pages/components/page-routes.ts';
4
6
  export interface WorkersApi {
5
7
  /**
6
8
  * Hook added to worker globals so customer code can access extension context at runtime.
@@ -14,6 +16,18 @@ export interface WorkersApi {
14
16
  * Hook added to worker globals so customer code can access extension API at runtime.
15
17
  */
16
18
  useExtensionApi: <ExtensionPoint extends keyof ExtensionPoints>() => ExtensionPointFullApi<ExtensionPoint>;
19
+ /**
20
+ * The PageRoutes component.
21
+ */
22
+ PageRoutes: PageRoutesComponent;
23
+ /**
24
+ * Hook added to worker globals so customer code can access the current page route at runtime.
25
+ */
26
+ usePageRoute: UsePageRouteHook;
27
+ /**
28
+ * Function added to worker globals so customer code can create a page router at runtime.
29
+ */
30
+ createPageRouter: CreatePageRouterFunction;
17
31
  }
18
32
  export interface WorkerGlobalsInternal {
19
33
  /**
@@ -1,4 +1,4 @@
1
- import { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../types/shared.ts';
1
+ import type { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../types/shared.ts';
2
2
  /**
3
3
  * Options for creating a remote React component.
4
4
  */
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
3
  import { Alert, Button } from "../../index.js";
4
- import { createRenderer, isMatch, isRenderedFragmentNode, } from "../index.js";
4
+ import { createRenderer, isMatch, isRenderedFragmentNode } from "../index.js";
5
5
  describe('isMatch()', () => {
6
6
  describe('isMatch() utility function', () => {
7
7
  it('should allow assertions against a mix of text and element nodes', () => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from 'vitest';
2
+ import { ServerlessExecutionStatus } from "../../shared/types/http-requests.js";
2
3
  import { createRenderer } from "../index.js";
3
- import { ServerlessExecutionStatus, } from "../../shared/types/http-requests.js";
4
4
  describe('mock runServerlessFunction', () => {
5
5
  it('should provide the ability to spy on the runServerlessFunction function', async () => {
6
6
  const { mocks } = createRenderer('crm.record.tab');
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it, vi } from 'vitest';
3
- import { Text, Button } from "../../index.js";
4
- import { createRenderer } from "../index.js";
5
3
  import { useAssociations } from "../../crm/index.js";
4
+ import { Button, Text } from "../../index.js";
5
+ import { createRenderer } from "../index.js";
6
6
  function MyComponent() {
7
7
  const { results, isLoading, isRefetching, error, refetch } = useAssociations({
8
8
  toObjectType: '0-1',
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it, vi } from 'vitest';
3
- import { Text, Button } from "../../index.js";
4
- import { createRenderer } from "../index.js";
5
3
  import { useCrmProperties } from "../../crm/index.js";
4
+ import { Button, Text } from "../../index.js";
5
+ import { createRenderer } from "../index.js";
6
6
  function MyComponent() {
7
7
  const { properties, isLoading, isRefetching, error, refetch } = useCrmProperties(['firstname', 'lastname']);
8
8
  if (isLoading) {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createRenderer } from "../index.js";
3
2
  import { useExtensionActions } from "../../hooks/useExtensionActions.js";
4
3
  import { Button } from "../../index.js";
4
+ import { createRenderer } from "../index.js";
5
5
  function MyActionsCrmComponent() {
6
6
  const actions = useExtensionActions();
7
7
  return (_jsxs(_Fragment, { children: [_jsx(Button, { testId: "reloadButton", onClick: () => actions.reloadPage(), children: "Reload Page" }), _jsx(Button, { testId: "fetchButton", onClick: () => {
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
+ import { useExtensionApi } from "../../hooks/useExtensionApi.js";
3
4
  import { Button, Text } from "../../index.js";
4
5
  import { createRenderer } from "../index.js";
5
- import { useExtensionApi } from "../../hooks/useExtensionApi.js";
6
6
  function MyComponent() {
7
7
  const { context } = useExtensionApi();
8
8
  return (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "location-text", children: context.location }), _jsx(Text, { testId: "user-email", children: context.user.email }), _jsx(Text, { testId: "user-firstName", children: context.user.firstName }), _jsx(Text, { testId: "user-lastName", children: context.user.lastName }), _jsx(Text, { testId: "portal-id", children: context.portal.id }), _jsx(Text, { testId: "portal-timezone", children: context.portal.timezone }), 'crm' in context && (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "crm-objectId", children: context.crm.objectId }), _jsx(Text, { testId: "crm-objectTypeId", children: context.crm.objectTypeId })] }))] }));
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
+ import { useExtensionContext } from "../../hooks/useExtensionContext.js";
3
4
  import { Text } from "../../index.js";
4
5
  import { createRenderer } from "../index.js";
5
- import { useExtensionContext } from "../../hooks/useExtensionContext.js";
6
6
  function MyComponent() {
7
7
  const context = useExtensionContext();
8
8
  return (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "location-text", children: context.location }), _jsx(Text, { testId: "user-email", children: context.user.email }), _jsx(Text, { testId: "user-firstName", children: context.user.firstName }), _jsx(Text, { testId: "user-lastName", children: context.user.lastName }), _jsx(Text, { testId: "portal-id", children: context.portal.id }), _jsx(Text, { testId: "portal-timezone", children: context.portal.timezone }), 'crm' in context && (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "crm-objectId", children: context.crm.objectId }), _jsx(Text, { testId: "crm-objectTypeId", children: context.crm.objectTypeId })] }))] }));
@@ -1,4 +1,4 @@
1
- import { type RemoteRoot } from '@remote-ui/core';
1
+ import type { RemoteRoot } from '@remote-ui/core';
2
2
  import type { RenderedRootNodeInternal } from './types-internal.ts';
3
3
  /**
4
4
  * Converts a remote root node to a rendered root node. After conversion, the rendered root node will
@@ -1,13 +1,12 @@
1
- import { KIND_COMPONENT, KIND_FRAGMENT, KIND_TEXT, } from '@remote-ui/core';
1
+ import { KIND_COMPONENT, KIND_FRAGMENT, KIND_TEXT } from '@remote-ui/core';
2
+ import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
3
+ import { isRenderedTextNode } from "../type-utils.js";
4
+ import { EMPTY_RENDERED_CHILD_NODES } from "./constants.js";
2
5
  import { createElementNode } from "./element.js";
3
6
  import { DuplicateTestIdError, InvalidFragmentPropArrayError, } from "./errors.js";
4
7
  import { createFragmentNode } from "./fragment.js";
5
8
  import { createTextNode } from "./text.js";
6
- import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
7
- import { isRenderedTextNode } from "../type-utils.js";
8
- import { EMPTY_RENDERED_CHILD_NODES } from "./constants.js";
9
9
  import { asRenderedParentNode } from "./type-utils-internal.js";
10
- /* eslint-disable @typescript-eslint/no-use-before-define */
11
10
  /**
12
11
  * Converts a remote props object to a props object that can be attached to a rendered element node.
13
12
  *
@@ -1,4 +1,4 @@
1
- import { RenderedNode } from '../types.ts';
1
+ import type { RenderedNode } from '../types.ts';
2
2
  /**
3
3
  * Logs a rendered node tree to the console for debugging purposes.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import type { UnknownComponentProps } from '../../shared/types/shared.ts';
2
- import { RenderedElementNode } from '../types.ts';
2
+ import type { RenderedElementNode } from '../types.ts';
3
3
  import type { RenderedDocumentInternal } from './types-internal.ts';
4
4
  /**
5
5
  * Creates a rendered element node.
@@ -1,5 +1,5 @@
1
- import { RenderedElementNode, RenderedParentNode } from '../types.ts';
2
- import { RenderedRootNodeInternal } from './types-internal.ts';
1
+ import type { RenderedElementNode, RenderedParentNode } from '../types.ts';
2
+ import type { RenderedRootNodeInternal } from './types-internal.ts';
3
3
  /**
4
4
  * Thrown when trying to trigger an event that has a handler prop that is not a function.
5
5
  */
@@ -1,4 +1,4 @@
1
- import { RenderedFragmentNode } from '../types.ts';
1
+ import type { RenderedFragmentNode } from '../types.ts';
2
2
  import type { RenderedDocumentInternal } from './types-internal.ts';
3
3
  /**
4
4
  * Creates a rendered fragment node.
@@ -1,5 +1,5 @@
1
- import { UnknownComponentProps } from '../../shared/types/shared.ts';
2
- import { ElementMatcher, RenderedElementNode } from '../types.ts';
1
+ import type { UnknownComponentProps } from '../../shared/types/shared.ts';
2
+ import type { ElementMatcher, RenderedElementNode } from '../types.ts';
3
3
  /**
4
4
  * Checks if the element matches the matcher.
5
5
  *
@@ -1,6 +1,6 @@
1
- import { RendererSpies } from '../../types.ts';
2
- import { RendererMocksInternal } from '../types-internal.ts';
3
- import { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
1
+ import type { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
2
+ import type { RendererSpies } from '../../types.ts';
3
+ import type { RendererMocksInternal } from '../types-internal.ts';
4
4
  /**
5
5
  * An object containing the mocks and spies.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { spyOn } from 'tinyspy';
2
- import { createMockHooks } from "./mock-hooks.js";
3
2
  import { createMockExtensionPointApi } from "./mock-extension-point-api.js";
3
+ import { createMockHooks } from "./mock-hooks.js";
4
4
  /**
5
5
  * This function replaces all methods with a spy using the `spyOn` function from the `tinyspy` library.
6
6
  * The object tree is walked recursively to replace all methods with spies. The original object is not modified.
@@ -1,2 +1,3 @@
1
- import { ExtensionPointApi, type ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
1
+ import type { ExtensionPointApi } from '../../../shared/types/extension-points.ts';
2
+ import { type ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
2
3
  export declare const createMockExtensionPointApi: (extensionPointLocation: ExtensionPointLocation) => ExtensionPointApi<ExtensionPointLocation>;
@@ -1,4 +1,4 @@
1
- import { ServerlessExecutionStatus, } from "../../../shared/types/http-requests.js";
1
+ import { ServerlessExecutionStatus } from "../../../shared/types/http-requests.js";
2
2
  const fakePrefix = 'fake_';
3
3
  const createMockServerlessFuncRunner = () => {
4
4
  return () => Promise.resolve({
@@ -1,3 +1,3 @@
1
- import { RendererMockHooksInternal } from '../types-internal.ts';
2
1
  import type { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
2
+ import type { RendererMockHooksInternal } from '../types-internal.ts';
3
3
  export declare const createMockHooks: <TExtensionPointLocation extends ExtensionPointLocation>() => RendererMockHooksInternal;
@@ -1,6 +1,6 @@
1
1
  import { type RemoteRoot, type RemoteText } from '@remote-ui/core';
2
- import { RenderedTextNode } from '../types.ts';
3
- import { RenderedDocumentInternal } from './types-internal.ts';
2
+ import type { RenderedTextNode } from '../types.ts';
3
+ import type { RenderedDocumentInternal } from './types-internal.ts';
4
4
  /**
5
5
  * Creates a rendered text node.
6
6
  *
@@ -1,5 +1,5 @@
1
- import { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
2
- import { RenderedElementNodeInternal, RenderedFragmentNodeInternal, RenderedNodeInternal, RenderedRootNodeInternal, RenderedParentNodeInternal, RenderedTextNodeInternal } from './types-internal.ts';
1
+ import type { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
2
+ import type { RenderedElementNodeInternal, RenderedFragmentNodeInternal, RenderedNodeInternal, RenderedParentNodeInternal, RenderedRootNodeInternal, RenderedTextNodeInternal } from './types-internal.ts';
3
3
  /**
4
4
  * Converts an internal rendered node to a public rendered node using a type assertion.
5
5
  *
@@ -1,10 +1,10 @@
1
1
  import type { RemoteComponent, RemoteFragment, RemoteRoot, RemoteText } from '@remote-ui/core';
2
- import { ExtensionPointApi, ExtensionPointLocation } from '../../shared/types/extension-points.ts';
3
- import { HubSpotReactComponent, UnknownComponentProps } from '../../shared/types/shared.ts';
4
- import { useAssociations, useCrmProperties } from '../../crm/index.ts';
5
- import { useExtensionContext } from '../../hooks/useExtensionContext.tsx';
6
- import { useExtensionActions } from '../../hooks/useExtensionActions.tsx';
7
- import { useExtensionApi } from '../../hooks/useExtensionApi.tsx';
2
+ import type { useAssociations, useCrmProperties } from '../../crm/index.ts';
3
+ import type { useExtensionActions } from '../../hooks/useExtensionActions.tsx';
4
+ import type { useExtensionApi } from '../../hooks/useExtensionApi.tsx';
5
+ import type { useExtensionContext } from '../../hooks/useExtensionContext.tsx';
6
+ import type { ExtensionPointApi, ExtensionPointLocation } from '../../shared/types/extension-points.ts';
7
+ import type { HubSpotReactComponent, UnknownComponentProps } from '../../shared/types/shared.ts';
8
8
  import type { ElementMatcher, RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
9
9
  export type RemoteChildNode = RemoteComponent<any, RemoteRoot> | RemoteText<RemoteRoot>;
10
10
  export type RemoteParentNode = RemoteRoot | RemoteComponent<any, RemoteRoot> | RemoteFragment;
@@ -1,5 +1,5 @@
1
- import { ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
- import { Renderer } from './types.ts';
1
+ import type { ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
+ import type { Renderer } from './types.ts';
3
3
  /**
4
4
  * Creates a renderer object with methods for rendering and testing UI extension components.
5
5
  * Mocks for supported React hooks and the Extension Point API are automatically provided based on the extension point location.
@@ -1,16 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createRemoteRoot } from '@remote-ui/core';
3
3
  import { createRoot as createReactRoot } from '@remote-ui/react';
4
+ import { MocksContextProvider } from "../internal/hook-utils.js";
5
+ import { EXTENSION_POINT_LOCATIONS } from "../shared/types/extension-points.js";
4
6
  import { convertRemoteRoot } from "./internal/convert.js";
5
7
  import { createDocument } from "./internal/document.js";
6
8
  import { InvalidComponentsError, InvalidExtensionPointLocationError, WaitForTimeoutError, } from "./internal/errors.js";
7
- import { EXTENSION_POINT_LOCATIONS, } from "../shared/types/extension-points.js";
8
- import { MocksContextProvider } from "../internal/hook-utils.js";
9
9
  import { createMocksWithSpies } from "./internal/mocks/index.js";
10
10
  import { find, findAll, findAllChildren, findByTestId, findChild, maybeFind, maybeFindByTestId, maybeFindChild, } from "./internal/query.js";
11
11
  import { createRootNode } from "./internal/root.js";
12
12
  import { asRenderedRootNode } from "./internal/type-utils-internal.js";
13
- import { createDeferred, } from "./internal/utils/promise-utils.js";
13
+ import { createDeferred } from "./internal/utils/promise-utils.js";
14
14
  const DEFAULT_WAIT_FOR_TIMEOUT_IN_MS = 1000;
15
15
  const DEFAULT_WAIT_FOR_OPTIONS = {
16
16
  timeoutInMs: DEFAULT_WAIT_FOR_TIMEOUT_IN_MS,
@@ -28,7 +28,6 @@ const render = (node, mocksWithSpies) => {
28
28
  const runWaitForChecks = () => {
29
29
  waitForChecksQueued = false;
30
30
  waitForList = waitForList.filter((waitFor) => {
31
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
32
31
  const renderedRootNode = getLatestRootNode();
33
32
  if (renderedRootNode.document.hasInvalidComponentNames()) {
34
33
  // Reject the waitFor promise if we detect invalid components in the rendered output.
@@ -50,7 +49,7 @@ const render = (node, mocksWithSpies) => {
50
49
  waitFor.deferred.resolve(); // Resolve the promise that was originally returned by the waitFor function.
51
50
  return false; // Remove the waitFor from the list since the check passed and we resolved the promise
52
51
  }
53
- catch (error) {
52
+ catch {
54
53
  return true; // Keep the waitFor in the list since the check failed and we didn't resolve the promise.
55
54
  }
56
55
  });
@@ -112,7 +111,7 @@ const render = (node, mocksWithSpies) => {
112
111
  // Nothing to wait for since the check passed! Resolve the promise immediately.
113
112
  return Promise.resolve();
114
113
  }
115
- catch (error) {
114
+ catch {
116
115
  // If the check failed then we need to put it in the waitForList so that we
117
116
  // can check it again later. We return a promise that will be resolved when
118
117
  // the provided check passes.
@@ -1,4 +1,4 @@
1
- import { type RenderedElementNode, type RenderedFragmentNode, type RenderedNode, type RenderedRootNode, type RenderedTextNode } from './types.ts';
1
+ import type { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedRootNode, RenderedTextNode } from './types.ts';
2
2
  /**
3
3
  * Type guard to check if a node is a rendered element node.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { RenderedNodeType, } from "./types.js";
1
+ import { RenderedNodeType } from "./types.js";
2
2
  /**
3
3
  * Type guard to check if a node is a rendered element node.
4
4
  *