@riebeckite/honox 0.0.4 → 0.0.6
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 +1 -1
- package/README_ja.md +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2472 -984
- package/dist/server.js +25 -3
- package/dist/src/endpoints.d.ts +15 -0
- package/dist/src/honox_islands.d.ts +2 -4
- package/dist/src/scaffold/index.d.ts +2 -0
- package/dist/src/scaffold/localized-content.d.ts +10 -11
- package/dist/src/scaffold/next-steps.d.ts +1 -0
- package/dist/src/scaffold/presets.d.ts +105 -0
- package/dist/src/scaffold/presets.js +656 -0
- package/dist/src/scaffold/templates.d.ts +38 -1
- package/dist/src/scaffold/version.d.ts +1 -0
- package/package.json +8 -2
package/dist/server.js
CHANGED
|
@@ -48,14 +48,22 @@ function decodeSegment(segment) {
|
|
|
48
48
|
function mountRiebeckiteEndpoints(app, options) {
|
|
49
49
|
const endpoints = collectPluginEndpoints(options.config);
|
|
50
50
|
for (const endpoint of endpoints) {
|
|
51
|
-
|
|
51
|
+
const method = endpoint.method ?? "GET";
|
|
52
|
+
const handler = async (context) => {
|
|
52
53
|
const manifest = await options.content.getManifest();
|
|
54
|
+
const request = await toPluginEndpointRequest(context, method);
|
|
53
55
|
const response = await endpoint.handler({
|
|
54
56
|
config: options.config,
|
|
55
|
-
manifest
|
|
57
|
+
manifest,
|
|
58
|
+
request
|
|
56
59
|
});
|
|
57
60
|
return toHonoResponse(context, response);
|
|
58
|
-
}
|
|
61
|
+
};
|
|
62
|
+
if (method === "POST") {
|
|
63
|
+
app.post(endpoint.path, handler);
|
|
64
|
+
} else {
|
|
65
|
+
app.get(endpoint.path, handler);
|
|
66
|
+
}
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
function collectPluginEndpoints(config) {
|
|
@@ -102,6 +110,20 @@ function validateEndpointPath(path) {
|
|
|
102
110
|
);
|
|
103
111
|
}
|
|
104
112
|
}
|
|
113
|
+
async function toPluginEndpointRequest(context, method) {
|
|
114
|
+
const headers = {};
|
|
115
|
+
context.req.raw.headers.forEach((value, key) => {
|
|
116
|
+
headers[key.toLowerCase()] = value;
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
method,
|
|
120
|
+
url: context.req.url,
|
|
121
|
+
path: context.req.path,
|
|
122
|
+
query: context.req.query(),
|
|
123
|
+
headers,
|
|
124
|
+
body: await context.req.text()
|
|
125
|
+
};
|
|
126
|
+
}
|
|
105
127
|
function toHonoResponse(context, response) {
|
|
106
128
|
const status = response.status ?? 200;
|
|
107
129
|
if ("json" in response) {
|
package/dist/src/endpoints.d.ts
CHANGED
|
@@ -5,8 +5,23 @@ export type RiebeckiteEndpointMountOptions = {
|
|
|
5
5
|
};
|
|
6
6
|
type HonoLikeApp = {
|
|
7
7
|
get(path: string, handler: (context: HonoLikeContext) => Promise<unknown>): void;
|
|
8
|
+
post(path: string, handler: (context: HonoLikeContext) => Promise<unknown>): void;
|
|
9
|
+
};
|
|
10
|
+
type HonoLikeHeaders = {
|
|
11
|
+
forEach(callback: (value: string, key: string) => void): void;
|
|
12
|
+
};
|
|
13
|
+
type HonoLikeRequest = {
|
|
14
|
+
method: string;
|
|
15
|
+
url: string;
|
|
16
|
+
path: string;
|
|
17
|
+
raw: {
|
|
18
|
+
headers: HonoLikeHeaders;
|
|
19
|
+
};
|
|
20
|
+
query(): Record<string, string>;
|
|
21
|
+
text(): Promise<string>;
|
|
8
22
|
};
|
|
9
23
|
type HonoLikeContext = {
|
|
24
|
+
req: HonoLikeRequest;
|
|
10
25
|
json(body: unknown, status?: number, headers?: Record<string, string>): unknown;
|
|
11
26
|
body(body: string, status?: number, headers?: Record<string, string>): unknown;
|
|
12
27
|
text(body: string, status?: number, headers?: Record<string, string>): unknown;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type HonoxPlugin = Plugin | Promise<Plugin>;
|
|
1
|
+
import type { PluginOption } from "vite";
|
|
3
2
|
/**
|
|
4
3
|
* Replaces HonoX's dependency walker with one that remains inside the app
|
|
5
4
|
* directory. Riebeckite configurations import plugins with large dependency
|
|
6
5
|
* graphs, which must not be traversed merely to determine whether a route
|
|
7
6
|
* imports an island.
|
|
8
7
|
*/
|
|
9
|
-
export declare function replaceHonoxIslandDependencyPlugin(plugins:
|
|
10
|
-
export {};
|
|
8
|
+
export declare function replaceHonoxIslandDependencyPlugin(plugins: PluginOption[]): PluginOption[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ScaffoldPreset, type ScaffoldPresetName } from "./presets.js";
|
|
1
2
|
export type ScaffoldSiteOptions = {
|
|
2
3
|
readonly targetDirectory: string;
|
|
3
4
|
readonly name?: string;
|
|
@@ -5,6 +6,7 @@ export type ScaffoldSiteOptions = {
|
|
|
5
6
|
readonly description?: string;
|
|
6
7
|
readonly baseUrl?: string;
|
|
7
8
|
readonly locale?: string;
|
|
9
|
+
readonly preset?: ScaffoldPresetName | ScaffoldPreset;
|
|
8
10
|
readonly overwrite?: boolean;
|
|
9
11
|
};
|
|
10
12
|
export type ScaffoldSiteResult = {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export type ScaffoldLanguage = (typeof SCAFFOLD_LANGUAGES)[number];
|
|
4
|
-
export declare function defaultLanguageForLocale(locale: string): string;
|
|
1
|
+
import { type ScaffoldPreset } from "./presets.js";
|
|
2
|
+
import { type SiteTemplateFile, type SiteTemplateVariables } from "./templates.js";
|
|
5
3
|
/**
|
|
6
|
-
* Generates the
|
|
4
|
+
* Generates the content pages for a scaffold preset.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* Localized pages (`index`, `framework/plugins`, `framework/themes`) follow the
|
|
7
|
+
* l10n plugin convention: the default-language page keeps the plain name
|
|
8
|
+
* (`index.md`) while every other language uses the `<base>.<lang>.md` suffix.
|
|
9
|
+
* Presets without l10n emit the index in the site's default language only.
|
|
10
|
+
* Extra pages (`guide`, `examples`, `reference/*`) are English-only and are
|
|
11
|
+
* suffixed with `.en` when English is not the site's default language.
|
|
13
12
|
*/
|
|
14
|
-
export declare function localizedContentFiles(variables: SiteTemplateVariables): readonly SiteTemplateFile[];
|
|
13
|
+
export declare function localizedContentFiles(variables: SiteTemplateVariables, preset: ScaffoldPreset): readonly SiteTemplateFile[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatScaffoldNextSteps(relativeDirectory: string): string;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaffold presets.
|
|
3
|
+
*
|
|
4
|
+
* A preset is the declarative description of one starter template. The
|
|
5
|
+
* scaffolder consumes a preset to decide which files it generates:
|
|
6
|
+
*
|
|
7
|
+
* - which plugins are registered in `riebeckite.config.ts`
|
|
8
|
+
* - which theme is applied
|
|
9
|
+
* - which content pages are emitted (localized, or English-only extras)
|
|
10
|
+
* - which `app/` shell files are written
|
|
11
|
+
*
|
|
12
|
+
* Presets are cumulative in spirit but defined explicitly so each tier is
|
|
13
|
+
* self-contained and can be imported and reused on its own:
|
|
14
|
+
*
|
|
15
|
+
* import { full, starter } from "@riebeckite/honox/scaffold";
|
|
16
|
+
*/
|
|
17
|
+
export declare const SCAFFOLD_LANGUAGES: readonly ["en", "ja", "zh-CN", "es", "de", "fr", "ko"];
|
|
18
|
+
export type ScaffoldLanguage = (typeof SCAFFOLD_LANGUAGES)[number];
|
|
19
|
+
export declare function defaultLanguageForLocale(locale: string): string;
|
|
20
|
+
export type ScaffoldPresetName = "empty" | "minimal" | "starter" | "rich" | "full" | "max" | "ultra";
|
|
21
|
+
export declare const SCAFFOLD_PRESET_NAMES: readonly ScaffoldPresetName[];
|
|
22
|
+
export declare function isScaffoldPresetName(value: string): value is ScaffoldPresetName;
|
|
23
|
+
/** How a theme factory is referenced in the generated config file. */
|
|
24
|
+
export type ScaffoldThemeSpec = {
|
|
25
|
+
/** Npm package, for example `@riebeckite/theme-minimal`. */
|
|
26
|
+
readonly package: string;
|
|
27
|
+
/** Factory/import name, for example `minimalTheme`. */
|
|
28
|
+
readonly factory: string;
|
|
29
|
+
/** Optional literal source for the factory call arguments, e.g. `{ colorMode: "light" }`. */
|
|
30
|
+
readonly options?: string;
|
|
31
|
+
};
|
|
32
|
+
/** How a plugin factory is referenced in the generated config file. */
|
|
33
|
+
export type ScaffoldPluginSpec = {
|
|
34
|
+
/** Npm package, for example `@riebeckite/plugin-seo`. */
|
|
35
|
+
readonly package: string;
|
|
36
|
+
/** Factory/import name, for example `seo`. */
|
|
37
|
+
readonly factory: string;
|
|
38
|
+
/** Options source for the factory call; see {@link ScaffoldOptions}. */
|
|
39
|
+
readonly options?: ScaffoldOptions;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Context passed to option sources. `variables` are the user-supplied site
|
|
43
|
+
* values (`title`, `baseUrl`, ...), `languages` the preset's configured
|
|
44
|
+
* languages, and `depth` the preset tier: 1 = rich essentials,
|
|
45
|
+
* 2 = full/max standard set, 3 = ultra full coverage.
|
|
46
|
+
*/
|
|
47
|
+
export type ScaffoldOptionContext = {
|
|
48
|
+
readonly variables: {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly title: string;
|
|
51
|
+
readonly description: string;
|
|
52
|
+
readonly baseUrl: string;
|
|
53
|
+
readonly locale: string;
|
|
54
|
+
};
|
|
55
|
+
readonly languages: readonly ScaffoldLanguage[];
|
|
56
|
+
readonly depth: number;
|
|
57
|
+
};
|
|
58
|
+
/** A single option value: a literal, or a function of the scaffold context. */
|
|
59
|
+
export type ScaffoldOptionValue = string | ((context: ScaffoldOptionContext) => string);
|
|
60
|
+
/** A config field gated to a minimum preset depth. */
|
|
61
|
+
export type ScaffoldOptionField = {
|
|
62
|
+
/** The lowest `ScaffoldOptionContext.depth` that includes this field. */
|
|
63
|
+
readonly depth: number;
|
|
64
|
+
readonly value: ScaffoldOptionValue;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Options for a generated plugin call: a literal source string, a function
|
|
68
|
+
* producing one, or a field map whose fields appear from a minimum depth.
|
|
69
|
+
* The field map form lets each preset tier demonstrate the configuration
|
|
70
|
+
* surface step by step while keeping one source of truth per plugin.
|
|
71
|
+
*/
|
|
72
|
+
export type ScaffoldOptions = string | ((context: ScaffoldOptionContext) => string) | Readonly<Record<string, ScaffoldOptionField>>;
|
|
73
|
+
/** Content pages the scaffold can emit. */
|
|
74
|
+
export type ScaffoldPageKey = "index" | "framework/plugins" | "framework/themes" | "guide" | "examples" | "reference/plugins" | "reference/themes";
|
|
75
|
+
/** `app/` shell files the scaffold can emit. */
|
|
76
|
+
export type ScaffoldAppFileKey = "server" | "client" | "config" | "content" | "paths" | "global" | "style" | "renderer" | "index" | "slug" | "header" | "article";
|
|
77
|
+
/** README verbosity. */
|
|
78
|
+
export type ScaffoldReadmeLevel = "short" | "standard" | "rich";
|
|
79
|
+
export type ScaffoldPreset = {
|
|
80
|
+
readonly name: ScaffoldPresetName;
|
|
81
|
+
/** One-line human description, shown by `--list-presets`. */
|
|
82
|
+
readonly description: string;
|
|
83
|
+
/** Languages the l10n plugin is configured with. A single entry means no l10n. */
|
|
84
|
+
readonly languages: readonly ScaffoldLanguage[];
|
|
85
|
+
readonly theme: ScaffoldThemeSpec | null;
|
|
86
|
+
readonly plugins: readonly ScaffoldPluginSpec[];
|
|
87
|
+
readonly contentPages: readonly ScaffoldPageKey[];
|
|
88
|
+
/**
|
|
89
|
+
* Order-sensitive; the scaffolder writes `app/` files in this order.
|
|
90
|
+
* Structural files (`server`, `client`, `config`, `content`, `paths`,
|
|
91
|
+
* `global`, `style`, `renderer`) are always included.
|
|
92
|
+
*/
|
|
93
|
+
readonly appFiles: readonly ScaffoldAppFileKey[];
|
|
94
|
+
readonly readme: ScaffoldReadmeLevel;
|
|
95
|
+
};
|
|
96
|
+
export declare const empty: ScaffoldPreset;
|
|
97
|
+
export declare const minimal: ScaffoldPreset;
|
|
98
|
+
export declare const starter: ScaffoldPreset;
|
|
99
|
+
export declare const rich: ScaffoldPreset;
|
|
100
|
+
export declare const full: ScaffoldPreset;
|
|
101
|
+
export declare const max: ScaffoldPreset;
|
|
102
|
+
export declare const ultra: ScaffoldPreset;
|
|
103
|
+
export declare const scaffoldPresets: Readonly<Record<ScaffoldPresetName, ScaffoldPreset>>;
|
|
104
|
+
export declare const SCAFFOLD_DEFAULT_PRESET: ScaffoldPresetName;
|
|
105
|
+
export declare function resolveScaffoldPreset(value: ScaffoldPresetName | ScaffoldPreset | undefined): ScaffoldPreset;
|