@forinda/kickjs-view 0.4.1 → 0.6.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/{ast-CDfapRqX.d.ts → ast-Pq3XT2Xi.d.ts} +164 -13
- package/dist/ast-Pq3XT2Xi.d.ts.map +1 -0
- package/dist/cli.d.ts +60 -4
- 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 +9 -5
- package/dist/edge.js +2 -2
- package/dist/exports-BsyGvnEU.js +17 -0
- package/dist/exports-BsyGvnEU.js.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-DBjtuDUY.js +18 -0
- package/dist/format-DBjtuDUY.js.map +1 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{project-BZtFwrHE.d.ts → project-DeGFHgGJ.d.ts} +24 -7
- package/dist/project-DeGFHgGJ.d.ts.map +1 -0
- package/dist/project-XTTCeVf3.js +12 -0
- package/dist/project-XTTCeVf3.js.map +1 -0
- package/dist/serve-Hc5UlJ56.d.ts +174 -0
- package/dist/serve-Hc5UlJ56.d.ts.map +1 -0
- package/dist/summary-EefMyOjo.js +20 -0
- package/dist/summary-EefMyOjo.js.map +1 -0
- package/dist/{views-DULTB3a4.d.ts → types-D-OIrXCW.d.ts} +190 -45
- package/dist/types-D-OIrXCW.d.ts.map +1 -0
- package/package.json +14 -14
- package/dist/ast-CDfapRqX.d.ts.map +0 -1
- package/dist/exports-S2r1JeKs.js +0 -17
- package/dist/exports-S2r1JeKs.js.map +0 -1
- package/dist/format-D4QQ6P1T.js +0 -18
- package/dist/format-D4QQ6P1T.js.map +0 -1
- package/dist/project-BZtFwrHE.d.ts.map +0 -1
- package/dist/serve-BodTyjAN.d.ts +0 -117
- package/dist/serve-BodTyjAN.d.ts.map +0 -1
- package/dist/template-KYyv-nFs.js +0 -20
- package/dist/template-KYyv-nFs.js.map +0 -1
- package/dist/views-DULTB3a4.d.ts.map +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/diagnostics.d.ts
|
|
3
2
|
/** A point in a template: 0-based offset, 1-based line and column (UTF-16 units). */
|
|
4
3
|
interface Pos {
|
|
5
4
|
offset: number;
|
|
6
5
|
line: number;
|
|
7
6
|
column: number;
|
|
8
7
|
}
|
|
8
|
+
/** A source range in a template, start and end. */
|
|
9
9
|
interface Span {
|
|
10
10
|
start: Pos;
|
|
11
11
|
end: Pos;
|
|
12
12
|
}
|
|
13
|
+
/** An error or warning from parsing, checking or rendering a template. */
|
|
13
14
|
interface Diagnostic {
|
|
14
15
|
file: string;
|
|
15
16
|
span: Span;
|
|
@@ -20,11 +21,11 @@ interface Diagnostic {
|
|
|
20
21
|
}
|
|
21
22
|
/** The position of `offset` in `source`. */
|
|
22
23
|
declare const positionAt: (source: string, offset: number) => Pos;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/ast.d.ts
|
|
25
24
|
/** Bumped when the shape of a checked template changes; builds and runtimes must agree. */
|
|
26
|
-
declare const AST_FORMAT_VERSION =
|
|
25
|
+
declare const AST_FORMAT_VERSION = 3;
|
|
26
|
+
/** A literal value in a template expression. */
|
|
27
27
|
type Literal = string | number | boolean | null;
|
|
28
|
+
/** One step of a path expression: `.name`, `[expr]`, or their `?.` forms. */
|
|
28
29
|
interface PathSegment {
|
|
29
30
|
/** `.name` / `?.name` */
|
|
30
31
|
name?: string;
|
|
@@ -32,6 +33,7 @@ interface PathSegment {
|
|
|
32
33
|
computed?: Expr;
|
|
33
34
|
optional: boolean;
|
|
34
35
|
}
|
|
36
|
+
/** A parsed template expression. */
|
|
35
37
|
type Expr = {
|
|
36
38
|
kind: 'literal';
|
|
37
39
|
value: Literal;
|
|
@@ -71,8 +73,9 @@ type Expr = {
|
|
|
71
73
|
args: Expr[];
|
|
72
74
|
span: Span;
|
|
73
75
|
};
|
|
74
|
-
/** Where an interpolation lands, which decides how its value is escaped
|
|
76
|
+
/** Where an interpolation lands, which decides how its value is escaped. */
|
|
75
77
|
type Ctx = 'text' | 'rcdata' | 'raw-text' | 'comment';
|
|
78
|
+
/** A parsed element attribute. */
|
|
76
79
|
interface Attr {
|
|
77
80
|
/** As written: `href`, `userId` (from `[userId]`), `on` (from `[class.on]`). */
|
|
78
81
|
name: string;
|
|
@@ -90,6 +93,7 @@ interface Attr {
|
|
|
90
93
|
quoted: boolean;
|
|
91
94
|
span: Span;
|
|
92
95
|
}
|
|
96
|
+
/** A parsed HTML element. */
|
|
93
97
|
interface Element {
|
|
94
98
|
k: 'element';
|
|
95
99
|
/** As written. */
|
|
@@ -102,6 +106,7 @@ interface Element {
|
|
|
102
106
|
selfClosing: boolean;
|
|
103
107
|
span: Span;
|
|
104
108
|
}
|
|
109
|
+
/** One branch of an `@if` / `@else if` / `@else` chain. */
|
|
105
110
|
interface IfBranch {
|
|
106
111
|
/** Absent on `@else`. */
|
|
107
112
|
cond?: Expr;
|
|
@@ -109,7 +114,9 @@ interface IfBranch {
|
|
|
109
114
|
alias?: string;
|
|
110
115
|
body: Node[];
|
|
111
116
|
}
|
|
117
|
+
/** A loop variable an `@for` can bind with `let`. */
|
|
112
118
|
type LoopVar = '$index' | '$first' | '$last' | '$even' | '$odd' | '$count';
|
|
119
|
+
/** A parsed template node. */
|
|
113
120
|
type Node = {
|
|
114
121
|
k: 'text';
|
|
115
122
|
value: string;
|
|
@@ -153,35 +160,93 @@ type Node = {
|
|
|
153
160
|
k: 'verbatim';
|
|
154
161
|
text: string;
|
|
155
162
|
span: Span;
|
|
156
|
-
} |
|
|
163
|
+
} |
|
|
164
|
+
/** `<slot name="n" [x]="expr">`: the values (`offers`) it hands the caller's content */
|
|
165
|
+
{
|
|
157
166
|
k: 'slot-outlet';
|
|
158
167
|
name?: string;
|
|
168
|
+
offers: Array<{
|
|
169
|
+
name: string;
|
|
170
|
+
expr: Expr;
|
|
171
|
+
span: Span;
|
|
172
|
+
}>;
|
|
159
173
|
fallback: Node[];
|
|
160
174
|
span: Span;
|
|
161
|
-
} |
|
|
175
|
+
} |
|
|
176
|
+
/** `@slot('n'; let a, b = c) { }`: `lets` bind offered values (`from`) to names */
|
|
177
|
+
{
|
|
162
178
|
k: 'slot-fill';
|
|
163
179
|
name: string;
|
|
180
|
+
lets: Array<{
|
|
181
|
+
name: string;
|
|
182
|
+
from: string;
|
|
183
|
+
}>;
|
|
164
184
|
body: Node[];
|
|
165
185
|
span: Span;
|
|
166
186
|
} | {
|
|
167
187
|
k: 'assets';
|
|
168
188
|
entry: string;
|
|
169
189
|
span: Span;
|
|
190
|
+
} |
|
|
191
|
+
/** `@fragment('name') { }`: a block a render can ask for on its own */
|
|
192
|
+
{
|
|
193
|
+
k: 'fragment';
|
|
194
|
+
name: string;
|
|
195
|
+
body: Node[];
|
|
196
|
+
span: Span;
|
|
197
|
+
} |
|
|
198
|
+
/** `@push('name') { }`: content for a layout's `<stack name>` */
|
|
199
|
+
{
|
|
200
|
+
k: 'push';
|
|
201
|
+
name: string;
|
|
202
|
+
body: Node[];
|
|
203
|
+
span: Span;
|
|
204
|
+
} |
|
|
205
|
+
/** `@snippet name(a, b = 'x') { }`: a block of markup with parameters, top level only */
|
|
206
|
+
{
|
|
207
|
+
k: 'snippet';
|
|
208
|
+
name: string;
|
|
209
|
+
params: Array<{
|
|
210
|
+
name: string;
|
|
211
|
+
default?: Literal;
|
|
212
|
+
}>;
|
|
213
|
+
body: Node[];
|
|
214
|
+
span: Span;
|
|
215
|
+
} |
|
|
216
|
+
/** `@render name(args)`: run a snippet of this file */
|
|
217
|
+
{
|
|
218
|
+
k: 'render';
|
|
219
|
+
name: string;
|
|
220
|
+
args: Expr[];
|
|
221
|
+
span: Span;
|
|
222
|
+
} |
|
|
223
|
+
/** `<stack name="…" />`: where pushed content goes; `children` must be blank (checked) */
|
|
224
|
+
{
|
|
225
|
+
k: 'stack';
|
|
226
|
+
name: string;
|
|
227
|
+
children: Node[];
|
|
228
|
+
span: Span;
|
|
170
229
|
};
|
|
230
|
+
/** An `@input` declaration, with its default when given. */
|
|
171
231
|
interface InputDecl {
|
|
172
232
|
name: string;
|
|
233
|
+
/** `@input name: Type`: the TypeScript type, as written (typegen copies it) */
|
|
234
|
+
type?: string;
|
|
173
235
|
default?: {
|
|
174
236
|
value: Literal;
|
|
175
237
|
span: Span;
|
|
176
238
|
};
|
|
177
239
|
span: Span;
|
|
178
240
|
}
|
|
241
|
+
/** A parsed template: its layout, inputs and body. */
|
|
179
242
|
interface TemplateAst {
|
|
180
243
|
file: string;
|
|
181
244
|
/** `undefined`: none declared (the default layout applies); `null`: `@layout(none)`. */
|
|
182
245
|
layout?: string | null;
|
|
183
246
|
layoutSpan?: Span;
|
|
184
247
|
inputs: InputDecl[];
|
|
248
|
+
/** `@import type … from '…'` lines, as written without the `@` (typegen copies them) */
|
|
249
|
+
typeImports?: string[];
|
|
185
250
|
body: Node[];
|
|
186
251
|
}
|
|
187
252
|
/** `[line, column]` of a node in its template, for render errors. */
|
|
@@ -194,6 +259,7 @@ type CSeg = {
|
|
|
194
259
|
e: CExpr;
|
|
195
260
|
o?: 1;
|
|
196
261
|
};
|
|
262
|
+
/** A checked expression, as the renderer reads it. */
|
|
197
263
|
type CExpr =
|
|
198
264
|
/** literal */
|
|
199
265
|
{
|
|
@@ -276,6 +342,18 @@ type CAttr =
|
|
|
276
342
|
e: CExpr;
|
|
277
343
|
x?: string;
|
|
278
344
|
};
|
|
345
|
+
/** A checked template node, as the renderer walks it. */
|
|
346
|
+
/**
|
|
347
|
+
* Slot content: its nodes, compiled in the caller's scope, and the offered
|
|
348
|
+
* values it takes (`let x = from`), each bound to caller slot `s`.
|
|
349
|
+
*/
|
|
350
|
+
interface CFill {
|
|
351
|
+
nodes: CNode[];
|
|
352
|
+
params?: Array<{
|
|
353
|
+
from: string;
|
|
354
|
+
s: number;
|
|
355
|
+
}>;
|
|
356
|
+
}
|
|
279
357
|
type CNode =
|
|
280
358
|
/** static output */
|
|
281
359
|
{
|
|
@@ -285,7 +363,7 @@ type CNode =
|
|
|
285
363
|
/** `{{ e }}`: `text` escapes HTML (trusted HTML prints as is), `rcdata` (`<title>`, `<textarea>`) escapes everything, `json` is the one value of a JSON script */
|
|
286
364
|
{
|
|
287
365
|
k: 'i';
|
|
288
|
-
c: 'text' | 'rcdata' | 'json';
|
|
366
|
+
c: 'text' | 'rcdata' | 'json' | 'css';
|
|
289
367
|
e: CExpr;
|
|
290
368
|
at: At;
|
|
291
369
|
} |
|
|
@@ -332,19 +410,87 @@ type CNode =
|
|
|
332
410
|
s: number;
|
|
333
411
|
e: CExpr;
|
|
334
412
|
}>;
|
|
413
|
+
/** inputs of wrapped components further down the chain, by name */
|
|
414
|
+
ci?: Array<{
|
|
415
|
+
n: string;
|
|
416
|
+
e: CExpr;
|
|
417
|
+
}>;
|
|
335
418
|
fa: CAttr[];
|
|
336
|
-
f: Record<string,
|
|
419
|
+
f: Record<string, CFill>;
|
|
420
|
+
/** this call is its template's root: it takes the caller's chained attributes */
|
|
421
|
+
r?: 1;
|
|
337
422
|
at: At;
|
|
338
423
|
} |
|
|
339
|
-
/**
|
|
424
|
+
/**
|
|
425
|
+
* `<slot name="n" [x]="e">fallback</slot>`: `v` are the values it offers;
|
|
426
|
+
* while the fallback renders they sit in slots `fs` (same order).
|
|
427
|
+
*/
|
|
340
428
|
{
|
|
341
429
|
k: 'o';
|
|
342
430
|
n: string;
|
|
343
431
|
fb: CNode[];
|
|
432
|
+
v?: Array<{
|
|
433
|
+
n: string;
|
|
434
|
+
e: CExpr;
|
|
435
|
+
}>;
|
|
436
|
+
fs?: number[];
|
|
437
|
+
} |
|
|
438
|
+
/**
|
|
439
|
+
* `<component [is]="e" of="…">`: one compiled call per candidate tag, picked
|
|
440
|
+
* by `e`. The slot content `f` is compiled once, here, and given to whichever
|
|
441
|
+
* candidate renders (it's in the caller's scope, the same for all).
|
|
442
|
+
*/
|
|
443
|
+
{
|
|
444
|
+
k: 'dyn';
|
|
445
|
+
e: CExpr;
|
|
446
|
+
c: Record<string, CNode>;
|
|
447
|
+
f: Record<string, CFill>;
|
|
448
|
+
at: At;
|
|
449
|
+
} |
|
|
450
|
+
/** `@render n(args)`: run snippet `n` of the current template */
|
|
451
|
+
{
|
|
452
|
+
k: 'rnd';
|
|
453
|
+
n: string;
|
|
454
|
+
a: CExpr[];
|
|
455
|
+
at: At;
|
|
456
|
+
} |
|
|
457
|
+
/** `@push('n') { }`: rendered, then added to stack `n` */
|
|
458
|
+
{
|
|
459
|
+
k: 'push';
|
|
460
|
+
n: string;
|
|
461
|
+
b: CNode[];
|
|
462
|
+
} |
|
|
463
|
+
/** `<stack name="n" />`: filled once the render is done */
|
|
464
|
+
{
|
|
465
|
+
k: 'stk';
|
|
466
|
+
n: string;
|
|
344
467
|
} | {
|
|
345
468
|
k: 'as';
|
|
346
469
|
en: string;
|
|
347
470
|
};
|
|
471
|
+
/** A template after `check`: plain JSON the renderer walks, which a build can ship as data. */
|
|
472
|
+
/**
|
|
473
|
+
* A `@snippet`, in its own slot space: the template's inputs first (same
|
|
474
|
+
* indexes as in the template), then `params`, then its own variables.
|
|
475
|
+
*/
|
|
476
|
+
interface CSnippet {
|
|
477
|
+
params: number[];
|
|
478
|
+
defaults: Array<Literal | undefined>;
|
|
479
|
+
slots: number;
|
|
480
|
+
body: CNode[];
|
|
481
|
+
/** a field in it has `validate` */
|
|
482
|
+
validates?: true;
|
|
483
|
+
}
|
|
484
|
+
/** A page's `@fragment`, compiled to render on its own. */
|
|
485
|
+
interface CheckedFragment {
|
|
486
|
+
/** names enclosing blocks bound (loop items, aliases, `@let`): the caller passes them */
|
|
487
|
+
needs: string[];
|
|
488
|
+
/** scope slots the unit needs */
|
|
489
|
+
slots: number;
|
|
490
|
+
body: CNode[];
|
|
491
|
+
/** a field in it has `validate` */
|
|
492
|
+
validates?: true;
|
|
493
|
+
}
|
|
348
494
|
interface CheckedTemplate {
|
|
349
495
|
v: typeof AST_FORMAT_VERSION;
|
|
350
496
|
name: string;
|
|
@@ -361,7 +507,7 @@ interface CheckedTemplate {
|
|
|
361
507
|
r: boolean;
|
|
362
508
|
}>;
|
|
363
509
|
/** `@slot('name') { }` fills a page passes to its layout */
|
|
364
|
-
fills: Record<string,
|
|
510
|
+
fills: Record<string, CFill>;
|
|
365
511
|
body: CNode[];
|
|
366
512
|
/** a component's `<script client>`: TypeScript as written (`js: false`), or plain JS once a build stripped it */
|
|
367
513
|
client?: {
|
|
@@ -370,7 +516,12 @@ interface CheckedTemplate {
|
|
|
370
516
|
};
|
|
371
517
|
/** a field in it has `validate`: pages rendering it ship the validator script */
|
|
372
518
|
validates?: true;
|
|
519
|
+
/** a page's `@input name = value` defaults: data that fills in when nobody supplied it */
|
|
520
|
+
defaults?: Record<string, Literal>;
|
|
521
|
+
/** its `@snippet`s, by name */
|
|
522
|
+
snippets?: Record<string, CSnippet>;
|
|
523
|
+
/** its `@fragment`s, by name */
|
|
524
|
+
fragments?: Record<string, CheckedFragment>;
|
|
373
525
|
}
|
|
374
|
-
//#endregion
|
|
375
526
|
export { TemplateAst as _, CNode as a, Span as b, Ctx as c, IfBranch as d, InputDecl as f, PathSegment as g, Node as h, CExpr as i, Element as l, LoopVar as m, Attr as n, CSeg as o, Literal as p, CAttr as r, CheckedTemplate as s, AST_FORMAT_VERSION as t, Expr as u, Diagnostic as v, positionAt as x, Pos as y };
|
|
376
|
-
//# sourceMappingURL=ast-
|
|
527
|
+
//# sourceMappingURL=ast-Pq3XT2Xi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-Pq3XT2Xi.d.ts","names":[],"sources":["../src/diagnostics.ts","../src/ast.ts"],"mappings":";;UACiB;EACf;EACA;EACA;;;UAIe;EACf,OAAO;EACP,KAAK;;;UAIU;EACf;EACA,MAAM;EACN;EACA;;EAEA;;;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3B,IAAI;EACJ,GAAG,eAAe;;EAElB;EACA,IAAI;;;;;;;EAMJ;EAAQ;EAAW,IAAI;EAAS,IAAI;IAAQ;IAAW,GAAG;;EAAU;;;;;;;;EAMpE;EAAU,GAAG;EAAO,GAAG,eAAe;EAAQ,GAAG,eAAe;EAAQ,IAAI;;;;EAE5E;EAAU;EAAW,GAAG;EAAS,IAAI;;;;EAErC;EAAW;EAAW,GAAG;;;;EAEzB;EAAU;;EACV;EAAS;;;;;;;UAOE;EACf;EACA,UAAU,MAAM;EAChB;EACA,MAAM;;EAEN;;;UAIe;;EAEf;;EAEA;EACA,MAAM;;EAEN;;UAGe;EACf,UAAU;EACV;EACA;;EAEA;;EAEA;;EAEA,QAAQ;IAAQ;IAAW;IAAW,IAAI;IAAS;;;EAEnD,OAAO,eAAe;EACtB,MAAM;;EAEN;IAAW;IAAc;;;EAEzB;;EAEA,WAAW,eAAe;;EAE1B,WAAW,eAAe;;EAE1B,YAAY,eAAe"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,14 +1,45 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as Project } from "./project-
|
|
2
|
+
import { t as Project } from "./project-DeGFHgGJ.js";
|
|
3
3
|
import { KickCliPlugin } from "@forinda/kickjs-cli-kit";
|
|
4
|
-
|
|
4
|
+
/** kick.config's `views` block. */
|
|
5
|
+
interface ViewsConfig {
|
|
6
|
+
/** The app's own templates. Default `src/views`. */
|
|
7
|
+
dir?: string;
|
|
8
|
+
/**
|
|
9
|
+
* More folders, by name: `billing::invoices/show`. A value starting with
|
|
10
|
+
* `.` or `/` is a folder; otherwise an installed package (its package.json
|
|
11
|
+
* `"kick": { "views": "views" }`), else a folder.
|
|
12
|
+
*/
|
|
13
|
+
roots?: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/** A view root, resolved. */
|
|
16
|
+
interface ViewRoot {
|
|
17
|
+
name: string;
|
|
18
|
+
/** Absolute. */
|
|
19
|
+
dir: string;
|
|
20
|
+
/** Inside `node_modules` (an installed package): not watched or formatted. */
|
|
21
|
+
readOnly: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Where package `pkg` is installed for the project at `root`, looking up the folders as Node does. */
|
|
24
|
+
export declare function packageDir(root: string, pkg: string): string | undefined;
|
|
25
|
+
/** The app's views folder and its named roots; `projectRoot` holds kick.config.ts. Throws on a bad root. */
|
|
26
|
+
export declare function resolveViewRoots(projectRoot: string, views?: ViewsConfig): {
|
|
27
|
+
dir: string;
|
|
28
|
+
roots: ViewRoot[];
|
|
29
|
+
};
|
|
30
|
+
/** kick.config's `views` block, if the config has one. */
|
|
31
|
+
export declare const viewsConfigOf: (config: unknown) => ViewsConfig | undefined;
|
|
32
|
+
/** For `createViews({ roots })`: name → absolute folder. */
|
|
33
|
+
export declare function rootFolders(roots: ViewRoot[]): Record<string, string>;
|
|
5
34
|
export interface ViewsCliOptions {
|
|
6
35
|
/** Project root. */
|
|
7
36
|
root: string;
|
|
8
37
|
/** Views folder, relative to the root. Default `src/views`. */
|
|
9
38
|
dir?: string;
|
|
10
|
-
/** Only these files (relative to the root). Default: every `.kick` file in the views
|
|
39
|
+
/** Only these files (relative to the root). Default: every `.kick` file in the views folders. */
|
|
11
40
|
paths?: string[];
|
|
41
|
+
/** Named view roots (from kick.config's `views.roots`, via `resolveViewRoots`). */
|
|
42
|
+
roots?: ViewRoot[];
|
|
12
43
|
log: (message: string) => void;
|
|
13
44
|
}
|
|
14
45
|
/** Format templates in place, or with `check` report the ones that would change. Returns the exit code. */
|
|
@@ -25,6 +56,31 @@ export declare function checkViews(opts: ViewsCliOptions & {
|
|
|
25
56
|
layouts?: Project['layouts'];
|
|
26
57
|
baseLayout?: string;
|
|
27
58
|
}): Promise<number>;
|
|
59
|
+
/** Where the app's views live, for the commands' defaults and the `kick/views` typegen. */
|
|
60
|
+
export interface KickViewsCliOptions {
|
|
61
|
+
/** Views folder, relative to the project root. Default `src/views`. */
|
|
62
|
+
dir?: string;
|
|
63
|
+
/** Components folder, inside the views folder. Default `components`. */
|
|
64
|
+
componentsDir?: string;
|
|
65
|
+
/** Pipes file. Default `<dir>/pipes.ts`. */
|
|
66
|
+
pipes?: string;
|
|
67
|
+
/** Validators file. Default `<dir>/validators.ts`. */
|
|
68
|
+
validators?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The view package's CLI plugin: `kick check:views`, `kick fmt:views`, and the
|
|
72
|
+
* `kick/views` typegen that types `ctx.render` from your templates. Pass the
|
|
73
|
+
* options when your views aren't in `src/views`:
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* // kick.config.ts
|
|
77
|
+
* plugins: [kickViewsCli({ dir: 'app/views' })]
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see https://kickjs.app/guide/views/typed-render-data
|
|
81
|
+
*/
|
|
82
|
+
export declare function kickViewsCli(options?: KickViewsCliOptions): KickCliPlugin;
|
|
83
|
+
/** The plugin with default folders — `kickViewsCli()`. */
|
|
28
84
|
export declare const viewCliPlugin: KickCliPlugin;
|
|
29
|
-
|
|
85
|
+
export type { ViewRoot, ViewsConfig };
|
|
30
86
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/cli.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","names":[],"sources":["../src/roots.ts","../src/cli.ts"],"mappings":";;;;UAgBiB;;EAEf;;;;;;EAMA,QAAQ;;;UAIO;EACf;;EAEA;;EAEA;;;wBAIc,WAAW,cAAc;;wBASzB,iBACd,qBACA,QAAO;EACJ;EAAa,OAAO;;;qBA+BZ,gBAAa,oBAAsB;;wBAIhC,YAAY,OAAO,aAAa;iBChE/B;;EAEf;;EAEA;;EAEA;;EAEA,QAAQ;EACR,MAAM;;;wBAOc,SACpB,MAAM;EAAoB;EAAiB;IAC1C;;wBA+BmB,WACpB,MAAM;EACJ;;EAEA;EACA;EACA,UAAU;EACV;IAED;;iBAsBc;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;wBAec,aAAa,UAAS,sBAA2B;;qBAmEpD,eAAe"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-view v0.
|
|
2
|
+
* @forinda/kickjs-view v0.6.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{d as readPipeExports,f as BUILTIN_PIPES,n as
|
|
11
|
+
import{a as check,d as readPipeExports,f as BUILTIN_PIPES,i as parse,n as mergeSummary,r as summarize,u as readValidatorExports}from"./summary-EefMyOjo.js";import{c as splitName,i as isComponent,o as qualify,s as resolveRef,t as ROOT_NAME}from"./project-XTTCeVf3.js";import{t as format}from"./format-DBjtuDUY.js";import{readFile,readdir,writeFile}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";async function templates(viewsDir,root,paths){return paths?.length?paths.map(p=>relative(viewsDir,resolve(root,p))).filter(p=>p.endsWith(`.kick`)&&!p.startsWith(`..`)).map(p=>p.slice(0,-5).split(sep).join(`/`)):existsSync(viewsDir)?(await readdir(viewsDir,{recursive:!0,withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.kick`)).map(e=>relative(viewsDir,join(direntDir(e),e.name)).slice(0,-5).split(sep).join(`/`)).toSorted():[]}function direntDir(e){return e.parentPath??e.path??``}async function allTemplates(viewsDir,root,roots=[],paths){let out=await templates(viewsDir,root,paths);for(let r of roots)for(let name of await templates(r.dir,root,paths))out.push(qualify(r.name,name));return out}async function loadViewsProject(loc){let dir=loc.dir??`src/views`,viewsDir=resolve(loc.root,dir),pipesFile=resolve(loc.root,loc.pipesFile??join(dir,`pipes.ts`)),validatorsFile=resolve(loc.root,loc.validatorsFile??join(dir,`validators.ts`)),diagnostics=[],pipes=new Set(BUILTIN_PIPES);if(existsSync(pipesFile)){let read=readPipeExports(await readFile(pipesFile,`utf8`),relative(loc.root,pipesFile));for(let n of read.names)pipes.add(n);for(let d of read.diagnostics)diagnostics.push({d,prefix:``})}let validators=/* @__PURE__ */ new Set;if(existsSync(validatorsFile)){let read=readValidatorExports(await readFile(validatorsFile,`utf8`),relative(loc.root,validatorsFile));for(let n of read.names)validators.add(n);for(let d of read.diagnostics)diagnostics.push({d,prefix:``})}let project={templates:/* @__PURE__ */ new Map,pipes,validators,componentsDir:loc.componentsDir??`components`,layouts:loc.layouts,baseLayout:loc.baseLayout},rootDirs=new Map((loc.roots??[]).map(r=>[r.name,r.dir])),absOf=name=>{let{root,path}=splitName(name);return join(root===void 0?viewsDir:rootDirs.get(root),`${path}.kick`)},fileOf=name=>relative(loc.root,absOf(name)).split(sep).join(`/`),prefixOf=name=>splitName(name).root===void 0?`${dir}/`:``,names=await allTemplates(viewsDir,loc.root,loc.roots),unparsed=/* @__PURE__ */ new Set;for(let name of names){let label=splitName(name).root===void 0?`${name}.kick`:fileOf(name),r=parse(await readFile(absOf(name),`utf8`),label);project.templates.set(name,r.ast);for(let d of r.diagnostics)diagnostics.push({d,prefix:prefixOf(name)});r.diagnostics.some(d=>d.severity===`error`)&&unparsed.add(name)}return{project,dir,viewsDir,names,diagnostics,unparsed,fileOf,prefixOf}}function packageDir(root,pkg){for(let dir=resolve(root);;dir=dirname(dir)){let at=join(dir,`node_modules`,pkg);if(existsSync(join(at,`package.json`)))return at;if(dirname(dir)===dir)return}}function resolveViewRoots(projectRoot,views={}){let roots=Object.entries(views.roots??{}).map(([name,value])=>{if(!ROOT_NAME.test(name))throw Error(`views.roots: '${name}' isn't a valid root name (lowercase letters, digits and -, starting with a letter)`);let dir=rootDir(projectRoot,name,value);if(!existsSync(dir))throw Error(`views.roots.${name}: no folder at ${dir}`);return{name,dir,readOnly:realpathSync(dir).split(sep).includes(`node_modules`)}});return{dir:resolve(projectRoot,views.dir??`src/views`),roots}}function rootDir(projectRoot,name,value){if(value.startsWith(`.`)||value.startsWith(`/`))return resolve(projectRoot,value);let pkg=packageDir(projectRoot,value);if(!pkg)return resolve(projectRoot,value);let views=JSON.parse(readFileSync(join(pkg,`package.json`),`utf8`)).kick?.views;if(typeof views!=`string`)throw Error(`views.roots.${name}: package ${value} has no "kick": { "views": "<folder>" } (kick.views) in its package.json`);return resolve(pkg,views)}const viewsConfigOf=config=>config?.views;function rootFolders(roots){return Object.fromEntries(roots.map(r=>[r.name,r.dir]))}const IDENT=/^[A-Za-z_$][\w$]*$/,key=k=>IDENT.test(k)?k:`'${k.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`;function shapeType(s){switch(s.k){case`unknown`:return`unknown`;case`object`:return objectType(s.props);case`list`:{let item=shapeType(s.item);return`readonly ${item.includes(` | `)?`(${item})`:item}[] | ReadonlySet<${item}>${s.item.k===`unknown`?` | string`:``}`}case`pairs`:{let value=shapeType(s.value);return`ReadonlyMap<unknown, ${value}> | readonly (readonly [unknown, ${value}])[]`}}}function fieldType(f){let t=shapeType(f.shape);return f.nullable?`${t} | null | undefined`:t===`unknown`?`NonNullable<unknown>`:t}function objectType(props){let parts=Object.entries(props).map(([k,f])=>`${key(k)}${f.optional?`?`:``}: ${fieldType(f)}`);return parts.length?`{ ${parts.join(`; `)} }`:`{}`}function dataType(s,fields=s.fields,onlyFields=!1){let parts=[],names=(onlyFields?Object.keys(fields):[.../* @__PURE__ */ new Set([...Object.keys(fields),...Object.keys(s.declared)])]).toSorted();for(let name of names){let declared=s.declared[name],field=fields[name];declared?parts.push(`${key(name)}${declared.optional?`?`:``}: ${declared.type??(field?fieldType(field):`unknown`)}`):field&&parts.push(`${key(name)}${field.optional?`?`:``}: ${fieldType(field)}`)}return parts.length?`{ ${parts.join(`; `)} }`:`{}`}function repoint(spec,templateFile,outDir,root){let abs=resolve(root,dirname(templateFile),spec),rel=relative(outDir,abs).split(sep).join(`/`);return rel.startsWith(`.`)?rel:`./${rel}`}function importLine(line,templateFile,outDir,root){return line.replace(/(\bfrom\s*)(['"])(\.[^'"]*)\2/,(_,from,q,spec)=>`${from}${q}${repoint(spec,templateFile,outDir,root)}${q}`)}const escape=name=>name.replace(/\$/g,`\\$`),refTo=names=>RegExp(`(?<![\\w$.])(?:${names.map(escape).join(`|`)})(?![\\w$])(?!\\s*\\??\\s*:)`,`g`),STRINGS=/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g;function renameRefs(type,rename){if(!rename.size)return type;let ref=refTo([...rename.keys()]);return type.replace(/('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")|[^'"]+/g,(part,quoted)=>quoted?part:part.replace(ref,local=>rename.get(local)))}function renderViewTypes(entries,opts){let{imports,entries:aliased}=opts.aliased?{imports:opts.aliased,entries}:aliasImports(entries,opts);entries=aliased;let body=entries.toSorted((a,b)=>a.name.localeCompare(b.name)).map(e=>{let fragments=Object.entries(e.summary.fragments).map(([name,f])=>`${key(name)}: { needs: ${objectType(f.needs)}; reads: ${dataType(e.summary,f.reads,!0)} }`).join(`; `);return[` // from ${e.file}`,` ${key(e.name)}: {`,` data: ${dataType(e.summary)}`,` fragments: ${fragments?`{ ${fragments} }`:`{}`}`,` }`].join(`
|
|
12
|
+
`)}).join(`
|
|
13
|
+
`),blocks=opts.modules.map(m=>`declare module '${m}' {\n interface KickViews {\n${body}\n }\n}`);return["// Generated by `kick typegen` (kick/views) from your .kick templates. Do not edit.",...imports,``,...blocks,``,`export {}`,``].join(`
|
|
14
|
+
`)}function aliasImports(entries,opts){let byModule=/* @__PURE__ */ new Map,owner=/* @__PURE__ */ new Map,other=/* @__PURE__ */ new Set,out=entries.map(e=>{let rename=/* @__PURE__ */ new Map;for(let line of e.summary.imports){let rewritten=importLine(line,e.file,opts.outDir,opts.projectRoot),m=/^import\s+type\s*\{([^}]*)\}\s*from\s*(['"])([^'"]+)\2$/.exec(rewritten.replace(/\/\*[\s\S]*?\*\//g,``).trim());if(!m){other.add(rewritten);continue}let from=m[3],names=byModule.get(from)??/* @__PURE__ */ new Map;byModule.set(from,names);for(let spec of m[1].split(`,`)){let sm=/^\s*([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/.exec(spec);if(!sm)continue;let exported=sm[1],local=sm[2]??exported,id=`${from}\0${exported}`,alias=names.get(exported);if(!alias){alias=local;for(let n=2;owner.has(alias)&&owner.get(alias)!==id;n++)alias=`${local}_${n}`;owner.set(alias,id),names.set(exported,alias)}alias!==local&&rename.set(local,alias)}}let declared={};for(let[name,d]of Object.entries(e.summary.declared)){let type=d.type?renameRefs(d.type,rename).replace(/\bimport\(\s*(['"])(\.[^'"]*)\1\s*\)/g,(_,q,spec)=>`import(${q}${repoint(spec,e.file,opts.outDir,opts.projectRoot)}${q})`):void 0;declared[name]={...d,...type?{type}:{}}}return{...e,summary:{...e.summary,declared}}}),used=out.flatMap(e=>Object.values(e.summary.declared).map(d=>(d.type??``).replace(STRINGS,`''`))),isUsed=alias=>used.some(t=>refTo([alias]).test(t));return{imports:[...[...byModule].flatMap(([from,names])=>{let kept=[...names].filter(([,a])=>isUsed(a));return kept.length?[`import type { ${kept.map(([x,a])=>x===a?x:`${x} as ${a}`).join(`, `)} } from '${from}'`]:[]}),...[...other].filter(line=>{let m=/^import\s+type\s+(?:\*\s+as\s+)?([A-Za-z_$][\w$]*)\s+from\b/.exec(line.trim());return!m||isUsed(m[1])})],entries:out}}const PACKAGES=[`@forinda/kickjs`,`@forinda/kickjs-view`],installedIn=root=>pkg=>packageDir(root,pkg)!==void 0;function viewsTypegen(options={},deps={}){let dir=options.dir??`src/views`;return{id:`kick/views`,outExtension:`.ts`,inputs:[`${dir}/**/*.kick`,options.pipes??`${dir}/pipes.ts`],async generate(ctx){let views=viewsConfigOf(ctx.config),loaded=await loadViewsProject({root:ctx.cwd,dir:options.dir??views?.dir??`src/views`,roots:resolveViewRoots(ctx.cwd,views).roots,componentsDir:options.componentsDir,pipesFile:options.pipes,validatorsFile:options.validators}),installed=deps.installed??installedIn(ctx.cwd),modules=PACKAGES.filter(m=>installed(m));if(!modules.length)return null;let outDir=resolve(ctx.cwd,`.kickjs/types`);if(!loaded.names.length)return renderViewTypes([],{modules,outDir,projectRoot:ctx.cwd,aliased:[]});let summaries=/* @__PURE__ */ new Map,failed=[];for(let name of loaded.names)isComponent(name,loaded.project.componentsDir)||((check(name,loaded.project).diagnostics.some(d=>d.severity===`error`)||loaded.unparsed.has(name))&&failed.push(name),summaries.set(name,summarize(loaded.project.templates.get(name))));failed.length&&ctx.log.warn(`kick/views: ${failed.join(`, `)} ha${failed.length===1?`s`:`ve`} errors (kick check:views) — typed from what could be read`);let aliased=aliasImports([...summaries].map(([name,summary])=>({name,file:loaded.fileOf(name),summary})),{outDir,projectRoot:ctx.cwd});for(let e of aliased.entries)summaries.set(e.name,e.summary);let entries=[],layoutOf=(from,s)=>typeof s.layout==`string`?resolveRef(from,s.layout,n=>summaries.has(n)):void 0;for(let[name,summary]of summaries){let merged=summary,seen=/* @__PURE__ */ new Set([name]),next=layoutOf(name,summary);for(;next!==void 0&&!seen.has(next)&&summaries.has(next);){seen.add(next);let layout=summaries.get(next);merged=mergeSummary(merged,layout),next=layoutOf(next,layout)}entries.push({name,file:loaded.fileOf(name),summary:merged})}return renderViewTypes(entries,{modules,outDir,projectRoot:ctx.cwd,aliased:aliased.imports})}}}const line=(d,prefix)=>`${prefix}${d.file}:${d.span.start.line}:${d.span.start.column} — ${d.message}`;async function fmtViews(opts){let dir=opts.dir??`src/views`,viewsDir=resolve(opts.root,dir),editable=(opts.roots??[]).filter(r=>!r.readOnly),dirs=new Map(editable.map(r=>[r.name,r.dir])),failed=!1,changed=0;for(let name of await allTemplates(viewsDir,opts.root,editable,opts.paths)){let{root,path}=splitName(name),file=join(root===void 0?viewsDir:dirs.get(root),`${path}.kick`),shown=relative(opts.root,file).split(sep).join(`/`),source=await readFile(file,`utf8`),r=format(source,shown,{indent:opts.indent});for(let d of r.diagnostics)opts.log(line(d,``));r.output===void 0?failed=!0:r.output!==source&&(changed++,opts.check?opts.log(`would reformat ${shown}`):(await writeFile(file,r.output),opts.log(`formatted ${shown}`)))}return failed||opts.check&&changed?1:0}async function checkViews(opts){let loaded=await loadViewsProject({...opts,pipesFile:opts.pipesFile}),{project,viewsDir,unparsed:syntax}=loaded,errors=0,report=(d,prefix)=>{d.severity===`error`&&errors++,opts.log(line(d,prefix))};for(let{d,prefix}of loaded.diagnostics)report(d,prefix);let all=loaded.names,wanted=opts.paths?.length?await allTemplates(viewsDir,opts.root,opts.roots,opts.paths):all;for(let name of wanted)if(!syntax.has(name))for(let d of check(name,project).diagnostics)report(d,loaded.prefixOf(name));return errors||opts.log(`${wanted.length} template(s) checked, no errors`),+!!errors}function kickViewsCli(options={}){return{name:`kick/view`,typegens:[viewsTypegen(options)],register(program,ctx){let views=viewsConfigOf(ctx.config),dir=options.dir??views?.dir??`src/views`,roots=()=>{try{return resolveViewRoots(ctx.projectRoot,views).roots}catch(err){ctx.log(err.message);return}};program.command(`fmt:views [paths...]`).description(`Format .kick templates (spacing and indentation; raw regions untouched)`).option(`--check`,`list files that would change and exit 1, writing nothing`).option(`--dir <dir>`,`views folder`,dir).action(async(paths,o)=>{let r=roots();if(!r)return void(process.exitCode=1);process.exitCode=await fmtViews({root:ctx.projectRoot,dir:o.dir,roots:r,paths,check:o.check,log:ctx.log})}),program.command(`check:views [paths...]`).description(`Check .kick templates for errors: syntax, unknown pipes, inputs, slots, layouts, unsafe interpolation`).option(`--dir <dir>`,`views folder`,dir).option(`--pipes <file>`,`pipes file (default <dir>/pipes.ts)`,options.pipes).option(`--validators <file>`,`validators file (default <dir>/validators.ts)`,options.validators).action(async(paths,o)=>{let r=roots();if(!r)return void(process.exitCode=1);process.exitCode=await checkViews({root:ctx.projectRoot,dir:o.dir,roots:r,paths,pipesFile:o.pipes,validatorsFile:o.validators,componentsDir:options.componentsDir,log:ctx.log})})}}}const viewCliPlugin=kickViewsCli();export{checkViews,fmtViews,kickViewsCli,packageDir,resolveViewRoots,rootFolders,viewCliPlugin,viewsConfigOf};
|
|
12
15
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["/**\n * `kick fmt:views` and `kick check:views`, as a kick CLI plugin:\n *\n * ```ts\n * // kick.config.ts\n * import { viewCliPlugin } from '@forinda/kickjs-view/cli'\n * export default defineConfig({ plugins: [viewCliPlugin] })\n * ```\n */\nimport { existsSync } from 'node:fs'\nimport { readdir, readFile, writeFile } from 'node:fs/promises'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { KickCliPlugin } from '@forinda/kickjs-cli-kit'\nimport type { Diagnostic } from './diagnostics'\nimport { check } from './check/check'\nimport type { Project } from './check/project'\nimport { format } from './format'\nimport { parse } from './parse/template'\nimport { BUILTIN_PIPES } from './pipes/builtins'\nimport { readPipeExports } from './pipes/read-exports'\nimport { readValidatorExports } from './validators'\n\nexport interface ViewsCliOptions {\n /** Project root. */\n root: string\n /** Views folder, relative to the root. Default `src/views`. */\n dir?: string\n /** Only these files (relative to the root). Default: every `.kick` file in the views folder. */\n paths?: string[]\n log: (message: string) => void\n}\n\nconst line = (d: Diagnostic, prefix: string) =>\n `${prefix}${d.file}:${d.span.start.line}:${d.span.start.column} — ${d.message}`\n\n/** Template names (`users/show`) under the views folder, or those `paths` name. */\nasync function templates(viewsDir: string, root: string, paths?: string[]): Promise<string[]> {\n if (paths?.length) {\n return paths\n .map((p) => relative(viewsDir, resolve(root, p)))\n .filter((p) => p.endsWith('.kick') && !p.startsWith('..'))\n .map((p) => p.slice(0, -'.kick'.length).split(sep).join('/'))\n }\n if (!existsSync(viewsDir)) return []\n const entries = await readdir(viewsDir, { recursive: true, withFileTypes: true })\n return entries\n .filter((e) => e.isFile() && e.name.endsWith('.kick'))\n .map((e) =>\n relative(viewsDir, join(direntDir(e), e.name))\n .slice(0, -'.kick'.length)\n .split(sep)\n .join('/'),\n )\n .toSorted()\n}\n\n/** Format templates in place, or with `check` report the ones that would change. Returns the exit code. */\nexport async function fmtViews(\n opts: ViewsCliOptions & { check?: boolean; indent?: number },\n): Promise<number> {\n const dir = opts.dir ?? 'src/views'\n const viewsDir = resolve(opts.root, dir)\n let failed = false\n let changed = 0\n for (const name of await templates(viewsDir, opts.root, opts.paths)) {\n const file = join(viewsDir, `${name}.kick`)\n const source = await readFile(file, 'utf8')\n const r = format(source, `${name}.kick`, { indent: opts.indent })\n for (const d of r.diagnostics) opts.log(line(d, `${dir}/`))\n if (r.output === undefined) {\n failed = true\n continue\n }\n if (r.output === source) continue\n changed++\n if (opts.check) opts.log(`would reformat ${dir}/${name}.kick`)\n else {\n await writeFile(file, r.output)\n opts.log(`formatted ${dir}/${name}.kick`)\n }\n }\n return failed || (opts.check && changed) ? 1 : 0\n}\n\n/** Parse and check every template; print each problem with its position. Returns the exit code. */\nexport async function checkViews(\n opts: ViewsCliOptions & {\n pipesFile?: string\n /** The app's browser validators. Default `<dir>/validators.ts`. */\n validatorsFile?: string\n componentsDir?: string\n layouts?: Project['layouts']\n baseLayout?: string\n },\n): Promise<number> {\n const dir = opts.dir ?? 'src/views'\n const viewsDir = resolve(opts.root, dir)\n const pipesFile = resolve(opts.root, opts.pipesFile ?? join(dir, 'pipes.ts'))\n const validatorsFile = resolve(opts.root, opts.validatorsFile ?? join(dir, 'validators.ts'))\n const all = await templates(viewsDir, opts.root)\n const pipes = new Set(BUILTIN_PIPES)\n let errors = 0\n const report = (d: Diagnostic, prefix: string) => {\n if (d.severity === 'error') errors++\n opts.log(line(d, prefix))\n }\n if (existsSync(pipesFile)) {\n const read = readPipeExports(await readFile(pipesFile, 'utf8'), relative(opts.root, pipesFile))\n for (const n of read.names) pipes.add(n)\n for (const d of read.diagnostics) report(d, '')\n }\n const validators = new Set<string>()\n if (existsSync(validatorsFile)) {\n const read = readValidatorExports(\n await readFile(validatorsFile, 'utf8'),\n relative(opts.root, validatorsFile),\n )\n for (const n of read.names) validators.add(n)\n for (const d of read.diagnostics) report(d, '')\n }\n const project: Project = {\n templates: new Map(),\n pipes,\n validators,\n componentsDir: opts.componentsDir ?? 'components',\n layouts: opts.layouts,\n baseLayout: opts.baseLayout,\n }\n const syntax = new Set<string>()\n for (const name of all) {\n const r = parse(await readFile(join(viewsDir, `${name}.kick`), 'utf8'), `${name}.kick`)\n project.templates.set(name, r.ast)\n for (const d of r.diagnostics) report(d, `${dir}/`)\n if (r.diagnostics.some((d) => d.severity === 'error')) syntax.add(name)\n }\n const wanted = opts.paths?.length ? await templates(viewsDir, opts.root, opts.paths) : all\n for (const name of wanted) {\n if (syntax.has(name)) continue\n for (const d of check(name, project).diagnostics) report(d, `${dir}/`)\n }\n if (!errors) opts.log(`${wanted.length} template(s) checked, no errors`)\n return errors ? 1 : 0\n}\n\nexport const viewCliPlugin: KickCliPlugin = {\n name: 'kick/view',\n register(program, ctx) {\n program\n .command('fmt:views [paths...]')\n .description('Format .kick templates (spacing and indentation; raw regions untouched)')\n .option('--check', 'list files that would change and exit 1, writing nothing')\n .option('--dir <dir>', 'views folder', 'src/views')\n .action(async (paths: string[], o: { check?: boolean; dir: string }) => {\n process.exitCode = await fmtViews({\n root: ctx.projectRoot,\n dir: o.dir,\n paths,\n check: o.check,\n log: ctx.log,\n })\n })\n program\n .command('check:views [paths...]')\n .description(\n 'Check .kick templates for errors: syntax, unknown pipes, inputs, slots, layouts, unsafe interpolation',\n )\n .option('--dir <dir>', 'views folder', 'src/views')\n .option('--pipes <file>', 'pipes file (default <dir>/pipes.ts)')\n .option('--validators <file>', 'validators file (default <dir>/validators.ts)')\n .action(async (paths: string[], o: { dir: string; pipes?: string; validators?: string }) => {\n process.exitCode = await checkViews({\n root: ctx.projectRoot,\n dir: o.dir,\n paths,\n pipesFile: o.pipes,\n validatorsFile: o.validators,\n log: ctx.log,\n })\n })\n },\n}\n\n/** A dirent's folder: `parentPath` from Node 20.12, `path` before it. */\nfunction direntDir(e: { parentPath?: string; path?: string }): string {\n return e.parentPath ?? e.path ?? ''\n}\n"],"mappings":";;;;;;;;;;oTAgCA,MAAM,MAAQ,EAAe,SAC3B,GAAG,SAAS,EAAE,KAAK,GAAG,EAAE,KAAK,MAAM,KAAK,GAAG,EAAE,KAAK,MAAM,OAAO,KAAK,EAAE,UAGxE,eAAe,UAAU,SAAkB,KAAc,MAAqC,CAS5F,OARI,OAAO,OACF,MACJ,IAAK,GAAM,SAAS,SAAU,QAAQ,KAAM,CAAC,CAAC,CAAC,CAAC,CAChD,OAAQ,GAAM,EAAE,SAAS,OAAO,GAAK,CAAC,EAAE,WAAW,IAAI,CAAC,CAAC,CACzD,IAAK,GAAM,EAAE,MAAM,EAAG,EAAe,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,EAE3D,WAAW,QAAQ,GAEjB,MADe,QAAQ,SAAU,CAAE,UAAW,GAAM,cAAe,EAAK,CAAC,EAAA,CAE7E,OAAQ,GAAM,EAAE,OAAO,GAAK,EAAE,KAAK,SAAS,OAAO,CAAC,CAAC,CACrD,IAAK,GACJ,SAAS,SAAU,KAAK,UAAU,CAAC,EAAG,EAAE,IAAI,CAAC,CAAC,CAC3C,MAAM,EAAG,EAAe,CAAC,CACzB,MAAM,GAAG,CAAC,CACV,KAAK,GAAG,CACb,CAAC,CACA,SAAS,EAVsB,CAAC,CAWrC,CAGA,eAAsB,SACpB,KACiB,CACjB,IAAM,IAAM,KAAK,KAAO,YAClB,SAAW,QAAQ,KAAK,KAAM,GAAG,EACnC,OAAS,GACT,QAAU,EACd,IAAK,IAAM,QAAQ,MAAM,UAAU,SAAU,KAAK,KAAM,KAAK,KAAK,EAAG,CACnE,IAAM,KAAO,KAAK,SAAU,GAAG,KAAK,MAAM,EACpC,OAAS,MAAM,SAAS,K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ACjC,YACC,uGACF,CAAC,CACA,OAAO,cAAe,eAAgB,WAAW,CAAC,CAClD,OAAO,iBAAkB,qCAAqC,CAAC,CAC/D,OAAO,sBAAuB,+CAA+C,CAAC,CAC9E,OAAO,MAAO,MAAiB,IAA4D,CAC1F,QAAQ,SAAW,MAAM,WAAW,CAClC,KAAM,IAAI,YACV,IAAK,EAAE,IACP,MACA,UAAW,EAAE,MACb,eAAgB,EAAE,WAClB,IAAK,IAAI,GACX,CAAC,CACH,CAAC,CACL,CACF,EAGA,SAAS,UAAU,EAAmD,CACpE,OAAO,EAAE,YAAc,EAAE,MAAQ,EACnC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/load-project.ts","../src/roots.ts","../src/typegen.ts","../src/cli.ts"],"sourcesContent":["/**\n * Reading an app's views from disk — templates, pipe and validator names —\n * the way `kick check:views` and the `kick/views` typegen both need it.\n */\nimport { existsSync } from 'node:fs'\nimport { readdir, readFile } from 'node:fs/promises'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { Diagnostic } from './diagnostics'\nimport { qualify, splitName, type Project } from './check/project'\nimport type { ViewRoot } from './roots'\nimport { parse } from './parse/template'\nimport { BUILTIN_PIPES } from './pipes/builtins'\nimport { readPipeExports } from './pipes/read-exports'\nimport { readValidatorExports } from './validators'\n\n/** Template names under `viewsDir` (or just `paths`, relative to the root), `/`-separated, sorted. */\nexport async function templates(\n viewsDir: string,\n root: string,\n paths?: string[],\n): Promise<string[]> {\n if (paths?.length) {\n return paths\n .map((p) => relative(viewsDir, resolve(root, p)))\n .filter((p) => p.endsWith('.kick') && !p.startsWith('..'))\n .map((p) => p.slice(0, -'.kick'.length).split(sep).join('/'))\n }\n if (!existsSync(viewsDir)) return []\n const entries = await readdir(viewsDir, { recursive: true, withFileTypes: true })\n return entries\n .filter((e) => e.isFile() && e.name.endsWith('.kick'))\n .map((e) =>\n relative(viewsDir, join(direntDir(e), e.name))\n .slice(0, -'.kick'.length)\n .split(sep)\n .join('/'),\n )\n .toSorted()\n}\n\n/** `Dirent.parentPath` (Node 20.12+), or the older `path`. */\nfunction direntDir(e: { parentPath?: string; path?: string }): string {\n return e.parentPath ?? e.path ?? ''\n}\n\n/** Where an app's views live, relative to its root. */\nexport interface ViewsLocation {\n root: string\n /** Default `src/views`. */\n dir?: string\n /** Default `components`, inside the views folder. */\n componentsDir?: string\n /** Default `<dir>/pipes.ts`. */\n pipesFile?: string\n /** Default `<dir>/validators.ts`. */\n validatorsFile?: string\n layouts?: Project['layouts']\n baseLayout?: string\n /** Named view roots (`billing::…`), resolved by `resolveViewRoots`. */\n roots?: ViewRoot[]\n}\n\n/** Template names under the app folder and every root, qualified (`billing::x`); `paths` limits them. */\nexport async function allTemplates(\n viewsDir: string,\n root: string,\n roots: ViewRoot[] = [],\n paths?: string[],\n): Promise<string[]> {\n const out = await templates(viewsDir, root, paths)\n for (const r of roots) {\n for (const name of await templates(r.dir, root, paths)) out.push(qualify(r.name, name))\n }\n return out\n}\n\n/** Every template parsed, with the app's pipe and validator names — ready for `check`. */\nexport async function loadViewsProject(loc: ViewsLocation): Promise<{\n project: Project\n dir: string\n viewsDir: string\n names: string[]\n /** Problems reading pipes.ts / validators.ts (no prefix) and parse errors (`<dir>/` prefix). */\n diagnostics: Array<{ d: Diagnostic; prefix: string }>\n /** Templates that didn't parse: `check` would only repeat the errors. */\n unparsed: Set<string>\n /** Where template `name` lives, relative to the project root (`/`-separated). */\n fileOf: (name: string) => string\n /** What goes before a diagnostic's file: `<dir>/` for the app's templates, nothing for a root's (its file is already a project path). */\n prefixOf: (name: string) => string\n}> {\n const dir = loc.dir ?? 'src/views'\n const viewsDir = resolve(loc.root, dir)\n const pipesFile = resolve(loc.root, loc.pipesFile ?? join(dir, 'pipes.ts'))\n const validatorsFile = resolve(loc.root, loc.validatorsFile ?? join(dir, 'validators.ts'))\n const diagnostics: Array<{ d: Diagnostic; prefix: string }> = []\n const pipes = new Set(BUILTIN_PIPES)\n if (existsSync(pipesFile)) {\n const read = readPipeExports(await readFile(pipesFile, 'utf8'), relative(loc.root, pipesFile))\n for (const n of read.names) pipes.add(n)\n for (const d of read.diagnostics) diagnostics.push({ d, prefix: '' })\n }\n const validators = new Set<string>()\n if (existsSync(validatorsFile)) {\n const read = readValidatorExports(\n await readFile(validatorsFile, 'utf8'),\n relative(loc.root, validatorsFile),\n )\n for (const n of read.names) validators.add(n)\n for (const d of read.diagnostics) diagnostics.push({ d, prefix: '' })\n }\n const project: Project = {\n templates: new Map(),\n pipes,\n validators,\n componentsDir: loc.componentsDir ?? 'components',\n layouts: loc.layouts,\n baseLayout: loc.baseLayout,\n }\n const rootDirs = new Map((loc.roots ?? []).map((r) => [r.name, r.dir]))\n const absOf = (name: string) => {\n const { root, path } = splitName(name)\n return join(root === undefined ? viewsDir : rootDirs.get(root)!, `${path}.kick`)\n }\n const fileOf = (name: string) => relative(loc.root, absOf(name)).split(sep).join('/')\n const prefixOf = (name: string) => (splitName(name).root === undefined ? `${dir}/` : '')\n const names = await allTemplates(viewsDir, loc.root, loc.roots)\n const unparsed = new Set<string>()\n for (const name of names) {\n // A root's template is labelled by its project path; the app's keep `<name>.kick`.\n const label = splitName(name).root === undefined ? `${name}.kick` : fileOf(name)\n const r = parse(await readFile(absOf(name), 'utf8'), label)\n project.templates.set(name, r.ast)\n for (const d of r.diagnostics) diagnostics.push({ d, prefix: prefixOf(name) })\n if (r.diagnostics.some((d) => d.severity === 'error')) unparsed.add(name)\n }\n return { project, dir, viewsDir, names, diagnostics, unparsed, fileOf, prefixOf }\n}\n","/**\n * Named view roots: kick.config's `views` block turned into the folders the\n * runtime, the Vite plugin, the CLI and the editor all read.\n *\n * ```ts\n * views: {\n * dir: 'src/views',\n * roots: { billing: './src/modules/billing/views', ui: '@acme/kick-ui' },\n * }\n * ```\n */\nimport { existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, join, resolve, sep } from 'node:path'\nimport { ROOT_NAME } from './check/project'\n\n/** kick.config's `views` block. */\nexport interface ViewsConfig {\n /** The app's own templates. Default `src/views`. */\n dir?: string\n /**\n * More folders, by name: `billing::invoices/show`. A value starting with\n * `.` or `/` is a folder; otherwise an installed package (its package.json\n * `\"kick\": { \"views\": \"views\" }`), else a folder.\n */\n roots?: Record<string, string>\n}\n\n/** A view root, resolved. */\nexport interface ViewRoot {\n name: string\n /** Absolute. */\n dir: string\n /** Inside `node_modules` (an installed package): not watched or formatted. */\n readOnly: boolean\n}\n\n/** Where package `pkg` is installed for the project at `root`, looking up the folders as Node does. */\nexport function packageDir(root: string, pkg: string): string | undefined {\n for (let dir = resolve(root); ; dir = dirname(dir)) {\n const at = join(dir, 'node_modules', pkg)\n if (existsSync(join(at, 'package.json'))) return at\n if (dirname(dir) === dir) return undefined\n }\n}\n\n/** The app's views folder and its named roots; `projectRoot` holds kick.config.ts. Throws on a bad root. */\nexport function resolveViewRoots(\n projectRoot: string,\n views: ViewsConfig = {},\n): { dir: string; roots: ViewRoot[] } {\n const roots = Object.entries(views.roots ?? {}).map(([name, value]): ViewRoot => {\n if (!ROOT_NAME.test(name)) {\n throw new Error(\n `views.roots: '${name}' isn't a valid root name (lowercase letters, digits and -, starting with a letter)`,\n )\n }\n const dir = rootDir(projectRoot, name, value)\n if (!existsSync(dir)) throw new Error(`views.roots.${name}: no folder at ${dir}`)\n return { name, dir, readOnly: realpathSync(dir).split(sep).includes('node_modules') }\n })\n return { dir: resolve(projectRoot, views.dir ?? 'src/views'), roots }\n}\n\nfunction rootDir(projectRoot: string, name: string, value: string): string {\n if (value.startsWith('.') || value.startsWith('/')) return resolve(projectRoot, value)\n const pkg = packageDir(projectRoot, value)\n if (!pkg) return resolve(projectRoot, value)\n const manifest = JSON.parse(readFileSync(join(pkg, 'package.json'), 'utf8')) as {\n kick?: { views?: unknown }\n }\n const views = manifest.kick?.views\n if (typeof views !== 'string') {\n throw new Error(\n `views.roots.${name}: package ${value} has no \"kick\": { \"views\": \"<folder>\" } (kick.views) in its package.json`,\n )\n }\n return resolve(pkg, views)\n}\n\n/** kick.config's `views` block, if the config has one. */\nexport const viewsConfigOf = (config: unknown): ViewsConfig | undefined =>\n (config as { views?: ViewsConfig } | null | undefined)?.views\n\n/** For `createViews({ roots })`: name → absolute folder. */\nexport function rootFolders(roots: ViewRoot[]): Record<string, string> {\n return Object.fromEntries(roots.map((r) => [r.name, r.dir]))\n}\n","/**\n * The `kick/views` typegen: turns what each page reads (the checker's data\n * summary) into the `KickViews` registry, so `ctx.render(name, data)` and\n * `views.render(name, data)` check the name and the data.\n *\n * Writes `.kickjs/types/kick__views.ts` — a `.ts` file rather than a `.d.ts`,\n * so `skipLibCheck` doesn't hide a bad `@input` type or an `@import type` that\n * doesn't resolve.\n */\nimport { dirname, relative, resolve, sep } from 'node:path'\nimport type { CliTypegen } from '@forinda/kickjs-cli-kit'\nimport { check } from './check/check'\nimport { isComponent, resolveRef } from './check/project'\nimport { mergeSummary, summarize, type DataSummary, type Field, type Shape } from './check/summary'\nimport type { KickViewsCliOptions } from './cli'\nimport { loadViewsProject } from './load-project'\nimport { packageDir, resolveViewRoots, viewsConfigOf } from './roots'\n\n/** One page: its name, its file (relative to the project root) and what it reads. */\nexport interface ViewTypesEntry {\n name: string\n file: string\n summary: DataSummary\n}\n\nconst IDENT = /^[A-Za-z_$][\\w$]*$/\nconst key = (k: string) =>\n IDENT.test(k) ? k : `'${k.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`\n\nfunction shapeType(s: Shape): string {\n switch (s.k) {\n case 'unknown':\n return 'unknown'\n case 'object':\n return objectType(s.props)\n // What `@for` loops over: arrays and Sets (strings too, when items are\n // only printed); Maps or [key, value] lists for pairs. Not any iterable.\n case 'list': {\n const item = shapeType(s.item)\n const el = item.includes(' | ') ? `(${item})` : item\n return `readonly ${el}[] | ReadonlySet<${item}>${s.item.k === 'unknown' ? ' | string' : ''}`\n }\n case 'pairs': {\n const value = shapeType(s.value)\n return `ReadonlyMap<unknown, ${value}> | readonly (readonly [unknown, ${value}])[]`\n }\n }\n}\n\nfunction fieldType(f: Field): string {\n const t = shapeType(f.shape)\n if (f.nullable) return `${t} | null | undefined`\n // Read as is: present and not null, whatever else it is.\n return t === 'unknown' ? 'NonNullable<unknown>' : t\n}\n\nfunction objectType(props: Record<string, Field>): string {\n const parts = Object.entries(props).map(\n ([k, f]) => `${key(k)}${f.optional ? '?' : ''}: ${fieldType(f)}`,\n )\n return parts.length ? `{ ${parts.join('; ')} }` : '{}'\n}\n\n/**\n * A page's data type: declared `@input` types win over what's inferred.\n * `fields` defaults to the page's own; a fragment passes its reads (and only\n * those names count, declared or not).\n */\nfunction dataType(s: DataSummary, fields = s.fields, onlyFields = false): string {\n const parts: string[] = []\n const names = (\n onlyFields\n ? Object.keys(fields)\n : [...new Set([...Object.keys(fields), ...Object.keys(s.declared)])]\n ).toSorted()\n for (const name of names) {\n const declared = s.declared[name]\n const field = fields[name]\n if (declared) {\n parts.push(\n `${key(name)}${declared.optional ? '?' : ''}: ${declared.type ?? (field ? fieldType(field) : 'unknown')}`,\n )\n } else if (field) {\n parts.push(`${key(name)}${field.optional ? '?' : ''}: ${fieldType(field)}`)\n }\n }\n return parts.length ? `{ ${parts.join('; ')} }` : '{}'\n}\n\n/** A relative specifier written in `templateFile`, as `outDir` reaches the same module. */\nfunction repoint(spec: string, templateFile: string, outDir: string, root: string): string {\n const abs = resolve(root, dirname(templateFile), spec)\n const rel = relative(outDir, abs).split(sep).join('/')\n return rel.startsWith('.') ? rel : `./${rel}`\n}\n\n/** An `@import type` line, its relative specifier re-pointed from the template to `outDir`. */\nfunction importLine(line: string, templateFile: string, outDir: string, root: string): string {\n return line.replace(\n /(\\bfrom\\s*)(['\"])(\\.[^'\"]*)\\2/,\n (_, from: string, q: string, spec: string) =>\n `${from}${q}${repoint(spec, templateFile, outDir, root)}${q}`,\n )\n}\n\nconst escape = (name: string) => name.replace(/\\$/g, '\\\\$')\n/** `name` as a type reference: not part of a longer name, a member, or a property key. */\nconst refTo = (names: string[]) =>\n new RegExp(`(?<![\\\\w$.])(?:${names.map(escape).join('|')})(?![\\\\w$])(?!\\\\s*\\\\??\\\\s*:)`, 'g')\n\nconst STRINGS = /'(?:[^'\\\\]|\\\\.)*'|\"(?:[^\"\\\\]|\\\\.)*\"/g\n\n/** `type` with each name in `rename` replaced, string literals left alone. */\nfunction renameRefs(type: string, rename: Map<string, string>): string {\n if (!rename.size) return type\n const ref = refTo([...rename.keys()])\n return type.replace(/('(?:[^'\\\\]|\\\\.)*'|\"(?:[^\"\\\\]|\\\\.)*\")|[^'\"]+/g, (part, quoted) =>\n quoted ? part : part.replace(ref, (local) => rename.get(local)!),\n )\n}\n\n/**\n * The generated module: imports, then one `declare module` per package in\n * `modules` (the ones the app has installed), each adding every page to its\n * `KickViews`.\n */\nexport function renderViewTypes(\n entries: ViewTypesEntry[],\n opts: {\n modules: string[]\n outDir: string\n projectRoot: string\n /** The import lines when `aliasImports` already ran (the typegen does, before merging layouts). */\n aliased?: string[]\n },\n): string {\n const { imports, entries: aliased } = opts.aliased\n ? { imports: opts.aliased, entries }\n : aliasImports(entries, opts)\n entries = aliased\n const body = entries\n .toSorted((a, b) => a.name.localeCompare(b.name))\n .map((e) => {\n const fragments = Object.entries(e.summary.fragments)\n .map(\n ([name, f]) =>\n `${key(name)}: { needs: ${objectType(f.needs)}; reads: ${dataType(e.summary, f.reads, true)} }`,\n )\n .join('; ')\n return [\n ` // from ${e.file}`,\n ` ${key(e.name)}: {`,\n ` data: ${dataType(e.summary)}`,\n ` fragments: ${fragments ? `{ ${fragments} }` : '{}'}`,\n ` }`,\n ].join('\\n')\n })\n .join('\\n')\n const blocks = opts.modules.map(\n (m) => `declare module '${m}' {\\n interface KickViews {\\n${body}\\n }\\n}`,\n )\n return [\n '// Generated by `kick typegen` (kick/views) from your .kick templates. Do not edit.',\n ...imports,\n '',\n ...blocks,\n '',\n 'export {}',\n '',\n ].join('\\n')\n}\n\n/**\n * Every template's `@import type` lines as one set: relative paths re-pointed\n * at `outDir`, one line per module, and a name two templates import from\n * different modules aliased (`User as User_2`) — with that template's\n * declared types rewritten to match.\n */\nexport function aliasImports(\n entries: ViewTypesEntry[],\n opts: { outDir: string; projectRoot: string },\n): { imports: string[]; entries: ViewTypesEntry[] } {\n // module → exported name → alias; and which import each alias belongs to.\n const byModule = new Map<string, Map<string, string>>()\n const owner = new Map<string, string>()\n const other = new Set<string>()\n const out = entries.map((e) => {\n const rename = new Map<string, string>()\n for (const line of e.summary.imports) {\n const rewritten = importLine(line, e.file, opts.outDir, opts.projectRoot)\n // Comments inside the braces aren't bindings.\n const m = /^import\\s+type\\s*\\{([^}]*)\\}\\s*from\\s*(['\"])([^'\"]+)\\2$/.exec(\n rewritten.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim(),\n )\n if (!m) {\n other.add(rewritten)\n continue\n }\n const from = m[3]!\n const names = byModule.get(from) ?? new Map<string, string>()\n byModule.set(from, names)\n for (const spec of m[1]!.split(',')) {\n const sm = /^\\s*([A-Za-z_$][\\w$]*)(?:\\s+as\\s+([A-Za-z_$][\\w$]*))?\\s*$/.exec(spec)\n if (!sm) continue\n const exported = sm[1]!\n const local = sm[2] ?? exported\n const id = `${from}\\0${exported}`\n let alias = names.get(exported)\n if (!alias) {\n alias = local\n for (let n = 2; owner.has(alias) && owner.get(alias) !== id; n++) alias = `${local}_${n}`\n owner.set(alias, id)\n names.set(exported, alias)\n }\n if (alias !== local) rename.set(local, alias)\n }\n }\n // One pass over the original text, so `A → A_2` and `A_2 → A_2_2` don't\n // chain; and an inline `import('./x')` re-pointed like an `@import` line.\n const declared: DataSummary['declared'] = {}\n for (const [name, d] of Object.entries(e.summary.declared)) {\n const type = d.type\n ? renameRefs(d.type, rename).replace(\n /\\bimport\\(\\s*(['\"])(\\.[^'\"]*)\\1\\s*\\)/g,\n (_, q: string, spec: string) =>\n `import(${q}${repoint(spec, e.file, opts.outDir, opts.projectRoot)}${q})`,\n )\n : undefined\n declared[name] = { ...d, ...(type ? { type } : {}) }\n }\n return { ...e, summary: { ...e.summary, declared } }\n })\n // Only the names a declared type uses: an unused import fails `noUnusedLocals`.\n // String literals don't count: `'User'` isn't a use of the type `User`.\n const used = out.flatMap((e) =>\n Object.values(e.summary.declared).map((d) => (d.type ?? '').replace(STRINGS, \"''\")),\n )\n const isUsed = (alias: string) => used.some((t) => refTo([alias]).test(t))\n const imports = [\n ...[...byModule].flatMap(([from, names]) => {\n const kept = [...names].filter(([, a]) => isUsed(a))\n return kept.length\n ? [\n `import type { ${kept.map(([x, a]) => (x === a ? x : `${x} as ${a}`)).join(', ')} } from '${from}'`,\n ]\n : []\n }),\n // `import type X from` / `import type * as X from`: kept when X is used.\n ...[...other].filter((line) => {\n const m = /^import\\s+type\\s+(?:\\*\\s+as\\s+)?([A-Za-z_$][\\w$]*)\\s+from\\b/.exec(line.trim())\n return !m || isUsed(m[1]!)\n }),\n ]\n return { imports, entries: out }\n}\n\nconst PACKAGES = ['@forinda/kickjs', '@forinda/kickjs-view'] as const\n\n/** Is `pkg` installed for the project at `root`? (Not `require.resolve`, which a package's `exports` can refuse.) */\nconst installedIn =\n (root: string) =>\n (pkg: string): boolean =>\n packageDir(root, pkg) !== undefined\n\ninterface TypegenLog {\n warn(message: string): void\n}\n\n/** The `kick/views` typegen plugin. `deps.installed` stands in for module resolution in tests. */\nexport function viewsTypegen(\n options: KickViewsCliOptions = {},\n deps: { installed?: (pkg: string) => boolean } = {},\n): CliTypegen {\n const dir = options.dir ?? 'src/views'\n return {\n id: 'kick/views',\n outExtension: '.ts',\n inputs: [`${dir}/**/*.kick`, options.pipes ?? `${dir}/pipes.ts`],\n async generate(ctx: { cwd: string; log: TypegenLog; config?: unknown }) {\n const views = viewsConfigOf(ctx.config)\n const loaded = await loadViewsProject({\n root: ctx.cwd,\n dir: options.dir ?? views?.dir ?? 'src/views',\n roots: resolveViewRoots(ctx.cwd, views).roots,\n componentsDir: options.componentsDir,\n pipesFile: options.pipes,\n validatorsFile: options.validators,\n })\n const installed = deps.installed ?? installedIn(ctx.cwd)\n const modules = PACKAGES.filter((m) => installed(m))\n if (!modules.length) return null\n const outDir = resolve(ctx.cwd, '.kickjs/types')\n // No templates left: an empty registry, so deleted names stop compiling.\n if (!loaded.names.length) {\n return renderViewTypes([], { modules, outDir, projectRoot: ctx.cwd, aliased: [] })\n }\n const summaries = new Map<string, DataSummary>()\n const failed: string[] = []\n for (const name of loaded.names) {\n if (isComponent(name, loaded.project.componentsDir)) continue\n const r = check(name, loaded.project)\n if (r.diagnostics.some((d) => d.severity === 'error') || loaded.unparsed.has(name)) {\n failed.push(name)\n }\n // The summary is typegen's own pass: the runtime check never computes it.\n summaries.set(name, summarize(loaded.project.templates.get(name)!))\n }\n if (failed.length) {\n ctx.log.warn(\n `kick/views: ${failed.join(', ')} ha${failed.length === 1 ? 's' : 've'} errors (kick check:views) — typed from what could be read`,\n )\n }\n // Imports aliased per template first, so a layout's types keep their\n // own names when its declarations merge into its pages.\n const aliased = aliasImports(\n [...summaries].map(([name, summary]) => ({ name, file: loaded.fileOf(name), summary })),\n { outDir, projectRoot: ctx.cwd },\n )\n for (const e of aliased.entries) summaries.set(e.name, e.summary)\n // A page's explicit @layout chain reads data too.\n const entries: ViewTypesEntry[] = []\n // A layout named in a root's template is that root's first (`resolveRef`).\n const layoutOf = (from: string, s: DataSummary) =>\n typeof s.layout === 'string'\n ? resolveRef(from, s.layout, (n) => summaries.has(n))\n : undefined\n for (const [name, summary] of summaries) {\n let merged = summary\n const seen = new Set([name])\n let next = layoutOf(name, summary)\n while (next !== undefined && !seen.has(next) && summaries.has(next)) {\n seen.add(next)\n const layout = summaries.get(next)!\n merged = mergeSummary(merged, layout)\n next = layoutOf(next, layout)\n }\n entries.push({ name, file: loaded.fileOf(name), summary: merged })\n }\n return renderViewTypes(entries, {\n modules,\n outDir,\n projectRoot: ctx.cwd,\n aliased: aliased.imports,\n })\n },\n }\n}\n","/**\n * `kick fmt:views` and `kick check:views`, as a kick CLI plugin:\n *\n * ```ts\n * // kick.config.ts\n * import { viewCliPlugin } from '@forinda/kickjs-view/cli'\n * export default defineConfig({ plugins: [viewCliPlugin] })\n * ```\n */\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { KickCliPlugin } from '@forinda/kickjs-cli-kit'\nimport type { Diagnostic } from './diagnostics'\nimport { check } from './check/check'\nimport { splitName, type Project } from './check/project'\nimport { format } from './format'\nimport { allTemplates, loadViewsProject } from './load-project'\nimport { resolveViewRoots, viewsConfigOf, type ViewRoot } from './roots'\nimport { viewsTypegen } from './typegen'\n\nexport interface ViewsCliOptions {\n /** Project root. */\n root: string\n /** Views folder, relative to the root. Default `src/views`. */\n dir?: string\n /** Only these files (relative to the root). Default: every `.kick` file in the views folders. */\n paths?: string[]\n /** Named view roots (from kick.config's `views.roots`, via `resolveViewRoots`). */\n roots?: ViewRoot[]\n log: (message: string) => void\n}\n\nconst line = (d: Diagnostic, prefix: string) =>\n `${prefix}${d.file}:${d.span.start.line}:${d.span.start.column} — ${d.message}`\n\n/** Format templates in place, or with `check` report the ones that would change. Returns the exit code. */\nexport async function fmtViews(\n opts: ViewsCliOptions & { check?: boolean; indent?: number },\n): Promise<number> {\n const dir = opts.dir ?? 'src/views'\n const viewsDir = resolve(opts.root, dir)\n // An installed package's templates aren't the app's to rewrite.\n const editable = (opts.roots ?? []).filter((r) => !r.readOnly)\n const dirs = new Map(editable.map((r) => [r.name, r.dir]))\n let failed = false\n let changed = 0\n for (const name of await allTemplates(viewsDir, opts.root, editable, opts.paths)) {\n const { root, path } = splitName(name)\n const file = join(root === undefined ? viewsDir : dirs.get(root)!, `${path}.kick`)\n const shown = relative(opts.root, file).split(sep).join('/')\n const source = await readFile(file, 'utf8')\n const r = format(source, shown, { indent: opts.indent })\n for (const d of r.diagnostics) opts.log(line(d, ''))\n if (r.output === undefined) {\n failed = true\n continue\n }\n if (r.output === source) continue\n changed++\n if (opts.check) opts.log(`would reformat ${shown}`)\n else {\n await writeFile(file, r.output)\n opts.log(`formatted ${shown}`)\n }\n }\n return failed || (opts.check && changed) ? 1 : 0\n}\n\n/** Parse and check every template; print each problem with its position. Returns the exit code. */\nexport async function checkViews(\n opts: ViewsCliOptions & {\n pipesFile?: string\n /** The app's browser validators. Default `<dir>/validators.ts`. */\n validatorsFile?: string\n componentsDir?: string\n layouts?: Project['layouts']\n baseLayout?: string\n },\n): Promise<number> {\n const loaded = await loadViewsProject({ ...opts, pipesFile: opts.pipesFile })\n const { project, viewsDir, unparsed: syntax } = loaded\n let errors = 0\n const report = (d: Diagnostic, prefix: string) => {\n if (d.severity === 'error') errors++\n opts.log(line(d, prefix))\n }\n for (const { d, prefix } of loaded.diagnostics) report(d, prefix)\n const all = loaded.names\n const wanted = opts.paths?.length\n ? await allTemplates(viewsDir, opts.root, opts.roots, opts.paths)\n : all\n for (const name of wanted) {\n if (syntax.has(name)) continue\n for (const d of check(name, project).diagnostics) report(d, loaded.prefixOf(name))\n }\n if (!errors) opts.log(`${wanted.length} template(s) checked, no errors`)\n return errors ? 1 : 0\n}\n\n/** Where the app's views live, for the commands' defaults and the `kick/views` typegen. */\nexport interface KickViewsCliOptions {\n /** Views folder, relative to the project root. Default `src/views`. */\n dir?: string\n /** Components folder, inside the views folder. Default `components`. */\n componentsDir?: string\n /** Pipes file. Default `<dir>/pipes.ts`. */\n pipes?: string\n /** Validators file. Default `<dir>/validators.ts`. */\n validators?: string\n}\n\n/**\n * The view package's CLI plugin: `kick check:views`, `kick fmt:views`, and the\n * `kick/views` typegen that types `ctx.render` from your templates. Pass the\n * options when your views aren't in `src/views`:\n *\n * ```ts\n * // kick.config.ts\n * plugins: [kickViewsCli({ dir: 'app/views' })]\n * ```\n *\n * @see https://kickjs.app/guide/views/typed-render-data\n */\nexport function kickViewsCli(options: KickViewsCliOptions = {}): KickCliPlugin {\n return {\n name: 'kick/view',\n typegens: [viewsTypegen(options)],\n register(program, ctx) {\n const views = viewsConfigOf(ctx.config)\n // `kickViewsCli({ dir })` overrides kick.config's `views.dir`.\n const dir = options.dir ?? views?.dir ?? 'src/views'\n /** The roots, or `undefined` after logging why kick.config's are wrong. */\n const roots = (): ViewRoot[] | undefined => {\n try {\n return resolveViewRoots(ctx.projectRoot, views).roots\n } catch (err) {\n ctx.log((err as Error).message)\n return undefined\n }\n }\n program\n .command('fmt:views [paths...]')\n .description('Format .kick templates (spacing and indentation; raw regions untouched)')\n .option('--check', 'list files that would change and exit 1, writing nothing')\n .option('--dir <dir>', 'views folder', dir)\n .action(async (paths: string[], o: { check?: boolean; dir: string }) => {\n const r = roots()\n if (!r) return void (process.exitCode = 1)\n process.exitCode = await fmtViews({\n root: ctx.projectRoot,\n dir: o.dir,\n roots: r,\n paths,\n check: o.check,\n log: ctx.log,\n })\n })\n program\n .command('check:views [paths...]')\n .description(\n 'Check .kick templates for errors: syntax, unknown pipes, inputs, slots, layouts, unsafe interpolation',\n )\n .option('--dir <dir>', 'views folder', dir)\n .option('--pipes <file>', 'pipes file (default <dir>/pipes.ts)', options.pipes)\n .option(\n '--validators <file>',\n 'validators file (default <dir>/validators.ts)',\n options.validators,\n )\n .action(\n async (paths: string[], o: { dir: string; pipes?: string; validators?: string }) => {\n const r = roots()\n if (!r) return void (process.exitCode = 1)\n process.exitCode = await checkViews({\n root: ctx.projectRoot,\n dir: o.dir,\n roots: r,\n paths,\n pipesFile: o.pipes,\n validatorsFile: o.validators,\n componentsDir: options.componentsDir,\n log: ctx.log,\n })\n },\n )\n },\n }\n}\n\n/** The plugin with default folders — `kickViewsCli()`. */\nexport const viewCliPlugin: KickCliPlugin = kickViewsCli()\n\nexport {\n packageDir,\n resolveViewRoots,\n rootFolders,\n viewsConfigOf,\n type ViewRoot,\n type ViewsConfig,\n} from './roots'\n"],"mappings":";;;;;;;;;;A,qeAgBA,eAAsB,UACpB,SACA,KACA,MACmB,CASnB,OARI,OAAO,OACF,MACJ,IAAK,GAAM,SAAS,SAAU,QAAQ,KAAM,CAAC,CAAC,CAAC,CAAC,CAChD,OAAQ,GAAM,EA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-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The edge entry (`workerd`, `worker`, `browser` conditions): the same API,
|
|
4
|
+
* without the file loader — templates come from the build's bundle.
|
|
5
|
+
*/
|
|
6
|
+
import { _ as TemplateAst, a as CNode, b as Span, c as Ctx, d as IfBranch, f as InputDecl, g as PathSegment, h as Node, i as CExpr, l as Element, m as LoopVar, n as Attr, o as CSeg, p as Literal, r as CAttr, s as CheckedTemplate, t as AST_FORMAT_VERSION, u as Expr, v as Diagnostic, x as positionAt, y as Pos } from "./ast-Pq3XT2Xi.js";
|
|
7
|
+
import { a as resolveRef, i as qualify, n as componentTag, o as splitName, r as layoutResolver, s as templateName, t as Project } from "./project-DeGFHgGJ.js";
|
|
8
|
+
import { C as ParseResult, E as parseExpression, S as check, T as FORBIDDEN_NAMES, _ as merge, a as assetTags, b as isUrlAttr, c as viewsMiddleware, d as VALIDATORS_TAG, f as readValidatorExports, g as Shape, h as Field, i as ViteManifestChunk, l as VALIDATORS_REGISTER, m as DataSummary, n as AssetsMode, o as KickView, p as readPipeExports, r as ViteManifest, s as KickViewOptions, t as clientScriptResponse, u as BUILTIN_VALIDATORS, v as mergeSummary, w as parse, x as CheckResult, y as URL_ATTRS } from "./serve-Hc5UlJ56.js";
|
|
9
|
+
import { A as PipeEnv, B as Pipe, C as useFileLoader, D as safeHtml, E as pipesFor, F as read, H as RenderError, I as safeStyleValue, L as sanitizeSrcset, M as SafeHtml, N as escapeHtml, O as withEnv, P as escapeJsonForScript, R as sanitizeUrl, S as useClientFiles, T as EnvPipe, U as render, V as RenderEnv, _ as Views, a as LooseViewNameOf, b as bundleLoader, c as ViewDataOf, d as ViewName, f as ViewNameOf, g as ShareContext, h as RenderOptions, i as KickViews, j as builtinPipes, k as BUILTIN_PIPES, l as ViewFragmentData, m as Loader, n as KickViewShared, o as RenderArgs, p as ViewRenderArgs, r as KickViewTypeOptions, s as ViewData, t as FragmentNames, u as ViewFragmentDataOf, v as ViewsBundle, w as useStripTypes, x as createViews, y as ViewsOptions, z as MAX_DEPTH } from "./types-D-OIrXCW.js";
|
|
10
|
+
export { AST_FORMAT_VERSION, type AssetsMode, type Attr, BUILTIN_PIPES, BUILTIN_VALIDATORS, type CAttr, type CExpr, type CNode, type CSeg, type CheckResult, type CheckedTemplate, type Ctx, type DataSummary, type Diagnostic, type Element, type EnvPipe, type Expr, FORBIDDEN_NAMES, type Field, type FragmentNames, type IfBranch, type InputDecl, KickView, type KickViewOptions, type KickViewShared, type KickViewTypeOptions, type KickViews, type Literal, type Loader, type LoopVar, type LooseViewNameOf, MAX_DEPTH, type Node, type ParseResult, type PathSegment, type Pipe, type PipeEnv, type Pos, type Project, type RenderArgs, type RenderEnv, RenderError, type RenderOptions, SafeHtml, type Shape, type ShareContext, type Span, type TemplateAst, URL_ATTRS, VALIDATORS_REGISTER, VALIDATORS_TAG, type ViewData, type ViewDataOf, type ViewFragmentData, type ViewFragmentDataOf, type ViewName, type ViewNameOf, type ViewRenderArgs, type Views, type ViewsBundle, type ViewsOptions, type ViteManifest, type ViteManifestChunk, assetTags, builtinPipes, bundleLoader, check, clientScriptResponse, componentTag, createViews, escapeHtml, escapeJsonForScript, isUrlAttr, layoutResolver, merge as mergeField, mergeSummary, parse, parseExpression, pipesFor, positionAt, qualify, read, readPipeExports, readValidatorExports, render, resolveRef, safeHtml, safeStyleValue, sanitizeSrcset, sanitizeUrl, splitName, templateName, useClientFiles, useFileLoader, useStripTypes, viewsMiddleware, withEnv };
|