@absolutejs/absolute 0.20.0-beta.169 → 0.20.0-beta.170
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/CHANGELOG.md +80 -0
- package/README.md +232 -0
- package/changelog.json +228 -0
- package/dist/angular/browser.js +7 -8
- package/dist/angular/browser.js.map +6 -5
- package/dist/angular/components/core/streamingSlotRegistrar.js +6 -2
- package/dist/angular/components/core/streamingSlotRegistry.js +7 -3
- package/dist/angular/index.js +555 -156
- package/dist/angular/index.js.map +29 -23
- package/dist/angular/server.js +555 -156
- package/dist/angular/server.js.map +29 -23
- package/dist/build/buildWorker.js +14 -8
- package/dist/build.js +4949 -1941
- package/dist/build.js.map +72 -42
- package/dist/cli/{add-7azr0c83.js → add-6a7pjkn9.js} +11 -7
- package/dist/cli/{analyze-3cyek6v3.js → analyze-606fshwa.js} +1 -1
- package/dist/cli/{build-25rz8v25.js → build-g81xqbb9.js} +1 -1
- package/dist/cli/{compile-4jnfxts9.js → compile-9y1w9zpj.js} +3 -3
- package/dist/cli/config/server.js +10699 -1538
- package/dist/cli/{dev-9tk5hn2e.js → dev-hyeb89hp.js} +5 -1
- package/dist/cli/{doctor-4nv2c2j3.js → doctor-h55y9hj1.js} +1 -1
- package/dist/cli/{generate-v75p2fct.js → generate-20x1pkf7.js} +4 -4
- package/dist/cli/{htmx-427swtdz.js → htmx-6mz2h7k1.js} +2 -2
- package/dist/cli/{index-bhbs6d5z.js → index-32ge2w1f.js} +12 -4
- package/dist/cli/{index-a4ws2jwd.js → index-3wz3mktm.js} +1 -1
- package/dist/cli/{index-b7hjgknf.js → index-9sksd8c8.js} +13 -4
- package/dist/cli/{index-eyzwc7gz.js → index-qbrzvmh9.js} +4 -2
- package/dist/cli/index-qw98g1p6.js +269 -0
- package/dist/cli/{index-434b7j4a.js → index-vtp20gwf.js} +69 -1
- package/dist/cli/{index-h7qhz02e.js → index-wk0pyxrg.js} +3 -0
- package/dist/cli/{index-k3y8cb6c.js → index-z6f43b20.js} +1 -1
- package/dist/cli/index.js +16 -16
- package/dist/cli/{islands-8sgky9gh.js → islands-dc54e5y1.js} +1 -1
- package/dist/cli/{ls-4m4yqwww.js → ls-b6zz24nt.js} +1 -1
- package/dist/cli/{mobile-hcxjr2gf.js → mobile-ajnnvqtv.js} +3 -3
- package/dist/cli/prerender-fqpp0m1j.js +10 -0
- package/dist/cli/{remove-1ycjx85k.js → remove-t8x1mrxg.js} +4 -4
- package/dist/cli/{start-mbaejxhm.js → start-d6p831ny.js} +3 -3
- package/dist/cli/{typecheck-dr068pmh.js → typecheck-stbt0qt5.js} +6 -1
- package/dist/cli/{workspace-1sycp9g1.js → workspace-61hh6jq1.js} +1 -1
- package/dist/client/chunks/index-6b66nzyf.js +381 -0
- package/dist/client/chunks/index-6b66nzyf.js.map +11 -0
- package/dist/client/chunks/{islands-rc28k5sx.js → islands-s2ta5ajb.js} +5 -2
- package/dist/client/chunks/{islands-rc28k5sx.js.map → islands-s2ta5ajb.js.map} +7 -6
- package/dist/client/index.js +160 -3
- package/dist/client/index.js.map +6 -4
- package/dist/client/navigation.js +764 -0
- package/dist/client/navigation.js.map +10 -0
- package/dist/client/prefetch.js +33 -375
- package/dist/client/prefetch.js.map +3 -4
- package/dist/core/streamingSlotRegistrar.js +5 -2
- package/dist/core/streamingSlotRegistrar.js.map +5 -4
- package/dist/core/streamingSlotRegistry.js +5 -2
- package/dist/core/streamingSlotRegistry.js.map +5 -4
- package/dist/dev/client/cspNonce.ts +28 -0
- package/dist/dev/client/handlers/html.ts +4 -3
- package/dist/dev/client/handlers/htmx.ts +3 -2
- package/dist/dev/client/handlers/svelte.ts +15 -90
- package/dist/dev/client/syncDevtools.ts +2 -1
- package/dist/dev/serverBootstrap.js +11 -4
- package/dist/i18n/index.js +543 -0
- package/dist/i18n/index.js.map +15 -0
- package/dist/index.js +6339 -2233
- package/dist/index.js.map +89 -54
- package/dist/islands/index.js +282 -40
- package/dist/islands/index.js.map +14 -10
- package/dist/mobile/browser.js +7 -2
- package/dist/mobile/browser.js.map +5 -4
- package/dist/mobile/index.js +7 -2
- package/dist/mobile/index.js.map +5 -4
- package/dist/mobile/remoteMacAgentEntry.js +1 -1
- package/dist/react/components/browser/index.js +94 -4
- package/dist/react/components/index.js +150 -10
- package/dist/react/components/index.js.map +15 -10
- package/dist/react/hooks/index.js +479 -13
- package/dist/react/hooks/index.js.map +12 -4
- package/dist/react/index.js +769 -166
- package/dist/react/index.js.map +32 -21
- package/dist/react/router/browser.js +21 -4
- package/dist/react/router/browser.js.map +5 -4
- package/dist/react/router/index.js +21 -4
- package/dist/react/router/index.js.map +5 -4
- package/dist/react/server.js +597 -203
- package/dist/react/server.js.map +25 -15
- package/dist/src/angular/zoneRuntime.d.ts +5 -0
- package/dist/src/build/buildReactServerComponents.d.ts +22 -0
- package/dist/src/build/downlevelAsyncForZone.d.ts +1 -0
- package/dist/src/build/fileRoutes.d.ts +65 -0
- package/dist/src/build/fonts/buildFonts.d.ts +25 -0
- package/dist/src/build/fonts/fallbackMetrics.d.ts +13 -0
- package/dist/src/build/fonts/googleFonts.d.ts +18 -0
- package/dist/src/build/fonts/injectFontTags.d.ts +7 -0
- package/dist/src/build/fonts/parseFontMetrics.d.ts +4 -0
- package/dist/src/build/generateReactIndexes.d.ts +7 -1
- package/dist/src/build/htmlIncludes.d.ts +16 -0
- package/dist/src/build/inlineSourceMapComment.d.ts +1 -0
- package/dist/src/build/scanConventions.d.ts +3 -0
- package/dist/src/build/vitals.d.ts +21 -0
- package/dist/src/client/formActions.d.ts +29 -0
- package/dist/src/client/index.d.ts +2 -0
- package/dist/src/client/navigation.d.ts +16 -0
- package/dist/src/client/prefetch.d.ts +2 -30
- package/dist/src/core/build.d.ts +2 -2
- package/dist/src/core/cspNonce.d.ts +12 -0
- package/dist/src/core/fileRouteAdapter.d.ts +15 -0
- package/dist/src/core/fileRoutes.d.ts +5 -0
- package/dist/src/core/formActionFlash.d.ts +25 -0
- package/dist/src/core/formActions.d.ts +249 -0
- package/dist/src/core/index.d.ts +5 -0
- package/dist/src/core/partialPrerender.d.ts +28 -0
- package/dist/src/core/partialPrerenderServe.d.ts +24 -0
- package/dist/src/core/precompressed.d.ts +11 -1
- package/dist/src/core/prerenderNonce.d.ts +9 -0
- package/dist/src/core/productionRuntime.d.ts +4 -2
- package/dist/src/core/serverOnlyStaticFiles.d.ts +8 -0
- package/dist/src/core/staticHtmlNonce.d.ts +2 -0
- package/dist/src/core/vitals.d.ts +108 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +1 -1
- package/dist/src/dev/client/cspNonce.d.ts +2 -0
- package/dist/src/dev/fileRouteRefresher.d.ts +5 -0
- package/dist/src/dev/importCost/instrument.d.ts +1 -1
- package/dist/src/dev/reactServerComponentsRebuild.d.ts +3 -0
- package/dist/src/i18n/defineMessages.d.ts +5 -0
- package/dist/src/i18n/formatMessage.d.ts +26 -0
- package/dist/src/i18n/index.d.ts +6 -0
- package/dist/src/i18n/intlCache.d.ts +5 -0
- package/dist/src/i18n/routing.d.ts +28 -0
- package/dist/src/i18n/translator.d.ts +11 -0
- package/dist/src/mobile/androidRelease.d.ts +2 -2
- package/dist/src/mobile/iosRelease.d.ts +4 -4
- package/dist/src/mobile/materializedBundle.d.ts +1 -1
- package/dist/src/mobile/mobileInspect.d.ts +1 -1
- package/dist/src/mobile/releaseArtifact.d.ts +2 -2
- package/dist/src/mobile/remoteMacProtocol.d.ts +2 -2
- package/dist/src/plugins/i18n.d.ts +30 -0
- package/dist/src/plugins/index.d.ts +2 -1
- package/dist/src/plugins/secureHeaders.d.ts +48 -0
- package/dist/src/react/components/Head.d.ts +1 -1
- package/dist/src/react/components/StreamSlot.browser.d.ts +1 -0
- package/dist/src/react/components/StreamSlot.d.ts +5 -1
- package/dist/src/react/components/SuspenseSlot.browser.d.ts +2 -0
- package/dist/src/react/components/SuspenseSlot.d.ts +12 -0
- package/dist/src/react/fileRoute.d.ts +18 -0
- package/dist/src/react/hooks/index.d.ts +4 -0
- package/dist/src/react/hooks/useFormAction.d.ts +42 -0
- package/dist/src/react/hooks/useI18n.d.ts +15 -0
- package/dist/src/react/index.d.ts +2 -0
- package/dist/src/react/server.d.ts +2 -0
- package/dist/src/react/serverComponents/constants.d.ts +11 -0
- package/dist/src/react/serverComponents/flightPayload.d.ts +2 -0
- package/dist/src/react/serverComponents/pageHandler.d.ts +14 -0
- package/dist/src/svelte/browser.d.ts +1 -0
- package/dist/src/svelte/fileRoute.d.ts +15 -0
- package/dist/src/svelte/i18n.d.ts +8 -0
- package/dist/src/svelte/index.d.ts +2 -0
- package/dist/src/svelte/lowerAwaitSlotSyntax.d.ts +5 -1
- package/dist/src/svelte/renderToReadableStream.d.ts +10 -2
- package/dist/src/svelte/router/browser.d.ts +3 -1
- package/dist/src/svelte/router/goto.d.ts +13 -10
- package/dist/src/svelte/router/guards.d.ts +43 -0
- package/dist/src/svelte/router/index.d.ts +3 -1
- package/dist/src/svelte/router/lazy.d.ts +17 -0
- package/dist/src/svelte/router/lazyModule.d.ts +29 -0
- package/dist/src/svelte/router/navigation.d.ts +55 -0
- package/dist/src/svelte/router/pushState.d.ts +4 -2
- package/dist/src/svelte/router/scroll.d.ts +34 -0
- package/dist/src/svelte/routerSsr.d.ts +9 -0
- package/dist/src/svelte/server.d.ts +1 -0
- package/dist/src/utils/cspNonceRef.d.ts +8 -0
- package/dist/src/utils/fontAssets.d.ts +17 -0
- package/dist/src/utils/formActionProtocol.d.ts +10 -0
- package/dist/src/utils/generateHeadElement.d.ts +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/inlinePageCss.d.ts +18 -0
- package/dist/src/utils/loadConfig.d.ts +5 -0
- package/dist/src/utils/localeRef.d.ts +10 -0
- package/dist/src/utils/resolveConvention.d.ts +6 -1
- package/dist/src/utils/streamingSlots.d.ts +5 -0
- package/dist/src/vue/browser.d.ts +2 -0
- package/dist/src/vue/components/Image.d.ts +2 -2
- package/dist/src/vue/index.d.ts +2 -0
- package/dist/src/vue/serverDataPayload.d.ts +32 -0
- package/dist/src/vue/serverDataState.d.ts +9 -0
- package/dist/src/vue/useServerData.browser.d.ts +6 -0
- package/dist/src/vue/useServerData.d.ts +24 -0
- package/dist/svelte/browser.js +330 -3
- package/dist/svelte/browser.js.map +8 -4
- package/dist/svelte/components/AwaitSlot.svelte +5 -0
- package/dist/svelte/components/Head.svelte +50 -0
- package/dist/svelte/components/JsonLd.svelte +9 -1
- package/dist/svelte/components/StreamSlot.svelte +5 -0
- package/dist/svelte/index.js +1017 -117
- package/dist/svelte/index.js.map +38 -24
- package/dist/svelte/router/Link.svelte +40 -8
- package/dist/svelte/router/Route.svelte +157 -12
- package/dist/svelte/router/Route.svelte.d.ts +39 -5
- package/dist/svelte/router/Router.svelte +140 -25
- package/dist/svelte/router/Router.svelte.d.ts +5 -1
- package/dist/svelte/router/browser.ts +10 -0
- package/dist/svelte/router/goto.ts +15 -86
- package/dist/svelte/router/guards.ts +112 -0
- package/dist/svelte/router/index.ts +10 -0
- package/dist/svelte/router/lazy.ts +82 -0
- package/dist/svelte/router/lazyModule.ts +74 -0
- package/dist/svelte/router/navigation.ts +412 -0
- package/dist/svelte/router/pushState.ts +7 -4
- package/dist/svelte/router/scroll.ts +286 -0
- package/dist/svelte/server.js +747 -252
- package/dist/svelte/server.js.map +30 -20
- package/dist/types/angular.d.ts +2 -0
- package/dist/types/build.d.ts +37 -0
- package/dist/types/conventions.d.ts +3 -0
- package/dist/types/fileRoutes.d.ts +72 -0
- package/dist/types/fonts.d.ts +86 -0
- package/dist/types/formAction.d.ts +54 -0
- package/dist/types/globals.d.ts +10 -0
- package/dist/types/i18n.d.ts +185 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/metadata.d.ts +11 -0
- package/dist/types/navigation.d.ts +37 -0
- package/dist/types/prefetch.d.ts +10 -0
- package/dist/types/sitemap.d.ts +4 -0
- package/dist/types/svelteRouter.d.ts +89 -2
- package/dist/types/svelteRouter.ts +112 -2
- package/dist/types/vue.d.ts +46 -1
- package/dist/utils/iconVersion.ts +34 -0
- package/dist/vue/browser.js +107 -11
- package/dist/vue/browser.js.map +7 -4
- package/dist/vue/components/index.js +5 -2
- package/dist/vue/components/index.js.map +5 -4
- package/dist/vue/index.js +712 -158
- package/dist/vue/index.js.map +32 -23
- package/dist/vue/server.js +310 -79
- package/dist/vue/server.js.map +20 -15
- package/package.json +9 -1
- package/dist/cli/prerender-mfnwsvyt.js +0 -7
- package/dist/src/plugins/pageRouter.d.ts +0 -1
- /package/dist/cli/{index-j7m8pq48.js → index-rervww4p.js} +0 -0
package/dist/types/angular.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export type AngularDeps = {
|
|
|
9
9
|
NgComponentOutlet: typeof import('@angular/common').NgComponentOutlet;
|
|
10
10
|
provideClientHydration: typeof import('@angular/platform-browser').provideClientHydration;
|
|
11
11
|
provideServerRendering: typeof import('@angular/platform-server').provideServerRendering;
|
|
12
|
+
CSP_NONCE: typeof import('@angular/core').CSP_NONCE;
|
|
13
|
+
provideZoneChangeDetection: typeof import('@angular/core').provideZoneChangeDetection;
|
|
12
14
|
provideZonelessChangeDetection: typeof import('@angular/core').provideZonelessChangeDetection;
|
|
13
15
|
reflectComponentType: typeof import('@angular/core').reflectComponentType;
|
|
14
16
|
renderApplication: typeof import('@angular/platform-server').renderApplication;
|
package/dist/types/build.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { build } from '../src/core/build';
|
|
2
2
|
import { devBuild } from '../src/core/devBuild';
|
|
3
3
|
import type { BuildConfig as BunBuildConfig } from 'bun';
|
|
4
|
+
import type { FileRoutesConfig } from './fileRoutes';
|
|
5
|
+
import type { FontsConfig } from './fonts';
|
|
4
6
|
import type { ImageConfig } from './image';
|
|
5
7
|
import type { SitemapConfig } from './sitemap';
|
|
8
|
+
/** How Angular pages run change detection. `'zoneless'` (the default)
|
|
9
|
+
* uses signals and explicit scheduling; `'zone'` loads zone.js on the
|
|
10
|
+
* server and in the browser for apps and libraries that rely on NgZone. */
|
|
11
|
+
export type AngularChangeDetection = 'zone' | 'zoneless';
|
|
6
12
|
export type BunBuildPassKey = 'server' | 'reactClient' | 'nonReactClient' | 'islandClient' | 'globalCss' | 'vueCss';
|
|
7
13
|
export type ReservedBunBuildConfigKey = 'entrypoints' | 'outdir' | 'outfile' | 'root' | 'target' | 'format' | 'throw' | 'compile';
|
|
8
14
|
type DistributivePartialOmit<T, K extends PropertyKey> = T extends unknown ? Partial<Omit<T, Extract<keyof T, K>>> : never;
|
|
@@ -425,6 +431,11 @@ export type BaseBuildConfig = {
|
|
|
425
431
|
bootstrap?: string;
|
|
426
432
|
};
|
|
427
433
|
reactDirectory?: string;
|
|
434
|
+
/** Opt-in React Server Components. Pages are the files directly in
|
|
435
|
+
* `<dir>/pages`; serve one with `handleReactServerPageRequest({ page:
|
|
436
|
+
* asset(manifest, '<Page>RSC') })`. Requires react-server-dom-webpack
|
|
437
|
+
* at the version of react. */
|
|
438
|
+
reactServerComponentsDirectory?: string;
|
|
428
439
|
vueDirectory?: string;
|
|
429
440
|
angularDirectory?: string;
|
|
430
441
|
/** Per-framework Angular config. `providers` is the global default
|
|
@@ -438,6 +449,9 @@ export type BaseBuildConfig = {
|
|
|
438
449
|
* come from page-level `export const routes` and are auto-wired by
|
|
439
450
|
* the build — users never write `provideRouter` themselves. */
|
|
440
451
|
angular?: {
|
|
452
|
+
/** `'zone'` opts every Angular page into zone.js change detection
|
|
453
|
+
* (zone.js must be installed in the app). Defaults to `'zoneless'`. */
|
|
454
|
+
changeDetection?: AngularChangeDetection;
|
|
441
455
|
providers?: ReadonlyArray<import('@angular/core').Provider | import('@angular/core').EnvironmentProviders>;
|
|
442
456
|
};
|
|
443
457
|
astroDirectory?: string;
|
|
@@ -515,7 +529,20 @@ export type BaseBuildConfig = {
|
|
|
515
529
|
static?: StaticConfig;
|
|
516
530
|
compile?: CompileConfig;
|
|
517
531
|
images?: ImageConfig;
|
|
532
|
+
/** Build-time font optimization: self-hosts Google Fonts or local font
|
|
533
|
+
* files with hashed names, preloads the critical faces and adds
|
|
534
|
+
* metric-matched fallback faces. Use `fontAssets(manifest)` to put them
|
|
535
|
+
* in a page's head. See docs/FONTS.md. */
|
|
536
|
+
fonts?: FontsConfig;
|
|
537
|
+
/** Opt-in Core Web Vitals reporting (LCP, INP, CLS, FCP, TTFB) from real
|
|
538
|
+
* visits. See docs/WEB_VITALS.md. */
|
|
539
|
+
vitals?: VitalsConfig;
|
|
518
540
|
sitemap?: SitemapConfig;
|
|
541
|
+
/** Opt-in file-system routing: route files under each framework
|
|
542
|
+
* directory's `routes/` folder become GET routes (React and Svelte for
|
|
543
|
+
* now). Explicit routes stay the default and take precedence. See
|
|
544
|
+
* docs/FILE_ROUTER_PLAN.md. */
|
|
545
|
+
fileRoutes?: boolean | FileRoutesConfig;
|
|
519
546
|
openapi?: boolean | OpenApiConfig;
|
|
520
547
|
telemetry?: boolean | OtelConfig;
|
|
521
548
|
sourcemaps?: 'external' | 'inline' | boolean;
|
|
@@ -569,4 +596,14 @@ export type Result = BuildResult | DevBuildResult;
|
|
|
569
596
|
export type Prettify<T> = {
|
|
570
597
|
[K in keyof T]: T[K];
|
|
571
598
|
} & {};
|
|
599
|
+
export type VitalsConfig = {
|
|
600
|
+
/** Where the browser sends each page's batch. A path is served by the
|
|
601
|
+
* built-in route (handlers registered with `onVital()`); a full URL
|
|
602
|
+
* posts elsewhere. Default `/__absolute/vitals`. */
|
|
603
|
+
endpoint?: string;
|
|
604
|
+
/** Share of page loads that report, 0–1. Default 1. */
|
|
605
|
+
sampleRate?: number;
|
|
606
|
+
/** Report from `absolute dev` too. Default false. */
|
|
607
|
+
dev?: boolean;
|
|
608
|
+
};
|
|
572
609
|
export {};
|
|
@@ -19,6 +19,9 @@ export type ConventionsMap = {
|
|
|
19
19
|
angular?: FrameworkConventionEntry;
|
|
20
20
|
ember?: FrameworkConventionEntry;
|
|
21
21
|
html?: FrameworkConventionEntry;
|
|
22
|
+
/** Conventions from the HTMX pages directory only. HTMX pages try these
|
|
23
|
+
* first, then `html` (which also includes them). */
|
|
24
|
+
htmx?: FrameworkConventionEntry;
|
|
22
25
|
};
|
|
23
26
|
export type ErrorPageProps = Pick<Error, 'name' | 'message' | 'stack'>;
|
|
24
27
|
export type HtmlDocument = `<!DOCTYPE html>${string}` | `<!doctype html>${string}`;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Context } from 'elysia';
|
|
2
|
+
export type FileRouteFramework = 'react' | 'svelte';
|
|
3
|
+
export type FileRoutesConfig = {
|
|
4
|
+
/** Folder inside each framework directory that holds route files.
|
|
5
|
+
* Default `routes`, so React routes live in `<reactDirectory>/routes`. */
|
|
6
|
+
directory?: string;
|
|
7
|
+
/** Where the generated route module is written, relative to the project
|
|
8
|
+
* root. Your server imports `routeTree` from it. Default
|
|
9
|
+
* `src/routes.gen.ts`. */
|
|
10
|
+
output?: string;
|
|
11
|
+
};
|
|
12
|
+
type ParamNamesOf<Path extends string> = Path extends `${string}:${infer Param}/${infer Rest}` ? Param | ParamNamesOf<`/${Rest}`> : Path extends `${string}:${infer Param}` ? Param : never;
|
|
13
|
+
/** The params of an Elysia-style path: `'/blog/:slug'` → `{ slug: string }`.
|
|
14
|
+
* An unknown path (`string`) has string params of any name. */
|
|
15
|
+
export type FileRouteParams<Path extends string> = string extends Path ? Record<string, string> : {
|
|
16
|
+
[Name in ParamNamesOf<Path>]: string;
|
|
17
|
+
};
|
|
18
|
+
export type FileRouteRedirectStatus = 301 | 302 | 303 | 307 | 308;
|
|
19
|
+
/** What `load` and `beforeHandle` receive for a request to `Path`. */
|
|
20
|
+
export type FileRouteContext<Path extends string = string> = {
|
|
21
|
+
headers: Record<string, string | undefined>;
|
|
22
|
+
params: FileRouteParams<Path>;
|
|
23
|
+
path: string;
|
|
24
|
+
query: Record<string, string | undefined>;
|
|
25
|
+
request: Request;
|
|
26
|
+
/** Response status and headers, as on an Elysia context. */
|
|
27
|
+
set: Context['set'];
|
|
28
|
+
/** A redirect response; return it from `beforeHandle` or `load`. */
|
|
29
|
+
redirect: (url: string, status?: FileRouteRedirectStatus) => Response;
|
|
30
|
+
};
|
|
31
|
+
type MaybePromise<Value> = Value | Promise<Value>;
|
|
32
|
+
/** The shape of a route's co-located `<Route>.server.ts` module. */
|
|
33
|
+
export type FileRouteServerModule<Path extends string = string, Props = Record<string, unknown>> = {
|
|
34
|
+
/** Runs before `load`; return a value (a `Response`, a redirect) to
|
|
35
|
+
* answer the request instead of rendering the page. */
|
|
36
|
+
beforeHandle?: (context: FileRouteContext<Path>) => unknown;
|
|
37
|
+
/** Returns the props the page renders with. */
|
|
38
|
+
load?: (context: FileRouteContext<Path>) => MaybePromise<Props | Response>;
|
|
39
|
+
};
|
|
40
|
+
type RequiredKeysOf<Value> = {
|
|
41
|
+
[Key in keyof Value]-?: undefined extends Value[Key] ? never : Key;
|
|
42
|
+
}[keyof Value];
|
|
43
|
+
/** Props a route's `load` has to supply: the page's props minus the `url`
|
|
44
|
+
* the page handler fills in from the request. */
|
|
45
|
+
export type FileRouteLoadProps<Props> = Omit<Props, 'url'>;
|
|
46
|
+
/** A route with required page props needs a server module whose `load`
|
|
47
|
+
* returns them; otherwise the server module is optional. */
|
|
48
|
+
export type FileRouteServerModuleFor<Path extends string, Props> = [
|
|
49
|
+
RequiredKeysOf<FileRouteLoadProps<Props>>
|
|
50
|
+
] extends [never] ? FileRouteServerModule<Path, FileRouteLoadProps<Props>> | undefined : FileRouteServerModule<Path, FileRouteLoadProps<Props>> & {
|
|
51
|
+
load: (context: FileRouteContext<Path>) => MaybePromise<FileRouteLoadProps<Props> | Response>;
|
|
52
|
+
};
|
|
53
|
+
/** What `fileRoutes()` needs to serve one request. Built by the framework
|
|
54
|
+
* adapters (`reactFileRoute`, `svelteFileRoute`) in the generated module. */
|
|
55
|
+
export type FileRouteRenderInput = {
|
|
56
|
+
manifest: Record<string, string>;
|
|
57
|
+
props: Record<string, unknown>;
|
|
58
|
+
request: Request;
|
|
59
|
+
};
|
|
60
|
+
export type FileRouteDefinition = {
|
|
61
|
+
framework: FileRouteFramework;
|
|
62
|
+
/** Page name in the manifest (`<name>Index`, …). */
|
|
63
|
+
name: string;
|
|
64
|
+
/** Elysia path, e.g. `/blog/:slug`. */
|
|
65
|
+
path: string;
|
|
66
|
+
/** Route file, relative to the project root. */
|
|
67
|
+
source: string;
|
|
68
|
+
beforeHandle?: (context: FileRouteContext) => unknown;
|
|
69
|
+
load?: (context: FileRouteContext) => Promise<unknown>;
|
|
70
|
+
render: (input: FileRouteRenderInput) => Promise<Response>;
|
|
71
|
+
};
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export type FontStyle = 'normal' | 'italic';
|
|
2
|
+
export type FontDisplay = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
3
|
+
/** The generic family the size-adjusted fallback face is built from:
|
|
4
|
+
* Arial for `sans-serif`, Times New Roman for `serif`, Courier New for
|
|
5
|
+
* `monospace`. */
|
|
6
|
+
export type FontFallbackCategory = 'sans-serif' | 'serif' | 'monospace';
|
|
7
|
+
/** A face to preload. Omitted fields match any value. */
|
|
8
|
+
export type FontPreloadSelector = {
|
|
9
|
+
weight?: number | string;
|
|
10
|
+
style?: FontStyle;
|
|
11
|
+
subset?: string;
|
|
12
|
+
};
|
|
13
|
+
/** One font file from the project, for a family with `src`. */
|
|
14
|
+
export type LocalFontSource = {
|
|
15
|
+
/** Path to a `.woff2`, `.woff`, `.ttf` or `.otf` file, relative to the
|
|
16
|
+
* project root. */
|
|
17
|
+
path: string;
|
|
18
|
+
/** A number (`400`) or, for a variable font, a range (`'100 900'`).
|
|
19
|
+
* Defaults to 400. */
|
|
20
|
+
weight?: number | string;
|
|
21
|
+
/** Defaults to `normal`. */
|
|
22
|
+
style?: FontStyle;
|
|
23
|
+
};
|
|
24
|
+
export type FontFamilyConfig = {
|
|
25
|
+
/** The family name, e.g. `'Poppins'` or `'Open Sans'`. */
|
|
26
|
+
family: string;
|
|
27
|
+
/** Local font files. When set, the family is self-hosted from these
|
|
28
|
+
* files instead of downloaded from Google Fonts. */
|
|
29
|
+
src?: LocalFontSource[];
|
|
30
|
+
/** Google Fonts weights: numbers (`[400, 700]`) or one variable range
|
|
31
|
+
* (`'100..900'`). Defaults to `[400]`. */
|
|
32
|
+
weights?: Array<number | string> | string;
|
|
33
|
+
/** Google Fonts styles. Defaults to `['normal']`. */
|
|
34
|
+
styles?: FontStyle[];
|
|
35
|
+
/** Google Fonts subsets to keep. Defaults to `['latin']`. */
|
|
36
|
+
subsets?: string[];
|
|
37
|
+
/** `font-display` for this family. Defaults to the top-level `display`. */
|
|
38
|
+
display?: FontDisplay;
|
|
39
|
+
/** Which faces to preload. `true` (the default) preloads the first
|
|
40
|
+
* weight and style in the latin subset (or the first subset); `false`
|
|
41
|
+
* preloads nothing; a list picks faces explicitly. */
|
|
42
|
+
preload?: boolean | FontPreloadSelector[];
|
|
43
|
+
/** Generic family for the metric-matched fallback face. Inferred from
|
|
44
|
+
* the family name when omitted (`Mono` -> monospace, `Serif` -> serif,
|
|
45
|
+
* otherwise sans-serif). */
|
|
46
|
+
fallback?: FontFallbackCategory;
|
|
47
|
+
/** Generate the size-adjusted fallback `@font-face`. Defaults to true. */
|
|
48
|
+
adjustFallback?: boolean;
|
|
49
|
+
/** CSS custom property name. Defaults to `--font-<family-kebab>`. */
|
|
50
|
+
variable?: string;
|
|
51
|
+
/** Class name that applies the family. Defaults to `font-<family-kebab>`. */
|
|
52
|
+
className?: string;
|
|
53
|
+
};
|
|
54
|
+
export type FontsConfig = {
|
|
55
|
+
families: FontFamilyConfig[];
|
|
56
|
+
/** Default `font-display` for every family. Defaults to `swap`. */
|
|
57
|
+
display?: FontDisplay;
|
|
58
|
+
/** When a Google Fonts download fails (offline, blocked), link the
|
|
59
|
+
* remote stylesheet instead of failing the build. Defaults to false. */
|
|
60
|
+
fallbackToRemote?: boolean;
|
|
61
|
+
/** Where downloads are cached between builds. Defaults to
|
|
62
|
+
* `.absolutejs/cache/fonts` under the project root. */
|
|
63
|
+
cacheDirectory?: string;
|
|
64
|
+
/** Add the font stylesheet and preloads to the `<head>` of HTML and
|
|
65
|
+
* HTMX pages. Defaults to true. */
|
|
66
|
+
injectHtml?: boolean;
|
|
67
|
+
};
|
|
68
|
+
/** What a page needs in its `<head>` to use the built fonts. Plain data,
|
|
69
|
+
* so it can be passed as a page prop and serialized for hydration. */
|
|
70
|
+
export type FontAssets = {
|
|
71
|
+
preload: string[];
|
|
72
|
+
stylesheets: string[];
|
|
73
|
+
};
|
|
74
|
+
/** Vertical and horizontal metrics read from a font file. */
|
|
75
|
+
export type FontMetrics = {
|
|
76
|
+
ascent: number;
|
|
77
|
+
descent: number;
|
|
78
|
+
lineGap: number;
|
|
79
|
+
unitsPerEm: number;
|
|
80
|
+
/** Average advance width of latin text, weighted by letter frequency. */
|
|
81
|
+
averageWidth: number;
|
|
82
|
+
};
|
|
83
|
+
export type FontFetch = (url: string, init?: {
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
signal?: AbortSignal;
|
|
86
|
+
}) => Promise<Response>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type surface for form actions (`defineAction` on the server,
|
|
3
|
+
* `useFormAction` / `enhanceForms` in the browser). Browser code imports
|
|
4
|
+
* these types only, so a page can type its form against a server action
|
|
5
|
+
* with `import type { createUser } from '../../server'` and never pull
|
|
6
|
+
* server code into its bundle.
|
|
7
|
+
*/
|
|
8
|
+
/** Field name → message, one message per field. */
|
|
9
|
+
export type ActionFieldErrors<Fields extends string = string> = Partial<Record<Fields, string>>;
|
|
10
|
+
/** What the user typed, echoed back after a submission without
|
|
11
|
+
* JavaScript failed, so the form can be refilled. Files and fields whose
|
|
12
|
+
* name looks secret (password, token, card…) are never echoed. */
|
|
13
|
+
export type ActionFormValues<Fields extends string = string> = Partial<Record<Fields, string | string[]>>;
|
|
14
|
+
export type ActionIdleState = {
|
|
15
|
+
status: 'idle';
|
|
16
|
+
};
|
|
17
|
+
export type ActionSuccessState<Data = unknown> = {
|
|
18
|
+
status: 'success';
|
|
19
|
+
/** The handler's return value. Undefined after a submission without
|
|
20
|
+
* JavaScript when the value didn't fit the result cookie (~3.5 KB). */
|
|
21
|
+
data?: Data;
|
|
22
|
+
/** Where the browser goes next, when the action sets `redirect`. */
|
|
23
|
+
redirect?: string;
|
|
24
|
+
};
|
|
25
|
+
export type ActionErrorState<Fields extends string = string> = {
|
|
26
|
+
status: 'error';
|
|
27
|
+
errors: ActionFieldErrors<Fields>;
|
|
28
|
+
/** A message for the whole form (`fail(errors, message)`, or a
|
|
29
|
+
* network / server failure seen by the browser helpers). */
|
|
30
|
+
message?: string;
|
|
31
|
+
values?: ActionFormValues<Fields>;
|
|
32
|
+
};
|
|
33
|
+
/** What a submission produces. */
|
|
34
|
+
export type ActionResult<Data = unknown, Fields extends string = string> = ActionErrorState<Fields> | ActionSuccessState<Data>;
|
|
35
|
+
/** A form's state: idle until the first submission. */
|
|
36
|
+
export type ActionState<Data = unknown, Fields extends string = string> = ActionIdleState | ActionResult<Data, Fields>;
|
|
37
|
+
/** The phantom type a `defineAction(...)` result carries, so browser code
|
|
38
|
+
* can name the action with `typeof createUser` and get its path, field
|
|
39
|
+
* names and result type. */
|
|
40
|
+
export type FormActionDefinition<Path extends string = string, Body = unknown, Data = unknown> = {
|
|
41
|
+
readonly actionPath: Path;
|
|
42
|
+
readonly '~formAction'?: {
|
|
43
|
+
body: Body;
|
|
44
|
+
data: Data;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type AnyFormAction = FormActionDefinition;
|
|
48
|
+
export type ActionPath<Action extends AnyFormAction> = Action['actionPath'];
|
|
49
|
+
export type ActionBody<Action extends AnyFormAction> = NonNullable<Action['~formAction']>['body'];
|
|
50
|
+
export type ActionData<Action extends AnyFormAction> = NonNullable<Action['~formAction']>['data'];
|
|
51
|
+
/** The body's field names; any string for an untyped action. */
|
|
52
|
+
export type ActionFields<Action extends AnyFormAction> = unknown extends ActionBody<Action> ? string : Extract<keyof ActionBody<Action>, string>;
|
|
53
|
+
export type ActionResultOf<Action extends AnyFormAction> = ActionResult<ActionData<Action>, ActionFields<Action>>;
|
|
54
|
+
export type ActionStateOf<Action extends AnyFormAction> = ActionState<ActionData<Action>, ActionFields<Action>>;
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -75,6 +75,10 @@ declare global {
|
|
|
75
75
|
* detect this and call `.reload({ fetch })` on the existing server
|
|
76
76
|
* instead of re-binding the port. Stays unset outside dev. */
|
|
77
77
|
var __absoluteBunServer: import('bun').Server | null | undefined;
|
|
78
|
+
/** Angular change detection mode for this process, set by the build
|
|
79
|
+
* and by `installAngularZoneRuntime` (src/angular/zoneRuntime.ts). */
|
|
80
|
+
var __absoluteAngularChangeDetection:
|
|
81
|
+
import('./build').AngularChangeDetection | undefined;
|
|
78
82
|
/** "Building…" placeholder bound by the dev bootstrap before the entry
|
|
79
83
|
* is imported; released by `networking` right before the real listen.
|
|
80
84
|
* See `src/dev/earlyListener.ts`. */
|
|
@@ -160,6 +164,12 @@ declare global {
|
|
|
160
164
|
__ABS_HMR_APPLIES__?: NonNullable<Window['__ABS_HMR_LAST_APPLY__']>[];
|
|
161
165
|
__ERROR_BOUNDARY__?: { reset: () => void };
|
|
162
166
|
__INITIAL_PROPS__?: Record<string, unknown>;
|
|
167
|
+
/** `useServerData` results the Vue page handler serialized for
|
|
168
|
+
* hydration. Entries are removed as components read them. */
|
|
169
|
+
__ABSOLUTE_SERVER_DATA__?: Record<
|
|
170
|
+
string,
|
|
171
|
+
import('./vue').ServerDataEntry
|
|
172
|
+
>;
|
|
163
173
|
__ABSOLUTE_PAGE_RENDER_MODE__?: 'client' | 'hydrate';
|
|
164
174
|
__ABS_REACT_REMOUNT__?: (module: Record<string, unknown>) => void;
|
|
165
175
|
__REACT_COMPONENT_KEY__?: string;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** A message catalog: nested objects whose leaves are ICU MessageFormat
|
|
2
|
+
* strings. Top-level keys double as namespaces (what a page loads). */
|
|
3
|
+
export type MessageCatalog = {
|
|
4
|
+
readonly [key: string]: string | MessageCatalog;
|
|
5
|
+
};
|
|
6
|
+
/** Runtime shape of a catalog after loading (no literal types). */
|
|
7
|
+
export type MessageTree = {
|
|
8
|
+
[key: string]: string | MessageTree;
|
|
9
|
+
};
|
|
10
|
+
/** A value a simple `{name}` argument accepts. Numbers are formatted with
|
|
11
|
+
* `Intl.NumberFormat`, dates with `Intl.DateTimeFormat`. */
|
|
12
|
+
export type MessageValue = string | number | bigint | Date;
|
|
13
|
+
/** The same shape as `Source`, with every leaf widened to `string` — the
|
|
14
|
+
* type a non-default locale's catalog must satisfy. A missing key is a
|
|
15
|
+
* type error. */
|
|
16
|
+
export type Translation<Source> = {
|
|
17
|
+
readonly [K in keyof Source]: Source[K] extends string ? string : Translation<Source[K]>;
|
|
18
|
+
};
|
|
19
|
+
/** Every dot-separated key that leads to a message in `Catalog`. */
|
|
20
|
+
export type MessageKey<Catalog> = string extends keyof Catalog ? string : {
|
|
21
|
+
[K in keyof Catalog & string]: Catalog[K] extends string ? K : `${K}.${MessageKey<Catalog[K]>}`;
|
|
22
|
+
}[keyof Catalog & string];
|
|
23
|
+
/** The message string (literal when the catalog is `as const`) at `Key`. */
|
|
24
|
+
export type MessageAt<Catalog, Key extends string> = Key extends `${infer Head}.${infer Rest}` ? Head extends keyof Catalog ? MessageAt<Catalog[Head], Rest> : never : Key extends keyof Catalog ? Catalog[Key] : never;
|
|
25
|
+
type Whitespace = ' ' | '\n' | '\t' | '\r';
|
|
26
|
+
type Trim<Value extends string> = Value extends `${Whitespace}${infer Rest}` ? Trim<Rest> : Value extends `${infer Rest}${Whitespace}` ? Trim<Rest> : Value;
|
|
27
|
+
type HasChar<Value extends string, Char extends string> = Value extends `${string}${Char}${string}` ? true : false;
|
|
28
|
+
type ArgumentType<Kind extends string> = Kind extends 'number' | 'plural' | 'selectordinal' ? number : Kind extends 'date' | 'time' ? Date | number : Kind extends 'select' ? string : MessageValue;
|
|
29
|
+
type Branching = 'plural' | 'select' | 'selectordinal';
|
|
30
|
+
/** Parse the branches after `{name, plural,` up to the closing `}`. */
|
|
31
|
+
type ParseBranches<Source extends string, Params> = Source extends `${infer Selector}{${infer Body}` ? HasChar<Selector, '}'> extends true ? Source extends `${string}}${infer After}` ? [Params, After] : [Params, ''] : ParseBody<Body, Params> extends [infer Next, infer Rest] ? Rest extends string ? ParseBranches<Rest, Next> : [Params, ''] : [Params, ''] : Source extends `${string}}${infer After}` ? [Params, After] : [Params, ''];
|
|
32
|
+
/** Parse an argument; `Source` starts just after its `{`. */
|
|
33
|
+
type ParseArgument<Source extends string, Params> = Source extends `${infer Head}}${infer After}` ? HasChar<Head, ',' | '{'> extends false ? [Params & Record<Trim<Head>, MessageValue>, After] : ParseTypedArgument<Source, Params> : [Params, ''];
|
|
34
|
+
type ParseTypedArgument<Source extends string, Params> = Source extends `${infer Name},${infer Rest}` ? Rest extends `${infer Kind},${infer Branches}` ? Trim<Kind> extends Branching ? ParseBranches<Branches, Params & Record<Trim<Name>, ArgumentType<Trim<Kind>>>> : ParseFormattedArgument<Name, Rest, Params> : ParseFormattedArgument<Name, Rest, Params> : [Params, ''];
|
|
35
|
+
/** `{name, number}` or `{name, date, short}` (a style never nests). */
|
|
36
|
+
type ParseFormattedArgument<Name extends string, Rest extends string, Params> = Rest extends `${infer Kind}}${infer After}` ? HasChar<Kind, ','> extends false ? [Params & Record<Trim<Name>, ArgumentType<Trim<Kind>>>, After] : Rest extends `${infer StyledKind},${string}}${infer StyledAfter}` ? [
|
|
37
|
+
Params & Record<Trim<Name>, ArgumentType<Trim<StyledKind>>>,
|
|
38
|
+
StyledAfter
|
|
39
|
+
] : [Params, ''] : [Params, ''];
|
|
40
|
+
/** Parse a branch body up to its closing `}`. */
|
|
41
|
+
type ParseBody<Source extends string, Params> = Source extends `${infer Text}{${infer Inner}` ? HasChar<Text, '}'> extends true ? Source extends `${string}}${infer After}` ? [Params, After] : [Params, ''] : ParseArgument<Inner, Params> extends [infer Next, infer Rest] ? Rest extends string ? ParseBody<Rest, Next> : [Params, ''] : [Params, ''] : Source extends `${string}}${infer After}` ? [Params, After] : [Params, ''];
|
|
42
|
+
type ParseMessage<Source extends string, Params> = Source extends `${string}{${infer Inner}` ? ParseArgument<Inner, Params> extends [infer Next, infer Rest] ? Rest extends string ? ParseMessage<Rest, Next> : Params : Params : Params;
|
|
43
|
+
type Flatten<Value> = {
|
|
44
|
+
[K in keyof Value]: Value[K];
|
|
45
|
+
} & {};
|
|
46
|
+
/** The parameters an ICU message string needs, e.g.
|
|
47
|
+
* `MessageParams<'{count, plural, one {# item} other {# items}}'>` is
|
|
48
|
+
* `{ count: number }`. */
|
|
49
|
+
export type MessageParams<Message extends string> = Flatten<ParseMessage<Message, Record<never, never>>>;
|
|
50
|
+
/** The rest arguments `t(key, …)` takes for `Key`: nothing when the
|
|
51
|
+
* message has no arguments, the typed params object when it has. A
|
|
52
|
+
* catalog without literal types (JSON, or `MessageCatalog`) accepts any
|
|
53
|
+
* params. */
|
|
54
|
+
export type TranslateArgs<Catalog, Key extends string> = string extends keyof Catalog ? [params?: Record<string, MessageValue>] : LiteralTranslateArgs<MessageAt<Catalog, Key>>;
|
|
55
|
+
type LiteralTranslateArgs<Message> = Message extends string ? string extends Message ? [params?: Record<string, MessageValue>] : keyof MessageParams<Message> extends never ? [] : [params: MessageParams<Message>] : [params?: Record<string, MessageValue>];
|
|
56
|
+
export type Translate<Catalog> = <Key extends MessageKey<Catalog>>(key: Key, ...args: TranslateArgs<Catalog, Key>) => string;
|
|
57
|
+
export type TextDirection = 'ltr' | 'rtl';
|
|
58
|
+
/** What a page needs to translate on the server and hydrate in the
|
|
59
|
+
* browser: one locale's messages (optionally only some namespaces),
|
|
60
|
+
* already merged over the default locale's. Pass it as a page prop. */
|
|
61
|
+
export type I18nPayload<Locale extends string = string> = {
|
|
62
|
+
locale: Locale;
|
|
63
|
+
defaultLocale: Locale;
|
|
64
|
+
dir: TextDirection;
|
|
65
|
+
messages: MessageTree;
|
|
66
|
+
};
|
|
67
|
+
export type DateInput = Date | number | string;
|
|
68
|
+
export type Translator<Catalog = MessageCatalog> = {
|
|
69
|
+
locale: string;
|
|
70
|
+
dir: TextDirection;
|
|
71
|
+
/** Format the message at `key` with its ICU parameters. A key missing
|
|
72
|
+
* from the catalog renders as the key itself. */
|
|
73
|
+
t: Translate<Catalog>;
|
|
74
|
+
/** Whether the loaded catalog has a message at `key`. */
|
|
75
|
+
has: (key: string) => boolean;
|
|
76
|
+
formatNumber: (value: number | bigint, options?: Intl.NumberFormatOptions) => string;
|
|
77
|
+
formatDate: (value: DateInput, options?: Intl.DateTimeFormatOptions) => string;
|
|
78
|
+
formatRelativeTime: (value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions) => string;
|
|
79
|
+
formatList: (items: readonly string[], options?: Intl.ListFormatOptions) => string;
|
|
80
|
+
};
|
|
81
|
+
/** `<link rel="alternate" hreflang="…" href="…">` in the document head. */
|
|
82
|
+
export type AlternateLink = {
|
|
83
|
+
hreflang: string;
|
|
84
|
+
href: string;
|
|
85
|
+
};
|
|
86
|
+
/** How the request's locale is chosen.
|
|
87
|
+
* - `prefix`: the first path segment (`/fr/about`); unprefixed paths are
|
|
88
|
+
* the default locale unless `prefixDefault` is set.
|
|
89
|
+
* - `domain`: the request host, mapped through `domains`.
|
|
90
|
+
* - `negotiate`: one URL for every locale; the locale cookie, then
|
|
91
|
+
* `Accept-Language`, then the default. */
|
|
92
|
+
export type LocaleStrategy = 'domain' | 'negotiate' | 'prefix';
|
|
93
|
+
/** The routing half of the config: everything needed to map paths and
|
|
94
|
+
* hosts to locales, shared by the server plugin and the sitemap. */
|
|
95
|
+
export type LocaleRoutingConfig<Locale extends string = string> = {
|
|
96
|
+
locales: readonly Locale[];
|
|
97
|
+
defaultLocale: Locale;
|
|
98
|
+
/** Default `prefix`. */
|
|
99
|
+
strategy?: LocaleStrategy;
|
|
100
|
+
/** `prefix` only: put the default locale under its prefix too
|
|
101
|
+
* (`/en/about`). Unprefixed paths then negotiate. Default `false`. */
|
|
102
|
+
prefixDefault?: boolean;
|
|
103
|
+
/** `domain` only: locale → host (`{ fr: 'example.fr' }`). */
|
|
104
|
+
domains?: Partial<Record<Locale, string>>;
|
|
105
|
+
};
|
|
106
|
+
/** A non-default locale's catalog: the object itself, a module whose
|
|
107
|
+
* default export is it, or a loader returning either (lazy). */
|
|
108
|
+
export type MessageSource<Source> = Translation<Source> | (() => Translation<Source> | {
|
|
109
|
+
default: Translation<Source>;
|
|
110
|
+
} | Promise<Translation<Source> | {
|
|
111
|
+
default: Translation<Source>;
|
|
112
|
+
}>);
|
|
113
|
+
export type I18nConfig<Locale extends string, Default extends Locale, Catalog extends MessageCatalog> = Omit<LocaleRoutingConfig<Locale>, 'defaultLocale' | 'domains'> & {
|
|
114
|
+
/** One of `locales`. */
|
|
115
|
+
defaultLocale: Default;
|
|
116
|
+
/** `domain` only: locale → host (`{ fr: 'example.fr' }`). */
|
|
117
|
+
domains?: Partial<Record<NoInfer<Locale>, string>>;
|
|
118
|
+
/** The default locale's catalog: the source of truth for keys and
|
|
119
|
+
* parameter types, and the fallback for any other locale. */
|
|
120
|
+
messages: Catalog;
|
|
121
|
+
/** Every other locale's catalog, loaded on first use. */
|
|
122
|
+
loaders: Record<Exclude<Locale, Default>, MessageSource<NoInfer<Catalog>>>;
|
|
123
|
+
/** Cookie that remembers a visitor's choice (read by `negotiate` and
|
|
124
|
+
* by unprefixed paths under `prefixDefault`). Default `locale`. */
|
|
125
|
+
cookieName?: string;
|
|
126
|
+
/** Route param that carries the locale (`/:locale/about`). A request
|
|
127
|
+
* whose param is not a configured locale gets a 404. Default `locale`. */
|
|
128
|
+
localeParam?: string;
|
|
129
|
+
/** `prefix` + `prefixDefault` only: redirect unprefixed page
|
|
130
|
+
* navigations to the negotiated locale's prefix. Default `false`. */
|
|
131
|
+
redirect?: boolean;
|
|
132
|
+
/** Origin for absolute hreflang URLs (`https://example.com`). Default:
|
|
133
|
+
* the request's origin. */
|
|
134
|
+
baseUrl?: string;
|
|
135
|
+
};
|
|
136
|
+
/** Where a request's locale came from. */
|
|
137
|
+
export type LocaleSource = 'cookie' | 'default' | 'domain' | 'header' | 'path';
|
|
138
|
+
export type LocaleResolution<Locale extends string = string> = {
|
|
139
|
+
locale: Locale;
|
|
140
|
+
source: LocaleSource;
|
|
141
|
+
};
|
|
142
|
+
/** What `defineI18n(config)` returns: usable on its own (prerendering,
|
|
143
|
+
* scripts, tests) and the input to `i18nPlugin()`. */
|
|
144
|
+
export type I18nInstance<Locale extends string = string, Default extends Locale = Locale, Catalog extends MessageCatalog = MessageCatalog> = {
|
|
145
|
+
config: I18nConfig<Locale, Default, Catalog>;
|
|
146
|
+
locales: readonly Locale[];
|
|
147
|
+
defaultLocale: Default;
|
|
148
|
+
isLocale: (value: unknown) => value is Locale;
|
|
149
|
+
/** Which locale `request` is in, and why. */
|
|
150
|
+
resolve: (request: Request) => LocaleResolution<Locale>;
|
|
151
|
+
/** The locale's messages merged over the default locale's; loaded on
|
|
152
|
+
* first use, then cached. */
|
|
153
|
+
load: (locale: Locale) => Promise<MessageTree>;
|
|
154
|
+
/** The hydration payload for `locale`, optionally only the given
|
|
155
|
+
* top-level namespaces. */
|
|
156
|
+
payload: (locale: Locale, namespaces?: readonly (keyof Catalog & string)[]) => Promise<I18nPayload<Locale>>;
|
|
157
|
+
translator: (locale: Locale) => Promise<Translator<Catalog>>;
|
|
158
|
+
/** hreflang alternates for `path`, absolute against `origin` (or the
|
|
159
|
+
* configured `baseUrl`). */
|
|
160
|
+
alternates: (path: string, origin: string) => AlternateLink[];
|
|
161
|
+
localizePath: (path: string, locale: Locale) => string;
|
|
162
|
+
/** A `Set-Cookie` value that remembers `locale`. */
|
|
163
|
+
cookie: (locale: Locale) => string;
|
|
164
|
+
};
|
|
165
|
+
/** The `i18n` object `i18nPlugin()` puts on every request's context. */
|
|
166
|
+
export type RequestI18n<Locale extends string = string, Catalog extends MessageCatalog = MessageCatalog> = Translator<Catalog> & {
|
|
167
|
+
locale: Locale;
|
|
168
|
+
source: LocaleSource;
|
|
169
|
+
/** hreflang alternates for `path` (default: this request's path). */
|
|
170
|
+
alternates: (path?: string) => AlternateLink[];
|
|
171
|
+
/** `path` in `locale` (default: this request's locale). */
|
|
172
|
+
localizePath: (path: string, locale?: Locale) => string;
|
|
173
|
+
/** This locale's messages for hydration — pass it as a page prop.
|
|
174
|
+
* Namespaces limit it to those top-level keys, so a page ships only
|
|
175
|
+
* what it uses. */
|
|
176
|
+
payload: (namespaces?: readonly (keyof Catalog & string)[]) => I18nPayload<Locale>;
|
|
177
|
+
};
|
|
178
|
+
/** Sitemap localization: every page is listed once per locale with
|
|
179
|
+
* `xhtml:link` alternates. Routes registered as `/:locale/…` or
|
|
180
|
+
* `/:locale?/…` are picked up under their unprefixed path. */
|
|
181
|
+
export type SitemapI18nConfig<Locale extends string = string> = LocaleRoutingConfig<Locale> & {
|
|
182
|
+
/** Route param that carries the locale. Default `locale`. */
|
|
183
|
+
localeParam?: string;
|
|
184
|
+
};
|
|
185
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ export * from './conventions';
|
|
|
3
3
|
export * from './build';
|
|
4
4
|
export * from './cli';
|
|
5
5
|
export * from './env';
|
|
6
|
+
export * from './fileRoutes';
|
|
6
7
|
export * from './client';
|
|
8
|
+
export * from './fonts';
|
|
9
|
+
export * from './i18n';
|
|
7
10
|
export * from './image';
|
|
8
11
|
export * from './island';
|
|
9
12
|
export * from './messages';
|
|
@@ -15,3 +18,4 @@ export * from './metadata';
|
|
|
15
18
|
export * from './packageJson';
|
|
16
19
|
export * from './sitemap';
|
|
17
20
|
export * from './websocket';
|
|
21
|
+
export * from './formAction';
|
package/dist/types/metadata.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export type MetaTag = {
|
|
|
35
35
|
httpEquiv?: 'accept-ch' | 'content-security-policy' | 'content-type' | 'default-style' | 'refresh' | 'x-ua-compatible';
|
|
36
36
|
content: string;
|
|
37
37
|
};
|
|
38
|
+
import type { FontAssets } from './fonts';
|
|
39
|
+
import type { AlternateLink } from './i18n';
|
|
38
40
|
import type { JsonLdSchema } from './jsonLd';
|
|
39
41
|
/** A `<link rel="preload">` (or `rel="modulepreload"` when `module` is
|
|
40
42
|
* set) emitted in the document head so the browser starts fetching the
|
|
@@ -61,9 +63,18 @@ export type Metadata = {
|
|
|
61
63
|
title?: string;
|
|
62
64
|
description?: string;
|
|
63
65
|
icon?: string;
|
|
66
|
+
/** A Google Fonts family name linked from fonts.googleapis.com at
|
|
67
|
+
* runtime. Prefer the `fonts` build config with `fonts` below. */
|
|
64
68
|
font?: string;
|
|
69
|
+
/** Self-hosted fonts built from the `fonts` config; pass
|
|
70
|
+
* `fontAssets(manifest)`. */
|
|
71
|
+
fonts?: FontAssets;
|
|
65
72
|
cssPath?: string | string[];
|
|
66
73
|
canonical?: string;
|
|
74
|
+
/** Localized versions of this page, rendered as
|
|
75
|
+
* `<link rel="alternate" hreflang="…" href="…">`. The i18n plugin's
|
|
76
|
+
* `i18n.alternates()` builds the list (with `x-default`). */
|
|
77
|
+
alternates?: AlternateLink[];
|
|
67
78
|
openGraph?: OpenGraph;
|
|
68
79
|
twitter?: TwitterCard;
|
|
69
80
|
robots?: RobotsDirective;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type surface for cross-framework document navigation
|
|
3
|
+
* (`src/client/navigation.ts`, `@absolutejs/absolute/client/navigation`).
|
|
4
|
+
*/
|
|
5
|
+
/** How a navigation ended.
|
|
6
|
+
*
|
|
7
|
+
* - `'swapped'` — the target page replaced the current one in place: no
|
|
8
|
+
* full page load.
|
|
9
|
+
* - `'reloaded'` — the layer handed the navigation to the browser (an
|
|
10
|
+
* error, a non-HTML / non-2xx response, a cross-origin redirect, or a
|
|
11
|
+
* current page that can't be torn down).
|
|
12
|
+
* - `'superseded'` — a newer navigation started before this one finished.
|
|
13
|
+
* - `'cancelled'` — an `absolute:before-navigate` listener called
|
|
14
|
+
* `preventDefault()`. */
|
|
15
|
+
export type DocumentNavigationOutcome = 'cancelled' | 'reloaded' | 'superseded' | 'swapped';
|
|
16
|
+
/** What started a document navigation. */
|
|
17
|
+
export type DocumentNavigationType = 'link' | 'navigate' | 'traverse';
|
|
18
|
+
export type EnableNavigationOptions = {
|
|
19
|
+
/** Decide per URL whether the layer may soft-navigate to it. Return
|
|
20
|
+
* `false` for a full page load. Runs after the built-in checks
|
|
21
|
+
* (same origin, no `target` / `download` / modifier keys, no
|
|
22
|
+
* `data-absolute-navigation="off"`). */
|
|
23
|
+
shouldIntercept?: (url: URL) => boolean;
|
|
24
|
+
/** Wrap the swap in `document.startViewTransition` where supported.
|
|
25
|
+
* Default `true`; skipped for users who prefer reduced motion. */
|
|
26
|
+
viewTransition?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type NavigateDocumentOptions = {
|
|
29
|
+
/** Replace the current history entry instead of pushing one. */
|
|
30
|
+
replace?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/** `detail` of the `absolute:before-navigate` (cancelable) and
|
|
33
|
+
* `absolute:after-navigate` events dispatched on `window`. */
|
|
34
|
+
export type DocumentNavigationEventDetail = {
|
|
35
|
+
type: DocumentNavigationType;
|
|
36
|
+
url: string;
|
|
37
|
+
};
|
package/dist/types/prefetch.d.ts
CHANGED
|
@@ -37,6 +37,16 @@ export type PrefetchMode = 'hover' | 'viewport' | 'none';
|
|
|
37
37
|
export type HoverPrefetchOptions = PrefetchOptions & {
|
|
38
38
|
/** Also inject a prerender speculation rule when the hover fires. */
|
|
39
39
|
prerender?: boolean;
|
|
40
|
+
/** Called when the debounced hover trigger fires, after the prefetch —
|
|
41
|
+
* for warming something the URL alone doesn't name (the Svelte
|
|
42
|
+
* router's lazy route chunks). */
|
|
43
|
+
onPrefetch?: () => void;
|
|
44
|
+
};
|
|
45
|
+
/** Options for a viewport trigger. */
|
|
46
|
+
export type ViewportPrefetchOptions = PrefetchOptions & {
|
|
47
|
+
/** Called once when the element scrolls into view, after the
|
|
48
|
+
* prefetch. */
|
|
49
|
+
onVisible?: () => void;
|
|
40
50
|
};
|
|
41
51
|
export type HoverPrefetchHandle = {
|
|
42
52
|
cancel: () => void;
|
package/dist/types/sitemap.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SitemapI18nConfig } from './i18n';
|
|
1
2
|
export type ChangeFrequency = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
2
3
|
export type SitemapRouteOverride = {
|
|
3
4
|
changefreq?: ChangeFrequency;
|
|
@@ -21,4 +22,7 @@ export type SitemapConfig = {
|
|
|
21
22
|
defaultPriority?: number;
|
|
22
23
|
overrides?: Record<string, SitemapRouteOverride>;
|
|
23
24
|
routes?: () => string[] | Promise<string[]>;
|
|
25
|
+
/** List every page once per locale, each with `xhtml:link` hreflang
|
|
26
|
+
* alternates. Pass the same locales/strategy as `defineI18n()`. */
|
|
27
|
+
i18n?: SitemapI18nConfig;
|
|
24
28
|
};
|