@forinda/kickjs-view 0.5.0 → 0.7.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/dist/cli.d.ts +61 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +1 -1
- package/dist/edge.d.ts +8 -5
- package/dist/edge.js +2 -2
- package/dist/exports-CII2eM6o.js +17 -0
- package/dist/exports-CII2eM6o.js.map +1 -0
- package/dist/file-BIua9gOB.d.ts +925 -0
- package/dist/file-BIua9gOB.d.ts.map +1 -0
- package/dist/file-loader.d.ts +2 -2
- package/dist/file-loader.js +3 -3
- package/dist/file-loader.js.map +1 -1
- package/dist/format-CvHG95ck.js +18 -0
- package/dist/format-CvHG95ck.js.map +1 -0
- package/dist/i18n-EriU9b68.js +12 -0
- package/dist/i18n-EriU9b68.js.map +1 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/project-mP4NzZhQ.d.ts +50 -0
- package/dist/project-mP4NzZhQ.d.ts.map +1 -0
- package/dist/serve-Df9_MrXE.d.ts +173 -0
- package/dist/serve-Df9_MrXE.d.ts.map +1 -0
- package/dist/summary-DOhWOKmu.js +20 -0
- package/dist/summary-DOhWOKmu.js.map +1 -0
- package/package.json +12 -10
- package/virtual.d.ts +4 -1
- package/dist/ast-bZ1jJ5-w.d.ts +0 -372
- package/dist/ast-bZ1jJ5-w.d.ts.map +0 -1
- package/dist/exports-DNeTdtX4.js +0 -17
- package/dist/exports-DNeTdtX4.js.map +0 -1
- package/dist/format-Cig7Gm1h.js +0 -18
- package/dist/format-Cig7Gm1h.js.map +0 -1
- package/dist/project-XUrj8cl0.d.ts +0 -29
- package/dist/project-XUrj8cl0.d.ts.map +0 -1
- package/dist/rolldown-runtime-BLRzqIEa.js +0 -11
- package/dist/serve-fHP-Eia9.d.ts +0 -97
- package/dist/serve-fHP-Eia9.d.ts.map +0 -1
- package/dist/template-DU9sjMgd.js +0 -20
- package/dist/template-DU9sjMgd.js.map +0 -1
- package/dist/views-_eQ9NTKn.d.ts +0 -198
- package/dist/views-_eQ9NTKn.d.ts.map +0 -1
package/dist/views-_eQ9NTKn.d.ts
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { s as CheckedTemplate, v as Diagnostic } from "./ast-bZ1jJ5-w.js";
|
|
3
|
-
/** HTML a pipe or the app marked as trusted: printed unescaped, in text only. */
|
|
4
|
-
declare class SafeHtml {
|
|
5
|
-
readonly html: string;
|
|
6
|
-
constructor(html: string);
|
|
7
|
-
toString(): string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Read `obj[key]` for a template. Forbidden names and function values read
|
|
11
|
-
* as `undefined`, so a template can neither reach a prototype nor get hold of
|
|
12
|
-
* something to call. Getters and Proxy traps run: they are the app's own code.
|
|
13
|
-
*/
|
|
14
|
-
declare function read(obj: unknown, key: unknown): unknown;
|
|
15
|
-
declare const escapeHtml: (s: string) => string;
|
|
16
|
-
/**
|
|
17
|
-
* A URL attribute's value, or `#` when its scheme could run script.
|
|
18
|
-
* Browsers ignore ASCII whitespace and control characters inside a scheme
|
|
19
|
-
* (`java\tscript:`), so those are removed before the scheme is read.
|
|
20
|
-
*/
|
|
21
|
-
declare function sanitizeUrl(value: string): string;
|
|
22
|
-
/** `srcset`: each candidate URL is checked on its own. */
|
|
23
|
-
declare function sanitizeSrcset(value: string): string;
|
|
24
|
-
/** JSON text made safe inside `<script type="application/json">`: no `</script`, no `<!--`. */
|
|
25
|
-
declare const escapeJsonForScript: (json: string) => string;
|
|
26
|
-
/** A CSS value for `[style.prop]`, or `undefined` when it could leave its property. */
|
|
27
|
-
declare function safeStyleValue(v: string): string | undefined;
|
|
28
|
-
type Pipe = (value: unknown, ...args: unknown[]) => unknown;
|
|
29
|
-
interface RenderEnv {
|
|
30
|
-
locale: string;
|
|
31
|
-
timeZone: string;
|
|
32
|
-
strict: boolean;
|
|
33
|
-
pipes: Record<string, Pipe>;
|
|
34
|
-
warn(message: string): void;
|
|
35
|
-
/** A checked template by name: layouts and components. */
|
|
36
|
-
resolve(name: string): CheckedTemplate;
|
|
37
|
-
/** The layout a page gets when it declares none (a folder mapping, usually). */
|
|
38
|
-
layoutFor?(page: string): string | undefined;
|
|
39
|
-
/** The shell wrapped around every page's outermost layout. */
|
|
40
|
-
baseLayout?: string;
|
|
41
|
-
/** `@assets('entry')`: the tags for a Vite entry; `data` is the page's (for a CSP nonce). */
|
|
42
|
-
assets?(entry: string, data: Record<string, unknown>): string;
|
|
43
|
-
/** A component with a `<script client>` rendered: the page ships its script. */
|
|
44
|
-
clientScript?(t: CheckedTemplate): void;
|
|
45
|
-
/** A template with a `validate` field rendered: the page ships the validator script. */
|
|
46
|
-
validation?(): void;
|
|
47
|
-
}
|
|
48
|
-
declare class RenderError extends Error {
|
|
49
|
-
readonly diagnostic: Diagnostic;
|
|
50
|
-
constructor(diagnostic: Diagnostic);
|
|
51
|
-
}
|
|
52
|
-
/** The most components one render may nest — a self-including component stops here. */
|
|
53
|
-
declare const MAX_DEPTH = 64;
|
|
54
|
-
/**
|
|
55
|
-
* Render a checked page with `data`. Its layouts wrap it, outermost last:
|
|
56
|
-
* `opts.layout` (a name, or `false` for none), else the page's `@layout`, else
|
|
57
|
-
* the environment's mapping — then the base layout around the outermost one.
|
|
58
|
-
* `@layout(none)` and `layout: false` skip the base too.
|
|
59
|
-
*/
|
|
60
|
-
declare function render(template: CheckedTemplate, data: object, env: RenderEnv, opts?: {
|
|
61
|
-
layout?: boolean | string;
|
|
62
|
-
}): string;
|
|
63
|
-
declare const BUILTIN_PIPES: readonly string[];
|
|
64
|
-
interface PipeEnv {
|
|
65
|
-
locale: string;
|
|
66
|
-
timeZone: string;
|
|
67
|
-
/** The request's `ctx.urlFor` (params in path order), for `kvRoute`. Absent outside a request. */
|
|
68
|
-
urlFor?: (name: string, params: Array<string | number>) => string;
|
|
69
|
-
}
|
|
70
|
-
declare function builtinPipes(env: PipeEnv): Record<string, Pipe>;
|
|
71
|
-
declare const ENV_PIPE: unique symbol;
|
|
72
|
-
/** A pipe built per render from the render's locale and time zone. */
|
|
73
|
-
interface EnvPipe {
|
|
74
|
-
[ENV_PIPE]: (env: PipeEnv) => Pipe;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* A pipe that needs the render's locale or time zone:
|
|
78
|
-
* `export const ago = withEnv(({ locale }) => (date: Date) => …)`.
|
|
79
|
-
*/
|
|
80
|
-
declare function withEnv(make: (env: PipeEnv) => Pipe): EnvPipe;
|
|
81
|
-
/** Mark HTML as trusted: a pipe returning it prints unescaped, in text only. */
|
|
82
|
-
declare const safeHtml: (html: string) => SafeHtml;
|
|
83
|
-
/** The pipes for one render: the built-ins and the app's, with env pipes built for `env`. */
|
|
84
|
-
declare function pipesFor(app: Record<string, Pipe | EnvPipe>, env: PipeEnv): Record<string, Pipe>;
|
|
85
|
-
declare namespace file_d_exports {
|
|
86
|
-
export { fileLoader, loadPipesFile, readTextFile };
|
|
87
|
-
}
|
|
88
|
-
declare function fileLoader(viewsDir: string): Loader;
|
|
89
|
-
/** The app's pipes file, if there is one, imported as a module. */
|
|
90
|
-
declare function loadPipesFile(file: string): Promise<Record<string, unknown> | undefined>;
|
|
91
|
-
/** A text file's contents, or undefined when there's none. */
|
|
92
|
-
declare function readTextFile(file: string): Promise<string | undefined>;
|
|
93
|
-
interface Loader {
|
|
94
|
-
/** Every template name (`users/show`, `components/user-card`). */
|
|
95
|
-
list(): Promise<string[]>;
|
|
96
|
-
read(name: string): Promise<string>;
|
|
97
|
-
/** Changes when the source changes (an mtime); checked on every render in dev. */
|
|
98
|
-
version?(name: string): Promise<number>;
|
|
99
|
-
}
|
|
100
|
-
/** What a build emits: checked templates as data. */
|
|
101
|
-
interface ViewsBundle {
|
|
102
|
-
v: number;
|
|
103
|
-
templates: Record<string, CheckedTemplate>;
|
|
104
|
-
/** Client scripts bundled by the build: each component's entry file, and every file (entries and shared chunks). */
|
|
105
|
-
client?: {
|
|
106
|
-
entries: Record<string, string>;
|
|
107
|
-
/** Each entry's stylesheets, by component tag. */
|
|
108
|
-
css?: Record<string, string[]>;
|
|
109
|
-
/** Files kept in the bundle (`clientFiles: 'bundle'`). */
|
|
110
|
-
files?: Record<string, string>;
|
|
111
|
-
/** Files the build wrote to disk, under `clientDir` (`clientFiles: 'disk'`). */
|
|
112
|
-
disk?: string[];
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
interface RenderOptions {
|
|
116
|
-
/** A layout for this render, or `false` for none at all (htmx and other partial responses). */
|
|
117
|
-
layout?: boolean | string;
|
|
118
|
-
locale?: string;
|
|
119
|
-
timeZone?: string;
|
|
120
|
-
}
|
|
121
|
-
/** What `share` can read from the request: KickJS's `RequestContext` has both. */
|
|
122
|
-
interface ShareContext {
|
|
123
|
-
req: unknown;
|
|
124
|
-
get(key: string): unknown;
|
|
125
|
-
}
|
|
126
|
-
interface ViewsOptions {
|
|
127
|
-
/** Default `src/views`. */
|
|
128
|
-
viewsDir?: string;
|
|
129
|
-
/** Default `components`, inside the views folder. */
|
|
130
|
-
componentsDir?: string;
|
|
131
|
-
/** Default `src/views/pipes.ts`. Read when `pipes` isn't given and there is no bundle. */
|
|
132
|
-
pipesFile?: string;
|
|
133
|
-
/** Default `<viewsDir>/validators.ts`: the app's browser validators. Read when there is no bundle. */
|
|
134
|
-
validatorsFile?: string;
|
|
135
|
-
pipes?: Record<string, Pipe | EnvPipe>;
|
|
136
|
-
/**
|
|
137
|
-
* The layout a page gets when it declares none: one name, or folder prefix →
|
|
138
|
-
* layout (`{ admin: 'layouts/admin', '': 'layouts/main' }`; the longest prefix wins).
|
|
139
|
-
*/
|
|
140
|
-
layout?: string | Record<string, string>;
|
|
141
|
-
/** The shell (CSS, assets, SEO tags) wrapped around every page's outermost layout. */
|
|
142
|
-
baseLayout?: string;
|
|
143
|
-
/** Default `en-US`. */
|
|
144
|
-
locale?: string;
|
|
145
|
-
/** Default `UTC`. */
|
|
146
|
-
timeZone?: string;
|
|
147
|
-
/** Unresolved names and values that can't print become errors. */
|
|
148
|
-
strict?: boolean;
|
|
149
|
-
/** Default `true`. `false` re-reads and re-checks on every render. */
|
|
150
|
-
cache?: boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Data every render gets, under the page's own: the current user, a CSP nonce.
|
|
153
|
-
* `ctx` is the request the page renders in (KickJS's `RequestContext`), or
|
|
154
|
-
* `undefined` outside one.
|
|
155
|
-
*/
|
|
156
|
-
share?: (ctx: ShareContext | undefined) => object | Promise<object>;
|
|
157
|
-
loader?: Loader;
|
|
158
|
-
/** Checked templates from the build (`virtual:kick-views`); `null` in dev. */
|
|
159
|
-
bundle?: ViewsBundle | null;
|
|
160
|
-
/** Re-check templates whose source changed, on every render. Default: on when `bundle` is `null` (`kick dev`). */
|
|
161
|
-
dev?: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* `@assets('entry')`: usually `(entry, data) => assetTags(entry, mode, data.cspNonce)`.
|
|
164
|
-
* `data` is the page's data with shared data merged in.
|
|
165
|
-
*/
|
|
166
|
-
assets?: (entry: string, data: Record<string, unknown>) => string;
|
|
167
|
-
warn?: (message: string) => void;
|
|
168
|
-
/** Strips a `<script client>`'s TypeScript when a build hasn't. Default: Node's `stripTypeScriptTypes` (22.13+), on the Node entry. */
|
|
169
|
-
stripTypes?: (code: string) => string | Promise<string>;
|
|
170
|
-
/** Where component scripts are served. Default `'/_kick/c'`. */
|
|
171
|
-
clientScriptPath?: string;
|
|
172
|
-
/** A `file:` URL of the folder holding the bundle's `disk` files; `virtual:kick-views` exports it. */
|
|
173
|
-
clientDir?: string;
|
|
174
|
-
}
|
|
175
|
-
interface Views {
|
|
176
|
-
render(name: string, data?: object, opts?: RenderOptions & {
|
|
177
|
-
ctx?: unknown;
|
|
178
|
-
}): Promise<string>;
|
|
179
|
-
/** A component's script by its served file name (`<tag>.<hash>.js`); `undefined` when there's none by that name. */
|
|
180
|
-
clientScript(file: string): Promise<string | undefined>;
|
|
181
|
-
/** A client file (script, stylesheet, asset) by its served name, with its content type. */
|
|
182
|
-
clientFile(file: string): Promise<{
|
|
183
|
-
body: string | Uint8Array;
|
|
184
|
-
type: string;
|
|
185
|
-
} | undefined>;
|
|
186
|
-
/** The path component scripts are served under (`clientScriptPath`). */
|
|
187
|
-
readonly clientScriptPath: string;
|
|
188
|
-
/** Whether `name` is one of these views — `ctx.render` falls through to another engine when not. */
|
|
189
|
-
has(name: string): Promise<boolean>;
|
|
190
|
-
}
|
|
191
|
-
declare function bundleLoader(bundle: ViewsBundle): Loader;
|
|
192
|
-
type FileLoaderModule = typeof file_d_exports;
|
|
193
|
-
declare function useFileLoader(load: () => Promise<FileLoaderModule>): void;
|
|
194
|
-
declare function useStripTypes(strip: (code: string) => string): void;
|
|
195
|
-
declare function useClientFiles(read: ((url: URL) => Promise<Uint8Array>) | undefined): void;
|
|
196
|
-
declare function createViews(options?: ViewsOptions): Views;
|
|
197
|
-
export { read as A, Pipe as C, SafeHtml as D, render as E, sanitizeSrcset as M, sanitizeUrl as N, escapeHtml as O, MAX_DEPTH as S, RenderError as T, safeHtml as _, ViewsBundle as a, PipeEnv as b, createViews as c, useStripTypes as d, fileLoader as f, pipesFor as g, EnvPipe as h, Views as i, safeStyleValue as j, escapeJsonForScript as k, useClientFiles as l, readTextFile as m, RenderOptions as n, ViewsOptions as o, loadPipesFile as p, ShareContext as r, bundleLoader as s, Loader as t, useFileLoader as u, withEnv as v, RenderEnv as w, builtinPipes as x, BUILTIN_PIPES as y };
|
|
198
|
-
//# sourceMappingURL=views-_eQ9NTKn.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"views-_eQ9NTKn.d.ts","names":["_$__loaders_file0"],"sources":["../src/render/safe.ts","../src/render/render.ts","../src/pipes/builtins.ts","../src/pipes/env.ts","../src/loaders/file.ts","../src/views.ts"],"mappings":";;;cAUa;WACU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