@demiurgejs/core 0.2.0-beta.3 → 0.2.0-beta.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/README.md +36 -11
- package/bin/demiurge.mjs +47 -13
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/browser/file-router.d.ts +388 -5
- package/dist/browser/file-router.d.ts.map +1 -1
- package/dist/browser/focus.d.ts +20 -0
- package/dist/browser/focus.d.ts.map +1 -0
- package/dist/browser/index.d.ts +7 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/mutation-action.d.ts +81 -0
- package/dist/browser/mutation-action.d.ts.map +1 -0
- package/dist/chunks/document-shell-9GPwtcTt.js +36 -0
- package/dist/chunks/document-shell-9GPwtcTt.js.map +1 -0
- package/dist/chunks/{image-codec-Di53WpcH.js → image-codec-Dh1POFhE.js} +2 -2
- package/dist/chunks/{image-codec-Di53WpcH.js.map → image-codec-Dh1POFhE.js.map} +1 -1
- package/dist/chunks/{images-Edar3eU1.js → images-CG7ZzayG.js} +99 -91
- package/dist/chunks/images-CG7ZzayG.js.map +1 -0
- package/dist/chunks/index-0MNiR_wo.js +833 -0
- package/dist/chunks/index-0MNiR_wo.js.map +1 -0
- package/dist/chunks/manifest-vO6c0G0W.js +19 -0
- package/dist/chunks/manifest-vO6c0G0W.js.map +1 -0
- package/dist/chunks/plugin-BZauDxRY.js +2310 -0
- package/dist/chunks/plugin-BZauDxRY.js.map +1 -0
- package/dist/chunks/session-store-ChModVcq.js +92 -0
- package/dist/chunks/session-store-ChModVcq.js.map +1 -0
- package/dist/chunks/static-files-ehaD1kE7.js +51 -0
- package/dist/chunks/static-files-ehaD1kE7.js.map +1 -0
- package/dist/chunks/streaming-GYIsVTQH.js +560 -0
- package/dist/chunks/streaming-GYIsVTQH.js.map +1 -0
- package/dist/chunks/testing-CUwGj2ie.js +4751 -0
- package/dist/chunks/testing-CUwGj2ie.js.map +1 -0
- package/dist/chunks/vite-QoqrGl6f.js +259 -0
- package/dist/chunks/vite-QoqrGl6f.js.map +1 -0
- package/dist/cli.d.ts +19 -25
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +289 -128
- package/dist/cli.js.map +1 -1
- package/dist/config/define.d.ts +3 -0
- package/dist/config/define.d.ts.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +78 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.d.ts +12 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/types.d.ts +74 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validate.d.ts +9 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/vite.d.ts +12 -0
- package/dist/config/vite.d.ts.map +1 -0
- package/dist/data/cache.d.ts +2 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/idempotency.d.ts.map +1 -1
- package/dist/deployment/testing.d.ts +25 -0
- package/dist/deployment/testing.d.ts.map +1 -0
- package/dist/deployment/testing.js +171 -0
- package/dist/deployment/testing.js.map +1 -0
- package/dist/document/hydration.d.ts +9 -0
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +4 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/metadata.d.ts +8 -0
- package/dist/document/metadata.d.ts.map +1 -1
- package/dist/document/navigation.d.ts +28 -0
- package/dist/document/navigation.d.ts.map +1 -0
- package/dist/document/render.d.ts +3 -1
- package/dist/document/render.d.ts.map +1 -1
- package/dist/document/seo.d.ts.map +1 -1
- package/dist/edge/assets.d.ts.map +1 -1
- package/dist/edge/index.js +55 -73
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1883 -692
- package/dist/index.js.map +1 -1
- package/dist/inspect/command.d.ts +28 -0
- package/dist/inspect/command.d.ts.map +1 -0
- package/dist/inspect/index.d.ts +9 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/redact.d.ts +35 -0
- package/dist/inspect/redact.d.ts.map +1 -0
- package/dist/inspect/report.d.ts +24 -0
- package/dist/inspect/report.d.ts.map +1 -0
- package/dist/inspect/types.d.ts +102 -0
- package/dist/inspect/types.d.ts.map +1 -0
- package/dist/internal/testing.js +5 -5
- package/dist/kv/index.d.ts +2 -0
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +170 -73
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/session-store.d.ts +20 -0
- package/dist/kv/session-store.d.ts.map +1 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/node/http.d.ts +5 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/image.d.ts.map +1 -1
- package/dist/node/index.d.ts +4 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +257 -182
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +47 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/static.d.ts.map +1 -1
- package/dist/platform/fonts.d.ts.map +1 -1
- package/dist/platform/image-url.d.ts.map +1 -1
- package/dist/platform/url.d.ts +19 -0
- package/dist/platform/url.d.ts.map +1 -0
- package/dist/platform/web-vitals.d.ts.map +1 -1
- package/dist/redis/index.d.ts +2 -0
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +186 -69
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/session-store.d.ts +9 -0
- package/dist/redis/session-store.d.ts.map +1 -0
- package/dist/route/index.d.ts +3 -2
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/mutation.d.ts +97 -0
- package/dist/route/mutation.d.ts.map +1 -0
- package/dist/route/serialization.d.ts +24 -0
- package/dist/route/serialization.d.ts.map +1 -0
- package/dist/route/types.d.ts +6 -1
- package/dist/route/types.d.ts.map +1 -1
- package/dist/route/webhook.d.ts +6 -1
- package/dist/route/webhook.d.ts.map +1 -1
- package/dist/router/manifest.d.ts +8 -0
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/router/navigation-data.d.ts +9 -1
- package/dist/router/navigation-data.d.ts.map +1 -1
- package/dist/routing/generate.d.ts +3 -0
- package/dist/routing/generate.d.ts.map +1 -1
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/locale.d.ts +43 -0
- package/dist/routing/locale.d.ts.map +1 -0
- package/dist/routing/types.d.ts +12 -0
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/security/audit.d.ts +2 -1
- package/dist/security/audit.d.ts.map +1 -1
- package/dist/security/authorization.d.ts +36 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/cookie-session.d.ts +43 -0
- package/dist/security/cookie-session.d.ts.map +1 -0
- package/dist/security/csrf.d.ts +1 -1
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +13 -0
- package/dist/security/env-startup.d.ts.map +1 -0
- package/dist/security/env.d.ts +49 -11
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/exceptions.d.ts +29 -0
- package/dist/security/exceptions.d.ts.map +1 -0
- package/dist/security/finding-codes.d.ts +56 -0
- package/dist/security/finding-codes.d.ts.map +1 -0
- package/dist/security/index.d.ts +14 -3
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/policy.d.ts +2 -5
- package/dist/security/policy.d.ts.map +1 -1
- package/dist/security/report.d.ts +2 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/request.d.ts +1 -0
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/session-manager.d.ts +32 -0
- package/dist/security/session-manager.d.ts.map +1 -0
- package/dist/security/session-store.d.ts +51 -0
- package/dist/security/session-store.d.ts.map +1 -0
- package/dist/security/testing.d.ts +10 -0
- package/dist/security/testing.d.ts.map +1 -0
- package/dist/security/testing.js +145 -0
- package/dist/security/testing.js.map +1 -0
- package/dist/security/types.d.ts +139 -5
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/upload.d.ts +3 -3
- package/dist/security/upload.d.ts.map +1 -1
- package/dist/security/verification.d.ts.map +1 -1
- package/dist/server/document-shell.d.ts.map +1 -1
- package/dist/server/errors.d.ts +1 -0
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/not-found.d.ts +1 -0
- package/dist/server/not-found.d.ts.map +1 -1
- package/dist/server/render-tree.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +7 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server/request-metadata.d.ts +1 -0
- package/dist/server/request-metadata.d.ts.map +1 -1
- package/dist/server/ssr.d.ts +2 -0
- package/dist/server/ssr.d.ts.map +1 -1
- package/dist/server-only/browser.d.ts +2 -0
- package/dist/server-only/browser.d.ts.map +1 -0
- package/dist/server-only/browser.js +4 -0
- package/dist/server-only/browser.js.map +1 -0
- package/dist/server-only/index.d.ts +2 -0
- package/dist/server-only/index.d.ts.map +1 -0
- package/dist/server-only/index.js +2 -0
- package/dist/server-only/index.js.map +1 -0
- package/dist/static/index.d.ts +2 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +380 -363
- package/dist/static/index.js.map +1 -1
- package/dist/static/preview.d.ts.map +1 -1
- package/dist/static/vercel.d.ts +11 -2
- package/dist/static/vercel.d.ts.map +1 -1
- package/dist/static-files.d.ts +12 -0
- package/dist/static-files.d.ts.map +1 -1
- package/dist/type-guards.d.ts +19 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/vite/env-boundary.d.ts +14 -0
- package/dist/vite/env-boundary.d.ts.map +1 -0
- package/dist/vite/index.d.ts +13 -6
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +29 -1560
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +24 -3
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts +33 -2
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/dist/vite/route-audit.d.ts +14 -2
- package/dist/vite/route-audit.d.ts.map +1 -1
- package/dist/vite/server-only-boundary.d.ts +8 -0
- package/dist/vite/server-only-boundary.d.ts.map +1 -0
- package/package.json +24 -6
- package/dist/chunks/document-shell-WoM8yZlR.js +0 -35
- package/dist/chunks/document-shell-WoM8yZlR.js.map +0 -1
- package/dist/chunks/images-Edar3eU1.js.map +0 -1
- package/dist/chunks/request-metadata-DaIYq4Ea.js +0 -677
- package/dist/chunks/request-metadata-DaIYq4Ea.js.map +0 -1
- package/dist/chunks/static-files-DUjHw-4H.js +0 -11
- package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
- package/dist/chunks/streaming-D0fGAuiO.js +0 -469
- package/dist/chunks/streaming-D0fGAuiO.js.map +0 -1
- package/dist/chunks/testing-CRflAw4X.js +0 -3475
- package/dist/chunks/testing-CRflAw4X.js.map +0 -1
- package/dist/route/action.d.ts +0 -33
- package/dist/route/action.d.ts.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { existsSync as f } from "node:fs";
|
|
2
|
+
import { join as u, resolve as a, dirname as s } from "node:path";
|
|
3
|
+
import { D as r, v as d } from "../chunks/vite-QoqrGl6f.js";
|
|
4
|
+
import { c as F, t as M } from "../chunks/vite-QoqrGl6f.js";
|
|
5
|
+
function x(e) {
|
|
6
|
+
return e;
|
|
7
|
+
}
|
|
8
|
+
const g = "demiurge.config.ts";
|
|
9
|
+
function l(e = process.cwd()) {
|
|
10
|
+
let n = a(e);
|
|
11
|
+
for (; ; ) {
|
|
12
|
+
if (f(u(n, "package.json"))) return n;
|
|
13
|
+
const o = s(n);
|
|
14
|
+
if (o === n) return a(e);
|
|
15
|
+
n = o;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function m(e) {
|
|
19
|
+
return u(e, g);
|
|
20
|
+
}
|
|
21
|
+
async function y(e = {}) {
|
|
22
|
+
const n = e.root ?? l(), o = m(n);
|
|
23
|
+
if (!f(o))
|
|
24
|
+
throw new r(p(o));
|
|
25
|
+
const c = e.loadModule ?? C;
|
|
26
|
+
let t;
|
|
27
|
+
try {
|
|
28
|
+
t = await c(o);
|
|
29
|
+
} catch (i) {
|
|
30
|
+
throw new r(
|
|
31
|
+
[
|
|
32
|
+
`Demiurge failed to load ${o}.`,
|
|
33
|
+
` cause: ${i instanceof Error ? i.message : String(i)}`
|
|
34
|
+
].join(`
|
|
35
|
+
`),
|
|
36
|
+
{ cause: i }
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (t == null)
|
|
40
|
+
throw new r(
|
|
41
|
+
[
|
|
42
|
+
`Demiurge did not find a default export in ${o}.`,
|
|
43
|
+
" The file must export a Demiurge configuration as its default export.",
|
|
44
|
+
" Example: export default defineConfig({ routing: { typedRoutes: true } });"
|
|
45
|
+
].join(`
|
|
46
|
+
`)
|
|
47
|
+
);
|
|
48
|
+
return { ...d(t, o), configFile: o, root: n };
|
|
49
|
+
}
|
|
50
|
+
function p(e) {
|
|
51
|
+
return [
|
|
52
|
+
`Demiurge did not find the configuration file ${e}.`,
|
|
53
|
+
" Every Demiurge command needs this file. There is no default configuration.",
|
|
54
|
+
' Create an application with "npm create demiurge" to generate it.'
|
|
55
|
+
].join(`
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
async function C(e) {
|
|
59
|
+
const { loadConfigFromFile: n } = await import("vite");
|
|
60
|
+
return (await n(
|
|
61
|
+
{ command: "serve", mode: "development" },
|
|
62
|
+
e,
|
|
63
|
+
s(e)
|
|
64
|
+
))?.config;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
g as CONFIG_FILE_NAME,
|
|
68
|
+
r as DemiurgeConfigError,
|
|
69
|
+
x as defineConfig,
|
|
70
|
+
y as loadDemiurgeConfig,
|
|
71
|
+
p as missingConfigMessage,
|
|
72
|
+
m as resolveConfigFile,
|
|
73
|
+
l as resolveProjectRoot,
|
|
74
|
+
F as unstable_createDemiurgeViteConfig,
|
|
75
|
+
M as unstable_toPluginOptions,
|
|
76
|
+
d as validateDemiurgeConfig
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/config/define.ts","../../src/config/load.ts"],"sourcesContent":["import type { DemiurgeConfig } from \"./types\";\n\n// This builder gives editor completion and type checking to the application\n// configuration file. It returns the value without a change.\nexport function defineConfig<Locale extends string = string>(\n config: DemiurgeConfig<Locale>,\n): DemiurgeConfig<Locale> {\n return config;\n}\n","import { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { DemiurgeConfig, ResolvedDemiurgeConfig } from \"./types\";\nimport { DemiurgeConfigError, validateDemiurgeConfig } from \"./validate\";\n\n// The framework accepts one configuration file name at one location. It does\n// not search parent directories and it does not accept another extension.\nexport const CONFIG_FILE_NAME = \"demiurge.config.ts\";\n\nexport type ConfigModuleLoader = (file: string) => Promise<unknown>;\n\nexport type LoadDemiurgeConfigOptions = {\n loadModule?: ConfigModuleLoader;\n root?: string;\n};\n\n// The project root is the directory that holds the package manifest of the\n// application. The framework resolves it from the working directory.\nexport function resolveProjectRoot(from: string = process.cwd()) {\n let directory = resolve(from);\n\n for (;;) {\n if (existsSync(join(directory, \"package.json\"))) return directory;\n const parent = dirname(directory);\n if (parent === directory) return resolve(from);\n directory = parent;\n }\n}\n\nexport function resolveConfigFile(root: string) {\n return join(root, CONFIG_FILE_NAME);\n}\n\nexport async function loadDemiurgeConfig(\n options: LoadDemiurgeConfigOptions = {},\n): Promise<ResolvedDemiurgeConfig> {\n const root = options.root ?? resolveProjectRoot();\n const configFile = resolveConfigFile(root);\n\n if (!existsSync(configFile)) {\n throw new DemiurgeConfigError(missingConfigMessage(configFile));\n }\n\n const loadModule = options.loadModule ?? loadConfigModule;\n let exported: unknown;\n\n try {\n exported = await loadModule(configFile);\n } catch (error) {\n throw new DemiurgeConfigError(\n [\n `Demiurge failed to load ${configFile}.`,\n ` cause: ${error instanceof Error ? error.message : String(error)}`,\n ].join(\"\\n\"),\n { cause: error },\n );\n }\n\n if (exported === undefined || exported === null) {\n throw new DemiurgeConfigError(\n [\n `Demiurge did not find a default export in ${configFile}.`,\n \" The file must export a Demiurge configuration as its default export.\",\n ' Example: export default defineConfig({ routing: { typedRoutes: true } });',\n ].join(\"\\n\"),\n );\n }\n\n const config: DemiurgeConfig = validateDemiurgeConfig(exported, configFile);\n return { ...config, configFile, root };\n}\n\nexport function missingConfigMessage(configFile: string) {\n return [\n `Demiurge did not find the configuration file ${configFile}.`,\n \" Every Demiurge command needs this file. There is no default configuration.\",\n ' Create an application with \"npm create demiurge\" to generate it.',\n ].join(\"\\n\");\n}\n\nasync function loadConfigModule(configFile: string) {\n const { loadConfigFromFile } = await import(\"vite\");\n const loaded = await loadConfigFromFile(\n { command: \"serve\", mode: \"development\" },\n configFile,\n dirname(configFile),\n );\n return loaded?.config;\n}\n"],"names":["defineConfig","config","CONFIG_FILE_NAME","resolveProjectRoot","from","directory","resolve","existsSync","join","parent","dirname","resolveConfigFile","root","loadDemiurgeConfig","options","configFile","DemiurgeConfigError","missingConfigMessage","loadModule","loadConfigModule","exported","error","validateDemiurgeConfig","loadConfigFromFile"],"mappings":";;;;AAIO,SAASA,EACdC,GACwB;AACxB,SAAOA;AACT;ACDO,MAAMC,IAAmB;AAWzB,SAASC,EAAmBC,IAAe,QAAQ,OAAO;AAC/D,MAAIC,IAAYC,EAAQF,CAAI;AAE5B,aAAS;AACP,QAAIG,EAAWC,EAAKH,GAAW,cAAc,CAAC,EAAG,QAAOA;AACxD,UAAMI,IAASC,EAAQL,CAAS;AAChC,QAAII,MAAWJ,EAAW,QAAOC,EAAQF,CAAI;AAC7C,IAAAC,IAAYI;AAAA,EACd;AACF;AAEO,SAASE,EAAkBC,GAAc;AAC9C,SAAOJ,EAAKI,GAAMV,CAA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|
|
3
|
+
export type ConfigModuleLoader = (file: string) => Promise<unknown>;
|
|
4
|
+
export type LoadDemiurgeConfigOptions = {
|
|
5
|
+
loadModule?: ConfigModuleLoader;
|
|
6
|
+
root?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveProjectRoot(from?: string): string;
|
|
9
|
+
export declare function resolveConfigFile(root: string): string;
|
|
10
|
+
export declare function loadDemiurgeConfig(options?: LoadDemiurgeConfigOptions): Promise<ResolvedDemiurgeConfig>;
|
|
11
|
+
export declare function missingConfigMessage(configFile: string): string;
|
|
12
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAKtE,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAIF,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,MAAsB,UAS9D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,UAE7C;AAED,wBAAsB,kBAAkB,CACtC,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC,CAmCjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,UAMtD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { PluginOption, UserConfig as ViteUserConfig } from "vite";
|
|
2
|
+
import type { FontContribution } from "../platform/fonts";
|
|
3
|
+
import type { ImagePolicy } from "../platform/images";
|
|
4
|
+
import type { LocaleConfiguration } from "../routing";
|
|
5
|
+
import type { EnvSchema } from "../security/env";
|
|
6
|
+
import type { StaticFileHeaderPatternRule, VercelStaticDeployment } from "../static";
|
|
7
|
+
export type DemiurgeRoutingConfig<Locale extends string = string> = {
|
|
8
|
+
locales?: LocaleConfiguration<Locale>;
|
|
9
|
+
routesDir?: string;
|
|
10
|
+
typedRoutes?: boolean | {
|
|
11
|
+
outputFile?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type DemiurgeRenderingConfig = {
|
|
15
|
+
document?: {
|
|
16
|
+
lang?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
};
|
|
19
|
+
styles?: false | string;
|
|
20
|
+
};
|
|
21
|
+
export type DemiurgeSecurityConfig = {
|
|
22
|
+
staticFileHeaders?: readonly StaticFileHeaderPatternRule[];
|
|
23
|
+
};
|
|
24
|
+
export type DemiurgeAssetsConfig = {
|
|
25
|
+
fonts?: FontContribution;
|
|
26
|
+
images?: ImagePolicy;
|
|
27
|
+
};
|
|
28
|
+
export type DemiurgeServerDeploymentConfig = {
|
|
29
|
+
entry: string;
|
|
30
|
+
outDir?: string;
|
|
31
|
+
};
|
|
32
|
+
export type DemiurgeStaticDeploymentConfig = {
|
|
33
|
+
origin?: string;
|
|
34
|
+
provider?: VercelStaticDeployment;
|
|
35
|
+
};
|
|
36
|
+
export type DemiurgeDeploymentConfig = {
|
|
37
|
+
outDir?: string;
|
|
38
|
+
server?: DemiurgeServerDeploymentConfig;
|
|
39
|
+
static?: DemiurgeStaticDeploymentConfig;
|
|
40
|
+
};
|
|
41
|
+
export type DemiurgeViteExtension = {
|
|
42
|
+
define?: Record<string, unknown>;
|
|
43
|
+
optimizeDeps?: ViteUserConfig["optimizeDeps"];
|
|
44
|
+
plugins?: PluginOption[];
|
|
45
|
+
resolve?: {
|
|
46
|
+
alias?: NonNullable<ViteUserConfig["resolve"]>["alias"];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type DemiurgeConfig<Locale extends string = string> = {
|
|
50
|
+
assets?: DemiurgeAssetsConfig;
|
|
51
|
+
deployment?: DemiurgeDeploymentConfig;
|
|
52
|
+
devtools?: boolean;
|
|
53
|
+
env?: EnvSchema;
|
|
54
|
+
rendering?: DemiurgeRenderingConfig;
|
|
55
|
+
routing?: DemiurgeRoutingConfig<Locale>;
|
|
56
|
+
security?: DemiurgeSecurityConfig;
|
|
57
|
+
vite?: DemiurgeViteExtension;
|
|
58
|
+
/**
|
|
59
|
+
* This callback is unsafe and unstable.
|
|
60
|
+
*
|
|
61
|
+
* It has no compatibility guarantee between Demiurge versions. It receives
|
|
62
|
+
* the resolved Vite configuration of the framework, after the framework
|
|
63
|
+
* adds its own build-time security plugins. Those plugins enforce the
|
|
64
|
+
* server-only module boundary and the client environment boundary. An
|
|
65
|
+
* application that removes or reorders a framework plugin in this callback
|
|
66
|
+
* loses that boundary. The application then owns the removed boundary.
|
|
67
|
+
*/
|
|
68
|
+
unsafe_unstable_viteConfig?: (config: ViteUserConfig) => ViteUserConfig | Promise<ViteUserConfig>;
|
|
69
|
+
};
|
|
70
|
+
export type ResolvedDemiurgeConfig = DemiurgeConfig & {
|
|
71
|
+
configFile: string;
|
|
72
|
+
root: string;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,2BAA2B,EAC3B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cAAc,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;KACzD,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;IAC3D,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,UAAU,CAAC,EAAE,wBAAwB,CAAC;IAGtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,OAAO,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B;;;;;;;;;OASG;IACH,0BAA0B,CAAC,EAAE,CAC3B,MAAM,EAAE,cAAc,KACnB,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DemiurgeConfig } from "./types";
|
|
2
|
+
export declare class DemiurgeConfigError extends Error {
|
|
3
|
+
constructor(message: string, options?: {
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export declare function validateDemiurgeConfig(value: unknown, configFile: string): DemiurgeConfig;
|
|
8
|
+
export declare function describeValue(value: unknown): string;
|
|
9
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/config/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AA2BD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,GACjB,cAAc,CAoIhB;AA4HD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,UAW3C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InlineConfig, PluginOption } from "vite";
|
|
2
|
+
import { type DemiurgeVitePluginOptions } from "../vite/plugin";
|
|
3
|
+
import type { DemiurgeConfig, ResolvedDemiurgeConfig } from "./types";
|
|
4
|
+
export type ReactPluginLoader = () => Promise<(...args: never[]) => PluginOption>;
|
|
5
|
+
export type CreateDemiurgeViteConfigOptions = {
|
|
6
|
+
config: ResolvedDemiurgeConfig;
|
|
7
|
+
loadReactPlugin?: ReactPluginLoader;
|
|
8
|
+
overrides?: InlineConfig;
|
|
9
|
+
};
|
|
10
|
+
export declare function createDemiurgeViteConfig(options: CreateDemiurgeViteConfigOptions): Promise<InlineConfig>;
|
|
11
|
+
export declare function toPluginOptions(config: DemiurgeConfig): DemiurgeVitePluginOptions;
|
|
12
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/config/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAc,MAAM,MAAM,CAAC;AACnE,OAAO,EAAY,KAAK,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtE,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,YAAY,CAAC,CAAC;AAElF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,sBAAsB,CAAC;IAC/B,eAAe,CAAC,EAAE,iBAAiB,CAAC;IACpC,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B,CAAC;AAIF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,YAAY,CAAC,CAwCvB;AAID,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,GACrB,yBAAyB,CAgC3B"}
|
package/dist/data/cache.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ type MaybePromise<T> = T | Promise<T>;
|
|
|
11
11
|
export type CacheRequest<TResult> = {
|
|
12
12
|
fn: () => MaybePromise<TResult>;
|
|
13
13
|
key: CacheKey;
|
|
14
|
+
locale?: "neutral";
|
|
14
15
|
notFoundTtl?: CacheDuration;
|
|
15
16
|
scope?: CacheScope;
|
|
16
17
|
staleWhileRevalidate?: CacheDuration;
|
|
@@ -20,6 +21,7 @@ export type CacheRequest<TResult> = {
|
|
|
20
21
|
export type QueryDefinition<TArgs extends readonly unknown[], TResult> = {
|
|
21
22
|
fn: (...args: TArgs) => MaybePromise<TResult>;
|
|
22
23
|
key: (...args: TArgs) => CacheKey;
|
|
24
|
+
locale?: "neutral";
|
|
23
25
|
notFoundTtl?: CacheDuration;
|
|
24
26
|
scope?: CacheScope;
|
|
25
27
|
staleWhileRevalidate?: CacheDuration;
|
package/dist/data/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/data/cache.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,OAAO,GACP,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,IAAI,GACJ,MAAM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GAAG,EAAE,QAAQ,UAE9C;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,UAE9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../src/data/idempotency.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,QAAQ,EACd,MAAM,SAAS,CAAC;AAEjB,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,kBAAkB,CAAC,OAAO,IAAI;IACxC,EAAE,EAAE,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,OAAO,IAAI;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,CAAC,OAAO,EACX,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,KACjC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;CAC1C,CAAC;AAQF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,CAAC;AAKF,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,6BAAkC,GAC1C,gBAAgB,
|
|
1
|
+
{"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../src/data/idempotency.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,QAAQ,EACd,MAAM,SAAS,CAAC;AAEjB,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,kBAAkB,CAAC,OAAO,IAAI;IACxC,EAAE,EAAE,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,OAAO,IAAI;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,CAAC,OAAO,EACX,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,KACjC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;CAC1C,CAAC;AAQF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,CAAC;AAKF,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,6BAAkC,GAC1C,gBAAgB,CA0ElB;AA8BD,wBAAgB,qBAAqB,CAAC,OAAO,EAC3C,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,uCAGrC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
export type DeploymentCapability = "clientAddress" | "readiness" | "repeatedHeaders" | "requestUrl" | "securityHeaders" | "sharedCache" | "staticAssets" | "streaming";
|
|
3
|
+
export type DeploymentClaims = Record<DeploymentCapability, boolean>;
|
|
4
|
+
export type DeploymentReadinessHost = {
|
|
5
|
+
afterShutdown: () => MaybePromise<Response>;
|
|
6
|
+
ready: () => MaybePromise<Response>;
|
|
7
|
+
shutdown: () => MaybePromise<void>;
|
|
8
|
+
};
|
|
9
|
+
export type DeploymentSharedCacheHost = {
|
|
10
|
+
readFromPeer: (key: string) => MaybePromise<Response>;
|
|
11
|
+
writeFromOrigin: (key: string, value: string) => MaybePromise<Response>;
|
|
12
|
+
};
|
|
13
|
+
export type DeploymentContractProbes = {
|
|
14
|
+
clientAddress?: (forwardedFor: string) => MaybePromise<Response>;
|
|
15
|
+
readiness?: () => MaybePromise<DeploymentReadinessHost>;
|
|
16
|
+
repeatedHeaders?: () => MaybePromise<Response>;
|
|
17
|
+
requestUrl?: (pathname: string, search: string) => MaybePromise<Response>;
|
|
18
|
+
securityHeaders?: () => MaybePromise<Response>;
|
|
19
|
+
sharedCache?: () => MaybePromise<DeploymentSharedCacheHost>;
|
|
20
|
+
staticAssets?: () => MaybePromise<Response>;
|
|
21
|
+
streaming?: () => MaybePromise<Response>;
|
|
22
|
+
};
|
|
23
|
+
export declare function verifyDeploymentContract(claims: DeploymentClaims, probes: DeploymentContractProbes): Promise<void>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/deployment/testing.ts"],"names":[],"mappings":"AAcA,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAC5B,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,WAAW,CAAC;AAEhB,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;AAErE,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5C,KAAK,EAAE,MAAM,YAAY,CAAC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
"streaming"
|
|
10
|
+
], f = /'nonce-([^']+)'/;
|
|
11
|
+
async function b(a, e) {
|
|
12
|
+
for (const t of y) {
|
|
13
|
+
const n = a[t], r = e[t];
|
|
14
|
+
s(
|
|
15
|
+
typeof n == "boolean",
|
|
16
|
+
`a deployment must declare capability "${t}" as a boolean`
|
|
17
|
+
), s(
|
|
18
|
+
!n || !!r,
|
|
19
|
+
`capability "${t}" is declared true and needs a probe that proves it`
|
|
20
|
+
), s(
|
|
21
|
+
n || !r,
|
|
22
|
+
`capability "${t}" has a probe but the deployment declares it false`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
e.requestUrl && await m(e.requestUrl), e.clientAddress && await w(e.clientAddress), e.streaming && await p(e.streaming), e.repeatedHeaders && await g(e.repeatedHeaders), e.staticAssets && await $(e.staticAssets), e.securityHeaders && await S(e.securityHeaders), e.sharedCache && await C(e.sharedCache), e.readiness && await v(e.readiness);
|
|
26
|
+
}
|
|
27
|
+
async function m(a) {
|
|
28
|
+
const e = "/deployment-contract/request-url-probe", t = `?probe=${Date.now()}`, n = await a(e, t), r = await d(n, "the request-url probe");
|
|
29
|
+
s(
|
|
30
|
+
r.pathname === e,
|
|
31
|
+
`the deployment must report the client's request pathname, and it reported ${JSON.stringify(r.pathname)} instead of ${JSON.stringify(e)}`
|
|
32
|
+
), s(
|
|
33
|
+
r.search === t,
|
|
34
|
+
`the deployment must report the client's request query string, and it reported ${JSON.stringify(r.search)} instead of ${JSON.stringify(t)}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async function w(a) {
|
|
38
|
+
const e = `203.0.113.${1 + Math.floor(Math.random() * 200)}`, t = `198.51.100.${1 + Math.floor(Math.random() * 200)}`, n = await d(await a(e), "the client-address probe"), r = await d(await a(t), "the client-address probe");
|
|
39
|
+
s(
|
|
40
|
+
n.address === e,
|
|
41
|
+
`the deployment must translate the forwarded client address, and it reported ${JSON.stringify(n.address)} instead of ${JSON.stringify(e)}`
|
|
42
|
+
), s(
|
|
43
|
+
r.address === t,
|
|
44
|
+
`the deployment must translate the forwarded client address, and it reported ${JSON.stringify(r.address)} instead of ${JSON.stringify(t)}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
async function p(a) {
|
|
48
|
+
const e = await a();
|
|
49
|
+
s(
|
|
50
|
+
!!e.body,
|
|
51
|
+
"a streaming response must expose a readable body stream"
|
|
52
|
+
);
|
|
53
|
+
const t = e.body.getReader(), n = new TextDecoder();
|
|
54
|
+
let r = 0, o = "";
|
|
55
|
+
for (; ; ) {
|
|
56
|
+
const c = await t.read();
|
|
57
|
+
if (c.done)
|
|
58
|
+
break;
|
|
59
|
+
r += 1, o += n.decode(c.value, { stream: !0 });
|
|
60
|
+
}
|
|
61
|
+
o += n.decode(), s(o.length > 0, "a streaming response must deliver a body"), s(
|
|
62
|
+
r > 1,
|
|
63
|
+
"a streaming response must deliver its body in more than one chunk"
|
|
64
|
+
);
|
|
65
|
+
const i = await a();
|
|
66
|
+
try {
|
|
67
|
+
await i.body?.cancel();
|
|
68
|
+
} catch (c) {
|
|
69
|
+
throw u(
|
|
70
|
+
`a streaming response body must accept cancellation, and it failed with ${h(c)}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function g(a) {
|
|
75
|
+
const e = await a(), t = typeof e.headers.getSetCookie == "function" ? e.headers.getSetCookie() : [];
|
|
76
|
+
s(
|
|
77
|
+
t.length >= 2,
|
|
78
|
+
`a deployment must forward every Set-Cookie header as a distinct value, and it reported ${t.length}`
|
|
79
|
+
);
|
|
80
|
+
const n = t.map((r) => r.split("=")[0]);
|
|
81
|
+
s(
|
|
82
|
+
new Set(n).size === n.length,
|
|
83
|
+
"a deployment must forward every declared cookie without dropping or duplicating one"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
async function $(a) {
|
|
87
|
+
const e = await a();
|
|
88
|
+
s(e.ok, `a static asset request must succeed, and it returned ${e.status}`);
|
|
89
|
+
const t = (e.headers.get("cache-control") ?? "").toLowerCase();
|
|
90
|
+
s(
|
|
91
|
+
t.includes("immutable") && t.includes("max-age"),
|
|
92
|
+
`a fingerprinted static asset must carry an immutable, long-lived cache-control header, and it carried ${JSON.stringify(t)}`
|
|
93
|
+
);
|
|
94
|
+
const n = await e.text(), o = await (await a()).text();
|
|
95
|
+
s(
|
|
96
|
+
n === o,
|
|
97
|
+
"a repeated static asset request must return the same bytes"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
async function S(a) {
|
|
101
|
+
const e = await a(), t = await a(), n = l(e), r = l(t);
|
|
102
|
+
s(
|
|
103
|
+
!!n,
|
|
104
|
+
"a security-headers response must declare a content-security-policy nonce source"
|
|
105
|
+
), s(
|
|
106
|
+
!!r && r !== n,
|
|
107
|
+
"every response must carry a freshly generated nonce"
|
|
108
|
+
);
|
|
109
|
+
const o = await e.text();
|
|
110
|
+
s(
|
|
111
|
+
o.includes(`nonce="${n}"`),
|
|
112
|
+
"the rendered document must carry the nonce its header declares"
|
|
113
|
+
), await t.body?.cancel(), s(
|
|
114
|
+
(e.headers.get("x-content-type-options") ?? "").toLowerCase() === "nosniff",
|
|
115
|
+
"a security-headers response must carry x-content-type-options nosniff"
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
async function C(a) {
|
|
119
|
+
const e = await a(), t = `deployment-contract-${Date.now()}-${Math.random().toString(36).slice(2)}`, n = `shared-cache-probe-${Math.random().toString(36).slice(2)}`, r = await e.writeFromOrigin(t, n);
|
|
120
|
+
s(
|
|
121
|
+
r.ok,
|
|
122
|
+
`writing to the shared cache must succeed, and it returned ${r.status}`
|
|
123
|
+
);
|
|
124
|
+
const o = await e.readFromPeer(t), i = await o.text();
|
|
125
|
+
s(
|
|
126
|
+
o.ok,
|
|
127
|
+
`reading the shared cache from a peer instance must succeed, and it returned ${o.status}`
|
|
128
|
+
), s(
|
|
129
|
+
i === n,
|
|
130
|
+
`a value written to the shared cache must be visible from another instance, and it read ${JSON.stringify(i)} instead of ${JSON.stringify(n)}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
async function v(a) {
|
|
134
|
+
const e = await a(), t = await e.ready();
|
|
135
|
+
s(
|
|
136
|
+
t.ok,
|
|
137
|
+
`the readiness probe must succeed before shutdown, and it returned ${t.status}`
|
|
138
|
+
), await e.shutdown(), await e.shutdown();
|
|
139
|
+
const n = await e.afterShutdown();
|
|
140
|
+
s(
|
|
141
|
+
!n.ok,
|
|
142
|
+
`the readiness probe must stop reporting ready once shutdown starts, and it returned ${n.status}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
async function d(a, e) {
|
|
146
|
+
try {
|
|
147
|
+
return await a.json();
|
|
148
|
+
} catch (t) {
|
|
149
|
+
throw u(
|
|
150
|
+
`${e} must return a JSON body, and it failed with ${h(t)}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function l(a) {
|
|
155
|
+
const e = a.headers.get("content-security-policy") ?? "";
|
|
156
|
+
return f.exec(e)?.[1];
|
|
157
|
+
}
|
|
158
|
+
function h(a) {
|
|
159
|
+
return a instanceof Error ? a.message : String(a);
|
|
160
|
+
}
|
|
161
|
+
function s(a, e) {
|
|
162
|
+
if (!a)
|
|
163
|
+
throw u(e);
|
|
164
|
+
}
|
|
165
|
+
function u(a) {
|
|
166
|
+
return new Error(`Deployment contract failed: ${a}.`);
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
b as verifyDeploymentContract
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../../src/deployment/testing.ts"],"sourcesContent":["// A deployment conformance kit proves the provider translation and the\n// production artifact, not the framework. The adapter contract in\n// `../adapter/testing` proves an adapter's in-process behavior against a\n// `Request`/`Response` pair it controls. A deployment sits one layer further\n// out: a real process, behind a real provider, answering real HTTP. The\n// probes here run against a live origin, and each one proves one behavior a\n// deployment integration can claim to support.\n//\n// Every integration selects only the probes that its execution model\n// supports. A process runtime can prove `readiness`. A platform that recycles\n// instances between requests cannot. The claims map keeps that selection\n// honest the same way the adapter contract does. A probe with no matching\n// claim, or a claim with no matching probe, fails the suite.\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type DeploymentCapability =\n | \"clientAddress\"\n | \"readiness\"\n | \"repeatedHeaders\"\n | \"requestUrl\"\n | \"securityHeaders\"\n | \"sharedCache\"\n | \"staticAssets\"\n | \"streaming\";\n\nexport type DeploymentClaims = Record<DeploymentCapability, boolean>;\n\nexport type DeploymentReadinessHost = {\n afterShutdown: () => MaybePromise<Response>;\n ready: () => MaybePromise<Response>;\n shutdown: () => MaybePromise<void>;\n};\n\nexport type DeploymentSharedCacheHost = {\n readFromPeer: (key: string) => MaybePromise<Response>;\n writeFromOrigin: (key: string, value: string) => MaybePromise<Response>;\n};\n\n// One probe per capability. A probe reaches the deployment the way a real\n// client would, over the network, and the contract reads the result. Every\n// probe may be called more than once.\nexport type DeploymentContractProbes = {\n clientAddress?: (forwardedFor: string) => MaybePromise<Response>;\n readiness?: () => MaybePromise<DeploymentReadinessHost>;\n repeatedHeaders?: () => MaybePromise<Response>;\n requestUrl?: (pathname: string, search: string) => MaybePromise<Response>;\n securityHeaders?: () => MaybePromise<Response>;\n sharedCache?: () => MaybePromise<DeploymentSharedCacheHost>;\n staticAssets?: () => MaybePromise<Response>;\n streaming?: () => MaybePromise<Response>;\n};\n\nconst contractCapabilities = [\n \"clientAddress\",\n \"readiness\",\n \"repeatedHeaders\",\n \"requestUrl\",\n \"securityHeaders\",\n \"sharedCache\",\n \"staticAssets\",\n \"streaming\",\n] as const satisfies readonly DeploymentCapability[];\n\nconst noncePattern = /'nonce-([^']+)'/;\n\nexport async function verifyDeploymentContract(\n claims: DeploymentClaims,\n probes: DeploymentContractProbes,\n) {\n for (const capability of contractCapabilities) {\n const declared = claims[capability];\n const probe = probes[capability];\n\n assert(\n typeof declared === \"boolean\",\n `a deployment must declare capability \"${capability}\" as a boolean`,\n );\n assert(\n !declared || Boolean(probe),\n `capability \"${capability}\" is declared true and needs a probe that proves it`,\n );\n assert(\n declared || !probe,\n `capability \"${capability}\" has a probe but the deployment declares it false`,\n );\n }\n\n if (probes.requestUrl) {\n await verifyRequestUrlContract(probes.requestUrl);\n }\n\n if (probes.clientAddress) {\n await verifyClientAddressContract(probes.clientAddress);\n }\n\n if (probes.streaming) {\n await verifyStreamingContract(probes.streaming);\n }\n\n if (probes.repeatedHeaders) {\n await verifyRepeatedHeadersContract(probes.repeatedHeaders);\n }\n\n if (probes.staticAssets) {\n await verifyStaticAssetsContract(probes.staticAssets);\n }\n\n if (probes.securityHeaders) {\n await verifySecurityHeadersContract(probes.securityHeaders);\n }\n\n if (probes.sharedCache) {\n await verifySharedCacheContract(probes.sharedCache);\n }\n\n if (probes.readiness) {\n await verifyReadinessContract(probes.readiness);\n }\n}\n\n// A provider sits in front of the process and rewrites the request before\n// the application ever sees it. The pathname and query string the\n// application reports back must be the ones the client asked for. Not an\n// internal rewrite target, a proxy's own path, or a stale default.\nasync function verifyRequestUrlContract(\n probe: NonNullable<DeploymentContractProbes[\"requestUrl\"]>,\n) {\n const pathname = \"/deployment-contract/request-url-probe\";\n const search = `?probe=${Date.now()}`;\n const response = await probe(pathname, search);\n const reported = await readJson(response, \"the request-url probe\");\n\n assert(\n reported.pathname === pathname,\n `the deployment must report the client's request pathname, and it reported ${JSON.stringify(reported.pathname)} instead of ${JSON.stringify(pathname)}`,\n );\n assert(\n reported.search === search,\n `the deployment must report the client's request query string, and it reported ${JSON.stringify(reported.search)} instead of ${JSON.stringify(search)}`,\n );\n}\n\n// A provider terminates the client's TCP connection and forwards the request\n// over its own connection to the process. Without a forwarded-header\n// translation, every request would appear to originate from the provider\n// itself instead of the client that sent it.\nasync function verifyClientAddressContract(\n probe: NonNullable<DeploymentContractProbes[\"clientAddress\"]>,\n) {\n const first = `203.0.113.${1 + Math.floor(Math.random() * 200)}`;\n const second = `198.51.100.${1 + Math.floor(Math.random() * 200)}`;\n const firstReported = await readJson(await probe(first), \"the client-address probe\");\n const secondReported = await readJson(await probe(second), \"the client-address probe\");\n\n assert(\n firstReported.address === first,\n `the deployment must translate the forwarded client address, and it reported ${JSON.stringify(firstReported.address)} instead of ${JSON.stringify(first)}`,\n );\n assert(\n secondReported.address === second,\n `the deployment must translate the forwarded client address, and it reported ${JSON.stringify(secondReported.address)} instead of ${JSON.stringify(second)}`,\n );\n}\n\n// A streamed body reaches the client before the render finishes, so it\n// arrives as more than one chunk. A provider that buffers the whole response\n// before forwarding it fails this, even when the application itself streams.\nasync function verifyStreamingContract(\n probe: NonNullable<DeploymentContractProbes[\"streaming\"]>,\n) {\n const response = await probe();\n\n assert(\n Boolean(response.body),\n \"a streaming response must expose a readable body stream\",\n );\n\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n let chunks = 0;\n let body = \"\";\n\n while (true) {\n const chunk = await reader.read();\n\n if (chunk.done) {\n break;\n }\n\n chunks += 1;\n body += decoder.decode(chunk.value, { stream: true });\n }\n\n body += decoder.decode();\n\n assert(body.length > 0, \"a streaming response must deliver a body\");\n assert(\n chunks > 1,\n \"a streaming response must deliver its body in more than one chunk\",\n );\n\n const cancelled = await probe();\n\n try {\n await cancelled.body?.cancel();\n } catch (error) {\n throw contractError(\n `a streaming response body must accept cancellation, and it failed with ${describe(error)}`,\n );\n }\n}\n\n// A provider that folds multiple response headers of the same name into one\n// comma-joined value corrupts `Set-Cookie`. It is defined to never combine\n// that way. This probe proves the deployment forwards repeated headers as\n// distinct values instead of merging them.\nasync function verifyRepeatedHeadersContract(\n probe: NonNullable<DeploymentContractProbes[\"repeatedHeaders\"]>,\n) {\n const response = await probe();\n const cookies = typeof response.headers.getSetCookie === \"function\"\n ? response.headers.getSetCookie()\n : [];\n\n assert(\n cookies.length >= 2,\n `a deployment must forward every Set-Cookie header as a distinct value, and it reported ${cookies.length}`,\n );\n\n const names = cookies.map((cookie) => cookie.split(\"=\")[0]);\n\n assert(\n new Set(names).size === names.length,\n \"a deployment must forward every declared cookie without dropping or duplicating one\",\n );\n}\n\n// A static asset served through the production artifact must stay byte\n// identical across requests and carry the long-lived, immutable cache header\n// a fingerprinted filename promises. A provider that regenerates or\n// revalidates the asset on every request breaks that promise even when the\n// bytes still match.\nasync function verifyStaticAssetsContract(\n probe: NonNullable<DeploymentContractProbes[\"staticAssets\"]>,\n) {\n const first = await probe();\n\n assert(first.ok, `a static asset request must succeed, and it returned ${first.status}`);\n\n const cacheControl = (first.headers.get(\"cache-control\") ?? \"\").toLowerCase();\n\n assert(\n cacheControl.includes(\"immutable\") && cacheControl.includes(\"max-age\"),\n `a fingerprinted static asset must carry an immutable, long-lived cache-control header, and it carried ${JSON.stringify(cacheControl)}`,\n );\n\n const firstBody = await first.text();\n const second = await probe();\n const secondBody = await second.text();\n\n assert(\n firstBody === secondBody,\n \"a repeated static asset request must return the same bytes\",\n );\n}\n\n// A nonce is single use. Two responses cannot share one, and the document\n// must carry the value the header declares. Security headers that protect\n// against framing or MIME sniffing must survive the trip through the\n// provider unchanged.\nasync function verifySecurityHeadersContract(\n probe: NonNullable<DeploymentContractProbes[\"securityHeaders\"]>,\n) {\n const first = await probe();\n const second = await probe();\n const firstNonce = readCspNonce(first);\n const secondNonce = readCspNonce(second);\n\n assert(\n Boolean(firstNonce),\n \"a security-headers response must declare a content-security-policy nonce source\",\n );\n assert(\n Boolean(secondNonce) && secondNonce !== firstNonce,\n \"every response must carry a freshly generated nonce\",\n );\n\n const document = await first.text();\n\n assert(\n document.includes(`nonce=\"${firstNonce}\"`),\n \"the rendered document must carry the nonce its header declares\",\n );\n await second.body?.cancel();\n\n assert(\n (first.headers.get(\"x-content-type-options\") ?? \"\").toLowerCase() === \"nosniff\",\n \"a security-headers response must carry x-content-type-options nosniff\",\n );\n}\n\n// A cache is shared, not per instance, when a write on one instance is\n// visible from another. This is the one probe in the suite that reaches two\n// separate connections into the deployment. It is the only behavior a\n// single connection cannot distinguish from an in-process cache.\nasync function verifySharedCacheContract(\n probe: NonNullable<DeploymentContractProbes[\"sharedCache\"]>,\n) {\n const host = await probe();\n const key = `deployment-contract-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n const value = `shared-cache-probe-${Math.random().toString(36).slice(2)}`;\n\n const write = await host.writeFromOrigin(key, value);\n\n assert(\n write.ok,\n `writing to the shared cache must succeed, and it returned ${write.status}`,\n );\n\n const read = await host.readFromPeer(key);\n const readBody = await read.text();\n\n assert(\n read.ok,\n `reading the shared cache from a peer instance must succeed, and it returned ${read.status}`,\n );\n assert(\n readBody === value,\n `a value written to the shared cache must be visible from another instance, and it read ${JSON.stringify(readBody)} instead of ${JSON.stringify(value)}`,\n );\n}\n\n// Readiness and graceful shutdown apply only to a process runtime, one that\n// keeps running between requests and can be told to drain. Shutdown must\n// stop accepting new traffic and the readiness probe must reflect that\n// before the process exits.\nasync function verifyReadinessContract(\n probe: NonNullable<DeploymentContractProbes[\"readiness\"]>,\n) {\n const host = await probe();\n const ready = await host.ready();\n\n assert(\n ready.ok,\n `the readiness probe must succeed before shutdown, and it returned ${ready.status}`,\n );\n\n await host.shutdown();\n await host.shutdown();\n\n const afterShutdown = await host.afterShutdown();\n\n assert(\n !afterShutdown.ok,\n `the readiness probe must stop reporting ready once shutdown starts, and it returned ${afterShutdown.status}`,\n );\n}\n\nasync function readJson(response: Response, requirement: string) {\n try {\n // TYPE-EVIDENCE: json() returns unknown. The contract only reads string fields it names itself, and the assertions below fail loudly for a missing or wrong-typed field.\n return (await response.json()) as Record<string, string>;\n } catch (error) {\n throw contractError(\n `${requirement} must return a JSON body, and it failed with ${describe(error)}`,\n );\n }\n}\n\nfunction readCspNonce(response: Response) {\n const csp = response.headers.get(\"content-security-policy\") ?? \"\";\n\n return noncePattern.exec(csp)?.[1];\n}\n\nfunction describe(error: unknown) {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction assert(condition: boolean, requirement: string): asserts condition {\n if (!condition) {\n throw contractError(requirement);\n }\n}\n\nfunction contractError(requirement: string) {\n return new Error(`Deployment contract failed: ${requirement}.`);\n}\n"],"names":["contractCapabilities","noncePattern","verifyDeploymentContract","claims","probes","capability","declared","probe","assert","verifyRequestUrlContract","verifyClientAddressContract","verifyStreamingContract","verifyRepeatedHeadersContract","verifyStaticAssetsContract","verifySecurityHeadersContract","verifySharedCacheContract","verifyReadinessContract","pathname","search","response","reported","readJson","first","second","firstReported","secondReported","reader","decoder","chunks","body","chunk","cancelled","error","contractError","describe","cookies","names","cookie","cacheControl","firstBody","secondBody","firstNonce","readCspNonce","secondNonce","document","host","key","value","write","read","readBody","ready","afterShutdown","requirement","csp","condition"],"mappings":"AAqDA,MAAMA,IAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAe;AAErB,eAAsBC,EACpBC,GACAC,GACA;AACA,aAAWC,KAAcL,GAAsB;AAC7C,UAAMM,IAAWH,EAAOE,CAAU,GAC5BE,IAAQH,EAAOC,CAAU;AAE/B,IAAAG;AAAA,MACE,OAAOF,KAAa;AAAA,MACpB,yCAAyCD,CAAU;AAAA,IAAA,GAErDG;AAAA,MACE,CAACF,KAAY,EAAQC;AAAA,MACrB,eAAeF,CAAU;AAAA,IAAA,GAE3BG;AAAA,MACEF,KAAY,CAACC;AAAA,MACb,eAAeF,CAAU;AAAA,IAAA;AAAA,EAE7B;AAEA,EAAID,EAAO,cACT,MAAMK,EAAyBL,EAAO,UAAU,GAG9CA,EAAO,iBACT,MAAMM,EAA4BN,EAAO,aAAa,GAGpDA,EAAO,aACT,MAAMO,EAAwBP,EAAO,SAAS,GAG5CA,EAAO,mBACT,MAAMQ,EAA8BR,EAAO,eAAe,GAGxDA,EAAO,gBACT,MAAMS,EAA2BT,EAAO,YAAY,GAGlDA,EAAO,mBACT,MAAMU,EAA8BV,EAAO,eAAe,GAGxDA,EAAO,eACT,MAAMW,EAA0BX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AE5FzC;AAAA,IACE0C,MAAaH;AAAA,IACb,0FAA0F,KAAK,UAAUG,CAAQ,CAAC,eAAe,KAAK,UAAUH,CAAK,CAAC;AAAA,EAAA;AAE1J;AAMA,eAAe/B,EACbT,GACA;AACA,QAAMsC,IAAO,MAAMtC,EAAA,GACb4C,IAAQ,MAAMN,EAAK,MAAA;AAEzB,EAAArC;AAAA,IACE2C,EAAM;AAAA,IACN,qEAAqEA,EAAM,MAAM;AAAA,EAAA,GAGnF,MAAMN,EAAK,SAAA,GACX,MAAMA,EAAK,SAAA;AAEX,QAAMO,IAAgB,MAAMP,EAAK,cAAA;AAEjC,EAAArC;AAAA,IACE,CAAC4C,EAAc;AAAA,IACf,uFAAuFA,EAAc,MAAM;AAAA,EAAA;AAE/G;AAEA,eAAe/B,EAASF,GAAoBkC,GAAqB;AAC/D,MAAI;AAEF,WAAQ,MAAMlC,EAAS,KAAA;AAAA,EACzB,SAASa,GAAO;AACd,UAAMC;AAAA,MACJ,GAAGoB,CAAW,gDAAgDnB,EAASF,CAAK,CAAC;AAAA,IAAA;AAAA,EAEjF;AACF;AAEA,SAASU,EAAavB,GAAoB;AACxC,QAAMmC,IAAMnC,EAAS,QAAQ,IAAI,yBAAyB,KAAK;AAE/D,SAAOlB,EAAa,KAAKqD,CAAG,IAAI,CAAC;AACnC;AAEA,SAASpB,EAASF,GAAgB;AAChC,SAAOA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK;AAC9D;AAEA,SAASxB,EAAO+C,GAAoBF,GAAwC;AAC1E,MAAI,CAACE;AACH,UAAMtB,EAAcoB,CAAW;AAEnC;AAEA,SAASpB,EAAcoB,GAAqB;AAC1C,SAAO,IAAI,MAAM,+BAA+BA,CAAW,GAAG;AAChE;"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import type { NavigationDocument } from "./navigation";
|
|
1
2
|
export type InitialRouteData = {
|
|
2
3
|
data?: unknown;
|
|
4
|
+
document?: NavigationDocument;
|
|
5
|
+
error?: {
|
|
6
|
+
detail?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
3
9
|
hasData: boolean;
|
|
10
|
+
locale?: string;
|
|
4
11
|
navigation?: "document";
|
|
12
|
+
url?: string;
|
|
5
13
|
};
|
|
6
14
|
export declare const HYDRATION_DATA_ELEMENT_ID = "__demiurge_data";
|
|
7
15
|
export declare const HYDRATION_ROOT_ATTRIBUTE = "data-demiurge-hydrate";
|
|
8
16
|
export declare const HYDRATION_FALLBACK_ATTRIBUTE = "data-demiurge-fallback";
|
|
9
17
|
export declare function serializeInitialRouteData(data: unknown, options?: {
|
|
18
|
+
locale?: string;
|
|
10
19
|
navigation?: "document";
|
|
11
20
|
}): string;
|
|
12
21
|
export declare function readInitialRouteData(source: Document): InitialRouteData | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../src/document/hydration.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../src/document/hydration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAC3D,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAIhE,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AAErE,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAAO,UAK3D;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,gCAoBpD"}
|
package/dist/document/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { HYDRATION_DATA_ELEMENT_ID, HYDRATION_FALLBACK_ATTRIBUTE, HYDRATION_ROOT_ATTRIBUTE, readInitialRouteData, serializeInitialRouteData, } from "./hydration";
|
|
2
2
|
export { getScriptWorker, startDeferredScripts, } from "./deferred-scripts";
|
|
3
3
|
export { defineLinks, modulePreload, preconnect, preload, resolveLinks, } from "./links";
|
|
4
|
-
export { defineMetadata, link, meta, resolveMetadata, structuredData, } from "./metadata";
|
|
4
|
+
export { defineMetadata, applyLocalizedMetadata, link, meta, resolveMetadata, structuredData, } from "./metadata";
|
|
5
|
+
export { applyNavigationDocument, createNavigationDocument, DOCUMENT_CONTRIBUTION_ATTRIBUTE, DOCUMENT_SCRIPT_STRATEGY_ATTRIBUTE, NAVIGATION_STATUS_ATTRIBUTE, NAVIGATION_STATUS_ID, announceNavigation, ensureNavigationStatusRegion, } from "./navigation";
|
|
5
6
|
export { renderDocument, } from "./render";
|
|
6
7
|
export { defineScripts, Script, resolveScripts, script, } from "./scripts";
|
|
7
8
|
export { createFrameworkScriptUrl, FRAMEWORK_TRUSTED_TYPES_POLICY, } from "./trusted-types";
|
|
@@ -9,7 +10,8 @@ export { defineOgImage, defineRobots, defineSitemap, renderOgImageResponse, rend
|
|
|
9
10
|
export type { DeferredScriptStrategy } from "./deferred-scripts";
|
|
10
11
|
export type { InitialRouteData } from "./hydration";
|
|
11
12
|
export type { LinkContribution, PreconnectOptions, PreloadOptions, } from "./links";
|
|
12
|
-
export type { DocumentMetadataTag, LinkTag, Metadata, MetadataTitle, MetaTag, OpenGraphMetadata, ResolvedMetadata, RobotsMetadata, StructuredDataTag, StructuredDataValue, } from "./metadata";
|
|
13
|
+
export type { DocumentMetadataTag, LocalizedMetadataAlternate, LinkTag, Metadata, MetadataTitle, MetaTag, OpenGraphMetadata, ResolvedMetadata, RobotsMetadata, StructuredDataTag, StructuredDataValue, } from "./metadata";
|
|
14
|
+
export type { NavigationDocument, NavigationScriptTag, } from "./navigation";
|
|
13
15
|
export type { DocumentBody, RenderDocumentOptions, } from "./render";
|
|
14
16
|
export type { ScriptContribution, ScriptCspNeeds, ScriptProps, ScriptStrategy, ScriptTag, } from "./scripts";
|
|
15
17
|
export type { OgImage, Robots, RobotsDirective, Sitemap, SitemapAlternate, SitemapChangeFrequency, SitemapEntry, } from "./seo";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,aAAa,EACb,UAAU,EACV,OAAO,EACP,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,MAAM,EACN,cAAc,EACd,MAAM,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,OAAO,CAAC;AACf,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,mBAAmB,EACnB,OAAO,EACP,QAAQ,EACR,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,YAAY,EACZ,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACb,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,aAAa,EACb,UAAU,EACV,OAAO,EACP,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,kCAAkC,EAClC,2BAA2B,EAC3B,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,MAAM,EACN,cAAc,EACd,MAAM,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,OAAO,CAAC;AACf,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,OAAO,EACP,QAAQ,EACR,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACb,MAAM,OAAO,CAAC"}
|
|
@@ -54,6 +54,14 @@ export type ResolvedMetadata = {
|
|
|
54
54
|
title?: string;
|
|
55
55
|
viewport: "width=device-width, initial-scale=1";
|
|
56
56
|
};
|
|
57
|
+
export type LocalizedMetadataAlternate = {
|
|
58
|
+
href: string;
|
|
59
|
+
hrefLang: string;
|
|
60
|
+
};
|
|
61
|
+
export declare function applyLocalizedMetadata(metadata: ResolvedMetadata, options: {
|
|
62
|
+
alternates: readonly LocalizedMetadataAlternate[];
|
|
63
|
+
canonical: string;
|
|
64
|
+
}): ResolvedMetadata;
|
|
57
65
|
export declare function defineMetadata(metadata: Metadata): Metadata;
|
|
58
66
|
export declare function meta(tag: Omit<MetaTag, "kind">): MetaTag;
|
|
59
67
|
export declare function link(tag: Omit<LinkTag, "kind">): LinkTag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/document/metadata.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,MAAM,GACN;IACE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,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