clarusjs 0.19.1 → 0.21.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/README.md +1 -1
- package/dist/check/generate.js +124 -25
- package/dist/cli/index.js +17 -0
- package/dist/cli/migrate-files.d.ts +5 -0
- package/dist/cli/migrate-files.js +22 -0
- package/dist/cli/migrate.d.ts +8 -0
- package/dist/cli/migrate.js +317 -0
- package/dist/compiler/emit-client.js +7 -4
- package/dist/compiler/emit-server.js +10 -3
- package/dist/compiler/factories.d.ts +38 -0
- package/dist/compiler/factories.js +273 -0
- package/dist/compiler/html-expr.d.ts +4 -0
- package/dist/compiler/html-expr.js +5 -1
- package/dist/compiler/index.js +8 -9
- package/dist/compiler/ir.d.ts +13 -0
- package/dist/compiler/ir.js +41 -12
- package/dist/compiler/jsdoc.d.ts +15 -0
- package/dist/compiler/jsdoc.js +81 -0
- package/dist/compiler/lint.js +9 -4
- package/dist/compiler/parse.d.ts +35 -9
- package/dist/compiler/parse.js +77 -8
- package/dist/compiler/script.d.ts +15 -5
- package/dist/compiler/script.js +112 -18
- package/dist/compiler/shared.d.ts +5 -0
- package/dist/compiler/shared.js +5 -3
- package/dist/compiler/strip-types.d.ts +20 -0
- package/dist/compiler/strip-types.js +148 -0
- package/dist/forms/index.js +26 -5
- package/dist/runtime/context.d.ts +39 -0
- package/dist/runtime/context.js +4 -0
- package/dist/runtime/fragments.js +6 -2
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/navigate.js +2 -1
- package/dist/runtime/signals.d.ts +11 -6
- package/dist/runtime/signals.js +12 -3
- package/dist/vite/base-clash.d.ts +9 -0
- package/dist/vite/base-clash.js +54 -0
- package/dist/vite/build-app.d.ts +5 -0
- package/dist/vite/build-app.js +185 -0
- package/dist/vite/dev-server.d.ts +5 -0
- package/dist/vite/dev-server.js +67 -0
- package/dist/vite/graph.d.ts +45 -0
- package/dist/vite/graph.js +125 -0
- package/dist/vite/hmr.d.ts +19 -0
- package/dist/vite/hmr.js +53 -0
- package/dist/vite/links.d.ts +2 -0
- package/dist/vite/links.js +2 -0
- package/dist/vite/options.d.ts +147 -0
- package/dist/vite/options.js +1 -0
- package/dist/vite/output.d.ts +25 -0
- package/dist/vite/output.js +49 -0
- package/dist/vite/plugin.d.ts +4 -150
- package/dist/vite/plugin.js +68 -624
- package/dist/vite/preview.d.ts +3 -0
- package/dist/vite/preview.js +100 -0
- package/dist/vite/server-entry.d.ts +18 -0
- package/dist/vite/server-entry.js +83 -0
- package/dist/vite/shared.d.ts +34 -0
- package/dist/vite/shared.js +47 -0
- package/dist/vite/styles.d.ts +16 -0
- package/dist/vite/styles.js +56 -0
- package/package.json +6 -4
package/dist/vite/plugin.d.ts
CHANGED
|
@@ -1,157 +1,11 @@
|
|
|
1
1
|
import { type Plugin } from 'vite';
|
|
2
|
-
import { type LibraryOption } from './libraries.ts';
|
|
3
|
-
import type { LintConfig, LintRuleDef } from '../compiler/lint.ts';
|
|
4
2
|
export { packageOf } from './build.ts';
|
|
5
3
|
/** Newest commit time (unix seconds) of every file under a folder, from one `git log` (themes use it for "last updated"). */
|
|
6
4
|
export { gitDates } from './sitemap.ts';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Dev URL of a component's client module: root-relative, or Vite's /@fs/ form for files outside the root. Always with
|
|
13
|
-
* forward slashes (`/@fs/C:/libs/c.tscl` on Windows). `path`: the platform's (a parameter for tests). @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare function clientUrlFor(root: string, file: string, path?: Pick<typeof import('node:path'), 'relative' | 'isAbsolute' | 'sep'>): string;
|
|
16
|
-
/**
|
|
17
|
-
* The Vite plugin's options: when routes render, the deploy adapter, fragment navigation, link checks, head tags, the
|
|
18
|
-
* site's address, sitemap and robots, redirects, and page sources.
|
|
19
|
-
* @see https://clarusjs.com/reference/vite-plugin#clarusjs
|
|
20
|
-
*/
|
|
21
|
-
export type ClarusOptions = {
|
|
22
|
-
/** When each route renders: { '/account/*': 'server' }. Routes default to 'static' (prerendered at build). */
|
|
23
|
-
routes?: ModeTable;
|
|
24
|
-
/**
|
|
25
|
-
* Layouts by route (#456), outermost first, around the folder layouts (`+layout.tscl`): `{ layout: '/src/layouts/site.tscl',
|
|
26
|
-
* include: ['/*'], exclude: ['/embed/*'] }` (patterns as in `routes`; include defaults to every route). A page with
|
|
27
|
-
* `@layout none` gets none.
|
|
28
|
-
*/
|
|
29
|
-
layouts?: {
|
|
30
|
-
layout: string;
|
|
31
|
-
include?: string[];
|
|
32
|
-
exclude?: string[];
|
|
33
|
-
}[];
|
|
34
|
-
/**
|
|
35
|
-
* Automatic component imports (#458): a kebab-case file under these folders is used by its name, without @import
|
|
36
|
-
* (`src/components/forms/text-field.tscl` → `<forms-text-field>`, or `<text-field>` when no other has that name).
|
|
37
|
-
* Defaults: `{ dirs: ['src/components', 'src/layouts'], auto: true }`. `libraries`: installed component libraries whose
|
|
38
|
-
* components are used the same way (`libraries: ['@clarusjs/ui-primitives']` → `<ui-dialog>`), each described by its
|
|
39
|
-
* package.json; your own components win over theirs.
|
|
40
|
-
*/
|
|
41
|
-
components?: {
|
|
42
|
-
dirs?: string[];
|
|
43
|
-
auto?: boolean;
|
|
44
|
-
libraries?: LibraryOption[];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Where server routes deploy. 'netlify': a Netlify Function (Frameworks API) next to the static files. 'vercel': the
|
|
48
|
-
* Build Output API in .vercel/output (static files, one Node function, routes), with the server bundled.
|
|
49
|
-
* 'cloudflare': a worker in dist/client/_worker.js/ and _routes.json (Pages, or a Worker with static assets).
|
|
50
|
-
* @see https://clarusjs.com/guide/deploy
|
|
51
|
-
*/
|
|
52
|
-
adapter?: 'netlify' | 'vercel' | 'cloudflare';
|
|
53
|
-
/** Fragment navigation: each static and server page also answers at <path>/index.frag.html. */
|
|
54
|
-
fragments?: boolean;
|
|
55
|
-
/** Page sources for other file types, such as Markdown from @clarusjs/content: `sources: [markdown()]`. */
|
|
56
|
-
sources?: Source[];
|
|
57
|
-
/**
|
|
58
|
-
* Build-time link checking, after every page is built. `pages`: links to pages or files that don't exist (default
|
|
59
|
-
* 'error'). `anchors`: links to a #id the target page doesn't have (default 'warn'). `strict`: warnings fail too.
|
|
60
|
-
*/
|
|
61
|
-
links?: {
|
|
62
|
-
pages?: LinkLevel;
|
|
63
|
-
anchors?: LinkLevel;
|
|
64
|
-
outside?: LinkLevel;
|
|
65
|
-
strict?: boolean;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Template lint levels for `clarusjs check`: `{ 'img-alt': 'off', 'accessible-name': 'error' }`. Rules warn by default.
|
|
69
|
-
* @see https://clarusjs.com/guide/lint
|
|
70
|
-
*/
|
|
71
|
-
lint?: LintConfig;
|
|
72
|
-
/**
|
|
73
|
-
* The project's own lint rules, run by `clarusjs check` beside the built-in ones.
|
|
74
|
-
* @see https://clarusjs.com/guide/lint#writing-a-rule
|
|
75
|
-
*/
|
|
76
|
-
lintRules?: LintRuleDef[];
|
|
77
|
-
/**
|
|
78
|
-
* Paths that moved: `{ '/old': '/new' }` (a site path or a full URL). The build writes a page at each old path that
|
|
79
|
-
* sends visitors on, and `_redirects` lines (a real 301 on Netlify and Cloudflare Pages); dev answers 301.
|
|
80
|
-
* @see https://clarusjs.com/guide/routing
|
|
81
|
-
*/
|
|
82
|
-
redirects?: Record<string, string>;
|
|
83
|
-
/**
|
|
84
|
-
* Response headers by path pattern (`*` anything, `:name` one segment): `{ '/*': { 'X-Frame-Options': 'DENY' } }`.
|
|
85
|
-
* The build writes them to `_headers` (read as is by Netlify and Cloudflare Pages; applied by `clarusjs serve` and
|
|
86
|
-
* vite preview), after `X-Content-Type-Options: nosniff`, `Referrer-Policy: strict-origin-when-cross-origin` and
|
|
87
|
-
* immutable caching for hashed assets. A name set by several matching patterns gets their values joined. `false`: no
|
|
88
|
-
* `_headers` written.
|
|
89
|
-
* @see https://clarusjs.com/guide/deploy#headers
|
|
90
|
-
*/
|
|
91
|
-
headers?: HeaderRules | false;
|
|
92
|
-
/**
|
|
93
|
-
* The environment variables the site needs: `{ server: ['DATABASE_URL'], browser: ['VITE_API_URL'] }`. `vite build`
|
|
94
|
-
* fails naming any that is missing (dev warns), and `.clarusjs/env.d.ts` types them as strings. Browser ones start
|
|
95
|
-
* with Vite's prefix (VITE_). Server code reads every .env variable from process.env, whether named here or not.
|
|
96
|
-
* @see https://clarusjs.com/guide/environment-variables
|
|
97
|
-
*/
|
|
98
|
-
env?: EnvOption;
|
|
99
|
-
/**
|
|
100
|
-
* Every page's <head>: `titleTemplate` ('%s · Site') wraps the document title, `tags` are added unless the page has
|
|
101
|
-
* its own with the same key. Anything else: export `transformHead(head, page)` from src/head.ts.
|
|
102
|
-
*/
|
|
103
|
-
head?: {
|
|
104
|
-
titleTemplate?: string;
|
|
105
|
-
tags?: HeadTag[];
|
|
106
|
-
jsonLd?: object | object[];
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* The site's public address. Every page gets a canonical URL and social cards (Open Graph, Twitter) from its title,
|
|
110
|
-
* description and an image (the page's og:image, or `image`); absolute links to the site are link-checked.
|
|
111
|
-
*/
|
|
112
|
-
site?: SiteOptions;
|
|
113
|
-
/**
|
|
114
|
-
* With site.url, vite build writes sitemap.xml (static pages, dated from git). false: no sitemap. `exclude`: paths
|
|
115
|
-
* left out ('/legal', '/tags/*' one segment, '/drafts/**' any depth). A page opts out itself with
|
|
116
|
-
* <cl-head><meta name="sitemap" content="false"></cl-head> (removed from the built page) or noindex, and sets its
|
|
117
|
-
* own date with <meta name="sitemap:lastmod" content="2026-11-01">. Each page's images (not alt="", not data:) are
|
|
118
|
-
* listed with Google's image extension; `images: false` leaves them out. `include`: paths the build can't list (server
|
|
119
|
-
* and client routes), or a function returning them (async, to read them from a database at build time).
|
|
120
|
-
*/
|
|
121
|
-
sitemap?: boolean | {
|
|
122
|
-
exclude?: string[];
|
|
123
|
-
images?: boolean;
|
|
124
|
-
include?: string[] | (() => string[] | Promise<string[]>);
|
|
125
|
-
};
|
|
126
|
-
/** With site.url, vite build writes robots.txt (allow all, and the sitemap), unless public/robots.txt exists. */
|
|
127
|
-
robots?: boolean;
|
|
128
|
-
/** Collapse whitespace in template text at build (default true). */
|
|
129
|
-
collapseWhitespace?: boolean;
|
|
130
|
-
/** At build, write .br and .gz next to dist/client's text files, for servers that serve them as is. Default false. */
|
|
131
|
-
compress?: boolean;
|
|
132
|
-
};
|
|
133
|
-
export type { HeadTag };
|
|
134
|
-
/**
|
|
135
|
-
* How a build reports a broken link: fail (`'error'`), print a warning, or skip the check.
|
|
136
|
-
* @see https://clarusjs.com/reference/vite-plugin#links
|
|
137
|
-
*/
|
|
138
|
-
export type LinkLevel = 'error' | 'warn' | 'off';
|
|
139
|
-
/**
|
|
140
|
-
* A page source: files with another extension (such as Markdown) turned into .tscl text, then compiled like any
|
|
141
|
-
* page. `route` is the page's route when the file is under src/pages.
|
|
142
|
-
* @see https://clarusjs.com/reference/vite-plugin#page-sources
|
|
143
|
-
*/
|
|
144
|
-
export type Source = {
|
|
145
|
-
extension: string;
|
|
146
|
-
toTscl(code: string, file: string, context: SourceContext): string;
|
|
147
|
-
};
|
|
148
|
-
/** @see https://clarusjs.com/reference/vite-plugin#page-sources
|
|
149
|
-
* `root`: the app root. `addDependency(file)`: another file the output depends on (rebuilt when it changes in dev). */
|
|
150
|
-
export type SourceContext = {
|
|
151
|
-
route: string;
|
|
152
|
-
root: string;
|
|
153
|
-
addDependency(file: string): void;
|
|
154
|
-
};
|
|
5
|
+
import type { ClarusOptions } from './options.ts';
|
|
6
|
+
export type { ClarusOptions, LinkLevel, Source, SourceContext } from './options.ts';
|
|
7
|
+
export type { HeadTag } from '../server/head.ts';
|
|
8
|
+
export { clientUrlFor } from './shared.ts';
|
|
155
9
|
/**
|
|
156
10
|
* The clarusjs Vite plugin: compiles `.tscl` files, serves pages in development, and on `vite build` builds the
|
|
157
11
|
* browser code, the server and the prerendered pages.
|