@threadlabs/markupkit 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -2
  3. package/components/breadcrumbs.html +9 -0
  4. package/components/nav.html +51 -0
  5. package/components/pager.html +13 -0
  6. package/dist/application.d.ts +31 -0
  7. package/dist/application.d.ts.map +1 -0
  8. package/dist/application.js +488 -0
  9. package/dist/application.js.map +1 -0
  10. package/dist/browser.d.ts +13 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +151 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/build.d.ts +5 -0
  15. package/dist/build.d.ts.map +1 -0
  16. package/dist/build.js +351 -0
  17. package/dist/build.js.map +1 -0
  18. package/dist/bundle-worker.d.ts +2 -0
  19. package/dist/bundle-worker.d.ts.map +1 -0
  20. package/dist/bundle-worker.js +48 -0
  21. package/dist/bundle-worker.js.map +1 -0
  22. package/dist/bundle.d.ts +23 -0
  23. package/dist/bundle.d.ts.map +1 -0
  24. package/dist/bundle.js +34 -0
  25. package/dist/bundle.js.map +1 -0
  26. package/dist/cli.d.ts +3 -0
  27. package/dist/cli.d.ts.map +1 -0
  28. package/dist/cli.js +68 -0
  29. package/dist/cli.js.map +1 -0
  30. package/dist/client.d.ts +40 -0
  31. package/dist/client.d.ts.map +1 -0
  32. package/dist/client.js +447 -0
  33. package/dist/client.js.map +1 -0
  34. package/dist/component-module.d.ts +20 -0
  35. package/dist/component-module.d.ts.map +1 -0
  36. package/dist/component-module.js +82 -0
  37. package/dist/component-module.js.map +1 -0
  38. package/dist/config.d.ts +36 -0
  39. package/dist/config.d.ts.map +1 -0
  40. package/dist/config.js +111 -0
  41. package/dist/config.js.map +1 -0
  42. package/dist/csp.d.ts +23 -0
  43. package/dist/csp.d.ts.map +1 -0
  44. package/dist/csp.js +91 -0
  45. package/dist/csp.js.map +1 -0
  46. package/dist/description.d.ts +45 -0
  47. package/dist/description.d.ts.map +1 -0
  48. package/dist/description.js +28 -0
  49. package/dist/description.js.map +1 -0
  50. package/dist/document.d.ts +48 -0
  51. package/dist/document.d.ts.map +1 -0
  52. package/dist/document.js +65 -0
  53. package/dist/document.js.map +1 -0
  54. package/dist/index.d.ts +13 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +9 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/links.d.ts +8 -0
  59. package/dist/links.d.ts.map +1 -0
  60. package/dist/links.js +90 -0
  61. package/dist/links.js.map +1 -0
  62. package/dist/private-api.d.ts +12 -0
  63. package/dist/private-api.d.ts.map +1 -0
  64. package/dist/private-api.js +158 -0
  65. package/dist/private-api.js.map +1 -0
  66. package/dist/private-client.d.ts +11 -0
  67. package/dist/private-client.d.ts.map +1 -0
  68. package/dist/private-client.js +18 -0
  69. package/dist/private-client.js.map +1 -0
  70. package/dist/private-readers.d.ts +26 -0
  71. package/dist/private-readers.d.ts.map +1 -0
  72. package/dist/private-readers.js +107 -0
  73. package/dist/private-readers.js.map +1 -0
  74. package/dist/provider-preparation.d.ts +20 -0
  75. package/dist/provider-preparation.d.ts.map +1 -0
  76. package/dist/provider-preparation.js +82 -0
  77. package/dist/provider-preparation.js.map +1 -0
  78. package/dist/providers.d.ts +14 -0
  79. package/dist/providers.d.ts.map +1 -0
  80. package/dist/providers.js +127 -0
  81. package/dist/providers.js.map +1 -0
  82. package/dist/read-channel.d.ts +30 -0
  83. package/dist/read-channel.d.ts.map +1 -0
  84. package/dist/read-channel.js +65 -0
  85. package/dist/read-channel.js.map +1 -0
  86. package/dist/resource.d.ts +31 -0
  87. package/dist/resource.d.ts.map +1 -0
  88. package/dist/resource.js +117 -0
  89. package/dist/resource.js.map +1 -0
  90. package/dist/routes.d.ts +90 -0
  91. package/dist/routes.d.ts.map +1 -0
  92. package/dist/routes.js +536 -0
  93. package/dist/routes.js.map +1 -0
  94. package/dist/serve.d.ts +4 -0
  95. package/dist/serve.d.ts.map +1 -0
  96. package/dist/serve.js +221 -0
  97. package/dist/serve.js.map +1 -0
  98. package/dist/server.d.ts +211 -0
  99. package/dist/server.d.ts.map +1 -0
  100. package/dist/server.js +734 -0
  101. package/dist/server.js.map +1 -0
  102. package/dist/types.d.ts +504 -0
  103. package/dist/types.d.ts.map +1 -0
  104. package/dist/types.js +2 -0
  105. package/dist/types.js.map +1 -0
  106. package/package.json +80 -4
