@moku-labs/web 1.13.2 → 1.15.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.
@@ -230,6 +230,28 @@ type Api$3 = {
230
230
  t(locale: string, key: string): string;
231
231
  };
232
232
  //#endregion
233
+ //#region src/plugins/i18n/index.d.ts
234
+ /**
235
+ * Internationalization plugin — locale registry plus a flat translation helper
236
+ * with default-locale fallback. Pure config-as-data (no state or events);
237
+ * consumed read-only by content, router, head, and build.
238
+ *
239
+ * @example Register locales and translations
240
+ * ```ts
241
+ * const app = createApp({
242
+ * pluginConfigs: {
243
+ * i18n: {
244
+ * locales: ["en", "uk"],
245
+ * defaultLocale: "en",
246
+ * localeNames: { en: "English", uk: "Українська" },
247
+ * translations: { uk: { "nav.home": "Головна" } }
248
+ * }
249
+ * }
250
+ * });
251
+ * ```
252
+ */
253
+ declare const i18nPlugin: import("@moku-labs/core").PluginInstance<"i18n", Config$3, Record<string, never>, Api$3, {}> & Record<never, never>;
254
+ //#endregion
233
255
  //#region src/plugins/router/iso-match.d.ts
234
256
  /**
235
257
  * A compiled, engine-agnostic path matcher: the same `.exec({ pathname })` shape the
@@ -287,7 +309,10 @@ interface RouteState<P extends string = string, D = unknown> {
287
309
  /** Loaded data type produced by `.load()` (widened only by `.load()`). */
288
310
  readonly data: D;
289
311
  }
