@ampless/admin 0.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +78 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/index.js +41 -0
- package/dist/chunk-BN6BW7MP.js +2074 -0
- package/dist/chunk-TJR3ALRJ.js +575 -0
- package/dist/components/index.d.ts +169 -0
- package/dist/components/index.js +44 -0
- package/dist/i18n-ByHM_Bho.d.ts +738 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +115 -0
- package/dist/pages/index.d.ts +90 -0
- package/dist/pages/index.js +839 -0
- package/package.json +83 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { L as Locale, D as Dictionary } from '../i18n-ByHM_Bho.js';
|
|
3
|
+
import { Config, Post, ThemeManifest, LocalizedString, MediaProcessingDefaults } from 'ampless';
|
|
4
|
+
import { AmplessOutputs } from '@ampless/runtime';
|
|
5
|
+
import { ProcessOptions } from 'ampless/media';
|
|
6
|
+
|
|
7
|
+
interface ProviderProps {
|
|
8
|
+
locale: Locale;
|
|
9
|
+
/**
|
|
10
|
+
* Pass the dictionary as plain JSON via props. Server resolves it in
|
|
11
|
+
* the admin layout and threads it through, so the client bundle
|
|
12
|
+
* doesn't need to import every locale eagerly.
|
|
13
|
+
*/
|
|
14
|
+
dict: Dictionary;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
declare function I18nProvider({ locale, dict, children }: ProviderProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Client-side translation hook. For server components, prefer
|
|
20
|
+
* `admin.t(...)` from the createAdmin instance.
|
|
21
|
+
*/
|
|
22
|
+
declare function useT(): (key: string, vars?: Record<string, string | number>) => string;
|
|
23
|
+
/** Read the active locale from context (e.g. for `<html lang>` parity). */
|
|
24
|
+
declare function useLocale(): Locale;
|
|
25
|
+
|
|
26
|
+
declare const ADMIN_SITE_COOKIE = "admin-site-id";
|
|
27
|
+
/**
|
|
28
|
+
* Register the cms.config for client-side multi-site lookups. Called
|
|
29
|
+
* once from the admin layout factory.
|
|
30
|
+
*/
|
|
31
|
+
declare function setAdminCmsConfig(config: Config): void;
|
|
32
|
+
/**
|
|
33
|
+
* Read the active siteId from the cookie set by `<SiteSelector>`.
|
|
34
|
+
*
|
|
35
|
+
* - Single-site mode: always `DEFAULT_SITE_ID`.
|
|
36
|
+
* - Multi-site mode: the cookie value if it points to a declared site;
|
|
37
|
+
* otherwise the first site in `cms.config.sites` declaration order.
|
|
38
|
+
*
|
|
39
|
+
* The fallback matches `lib/admin-site.ts:currentAdminSiteId` (server
|
|
40
|
+
* side) so the two never disagree on first load.
|
|
41
|
+
*/
|
|
42
|
+
declare function readAdminSiteIdFromCookie(): string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Register the project's outputs + cms.config for client-side media
|
|
46
|
+
* URL resolution. Called once from the admin layout factory so client
|
|
47
|
+
* components downstream can call `publicMediaUrl` without threading
|
|
48
|
+
* the config through props.
|
|
49
|
+
*/
|
|
50
|
+
declare function setAdminMediaContext(outputs: AmplessOutputs, cmsConfig: Config): void;
|
|
51
|
+
/**
|
|
52
|
+
* Standalone `publicMediaUrl` callable from client components. Reads
|
|
53
|
+
* from the module-level state registered by `setAdminMediaContext`.
|
|
54
|
+
*
|
|
55
|
+
* Resolves based on `cms.config.ts` `media.delivery`:
|
|
56
|
+
* - `nextjs` (default): proxy via `/api/media/...` → Next.js issues a
|
|
57
|
+
* short-lived S3 presigned URL using server credentials.
|
|
58
|
+
* Keeps URLs permanent without making the bucket public.
|
|
59
|
+
* - `s3-direct`: build the direct `https://{bucket}.s3.{region}.amazonaws.com/public/...`
|
|
60
|
+
* URL. Requires the storage bucket policy in
|
|
61
|
+
* `amplify/backend.ts` to be active so anonymous GETs work.
|
|
62
|
+
*
|
|
63
|
+
* Inputs accepted:
|
|
64
|
+
* - "public/media/2026/04/foo.jpg" (S3 path)
|
|
65
|
+
* - "media/2026/04/foo.jpg" (path relative to public/)
|
|
66
|
+
* - "https://..." (passthrough)
|
|
67
|
+
*/
|
|
68
|
+
declare function publicMediaUrl(input: string): string;
|
|
69
|
+
|
|
70
|
+
declare function sanitizeName(name: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Run the image through processImage (crop/resize/encode) and upload the
|
|
73
|
+
* result to S3 under `public/media/YYYY/MM/`. Returns a stable public URL.
|
|
74
|
+
*
|
|
75
|
+
* Used by both /admin/media (gallery uploads) and the editor's MediaPicker
|
|
76
|
+
* (upload-and-embed) so the storage layout and naming stay consistent.
|
|
77
|
+
*/
|
|
78
|
+
declare function uploadProcessedImage(file: File, options: ProcessOptions): Promise<{
|
|
79
|
+
path: string;
|
|
80
|
+
url: string;
|
|
81
|
+
}>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Force-invalidate the Next.js fetch cache for a site's settings JSON.
|
|
85
|
+
* Used by the admin theme switcher: writes to KvStore propagate to S3
|
|
86
|
+
* via the trusted processor (~5-10s), and without this call the
|
|
87
|
+
* `revalidate: 60` on the public-side fetch would keep serving the old
|
|
88
|
+
* cached response for up to a minute after the rebuild.
|
|
89
|
+
*
|
|
90
|
+
* The cache tag matches the one used in `theme-active.ts` and
|
|
91
|
+
* `theme-config.ts` (in `@ampless/runtime`): `site-settings:{siteId}`.
|
|
92
|
+
*/
|
|
93
|
+
declare function invalidateSiteSettingsCache(siteId: string): Promise<void>;
|
|
94
|
+
|
|
95
|
+
declare function Sidebar({ email, siteSelector, }: {
|
|
96
|
+
email: string;
|
|
97
|
+
/** Rendered above the main nav in multi-site mode. */
|
|
98
|
+
siteSelector?: React.ReactNode;
|
|
99
|
+
}): react_jsx_runtime.JSX.Element;
|
|
100
|
+
|
|
101
|
+
interface SiteOption {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
}
|
|
105
|
+
interface Props$2 {
|
|
106
|
+
current: string;
|
|
107
|
+
sites: SiteOption[];
|
|
108
|
+
}
|
|
109
|
+
declare function SiteSelector({ current, sites }: Props$2): react_jsx_runtime.JSX.Element;
|
|
110
|
+
|
|
111
|
+
interface PostFormProps {
|
|
112
|
+
post?: Post;
|
|
113
|
+
}
|
|
114
|
+
declare function PostForm({ post }: PostFormProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
116
|
+
interface SiteSettingsFormValues {
|
|
117
|
+
'site.name'?: string;
|
|
118
|
+
'site.url'?: string;
|
|
119
|
+
'site.description'?: string;
|
|
120
|
+
'media.imageDisplay'?: 'inline' | 'lightbox';
|
|
121
|
+
'media.imageMaxWidth'?: string;
|
|
122
|
+
dateFormat?: 'iso' | 'long' | 'locale';
|
|
123
|
+
timezone?: string;
|
|
124
|
+
}
|
|
125
|
+
interface Props$1 {
|
|
126
|
+
siteId: string;
|
|
127
|
+
initial: SiteSettingsFormValues;
|
|
128
|
+
/** Defaults from cms.config.ts shown as placeholders. */
|
|
129
|
+
fallback: SiteSettingsFormValues;
|
|
130
|
+
}
|
|
131
|
+
declare function SiteSettingsForm({ siteId, initial, fallback }: Props$1): react_jsx_runtime.JSX.Element;
|
|
132
|
+
|
|
133
|
+
interface ThemeOption {
|
|
134
|
+
value: string;
|
|
135
|
+
label: LocalizedString;
|
|
136
|
+
description?: LocalizedString;
|
|
137
|
+
}
|
|
138
|
+
interface Props {
|
|
139
|
+
siteId: string;
|
|
140
|
+
manifest: ThemeManifest;
|
|
141
|
+
activeTheme: string;
|
|
142
|
+
themeOptions: ThemeOption[];
|
|
143
|
+
/** Resolved values currently shown to the user (overrides ?? defaults). */
|
|
144
|
+
initial: Record<string, string>;
|
|
145
|
+
}
|
|
146
|
+
declare function ThemeSettingsForm({ siteId, manifest, activeTheme, themeOptions, initial, }: Props): react_jsx_runtime.JSX.Element;
|
|
147
|
+
|
|
148
|
+
declare function MediaUploader(): react_jsx_runtime.JSX.Element;
|
|
149
|
+
|
|
150
|
+
interface MediaPickerProps {
|
|
151
|
+
trigger: React.ReactNode;
|
|
152
|
+
onSelect: (url: string) => void;
|
|
153
|
+
}
|
|
154
|
+
declare function MediaPicker({ trigger, onSelect }: MediaPickerProps): react_jsx_runtime.JSX.Element;
|
|
155
|
+
|
|
156
|
+
interface ImageUploadDialogProps {
|
|
157
|
+
file: File | null;
|
|
158
|
+
/** Total number of files still queued, including the current one. */
|
|
159
|
+
remaining: number;
|
|
160
|
+
/** True while the parent is uploading the current file. Disables Skip/Upload to prevent the queue race. */
|
|
161
|
+
busy?: boolean;
|
|
162
|
+
defaults?: MediaProcessingDefaults;
|
|
163
|
+
onConfirm: (file: File, options: ProcessOptions) => void;
|
|
164
|
+
onSkip: () => void;
|
|
165
|
+
onCancel: () => void;
|
|
166
|
+
}
|
|
167
|
+
declare function ImageUploadDialog({ file, remaining, busy, defaults, onConfirm, onSkip, onCancel, }: ImageUploadDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
168
|
+
|
|
169
|
+
export { ADMIN_SITE_COOKIE, I18nProvider, ImageUploadDialog, type ImageUploadDialogProps, MediaPicker, MediaUploader, PostForm, Sidebar, SiteSelector, SiteSettingsForm, type SiteSettingsFormValues, ThemeSettingsForm, invalidateSiteSettingsCache, publicMediaUrl, readAdminSiteIdFromCookie, sanitizeName, setAdminCmsConfig, setAdminMediaContext, uploadProcessedImage, useLocale, useT };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
I18nProvider,
|
|
3
|
+
ImageUploadDialog,
|
|
4
|
+
MediaPicker,
|
|
5
|
+
MediaUploader,
|
|
6
|
+
PostForm,
|
|
7
|
+
Sidebar,
|
|
8
|
+
SiteSelector,
|
|
9
|
+
SiteSettingsForm,
|
|
10
|
+
ThemeSettingsForm,
|
|
11
|
+
invalidateSiteSettingsCache,
|
|
12
|
+
sanitizeName,
|
|
13
|
+
uploadProcessedImage,
|
|
14
|
+
useLocale,
|
|
15
|
+
useT
|
|
16
|
+
} from "../chunk-BN6BW7MP.js";
|
|
17
|
+
import {
|
|
18
|
+
ADMIN_SITE_COOKIE,
|
|
19
|
+
publicMediaUrl,
|
|
20
|
+
readAdminSiteIdFromCookie,
|
|
21
|
+
setAdminCmsConfig,
|
|
22
|
+
setAdminMediaContext
|
|
23
|
+
} from "../chunk-TJR3ALRJ.js";
|
|
24
|
+
export {
|
|
25
|
+
ADMIN_SITE_COOKIE,
|
|
26
|
+
I18nProvider,
|
|
27
|
+
ImageUploadDialog,
|
|
28
|
+
MediaPicker,
|
|
29
|
+
MediaUploader,
|
|
30
|
+
PostForm,
|
|
31
|
+
Sidebar,
|
|
32
|
+
SiteSelector,
|
|
33
|
+
SiteSettingsForm,
|
|
34
|
+
ThemeSettingsForm,
|
|
35
|
+
invalidateSiteSettingsCache,
|
|
36
|
+
publicMediaUrl,
|
|
37
|
+
readAdminSiteIdFromCookie,
|
|
38
|
+
sanitizeName,
|
|
39
|
+
setAdminCmsConfig,
|
|
40
|
+
setAdminMediaContext,
|
|
41
|
+
uploadProcessedImage,
|
|
42
|
+
useLocale,
|
|
43
|
+
useT
|
|
44
|
+
};
|