@moku-labs/web 0.1.0-alpha.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +64 -51
- package/dist/chunk-D7D4PA-g.mjs +13 -0
- package/dist/index.cjs +5972 -113
- package/dist/index.d.cts +2078 -106
- package/dist/index.d.mts +2078 -106
- package/dist/index.mjs +5859 -33
- package/package.json +65 -65
- package/dist/bin/moku.cjs +0 -1383
- package/dist/bin/moku.d.cts +0 -1
- package/dist/bin/moku.d.mts +0 -1
- package/dist/bin/moku.mjs +0 -1383
- package/dist/chunk-DQk6qfdC.mjs +0 -18
- package/dist/factory-CMOo4n6a.cjs +0 -1722
- package/dist/factory-DRFGSslp.d.mts +0 -114
- package/dist/factory-DiKypQqs.mjs +0 -1602
- package/dist/factory-k-YoScgB.d.cts +0 -114
- package/dist/index-DH3jlpNi.d.mts +0 -503
- package/dist/index-DaY7vTuo.d.cts +0 -503
- package/dist/plugins/head/build.cjs +0 -35
- package/dist/plugins/head/build.d.cts +0 -17
- package/dist/plugins/head/build.d.mts +0 -17
- package/dist/plugins/head/build.mjs +0 -27
- package/dist/plugins/spa/index.cjs +0 -26
- package/dist/plugins/spa/index.d.cts +0 -30
- package/dist/plugins/spa/index.d.mts +0 -30
- package/dist/plugins/spa/index.mjs +0 -24
- package/dist/primitives-BYUp6kae.cjs +0 -100
- package/dist/primitives-DKgZfRAO.d.mts +0 -71
- package/dist/primitives-Dhko-oLM.mjs +0 -58
- package/dist/primitives-yZqQkOVR.d.cts +0 -71
- package/dist/project-B8z4jeMC.cjs +0 -1383
- package/dist/project-guCYpUeD.mjs +0 -1244
- package/dist/test.cjs +0 -82
- package/dist/test.d.cts +0 -61
- package/dist/test.d.mts +0 -61
- package/dist/test.mjs +0 -79
- package/dist/wrangler-BlZWVmX9.mjs +0 -369
- package/dist/wrangler-Bomk9mU-.cjs +0 -423
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
declare namespace types_d_exports {
|
|
2
|
-
export { ComponentDef, ComponentHooks, ComponentInstance, ComponentMap, ComponentsSubApi, EventBus, EventBusListener, HeadSubApi, LifecycleEventMap, MountContext, NavEndContext, NavStartContext, PageData, ProgressSubApi, RouterHandlers, RouterSubApi, SpaApi, SpaConfig, SpaRuntime, SpaState, UnMountContext };
|
|
3
|
-
}
|
|
4
|
-
/** @file spa plugin shared types — config envelope, composed state, composed API, ComponentDef. */
|
|
5
|
-
type ComponentHooks = {
|
|
6
|
-
onCreate?(element: Element): void;
|
|
7
|
-
onMount?(ctx: {
|
|
8
|
-
container: Element;
|
|
9
|
-
pageData?: unknown;
|
|
10
|
-
url: string;
|
|
11
|
-
}): void;
|
|
12
|
-
onNavStart?(ctx: {
|
|
13
|
-
url: string;
|
|
14
|
-
fromUrl: string;
|
|
15
|
-
}): void;
|
|
16
|
-
onNavEnd?(ctx: {
|
|
17
|
-
url: string;
|
|
18
|
-
pageData?: unknown;
|
|
19
|
-
doc?: Document;
|
|
20
|
-
}): void;
|
|
21
|
-
onUnMount?(ctx: {
|
|
22
|
-
reason: 'navigation' | 'destroy';
|
|
23
|
-
element: Element;
|
|
24
|
-
}): void | Promise<void>;
|
|
25
|
-
onDestroy?(element: Element): void;
|
|
26
|
-
};
|
|
27
|
-
type ComponentDef = {
|
|
28
|
-
name: string;
|
|
29
|
-
hooks: ComponentHooks;
|
|
30
|
-
};
|
|
31
|
-
type ComponentInstance = {
|
|
32
|
-
def: ComponentDef;
|
|
33
|
-
element: Element;
|
|
34
|
-
};
|
|
35
|
-
type SpaRuntime = {
|
|
36
|
-
viewTransitions?: boolean;
|
|
37
|
-
progressBar?: boolean;
|
|
38
|
-
};
|
|
39
|
-
/** Synthetic envelope: `spa` blog key → config; `components` blog key → components. Documented per acknowledged risk. */
|
|
40
|
-
type SpaConfig = {
|
|
41
|
-
config: SpaRuntime;
|
|
42
|
-
components: ComponentDef[];
|
|
43
|
-
};
|
|
44
|
-
type ComponentMap = ComponentDef[];
|
|
45
|
-
type EventBusListener = (payload: unknown) => void;
|
|
46
|
-
type EventBus = {
|
|
47
|
-
on(event: string, listener: EventBusListener): () => void;
|
|
48
|
-
emit(event: string, payload: unknown): void;
|
|
49
|
-
};
|
|
50
|
-
type SpaState = {
|
|
51
|
-
router: {
|
|
52
|
-
currentUrl: string;
|
|
53
|
-
history: string[];
|
|
54
|
-
};
|
|
55
|
-
head: {
|
|
56
|
-
currentDoc: Document | null;
|
|
57
|
-
};
|
|
58
|
-
progress: {
|
|
59
|
-
active: boolean;
|
|
60
|
-
visible: boolean;
|
|
61
|
-
};
|
|
62
|
-
components: {
|
|
63
|
-
instances: Map<Element, ComponentInstance>;
|
|
64
|
-
registered: ComponentDef[];
|
|
65
|
-
};
|
|
66
|
-
eventBus: EventBus;
|
|
67
|
-
};
|
|
68
|
-
type RouterSubApi = {
|
|
69
|
-
navigate(url: string): Promise<void>;
|
|
70
|
-
current(): string;
|
|
71
|
-
destroy(): void;
|
|
72
|
-
};
|
|
73
|
-
type HeadSubApi = {
|
|
74
|
-
update(doc: Document): void;
|
|
75
|
-
};
|
|
76
|
-
type ProgressSubApi = {
|
|
77
|
-
start(): void;
|
|
78
|
-
done(): void;
|
|
79
|
-
};
|
|
80
|
-
type ComponentsSubApi = {
|
|
81
|
-
register(def: ComponentDef): void;
|
|
82
|
-
};
|
|
83
|
-
type SpaApi = {
|
|
84
|
-
router: RouterSubApi;
|
|
85
|
-
head: HeadSubApi;
|
|
86
|
-
progress: ProgressSubApi;
|
|
87
|
-
components: ComponentsSubApi;
|
|
88
|
-
};
|
|
89
|
-
type MountContext = {
|
|
90
|
-
container: Element;
|
|
91
|
-
pageData?: unknown;
|
|
92
|
-
url: string;
|
|
93
|
-
};
|
|
94
|
-
type NavStartContext = {
|
|
95
|
-
url: string;
|
|
96
|
-
fromUrl: string;
|
|
97
|
-
};
|
|
98
|
-
type NavEndContext = {
|
|
99
|
-
url: string;
|
|
100
|
-
pageData?: unknown;
|
|
101
|
-
doc?: Document;
|
|
102
|
-
};
|
|
103
|
-
type UnMountContext = {
|
|
104
|
-
reason: 'navigation' | 'destroy';
|
|
105
|
-
element: Element;
|
|
106
|
-
};
|
|
107
|
-
type PageData = unknown;
|
|
108
|
-
type RouterHandlers = unknown;
|
|
109
|
-
type LifecycleEventMap = unknown;
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/plugins/spa/components/factory.d.ts
|
|
112
|
-
declare const createComponent: (name: string, hooks: ComponentHooks) => ComponentDef;
|
|
113
|
-
//#endregion
|
|
114
|
-
export { SpaConfig as a, SpaApi as i, ComponentDef as n, SpaState as o, ComponentHooks as r, types_d_exports as s, createComponent as t };
|
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
import { d as HeadPluginConfig, f as HeadState, l as HeadApi, p as OGImageConfig } from "./primitives-DKgZfRAO.mjs";
|
|
2
|
-
import { n as ComponentDef } from "./factory-DRFGSslp.mjs";
|
|
3
|
-
import * as _moku_labs_core0 from "@moku-labs/core";
|
|
4
|
-
import { Processor } from "unified";
|
|
5
|
-
|
|
6
|
-
//#region src/plugins/log/types.d.ts
|
|
7
|
-
declare namespace types_d_exports$7 {
|
|
8
|
-
export { ExpectChain, LogApi, LogConfig, LogEntry, LogLevel, LogSink, LogState };
|
|
9
|
-
}
|
|
10
|
-
/** @file log plugin types — LogEntry, LogSink, ExpectChain, LogState, LogApi. */
|
|
11
|
-
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
12
|
-
type LogEntry = {
|
|
13
|
-
level: LogLevel;
|
|
14
|
-
event: string;
|
|
15
|
-
data?: unknown;
|
|
16
|
-
ts: number;
|
|
17
|
-
plugin?: string;
|
|
18
|
-
};
|
|
19
|
-
type LogSink = {
|
|
20
|
-
write(entry: LogEntry): void;
|
|
21
|
-
};
|
|
22
|
-
type ExpectChain = {
|
|
23
|
-
toHaveEvent(event: string, partial?: Record<string, unknown>): ExpectChain;
|
|
24
|
-
toHaveEventInOrder(events: string[]): ExpectChain;
|
|
25
|
-
toNotHaveEvent(event: string, partial?: Record<string, unknown>): ExpectChain;
|
|
26
|
-
};
|
|
27
|
-
type LogState = {
|
|
28
|
-
entries: LogEntry[];
|
|
29
|
-
sinks: LogSink[];
|
|
30
|
-
};
|
|
31
|
-
type LogConfig = {
|
|
32
|
-
level: LogLevel;
|
|
33
|
-
mode: 'auto' | 'production' | 'test' | 'dev';
|
|
34
|
-
};
|
|
35
|
-
type LogApi = {
|
|
36
|
-
info(event: string, data?: unknown): void;
|
|
37
|
-
debug(event: string, data?: unknown): void;
|
|
38
|
-
warn(event: string, data?: unknown): void;
|
|
39
|
-
error(event: string, data?: unknown, error?: Error): void;
|
|
40
|
-
trace(): readonly LogEntry[];
|
|
41
|
-
expect(): ExpectChain;
|
|
42
|
-
addSink(sink: LogSink): void;
|
|
43
|
-
reset(): void;
|
|
44
|
-
};
|
|
45
|
-
declare namespace types_d_exports$6 {
|
|
46
|
-
export { EnvApi, EnvConfig, EnvProvider, EnvState, EnvVarSpec };
|
|
47
|
-
}
|
|
48
|
-
/** @file env plugin types — schema, provider, EnvApi. */
|
|
49
|
-
type EnvVarSpec = {
|
|
50
|
-
public: boolean;
|
|
51
|
-
required?: boolean;
|
|
52
|
-
default?: string;
|
|
53
|
-
secret?: boolean;
|
|
54
|
-
};
|
|
55
|
-
type EnvProvider = {
|
|
56
|
-
name: string;
|
|
57
|
-
load(): Record<string, string | undefined>;
|
|
58
|
-
};
|
|
59
|
-
type EnvConfig = {
|
|
60
|
-
schema: Record<string, EnvVarSpec>;
|
|
61
|
-
providers: EnvProvider[];
|
|
62
|
-
publicPrefix: string;
|
|
63
|
-
};
|
|
64
|
-
type EnvState = {
|
|
65
|
-
resolved: Map<string, string>;
|
|
66
|
-
publicMap: Map<string, string>;
|
|
67
|
-
};
|
|
68
|
-
type EnvApi = {
|
|
69
|
-
get<K extends string>(key: K): string | undefined;
|
|
70
|
-
require(key: string): string;
|
|
71
|
-
getPublic(): Readonly<Record<string, string>>;
|
|
72
|
-
getPublicMap(): ReadonlyMap<string, string>;
|
|
73
|
-
has(key: string): boolean;
|
|
74
|
-
};
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/config.d.ts
|
|
77
|
-
/** Top-level framework config — flows to all plugins via context. */
|
|
78
|
-
type Config = {
|
|
79
|
-
mode: 'production' | 'development';
|
|
80
|
-
};
|
|
81
|
-
/** Framework-level event map — plugin-specific events added by each plugin's events field. */
|
|
82
|
-
type Events = {
|
|
83
|
-
'content:ready': {
|
|
84
|
-
articles: Map<string, unknown[]>;
|
|
85
|
-
};
|
|
86
|
-
'content:invalidated': {
|
|
87
|
-
paths: string[];
|
|
88
|
-
};
|
|
89
|
-
'router:registered': {
|
|
90
|
-
routeCount: number;
|
|
91
|
-
};
|
|
92
|
-
'build:phase': {
|
|
93
|
-
phase: 'bundle' | 'content' | 'pages' | 'feeds' | 'sitemap' | 'og' | 'images';
|
|
94
|
-
};
|
|
95
|
-
'build:complete': {
|
|
96
|
-
pages: number;
|
|
97
|
-
durationMs: number;
|
|
98
|
-
};
|
|
99
|
-
'component:create': {
|
|
100
|
-
name: string;
|
|
101
|
-
element: Element;
|
|
102
|
-
};
|
|
103
|
-
'component:mount': {
|
|
104
|
-
name: string;
|
|
105
|
-
element: Element;
|
|
106
|
-
};
|
|
107
|
-
'component:unmount': {
|
|
108
|
-
name: string;
|
|
109
|
-
reason: 'navigation' | 'destroy';
|
|
110
|
-
};
|
|
111
|
-
'component:destroy': {
|
|
112
|
-
name: string;
|
|
113
|
-
};
|
|
114
|
-
'nav:start': {
|
|
115
|
-
url: string;
|
|
116
|
-
fromUrl: string;
|
|
117
|
-
};
|
|
118
|
-
'nav:end': {
|
|
119
|
-
url: string;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
declare const createPlugin: _moku_labs_core0.BoundCreatePluginFunction<Config, Events, _moku_labs_core0.CoreApisFromTuple<[_moku_labs_core0.CorePluginInstance<"log", {
|
|
123
|
-
level: "info";
|
|
124
|
-
mode: "auto";
|
|
125
|
-
}, LogState, LogApi>, _moku_labs_core0.CorePluginInstance<"env", {
|
|
126
|
-
schema: {};
|
|
127
|
-
providers: never[];
|
|
128
|
-
publicPrefix: string;
|
|
129
|
-
}, EnvState, EnvApi>]>>, createCore: _moku_labs_core0.BoundCreateCoreFunction<Config, Events, [_moku_labs_core0.CorePluginInstance<"log", {
|
|
130
|
-
level: "info";
|
|
131
|
-
mode: "auto";
|
|
132
|
-
}, LogState, LogApi>, _moku_labs_core0.CorePluginInstance<"env", {
|
|
133
|
-
schema: {};
|
|
134
|
-
providers: never[];
|
|
135
|
-
publicPrefix: string;
|
|
136
|
-
}, EnvState, EnvApi>]>;
|
|
137
|
-
declare namespace types_d_exports$5 {
|
|
138
|
-
export { SiteApi, SiteConfig, SiteState };
|
|
139
|
-
}
|
|
140
|
-
/** @file site plugin types — SiteConfig + SiteState + SiteApi. */
|
|
141
|
-
type SiteConfig = {
|
|
142
|
-
/** Display name of the site. */name: string; /** Base URL of the site (no trailing slash). */
|
|
143
|
-
url: string; /** Default author name for content. */
|
|
144
|
-
author: string; /** Site description for feeds, meta tags, and preview pages. */
|
|
145
|
-
description: string;
|
|
146
|
-
};
|
|
147
|
-
type SiteState = {
|
|
148
|
-
config: Readonly<SiteConfig>;
|
|
149
|
-
};
|
|
150
|
-
type SiteApi = {
|
|
151
|
-
get(): Readonly<SiteConfig>;
|
|
152
|
-
name(): string;
|
|
153
|
-
url(): string;
|
|
154
|
-
author(): string;
|
|
155
|
-
description(): string;
|
|
156
|
-
};
|
|
157
|
-
declare namespace types_d_exports$4 {
|
|
158
|
-
export { I18nApi, I18nConfig, I18nState };
|
|
159
|
-
}
|
|
160
|
-
/** @file i18n plugin types — I18nConfig (generic over locale tuple), I18nState, I18nApi. */
|
|
161
|
-
type I18nConfig<TLocales extends readonly string[] = readonly string[]> = {
|
|
162
|
-
/** Active locale codes (literal tuple preserved). */locales: TLocales; /** Default locale (must be member of locales). */
|
|
163
|
-
defaultLocale: TLocales[number]; /** Display names per locale. */
|
|
164
|
-
localeNames: Record<TLocales[number], string>; /** OG locale format mapping (e.g., { en: 'en_US' }). */
|
|
165
|
-
ogLocaleMap?: Partial<Record<TLocales[number], string>>; /** UI translation strings per locale. */
|
|
166
|
-
translations?: Record<TLocales[number], Record<string, string>>;
|
|
167
|
-
};
|
|
168
|
-
type I18nState<TLocales extends readonly string[] = readonly string[]> = {
|
|
169
|
-
config: Readonly<I18nConfig<TLocales>>;
|
|
170
|
-
};
|
|
171
|
-
type I18nApi<TLocales extends readonly string[] = readonly string[]> = {
|
|
172
|
-
locales(): TLocales;
|
|
173
|
-
defaultLocale(): TLocales[number];
|
|
174
|
-
localeName(locale: TLocales[number]): string;
|
|
175
|
-
ogLocale(locale: TLocales[number]): string;
|
|
176
|
-
t(locale: TLocales[number], key: string): string;
|
|
177
|
-
};
|
|
178
|
-
declare namespace types_d_exports$3 {
|
|
179
|
-
export { Article, ComputedFields, ContentApi, ContentConfig, ContentState, Frontmatter, RehypePluginEntry, RemarkPluginEntry };
|
|
180
|
-
}
|
|
181
|
-
type Frontmatter = {
|
|
182
|
-
title: string;
|
|
183
|
-
date: string;
|
|
184
|
-
description: string;
|
|
185
|
-
tags: string[];
|
|
186
|
-
language: string;
|
|
187
|
-
author?: string;
|
|
188
|
-
draft?: boolean;
|
|
189
|
-
[key: string]: unknown;
|
|
190
|
-
};
|
|
191
|
-
type ComputedFields = {
|
|
192
|
-
contentId: string;
|
|
193
|
-
readingTimeMinutes: number;
|
|
194
|
-
wordCount: number;
|
|
195
|
-
};
|
|
196
|
-
type Article = {
|
|
197
|
-
slug: string;
|
|
198
|
-
locale: string;
|
|
199
|
-
frontmatter: Frontmatter;
|
|
200
|
-
html: string;
|
|
201
|
-
computed: ComputedFields;
|
|
202
|
-
};
|
|
203
|
-
type RehypePluginEntry = readonly [unknown, Record<string, unknown>?];
|
|
204
|
-
type RemarkPluginEntry = readonly [unknown, Record<string, unknown>?];
|
|
205
|
-
type ContentConfig = {
|
|
206
|
-
dir: string;
|
|
207
|
-
defaultAuthor?: string;
|
|
208
|
-
trustedContent: boolean;
|
|
209
|
-
rehypePlugins?: RehypePluginEntry[];
|
|
210
|
-
remarkPlugins?: RemarkPluginEntry[];
|
|
211
|
-
};
|
|
212
|
-
type ContentState = {
|
|
213
|
-
processor: Processor | null;
|
|
214
|
-
articles: Map<string, Map<string, Article>>;
|
|
215
|
-
slugs: string[] | null;
|
|
216
|
-
lastPaths: Set<string>; /** Paths marked stale by `invalidate()` — re-read on next `loadAll()` then cleared. */
|
|
217
|
-
dirtyPaths: Set<string>;
|
|
218
|
-
};
|
|
219
|
-
type ContentApi = {
|
|
220
|
-
loadAll(): Promise<Map<string, Article[]>>;
|
|
221
|
-
load(slug: string, locale: string): Promise<Article | null>;
|
|
222
|
-
discoverSlugs(): Promise<string[]>;
|
|
223
|
-
render(markdown: string): Promise<string>;
|
|
224
|
-
invalidate(paths: string[]): void;
|
|
225
|
-
reset(): void;
|
|
226
|
-
};
|
|
227
|
-
declare namespace types_d_exports$2 {
|
|
228
|
-
export { HeadConfig, LayoutComponent, RenderContext, RouteBuilder, RouteEntry, RouteSpec, RouterApi, RouterConfig, RouterState, VNode };
|
|
229
|
-
}
|
|
230
|
-
/** @file router plugin types — RouteSpec (non-accumulating), RouteBuilder, RouterApi. */
|
|
231
|
-
/** Render context passed to route handlers. */
|
|
232
|
-
type RenderContext = {
|
|
233
|
-
url: string;
|
|
234
|
-
locale: string;
|
|
235
|
-
params: Record<string, string>;
|
|
236
|
-
data?: unknown;
|
|
237
|
-
};
|
|
238
|
-
type LayoutComponent = unknown;
|
|
239
|
-
type VNode = unknown;
|
|
240
|
-
type HeadConfig = unknown;
|
|
241
|
-
type RouteSpec = {
|
|
242
|
-
pattern: string;
|
|
243
|
-
load?: (params: Record<string, string>) => unknown;
|
|
244
|
-
layout?: LayoutComponent;
|
|
245
|
-
render?: (ctx: RenderContext) => VNode;
|
|
246
|
-
generate?: (locale: string) => Array<{
|
|
247
|
-
params: Record<string, string>;
|
|
248
|
-
}>;
|
|
249
|
-
head?: (ctx: RenderContext) => HeadConfig;
|
|
250
|
-
meta?: Record<string, unknown>;
|
|
251
|
-
toJson?: (ctx: RenderContext) => object;
|
|
252
|
-
toFile?: (ctx: RenderContext) => {
|
|
253
|
-
name: string;
|
|
254
|
-
content: string | Uint8Array;
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* Non-accumulating fluent builder. Methods mutate an internal spec and return `this`
|
|
259
|
-
* typed as the same `RouteBuilder` — type information captured in `RouteSpec` shape,
|
|
260
|
-
* not builder generics. Prevents TS inference performance collapse at 50+ routes.
|
|
261
|
-
*/
|
|
262
|
-
type RouteBuilder = {
|
|
263
|
-
load<T>(fn: (params: Record<string, string>) => T | Promise<T>): RouteBuilder;
|
|
264
|
-
layout(component: LayoutComponent): RouteBuilder;
|
|
265
|
-
render(fn: (ctx: RenderContext) => VNode): RouteBuilder;
|
|
266
|
-
generate(fn: (locale: string) => Array<{
|
|
267
|
-
params: Record<string, string>;
|
|
268
|
-
}>): RouteBuilder;
|
|
269
|
-
head(fn: (ctx: RenderContext) => HeadConfig): RouteBuilder;
|
|
270
|
-
meta(data: Record<string, unknown>): RouteBuilder;
|
|
271
|
-
toJson(fn: (ctx: RenderContext) => object): RouteBuilder;
|
|
272
|
-
toFile(fn: (ctx: RenderContext) => {
|
|
273
|
-
name: string;
|
|
274
|
-
content: string | Uint8Array;
|
|
275
|
-
}): RouteBuilder; /** Internal: produce the RouteSpec object. */
|
|
276
|
-
_spec(): RouteSpec;
|
|
277
|
-
};
|
|
278
|
-
type RouteEntry = {
|
|
279
|
-
name: string;
|
|
280
|
-
spec: RouteSpec;
|
|
281
|
-
specificity: number;
|
|
282
|
-
};
|
|
283
|
-
type RouterConfig<Routes extends Record<string, RouteSpec> = Record<string, RouteSpec>> = {
|
|
284
|
-
routes: Routes;
|
|
285
|
-
defaultPage?: keyof Routes & string;
|
|
286
|
-
};
|
|
287
|
-
type RouterState<Routes extends Record<string, RouteSpec> = Record<string, RouteSpec>> = {
|
|
288
|
-
routes: Routes;
|
|
289
|
-
entries: ReadonlyArray<RouteEntry>;
|
|
290
|
-
};
|
|
291
|
-
type RouterApi<Routes extends Record<string, RouteSpec> = Record<string, RouteSpec>> = {
|
|
292
|
-
routes: Routes;
|
|
293
|
-
toUrl<K extends keyof Routes>(name: K, params: Record<string, string>): string;
|
|
294
|
-
match(url: string): {
|
|
295
|
-
entry: RouteEntry;
|
|
296
|
-
params: Record<string, string>;
|
|
297
|
-
} | null;
|
|
298
|
-
entries(): ReadonlyArray<RouteEntry>;
|
|
299
|
-
};
|
|
300
|
-
declare namespace types_d_exports$1 {
|
|
301
|
-
export { BuildApi, BuildConfig, BuildPhase, BuildResult, BuildState, BundleManifest };
|
|
302
|
-
}
|
|
303
|
-
/** @file build plugin types — BuildConfig, BuildState, BuildApi, BundleManifest, BuildResult. */
|
|
304
|
-
type BuildPhase = 'bundle' | 'content' | 'pages' | 'feeds' | 'sitemap' | 'og' | 'images';
|
|
305
|
-
type BuildConfig = {
|
|
306
|
-
outdir: string;
|
|
307
|
-
mode: 'production' | 'development';
|
|
308
|
-
renderMode: 'ssg' | 'spa' | 'hybrid';
|
|
309
|
-
cssEntry?: string;
|
|
310
|
-
jsEntry?: string;
|
|
311
|
-
articleRouteKey?: string;
|
|
312
|
-
sourcemap?: 'none' | 'external' | 'inline';
|
|
313
|
-
};
|
|
314
|
-
type BundleManifest = {
|
|
315
|
-
cssPaths: string[];
|
|
316
|
-
jsPaths: string[];
|
|
317
|
-
assets: Map<string, string>;
|
|
318
|
-
};
|
|
319
|
-
type BuildState = {
|
|
320
|
-
manifest: BundleManifest | null;
|
|
321
|
-
lastResult: BuildResult | null;
|
|
322
|
-
};
|
|
323
|
-
type BuildResult = {
|
|
324
|
-
pages: number;
|
|
325
|
-
durationMs: number;
|
|
326
|
-
manifest: BundleManifest;
|
|
327
|
-
};
|
|
328
|
-
type BuildApi = {
|
|
329
|
-
run(): Promise<BuildResult>;
|
|
330
|
-
getManifest(): Readonly<BundleManifest> | null;
|
|
331
|
-
};
|
|
332
|
-
declare namespace types_d_exports {
|
|
333
|
-
export { DeployApi, DeployConfig, DeployResult, DeployState, DeployTarget, RunOptions };
|
|
334
|
-
}
|
|
335
|
-
/** @file deploy plugin types — DeployConfig, DeployState, DeployResult, RunOptions, DeployApi. */
|
|
336
|
-
/**
|
|
337
|
-
* Deployment target. Phase 1 ships `'pages'` only; `'workers'` is reserved
|
|
338
|
-
* for the Workers Static Assets expansion path and `buildWranglerArgs`
|
|
339
|
-
* throws "not implemented in Phase 1" if invoked with it.
|
|
340
|
-
*/
|
|
341
|
-
type DeployTarget = 'pages' | 'workers';
|
|
342
|
-
/**
|
|
343
|
-
* deploy plugin config.
|
|
344
|
-
*
|
|
345
|
-
* `outdir` precedence at deploy time: `wrangler.jsonc#pages_build_output_dir`
|
|
346
|
-
* (written by `moku deploy init`) — this is the deploy-time single source of
|
|
347
|
-
* truth, NOT `DeployConfig.outdir`. The config field is the *init-time* default;
|
|
348
|
-
* once `wrangler.jsonc` exists, it owns the value.
|
|
349
|
-
*
|
|
350
|
-
* Forbidden: reading the `build` plugin's config via `ctx.has(build)` /
|
|
351
|
-
* `ctx.require(build).config.outdir`. The core `HasFunction` takes a name
|
|
352
|
-
* string and returns a non-narrowing boolean; `RequireFunction` returns the
|
|
353
|
-
* API surface only (`BuildApi = { run, getManifest }`). The optional coupling
|
|
354
|
-
* is a `ctx.log.warn` at init time when divergence is detectable through the
|
|
355
|
-
* directly-imported `build` plugin instance, never via the core API.
|
|
356
|
-
*/
|
|
357
|
-
type DeployConfig = {
|
|
358
|
-
/** Deployment target. Default: `'pages'`. */target: DeployTarget; /** Build output directory used at init only. Default: `'dist'` (matches build plugin default). */
|
|
359
|
-
outdir: string; /** Production branch name. Default: `'main'`. Overwritten by `init` via `git symbolic-ref`. */
|
|
360
|
-
productionBranch: string; /** Optional explicit override for the Cloudflare Pages project name. Default: derived from `site.name`. */
|
|
361
|
-
projectName?: string;
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* In-memory deploy plugin state.
|
|
365
|
-
*
|
|
366
|
-
* `lastDeployment` is reset per `createApp()` call and captures the most
|
|
367
|
-
* recent deploy's metadata (URL, deployment ID, branch, duration). Used by
|
|
368
|
-
* the future REST-API-based rollback command (deferred from Phase 1).
|
|
369
|
-
*/
|
|
370
|
-
type DeployState = {
|
|
371
|
-
lastDeployment: DeployResult | null;
|
|
372
|
-
};
|
|
373
|
-
/** Result of a successful `app.deploy.run()` invocation. */
|
|
374
|
-
type DeployResult = {
|
|
375
|
-
/** Production URL (e.g., `https://<project>.pages.dev`) or branch-alias preview URL. */url: string; /** Cloudflare deployment ID — captured for future rollback support. */
|
|
376
|
-
deploymentId: string; /** Branch the deploy was published to. */
|
|
377
|
-
branch: string; /** Total subprocess duration in milliseconds (init + upload + finalize). */
|
|
378
|
-
durationMs: number;
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* Options accepted by `app.deploy.run()`.
|
|
382
|
-
*
|
|
383
|
-
* `branch` overrides the production branch from wrangler.jsonc (defaults to
|
|
384
|
-
* `DeployConfig.productionBranch`). `build` runs `app.build.run()` first
|
|
385
|
-
* when true — used only for local convenience; the generated CI workflow
|
|
386
|
-
* always issues the two-step `moku build` then `moku deploy` pattern.
|
|
387
|
-
*/
|
|
388
|
-
type RunOptions = {
|
|
389
|
-
/** Override the production branch for this deploy. */branch?: string; /** Run `app.build.run()` first (local convenience). Default: `false`. */
|
|
390
|
-
build?: boolean;
|
|
391
|
-
};
|
|
392
|
-
/** Public deploy plugin API surface, attached as `app.deploy`. */
|
|
393
|
-
type DeployApi = {
|
|
394
|
-
/** Run a deploy. Reads outdir from wrangler.jsonc; errors if missing. */run(options?: RunOptions): Promise<DeployResult>; /** Read the last deployment result without re-running. */
|
|
395
|
-
getLastDeployment(): Readonly<DeployResult> | null;
|
|
396
|
-
};
|
|
397
|
-
//#endregion
|
|
398
|
-
//#region src/project.d.ts
|
|
399
|
-
/**
|
|
400
|
-
* Map each consumer `RouteBuilder` to the `RouteSpec` shape the router stores.
|
|
401
|
-
*
|
|
402
|
-
* Keys are preserved so `toUrl(name, ...)` and `defaultPage` stay typed.
|
|
403
|
-
*/
|
|
404
|
-
type RouteSpecMap<Routes extends Record<string, RouteBuilder>> = { [K in keyof Routes]: RouteSpec };
|
|
405
|
-
/**
|
|
406
|
-
* Consumer-facing flat config shape.
|
|
407
|
-
*
|
|
408
|
-
* Generic over Routes (a record of `RouteBuilder`) so the literal route-name
|
|
409
|
-
* keys flow through to `app.router.routes` after the wrapper assembles the app.
|
|
410
|
-
*/
|
|
411
|
-
type WebAppConfig<Routes extends Record<string, RouteBuilder>> = {
|
|
412
|
-
mode?: 'production' | 'development';
|
|
413
|
-
site: SiteConfig;
|
|
414
|
-
i18n: I18nConfig;
|
|
415
|
-
routes: Routes;
|
|
416
|
-
components?: ComponentDef[];
|
|
417
|
-
spa?: {
|
|
418
|
-
viewTransitions?: boolean;
|
|
419
|
-
progressBar?: boolean;
|
|
420
|
-
};
|
|
421
|
-
ogImage?: OGImageConfig;
|
|
422
|
-
contentDir: string;
|
|
423
|
-
defaultPage?: keyof Routes & string;
|
|
424
|
-
trustedContent?: boolean;
|
|
425
|
-
};
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region src/plugins/build/index.d.ts
|
|
428
|
-
declare const build: _moku_labs_core0.PluginInstance<"build", BuildConfig, BuildState, BuildApi, {
|
|
429
|
-
'build:phase': {
|
|
430
|
-
phase: "bundle" | "content" | "pages" | "feeds" | "sitemap" | "og" | "images";
|
|
431
|
-
};
|
|
432
|
-
'build:complete': {
|
|
433
|
-
pages: number;
|
|
434
|
-
durationMs: number;
|
|
435
|
-
};
|
|
436
|
-
}> & Record<never, never>;
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/plugins/content/index.d.ts
|
|
439
|
-
declare const content: _moku_labs_core0.PluginInstance<"content", ContentConfig, ContentState, ContentApi, {
|
|
440
|
-
'content:ready': {
|
|
441
|
-
articles: Map<string, Article[]>;
|
|
442
|
-
};
|
|
443
|
-
'content:invalidated': {
|
|
444
|
-
paths: string[];
|
|
445
|
-
};
|
|
446
|
-
}> & Record<never, never>;
|
|
447
|
-
//#endregion
|
|
448
|
-
//#region src/plugins/deploy/index.d.ts
|
|
449
|
-
declare const deploy: _moku_labs_core0.PluginInstance<"deploy", DeployConfig, DeployState, DeployApi, {}> & Record<never, never>;
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/plugins/env/index.d.ts
|
|
452
|
-
declare const env: _moku_labs_core0.CorePluginInstance<"env", {
|
|
453
|
-
schema: {};
|
|
454
|
-
providers: never[];
|
|
455
|
-
publicPrefix: string;
|
|
456
|
-
}, EnvState, EnvApi>;
|
|
457
|
-
//#endregion
|
|
458
|
-
//#region src/plugins/head/index.d.ts
|
|
459
|
-
declare const head: _moku_labs_core0.PluginInstance<"head", HeadPluginConfig, HeadState, HeadApi, {}> & Record<never, never>;
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region src/plugins/i18n/index.d.ts
|
|
462
|
-
declare const i18n: _moku_labs_core0.PluginInstance<"i18n", I18nConfig, I18nState<readonly string[]>, I18nApi<readonly string[]>, {}> & Record<never, never>;
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region src/plugins/log/index.d.ts
|
|
465
|
-
declare const log: _moku_labs_core0.CorePluginInstance<"log", {
|
|
466
|
-
level: "info";
|
|
467
|
-
mode: "auto";
|
|
468
|
-
}, LogState, LogApi>;
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/plugins/router/route-builder.d.ts
|
|
471
|
-
/**
|
|
472
|
-
* Build a `RouteSpec` via a fluent, non-accumulating builder.
|
|
473
|
-
*
|
|
474
|
-
* Methods mutate a single internal `RouteSpec` and return the same builder typed
|
|
475
|
-
* as `RouteBuilder` (NOT `RouteBuilder<T>`). Type information lives on the
|
|
476
|
-
* `RouteSpec` shape, not in builder generics — this keeps TS inference O(1) per
|
|
477
|
-
* route and prevents the 50+ route inference collapse described in D5.
|
|
478
|
-
*
|
|
479
|
-
* @param pattern - URL pattern (e.g. `/about`, `/{slug}`, `/{lang:?}/{slug}/`).
|
|
480
|
-
* @returns A `RouteBuilder` that mutates an internal spec.
|
|
481
|
-
* @example
|
|
482
|
-
* ```ts
|
|
483
|
-
* const home = route('/{lang:?}/').render(({ locale }) => <Home locale={locale} />)
|
|
484
|
-
* ```
|
|
485
|
-
*/
|
|
486
|
-
declare function route(pattern: string): RouteBuilder;
|
|
487
|
-
//#endregion
|
|
488
|
-
//#region src/plugins/router/index.d.ts
|
|
489
|
-
declare const router: _moku_labs_core0.PluginInstance<"router", RouterConfig, RouterState, RouterApi, {
|
|
490
|
-
'router:registered': {
|
|
491
|
-
routeCount: number;
|
|
492
|
-
};
|
|
493
|
-
}> & Record<never, never>;
|
|
494
|
-
//#endregion
|
|
495
|
-
//#region src/plugins/site/index.d.ts
|
|
496
|
-
declare const site: _moku_labs_core0.PluginInstance<"site", {
|
|
497
|
-
name: string;
|
|
498
|
-
url: string;
|
|
499
|
-
author: string;
|
|
500
|
-
description: string;
|
|
501
|
-
}, SiteState, SiteApi, {}> & Record<never, never>;
|
|
502
|
-
//#endregion
|
|
503
|
-
export { ContentState as A, Events as B, RouterApi as C, Article as D, types_d_exports$2 as E, types_d_exports$4 as F, EnvState as G, EnvApi as H, SiteApi as I, LogApi as J, EnvVarSpec as K, SiteState as L, I18nApi as M, I18nConfig as N, ContentApi as O, I18nState as P, types_d_exports$5 as R, RouteSpec as S, RouterState as T, EnvConfig as U, createPlugin as V, EnvProvider as W, types_d_exports$7 as X, LogState as Y, BuildApi as _, i18n as a, types_d_exports$1 as b, deploy as c, RouteSpecMap as d, WebAppConfig as f, types_d_exports as g, DeployState as h, log as i, types_d_exports$3 as j, ContentConfig as k, content as l, DeployConfig as m, router as n, head as o, DeployApi as p, types_d_exports$6 as q, route as r, env as s, site as t, build as u, BuildConfig as v, RouterConfig as w, RouteBuilder as x, BuildState as y, Config as z };
|