@amplifyup/sdk 0.2.3 → 0.2.5
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/dist/{AmplifyRenderer-BNWBrFQN.d.ts → AmplifyRenderer-CTwblDs3.d.ts} +3 -4
- package/dist/{AmplifyRenderer-CPUr9Bkc.d.mts → AmplifyRenderer-eGtn5k9_.d.mts} +3 -4
- package/dist/AmplifyRenderer.d.mts +1 -2
- package/dist/AmplifyRenderer.d.ts +1 -2
- package/dist/AmplifyRenderer.js +2 -29
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +2 -29
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +1 -1
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +1 -1
- package/dist/next.mjs.map +1 -1
- package/dist/{query-Xo9cy-2F.d.ts → query-Bs5o-qmw.d.ts} +55 -55
- package/dist/{query-DYjs4LQQ.d.mts → query-CYRvyIv0.d.mts} +55 -55
- package/dist/react.d.mts +21 -15
- package/dist/react.d.ts +21 -15
- package/dist/react.js +5 -29
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +5 -29
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/next.js
CHANGED
|
@@ -233,7 +233,7 @@ var watchRegistry = async (cwd) => {
|
|
|
233
233
|
|
|
234
234
|
// src/next.ts
|
|
235
235
|
var DEV_PHASE = "phase-development-server";
|
|
236
|
-
var STATE_KEY = Symbol.for("amplifyup.registryBuild");
|
|
236
|
+
var STATE_KEY = /* @__PURE__ */ Symbol.for("amplifyup.registryBuild");
|
|
237
237
|
var registryState = () => {
|
|
238
238
|
const store = globalThis;
|
|
239
239
|
store[STATE_KEY] ?? (store[STATE_KEY] = {});
|
package/dist/next.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/load-config.ts","../src/component-key.ts","../src/cli/scan-components.ts","../src/cli/render-registry.ts","../src/cli/build-registry.ts","../src/next.ts"],"names":["path","existsSync","jiti","createJiti","readFileSync","glob","mkdirSync","writeFileSync","watch"],"mappings":";;;;;;;;;;;;;AAKA,IAAM,YAAA,GAAe;AAAA,EACnB,qBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAA;AAaA,IAAM,iBAAiB,CAAC,GAAA,KACtB,aAAa,GAAA,CAAI,CAAC,SAASA,sBAAA,CAAK,IAAA,CAAK,GAAA,EAAK,IAAI,CAAC,CAAA,CAAE,IAAA,CAAK,CAAC,IAAA,KAASC,aAAA,CAAW,IAAI,CAAC,CAAA;AAElF,IAAM,YAAA,GAAe,CAAC,GAAA,KACpBA,aAAA,CAAWD,uBAAK,IAAA,CAAK,GAAA,EAAK,KAAK,CAAC,CAAA,GAAI,CAAC,gBAAgB,CAAA,GAAI,CAAC,YAAY,CAAA;AAExE,IAAM,aAAA,GAAgB,CAAC,SAAA,KACrBA,sBAAA,CAAK,IAAA,CAAKA,uBAAK,OAAA,CAAQ,SAAS,CAAA,EAAG,YAAA,EAAc,oBAAoB,CAAA;AAGvE,IAAM,eAAA,GAAkB,CAAC,GAAA,KACvBC,aAAA,CAAWD,sBAAA,CAAK,KAAK,GAAA,EAAK,eAAe,CAAC,CAAA,GAAI,MAAA,GAAS,MAAA;AAElD,IAAM,oBAAA,GAAuB,OAClC,GAAA,KACsC;AACtC,EAAA,MAAM,UAAA,GAAa,eAAe,GAAG,CAAA;AACrC,EAAA,IAAI,SAAwB,EAAC;AAE7B,EAAA,IA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,MAAM,gBAAgB,KAAK,CAAA;AAC3B,EAAA,OAAO,OAAO,UAAA,KAAe,UAAA,GAAa,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA,GAAI,UAAA;AACzE","file":"next.js","sourcesContent":["import { existsSync } from 'fs';\nimport path from 'path';\nimport { createJiti } from 'jiti';\nimport type { AmplifyConfig } from '../config';\n\nconst CONFIG_FILES = [\n 'amplifyup.config.ts',\n 'amplifyup.config.mts',\n 'amplifyup.config.mjs',\n 'amplifyup.config.js',\n 'amplifyup.config.cjs',\n];\n\nexport type ResolvedComponentsConfig = {\n cwd: string;\n /** Absolute component folders. */\n roots: string[];\n exclude: string[];\n /** Absolute generated file path, extension included. */\n outputFile: string;\n /** Config file that was loaded, if any. */\n configFile?: string;\n};\n\nconst findConfigFile = (cwd: string): string | undefined =>\n CONFIG_FILES.map((name) => path.join(cwd, name)).find((file) => existsSync(file));\n\nconst defaultRoots = (cwd: string): string[] =>\n existsSync(path.join(cwd, 'src')) ? ['src/components'] : ['components'];\n\nconst defaultOutput = (firstRoot: string): string =>\n path.join(path.dirname(firstRoot), '.amplifyup', 'component-registry');\n\n/** TS projects get `.tsx`; plain JS projects get `.jsx` so Next doesn't switch them to TypeScript. */\nconst outputExtension = (cwd: string): string =>\n existsSync(path.join(cwd, 'tsconfig.json')) ? '.tsx' : '.jsx';\n\nexport const loadComponentsConfig = async (\n cwd: string\n): Promise<ResolvedComponentsConfig> => {\n const configFile = findConfigFile(cwd);\n let config: AmplifyConfig = {};\n\n if (configFile) {\n const jiti = createJiti(path.join(cwd, 'amplifyup.config.loader'));\n config = (await jiti.import<AmplifyConfig>(configFile, { default: true })) ?? {};\n }\n\n const components = config.components ?? {};\n const roots = components.roots?.length ? components.roots : defaultRoots(cwd);\n const output = components.output ?? defaultOutput(roots[0]);\n\n return {\n cwd,\n roots: roots.map((root) => path.resolve(cwd, root)),\n exclude: components.exclude ?? [],\n outputFile: path.resolve(cwd, output) + outputExtension(cwd),\n configFile,\n };\n};\n","/**\n * One matching rule for layout component IDs and component file names, so\n * `Hero`, `hero`, `HERO` and `e2e-hero` / `E2eHero` resolve to the same entry.\n */\nexport const componentKey = (id: string): string =>\n id.toLowerCase().replace(/[^a-z0-9]/g, '');\n","import { existsSync, readFileSync } from 'fs';\nimport path from 'path';\nimport { glob } from 'tinyglobby';\nimport { componentKey } from '../component-key';\nimport type { ResolvedComponentsConfig } from './load-config';\n\nconst ALWAYS_EXCLUDE = [\n '**/*.test.*',\n '**/*.spec.*',\n '**/*.stories.*',\n '**/*.d.ts',\n '**/__tests__/**',\n '**/__mocks__/**',\n];\n\nexport type RegistryEntry = {\n /** Registry name — the file (or folder, for `index` files) name. */\n name: string;\n key: string;\n /** Absolute file path. */\n file: string;\n /** `default`, or the named export that is the component. */\n exportName: string;\n};\n\nexport type SkippedFile = {\n file: string;\n reason: string;\n};\n\nexport type ScanResult = {\n entries: RegistryEntry[];\n skipped: SkippedFile[];\n missingRoots: string[];\n};\n\nexport class ComponentRegistryError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ComponentRegistryError';\n }\n}\n\nconst NAMED_DECLARATION =\n /export\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class)\\s+([A-Za-z_$][\\w$]*)/g;\n\nconst EXPORT_LIST = /export\\s*\\{([^}]*)\\}/g;\n\n/** Export names a file declares, read from source (no type checking needed). */\nconst readExports = (source: string): { hasDefault: boolean; named: string[] } => {\n const named: string[] = [];\n let hasDefault = /export\\s+default\\b/.test(source);\n\n for (const match of source.matchAll(NAMED_DECLARATION)) {\n named.push(match[1]);\n }\n\n for (const match of source.matchAll(EXPORT_LIST)) {\n for (const part of match[1].split(',')) {\n const spec = part.trim();\n if (!spec || spec.startsWith('type ')) continue;\n\n const exported = spec.split(/\\s+as\\s+/).pop()!.trim();\n if (exported === 'default') {\n hasDefault = true;\n } else {\n named.push(exported);\n }\n }\n }\n\n return { hasDefault, named };\n};\n\nconst entryName = (file: string, root: string): string | null => {\n const base = path.basename(file, path.extname(file));\n if (base !== 'index') return base;\n\n // `components/index.tsx` is a barrel, not a component.\n const dir = path.dirname(file);\n return dir === root ? null : path.basename(dir);\n};\n\n/** `Hero/index.tsx` and `Hero/Hero.tsx` describe one component — keep the index. */\nconst isIndexPair = (a: RegistryEntry, b: RegistryEntry): boolean =>\n path.dirname(a.file) === path.dirname(b.file) &&\n [a, b].some((entry) => path.basename(entry.file).startsWith('index.'));\n\nconst toEntry = (\n file: string,\n root: string\n): RegistryEntry | SkippedFile | null => {\n const name = entryName(file, root);\n if (!name) return null;\n\n const key = componentKey(name);\n const { hasDefault, named } = readExports(readFileSync(file, 'utf8'));\n const exportName = hasDefault\n ? 'default'\n : named.find((exported) => componentKey(exported) === key);\n\n if (!exportName) {\n return {\n file,\n reason: `no default export or export named \"${name}\"`,\n };\n }\n\n return { name, key, file, exportName };\n};\n\nexport const scanComponents = async (\n config: ResolvedComponentsConfig\n): Promise<ScanResult> => {\n const byKey = new Map<string, RegistryEntry>();\n const skipped: SkippedFile[] = [];\n const missingRoots: string[] = [];\n\n for (const root of config.roots) {\n if (!existsSync(root)) {\n missingRoots.push(root);\n continue;\n }\n\n const files = await glob(['**/*.{tsx,jsx,js}'], {\n cwd: root,\n ignore: [...ALWAYS_EXCLUDE, ...config.exclude],\n absolute: true,\n });\n\n for (const file of files.map((f) => path.resolve(f)).sort()) {\n const result = toEntry(file, root);\n if (!result) continue;\n\n if (!('key' in result)) {\n skipped.push(result);\n continue;\n }\n\n const existing = byKey.get(result.key);\n if (!existing) {\n byKey.set(result.key, result);\n continue;\n }\n\n if (isIndexPair(existing, result)) {\n const keepResult = path.basename(result.file).startsWith('index.');\n if (keepResult) byKey.set(result.key, result);\n continue;\n }\n\n throw new ComponentRegistryError(\n `Two components resolve to the same name \"${result.name}\":\\n` +\n ` ${path.relative(config.cwd, existing.file)}\\n` +\n ` ${path.relative(config.cwd, result.file)}\\n` +\n 'Rename one of them, or add it to components.exclude in amplifyup.config.ts.'\n );\n }\n }\n\n const entries = [...byKey.values()].sort((a, b) => a.name.localeCompare(b.name));\n return { entries, skipped, missingRoots };\n};\n","import path from 'path';\nimport type { RegistryEntry } from './scan-components';\n\nconst importPath = (fromFile: string, toFile: string): string => {\n const withoutExt = toFile.slice(0, toFile.length - path.extname(toFile).length);\n const relative = path\n .relative(path.dirname(fromFile), withoutExt)\n .split(path.sep)\n .join('/')\n .replace(/\\/index$/, '');\n return relative.startsWith('.') ? relative : `./${relative}`;\n};\n\nconst importLine = (entry: RegistryEntry, local: string, outputFile: string): string => {\n const from = JSON.stringify(importPath(outputFile, entry.file));\n return entry.exportName === 'default'\n ? `import ${local} from ${from};`\n : `import { ${entry.exportName} as ${local} } from ${from};`;\n};\n\n/** Source of the generated component registry module. Stable for unchanged input. */\nexport const renderRegistrySource = (\n entries: RegistryEntry[],\n outputFile: string\n): string => {\n const imports = entries.map((entry, i) => importLine(entry, `C${i}`, outputFile));\n const members = entries.map((entry, i) => ` ${JSON.stringify(entry.name)}: C${i},`);\n\n return [\n \"'use client';\",\n '',\n '// Generated by Amplify UP from your components folder. Do not edit —',\n '// add, rename or delete component files instead.',\n '',\n \"import { defineComponentRegistry, bindAmplifyPage } from '@amplifyup/sdk/react';\",\n ...imports,\n '',\n 'export const componentRegistry = defineComponentRegistry({',\n ...members,\n '});',\n '',\n 'export const AmplifyPage = bindAmplifyPage(componentRegistry);',\n '',\n ].join('\\n');\n};\n","import { existsSync, mkdirSync, readFileSync, watch, writeFileSync, type FSWatcher } from 'fs';\nimport path from 'path';\nimport { loadComponentsConfig, type ResolvedComponentsConfig } from './load-config';\nimport { scanComponents, type ScanResult } from './scan-components';\nimport { renderRegistrySource } from './render-registry';\n\nconst LOG_PREFIX = '[Amplify UP]';\nconst WATCH_DEBOUNCE_MS = 120;\n\nexport type BuildRegistryResult = ScanResult & {\n outputFile: string;\n /** False when the file already had this content (no rewrite, no HMR churn). */\n changed: boolean;\n};\n\nconst writeIfChanged = (file: string, content: string): boolean => {\n if (existsSync(file) && readFileSync(file, 'utf8') === content) return false;\n\n mkdirSync(path.dirname(file), { recursive: true });\n writeFileSync(file, content);\n return true;\n};\n\n/** The generated folder ignores itself, so sites never commit it. */\nconst ensureSelfIgnored = (outputFile: string): void => {\n const dir = path.dirname(outputFile);\n if (path.basename(dir) !== '.amplifyup') return;\n writeIfChanged(path.join(dir, '.gitignore'), '*\\n');\n};\n\nexport const buildRegistryFromConfig = async (\n config: ResolvedComponentsConfig\n): Promise<BuildRegistryResult> => {\n const scan = await scanComponents(config);\n const source = renderRegistrySource(scan.entries, config.outputFile);\n\n const changed = writeIfChanged(config.outputFile, source);\n ensureSelfIgnored(config.outputFile);\n\n return { ...scan, outputFile: config.outputFile, changed };\n};\n\nexport const buildRegistry = async (cwd: string): Promise<BuildRegistryResult> =>\n buildRegistryFromConfig(await loadComponentsConfig(cwd));\n\nexport const reportRegistry = (result: BuildRegistryResult, cwd: string): void => {\n const rel = (file: string) => path.relative(cwd, file) || '.';\n\n for (const root of result.missingRoots) {\n console.warn(`${LOG_PREFIX} Components folder not found: ${rel(root)}`);\n }\n\n for (const skip of result.skipped) {\n console.warn(`${LOG_PREFIX} Skipped ${rel(skip.file)}: ${skip.reason}`);\n }\n\n console.log(\n `${LOG_PREFIX} Component registry: ${result.entries.length} component(s) → ${rel(result.outputFile)}`\n );\n};\n\n/** Regenerates on add/remove/rename. Returns a function that stops watching. */\nexport const watchRegistry = async (cwd: string): Promise<() => void> => {\n const config = await loadComponentsConfig(cwd);\n const watchers: FSWatcher[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const rebuild = () => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n buildRegistryFromConfig(config)\n .then((result) => {\n if (result.changed) reportRegistry(result, cwd);\n })\n .catch((error: unknown) => {\n console.error(`${LOG_PREFIX} Component registry update failed:`, error);\n });\n }, WATCH_DEBOUNCE_MS);\n };\n\n for (const root of config.roots.filter((r) => existsSync(r))) {\n watchers.push(watch(root, { recursive: true }, rebuild));\n }\n\n return () => {\n clearTimeout(timer);\n watchers.forEach((watcher) => watcher.close());\n };\n};\n","/**\n * `withAmplifyUp(nextConfig)` — builds the component registry whenever Next\n * loads its config (`next build`, `next dev`) and keeps it current during dev.\n */\nimport { buildRegistry, reportRegistry, watchRegistry } from './cli/build-registry';\n\ntype NextConfigObject = Record<string, unknown>;\n\ntype NextConfigContext = {\n defaultConfig: NextConfigObject;\n};\n\ntype NextConfigFunction = (\n phase: string,\n context: NextConfigContext\n) => NextConfigObject | Promise<NextConfigObject>;\n\ntype NextConfigInput = NextConfigObject | NextConfigFunction;\n\nconst DEV_PHASE = 'phase-development-server';\n\ntype RegistryState = {\n built?: Promise<void>;\n watching?: boolean;\n};\n\n// Next loads its config more than once per process; build and watch only once.\nconst STATE_KEY = Symbol.for('amplifyup.registryBuild');\n\nconst registryState = (): RegistryState => {\n const store = globalThis as typeof globalThis & { [STATE_KEY]?: RegistryState };\n store[STATE_KEY] ??= {};\n return store[STATE_KEY]!;\n};\n\nconst prepareRegistry = async (phase: string): Promise<void> => {\n const cwd = process.cwd();\n const state = registryState();\n\n state.built ??= buildRegistry(cwd).then((result) => reportRegistry(result, cwd));\n await state.built;\n\n if (phase === DEV_PHASE && !state.watching) {\n state.watching = true;\n await watchRegistry(cwd);\n }\n};\n\nexport const withAmplifyUp = (nextConfig: NextConfigInput = {}): NextConfigFunction =>\n async (phase, context) => {\n await prepareRegistry(phase);\n return typeof nextConfig === 'function' ? nextConfig(phase, context) : nextConfig;\n };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli/load-config.ts","../src/component-key.ts","../src/cli/scan-components.ts","../src/cli/render-registry.ts","../src/cli/build-registry.ts","../src/next.ts"],"names":["path","existsSync","jiti","createJiti","readFileSync","glob","mkdirSync","writeFileSync","watch"],"mappings":";;;;;;;;;;;;;AAKA,IAAM,YAAA,GAAe;AAAA,EACnB,qBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,qBAAA;AAAA,EAC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,EAAA,MAAM,KAAA,GAAQ,UAAA;AACd,EAAA,KAAA,CAAA,SAAA,CAAA,KAAA,KAAA,CAAA,SAAA,CAAA,GAAqB,EAAC,CAAA;AACtB,EAAA,OAAO,MAAM,SAAS,CAAA;AACxB,CAAA;AAEA,IAAM,eAAA,GAAkB,OAAO,KAAA,KAAiC;AAC9D,EAAA,MAAM,GAAA,GAAM,QAAQ,GAAA,EAAI;AACxB,EAAA,MAAM,QAAQ,aAAA,EAAc;AAE5B,EAAA,KAAA,CAAM,KAAA,KAAN,KAAA,CAAM,KAAA,GAAU,aAAA,CAAc,GAAG,CAAA,CAAE,IAAA,CAAK,CAAC,MAAA,KAAW,cAAA,CAAe,MAAA,EAAQ,GAAG,CAAC,CAAA,CAAA;AAC/E,EAAA,MAAM,KAAA,CAAM,KAAA;AAEZ,EAAA,IAAI,KAAA,KAAU,SAAA,IAAa,CAAC,KAAA,CAAM,QAAA,EAAU;AAC1C,IAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AACjB,IAAA,MAAM,cAAc,GAAG,CAAA;AAAA,EACzB;AACF,CAAA;AAEO,IAAM,gBAAgB,CAAC,UAAA,GAA8B,EAAC,KAC3D,OAAO,OAAO,OAAA,KAAY;AACxB,EAAA,MAAM,gBAAgB,KAAK,CAAA;AAC3B,EAAA,OAAO,OAAO,UAAA,KAAe,UAAA,GAAa,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA,GAAI,UAAA;AACzE","file":"next.js","sourcesContent":["import { existsSync } from 'fs';\nimport path from 'path';\nimport { createJiti } from 'jiti';\nimport type { AmplifyConfig } from '../config';\n\nconst CONFIG_FILES = [\n 'amplifyup.config.ts',\n 'amplifyup.config.mts',\n 'amplifyup.config.mjs',\n 'amplifyup.config.js',\n 'amplifyup.config.cjs',\n];\n\nexport type ResolvedComponentsConfig = {\n cwd: string;\n /** Absolute component folders. */\n roots: string[];\n exclude: string[];\n /** Absolute generated file path, extension included. */\n outputFile: string;\n /** Config file that was loaded, if any. */\n configFile?: string;\n};\n\nconst findConfigFile = (cwd: string): string | undefined =>\n CONFIG_FILES.map((name) => path.join(cwd, name)).find((file) => existsSync(file));\n\nconst defaultRoots = (cwd: string): string[] =>\n existsSync(path.join(cwd, 'src')) ? ['src/components'] : ['components'];\n\nconst defaultOutput = (firstRoot: string): string =>\n path.join(path.dirname(firstRoot), '.amplifyup', 'component-registry');\n\n/** TS projects get `.tsx`; plain JS projects get `.jsx` so Next doesn't switch them to TypeScript. */\nconst outputExtension = (cwd: string): string =>\n existsSync(path.join(cwd, 'tsconfig.json')) ? '.tsx' : '.jsx';\n\nexport const loadComponentsConfig = async (\n cwd: string\n): Promise<ResolvedComponentsConfig> => {\n const configFile = findConfigFile(cwd);\n let config: AmplifyConfig = {};\n\n if (configFile) {\n const jiti = createJiti(path.join(cwd, 'amplifyup.config.loader'));\n config = (await jiti.import<AmplifyConfig>(configFile, { default: true })) ?? {};\n }\n\n const components = config.components ?? {};\n const roots = components.roots?.length ? components.roots : defaultRoots(cwd);\n const output = components.output ?? defaultOutput(roots[0]);\n\n return {\n cwd,\n roots: roots.map((root) => path.resolve(cwd, root)),\n exclude: components.exclude ?? [],\n outputFile: path.resolve(cwd, output) + outputExtension(cwd),\n configFile,\n };\n};\n","/**\n * One matching rule for layout component IDs and component file names, so\n * `Hero`, `hero`, `HERO` and `e2e-hero` / `E2eHero` resolve to the same entry.\n */\nexport const componentKey = (id: string): string =>\n id.toLowerCase().replace(/[^a-z0-9]/g, '');\n","import { existsSync, readFileSync } from 'fs';\nimport path from 'path';\nimport { glob } from 'tinyglobby';\nimport { componentKey } from '../component-key';\nimport type { ResolvedComponentsConfig } from './load-config';\n\nconst ALWAYS_EXCLUDE = [\n '**/*.test.*',\n '**/*.spec.*',\n '**/*.stories.*',\n '**/*.d.ts',\n '**/__tests__/**',\n '**/__mocks__/**',\n];\n\nexport type RegistryEntry = {\n /** Registry name — the file (or folder, for `index` files) name. */\n name: string;\n key: string;\n /** Absolute file path. */\n file: string;\n /** `default`, or the named export that is the component. */\n exportName: string;\n};\n\nexport type SkippedFile = {\n file: string;\n reason: string;\n};\n\nexport type ScanResult = {\n entries: RegistryEntry[];\n skipped: SkippedFile[];\n missingRoots: string[];\n};\n\nexport class ComponentRegistryError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ComponentRegistryError';\n }\n}\n\nconst NAMED_DECLARATION =\n /export\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class)\\s+([A-Za-z_$][\\w$]*)/g;\n\nconst EXPORT_LIST = /export\\s*\\{([^}]*)\\}/g;\n\n/** Export names a file declares, read from source (no type checking needed). */\nconst readExports = (source: string): { hasDefault: boolean; named: string[] } => {\n const named: string[] = [];\n let hasDefault = /export\\s+default\\b/.test(source);\n\n for (const match of source.matchAll(NAMED_DECLARATION)) {\n named.push(match[1]);\n }\n\n for (const match of source.matchAll(EXPORT_LIST)) {\n for (const part of match[1].split(',')) {\n const spec = part.trim();\n if (!spec || spec.startsWith('type ')) continue;\n\n const exported = spec.split(/\\s+as\\s+/).pop()!.trim();\n if (exported === 'default') {\n hasDefault = true;\n } else {\n named.push(exported);\n }\n }\n }\n\n return { hasDefault, named };\n};\n\nconst entryName = (file: string, root: string): string | null => {\n const base = path.basename(file, path.extname(file));\n if (base !== 'index') return base;\n\n // `components/index.tsx` is a barrel, not a component.\n const dir = path.dirname(file);\n return dir === root ? null : path.basename(dir);\n};\n\n/** `Hero/index.tsx` and `Hero/Hero.tsx` describe one component — keep the index. */\nconst isIndexPair = (a: RegistryEntry, b: RegistryEntry): boolean =>\n path.dirname(a.file) === path.dirname(b.file) &&\n [a, b].some((entry) => path.basename(entry.file).startsWith('index.'));\n\nconst toEntry = (\n file: string,\n root: string\n): RegistryEntry | SkippedFile | null => {\n const name = entryName(file, root);\n if (!name) return null;\n\n const key = componentKey(name);\n const { hasDefault, named } = readExports(readFileSync(file, 'utf8'));\n const exportName = hasDefault\n ? 'default'\n : named.find((exported) => componentKey(exported) === key);\n\n if (!exportName) {\n return {\n file,\n reason: `no default export or export named \"${name}\"`,\n };\n }\n\n return { name, key, file, exportName };\n};\n\nexport const scanComponents = async (\n config: ResolvedComponentsConfig\n): Promise<ScanResult> => {\n const byKey = new Map<string, RegistryEntry>();\n const skipped: SkippedFile[] = [];\n const missingRoots: string[] = [];\n\n for (const root of config.roots) {\n if (!existsSync(root)) {\n missingRoots.push(root);\n continue;\n }\n\n const files = await glob(['**/*.{tsx,jsx,js}'], {\n cwd: root,\n ignore: [...ALWAYS_EXCLUDE, ...config.exclude],\n absolute: true,\n });\n\n for (const file of files.map((f) => path.resolve(f)).sort()) {\n const result = toEntry(file, root);\n if (!result) continue;\n\n if (!('key' in result)) {\n skipped.push(result);\n continue;\n }\n\n const existing = byKey.get(result.key);\n if (!existing) {\n byKey.set(result.key, result);\n continue;\n }\n\n if (isIndexPair(existing, result)) {\n const keepResult = path.basename(result.file).startsWith('index.');\n if (keepResult) byKey.set(result.key, result);\n continue;\n }\n\n throw new ComponentRegistryError(\n `Two components resolve to the same name \"${result.name}\":\\n` +\n ` ${path.relative(config.cwd, existing.file)}\\n` +\n ` ${path.relative(config.cwd, result.file)}\\n` +\n 'Rename one of them, or add it to components.exclude in amplifyup.config.ts.'\n );\n }\n }\n\n const entries = [...byKey.values()].sort((a, b) => a.name.localeCompare(b.name));\n return { entries, skipped, missingRoots };\n};\n","import path from 'path';\nimport type { RegistryEntry } from './scan-components';\n\nconst importPath = (fromFile: string, toFile: string): string => {\n const withoutExt = toFile.slice(0, toFile.length - path.extname(toFile).length);\n const relative = path\n .relative(path.dirname(fromFile), withoutExt)\n .split(path.sep)\n .join('/')\n .replace(/\\/index$/, '');\n return relative.startsWith('.') ? relative : `./${relative}`;\n};\n\nconst importLine = (entry: RegistryEntry, local: string, outputFile: string): string => {\n const from = JSON.stringify(importPath(outputFile, entry.file));\n return entry.exportName === 'default'\n ? `import ${local} from ${from};`\n : `import { ${entry.exportName} as ${local} } from ${from};`;\n};\n\n/** Source of the generated component registry module. Stable for unchanged input. */\nexport const renderRegistrySource = (\n entries: RegistryEntry[],\n outputFile: string\n): string => {\n const imports = entries.map((entry, i) => importLine(entry, `C${i}`, outputFile));\n const members = entries.map((entry, i) => ` ${JSON.stringify(entry.name)}: C${i},`);\n\n return [\n \"'use client';\",\n '',\n '// Generated by Amplify UP from your components folder. Do not edit —',\n '// add, rename or delete component files instead.',\n '',\n \"import { defineComponentRegistry, bindAmplifyPage } from '@amplifyup/sdk/react';\",\n ...imports,\n '',\n 'export const componentRegistry = defineComponentRegistry({',\n ...members,\n '});',\n '',\n 'export const AmplifyPage = bindAmplifyPage(componentRegistry);',\n '',\n ].join('\\n');\n};\n","import { existsSync, mkdirSync, readFileSync, watch, writeFileSync, type FSWatcher } from 'fs';\nimport path from 'path';\nimport { loadComponentsConfig, type ResolvedComponentsConfig } from './load-config';\nimport { scanComponents, type ScanResult } from './scan-components';\nimport { renderRegistrySource } from './render-registry';\n\nconst LOG_PREFIX = '[Amplify UP]';\nconst WATCH_DEBOUNCE_MS = 120;\n\nexport type BuildRegistryResult = ScanResult & {\n outputFile: string;\n /** False when the file already had this content (no rewrite, no HMR churn). */\n changed: boolean;\n};\n\nconst writeIfChanged = (file: string, content: string): boolean => {\n if (existsSync(file) && readFileSync(file, 'utf8') === content) return false;\n\n mkdirSync(path.dirname(file), { recursive: true });\n writeFileSync(file, content);\n return true;\n};\n\n/** The generated folder ignores itself, so sites never commit it. */\nconst ensureSelfIgnored = (outputFile: string): void => {\n const dir = path.dirname(outputFile);\n if (path.basename(dir) !== '.amplifyup') return;\n writeIfChanged(path.join(dir, '.gitignore'), '*\\n');\n};\n\nexport const buildRegistryFromConfig = async (\n config: ResolvedComponentsConfig\n): Promise<BuildRegistryResult> => {\n const scan = await scanComponents(config);\n const source = renderRegistrySource(scan.entries, config.outputFile);\n\n const changed = writeIfChanged(config.outputFile, source);\n ensureSelfIgnored(config.outputFile);\n\n return { ...scan, outputFile: config.outputFile, changed };\n};\n\nexport const buildRegistry = async (cwd: string): Promise<BuildRegistryResult> =>\n buildRegistryFromConfig(await loadComponentsConfig(cwd));\n\nexport const reportRegistry = (result: BuildRegistryResult, cwd: string): void => {\n const rel = (file: string) => path.relative(cwd, file) || '.';\n\n for (const root of result.missingRoots) {\n console.warn(`${LOG_PREFIX} Components folder not found: ${rel(root)}`);\n }\n\n for (const skip of result.skipped) {\n console.warn(`${LOG_PREFIX} Skipped ${rel(skip.file)}: ${skip.reason}`);\n }\n\n console.log(\n `${LOG_PREFIX} Component registry: ${result.entries.length} component(s) → ${rel(result.outputFile)}`\n );\n};\n\n/** Regenerates on add/remove/rename. Returns a function that stops watching. */\nexport const watchRegistry = async (cwd: string): Promise<() => void> => {\n const config = await loadComponentsConfig(cwd);\n const watchers: FSWatcher[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const rebuild = () => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n buildRegistryFromConfig(config)\n .then((result) => {\n if (result.changed) reportRegistry(result, cwd);\n })\n .catch((error: unknown) => {\n console.error(`${LOG_PREFIX} Component registry update failed:`, error);\n });\n }, WATCH_DEBOUNCE_MS);\n };\n\n for (const root of config.roots.filter((r) => existsSync(r))) {\n watchers.push(watch(root, { recursive: true }, rebuild));\n }\n\n return () => {\n clearTimeout(timer);\n watchers.forEach((watcher) => watcher.close());\n };\n};\n","/**\n * `withAmplifyUp(nextConfig)` — builds the component registry whenever Next\n * loads its config (`next build`, `next dev`) and keeps it current during dev.\n */\nimport { buildRegistry, reportRegistry, watchRegistry } from './cli/build-registry';\n\ntype NextConfigObject = Record<string, unknown>;\n\ntype NextConfigContext = {\n defaultConfig: NextConfigObject;\n};\n\ntype NextConfigFunction = (\n phase: string,\n context: NextConfigContext\n) => NextConfigObject | Promise<NextConfigObject>;\n\ntype NextConfigInput = NextConfigObject | NextConfigFunction;\n\nconst DEV_PHASE = 'phase-development-server';\n\ntype RegistryState = {\n built?: Promise<void>;\n watching?: boolean;\n};\n\n// Next loads its config more than once per process; build and watch only once.\nconst STATE_KEY = Symbol.for('amplifyup.registryBuild');\n\nconst registryState = (): RegistryState => {\n const store = globalThis as typeof globalThis & { [STATE_KEY]?: RegistryState };\n store[STATE_KEY] ??= {};\n return store[STATE_KEY]!;\n};\n\nconst prepareRegistry = async (phase: string): Promise<void> => {\n const cwd = process.cwd();\n const state = registryState();\n\n state.built ??= buildRegistry(cwd).then((result) => reportRegistry(result, cwd));\n await state.built;\n\n if (phase === DEV_PHASE && !state.watching) {\n state.watching = true;\n await watchRegistry(cwd);\n }\n};\n\nexport const withAmplifyUp = (nextConfig: NextConfigInput = {}): NextConfigFunction =>\n async (phase, context) => {\n await prepareRegistry(phase);\n return typeof nextConfig === 'function' ? nextConfig(phase, context) : nextConfig;\n };\n"]}
|
package/dist/next.mjs
CHANGED
|
@@ -227,7 +227,7 @@ var watchRegistry = async (cwd) => {
|
|
|
227
227
|
|
|
228
228
|
// src/next.ts
|
|
229
229
|
var DEV_PHASE = "phase-development-server";
|
|
230
|
-
var STATE_KEY = Symbol.for("amplifyup.registryBuild");
|
|
230
|
+
var STATE_KEY = /* @__PURE__ */ Symbol.for("amplifyup.registryBuild");
|
|
231
231
|
var registryState = () => {
|
|
232
232
|
const store = globalThis;
|
|
233
233
|
store[STATE_KEY] ?? (store[STATE_KEY] = {});
|
package/dist/next.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/load-config.ts","../src/component-key.ts","../src/cli/scan-components.ts","../src/cli/render-registry.ts","../src/cli/build-registry.ts","../src/next.ts"],"names":["path","existsSync","readFileSync"],"mappings":";;;;;;;AAKA,IAAM,YAAA,GAAe;AAAA,EACnB,qBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAA;AAaA,IAAM,iBAAiB,CAAC,GAAA,KACtB,aAAa,GAAA,CAAI,CAAC,SAASA,KAAA,CAAK,IAAA,CAAK,GAAA,EAAK,IAAI,CA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IAAM,eAAA,GAAkB,OAAO,KAAA,KAAiC;AAC9D,EAAA,MAAM,GAAA,GAAM,QAAQ,GAAA,EAAI;AACxB,EAAA,MAAM,QAAQ,aAAA,EAAc;AAE5B,EAAA,KAAA,CAAM,KAAA,KAAN,KAAA,CAAM,KAAA,GAAU,aAAA,CAAc,GAAG,CAAA,CAAE,IAAA,CAAK,CAAC,MAAA,KAAW,cAAA,CAAe,MAAA,EAAQ,GAAG,CAAC,CAAA,CAAA;AAC/E,EAAA,MAAM,KAAA,CAAM,KAAA;AAEZ,EAAA,IAAI,KAAA,KAAU,SAAA,IAAa,CAAC,KAAA,CAAM,QAAA,EAAU;AAC1C,IAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AACjB,IAAA,MAAM,cAAc,GAAG,CAAA;AAAA,EACzB;AACF,CAAA;AAEO,IAAM,gBAAgB,CAAC,UAAA,GAA8B,EAAC,KAC3D,OAAO,OAAO,OAAA,KAAY;AACxB,EAAA,MAAM,gBAAgB,KAAK,CAAA;AAC3B,EAAA,OAAO,OAAO,UAAA,KAAe,UAAA,GAAa,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA,GAAI,UAAA;AACzE","file":"next.mjs","sourcesContent":["import { existsSync } from 'fs';\nimport path from 'path';\nimport { createJiti } from 'jiti';\nimport type { AmplifyConfig } from '../config';\n\nconst CONFIG_FILES = [\n 'amplifyup.config.ts',\n 'amplifyup.config.mts',\n 'amplifyup.config.mjs',\n 'amplifyup.config.js',\n 'amplifyup.config.cjs',\n];\n\nexport type ResolvedComponentsConfig = {\n cwd: string;\n /** Absolute component folders. */\n roots: string[];\n exclude: string[];\n /** Absolute generated file path, extension included. */\n outputFile: string;\n /** Config file that was loaded, if any. */\n configFile?: string;\n};\n\nconst findConfigFile = (cwd: string): string | undefined =>\n CONFIG_FILES.map((name) => path.join(cwd, name)).find((file) => existsSync(file));\n\nconst defaultRoots = (cwd: string): string[] =>\n existsSync(path.join(cwd, 'src')) ? ['src/components'] : ['components'];\n\nconst defaultOutput = (firstRoot: string): string =>\n path.join(path.dirname(firstRoot), '.amplifyup', 'component-registry');\n\n/** TS projects get `.tsx`; plain JS projects get `.jsx` so Next doesn't switch them to TypeScript. */\nconst outputExtension = (cwd: string): string =>\n existsSync(path.join(cwd, 'tsconfig.json')) ? '.tsx' : '.jsx';\n\nexport const loadComponentsConfig = async (\n cwd: string\n): Promise<ResolvedComponentsConfig> => {\n const configFile = findConfigFile(cwd);\n let config: AmplifyConfig = {};\n\n if (configFile) {\n const jiti = createJiti(path.join(cwd, 'amplifyup.config.loader'));\n config = (await jiti.import<AmplifyConfig>(configFile, { default: true })) ?? {};\n }\n\n const components = config.components ?? {};\n const roots = components.roots?.length ? components.roots : defaultRoots(cwd);\n const output = components.output ?? defaultOutput(roots[0]);\n\n return {\n cwd,\n roots: roots.map((root) => path.resolve(cwd, root)),\n exclude: components.exclude ?? [],\n outputFile: path.resolve(cwd, output) + outputExtension(cwd),\n configFile,\n };\n};\n","/**\n * One matching rule for layout component IDs and component file names, so\n * `Hero`, `hero`, `HERO` and `e2e-hero` / `E2eHero` resolve to the same entry.\n */\nexport const componentKey = (id: string): string =>\n id.toLowerCase().replace(/[^a-z0-9]/g, '');\n","import { existsSync, readFileSync } from 'fs';\nimport path from 'path';\nimport { glob } from 'tinyglobby';\nimport { componentKey } from '../component-key';\nimport type { ResolvedComponentsConfig } from './load-config';\n\nconst ALWAYS_EXCLUDE = [\n '**/*.test.*',\n '**/*.spec.*',\n '**/*.stories.*',\n '**/*.d.ts',\n '**/__tests__/**',\n '**/__mocks__/**',\n];\n\nexport type RegistryEntry = {\n /** Registry name — the file (or folder, for `index` files) name. */\n name: string;\n key: string;\n /** Absolute file path. */\n file: string;\n /** `default`, or the named export that is the component. */\n exportName: string;\n};\n\nexport type SkippedFile = {\n file: string;\n reason: string;\n};\n\nexport type ScanResult = {\n entries: RegistryEntry[];\n skipped: SkippedFile[];\n missingRoots: string[];\n};\n\nexport class ComponentRegistryError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ComponentRegistryError';\n }\n}\n\nconst NAMED_DECLARATION =\n /export\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class)\\s+([A-Za-z_$][\\w$]*)/g;\n\nconst EXPORT_LIST = /export\\s*\\{([^}]*)\\}/g;\n\n/** Export names a file declares, read from source (no type checking needed). */\nconst readExports = (source: string): { hasDefault: boolean; named: string[] } => {\n const named: string[] = [];\n let hasDefault = /export\\s+default\\b/.test(source);\n\n for (const match of source.matchAll(NAMED_DECLARATION)) {\n named.push(match[1]);\n }\n\n for (const match of source.matchAll(EXPORT_LIST)) {\n for (const part of match[1].split(',')) {\n const spec = part.trim();\n if (!spec || spec.startsWith('type ')) continue;\n\n const exported = spec.split(/\\s+as\\s+/).pop()!.trim();\n if (exported === 'default') {\n hasDefault = true;\n } else {\n named.push(exported);\n }\n }\n }\n\n return { hasDefault, named };\n};\n\nconst entryName = (file: string, root: string): string | null => {\n const base = path.basename(file, path.extname(file));\n if (base !== 'index') return base;\n\n // `components/index.tsx` is a barrel, not a component.\n const dir = path.dirname(file);\n return dir === root ? null : path.basename(dir);\n};\n\n/** `Hero/index.tsx` and `Hero/Hero.tsx` describe one component — keep the index. */\nconst isIndexPair = (a: RegistryEntry, b: RegistryEntry): boolean =>\n path.dirname(a.file) === path.dirname(b.file) &&\n [a, b].some((entry) => path.basename(entry.file).startsWith('index.'));\n\nconst toEntry = (\n file: string,\n root: string\n): RegistryEntry | SkippedFile | null => {\n const name = entryName(file, root);\n if (!name) return null;\n\n const key = componentKey(name);\n const { hasDefault, named } = readExports(readFileSync(file, 'utf8'));\n const exportName = hasDefault\n ? 'default'\n : named.find((exported) => componentKey(exported) === key);\n\n if (!exportName) {\n return {\n file,\n reason: `no default export or export named \"${name}\"`,\n };\n }\n\n return { name, key, file, exportName };\n};\n\nexport const scanComponents = async (\n config: ResolvedComponentsConfig\n): Promise<ScanResult> => {\n const byKey = new Map<string, RegistryEntry>();\n const skipped: SkippedFile[] = [];\n const missingRoots: string[] = [];\n\n for (const root of config.roots) {\n if (!existsSync(root)) {\n missingRoots.push(root);\n continue;\n }\n\n const files = await glob(['**/*.{tsx,jsx,js}'], {\n cwd: root,\n ignore: [...ALWAYS_EXCLUDE, ...config.exclude],\n absolute: true,\n });\n\n for (const file of files.map((f) => path.resolve(f)).sort()) {\n const result = toEntry(file, root);\n if (!result) continue;\n\n if (!('key' in result)) {\n skipped.push(result);\n continue;\n }\n\n const existing = byKey.get(result.key);\n if (!existing) {\n byKey.set(result.key, result);\n continue;\n }\n\n if (isIndexPair(existing, result)) {\n const keepResult = path.basename(result.file).startsWith('index.');\n if (keepResult) byKey.set(result.key, result);\n continue;\n }\n\n throw new ComponentRegistryError(\n `Two components resolve to the same name \"${result.name}\":\\n` +\n ` ${path.relative(config.cwd, existing.file)}\\n` +\n ` ${path.relative(config.cwd, result.file)}\\n` +\n 'Rename one of them, or add it to components.exclude in amplifyup.config.ts.'\n );\n }\n }\n\n const entries = [...byKey.values()].sort((a, b) => a.name.localeCompare(b.name));\n return { entries, skipped, missingRoots };\n};\n","import path from 'path';\nimport type { RegistryEntry } from './scan-components';\n\nconst importPath = (fromFile: string, toFile: string): string => {\n const withoutExt = toFile.slice(0, toFile.length - path.extname(toFile).length);\n const relative = path\n .relative(path.dirname(fromFile), withoutExt)\n .split(path.sep)\n .join('/')\n .replace(/\\/index$/, '');\n return relative.startsWith('.') ? relative : `./${relative}`;\n};\n\nconst importLine = (entry: RegistryEntry, local: string, outputFile: string): string => {\n const from = JSON.stringify(importPath(outputFile, entry.file));\n return entry.exportName === 'default'\n ? `import ${local} from ${from};`\n : `import { ${entry.exportName} as ${local} } from ${from};`;\n};\n\n/** Source of the generated component registry module. Stable for unchanged input. */\nexport const renderRegistrySource = (\n entries: RegistryEntry[],\n outputFile: string\n): string => {\n const imports = entries.map((entry, i) => importLine(entry, `C${i}`, outputFile));\n const members = entries.map((entry, i) => ` ${JSON.stringify(entry.name)}: C${i},`);\n\n return [\n \"'use client';\",\n '',\n '// Generated by Amplify UP from your components folder. Do not edit —',\n '// add, rename or delete component files instead.',\n '',\n \"import { defineComponentRegistry, bindAmplifyPage } from '@amplifyup/sdk/react';\",\n ...imports,\n '',\n 'export const componentRegistry = defineComponentRegistry({',\n ...members,\n '});',\n '',\n 'export const AmplifyPage = bindAmplifyPage(componentRegistry);',\n '',\n ].join('\\n');\n};\n","import { existsSync, mkdirSync, readFileSync, watch, writeFileSync, type FSWatcher } from 'fs';\nimport path from 'path';\nimport { loadComponentsConfig, type ResolvedComponentsConfig } from './load-config';\nimport { scanComponents, type ScanResult } from './scan-components';\nimport { renderRegistrySource } from './render-registry';\n\nconst LOG_PREFIX = '[Amplify UP]';\nconst WATCH_DEBOUNCE_MS = 120;\n\nexport type BuildRegistryResult = ScanResult & {\n outputFile: string;\n /** False when the file already had this content (no rewrite, no HMR churn). */\n changed: boolean;\n};\n\nconst writeIfChanged = (file: string, content: string): boolean => {\n if (existsSync(file) && readFileSync(file, 'utf8') === content) return false;\n\n mkdirSync(path.dirname(file), { recursive: true });\n writeFileSync(file, content);\n return true;\n};\n\n/** The generated folder ignores itself, so sites never commit it. */\nconst ensureSelfIgnored = (outputFile: string): void => {\n const dir = path.dirname(outputFile);\n if (path.basename(dir) !== '.amplifyup') return;\n writeIfChanged(path.join(dir, '.gitignore'), '*\\n');\n};\n\nexport const buildRegistryFromConfig = async (\n config: ResolvedComponentsConfig\n): Promise<BuildRegistryResult> => {\n const scan = await scanComponents(config);\n const source = renderRegistrySource(scan.entries, config.outputFile);\n\n const changed = writeIfChanged(config.outputFile, source);\n ensureSelfIgnored(config.outputFile);\n\n return { ...scan, outputFile: config.outputFile, changed };\n};\n\nexport const buildRegistry = async (cwd: string): Promise<BuildRegistryResult> =>\n buildRegistryFromConfig(await loadComponentsConfig(cwd));\n\nexport const reportRegistry = (result: BuildRegistryResult, cwd: string): void => {\n const rel = (file: string) => path.relative(cwd, file) || '.';\n\n for (const root of result.missingRoots) {\n console.warn(`${LOG_PREFIX} Components folder not found: ${rel(root)}`);\n }\n\n for (const skip of result.skipped) {\n console.warn(`${LOG_PREFIX} Skipped ${rel(skip.file)}: ${skip.reason}`);\n }\n\n console.log(\n `${LOG_PREFIX} Component registry: ${result.entries.length} component(s) → ${rel(result.outputFile)}`\n );\n};\n\n/** Regenerates on add/remove/rename. Returns a function that stops watching. */\nexport const watchRegistry = async (cwd: string): Promise<() => void> => {\n const config = await loadComponentsConfig(cwd);\n const watchers: FSWatcher[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const rebuild = () => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n buildRegistryFromConfig(config)\n .then((result) => {\n if (result.changed) reportRegistry(result, cwd);\n })\n .catch((error: unknown) => {\n console.error(`${LOG_PREFIX} Component registry update failed:`, error);\n });\n }, WATCH_DEBOUNCE_MS);\n };\n\n for (const root of config.roots.filter((r) => existsSync(r))) {\n watchers.push(watch(root, { recursive: true }, rebuild));\n }\n\n return () => {\n clearTimeout(timer);\n watchers.forEach((watcher) => watcher.close());\n };\n};\n","/**\n * `withAmplifyUp(nextConfig)` — builds the component registry whenever Next\n * loads its config (`next build`, `next dev`) and keeps it current during dev.\n */\nimport { buildRegistry, reportRegistry, watchRegistry } from './cli/build-registry';\n\ntype NextConfigObject = Record<string, unknown>;\n\ntype NextConfigContext = {\n defaultConfig: NextConfigObject;\n};\n\ntype NextConfigFunction = (\n phase: string,\n context: NextConfigContext\n) => NextConfigObject | Promise<NextConfigObject>;\n\ntype NextConfigInput = NextConfigObject | NextConfigFunction;\n\nconst DEV_PHASE = 'phase-development-server';\n\ntype RegistryState = {\n built?: Promise<void>;\n watching?: boolean;\n};\n\n// Next loads its config more than once per process; build and watch only once.\nconst STATE_KEY = Symbol.for('amplifyup.registryBuild');\n\nconst registryState = (): RegistryState => {\n const store = globalThis as typeof globalThis & { [STATE_KEY]?: RegistryState };\n store[STATE_KEY] ??= {};\n return store[STATE_KEY]!;\n};\n\nconst prepareRegistry = async (phase: string): Promise<void> => {\n const cwd = process.cwd();\n const state = registryState();\n\n state.built ??= buildRegistry(cwd).then((result) => reportRegistry(result, cwd));\n await state.built;\n\n if (phase === DEV_PHASE && !state.watching) {\n state.watching = true;\n await watchRegistry(cwd);\n }\n};\n\nexport const withAmplifyUp = (nextConfig: NextConfigInput = {}): NextConfigFunction =>\n async (phase, context) => {\n await prepareRegistry(phase);\n return typeof nextConfig === 'function' ? nextConfig(phase, context) : nextConfig;\n };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli/load-config.ts","../src/component-key.ts","../src/cli/scan-components.ts","../src/cli/render-registry.ts","../src/cli/build-registry.ts","../src/next.ts"],"names":["path","existsSync","readFileSync"],"mappings":";;;;;;;AAKA,IAAM,YAAA,GAAe;AAAA,EACnB,qBAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAA;AAaA,IAAM,iBAAiB,CAAC,GAAA,KACtB,aAAa,GAAA,CAAI,CAAC,SAASA,KAAA,CAAK,IAAA,CAAK,GAAA,EAAK,IAAI,CAAC,CAAA,CAAE,IAAA,CAAK,CAAC,IAAA,KAAS,UAAA,CAAW,IAAI,CAAC,CAAA;AAElF,IAAM,YAAA,GAAe,CAAC,GAAA,KACpB,UAAA,CAAWA,MAAK,IAAA,CAAK,GAAA,EAAK,KAAK,CAAC,CAAA,GAAI,CAAC,gBAAgB,CAAA,GAAI,CAAC,YAAY,CAAA;AAExE,IAAM,aAAA,GAAgB,CAAC,SAAA,KACrBA,KAAA,CAAK,IAAA,CAAKA,MAAK,OAAA,CAAQ,SAAS,CAAA,EAAG,YAAA,EAAc,oBAAoB,CAAA;AAGvE,IAAM,eAAA,GAAkB,CAAC,GAAA,KACvB,UAAA,CAAWA,KAAA,CAAK,KAAK,GAAA,EAAK,eAAe,CAAC,CAAA,GAAI,MAAA,GAAS,MAAA;AAElD,IAAM,oBAAA,GAAuB,OAClC,GAAA,KACsC;AACtC,EAA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8B,EAAC,KAC3D,OAAO,OAAO,OAAA,KAAY;AACxB,EAAA,MAAM,gBAAgB,KAAK,CAAA;AAC3B,EAAA,OAAO,OAAO,UAAA,KAAe,UAAA,GAAa,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA,GAAI,UAAA;AACzE","file":"next.mjs","sourcesContent":["import { existsSync } from 'fs';\nimport path from 'path';\nimport { createJiti } from 'jiti';\nimport type { AmplifyConfig } from '../config';\n\nconst CONFIG_FILES = [\n 'amplifyup.config.ts',\n 'amplifyup.config.mts',\n 'amplifyup.config.mjs',\n 'amplifyup.config.js',\n 'amplifyup.config.cjs',\n];\n\nexport type ResolvedComponentsConfig = {\n cwd: string;\n /** Absolute component folders. */\n roots: string[];\n exclude: string[];\n /** Absolute generated file path, extension included. */\n outputFile: string;\n /** Config file that was loaded, if any. */\n configFile?: string;\n};\n\nconst findConfigFile = (cwd: string): string | undefined =>\n CONFIG_FILES.map((name) => path.join(cwd, name)).find((file) => existsSync(file));\n\nconst defaultRoots = (cwd: string): string[] =>\n existsSync(path.join(cwd, 'src')) ? ['src/components'] : ['components'];\n\nconst defaultOutput = (firstRoot: string): string =>\n path.join(path.dirname(firstRoot), '.amplifyup', 'component-registry');\n\n/** TS projects get `.tsx`; plain JS projects get `.jsx` so Next doesn't switch them to TypeScript. */\nconst outputExtension = (cwd: string): string =>\n existsSync(path.join(cwd, 'tsconfig.json')) ? '.tsx' : '.jsx';\n\nexport const loadComponentsConfig = async (\n cwd: string\n): Promise<ResolvedComponentsConfig> => {\n const configFile = findConfigFile(cwd);\n let config: AmplifyConfig = {};\n\n if (configFile) {\n const jiti = createJiti(path.join(cwd, 'amplifyup.config.loader'));\n config = (await jiti.import<AmplifyConfig>(configFile, { default: true })) ?? {};\n }\n\n const components = config.components ?? {};\n const roots = components.roots?.length ? components.roots : defaultRoots(cwd);\n const output = components.output ?? defaultOutput(roots[0]);\n\n return {\n cwd,\n roots: roots.map((root) => path.resolve(cwd, root)),\n exclude: components.exclude ?? [],\n outputFile: path.resolve(cwd, output) + outputExtension(cwd),\n configFile,\n };\n};\n","/**\n * One matching rule for layout component IDs and component file names, so\n * `Hero`, `hero`, `HERO` and `e2e-hero` / `E2eHero` resolve to the same entry.\n */\nexport const componentKey = (id: string): string =>\n id.toLowerCase().replace(/[^a-z0-9]/g, '');\n","import { existsSync, readFileSync } from 'fs';\nimport path from 'path';\nimport { glob } from 'tinyglobby';\nimport { componentKey } from '../component-key';\nimport type { ResolvedComponentsConfig } from './load-config';\n\nconst ALWAYS_EXCLUDE = [\n '**/*.test.*',\n '**/*.spec.*',\n '**/*.stories.*',\n '**/*.d.ts',\n '**/__tests__/**',\n '**/__mocks__/**',\n];\n\nexport type RegistryEntry = {\n /** Registry name — the file (or folder, for `index` files) name. */\n name: string;\n key: string;\n /** Absolute file path. */\n file: string;\n /** `default`, or the named export that is the component. */\n exportName: string;\n};\n\nexport type SkippedFile = {\n file: string;\n reason: string;\n};\n\nexport type ScanResult = {\n entries: RegistryEntry[];\n skipped: SkippedFile[];\n missingRoots: string[];\n};\n\nexport class ComponentRegistryError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ComponentRegistryError';\n }\n}\n\nconst NAMED_DECLARATION =\n /export\\s+(?:declare\\s+)?(?:async\\s+)?(?:const|let|var|function\\*?|class)\\s+([A-Za-z_$][\\w$]*)/g;\n\nconst EXPORT_LIST = /export\\s*\\{([^}]*)\\}/g;\n\n/** Export names a file declares, read from source (no type checking needed). */\nconst readExports = (source: string): { hasDefault: boolean; named: string[] } => {\n const named: string[] = [];\n let hasDefault = /export\\s+default\\b/.test(source);\n\n for (const match of source.matchAll(NAMED_DECLARATION)) {\n named.push(match[1]);\n }\n\n for (const match of source.matchAll(EXPORT_LIST)) {\n for (const part of match[1].split(',')) {\n const spec = part.trim();\n if (!spec || spec.startsWith('type ')) continue;\n\n const exported = spec.split(/\\s+as\\s+/).pop()!.trim();\n if (exported === 'default') {\n hasDefault = true;\n } else {\n named.push(exported);\n }\n }\n }\n\n return { hasDefault, named };\n};\n\nconst entryName = (file: string, root: string): string | null => {\n const base = path.basename(file, path.extname(file));\n if (base !== 'index') return base;\n\n // `components/index.tsx` is a barrel, not a component.\n const dir = path.dirname(file);\n return dir === root ? null : path.basename(dir);\n};\n\n/** `Hero/index.tsx` and `Hero/Hero.tsx` describe one component — keep the index. */\nconst isIndexPair = (a: RegistryEntry, b: RegistryEntry): boolean =>\n path.dirname(a.file) === path.dirname(b.file) &&\n [a, b].some((entry) => path.basename(entry.file).startsWith('index.'));\n\nconst toEntry = (\n file: string,\n root: string\n): RegistryEntry | SkippedFile | null => {\n const name = entryName(file, root);\n if (!name) return null;\n\n const key = componentKey(name);\n const { hasDefault, named } = readExports(readFileSync(file, 'utf8'));\n const exportName = hasDefault\n ? 'default'\n : named.find((exported) => componentKey(exported) === key);\n\n if (!exportName) {\n return {\n file,\n reason: `no default export or export named \"${name}\"`,\n };\n }\n\n return { name, key, file, exportName };\n};\n\nexport const scanComponents = async (\n config: ResolvedComponentsConfig\n): Promise<ScanResult> => {\n const byKey = new Map<string, RegistryEntry>();\n const skipped: SkippedFile[] = [];\n const missingRoots: string[] = [];\n\n for (const root of config.roots) {\n if (!existsSync(root)) {\n missingRoots.push(root);\n continue;\n }\n\n const files = await glob(['**/*.{tsx,jsx,js}'], {\n cwd: root,\n ignore: [...ALWAYS_EXCLUDE, ...config.exclude],\n absolute: true,\n });\n\n for (const file of files.map((f) => path.resolve(f)).sort()) {\n const result = toEntry(file, root);\n if (!result) continue;\n\n if (!('key' in result)) {\n skipped.push(result);\n continue;\n }\n\n const existing = byKey.get(result.key);\n if (!existing) {\n byKey.set(result.key, result);\n continue;\n }\n\n if (isIndexPair(existing, result)) {\n const keepResult = path.basename(result.file).startsWith('index.');\n if (keepResult) byKey.set(result.key, result);\n continue;\n }\n\n throw new ComponentRegistryError(\n `Two components resolve to the same name \"${result.name}\":\\n` +\n ` ${path.relative(config.cwd, existing.file)}\\n` +\n ` ${path.relative(config.cwd, result.file)}\\n` +\n 'Rename one of them, or add it to components.exclude in amplifyup.config.ts.'\n );\n }\n }\n\n const entries = [...byKey.values()].sort((a, b) => a.name.localeCompare(b.name));\n return { entries, skipped, missingRoots };\n};\n","import path from 'path';\nimport type { RegistryEntry } from './scan-components';\n\nconst importPath = (fromFile: string, toFile: string): string => {\n const withoutExt = toFile.slice(0, toFile.length - path.extname(toFile).length);\n const relative = path\n .relative(path.dirname(fromFile), withoutExt)\n .split(path.sep)\n .join('/')\n .replace(/\\/index$/, '');\n return relative.startsWith('.') ? relative : `./${relative}`;\n};\n\nconst importLine = (entry: RegistryEntry, local: string, outputFile: string): string => {\n const from = JSON.stringify(importPath(outputFile, entry.file));\n return entry.exportName === 'default'\n ? `import ${local} from ${from};`\n : `import { ${entry.exportName} as ${local} } from ${from};`;\n};\n\n/** Source of the generated component registry module. Stable for unchanged input. */\nexport const renderRegistrySource = (\n entries: RegistryEntry[],\n outputFile: string\n): string => {\n const imports = entries.map((entry, i) => importLine(entry, `C${i}`, outputFile));\n const members = entries.map((entry, i) => ` ${JSON.stringify(entry.name)}: C${i},`);\n\n return [\n \"'use client';\",\n '',\n '// Generated by Amplify UP from your components folder. Do not edit —',\n '// add, rename or delete component files instead.',\n '',\n \"import { defineComponentRegistry, bindAmplifyPage } from '@amplifyup/sdk/react';\",\n ...imports,\n '',\n 'export const componentRegistry = defineComponentRegistry({',\n ...members,\n '});',\n '',\n 'export const AmplifyPage = bindAmplifyPage(componentRegistry);',\n '',\n ].join('\\n');\n};\n","import { existsSync, mkdirSync, readFileSync, watch, writeFileSync, type FSWatcher } from 'fs';\nimport path from 'path';\nimport { loadComponentsConfig, type ResolvedComponentsConfig } from './load-config';\nimport { scanComponents, type ScanResult } from './scan-components';\nimport { renderRegistrySource } from './render-registry';\n\nconst LOG_PREFIX = '[Amplify UP]';\nconst WATCH_DEBOUNCE_MS = 120;\n\nexport type BuildRegistryResult = ScanResult & {\n outputFile: string;\n /** False when the file already had this content (no rewrite, no HMR churn). */\n changed: boolean;\n};\n\nconst writeIfChanged = (file: string, content: string): boolean => {\n if (existsSync(file) && readFileSync(file, 'utf8') === content) return false;\n\n mkdirSync(path.dirname(file), { recursive: true });\n writeFileSync(file, content);\n return true;\n};\n\n/** The generated folder ignores itself, so sites never commit it. */\nconst ensureSelfIgnored = (outputFile: string): void => {\n const dir = path.dirname(outputFile);\n if (path.basename(dir) !== '.amplifyup') return;\n writeIfChanged(path.join(dir, '.gitignore'), '*\\n');\n};\n\nexport const buildRegistryFromConfig = async (\n config: ResolvedComponentsConfig\n): Promise<BuildRegistryResult> => {\n const scan = await scanComponents(config);\n const source = renderRegistrySource(scan.entries, config.outputFile);\n\n const changed = writeIfChanged(config.outputFile, source);\n ensureSelfIgnored(config.outputFile);\n\n return { ...scan, outputFile: config.outputFile, changed };\n};\n\nexport const buildRegistry = async (cwd: string): Promise<BuildRegistryResult> =>\n buildRegistryFromConfig(await loadComponentsConfig(cwd));\n\nexport const reportRegistry = (result: BuildRegistryResult, cwd: string): void => {\n const rel = (file: string) => path.relative(cwd, file) || '.';\n\n for (const root of result.missingRoots) {\n console.warn(`${LOG_PREFIX} Components folder not found: ${rel(root)}`);\n }\n\n for (const skip of result.skipped) {\n console.warn(`${LOG_PREFIX} Skipped ${rel(skip.file)}: ${skip.reason}`);\n }\n\n console.log(\n `${LOG_PREFIX} Component registry: ${result.entries.length} component(s) → ${rel(result.outputFile)}`\n );\n};\n\n/** Regenerates on add/remove/rename. Returns a function that stops watching. */\nexport const watchRegistry = async (cwd: string): Promise<() => void> => {\n const config = await loadComponentsConfig(cwd);\n const watchers: FSWatcher[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const rebuild = () => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n buildRegistryFromConfig(config)\n .then((result) => {\n if (result.changed) reportRegistry(result, cwd);\n })\n .catch((error: unknown) => {\n console.error(`${LOG_PREFIX} Component registry update failed:`, error);\n });\n }, WATCH_DEBOUNCE_MS);\n };\n\n for (const root of config.roots.filter((r) => existsSync(r))) {\n watchers.push(watch(root, { recursive: true }, rebuild));\n }\n\n return () => {\n clearTimeout(timer);\n watchers.forEach((watcher) => watcher.close());\n };\n};\n","/**\n * `withAmplifyUp(nextConfig)` — builds the component registry whenever Next\n * loads its config (`next build`, `next dev`) and keeps it current during dev.\n */\nimport { buildRegistry, reportRegistry, watchRegistry } from './cli/build-registry';\n\ntype NextConfigObject = Record<string, unknown>;\n\ntype NextConfigContext = {\n defaultConfig: NextConfigObject;\n};\n\ntype NextConfigFunction = (\n phase: string,\n context: NextConfigContext\n) => NextConfigObject | Promise<NextConfigObject>;\n\ntype NextConfigInput = NextConfigObject | NextConfigFunction;\n\nconst DEV_PHASE = 'phase-development-server';\n\ntype RegistryState = {\n built?: Promise<void>;\n watching?: boolean;\n};\n\n// Next loads its config more than once per process; build and watch only once.\nconst STATE_KEY = Symbol.for('amplifyup.registryBuild');\n\nconst registryState = (): RegistryState => {\n const store = globalThis as typeof globalThis & { [STATE_KEY]?: RegistryState };\n store[STATE_KEY] ??= {};\n return store[STATE_KEY]!;\n};\n\nconst prepareRegistry = async (phase: string): Promise<void> => {\n const cwd = process.cwd();\n const state = registryState();\n\n state.built ??= buildRegistry(cwd).then((result) => reportRegistry(result, cwd));\n await state.built;\n\n if (phase === DEV_PHASE && !state.watching) {\n state.watching = true;\n await watchRegistry(cwd);\n }\n};\n\nexport const withAmplifyUp = (nextConfig: NextConfigInput = {}): NextConfigFunction =>\n async (phase, context) => {\n await prepareRegistry(phase);\n return typeof nextConfig === 'function' ? nextConfig(phase, context) : nextConfig;\n };\n"]}
|
|
@@ -1,59 +1,5 @@
|
|
|
1
1
|
import { A as AmplifyUpTarget } from './types-ffQNIQCK.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* On-request variant selection (tier 3).
|
|
5
|
-
*
|
|
6
|
-
* Decisions happen on AmplifyUp Edge. The client asks after the view has
|
|
7
|
-
* rendered; the Worker returns variant keys only. Profile data never leaves
|
|
8
|
-
* the edge. This helper is the JS wrapper around POST /v1/select — the same
|
|
9
|
-
* wire format is the contract for Flutter / native / .NET clients. No DOM
|
|
10
|
-
* or Next.js assumptions.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
interface SelectVariantsResult {
|
|
14
|
-
siteId: string;
|
|
15
|
-
view: string;
|
|
16
|
-
variantKeys: Record<string, string>;
|
|
17
|
-
meta?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
declare class SelectVariantsError extends Error {
|
|
20
|
-
status: number;
|
|
21
|
-
body: unknown;
|
|
22
|
-
constructor(message: string, status: number, body?: unknown);
|
|
23
|
-
}
|
|
24
|
-
interface FetchEdgeSelectOptions {
|
|
25
|
-
edgeUrl: string;
|
|
26
|
-
trackingId?: string;
|
|
27
|
-
site?: string;
|
|
28
|
-
view: string;
|
|
29
|
-
anonId: string;
|
|
30
|
-
sessionId?: string;
|
|
31
|
-
zones?: string[];
|
|
32
|
-
/** Request-local facts the edge cannot observe (app version, screen class). */
|
|
33
|
-
context?: Record<string, unknown>;
|
|
34
|
-
fetch?: typeof fetch;
|
|
35
|
-
signal?: AbortSignal;
|
|
36
|
-
}
|
|
37
|
-
declare function fetchEdgeSelect(options: FetchEdgeSelectOptions): Promise<SelectVariantsResult>;
|
|
38
|
-
interface SelectVariantsOptions {
|
|
39
|
-
trackingId?: string;
|
|
40
|
-
site?: string;
|
|
41
|
-
view: string;
|
|
42
|
-
anonId: string;
|
|
43
|
-
sessionId?: string;
|
|
44
|
-
zones?: string[];
|
|
45
|
-
context?: Record<string, unknown>;
|
|
46
|
-
target?: AmplifyUpTarget;
|
|
47
|
-
edgeUrl?: string;
|
|
48
|
-
fetch?: typeof fetch;
|
|
49
|
-
signal?: AbortSignal;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Ask Edge to decide deferred rules for a view. Returns variant keys to pass
|
|
53
|
-
* to `/v1/resolve?variants=`.
|
|
54
|
-
*/
|
|
55
|
-
declare function selectVariants(options: SelectVariantsOptions): Promise<SelectVariantsResult>;
|
|
56
|
-
|
|
57
3
|
/**
|
|
58
4
|
* Field envelopes — same shape in published, draft, and Composer edit.
|
|
59
5
|
* `{ value, name, ref? }` where `name` is the path within the owning record
|
|
@@ -155,6 +101,60 @@ declare function envelopeListRows<T extends Record<string, unknown> = Record<str
|
|
|
155
101
|
/** Attach branded `fields` once. Keeps sibling keys (e.g. zoneId). */
|
|
156
102
|
declare function attachFieldEnvelopes(props: Record<string, unknown> | null | undefined, sources?: EnvelopeSources | Record<string, ConnectionLike | null | undefined>): Record<string, unknown>;
|
|
157
103
|
|
|
104
|
+
/**
|
|
105
|
+
* On-request variant selection (tier 3).
|
|
106
|
+
*
|
|
107
|
+
* Decisions happen on AmplifyUp Edge. The client asks after the view has
|
|
108
|
+
* rendered; the Worker returns variant keys only. Profile data never leaves
|
|
109
|
+
* the edge. This helper is the JS wrapper around POST /v1/select — the same
|
|
110
|
+
* wire format is the contract for Flutter / native / .NET clients. No DOM
|
|
111
|
+
* or Next.js assumptions.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
interface SelectVariantsResult {
|
|
115
|
+
siteId: string;
|
|
116
|
+
view: string;
|
|
117
|
+
variantKeys: Record<string, string>;
|
|
118
|
+
meta?: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
declare class SelectVariantsError extends Error {
|
|
121
|
+
status: number;
|
|
122
|
+
body: unknown;
|
|
123
|
+
constructor(message: string, status: number, body?: unknown);
|
|
124
|
+
}
|
|
125
|
+
interface FetchEdgeSelectOptions {
|
|
126
|
+
edgeUrl: string;
|
|
127
|
+
trackingId?: string;
|
|
128
|
+
site?: string;
|
|
129
|
+
view: string;
|
|
130
|
+
anonId: string;
|
|
131
|
+
sessionId?: string;
|
|
132
|
+
zones?: string[];
|
|
133
|
+
/** Request-local facts the edge cannot observe (app version, screen class). */
|
|
134
|
+
context?: Record<string, unknown>;
|
|
135
|
+
fetch?: typeof fetch;
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}
|
|
138
|
+
declare function fetchEdgeSelect(options: FetchEdgeSelectOptions): Promise<SelectVariantsResult>;
|
|
139
|
+
interface SelectVariantsOptions {
|
|
140
|
+
trackingId?: string;
|
|
141
|
+
site?: string;
|
|
142
|
+
view: string;
|
|
143
|
+
anonId: string;
|
|
144
|
+
sessionId?: string;
|
|
145
|
+
zones?: string[];
|
|
146
|
+
context?: Record<string, unknown>;
|
|
147
|
+
target?: AmplifyUpTarget;
|
|
148
|
+
edgeUrl?: string;
|
|
149
|
+
fetch?: typeof fetch;
|
|
150
|
+
signal?: AbortSignal;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Ask Edge to decide deferred rules for a view. Returns variant keys to pass
|
|
154
|
+
* to `/v1/resolve?variants=`.
|
|
155
|
+
*/
|
|
156
|
+
declare function selectVariants(options: SelectVariantsOptions): Promise<SelectVariantsResult>;
|
|
157
|
+
|
|
158
158
|
/**
|
|
159
159
|
* Runtime content queries.
|
|
160
160
|
*
|
|
@@ -259,4 +259,4 @@ declare function nextPageSpec(pagination: QueryPagination): QuerySpec;
|
|
|
259
259
|
*/
|
|
260
260
|
declare function searchSpec(pagination: QueryPagination, field: string, term: string): QuerySpec;
|
|
261
261
|
|
|
262
|
-
export {
|
|
262
|
+
export { isReadOnlyRowField as A, listOwnerFromSpec as B, toFieldEnvelopes as C, type FetchEdgeQueryOptions as F, type ImageValue as I, type LayoutComponentProps as L, type PortableRef as P, QueryContentError as Q, SelectVariantsError as S, type FetchEdgeSelectOptions as a, type QueryContentOptions as b, type QueryFilter as c, type QueryFilterOp as d, type QueryPagination as e, type QueryResult as f, type QuerySort as g, type QuerySpec as h, type SelectVariantsOptions as i, type SelectVariantsResult as j, fetchEdgeQuery as k, fetchEdgeSelect as l, selectVariants as m, nextPageSpec as n, type Field as o, FIELDS_BRAND as p, queryContent as q, type FieldRef as r, searchSpec as s, type Fields as t, type ListRow as u, attachFieldEnvelopes as v, composerStoreKey as w, envelopeListRows as x, isBrandedFields as y, isFieldEnvelope as z };
|
|
@@ -1,59 +1,5 @@
|
|
|
1
1
|
import { A as AmplifyUpTarget } from './types-ffQNIQCK.mjs';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* On-request variant selection (tier 3).
|
|
5
|
-
*
|
|
6
|
-
* Decisions happen on AmplifyUp Edge. The client asks after the view has
|
|
7
|
-
* rendered; the Worker returns variant keys only. Profile data never leaves
|
|
8
|
-
* the edge. This helper is the JS wrapper around POST /v1/select — the same
|
|
9
|
-
* wire format is the contract for Flutter / native / .NET clients. No DOM
|
|
10
|
-
* or Next.js assumptions.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
interface SelectVariantsResult {
|
|
14
|
-
siteId: string;
|
|
15
|
-
view: string;
|
|
16
|
-
variantKeys: Record<string, string>;
|
|
17
|
-
meta?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
declare class SelectVariantsError extends Error {
|
|
20
|
-
status: number;
|
|
21
|
-
body: unknown;
|
|
22
|
-
constructor(message: string, status: number, body?: unknown);
|
|
23
|
-
}
|
|
24
|
-
interface FetchEdgeSelectOptions {
|
|
25
|
-
edgeUrl: string;
|
|
26
|
-
trackingId?: string;
|
|
27
|
-
site?: string;
|
|
28
|
-
view: string;
|
|
29
|
-
anonId: string;
|
|
30
|
-
sessionId?: string;
|
|
31
|
-
zones?: string[];
|
|
32
|
-
/** Request-local facts the edge cannot observe (app version, screen class). */
|
|
33
|
-
context?: Record<string, unknown>;
|
|
34
|
-
fetch?: typeof fetch;
|
|
35
|
-
signal?: AbortSignal;
|
|
36
|
-
}
|
|
37
|
-
declare function fetchEdgeSelect(options: FetchEdgeSelectOptions): Promise<SelectVariantsResult>;
|
|
38
|
-
interface SelectVariantsOptions {
|
|
39
|
-
trackingId?: string;
|
|
40
|
-
site?: string;
|
|
41
|
-
view: string;
|
|
42
|
-
anonId: string;
|
|
43
|
-
sessionId?: string;
|
|
44
|
-
zones?: string[];
|
|
45
|
-
context?: Record<string, unknown>;
|
|
46
|
-
target?: AmplifyUpTarget;
|
|
47
|
-
edgeUrl?: string;
|
|
48
|
-
fetch?: typeof fetch;
|
|
49
|
-
signal?: AbortSignal;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Ask Edge to decide deferred rules for a view. Returns variant keys to pass
|
|
53
|
-
* to `/v1/resolve?variants=`.
|
|
54
|
-
*/
|
|
55
|
-
declare function selectVariants(options: SelectVariantsOptions): Promise<SelectVariantsResult>;
|
|
56
|
-
|
|
57
3
|
/**
|
|
58
4
|
* Field envelopes — same shape in published, draft, and Composer edit.
|
|
59
5
|
* `{ value, name, ref? }` where `name` is the path within the owning record
|
|
@@ -155,6 +101,60 @@ declare function envelopeListRows<T extends Record<string, unknown> = Record<str
|
|
|
155
101
|
/** Attach branded `fields` once. Keeps sibling keys (e.g. zoneId). */
|
|
156
102
|
declare function attachFieldEnvelopes(props: Record<string, unknown> | null | undefined, sources?: EnvelopeSources | Record<string, ConnectionLike | null | undefined>): Record<string, unknown>;
|
|
157
103
|
|
|
104
|
+
/**
|
|
105
|
+
* On-request variant selection (tier 3).
|
|
106
|
+
*
|
|
107
|
+
* Decisions happen on AmplifyUp Edge. The client asks after the view has
|
|
108
|
+
* rendered; the Worker returns variant keys only. Profile data never leaves
|
|
109
|
+
* the edge. This helper is the JS wrapper around POST /v1/select — the same
|
|
110
|
+
* wire format is the contract for Flutter / native / .NET clients. No DOM
|
|
111
|
+
* or Next.js assumptions.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
interface SelectVariantsResult {
|
|
115
|
+
siteId: string;
|
|
116
|
+
view: string;
|
|
117
|
+
variantKeys: Record<string, string>;
|
|
118
|
+
meta?: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
declare class SelectVariantsError extends Error {
|
|
121
|
+
status: number;
|
|
122
|
+
body: unknown;
|
|
123
|
+
constructor(message: string, status: number, body?: unknown);
|
|
124
|
+
}
|
|
125
|
+
interface FetchEdgeSelectOptions {
|
|
126
|
+
edgeUrl: string;
|
|
127
|
+
trackingId?: string;
|
|
128
|
+
site?: string;
|
|
129
|
+
view: string;
|
|
130
|
+
anonId: string;
|
|
131
|
+
sessionId?: string;
|
|
132
|
+
zones?: string[];
|
|
133
|
+
/** Request-local facts the edge cannot observe (app version, screen class). */
|
|
134
|
+
context?: Record<string, unknown>;
|
|
135
|
+
fetch?: typeof fetch;
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}
|
|
138
|
+
declare function fetchEdgeSelect(options: FetchEdgeSelectOptions): Promise<SelectVariantsResult>;
|
|
139
|
+
interface SelectVariantsOptions {
|
|
140
|
+
trackingId?: string;
|
|
141
|
+
site?: string;
|
|
142
|
+
view: string;
|
|
143
|
+
anonId: string;
|
|
144
|
+
sessionId?: string;
|
|
145
|
+
zones?: string[];
|
|
146
|
+
context?: Record<string, unknown>;
|
|
147
|
+
target?: AmplifyUpTarget;
|
|
148
|
+
edgeUrl?: string;
|
|
149
|
+
fetch?: typeof fetch;
|
|
150
|
+
signal?: AbortSignal;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Ask Edge to decide deferred rules for a view. Returns variant keys to pass
|
|
154
|
+
* to `/v1/resolve?variants=`.
|
|
155
|
+
*/
|
|
156
|
+
declare function selectVariants(options: SelectVariantsOptions): Promise<SelectVariantsResult>;
|
|
157
|
+
|
|
158
158
|
/**
|
|
159
159
|
* Runtime content queries.
|
|
160
160
|
*
|
|
@@ -259,4 +259,4 @@ declare function nextPageSpec(pagination: QueryPagination): QuerySpec;
|
|
|
259
259
|
*/
|
|
260
260
|
declare function searchSpec(pagination: QueryPagination, field: string, term: string): QuerySpec;
|
|
261
261
|
|
|
262
|
-
export {
|
|
262
|
+
export { isReadOnlyRowField as A, listOwnerFromSpec as B, toFieldEnvelopes as C, type FetchEdgeQueryOptions as F, type ImageValue as I, type LayoutComponentProps as L, type PortableRef as P, QueryContentError as Q, SelectVariantsError as S, type FetchEdgeSelectOptions as a, type QueryContentOptions as b, type QueryFilter as c, type QueryFilterOp as d, type QueryPagination as e, type QueryResult as f, type QuerySort as g, type QuerySpec as h, type SelectVariantsOptions as i, type SelectVariantsResult as j, fetchEdgeQuery as k, fetchEdgeSelect as l, selectVariants as m, nextPageSpec as n, type Field as o, FIELDS_BRAND as p, queryContent as q, type FieldRef as r, searchSpec as s, type Fields as t, type ListRow as u, attachFieldEnvelopes as v, composerStoreKey as w, envelopeListRows as x, isBrandedFields as y, isFieldEnvelope as z };
|
package/dist/react.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import { P as PageConfig, f as AmplifyUpConfig, h as AmplifyPageContextInput, C as ContentSource, a as AmplifyContentMeta } from './types-ffQNIQCK.mjs';
|
|
3
2
|
export { Z as ZoneConfig } from './types-ffQNIQCK.mjs';
|
|
4
|
-
import
|
|
5
|
-
import { C as ComponentRegistry } from './AmplifyRenderer-
|
|
6
|
-
export { A as AmplifyRenderer, d as defineComponentRegistry } from './AmplifyRenderer-
|
|
7
|
-
import { o as Field$1, p as FIELDS_BRAND } from './query-
|
|
8
|
-
export {
|
|
3
|
+
import React__default, { ReactNode, FC } from 'react';
|
|
4
|
+
import { C as ComponentRegistry } from './AmplifyRenderer-eGtn5k9_.mjs';
|
|
5
|
+
export { A as AmplifyRenderer, d as defineComponentRegistry } from './AmplifyRenderer-eGtn5k9_.mjs';
|
|
6
|
+
import { o as Field$1, p as FIELDS_BRAND } from './query-CYRvyIv0.mjs';
|
|
7
|
+
export { r as FieldRef, t as Fields, I as ImageValue, L as LayoutComponentProps, u as ListRow, P as PortableRef, Q as QueryContentError, b as QueryContentOptions, c as QueryFilter, d as QueryFilterOp, e as QueryPagination, f as QueryResult, g as QuerySort, h as QuerySpec, S as SelectVariantsError, i as SelectVariantsOptions, j as SelectVariantsResult, v as attachFieldEnvelopes, w as composerStoreKey, x as envelopeListRows, y as isBrandedFields, z as isFieldEnvelope, A as isReadOnlyRowField, B as listOwnerFromSpec, n as nextPageSpec, q as queryContent, s as searchSpec, m as selectVariants, C as toFieldEnvelopes } from './query-CYRvyIv0.mjs';
|
|
9
8
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
10
9
|
|
|
11
10
|
interface AmplifyPageContentProps {
|
|
@@ -38,7 +37,7 @@ interface AmplifyPageContentProps {
|
|
|
38
37
|
* Live pages paint the SSG/ISR layout first. Client Edge resolve (visitor id)
|
|
39
38
|
* overlays only when the personalized tree differs from that static HTML.
|
|
40
39
|
*/
|
|
41
|
-
declare function AmplifyPageContent(contentProps: AmplifyPageContentProps):
|
|
40
|
+
declare function AmplifyPageContent(contentProps: AmplifyPageContentProps): React__default.JSX.Element | null;
|
|
42
41
|
|
|
43
42
|
type AmplifyPageProps = Omit<AmplifyPageContentProps, 'registry'>;
|
|
44
43
|
/**
|
|
@@ -62,6 +61,13 @@ declare function useInComposer(force?: boolean): boolean;
|
|
|
62
61
|
/** @deprecated Prefer `useInComposer`. Kept for internal AmplifyPageContent. */
|
|
63
62
|
declare function useComposerPreviewFlag(force?: boolean): boolean;
|
|
64
63
|
|
|
64
|
+
/**
|
|
65
|
+
* SDK Components for Slot and Field rendering
|
|
66
|
+
*
|
|
67
|
+
* These components allow developers to explicitly define where slots and fields
|
|
68
|
+
* are rendered in their components, with full control over styling and structure.
|
|
69
|
+
*/
|
|
70
|
+
|
|
65
71
|
/**
|
|
66
72
|
* Slot Component
|
|
67
73
|
*
|
|
@@ -91,7 +97,7 @@ declare function useComposerPreviewFlag(force?: boolean): boolean;
|
|
|
91
97
|
declare function Slot({ name, className }: {
|
|
92
98
|
name: string;
|
|
93
99
|
className?: string;
|
|
94
|
-
}):
|
|
100
|
+
}): React__default.JSX.Element | null;
|
|
95
101
|
type RejectFieldInput<T> = [T] extends [readonly unknown[]] ? never : T extends {
|
|
96
102
|
readonly [FIELDS_BRAND]: true;
|
|
97
103
|
} ? never : T;
|
|
@@ -126,7 +132,7 @@ declare function Field<T = unknown>(props: {
|
|
|
126
132
|
/** Required with `value` for computed values. */
|
|
127
133
|
name?: string;
|
|
128
134
|
className?: string;
|
|
129
|
-
}):
|
|
135
|
+
}): React__default.JSX.Element | null;
|
|
130
136
|
/**
|
|
131
137
|
* RichText - Renders a markdown (or HTML string) value as formatted HTML.
|
|
132
138
|
*
|
|
@@ -155,7 +161,7 @@ declare function RichText<T = string | null>(props: {
|
|
|
155
161
|
as?: keyof JSX.IntrinsicElements;
|
|
156
162
|
/** String children are treated as the markdown value (same as `value`). */
|
|
157
163
|
children?: ReactNode;
|
|
158
|
-
}):
|
|
164
|
+
}): React__default.JSX.Element | null;
|
|
159
165
|
/**
|
|
160
166
|
* Image — renders a provider-backed image value as `<img>`.
|
|
161
167
|
*
|
|
@@ -178,13 +184,13 @@ declare function Image<T = unknown>(props: {
|
|
|
178
184
|
/** Required with `value` for computed values. */
|
|
179
185
|
name?: string;
|
|
180
186
|
alt?: string;
|
|
181
|
-
} & Omit<
|
|
187
|
+
} & Omit<React__default.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): React__default.JSX.Element | null;
|
|
182
188
|
|
|
183
189
|
/** Tells Slot whether the layout/provider fetch has settled. */
|
|
184
190
|
declare function ComposerLayoutStatusProvider({ ready, children, }: {
|
|
185
191
|
ready: boolean;
|
|
186
192
|
children: ReactNode;
|
|
187
|
-
}):
|
|
193
|
+
}): React__default.JSX.Element;
|
|
188
194
|
|
|
189
195
|
/** Composer slot lifecycle. Loading ≠ empty. */
|
|
190
196
|
type SlotState = 'loading' | 'empty' | 'filled';
|
|
@@ -202,12 +208,12 @@ declare function ComposerProvider({ children, enabled, }: {
|
|
|
202
208
|
children: ReactNode;
|
|
203
209
|
/** When false, pass through any parent store without creating or wiring one. */
|
|
204
210
|
enabled?: boolean;
|
|
205
|
-
}):
|
|
211
|
+
}): React__default.JSX.Element;
|
|
206
212
|
declare function MaybeComposerProvider({ enabled, layoutNodeId, children, }: {
|
|
207
213
|
enabled: boolean;
|
|
208
214
|
layoutNodeId?: string;
|
|
209
215
|
children: ReactNode;
|
|
210
|
-
}):
|
|
216
|
+
}): React__default.JSX.Element;
|
|
211
217
|
|
|
212
218
|
interface AmplifyUpContextType {
|
|
213
219
|
pageConfig: PageConfig | null;
|
|
@@ -225,7 +231,7 @@ interface AmplifyUpProviderProps {
|
|
|
225
231
|
*/
|
|
226
232
|
pageContext?: AmplifyPageContextInput;
|
|
227
233
|
}
|
|
228
|
-
declare function AmplifyUpProvider({ children, config, pageContext, }: AmplifyUpProviderProps):
|
|
234
|
+
declare function AmplifyUpProvider({ children, config, pageContext, }: AmplifyUpProviderProps): React__default.JSX.Element;
|
|
229
235
|
declare function useAmplifyUp(): AmplifyUpContextType;
|
|
230
236
|
|
|
231
237
|
export { AmplifyContentMeta, AmplifyPageContent, type AmplifyPageContentProps, type AmplifyPageProps, AmplifyUpProvider, ComponentRegistry, ComposerLayoutStatusProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Image, MaybeComposerProvider, PageConfig, RichText, Slot, type SlotState, bindAmplifyPage, resolveSlotState, slotShowsAddComponent, slotStateFromEl, useAmplifyUp, useComposerPreviewFlag, useInComposer };
|