@@ -0,0 +1,36 @@
1
+ import type { ApplicationOptions, MarkupKitPlugin, RouteLayer } from "./types.js";
2
+ /**
3
+ * The options markupkit.config.ts (or .js) at root exports by default, loaded through Vite as the CLI
4
+ * loads them; {} without a config file.
5
+ */
6
+ export declare function loadConfig(root?: string): Promise<ApplicationOptions>;
7
+ export declare class MarkupKitError extends Error {
8
+ readonly source?: string | undefined;
9
+ constructor(message: string, source?: string | undefined);
10
+ }
11
+ export declare function within(parent: string, child: string): boolean;
12
+ export declare function configure(options: ApplicationOptions): {
13
+ root: string;
14
+ base: string;
15
+ origin: string;
16
+ outDir: string;
17
+ prefetch: import("./types.js").PrefetchPolicy;
18
+ csp: false | import("./types.js").ContentSecurityPolicyOptions;
19
+ };
20
+ /** Plugins' named layouts, kept apart from the site's: a site's app/layouts/<name>.html wins over them. */
21
+ export declare const pluginLayouts: unique symbol;
22
+ export type PluginOptions = ApplicationOptions & {
23
+ readonly [pluginLayouts]?: Readonly<Record<string, RouteLayer>>;
24
+ };
25
+ /** Merge each plugin's config() once; options already merged pass through, so nested entry points don't repeat hooks. */
26
+ export declare function withPlugins(options: ApplicationOptions): Promise<ApplicationOptions>;
27
+ /** Run each plugin's hook in order; a failure names the plugin and the hook. */
28
+ export declare function runHook<Hook extends "buildStart" | "buildEnd">(options: ApplicationOptions, hook: Hook, context: Parameters<NonNullable<MarkupKitPlugin[Hook]>>[0]): Promise<void>;
29
+ /** Vite's side of the import map's @/ entry, for loaders, controllers, and stylesheets. */
30
+ export declare function rootAlias(root: string): {
31
+ find: RegExp;
32
+ replacement: string;
33
+ }[];
34
+ /** The application's global stylesheets as absolute paths. */
35
+ export declare function globalStylesheets(options: ApplicationOptions, root: string): readonly string[];
36
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElF;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,SAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAalF;AAED,qBAAa,cAAe,SAAQ,KAAK;IACV,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAArD,YAAY,OAAO,EAAE,MAAM,EAAW,MAAM,CAAC,EAAE,MAAM,YAAA,EAGpD;CACF;AACD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAG7D;AACD,wBAAgB,SAAS,CAAC,OAAO,EAAE,kBAAkB;;;;;;;EAoBpD;AAED,2GAA2G;AAC3G,eAAO,MAAM,aAAa,eAAoC,CAAC;AAC/D,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;CAAE,CAAC;AAGrH,yHAAyH;AACzH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgB1F;AAED,gFAAgF;AAChF,wBAAsB,OAAO,CAAC,IAAI,SAAS,YAAY,GAAG,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAC3G,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAS3E;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM;;;IAGrC;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAE9F"}
package/dist/config.js ADDED
@@ -0,0 +1,111 @@
1
+ import { existsSync } from "node:fs";
2
+ import { isAbsolute, posix, relative, resolve, sep } from "node:path";
3
+ import { checkPolicyOptions } from "./csp.js";
4
+ /**
5
+ * The options markupkit.config.ts (or .js) at root exports by default, loaded through Vite as the CLI
6
+ * loads them; {} without a config file.
7
+ */
8
+ export async function loadConfig(root = process.cwd()) {
9
+ const files = ["ts", "js"].map(ext => resolve(root, `markupkit.config.${ext}`)).filter(existsSync);
10
+ if (files.length > 1)
11
+ throw new MarkupKitError("Choose one markupkit.config.ts or .js.", resolve(root));
12
+ if (files[0] === undefined)
13
+ return {};
14
+ // Loaded here, so the request server, which shares this module, runs without Vite.
15
+ const { createServer } = await import("vite");
16
+ const loader = await createServer({ root: resolve(root), configFile: false, appType: "custom", logLevel: "silent",
17
+ server: { middlewareMode: true, watch: null, hmr: false }, optimizeDeps: { noDiscovery: true, include: [] } });
18
+ let configured;
19
+ try {
20
+ configured = (await loader.ssrLoadModule(files[0])).default;
21
+ }
22
+ finally {
23
+ await loader.close();
24
+ }
25
+ if (configured === null || typeof configured !== "object")
26
+ throw new MarkupKitError("Configuration must export a default ApplicationOptions object.", files[0]);
27
+ return configured;
28
+ }
29
+ export class MarkupKitError extends Error {
30
+ source;
31
+ constructor(message, source) {
32
+ super(source === undefined ? message : `${source}: ${message}`);
33
+ this.source = source;
34
+ this.name = "MarkupKitError";
35
+ }
36
+ }
37
+ export function within(parent, child) {
38
+ const path = relative(parent, child);
39
+ return path === "" || (!isAbsolute(path) && path !== ".." && !path.startsWith(`..${sep}`));
40
+ }
41
+ export function configure(options) {
42
+ // Removed with the always-on 01. ordering; name that rather than quietly move pages to /01-guide/.
43
+ if ("routeOrdering" in options)
44
+ throw new MarkupKitError("The routeOrdering option was removed: a number and a dot (01.guide/) always orders pages.");
45
+ const root = resolve(options.root ?? process.cwd());
46
+ const base = options.base ?? "/";
47
+ if (!/^\/(?:[A-Za-z0-9_-]+\/)*$/.test(base))
48
+ throw new MarkupKitError("base must be an absolute path with a trailing slash, for example /docs/.");
49
+ const origin = new URL(options.origin ?? "http://localhost");
50
+ if (!/^https?:$/.test(origin.protocol) || origin.username || origin.password || origin.pathname !== "/" || origin.search || origin.hash) {
51
+ throw new MarkupKitError("origin must be an HTTP(S) origin without a path, credentials, query, or fragment.");
52
+ }
53
+ const outDir = resolve(root, options.outDir ?? "dist");
54
+ // A failed build must never erase source, the application, or its dependencies.
55
+ if (within(outDir, root) || ["app", "src", "public", "node_modules", ".git"].some(path => within(resolve(root, path), outDir))) {
56
+ throw new MarkupKitError("Unsafe output directory; choose dist or a separate deployment directory.", outDir);
57
+ }
58
+ const prefetch = options.prefetch ?? "interaction";
59
+ if (!["interaction", "visible", "none"].includes(prefetch))
60
+ throw new MarkupKitError('prefetch must be "interaction", "visible", or "none".');
61
+ if (![undefined, "error", "warn"].includes(options.linkCheck))
62
+ throw new MarkupKitError('linkCheck must be "error" or "warn".');
63
+ if (!["undefined", "boolean", "string"].includes(typeof options.robots))
64
+ throw new MarkupKitError("robots must be true, false, or the text of robots.txt.");
65
+ return { root, base, origin: origin.origin, outDir, prefetch, csp: checkPolicyOptions(options.csp) };
66
+ }
67
+ /** Plugins' named layouts, kept apart from the site's: a site's app/layouts/<name>.html wins over them. */
68
+ export const pluginLayouts = Symbol("markupkit.pluginLayouts");
69
+ const pluginsApplied = new WeakSet();
70
+ /** Merge each plugin's config() once; options already merged pass through, so nested entry points don't repeat hooks. */
71
+ export async function withPlugins(options) {
72
+ if (pluginsApplied.has(options) || options.plugins === undefined)
73
+ return options;
74
+ let merged = options;
75
+ for (const plugin of options.plugins) {
76
+ const { layouts, ...added } = await plugin.config?.(merged) ?? {};
77
+ // Page folders, stylesheets, and routes add to the application's own; app/pages stays the default folder.
78
+ merged = { ...merged, ...added, plugins: options.plugins,
79
+ ...(added.pages === undefined ? {} : { pages: [...merged.pages ?? [{ dir: "app/pages", optional: true }], ...added.pages] }),
80
+ ...(added.css === undefined ? {} : { css: [...merged.css ?? [], ...added.css] }),
81
+ // An earlier plugin's named layout wins over a later plugin's of the same name.
82
+ ...(layouts === undefined ? {} : { [pluginLayouts]: { ...layouts, ...merged[pluginLayouts] } }),
83
+ ...(added.routes === undefined ? {} : { routes: [...merged.routes ?? [], ...added.routes] }) };
84
+ }
85
+ merged = { ...merged };
86
+ pluginsApplied.add(merged);
87
+ return merged;
88
+ }
89
+ /** Run each plugin's hook in order; a failure names the plugin and the hook. */
90
+ export async function runHook(options, hook, context) {
91
+ for (const plugin of options.plugins ?? []) {
92
+ try {
93
+ await plugin[hook]?.call(plugin, context);
94
+ }
95
+ catch (error) {
96
+ const failure = new MarkupKitError(`Plugin ${plugin.name} failed in ${hook}: ${error instanceof Error ? error.message : String(error)}`);
97
+ failure.cause = error;
98
+ throw failure;
99
+ }
100
+ }
101
+ }
102
+ /** Vite's side of the import map's @/ entry, for loaders, controllers, and stylesheets. */
103
+ export function rootAlias(root) {
104
+ // Vite's normalizePath.
105
+ return [{ find: /^@\//, replacement: posix.normalize(root.replaceAll("\\", "/")) + "/" }];
106
+ }
107
+ /** The application's global stylesheets as absolute paths. */
108
+ export function globalStylesheets(options, root) {
109
+ return (options.css ?? []).map(path => resolve(root, path.startsWith("@/") ? path.slice(2) : path));
110
+ }
111
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,G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IAAY;IACpC,wBAAwB;IACxB,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,iBAAiB,CAAC,OAA2B,EAAE,IAAY;IACzE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACtG,CAAC"}
package/dist/csp.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { ComponentDefinition } from "@nextwebwg/html-next";
2
+ import type { ContentSecurityPolicyOptions, RenderedPolicy } from "./types.js";
3
+ /** The csp option checked: `false`, or sources per directive in CSP's own grammar. */
4
+ export declare function checkPolicyOptions(csp: unknown): ContentSecurityPolicyOptions | false;
5
+ /** A classic inline script's CSP hash source. */
6
+ export declare function scriptHash(script: string): string;
7
+ /**
8
+ * The site's policy, which every page carries: script-src with 'self' for MarkupKit's own modules and
9
+ * controllers, the origin of each script any component of the site declares, and the hash of each
10
+ * inline head script; object-src and base-uri 'none'; then the csp option's sources, added to each
11
+ * directive. One policy keeps client navigation in place, since a document keeps the policy it loaded
12
+ * with. Undefined with `csp: false`.
13
+ */
14
+ export declare function sitePolicy(csp: ContentSecurityPolicyOptions | false, definitions: readonly ComponentDefinition[], scripts: readonly string[]): RenderedPolicy | undefined;
15
+ /** The header that delivers the policy. */
16
+ export declare function policyHeader(policy: RenderedPolicy): string;
17
+ /**
18
+ * The csp option for the development server: what Vite needs beside 'self', which already covers its
19
+ * client and modules. Its HMR WebSocket needs connect-src, and the styles it injects for CSS a
20
+ * module imports need style-src 'unsafe-inline', each only where the policy restricts it.
21
+ */
22
+ export declare function developmentPolicyOptions(csp: ContentSecurityPolicyOptions | false, socket: string): ContentSecurityPolicyOptions | false;
23
+ //# sourceMappingURL=csp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.d.ts","sourceRoot":"","sources":["../src/csp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,KAAK,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK/E,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,4BAA4B,GAAG,KAAK,CAerF;AAED,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,EAAE,WAAW,EAAE,SAAS,mBAAmB,EAAE,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,GAAG,SAAS,CA0BzK;AAED,2CAA2C;AAC3C,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,4BAA4B,GAAG,KAAK,CAQxI"}
package/dist/csp.js ADDED
@@ -0,0 +1,91 @@
1
+ import { createHash } from "node:crypto";
2
+ import { MarkupKitError } from "./config.js";
3
+ /** Directives a `<meta http-equiv>` policy ignores (CSP 3, §3.3), which only the header carries. */
4
+ const headerOnly = new Set(["frame-ancestors", "report-uri", "sandbox"]);
5
+ /** The csp option checked: `false`, or sources per directive in CSP's own grammar. */
6
+ export function checkPolicyOptions(csp) {
7
+ if (csp === undefined)
8
+ return {};
9
+ if (csp === false)
10
+ return false;
11
+ if (csp === null || typeof csp !== "object" || Array.isArray(csp))
12
+ throw new MarkupKitError("csp must be false or an object of sources per directive.");
13
+ for (const [name, value] of Object.entries(csp)) {
14
+ if (name === "reportOnly") {
15
+ if (typeof value !== "boolean")
16
+ throw new MarkupKitError("csp.reportOnly must be true or false.");
17
+ continue;
18
+ }
19
+ if (!/^[a-z][a-z-]*$/.test(name))
20
+ throw new MarkupKitError(`csp directive ${name} must be a lowercase CSP directive name, such as "script-src".`);
21
+ if (!Array.isArray(value) || !value.every(source => typeof source === "string" && /^[^\s;,]+$/.test(source))) {
22
+ throw new MarkupKitError(`csp["${name}"] must be a list of CSP source expressions, such as ["https://cdn.example"], each without spaces, semicolons, or commas.`);
23
+ }
24
+ }
25
+ return csp;
26
+ }
27
+ /** A classic inline script's CSP hash source. */
28
+ export function scriptHash(script) {
29
+ return `'sha256-${createHash("sha256").update(script).digest("base64")}'`;
30
+ }
31
+ /**
32
+ * The site's policy, which every page carries: script-src with 'self' for MarkupKit's own modules and
33
+ * controllers, the origin of each script any component of the site declares, and the hash of each
34
+ * inline head script; object-src and base-uri 'none'; then the csp option's sources, added to each
35
+ * directive. One policy keeps client navigation in place, since a document keeps the policy it loaded
36
+ * with. Undefined with `csp: false`.
37
+ */
38
+ export function sitePolicy(csp, definitions, scripts) {
39
+ if (csp === false)
40
+ return undefined;
41
+ const origins = new Set();
42
+ for (const definition of definitions) {
43
+ for (const { src } of definition.scripts ?? []) {
44
+ // A relative or root-relative script is MarkupKit's own origin; a bare one resolves through an import map.
45
+ if (!/^(?:[A-Za-z][A-Za-z\d+.-]*:|\/\/)/.test(src))
46
+ continue;
47
+ const url = URL.parse(src, "https://markupkit.invalid/");
48
+ if (url !== null && /^https?:$/.test(url.protocol))
49
+ origins.add(url.origin);
50
+ }
51
+ }
52
+ const directives = new Map([
53
+ ["script-src", ["'self'", ...[...origins].sort(), ...scripts.map(scriptHash)]],
54
+ ["object-src", ["'none'"]],
55
+ ["base-uri", ["'none'"]],
56
+ ]);
57
+ for (const [name, sources] of Object.entries(csp)) {
58
+ if (name === "reportOnly" || !Array.isArray(sources))
59
+ continue;
60
+ const merged = directives.get(name) ?? [];
61
+ for (const source of sources)
62
+ if (!merged.includes(source))
63
+ merged.push(source);
64
+ // 'none' allows nothing only when it is a directive's one source.
65
+ directives.set(name, merged.length > 1 ? merged.filter(source => source !== "'none'") : merged);
66
+ }
67
+ const text = (entries) => entries.map(([name, sources]) => [name, ...sources].join(" ")).join("; ");
68
+ const reportOnly = csp.reportOnly === true;
69
+ return { header: text([...directives]), reportOnly, ...(reportOnly ? {} : { meta: text([...directives].filter(([name]) => !headerOnly.has(name))) }) };
70
+ }
71
+ /** The header that delivers the policy. */
72
+ export function policyHeader(policy) {
73
+ return policy.reportOnly ? "content-security-policy-report-only" : "content-security-policy";
74
+ }
75
+ /**
76
+ * The csp option for the development server: what Vite needs beside 'self', which already covers its
77
+ * client and modules. Its HMR WebSocket needs connect-src, and the styles it injects for CSS a
78
+ * module imports need style-src 'unsafe-inline', each only where the policy restricts it.
79
+ */
80
+ export function developmentPolicyOptions(csp, socket) {
81
+ if (csp === false)
82
+ return false;
83
+ const added = {};
84
+ for (const [name, source] of [["connect-src", socket], ["style-src", "'unsafe-inline'"]]) {
85
+ const sources = csp[name] ?? csp["default-src"];
86
+ if (Array.isArray(sources))
87
+ added[name] = [...sources, source];
88
+ }
89
+ return { ...csp, ...added };
90
+ }
91
+ //# sourceMappingURL=csp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.js","sourceRoot":"","sources":["../src/csp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,oGAAoG;AACpG,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;AAEzE,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,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,KAAK,GAAsC,EAAE,CAAC;IACpD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAU,EAAE,CAAC;QAClG,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { ApplicationOptions, ApplicationRoute, EndpointRoute, RouteLayer } from "./types.js";
2
+ /** A declaration reference, never an imported or serialized server module. */
3
+ export type ApplicationServerReference = {
4
+ readonly kind: "file";
5
+ readonly file: string;
6
+ } | {
7
+ readonly kind: "inline";
8
+ };
9
+ export interface ApplicationDescriptionLayer extends Omit<RouteLayer, "server"> {
10
+ readonly server?: ApplicationServerReference;
11
+ }
12
+ export interface ApplicationDescriptionRoute extends Omit<ApplicationRoute, "server" | "layouts"> {
13
+ readonly server?: ApplicationServerReference;
14
+ readonly layouts: readonly ApplicationDescriptionLayer[];
15
+ }
16
+ export interface ApplicationDescriptionSource {
17
+ readonly file: string;
18
+ /** HTML Next source after an explicitly configured page compiler, before presentation lowering. */
19
+ readonly source: string;
20
+ readonly tag: string;
21
+ /** The selected component's authored module specifier. Server route exports are referenced separately. */
22
+ readonly module?: string;
23
+ }
24
+ /** Build-time source inventory. Contains private paths/source; never ship it to a browser or native app. */
25
+ export interface ApplicationDescription {
26
+ readonly version: 1;
27
+ readonly root: string;
28
+ readonly base: string;
29
+ readonly routes: readonly ApplicationDescriptionRoute[];
30
+ readonly notFound?: ApplicationDescriptionRoute;
31
+ readonly error?: ApplicationDescriptionRoute;
32
+ readonly sources: readonly ApplicationDescriptionSource[];
33
+ /** Deployment-relative asset names mapped to original files registered by page compilers. */
34
+ readonly assets: Readonly<Record<string, string>>;
35
+ readonly endpoints: readonly EndpointRoute[];
36
+ readonly middleware?: string;
37
+ readonly redirects: Readonly<Record<string, string>>;
38
+ }
39
+ /**
40
+ * Describe the same declarations web discovery consumes. Explicit plugin config/page hooks run;
41
+ * page/layout modules, loaders, entries, endpoints and middleware do not. Configuration-file loading
42
+ * remains the caller's explicit operation through loadConfig().
43
+ */
44
+ export declare function describeApplication(input?: ApplicationOptions): Promise<ApplicationDescription>;
45
+ //# sourceMappingURL=description.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"description.d.ts","sourceRoot":"","sources":["../src/description.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElG,8EAA8E;AAC9E,MAAM,MAAM,0BAA0B,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AACxH,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,0BAA0B,CAAC;CAC9C;AACD,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,0BAA0B,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,SAAS,2BAA2B,EAAE,CAAC;CAC1D;AACD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mGAAmG;IACnG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0GAA0G;IAC1G,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AACD,4GAA4G;AAC5G,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,2BAA2B,EAAE,CAAC;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,2BAA2B,CAAC;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,2BAA2B,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,SAAS,4BAA4B,EAAE,CAAC;IAC1D,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;AAQD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,GAAE,kBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAazG"}
@@ -0,0 +1,28 @@
1
+ import { discoverApplication } from "./routes.js";
2
+ import { pageDefinition } from "./resource.js";
3
+ function layer({ server, ...value }) {
4
+ return { ...value, ...server === undefined ? {} : { server: typeof server === "string" ? { kind: "file", file: server } : { kind: "inline" } } };
5
+ }
6
+ function route({ layouts, ...value }) {
7
+ return { ...layer(value), layouts: layouts.map(layer) };
8
+ }
9
+ /**
10
+ * Describe the same declarations web discovery consumes. Explicit plugin config/page hooks run;
11
+ * page/layout modules, loaders, entries, endpoints and middleware do not. Configuration-file loading
12
+ * remains the caller's explicit operation through loadConfig().
13
+ */
14
+ export async function describeApplication(input = {}) {
15
+ const { config, discovery, server, redirects } = await discoverApplication(input);
16
+ const all = [...discovery.routes, ...discovery.notFound === undefined ? [] : [discovery.notFound], ...discovery.error === undefined ? [] : [discovery.error]];
17
+ const paths = [...new Set(all.flatMap(route => [...route.layouts.map(layer => layer.component), route.component]))];
18
+ return { version: 1, root: config.root, base: config.base, routes: discovery.routes.map(route),
19
+ ...discovery.notFound === undefined ? {} : { notFound: route(discovery.notFound) },
20
+ ...discovery.error === undefined ? {} : { error: route(discovery.error) },
21
+ sources: await Promise.all(paths.map(async (file) => {
22
+ const snapshot = await discovery.resourceOf(file);
23
+ const definition = pageDefinition(snapshot.resource, file);
24
+ return { file, source: snapshot.source, tag: definition.contract.tag,
25
+ ...definition.module === undefined ? {} : { module: definition.module } };
26
+ })), assets: Object.fromEntries(discovery.files), ...server, redirects: Object.fromEntries(redirects) };
27
+ }
28
+ //# sourceMappingURL=description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"description.js","sourceRoot":"","sources":["../src/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmC/C,SAAS,KAAK,CAAuB,EAAE,MAAM,EAAE,GAAG,KAAK,EAAK;IAC1D,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAA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,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;QAClF,GAAG,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACzE,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;YAChD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG;gBAClE,GAAG,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9E,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;AAC5G,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { RenderedHead, RenderedPage, RenderedPolicy } from "./types.js";
2
+ /**
3
+ * The application document's own head, which pages and layouts' head declarations start from: the
4
+ * viewport, which a page may replace. The charset and head scripts precede it in every document.
5
+ */
6
+ export declare const authoredHead = "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
7
+ /** A page's browser delivery: stylesheet and module URLs, which the serving adapter supplies. */
8
+ export interface PageAssets {
9
+ readonly styles: readonly string[];
10
+ readonly modules: readonly string[];
11
+ }
12
+ export declare function escapeHTML(value: string): string;
13
+ export declare function documentHTML(body: string, head: RenderedHead, assets?: PageAssets): string;
14
+ /**
15
+ * The page at a redirect's old URL, for static hosts without server redirects: a meta refresh and a
16
+ * canonical link to the Location, and a plain link for readers that don't refresh.
17
+ */
18
+ export declare function redirectPage(location: string, policy?: RenderedPolicy): {
19
+ head: RenderedHead;
20
+ body: string;
21
+ html: string;
22
+ };
23
+ /**
24
+ * A page's payload URL: its route path under the reserved _markupkit/pages/ tree, which no route or
25
+ * public file may use, so it never collides with an application's own files.
26
+ */
27
+ export declare function payloadPath(base: string, pathname: string): string;
28
+ /**
29
+ * What the browser needs to render a page in place: the document's head, its delivery, and each
30
+ * layer's invocation and initial state, exactly as the server rendered them. The page's component
31
+ * definitions are in its module. Undefined when JSON cannot carry the state exactly; such a page
32
+ * navigates by its HTML instead.
33
+ */
34
+ export declare function pagePayload(page: Pick<RenderedPage, "status" | "head" | "layers"> & Partial<Pick<RenderedPage, "body" | "prepared">>, assets: PageAssets): {
35
+ version: number;
36
+ head: {
37
+ lang: string;
38
+ canonical?: string;
39
+ };
40
+ rendered?: {
41
+ body: string;
42
+ head: string;
43
+ };
44
+ styles: readonly string[];
45
+ modules: readonly string[];
46
+ layers: readonly import("./types.js").RenderedLayer[];
47
+ } | undefined;
48
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7E;;;GAGG;AACH,eAAO,MAAM,YAAY,6EAAyE,CAAC;AACnG,iGAAiG;AACjG,MAAM,WAAW,UAAU;IAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE;AACvG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AACD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,GAAE,UAAwC,GAAG,MAAM,CASvH;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc;;;;EAKrE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAYD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU;;;;;;;QAOpH,IAAI;QAAc,IAAI;;;;;cAE1D"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The application document's own head, which pages and layouts' head declarations start from: the
3
+ * viewport, which a page may replace. The charset and head scripts precede it in every document.
4
+ */
5
+ export const authoredHead = '<meta name="viewport" content="width=device-width, initial-scale=1">';
6
+ export function escapeHTML(value) {
7
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
8
+ }
9
+ export function documentHTML(body, head, assets = { styles: [], modules: [] }) {
10
+ // Head scripts precede stylesheets, which would otherwise delay them until they load.
11
+ // The policy precedes every script it governs.
12
+ const policy = head.csp?.meta === undefined ? "" : `<meta http-equiv="Content-Security-Policy" content="${head.csp.meta.replace(/&/g, "&amp;").replace(/"/g, "&quot;")}">`;
13
+ return `<!doctype html>\n<html lang="${escapeHTML(head.lang ?? "en")}"><head><meta charset="utf-8">${policy}` +
14
+ (head.scripts ?? []).map(script => `<script>${script}</script>`).join("") + head.html +
15
+ assets.styles.map(href => `<link rel="stylesheet" href="${escapeHTML(href)}">`).join("") +
16
+ assets.modules.map(src => `<script type="module" src="${escapeHTML(src)}"></script>`).join("") +
17
+ `</head><body>${body}</body></html>`;
18
+ }
19
+ /**
20
+ * The page at a redirect's old URL, for static hosts without server redirects: a meta refresh and a
21
+ * canonical link to the Location, and a plain link for readers that don't refresh.
22
+ */
23
+ export function redirectPage(location, policy) {
24
+ const head = { ...(policy === undefined ? {} : { csp: policy }), html: `${authoredHead}<meta http-equiv="refresh" content="0; url=${escapeHTML(location)}">` +
25
+ `<link rel="canonical" href="${escapeHTML(location)}"><title>Redirecting</title>` };
26
+ const body = `<main><p>This page is now at <a href="${escapeHTML(location)}">${escapeHTML(location)}</a>.</p></main>`;
27
+ return { head, body, html: documentHTML(body, head) };
28
+ }
29
+ /**
30
+ * A page's payload URL: its route path under the reserved _markupkit/pages/ tree, which no route or
31
+ * public file may use, so it never collides with an application's own files.
32
+ */
33
+ export function payloadPath(base, pathname) {
34
+ return `${base}_markupkit/pages/${pathname.slice(base.length)}payload.json`;
35
+ }
36
+ /** Whether JSON carries a value exactly: no undefined, -0, non-finite numbers, or shared or opaque objects. */
37
+ function exact(value, seen) {
38
+ if (value === null || typeof value === "string" || typeof value === "boolean")
39
+ return true;
40
+ if (typeof value === "number")
41
+ return Number.isFinite(value) && !Object.is(value, -0);
42
+ if (typeof value !== "object" || seen.has(value) ||
43
+ !Array.isArray(value) && ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
44
+ return false;
45
+ seen.add(value);
46
+ return (Array.isArray(value) ? Array.from(value) : Object.values(value)).every(item => exact(item, seen));
47
+ }
48
+ /**
49
+ * What the browser needs to render a page in place: the document's head, its delivery, and each
50
+ * layer's invocation and initial state, exactly as the server rendered them. The page's component
51
+ * definitions are in its module. Undefined when JSON cannot carry the state exactly; such a page
52
+ * navigates by its HTML instead.
53
+ */
54
+ export function pagePayload(page, assets) {
55
+ if (page.status !== 200 || !page.layers.every(layer => (layer.state === undefined || exact(layer.state, new Set())) &&
56
+ (layer.props === undefined || exact(layer.props, new Set()))))
57
+ return undefined;
58
+ const { lang = "en", canonical } = page.head;
59
+ if (page.prepared && page.body === undefined)
60
+ return undefined;
61
+ return { version: page.prepared ? 2 : 1, head: { lang, ...(canonical === undefined ? {} : { canonical }) },
62
+ ...page.prepared ? { rendered: { body: page.body, head: page.head.html } } : {},
63
+ styles: assets.styles, modules: assets.modules, layers: page.layers };
64
+ }
65
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sEAAsE,CAAC;AAGnG,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjI,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAkB,EAAE,MAAM,GAAe,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7G,sFAAsF;IACtF,+CAA+C;IAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,uDAAuD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC3K,OAAO,gCAAgC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,iCAAiC,MAAM,EAAE;QAC3G,CAAC,IAAI,CAAC,OAAO,IAAI,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C,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAClF,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;IAC7C,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;QACxG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;QAChF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { createApplication } from "./application.js";
2
+ export { buildApplication, readManifest } from "./build.js";
3
+ export { devApplication, previewApplication } from "./serve.js";
4
+ export { startApplication } from "./server.js";
5
+ export type { ServerReader, ServerReaders, ServerReadContext } from "./private-readers.js";
6
+ export type { ComponentBindingDefinition, ComponentBindingModule } from "./component-module.js";
7
+ export { discoverRoutes } from "./routes.js";
8
+ export { MarkupKitError, loadConfig } from "./config.js";
9
+ import type { ApplicationOptions } from "./types.js";
10
+ /** Type-check an markupkit.config.ts file without changing its values. */
11
+ export declare function defineConfig(options: ApplicationOptions): ApplicationOptions;
12
+ export type { Application, ApplicationOptions, ApplicationRoute, ApplicationServer, BrowserDefinition, BuildEndContext, BuildManifest, BuildResult, BuildStartContext, ContentSecurityPolicyOptions, EndpointContext, EndpointHandler, EndpointModule, EndpointRoute, GenerateContext, GeneratedFile, MarkupKitPlugin, PageAction, PageContext, PageDirectory, LoadContext, LoaderResult, ManifestFile, ManifestPage, ManifestRedirect, Middleware, NavigationItem, NavigationNode, NavigationQuery, PagerLinks, PageHead, PrefetchPolicy, RedirectStatus, RenderedHead, RenderedLayer, RenderedPolicy, RenderedPage, RouteGroup, RouteInput, RouteLayer, RouteParam, ServerApplication, ServerModule, ServerOptions, StartOptions } from "./types.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,YAAY,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAAoB;AACjG,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,4BAA4B,EACjM,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAC/M,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAChL,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { createApplication } from "./application.js";
2
+ export { buildApplication, readManifest } from "./build.js";
3
+ export { devApplication, previewApplication } from "./serve.js";
4
+ export { startApplication } from "./server.js";
5
+ export { discoverRoutes } from "./routes.js";
6
+ export { MarkupKitError, loadConfig } from "./config.js";
7
+ /** Type-check an markupkit.config.ts file without changing its values. */
8
+ export function defineConfig(options) { return options; }
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,OAA2B,IAAwB,OAAO,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Fail when a link in a built document points under base at a page or file the output lacks, or at a
3
+ * #fragment that names no element in its page. It reads the output, as a static host serves it.
4
+ * documents are the deployment pathnames of the HTML the build rendered, and served names the paths a
5
+ * server answers on request, such as server-rendered pages and endpoints, which have no file.
6
+ */
7
+ export declare function checkLinks(outDir: string, origin: string, base: string, documents: readonly string[], mode?: "error" | "warn", served?: (pathname: string) => boolean): Promise<void>;
8
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,GAAE,OAAO,GAAG,MAAgB,EAC3I,MAAM,GAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCpE"}