@amplifyup/sdk 0.1.78 → 0.1.79
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.
- package/README.md +91 -28
- package/dist/AmplifyRenderer-BNWBrFQN.d.ts +47 -0
- package/dist/AmplifyRenderer-CPUr9Bkc.d.mts +47 -0
- package/dist/AmplifyRenderer.d.mts +4 -40
- package/dist/AmplifyRenderer.d.ts +4 -40
- package/dist/AmplifyRenderer.js +106 -14
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +106 -14
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +266 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +260 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/config.d.mts +18 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +8 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +9 -0
- package/dist/next.d.ts +9 -0
- package/dist/next.js +259 -0
- package/dist/next.js.map +1 -0
- package/dist/next.mjs +253 -0
- package/dist/next.mjs.map +1 -0
- package/dist/query-DYjs4LQQ.d.mts +262 -0
- package/dist/query-Xo9cy-2F.d.ts +262 -0
- package/dist/react.d.mts +19 -21
- package/dist/react.d.ts +19 -21
- package/dist/react.js +1141 -1035
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1140 -1035
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/{types-D4TSd2Yt.d.mts → types-ffQNIQCK.d.mts} +1 -102
- package/dist/{types-D4TSd2Yt.d.ts → types-ffQNIQCK.d.ts} +1 -102
- package/package.json +17 -2
- package/dist/query-B23UsNIv.d.ts +0 -161
- package/dist/query-CV8x3oQT.d.mts +0 -161
package/README.md
CHANGED
|
@@ -28,42 +28,37 @@ export default function RootLayout({ children }) {
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
### 2.
|
|
31
|
+
### 2. Component registry
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
import { AmplifyPageContent, ComponentContextProvider } from '@amplifyup/sdk/react';
|
|
35
|
-
import { Hero } from '@/components/Hero';
|
|
33
|
+
Wrap your Next config with `withAmplifyUp`. It builds your **component registry** from `src/components` (or `components/` when there is no `src/`) every time `next dev` or `next build` runs, and keeps it current while you work.
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
```js
|
|
36
|
+
// next.config.js
|
|
37
|
+
const { withAmplifyUp } = require('@amplifyup/sdk/next');
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
39
|
+
module.exports = withAmplifyUp({
|
|
40
|
+
// your existing Next config
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
You never register components by hand. Adding a component means adding a file.
|
|
45
|
+
|
|
46
|
+
### 3. Page content
|
|
47
|
+
|
|
48
|
+
Render `<AmplifyPage />` from the generated registry:
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { AmplifyPage } from '@/.amplifyup/component-registry';
|
|
53
52
|
|
|
54
53
|
export default function Page() {
|
|
55
|
-
return
|
|
56
|
-
<AmplifyPageContent
|
|
57
|
-
renderComponent={renderComponent}
|
|
58
|
-
fallback={<YourStaticPage />}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
54
|
+
return <AmplifyPage fallback={<YourStaticPage />} />;
|
|
61
55
|
}
|
|
62
56
|
```
|
|
63
57
|
|
|
64
|
-
###
|
|
58
|
+
### 4. Write a component
|
|
65
59
|
|
|
66
60
|
```tsx
|
|
61
|
+
// src/components/Hero.tsx
|
|
67
62
|
import { Field } from '@amplifyup/sdk/react';
|
|
68
63
|
import type { Fields } from '@amplifyup/sdk/react';
|
|
69
64
|
|
|
@@ -84,6 +79,72 @@ That's the whole loop. The rest of this section is the detail.
|
|
|
84
79
|
|
|
85
80
|
---
|
|
86
81
|
|
|
82
|
+
## Component registry
|
|
83
|
+
|
|
84
|
+
The SDK owns how layout components are found and rendered. Your site supplies the components; the SDK builds the lookup, renders each component, and gives it the context `Field`, `Slot`, `Image` and `RichText` read. Writing that lookup yourself is not supported.
|
|
85
|
+
|
|
86
|
+
### How components are found
|
|
87
|
+
|
|
88
|
+
| File | Registry name |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| `src/components/Hero.tsx` | `Hero` |
|
|
91
|
+
| `src/components/Hero/index.tsx` | `Hero` |
|
|
92
|
+
| `src/components/marketing/promo-card.tsx` | `promo-card` |
|
|
93
|
+
|
|
94
|
+
- Each file needs a default export, or a named export with the same name as the file (`export function Hero`).
|
|
95
|
+
- Names match the component ID in AmplifyUp regardless of case and separators, so `Hero`, `hero` and `HERO` are the same component, and so are `promo-card` and `PromoCard`.
|
|
96
|
+
- Tests, stories and type files are skipped. Files that don't export a component are listed as skipped when the registry builds.
|
|
97
|
+
- Two files that resolve to the same name stop the build and name both files.
|
|
98
|
+
|
|
99
|
+
### Settings
|
|
100
|
+
|
|
101
|
+
`amplifyup.config.ts` in your project root is optional. Use it when your components live elsewhere:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { defineAmplifyConfig } from '@amplifyup/sdk/config';
|
|
105
|
+
|
|
106
|
+
export default defineAmplifyConfig({
|
|
107
|
+
components: {
|
|
108
|
+
roots: ['src/components', 'src/marketing'],
|
|
109
|
+
exclude: ['**/internal/**'],
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
| Setting | Default |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `roots` | `['src/components']`, or `['components']` without `src/` |
|
|
117
|
+
| `exclude` | none (tests, stories and type files are always skipped) |
|
|
118
|
+
| `output` | `.amplifyup/component-registry` next to your first root |
|
|
119
|
+
|
|
120
|
+
The generated `.amplifyup` folder ignores itself in git. Don't edit it.
|
|
121
|
+
|
|
122
|
+
### Without the Next plugin
|
|
123
|
+
|
|
124
|
+
For CI steps or non-Next builds, run the CLI before your build:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npx amplifyup registry # build once
|
|
128
|
+
npx amplifyup registry --watch # rebuild as files are added, renamed or removed
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Missing components
|
|
132
|
+
|
|
133
|
+
If a page uses a component that isn't in your registry, Composer shows a placeholder naming it, and the live page renders nothing in its place. Add a file with that name to your components folder.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Upgrading from 0.1
|
|
138
|
+
|
|
139
|
+
0.2.0 removes hand-written rendering. `renderComponent` and the `ComponentContextProvider` export are gone, and passing `renderComponent` throws an error that points here.
|
|
140
|
+
|
|
141
|
+
1. Delete your component lookup object and your `renderComponent` function.
|
|
142
|
+
2. Wrap `next.config` with `withAmplifyUp` (see [Component registry](#2-component-registry)).
|
|
143
|
+
3. Replace `<AmplifyPageContent renderComponent={…} />` with `<AmplifyPage />` from `@/.amplifyup/component-registry`. Every other prop (`fallback`, `pageConfig`, loading and empty states) stays the same.
|
|
144
|
+
4. Check that each component file name matches its component ID in AmplifyUp (see [How components are found](#how-components-are-found)).
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
87
148
|
## Working with `fields`
|
|
88
149
|
|
|
89
150
|
Every component receives a `fields` prop. It is not raw CMS data — every entry is a **field envelope**:
|
|
@@ -431,7 +492,7 @@ export function TwoColumn() {
|
|
|
431
492
|
}
|
|
432
493
|
```
|
|
433
494
|
|
|
434
|
-
`<Slot>` takes only `name` and `className`.
|
|
495
|
+
`<Slot>` takes only `name` and `className`. The SDK hands each component its slot content when it renders it, so you never thread a `slots` prop through your component.
|
|
435
496
|
|
|
436
497
|
```tsx
|
|
437
498
|
// ✗ — Slot has no `slots` prop
|
|
@@ -476,7 +537,9 @@ In development the SDK tells you exactly what is wrong. Production is silent.
|
|
|
476
537
|
| `title has no write target; rendered read-only.` | A row field the SDK can't trace to a record | Bind the list to a connection, or query with the published spec |
|
|
477
538
|
| `Field value={…} requires name="…" for computed values` | You passed `value` without `name` | Add `name={fields.x.name}` |
|
|
478
539
|
| `Field needs field={fields.yourProp} (or value + name for computed values)` | No binding at all | Pass `field=` |
|
|
479
|
-
| `Slot "left"
|
|
540
|
+
| `Slot "left" only works inside a component rendered from your component registry` | `Slot` is used in a component the SDK didn't render | Use `Slot` only inside components in your components folder |
|
|
541
|
+
| `No component in your component registry matches "Hero"` | The page uses a component your site doesn't have | Add `Hero.tsx` (or a matching name) to your components folder |
|
|
542
|
+
| `renderComponent was removed in @amplifyup/sdk 0.2.0` | Code from 0.1 is still passing a render function | Follow [Upgrading from 0.1](#upgrading-from-01) |
|
|
480
543
|
|
|
481
544
|
---
|
|
482
545
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { P as PageConfig } from './types-ffQNIQCK.js';
|
|
5
|
+
|
|
6
|
+
declare const REGISTRY_BRAND: unique symbol;
|
|
7
|
+
type SiteComponent = ComponentType<any>;
|
|
8
|
+
type ComponentRegistry = {
|
|
9
|
+
readonly [REGISTRY_BRAND]: true;
|
|
10
|
+
/** Components by registry name (file name), as generated. */
|
|
11
|
+
readonly components: Readonly<Record<string, SiteComponent>>;
|
|
12
|
+
/** Looks up a layout component ID with the shared matching rule. */
|
|
13
|
+
resolve: (componentId: string) => SiteComponent | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Called by the generated `component-registry` module — sites don't call this by hand. */
|
|
16
|
+
declare const defineComponentRegistry: (components: Record<string, SiteComponent>) => ComponentRegistry;
|
|
17
|
+
|
|
18
|
+
interface AmplifyRendererProps {
|
|
19
|
+
/** The generated component registry (see `withAmplifyUp`). */
|
|
20
|
+
registry: ComponentRegistry;
|
|
21
|
+
/**
|
|
22
|
+
* Optional page config for server-side rendering (SSR/SSG)
|
|
23
|
+
* If provided, the component will use this instead of fetching client-side
|
|
24
|
+
*/
|
|
25
|
+
pageConfig?: PageConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Optional loading component
|
|
28
|
+
*/
|
|
29
|
+
loadingComponent?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Optional error component
|
|
32
|
+
*/
|
|
33
|
+
errorComponent?: (error: string) => ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Optional empty state component (when no content is configured)
|
|
36
|
+
*/
|
|
37
|
+
emptyComponent?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
40
|
+
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
41
|
+
*/
|
|
42
|
+
composerPreview?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare function AmplifyRendererInner(rendererProps: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
45
|
+
declare const AmplifyRenderer: react.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
46
|
+
|
|
47
|
+
export { AmplifyRenderer as A, type ComponentRegistry as C, defineComponentRegistry as d };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { P as PageConfig } from './types-ffQNIQCK.mjs';
|
|
5
|
+
|
|
6
|
+
declare const REGISTRY_BRAND: unique symbol;
|
|
7
|
+
type SiteComponent = ComponentType<any>;
|
|
8
|
+
type ComponentRegistry = {
|
|
9
|
+
readonly [REGISTRY_BRAND]: true;
|
|
10
|
+
/** Components by registry name (file name), as generated. */
|
|
11
|
+
readonly components: Readonly<Record<string, SiteComponent>>;
|
|
12
|
+
/** Looks up a layout component ID with the shared matching rule. */
|
|
13
|
+
resolve: (componentId: string) => SiteComponent | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Called by the generated `component-registry` module — sites don't call this by hand. */
|
|
16
|
+
declare const defineComponentRegistry: (components: Record<string, SiteComponent>) => ComponentRegistry;
|
|
17
|
+
|
|
18
|
+
interface AmplifyRendererProps {
|
|
19
|
+
/** The generated component registry (see `withAmplifyUp`). */
|
|
20
|
+
registry: ComponentRegistry;
|
|
21
|
+
/**
|
|
22
|
+
* Optional page config for server-side rendering (SSR/SSG)
|
|
23
|
+
* If provided, the component will use this instead of fetching client-side
|
|
24
|
+
*/
|
|
25
|
+
pageConfig?: PageConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Optional loading component
|
|
28
|
+
*/
|
|
29
|
+
loadingComponent?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Optional error component
|
|
32
|
+
*/
|
|
33
|
+
errorComponent?: (error: string) => ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Optional empty state component (when no content is configured)
|
|
36
|
+
*/
|
|
37
|
+
emptyComponent?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
40
|
+
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
41
|
+
*/
|
|
42
|
+
composerPreview?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare function AmplifyRendererInner(rendererProps: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
45
|
+
declare const AmplifyRenderer: react.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
46
|
+
|
|
47
|
+
export { AmplifyRenderer as A, type ComponentRegistry as C, defineComponentRegistry as d };
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
interface AmplifyRendererProps {
|
|
7
|
-
/**
|
|
8
|
-
* Component renderer function that maps componentId to React component
|
|
9
|
-
* This is site-specific and must be provided by the developer
|
|
10
|
-
*/
|
|
11
|
-
renderComponent: (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: {
|
|
12
|
-
layoutNodeId: string;
|
|
13
|
-
}) => ReactNode;
|
|
14
|
-
/**
|
|
15
|
-
* Optional page config for server-side rendering (SSR/SSG)
|
|
16
|
-
* If provided, the component will use this instead of fetching client-side
|
|
17
|
-
*/
|
|
18
|
-
pageConfig?: PageConfig;
|
|
19
|
-
/**
|
|
20
|
-
* Optional loading component
|
|
21
|
-
*/
|
|
22
|
-
loadingComponent?: ReactNode;
|
|
23
|
-
/**
|
|
24
|
-
* Optional error component
|
|
25
|
-
*/
|
|
26
|
-
errorComponent?: (error: string) => ReactNode;
|
|
27
|
-
/**
|
|
28
|
-
* Optional empty state component (when no content is configured)
|
|
29
|
-
*/
|
|
30
|
-
emptyComponent?: ReactNode;
|
|
31
|
-
/**
|
|
32
|
-
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
33
|
-
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
34
|
-
*/
|
|
35
|
-
composerPreview?: boolean;
|
|
36
|
-
}
|
|
37
|
-
declare function AmplifyRendererInner({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
38
|
-
declare const AmplifyRenderer: react.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
39
|
-
|
|
40
|
-
export { AmplifyRenderer };
|
|
1
|
+
import 'react';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
export { A as AmplifyRenderer } from './AmplifyRenderer-CPUr9Bkc.mjs';
|
|
4
|
+
import './types-ffQNIQCK.mjs';
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
interface AmplifyRendererProps {
|
|
7
|
-
/**
|
|
8
|
-
* Component renderer function that maps componentId to React component
|
|
9
|
-
* This is site-specific and must be provided by the developer
|
|
10
|
-
*/
|
|
11
|
-
renderComponent: (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: {
|
|
12
|
-
layoutNodeId: string;
|
|
13
|
-
}) => ReactNode;
|
|
14
|
-
/**
|
|
15
|
-
* Optional page config for server-side rendering (SSR/SSG)
|
|
16
|
-
* If provided, the component will use this instead of fetching client-side
|
|
17
|
-
*/
|
|
18
|
-
pageConfig?: PageConfig;
|
|
19
|
-
/**
|
|
20
|
-
* Optional loading component
|
|
21
|
-
*/
|
|
22
|
-
loadingComponent?: ReactNode;
|
|
23
|
-
/**
|
|
24
|
-
* Optional error component
|
|
25
|
-
*/
|
|
26
|
-
errorComponent?: (error: string) => ReactNode;
|
|
27
|
-
/**
|
|
28
|
-
* Optional empty state component (when no content is configured)
|
|
29
|
-
*/
|
|
30
|
-
emptyComponent?: ReactNode;
|
|
31
|
-
/**
|
|
32
|
-
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
33
|
-
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
34
|
-
*/
|
|
35
|
-
composerPreview?: boolean;
|
|
36
|
-
}
|
|
37
|
-
declare function AmplifyRendererInner({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
38
|
-
declare const AmplifyRenderer: react.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
39
|
-
|
|
40
|
-
export { AmplifyRenderer };
|
|
1
|
+
import 'react';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
export { A as AmplifyRenderer } from './AmplifyRenderer-BNWBrFQN.js';
|
|
4
|
+
import './types-ffQNIQCK.js';
|
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -3712,7 +3712,89 @@ function MaybeComposerProvider({
|
|
|
3712
3712
|
}) {
|
|
3713
3713
|
return /* @__PURE__ */ jsxRuntime.jsx(ComposerProvider, { enabled, children: /* @__PURE__ */ jsxRuntime.jsx(ComposerNodeContext.Provider, { value: enabled ? layoutNodeId : void 0, children }) });
|
|
3714
3714
|
}
|
|
3715
|
-
react.createContext(null);
|
|
3715
|
+
var ComponentContext = react.createContext(null);
|
|
3716
|
+
function ComponentContextProvider({
|
|
3717
|
+
children,
|
|
3718
|
+
slots,
|
|
3719
|
+
props,
|
|
3720
|
+
layoutNodeId,
|
|
3721
|
+
componentId
|
|
3722
|
+
}) {
|
|
3723
|
+
const next = hydratePageResourceProps(props || {}, getPageResourceFields());
|
|
3724
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3725
|
+
ComponentContext.Provider,
|
|
3726
|
+
{
|
|
3727
|
+
value: { slots, props: next, layoutNodeId, componentId },
|
|
3728
|
+
children
|
|
3729
|
+
}
|
|
3730
|
+
);
|
|
3731
|
+
}
|
|
3732
|
+
var REGISTRY_BRAND = Symbol.for("amplifyup.componentRegistry");
|
|
3733
|
+
var isComponentRegistry = (value) => !!value && typeof value === "object" && value[REGISTRY_BRAND] === true;
|
|
3734
|
+
var warnedMissing = /* @__PURE__ */ new Set();
|
|
3735
|
+
var warnMissingOnce = (componentId) => {
|
|
3736
|
+
if (warnedMissing.has(componentId)) return;
|
|
3737
|
+
warnedMissing.add(componentId);
|
|
3738
|
+
console.warn(
|
|
3739
|
+
`[Amplify UP] No component in your component registry matches "${componentId}". Add a file with that name to your components folder.`
|
|
3740
|
+
);
|
|
3741
|
+
};
|
|
3742
|
+
var MissingComponentHint = ({ componentId }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3743
|
+
"div",
|
|
3744
|
+
{
|
|
3745
|
+
"data-amplifyup-missing-component": componentId,
|
|
3746
|
+
style: {
|
|
3747
|
+
margin: "0.5rem 0",
|
|
3748
|
+
padding: "0.75rem 1rem",
|
|
3749
|
+
border: "1.5px dashed currentColor",
|
|
3750
|
+
borderRadius: 8,
|
|
3751
|
+
opacity: 0.7,
|
|
3752
|
+
fontSize: 14,
|
|
3753
|
+
textAlign: "center"
|
|
3754
|
+
},
|
|
3755
|
+
children: [
|
|
3756
|
+
"\u201C",
|
|
3757
|
+
componentId,
|
|
3758
|
+
"\u201D isn\u2019t set up on this site yet."
|
|
3759
|
+
]
|
|
3760
|
+
}
|
|
3761
|
+
);
|
|
3762
|
+
var RegistryComponent = ({
|
|
3763
|
+
registry,
|
|
3764
|
+
componentId,
|
|
3765
|
+
props,
|
|
3766
|
+
slots,
|
|
3767
|
+
layoutNodeId,
|
|
3768
|
+
composerPreview
|
|
3769
|
+
}) => {
|
|
3770
|
+
const Component2 = registry.resolve(componentId);
|
|
3771
|
+
if (!Component2) {
|
|
3772
|
+
warnMissingOnce(componentId);
|
|
3773
|
+
return composerPreview ? /* @__PURE__ */ jsxRuntime.jsx(MissingComponentHint, { componentId }) : null;
|
|
3774
|
+
}
|
|
3775
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3776
|
+
ComponentContextProvider,
|
|
3777
|
+
{
|
|
3778
|
+
props,
|
|
3779
|
+
slots,
|
|
3780
|
+
layoutNodeId,
|
|
3781
|
+
componentId,
|
|
3782
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Component2, { ...props })
|
|
3783
|
+
}
|
|
3784
|
+
);
|
|
3785
|
+
};
|
|
3786
|
+
var assertComponentRegistry = (owner, props) => {
|
|
3787
|
+
if ("renderComponent" in props) {
|
|
3788
|
+
throw new Error(
|
|
3789
|
+
`[Amplify UP] ${owner}: renderComponent was removed in @amplifyup/sdk 0.2.0. Components now load automatically \u2014 wrap next.config with withAmplifyUp and render <AmplifyPage /> from the generated component registry. See "Upgrading from 0.1" in the SDK README.`
|
|
3790
|
+
);
|
|
3791
|
+
}
|
|
3792
|
+
if (!isComponentRegistry(props.registry)) {
|
|
3793
|
+
throw new Error(
|
|
3794
|
+
`[Amplify UP] ${owner} needs your component registry. Render <AmplifyPage /> from the generated .amplifyup/component-registry module (created by withAmplifyUp or \`amplifyup registry\`).`
|
|
3795
|
+
);
|
|
3796
|
+
}
|
|
3797
|
+
};
|
|
3716
3798
|
var usePathname = null;
|
|
3717
3799
|
if (typeof window !== "undefined") {
|
|
3718
3800
|
try {
|
|
@@ -3799,21 +3881,31 @@ function NodeWithFields({
|
|
|
3799
3881
|
componentId,
|
|
3800
3882
|
props,
|
|
3801
3883
|
slots,
|
|
3802
|
-
|
|
3884
|
+
registry,
|
|
3803
3885
|
composerPreview
|
|
3804
3886
|
}) {
|
|
3805
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MaybeComposerProvider, { enabled: !!composerPreview, layoutNodeId: nodeId, children:
|
|
3806
|
-
|
|
3807
|
-
|
|
3887
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MaybeComposerProvider, { enabled: !!composerPreview, layoutNodeId: nodeId, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3888
|
+
RegistryComponent,
|
|
3889
|
+
{
|
|
3890
|
+
registry,
|
|
3891
|
+
componentId,
|
|
3892
|
+
props,
|
|
3893
|
+
slots,
|
|
3894
|
+
layoutNodeId: nodeId,
|
|
3895
|
+
composerPreview: !!composerPreview
|
|
3896
|
+
}
|
|
3897
|
+
) });
|
|
3808
3898
|
}
|
|
3809
|
-
function AmplifyRendererInner({
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3899
|
+
function AmplifyRendererInner(rendererProps) {
|
|
3900
|
+
assertComponentRegistry("AmplifyRenderer", rendererProps);
|
|
3901
|
+
const {
|
|
3902
|
+
registry,
|
|
3903
|
+
pageConfig: serverPageConfig,
|
|
3904
|
+
loadingComponent,
|
|
3905
|
+
errorComponent,
|
|
3906
|
+
emptyComponent,
|
|
3907
|
+
composerPreview
|
|
3908
|
+
} = rendererProps;
|
|
3817
3909
|
const clientHook = useAmplifyUp();
|
|
3818
3910
|
useRegisterPageContent(!serverPageConfig);
|
|
3819
3911
|
const composerPreviewFlag = useComposerPreviewFlag(!!composerPreview);
|
|
@@ -4149,7 +4241,7 @@ function AmplifyRendererInner({
|
|
|
4149
4241
|
componentId: node.componentId,
|
|
4150
4242
|
props: nodeRenderProps(node),
|
|
4151
4243
|
slots: slotsToPass,
|
|
4152
|
-
|
|
4244
|
+
registry,
|
|
4153
4245
|
composerPreview: composerPreviewFlag
|
|
4154
4246
|
}
|
|
4155
4247
|
)
|