290
- /** Render-time context handed to `.render()` / `.head()`; `data` is `.load()`'s return. */
312
+ /**
313
+ * Render-time context handed to `.render()` / `.head()`; `data` is `.load()`'s return,
314
+ * `meta` the route's `.meta()` bag.
315
+ */
291
316
  interface RouteContext<S extends RouteState> {
292
317
  /** Resolved path params. */
293
318
  readonly params: S["params"];
@@ -295,6 +320,13 @@ interface RouteContext<S extends RouteState> {
295
320
  readonly data: S["data"];
296
321
  /** Active locale for this render. */
297
322
  readonly locale: string;
323
+ /**
324
+ * The route's `.meta()` bag (e.g. `{ activeTab: "home" }`). Available in `.render()` and
325
+ * `.head()`, identically at build and on the client — `meta` is compiled into the route and
326
+ * shipped in the client manifest, so a client-only route (dynamic, no `.generate()`, whose
327
+ * `.load()` data is `{}` on the client) can feed static per-route config into its render.
328
+ */
329
+ readonly meta: Record<string, unknown>;
298
330
  /**
299
331
  * Build a link to a named route by pattern substitution — the framework delivers
300
332
  * this on the context (same output as `app.router.toUrl`), so render/head build
@@ -375,21 +407,16 @@ interface GenerateContext {
375
407
  readonly has: (name: string) => boolean;
376
408
  }
377
409
  /**
378
- * Context handed to a route's `.layout()` wrapper: the render-time
379
- * {@link RouteContext} plus the route's `.meta()` bag, so persistent chrome (e.g. a
380
- * TopBar/TabNav) can read `locale` and `meta.activeTab`. Distinct from
381
- * `RouteContext` because the layout is the only handler that needs `meta`; keeping
382
- * it on its own type leaves `.render()`/`.head()` contexts unchanged.
410
+ * Context handed to a route's `.layout()` wrapper identical to {@link RouteContext}
411
+ * (which now carries `meta` for every handler). Retained as a named alias so existing
412
+ * `.layout((ctx, children) => …)` typings keep compiling.
383
413
  *
384
414
  * @remarks
385
415
  * The layout is applied in the SSG render path ONLY. On client (SPA) navigation the
386
- * chrome is persistent and the layout is intentionally NOT re-applied — only the
387
- * inner swap region is replaced. See `build`'s pages phase and `spa`'s kernel.
416
+ * chrome is persistent and the layout is intentionally NOT re-applied — only the inner
417
+ * swap region is replaced. See `build`'s pages phase and `spa`'s kernel.
388
418
  */
389
- interface LayoutContext<S extends RouteState> extends RouteContext<S> {
390
- /** The route's `.meta()` bag (e.g. `{ activeTab: "home" }`). */
391
- readonly meta: Record<string, unknown>;
392
- }
419
+ type LayoutContext<S extends RouteState> = RouteContext<S>;
393
420
  /** Head metadata produced by a route's `.head()` handler. */
394
421
  interface HeadConfig$1 {
395
422
  /** Document title. */
@@ -944,12 +971,25 @@ interface ResolvedSpaConfig {
944
971
  /** Pre-registered components. */
945
972
  components: ComponentDef[];
946
973
  }
947
- /** Context handed to every component lifecycle hook. */
974
+ /**
975
+ * Context handed to every component lifecycle hook — the bound element + page data,
976
+ * plus the matched route's `params`/`meta`/`locale` and a link builder, so an island
977
+ * can read its route context (e.g. a `card` route's `ctx.meta.focus` + `ctx.params.id`)
978
+ * directly, without the page bridging it through `data-*` attributes.
979
+ */
948
980
  interface ComponentContext {
949
981
  /** The element the component instance is bound to. */
950
982
  el: Element;
951
983
  /** Page data extracted from the `script#__DATA__` payload. */
952
984
  data: PageData;
985
+ /** Resolved path params of the route matched for the current URL (empty if unmatched). */
986
+ readonly params: Record<string, string | undefined>;
987
+ /** The matched route's `.meta()` bag (empty if unmatched). */
988
+ readonly meta: Record<string, unknown>;
989
+ /** Active locale for the current route (empty string if unknown). */
990
+ readonly locale: string;
991
+ /** Build a link to a named route by pattern substitution (same output as `app.router.toUrl`). */
992
+ readonly url: (name: string, params?: Record<string, string>) => string;
953
993
  }
954
994
  /** Lifecycle hooks a component may implement. */
955
995
  interface ComponentHooks {
@@ -1173,28 +1213,6 @@ type SpaApi = {
1173
1213
  */
1174
1214
  declare const sitePlugin: import("@moku-labs/core").PluginInstance<"site", Config$4, Record<string, never>, Api$4, {}> & Record<never, never>;
1175
1215
  //#endregion
1176
- //#region src/plugins/i18n/index.d.ts
1177
- /**
1178
- * Internationalization plugin — locale registry plus a flat translation helper
1179
- * with default-locale fallback. Pure config-as-data (no state or events);
1180
- * consumed read-only by content, router, head, and build.
1181
- *
1182
- * @example Register locales and translations
1183
- * ```ts
1184
- * const app = createApp({
1185
- * pluginConfigs: {
1186
- * i18n: {
1187
- * locales: ["en", "uk"],
1188
- * defaultLocale: "en",
1189
- * localeNames: { en: "English", uk: "Українська" },
1190
- * translations: { uk: { "nav.home": "Головна" } }
1191
- * }
1192
- * }
1193
- * });
1194
- * ```
1195
- */
1196
- declare const i18nPlugin: import("@moku-labs/core").PluginInstance<"i18n", Config$3, Record<string, never>, Api$3, {}> & Record<never, never>;
1197
- //#endregion
1198
1216
  //#region src/plugins/router/builders/route-builder.d.ts
1199
1217
  /**
1200
1218
  * Create a fluent route builder from a URL pattern string. Captures the pattern
@@ -1258,8 +1276,8 @@ declare function createUrls<T extends RouteMap>(routes: T, defaultLocale?: strin
1258
1276
  /**
1259
1277
  * Router plugin — typed, named route definitions with locale-aware URL generation
1260
1278
  * and matching. Author routes with {@link route}, then register them the normal config
1261
- * way via `pluginConfigs.router.routes` (compiled at init). Depends on site (base URL)
1262
- * and i18n (locales).
1279
+ * way via `pluginConfigs.router.routes` (compiled at init). Depends on site (base URL);
1280
+ * i18n (locales) is OPTIONAL — falls back to a single default locale ("en") when absent.
1263
1281
  *
1264
1282
  * @example Register routes via config, then start/build
1265
1283
  * ```ts
@@ -1362,7 +1380,7 @@ declare function buildArticleHead(articleMeta: ArticleMeta, canonicalUrl: string
1362
1380
  * Head plugin — composes per-route `<head>` metadata (title template, Open Graph,
1363
1381
  * Twitter cards, canonical, hreflang). Use the re-exported SEO primitives
1364
1382
  * ({@link meta}, {@link og}, {@link twitter}, …) inside a route's `.head()`.
1365
- * Depends on site, i18n, and router.
1383
+ * Depends on site and router; i18n is OPTIONAL (single default-locale fallback when absent).
1366
1384
  *
1367
1385
  * @example Set global head defaults
1368
1386
  * ```ts
@@ -2072,7 +2090,8 @@ type Api = {
2072
2090
  * (locale fallback, draft filtering, sort, caching, events) lives here; source I/O +
2073
2091
  * the Markdown pipeline live in a {@link ContentProvider} you compose (like `env`
2074
2092
  * providers). The shell imports zero node code, so `contentPlugin` is browser-safe.
2075
- * Depends on i18n; emits `content:ready` and `content:invalidated`.
2093
+ * i18n is OPTIONAL (single default-locale fallback when absent); emits `content:ready`
2094
+ * and `content:invalidated`.
2076
2095
  *
2077
2096
  * @example Compose the node filesystem provider with a content dir + Shiki theme
2078
2097
  * ```ts