@kayjs/kay 1.104.1 → 1.104.3
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 +2 -7
- package/dist/eslint.js +208 -34
- package/editors/zed/extension.toml +2 -2
- package/llms/check-and-tools.md +5 -3
- package/llms/code-lints.md +1 -0
- package/llms/components.md +1 -1
- package/llms/islands.md +1 -1
- package/llms/project-new-and-add.md +5 -5
- package/llms/project.md +1 -2
- package/llms/styles-and-assets.md +1 -1
- package/llms/testing-browser.md +1 -0
- package/llms/upgrading.md +4 -0
- package/llms/whats-new-archive.md +17 -1
- package/llms/whats-new.md +20 -17
- package/llms.txt +1 -1
- package/package.json +9 -7
- package/src/add.ts +2 -0
- package/src/build/class-rules.ts +8 -0
- package/src/build/client.ts +9 -6
- package/src/build/recipe-classes.ts +11 -1
- package/src/build/recipe-utilities.ts +183 -0
- package/src/build/signals.ts +113 -14
- package/src/build/style-uses.ts +7 -6
- package/src/build/styles.ts +32 -21
- package/src/build/supports.ts +4 -4
- package/src/check/removed-ui-tokens.ts +2 -2
- package/src/check/shadow-types.ts +2 -0
- package/src/check/text-size-colour.ts +57 -0
- package/src/commands/new.ts +17 -7
- package/src/commands/upgrade-majors.ts +26 -0
- package/src/commands/upgrade-manifest.ts +23 -0
- package/src/commands/upgrade-messages.ts +16 -0
- package/src/commands/upgrade-peers.ts +89 -0
- package/src/commands/upgrade.ts +68 -36
- package/src/compiler/codegen.ts +1 -1
- package/src/compiler/dom.ts +12 -1
- package/src/compiler/index.ts +32 -17
- package/src/compiler/island-cause.ts +5 -2
- package/src/compiler/module-signals.ts +111 -8
- package/src/compiler/rewrite-reads.ts +1 -1
- package/src/compiler/route-lints.ts +8 -0
- package/src/compiler/script-props.ts +18 -1
- package/src/compiler/script-shared.ts +2 -0
- package/src/eslint/index.ts +19 -2
- package/src/features.ts +2 -2
- package/src/lsp/semantic-tokens.ts +2 -2
- package/src/migrate/project.ts +2 -2
- package/src/new.ts +6 -4
- package/src/runtime/dom.ts +11 -12
- package/src/template-config.ts +11 -4
- package/src/template-docker.ts +1 -1
- package/src/template-shared.ts +4 -1
- package/src/template-starter.ts +25 -4
- package/src/template-styles.ts +55 -43
- package/src/template-ws.ts +1 -1
- package/src/templates.ts +2 -4
- package/src/test/browser.ts +2 -5
- package/src/test/text-match.ts +44 -0
- package/types/add.d.ts.map +1 -1
- package/types/build/class-rules.d.ts +1 -0
- package/types/build/class-rules.d.ts.map +1 -1
- package/types/build/client.d.ts +1 -1
- package/types/build/client.d.ts.map +1 -1
- package/types/build/recipe-classes.d.ts +2 -0
- package/types/build/recipe-classes.d.ts.map +1 -1
- package/types/build/recipe-utilities.d.ts +4 -0
- package/types/build/recipe-utilities.d.ts.map +1 -0
- package/types/build/signals.d.ts.map +1 -1
- package/types/build/style-uses.d.ts +1 -0
- package/types/build/style-uses.d.ts.map +1 -1
- package/types/build/styles.d.ts +1 -1
- package/types/build/styles.d.ts.map +1 -1
- package/types/build/supports.d.ts +1 -1
- package/types/build/supports.d.ts.map +1 -1
- package/types/check/removed-ui-tokens.d.ts +2 -0
- package/types/check/removed-ui-tokens.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/check/text-size-colour.d.ts +3 -0
- package/types/check/text-size-colour.d.ts.map +1 -0
- package/types/commands/new.d.ts.map +1 -1
- package/types/commands/upgrade-majors.d.ts +7 -0
- package/types/commands/upgrade-majors.d.ts.map +1 -0
- package/types/commands/upgrade-manifest.d.ts +6 -0
- package/types/commands/upgrade-manifest.d.ts.map +1 -0
- package/types/commands/upgrade-messages.d.ts +4 -0
- package/types/commands/upgrade-messages.d.ts.map +1 -0
- package/types/commands/upgrade-peers.d.ts +23 -0
- package/types/commands/upgrade-peers.d.ts.map +1 -0
- package/types/commands/upgrade.d.ts +7 -0
- package/types/commands/upgrade.d.ts.map +1 -1
- package/types/compiler/dom.d.ts +1 -0
- package/types/compiler/dom.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-cause.d.ts +2 -2
- package/types/compiler/island-cause.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +8 -0
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/module-signals.d.ts +14 -1
- package/types/compiler/module-signals.d.ts.map +1 -1
- package/types/compiler/route-lints.d.ts +8 -0
- package/types/compiler/route-lints.d.ts.map +1 -1
- package/types/compiler/script-props.d.ts.map +1 -1
- package/types/compiler/script-shared.d.ts +1 -0
- package/types/compiler/script-shared.d.ts.map +1 -1
- package/types/new.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +1 -0
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/template-config.d.ts.map +1 -1
- package/types/template-shared.d.ts +1 -1
- package/types/template-shared.d.ts.map +1 -1
- package/types/template-starter.d.ts.map +1 -1
- package/types/template-styles.d.ts.map +1 -1
- package/types/templates.d.ts.map +1 -1
- package/types/test/browser.d.ts.map +1 -1
- package/types/test/text-match.d.ts +13 -0
- package/types/test/text-match.d.ts.map +1 -0
package/README.md
CHANGED
|
@@ -8,12 +8,7 @@ The full reference, written for people and coding agents alike, starts at [llms.
|
|
|
8
8
|
|
|
9
9
|
## Start a project
|
|
10
10
|
|
|
11
|
-
kay is published as `@kayjs/kay` to npm, and to the Forgejo registry at git.kaynooo.fr
|
|
12
|
-
|
|
13
|
-
```toml
|
|
14
|
-
[install.scopes]
|
|
15
|
-
"@kaynooo" = "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
|
|
16
|
-
```
|
|
11
|
+
kay is published as `@kayjs/kay` to npm, and to the Forgejo registry at git.kaynooo.fr as a mirror. Everything a project installs, pg-orm and eslint included, comes from npm, so Bun needs no setup:
|
|
17
12
|
|
|
18
13
|
```sh
|
|
19
14
|
bunx -p @kayjs/kay kay new my-app
|
|
@@ -22,7 +17,7 @@ bun install
|
|
|
22
17
|
bun run dev # http://localhost:3000, reloads on every change
|
|
23
18
|
```
|
|
24
19
|
|
|
25
|
-
The project depends on it as `"kay": "npm:@kayjs/kay@~<version>"`, a tilde since a minor may break, so imports read `kay`, `kay/server` and so on
|
|
20
|
+
The project depends on it as `"kay": "npm:@kayjs/kay@~<version>"`, a tilde since a minor may break, so imports read `kay`, `kay/server` and so on. `bun src/cli.ts new ../my-app` from a checkout of this repository depends on a packed copy of it instead.
|
|
26
21
|
|
|
27
22
|
## A page and an island
|
|
28
23
|
|
package/dist/eslint.js
CHANGED
|
@@ -25,7 +25,7 @@ var __esm = (fn, res, err) => () => {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// package.json
|
|
28
|
-
var version = "1.104.
|
|
28
|
+
var version = "1.104.3", peerDependencies;
|
|
29
29
|
var init_package = __esm(() => {
|
|
30
30
|
peerDependencies = {
|
|
31
31
|
"@happy-dom/global-registrator": "^20.14.6 || ^21.0.3",
|
|
@@ -2386,6 +2386,10 @@ function moduleSignals(source, jsx = false) {
|
|
|
2386
2386
|
const ast = NAMES_KAY.test(source) ? parseModule(source, jsx) : undefined;
|
|
2387
2387
|
return ast ? signalsIn(ast) : {};
|
|
2388
2388
|
}
|
|
2389
|
+
function scanModule(source, jsx = false) {
|
|
2390
|
+
const ast = NAMES_KAY.test(source) || EXPORT.test(source) ? parseModule(source, jsx) : undefined;
|
|
2391
|
+
return { signals: ast && NAMES_KAY.test(source) ? signalsIn(ast) : {}, links: ast ? linksIn(ast) : { stars: [], own: new Set, names: [] } };
|
|
2392
|
+
}
|
|
2389
2393
|
function parseModule(source, jsx) {
|
|
2390
2394
|
try {
|
|
2391
2395
|
return parseProgram(source, { lang: jsx ? "tsx" : "ts", semantic: true }).program;
|
|
@@ -2422,31 +2426,95 @@ function signalsIn(ast) {
|
|
|
2422
2426
|
continue;
|
|
2423
2427
|
for (const specifier of statement.specifiers) {
|
|
2424
2428
|
const imported = specifier.type === "ImportSpecifier" && specifier.importKind !== "type" ? specifier.imported : undefined;
|
|
2425
|
-
const
|
|
2429
|
+
const importedName = imported ? nameOf(imported) : undefined;
|
|
2430
|
+
const kind = importedName === "persisted" ? "persisted" : MADE[importedName ?? ""];
|
|
2426
2431
|
if (kind)
|
|
2427
2432
|
made.set(specifier.local.name, kind);
|
|
2428
|
-
if (
|
|
2433
|
+
if (importedName === "persisted")
|
|
2429
2434
|
persisted.add(specifier.local.name);
|
|
2430
2435
|
}
|
|
2431
2436
|
}
|
|
2437
|
+
const locals = new Map;
|
|
2432
2438
|
for (const statement of ast.body) {
|
|
2433
|
-
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration :
|
|
2439
|
+
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
2434
2440
|
if (declaration?.type !== "VariableDeclaration" || declaration.kind !== "const")
|
|
2435
2441
|
continue;
|
|
2436
2442
|
for (const { id, init } of declaration.declarations) {
|
|
2437
2443
|
const name = init?.type === "CallExpression" ? madeBy(init.callee, persisted) : undefined;
|
|
2438
|
-
const kind =
|
|
2439
|
-
if (id.type
|
|
2444
|
+
const kind = init?.type === "Identifier" ? locals.get(init.name) : made.get(name ?? "");
|
|
2445
|
+
if (id.type !== "Identifier" || !kind)
|
|
2446
|
+
continue;
|
|
2447
|
+
locals.set(id.name, kind);
|
|
2448
|
+
if (statement.type === "ExportNamedDeclaration")
|
|
2440
2449
|
found[id.name] = kind;
|
|
2441
2450
|
}
|
|
2442
2451
|
}
|
|
2452
|
+
for (const statement of ast.body) {
|
|
2453
|
+
if (statement.type !== "ExportNamedDeclaration" || statement.source || statement.exportKind === "type")
|
|
2454
|
+
continue;
|
|
2455
|
+
for (const specifier of statement.specifiers) {
|
|
2456
|
+
const local = specifier.type === "ExportSpecifier" && specifier.exportKind !== "type" && specifier.local.type === "Identifier" ? locals.get(specifier.local.name) : undefined;
|
|
2457
|
+
if (local)
|
|
2458
|
+
found[nameOf(specifier.exported)] = local;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2443
2461
|
return found;
|
|
2444
2462
|
}
|
|
2445
|
-
|
|
2463
|
+
function nameOf(node) {
|
|
2464
|
+
if (node.type === "Identifier")
|
|
2465
|
+
return node.name;
|
|
2466
|
+
return node.type === "Literal" ? String(node.value) : "";
|
|
2467
|
+
}
|
|
2468
|
+
function linksIn(ast) {
|
|
2469
|
+
const links = { stars: [], own: new Set, names: [] };
|
|
2470
|
+
const imports = new Map;
|
|
2471
|
+
for (const statement of ast.body) {
|
|
2472
|
+
if (statement.type !== "ImportDeclaration" || statement.importKind === "type")
|
|
2473
|
+
continue;
|
|
2474
|
+
for (const specifier of statement.specifiers) {
|
|
2475
|
+
if (specifier.type === "ImportSpecifier" && specifier.importKind !== "type")
|
|
2476
|
+
imports.set(specifier.local.name, { source: statement.source.value, imported: nameOf(specifier.imported) });
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
for (const statement of ast.body) {
|
|
2480
|
+
if (statement.type === "ExportAllDeclaration" && statement.exportKind !== "type" && !statement.exported)
|
|
2481
|
+
links.stars.push(statement.source.value);
|
|
2482
|
+
if (statement.type === "ExportNamedDeclaration" && statement.exportKind !== "type")
|
|
2483
|
+
linkNamed(statement, imports, links);
|
|
2484
|
+
}
|
|
2485
|
+
return links;
|
|
2486
|
+
}
|
|
2487
|
+
function linkNamed(statement, imports, links) {
|
|
2488
|
+
const declared = statement.declaration;
|
|
2489
|
+
if (declared?.type === "VariableDeclaration") {
|
|
2490
|
+
for (const { id } of declared.declarations) {
|
|
2491
|
+
if (id.type === "Identifier")
|
|
2492
|
+
links.own.add(id.name);
|
|
2493
|
+
}
|
|
2494
|
+
} else if (declared && "id" in declared && declared.id?.type === "Identifier") {
|
|
2495
|
+
links.own.add(declared.id.name);
|
|
2496
|
+
}
|
|
2497
|
+
for (const specifier of statement.specifiers) {
|
|
2498
|
+
if (specifier.type !== "ExportSpecifier" || specifier.exportKind === "type")
|
|
2499
|
+
continue;
|
|
2500
|
+
links.own.add(nameOf(specifier.exported));
|
|
2501
|
+
const local = specifier.local.type === "Identifier" ? imports.get(specifier.local.name) : undefined;
|
|
2502
|
+
const from = statement.source ? { source: statement.source.value, imported: nameOf(specifier.local) } : local;
|
|
2503
|
+
if (from)
|
|
2504
|
+
links.names.push({ exported: nameOf(specifier.exported), ...from });
|
|
2505
|
+
}
|
|
2506
|
+
for (const { id, init } of statement.declaration?.type === "VariableDeclaration" && statement.declaration.kind === "const" ? statement.declaration.declarations : []) {
|
|
2507
|
+
const from = id.type === "Identifier" && init?.type === "Identifier" ? imports.get(init.name) : undefined;
|
|
2508
|
+
if (from && id.type === "Identifier")
|
|
2509
|
+
links.names.push({ exported: id.name, ...from });
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
var MADE, NAMES_KAY, EXPORT, PERSISTED_ENTRIES;
|
|
2446
2513
|
var init_module_signals = __esm(() => {
|
|
2447
2514
|
init_estree();
|
|
2448
2515
|
MADE = { signal: "signal", persisted: "signal", linked: "signal", queryParam: "signal", memo: "memo", debounced: "memo", throttled: "memo", live: "live" };
|
|
2449
2516
|
NAMES_KAY = /["']kay["']/;
|
|
2517
|
+
EXPORT = /\bexport\b/;
|
|
2450
2518
|
PERSISTED_ENTRIES = new Set(["cookie", "local", "session", "query"]);
|
|
2451
2519
|
});
|
|
2452
2520
|
|
|
@@ -3124,8 +3192,8 @@ function readImportedSignals(file, source) {
|
|
|
3124
3192
|
}
|
|
3125
3193
|
imports.set(file, { hash, specifiers });
|
|
3126
3194
|
for (const specifier of specifiers) {
|
|
3127
|
-
const path =
|
|
3128
|
-
if (path === undefined
|
|
3195
|
+
const path = scannable(specifier, file);
|
|
3196
|
+
if (path === undefined)
|
|
3129
3197
|
continue;
|
|
3130
3198
|
const signals = signalsOf(path);
|
|
3131
3199
|
if (Object.keys(signals).length > 0)
|
|
@@ -3133,22 +3201,76 @@ function readImportedSignals(file, source) {
|
|
|
3133
3201
|
}
|
|
3134
3202
|
return found;
|
|
3135
3203
|
}
|
|
3204
|
+
function scannable(specifier, from) {
|
|
3205
|
+
const path = KAY_MODULE.test(specifier) ? undefined : resolveFrom(specifier, from);
|
|
3206
|
+
return path === undefined || !(SCRIPT_FILE.test(path) || KAY_FILE2.test(path)) || !specifier.startsWith(".") && path.includes("/node_modules/") ? undefined : path;
|
|
3207
|
+
}
|
|
3208
|
+
function stampOf(path) {
|
|
3209
|
+
const stats = statSync2(path, { throwIfNoEntry: false });
|
|
3210
|
+
return stats && `${stats.mtimeMs}-${stats.size}`;
|
|
3211
|
+
}
|
|
3136
3212
|
function signalsOf(path) {
|
|
3137
3213
|
try {
|
|
3138
|
-
const stats = statSync2(path, { throwIfNoEntry: false });
|
|
3139
|
-
if (!stats)
|
|
3140
|
-
return {};
|
|
3141
|
-
const stamp = `${stats.mtimeMs}-${stats.size}`;
|
|
3142
3214
|
const known = scanned.get(path);
|
|
3143
|
-
if (known
|
|
3215
|
+
if (known && [...known.stamps].every(([file, stamp]) => stampOf(file) === stamp) && known.misses.every((miss) => resolveFrom(miss.specifier, miss.from) === undefined))
|
|
3144
3216
|
return known.signals;
|
|
3145
|
-
const
|
|
3146
|
-
|
|
3217
|
+
const scan = { stamps: new Map, misses: [], done: new Map, cuts: 0 };
|
|
3218
|
+
const signals = Object.fromEntries(Object.entries(collect(path, scan, [])).map(([name, entry]) => [name, entry.kind]));
|
|
3219
|
+
scanned.set(path, { stamps: scan.stamps, misses: scan.misses, signals });
|
|
3147
3220
|
return signals;
|
|
3148
3221
|
} catch {
|
|
3149
3222
|
return {};
|
|
3150
3223
|
}
|
|
3151
3224
|
}
|
|
3225
|
+
function collect(path, scan, trail) {
|
|
3226
|
+
const kept = scan.done.get(path);
|
|
3227
|
+
if (kept)
|
|
3228
|
+
return kept;
|
|
3229
|
+
const stamp = stampOf(path);
|
|
3230
|
+
scan.stamps.set(path, stamp);
|
|
3231
|
+
if (stamp === undefined)
|
|
3232
|
+
return {};
|
|
3233
|
+
if (trail.includes(path)) {
|
|
3234
|
+
scan.cuts++;
|
|
3235
|
+
return {};
|
|
3236
|
+
}
|
|
3237
|
+
const cuts = scan.cuts;
|
|
3238
|
+
const text = readFileSync5(path, "utf8");
|
|
3239
|
+
const own = (kinds) => Object.fromEntries(Object.entries(kinds).map(([name, kind]) => [name, { kind, origin: `${path}#${name}` }]));
|
|
3240
|
+
if (KAY_FILE2.test(path))
|
|
3241
|
+
return own(kindsOf(path, text));
|
|
3242
|
+
const parsed = scanModule(text, scriptLoader(path) === "tsx" || scriptLoader(path) === "jsx");
|
|
3243
|
+
const { links } = parsed;
|
|
3244
|
+
const signals = own(parsed.signals);
|
|
3245
|
+
const next = [...trail, path];
|
|
3246
|
+
const from = (specifier) => {
|
|
3247
|
+
const target = scannable(specifier, path);
|
|
3248
|
+
if (target === undefined && resolveFrom(specifier, path) === undefined && !KAY_MODULE.test(specifier))
|
|
3249
|
+
scan.misses.push({ specifier, from: path });
|
|
3250
|
+
return target === undefined ? {} : collect(target, scan, next);
|
|
3251
|
+
};
|
|
3252
|
+
const starred = new Map;
|
|
3253
|
+
for (const specifier of links.stars) {
|
|
3254
|
+
for (const [name, entry] of Object.entries(from(specifier))) {
|
|
3255
|
+
if (name === "default" || links.own.has(name))
|
|
3256
|
+
continue;
|
|
3257
|
+
const before = starred.get(name);
|
|
3258
|
+
starred.set(name, starred.has(name) && before?.origin !== entry.origin ? undefined : entry);
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
for (const [name, entry] of starred) {
|
|
3262
|
+
if (entry)
|
|
3263
|
+
signals[name] = entry;
|
|
3264
|
+
}
|
|
3265
|
+
for (const { exported, source, imported } of links.names) {
|
|
3266
|
+
const found = from(source);
|
|
3267
|
+
if (Object.hasOwn(found, imported))
|
|
3268
|
+
signals[exported] = found[imported];
|
|
3269
|
+
}
|
|
3270
|
+
if (scan.cuts === cuts)
|
|
3271
|
+
scan.done.set(path, signals);
|
|
3272
|
+
return signals;
|
|
3273
|
+
}
|
|
3152
3274
|
function kindsOf(path, text) {
|
|
3153
3275
|
if (KAY_FILE2.test(path)) {
|
|
3154
3276
|
const { module } = parseKay(text);
|
|
@@ -3700,7 +3822,7 @@ function propRead(binding, index, local, check) {
|
|
|
3700
3822
|
if (check)
|
|
3701
3823
|
return { before: `${DEFAULTED}${access.before}`, replace: access.replace, after: `${access.after ?? ""}, ${defaultName(index)})` };
|
|
3702
3824
|
const text = quoted ? `${PROPS}[${JSON.stringify(binding.key)}]` : `${PROPS}.${binding.key}`;
|
|
3703
|
-
return { before: `(${access.before}`, replace: access.replace, after: `${access.after ?? ""} !== undefined ? ${text} : ${defaultName(index)}())` };
|
|
3825
|
+
return { before: `(${access.before}`, replace: access.replace, after: `${access.after ?? ""} !== undefined ? ${text} : ${binding.literal ?? `${defaultName(index)}()`})` };
|
|
3704
3826
|
}
|
|
3705
3827
|
function propType(binding) {
|
|
3706
3828
|
return binding.fallback ? `Exclude<(typeof ${PROPS})[${JSON.stringify(binding.key)}], undefined>` : undefined;
|
|
@@ -4056,10 +4178,21 @@ function propsDeclaration(statement, body, shift, diagnostics) {
|
|
|
4056
4178
|
const next = properties[index + 1];
|
|
4057
4179
|
const previous = properties[index - 1];
|
|
4058
4180
|
const removal = next ? { start: shift(property).start, end: shift(next).start } : previous && { start: shift(previous).end, end: shift(property).end };
|
|
4059
|
-
declaration.bindings.push({ local: shift(local), key, fallback: value.type === "AssignmentPattern" ? shift(value.right) : undefined, removal, bindable: bindable.has(key) });
|
|
4181
|
+
declaration.bindings.push({ local: shift(local), key, fallback: value.type === "AssignmentPattern" ? shift(value.right) : undefined, literal: value.type === "AssignmentPattern" ? literalSource(value.right) : undefined, removal, bindable: bindable.has(key) });
|
|
4060
4182
|
}
|
|
4061
4183
|
return declaration;
|
|
4062
4184
|
}
|
|
4185
|
+
function literalSource(node) {
|
|
4186
|
+
if (node.type === "Literal")
|
|
4187
|
+
return "regex" in node || "bigint" in node ? undefined : node.raw ?? undefined;
|
|
4188
|
+
if (node.type === "UnaryExpression" && node.operator === "-" && node.argument.type === "Literal" && typeof node.argument.value === "number")
|
|
4189
|
+
return `-${node.argument.raw}`;
|
|
4190
|
+
if (node.type === "TemplateLiteral" && node.expressions.length === 0) {
|
|
4191
|
+
const cooked = node.quasis[0]?.value.cooked;
|
|
4192
|
+
return typeof cooked === "string" ? JSON.stringify(cooked) : undefined;
|
|
4193
|
+
}
|
|
4194
|
+
return;
|
|
4195
|
+
}
|
|
4063
4196
|
function kayImports(body, wanted) {
|
|
4064
4197
|
const local = new Map;
|
|
4065
4198
|
for (const statement of body) {
|
|
@@ -7216,7 +7349,7 @@ var init_dom = __esm(() => {
|
|
|
7216
7349
|
init_names();
|
|
7217
7350
|
init_plan();
|
|
7218
7351
|
init_validate();
|
|
7219
|
-
DOM_HELPERS = ["append", "attribute", "branches", "checkedMarkup", "choose", "close", "component", "componentClass", "effect", "errorParagraph", "fragment", "holdSubmits", "insert", "listen", "listenSubmit", "listenSubmitWith", "listenWith", "markers", "memo", "merge", "omit", "outside", "partClass", "partHanded", "partsClass", "property", "ref", "setClass", "setStyle", "spreadAttributes", "spreadWith", "template", "text", "transition", "untrack"];
|
|
7352
|
+
DOM_HELPERS = ["append", "attribute", "branches", "checkedMarkup", "choose", "close", "component", "componentClass", "effect", "errorParagraph", "fragment", "holdSubmits", "insert", "listen", "listenSubmit", "listenSubmitWith", "listenWith", "markers", "memo", "merge", "omit", "outside", "part", "partClass", "partHanded", "partsClass", "property", "ref", "setClass", "setStyle", "spreadAttributes", "spreadWith", "template", "text", "transition", "untrack"];
|
|
7220
7353
|
APART = [["kay/dom-loop", ["loop", "rowKey"]], ["kay/dom-await", ["awaited"]], ["kay/dom-try", ["attempt"]], ["kay/dom-spread", ["dynamic", "spread"]], ["kay/dom-image", ["image"]], ["kay/pending", ["pendingCall"]]];
|
|
7221
7354
|
DomTemplate = class DomTemplate extends TemplateWriter {
|
|
7222
7355
|
errors;
|
|
@@ -7242,6 +7375,8 @@ var init_dom = __esm(() => {
|
|
|
7242
7375
|
this.b.add("null");
|
|
7243
7376
|
else if (items.length === 1 && only.kind === "element")
|
|
7244
7377
|
this.element(only.node);
|
|
7378
|
+
else if (items.length === 1 && only.kind === "component")
|
|
7379
|
+
this.part(only.node);
|
|
7245
7380
|
else
|
|
7246
7381
|
this.fragment(nodes);
|
|
7247
7382
|
}
|
|
@@ -7250,6 +7385,13 @@ var init_dom = __esm(() => {
|
|
|
7250
7385
|
`).join("")}${this.writesLinks || navigates ? `import 'kay/i18n-links'
|
|
7251
7386
|
` : ""}`;
|
|
7252
7387
|
}
|
|
7388
|
+
part(node) {
|
|
7389
|
+
this.b.wrap(node, () => {
|
|
7390
|
+
this.b.add(`${helperName("part")}(() => `);
|
|
7391
|
+
this.component(node);
|
|
7392
|
+
this.b.add(")");
|
|
7393
|
+
});
|
|
7394
|
+
}
|
|
7253
7395
|
fragment(nodes) {
|
|
7254
7396
|
const { b } = this;
|
|
7255
7397
|
const parent = `KayP${this.counter++}`;
|
|
@@ -10609,7 +10751,7 @@ const { `);
|
|
|
10609
10751
|
b.add("const ").addSource(props.name).add(` = ${PROPS};
|
|
10610
10752
|
`);
|
|
10611
10753
|
for (const [index, binding] of props.bindings.entries()) {
|
|
10612
|
-
if (!binding.fallback)
|
|
10754
|
+
if (!binding.fallback || binding.literal !== undefined && this.options.check !== true)
|
|
10613
10755
|
continue;
|
|
10614
10756
|
const name = defaultName(index);
|
|
10615
10757
|
const type = `Exclude<(typeof ${PROPS})[${JSON.stringify(binding.key)}], undefined>`;
|
|
@@ -11755,6 +11897,8 @@ function causeText(cause) {
|
|
|
11755
11897
|
return `\`${cause.name}\` from ${cause.source}`;
|
|
11756
11898
|
case "live":
|
|
11757
11899
|
return `\`${cause.name}\`, a live value`;
|
|
11900
|
+
case "persisted":
|
|
11901
|
+
return `\`${cause.name}\`, a persisted value`;
|
|
11758
11902
|
}
|
|
11759
11903
|
}
|
|
11760
11904
|
var init_island_cause = () => {};
|
|
@@ -12948,6 +13092,16 @@ var init_route_lints = __esm(() => {
|
|
|
12948
13092
|
ROUTE_LINTS = {
|
|
12949
13093
|
...SERIAL_AWAITS_LINTS,
|
|
12950
13094
|
...LOOP_LINTS,
|
|
13095
|
+
"text-size-colour": {
|
|
13096
|
+
level: "warn",
|
|
13097
|
+
group: "code",
|
|
13098
|
+
site: true,
|
|
13099
|
+
summary: "A theme colour named like one of Tailwind's text sizes (`--color-base`, `--color-lg`, `--color-2xl`) in the project's CSS, while a file uses that `text-` utility: `text-base` is the font size and the text colour at once, so the text takes the colour, the page background where `base` is the ground, and disappears. Every use of the utility is reported. Rename the colour (`--color-background`, kayjs-ui's name for the ground) or write the size as `text-[1rem]`.",
|
|
13100
|
+
wrong: `@theme { --color-base: #1e1e2e; }
|
|
13101
|
+
button.text-base Pick`,
|
|
13102
|
+
right: `@theme { --color-background: #1e1e2e; }
|
|
13103
|
+
button.text-base Pick`
|
|
13104
|
+
},
|
|
12951
13105
|
"unguarded-route": {
|
|
12952
13106
|
level: "deny",
|
|
12953
13107
|
group: "security",
|
|
@@ -16208,16 +16362,28 @@ import { basename as basename5, relative as relative2 } from "node:path";
|
|
|
16208
16362
|
function isErrorPage(name) {
|
|
16209
16363
|
return name === ERROR_PAGE || STATUS_PAGE_FILES.has(name);
|
|
16210
16364
|
}
|
|
16365
|
+
function kindOf(imported, source, name) {
|
|
16366
|
+
const module = imported?.[source];
|
|
16367
|
+
return module && Object.hasOwn(module, name) ? module[name] : undefined;
|
|
16368
|
+
}
|
|
16211
16369
|
function liveBindings(script, imported) {
|
|
16212
|
-
return script.imports.filter((binding) => !binding.typeOnly && imported
|
|
16370
|
+
return script.imports.filter((binding) => !binding.typeOnly && kindOf(imported, binding.source, binding.imported) === "live");
|
|
16213
16371
|
}
|
|
16214
|
-
function
|
|
16215
|
-
const binding
|
|
16216
|
-
|
|
16372
|
+
function browserBinding(script, imported) {
|
|
16373
|
+
for (const binding of script.imports) {
|
|
16374
|
+
const kind = binding.typeOnly ? undefined : kindOf(imported, binding.source, binding.imported);
|
|
16375
|
+
if (kind === "live" || kind === "persisted")
|
|
16376
|
+
return { local: binding.local, kind };
|
|
16377
|
+
}
|
|
16378
|
+
return;
|
|
16379
|
+
}
|
|
16380
|
+
function browserCause(file, script, value) {
|
|
16381
|
+
const binding = script.imports.find((binding) => binding.local === value?.local);
|
|
16382
|
+
return value === undefined || binding === undefined ? undefined : { kind: value.kind, name: value.local, span: binding.span, line: lineOf(file.source, binding.span.start) };
|
|
16217
16383
|
}
|
|
16218
16384
|
function withInteractive(cause, script) {
|
|
16219
16385
|
const interactive = interactiveProps(script);
|
|
16220
|
-
return cause !== undefined && interactive !== undefined && cause.kind !== "client" && cause.kind !== "live" ? { ...cause, interactive } : cause;
|
|
16386
|
+
return cause !== undefined && interactive !== undefined && cause.kind !== "client" && cause.kind !== "live" && cause.kind !== "persisted" ? { ...cause, interactive } : cause;
|
|
16221
16387
|
}
|
|
16222
16388
|
function realCause(cause, expansion, original) {
|
|
16223
16389
|
if (cause === undefined || expansion === undefined)
|
|
@@ -16228,9 +16394,6 @@ function realCause(cause, expansion, original) {
|
|
|
16228
16394
|
function staticPin(span, cause) {
|
|
16229
16395
|
return { ...span, code: "static-pin", message: `This component is pinned \`--- static\`, and is an island: ${describeCause(cause)}`, note: "it needs the browser, so it hydrates there", help: "take that out of the component, or pin it `--- island`" };
|
|
16230
16396
|
}
|
|
16231
|
-
function liveImport(script, imported) {
|
|
16232
|
-
return liveBindings(script, imported)[0]?.local;
|
|
16233
|
-
}
|
|
16234
16397
|
function serverNames(server) {
|
|
16235
16398
|
return server && [...server.data.map((data) => data.name), ...server.exportNames];
|
|
16236
16399
|
}
|
|
@@ -16253,19 +16416,19 @@ function compileKay(original, filename, options = {}) {
|
|
|
16253
16416
|
const failed = !client && !routeFile && options.page !== true ? takeBlock(file, filename, options, script, scope, "failed") : undefined;
|
|
16254
16417
|
const failedAt = failed?.code.search(FAILED_FUNCTION) ?? -1;
|
|
16255
16418
|
const failedCode = failed && options.output === "html" && failedAt >= 0 ? failed.code.slice(failedAt) : undefined;
|
|
16256
|
-
const live = routeFile ? undefined :
|
|
16419
|
+
const live = routeFile ? undefined : browserBinding(script, options.importedSignals);
|
|
16257
16420
|
const pinned = file.pin?.kind === "island" && !pageFile;
|
|
16258
16421
|
const island = client || pinned || isInteractive(file, script) || live !== undefined ? islandId(filename, options.root) : undefined;
|
|
16259
16422
|
const hydratableServer = options.output === "html" && options.hydratable === true;
|
|
16260
16423
|
const twin = hydratableServer && !options.twinBuild && island === undefined && !routeFile ? `./${basename5(filename)}${ISLAND_TWIN}` : undefined;
|
|
16261
16424
|
const pin = file.pin;
|
|
16262
|
-
const rawCause = island === undefined ? undefined : islandCause(file, script) ??
|
|
16425
|
+
const rawCause = island === undefined ? undefined : islandCause(file, script) ?? browserCause(file, script, live);
|
|
16263
16426
|
const cause = withInteractive(realCause(rawCause, expansion, original), script);
|
|
16264
16427
|
const generateOptions = { cause: options.inspect === true && cause !== undefined ? describeCause(cause) : undefined, classTable: options.classTable, classMerge: options.classMerge, island, client, lives: island === undefined ? undefined : liveBindings(script, options.importedSignals).map((binding) => binding.local), twin, output: options.output, failedCode, hydratable: hydratableServer && (island !== undefined || options.twinBuild === true), moduleId: islandId(filename, options.root), includeServer: options.includeServer, params: options.params, paramTypes: options.paramTypes, outerQueries: options.outerQueries, outerGuards: options.outerGuards, outerSlots: options.outerSlots, layoutFile: basename5(filename) === LAYOUT, component: options.page === false && !routeFile, check: options.check, route: options.check === true && pageFile, pageFile, namedRefresh: options.namedRefresh, insideIsland: options.insideIsland, inspect: options.inspect, inspectSource: expansion ? { text: original, real: (offset) => expansion.real(offset) } : undefined, relocateImport: options.relocateImport, contextModule: options.check === true ? options.contextModule : undefined, ui: options.output === undefined ? undefined : options.ui, uiAdded: options.output === undefined ? options.ui : undefined, errorPage: isErrorPage(basename5(filename)), cardPage: basename5(filename) === CARD_PAGE, special: basename5(filename).startsWith("_") && basename5(filename) !== LAYOUT };
|
|
16265
16428
|
const analysis = generate(file, script, server, { ...generateOptions, name: SELF });
|
|
16266
16429
|
const imported = new Map([...script.imports, ...server?.imports ?? []].flatMap((binding) => {
|
|
16267
|
-
const kind = binding.typeOnly ? undefined : options.importedSignals
|
|
16268
|
-
return kind ? [[binding.local, kind]] : [];
|
|
16430
|
+
const kind = binding.typeOnly ? undefined : kindOf(options.importedSignals, binding.source, binding.imported);
|
|
16431
|
+
return kind ? [[binding.local, kind === "persisted" ? "signal" : kind]] : [];
|
|
16269
16432
|
}));
|
|
16270
16433
|
const values = options.output === undefined;
|
|
16271
16434
|
const found = findRewrites({ code: analysis.builder.code, map: analysis.builder.map(), sites: analysis.sites, values, dom: options.output === "dom", templateStart: file.templateStart, imported, component: componentName(filename), check: options.check, fixedPage: routeFile });
|
|
@@ -17750,13 +17913,24 @@ function mapMessage(linted, message) {
|
|
|
17750
17913
|
return;
|
|
17751
17914
|
const endPosition = end === undefined ? undefined : positionAt(entry.source, span.end);
|
|
17752
17915
|
const named = entry.source.includes("__props") ? (text) => text : (text) => text.replaceAll(COMPILED_PROPS, "");
|
|
17753
|
-
const
|
|
17916
|
+
const mapped = (written) => mapFix(entry, unindentedFix(linted, written), tailwind) ?? mapFix(entry, unindentedFix(linted, narrowed(linted.text, written)), tailwind);
|
|
17917
|
+
const fix = message.fix && mapped(message.fix);
|
|
17754
17918
|
const suggestions = message.suggestions?.flatMap((suggestion) => {
|
|
17755
|
-
const mappedFix =
|
|
17919
|
+
const mappedFix = mapped(suggestion.fix);
|
|
17756
17920
|
return mappedFix ? [{ ...suggestion, desc: named(suggestion.desc), fix: { ...mappedFix, text: named(mappedFix.text) } }] : [];
|
|
17757
17921
|
});
|
|
17758
17922
|
return { ...message, message: named(levelled(linted, message, start)), ...positionAt(entry.source, span.start), endLine: endPosition?.line, endColumn: endPosition?.column, fix: fix && { ...fix, text: named(fix.text) }, suggestions };
|
|
17759
17923
|
}
|
|
17924
|
+
function narrowed(text, fix) {
|
|
17925
|
+
const old = text.slice(fix.range[0], fix.range[1]);
|
|
17926
|
+
let head = 0;
|
|
17927
|
+
while (head < old.length && head < fix.text.length && old[head] === fix.text[head])
|
|
17928
|
+
head++;
|
|
17929
|
+
let tail = 0;
|
|
17930
|
+
while (tail < old.length - head && tail < fix.text.length - head && old[old.length - 1 - tail] === fix.text[fix.text.length - 1 - tail])
|
|
17931
|
+
tail++;
|
|
17932
|
+
return { range: [fix.range[0] + head, fix.range[1] - tail], text: fix.text.slice(head, fix.text.length - tail) };
|
|
17933
|
+
}
|
|
17760
17934
|
function mapFix(entry, fix, classes) {
|
|
17761
17935
|
const span = codeEdit(entry, fix.range[0], fix.range[1]);
|
|
17762
17936
|
if (!span) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
id = "kay"
|
|
2
2
|
name = "Kay"
|
|
3
3
|
description = "Highlighting and the kay language server for .kay components"
|
|
4
|
-
version = "1.104.
|
|
4
|
+
version = "1.104.3"
|
|
5
5
|
schema_version = 1
|
|
6
6
|
authors = [ "Kaynooo" ]
|
|
7
7
|
repository = "https://github.com/Kayno0o/kayjs"
|
|
8
8
|
|
|
9
9
|
[grammars.kay]
|
|
10
10
|
repository = "https://github.com/Kayno0o/kayjs"
|
|
11
|
-
rev = "v1.104.
|
|
11
|
+
rev = "v1.104.3"
|
|
12
12
|
path = "editors/tree-sitter-kay"
|
|
13
13
|
|
|
14
14
|
[language_servers.kay]
|
package/llms/check-and-tools.md
CHANGED
|
@@ -119,11 +119,13 @@ kay fmt --check
|
|
|
119
119
|
- `kay i18n --help` lists every `i18n` command, those a library adds included, such as `kay i18n translate <locale>` of `@kayjs/ai`, which fills the missing messages and entries as drafts.
|
|
120
120
|
- `kay upgrade [dir] [--dry-run] [--quiet] [--format text|json]`:
|
|
121
121
|
- Move the `kay` and `@kayjs/*` ranges of `package.json` that are version ranges of the registry, `npm:@kayjs/kay@~1.45.0` or `~1.45.0` (a path, workspace or git source is left), to `~<latest>` with the registry's answer, install, then run the installed kay's `kay check --fix --since <minor>` once per minor between the version the app was on and the one it moves to, oldest first, listing them from the installed kay's `kay explain deprecated --format json`, then `kay check --fix --deny-warnings`, which prints what is left to do by hand, a warning too, and sets the exit code: it says `nothing left to do by hand` only when nothing was printed.
|
|
122
|
-
- A release that dropped the lints of a minor no longer rewrites its forms, so an app that may still hold them goes through the minor before that release first (an app on 1.70 to 1.77 installs 1.73, then 1.76, then the latest), each stop installing the ranges, rewriting its minors and moving on; `DEPRECATION_MINORS` in `src/compiler/lints.ts` lists them, and a test fails until dropping a lint's last minor writes its release there. A stop whose install fails because the registry no longer serves it or a version it pins (
|
|
123
|
-
- A package the app lists with a plain range that kay's own `dependencies` list too (`elysia` today) is raised, once the last install is done, to the version kay's range starts at when the app's range or its installed copy is below it, keeping its `~`, `^` or exact form (never lowering it: a range already at kay's with an older copy installed is only installed again),
|
|
122
|
+
- A release that dropped the lints of a minor no longer rewrites its forms, so an app that may still hold them goes through the minor before that release first (an app on 1.70 to 1.77 installs 1.73, then 1.76, then the latest), each stop installing the ranges, rewriting its minors and moving on; `DEPRECATION_MINORS` in `src/compiler/lints.ts` lists them, and a test fails until dropping a lint's last minor writes its release there. A stop whose install fails because the registry no longer serves it or a version it pins (any other failure stops the upgrade as below) is replaced by the closest older minor that still holds the lints it is there for, down to the oldest `since` among them, and the run says which one it took; when none installs, it names the deprecations left unfixed and the sections of `llms/upgrading.md` to read, skips the stop, goes on and exits 1. Only the install of the latest version failing puts `package.json` and the lockfile back at the last stop that installed.
|
|
123
|
+
- A package the app lists with a plain range that kay's own `dependencies` list too (`elysia` today) is raised, once the last install is done, to the version kay's range starts at when the app's range or its installed copy is below it, keeping its `~`, `^` or exact form (never lowering it: a range already at kay's with an older copy installed is only installed again), then installed again and printed as a `raised` step (an app already on the latest kay gets it too; `--dry-run` prints `would raise`): kay and the app then share one copy. A failed install of it puts `package.json` back as the phases left it.
|
|
124
|
+
- A shared package raised across a major (or a 0.x minor) is named as a warning on stderr, `warnings` in `--format json`, with its from and to versions and the installed package's `MIGRATION.md`, `UPGRADING.md` or `CHANGELOG.md` (path from the app) when it ships one, else its `repository` URL, to read before `kay check` fails on it.
|
|
125
|
+
- An optional peer of kay (`typescript7`, `axe-core`, `@happy-dom/global-registrator`, `@kaynooo/pg-orm`) installed (from the app's folder up) but not declared before the upgrade is added to `devDependencies` at the new kay's range (`added`, or `would add` under `--dry-run`, and in `changed` under json); one not installed is not.
|
|
124
126
|
- An install that leaves an npm `bun` in `node_modules` older than the installed kay's `engines.bun` (the auto-installed peer of `bun-plugin-tailwind`) is followed by `bun update bun`.
|
|
125
127
|
- `--dry-run` lists the packages it would move and writes, installs and rewrites nothing. A run that does write warns on stderr when a git working tree holds uncommitted changes to tracked files, which the rewrite would mix with its own, and goes on.
|
|
126
|
-
- `--format json` prints `{ steps, changed }` on stdout (a failure prints `{ errors, warnings, problems }` as `kay check` does, and exits 1), each step a `{ verb, rest }` and each `changed` package the `{ name, spec, section }` it moved (or would move) to, the install and the checks it runs printing on stderr; the exit code is the text output's.
|
|
128
|
+
- `--format json` prints `{ steps, changed, warnings }` on stdout (a failure prints `{ errors, warnings, problems }` as `kay check` does, and exits 1), each step a `{ verb, rest }` and each `changed` package the `{ name, spec, section }` it moved (or would move) to, the install and the checks it runs printing on stderr; the exit code is the text output's.
|
|
127
129
|
- A last `kay check --fix` also moves a root Dockerfile's `oven/bun:<version>` to the Bun the new kay needs (`old-bun-image`). An app already on the latest is left as it is, a registry older than the app's range never moves it back, and a failed install puts `package.json` back as it was. A deprecated form is one `deprecated` lint with its `since` minor and a safe fix; a minor's breaking changes carry one when `kay check` can see the old form, see [Checks](checks.md).
|
|
128
130
|
- `kay explain [lint|error|group|island [file]] [--format text|json]`:
|
|
129
131
|
- `island <file>` says whether a component is an island, why and the rule; `island` alone lists every island of the project.
|
package/llms/code-lints.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
| `unkept-page` | warn | code | A page saying `keep: true` that `kay build` does not keep prerendered, as it reads the request or the clock, imports a package, holds module state or renders differently each time: reported by `kay build` at the file and line that decided it, never by `kay check`, and no `// kay-allow` comment reaches it. |
|
|
22
22
|
| `uncaught-await` | warn | code | An `await` block with no `catch` block and no `try` around it: once its value rejects, the pending block goes with nothing in its place and the error only reaches the log. |
|
|
23
23
|
| `removed-ui-token` | warn | code | A kayjs-ui theme token or utility under its old `kui-` name, such as `--color-kui-canvas` or `bg-kui-surface2`, which stopped working in 1.75: a utility builds nothing and a `var()` of it resolves to nothing. `kay check --fix` rewrites it to the app's own name where one stands for it, and the report says where to set the rest: a `--kui-border-*` knob and a `kui-` utility with no new form are reported without a fix. Names quoted in a comment are not reported |
|
|
24
|
+
| `text-size-colour` | warn | code | A theme colour named like a Tailwind text size (`--color-base`, `--color-lg`) in the project's CSS while a file uses that `text-` utility: `text-base` is then the font size and the text colour at once, so the text takes the colour (the page background where `base` is the ground) and vanishes. Every use is reported. Rename the colour (`--color-background`) or write the size as `text-[1rem]` |
|
|
24
25
|
| `unknown-tool-label` | warn | code | A key of a `toolLabels` object on `Chat` that names no tool of the project (an export in snake case, a `tool.name` or the name of a `tool()`), whose calls show the raw name. |
|
|
25
26
|
| `public-env-outside-src` | warn | code | An `s.Public(` in a `.ts` file outside `src/` (tests left out), such as `common/env.ts`: kay finds public fields only in the modules under `src`, so an island reads it as a plain string and the browser is not sent it. Declare the field in a `defineEnv` in a module under `src`. Reported by `kay check`, set with `lints` or allowed with `// kay-allow public-env-outside-src` |
|
|
26
27
|
| `browser-global-at-load` | deny | code | A module a page imports reading `window` or another browser-only name as it loads ([details](browser-only.md#browser-globals-on-the-server)). |
|
package/llms/components.md
CHANGED
|
@@ -159,7 +159,7 @@ ul
|
|
|
159
159
|
|
|
160
160
|
- Props are declared once, at the top level, with the `props<T>()` macro.
|
|
161
161
|
- Destructure one level deep and read nested fields as `todo.title`. `const all = props<T>()` also works and reads as `all.todo`.
|
|
162
|
-
- Defaults go in the destructuring. A default applies only to an `undefined` prop (`null` stays `null`), and runs only then, once per component, the first time the prop is read.
|
|
162
|
+
- Defaults go in the destructuring. A default applies only to an `undefined` prop (`null` stays `null`), and runs only then, once per component, the first time the prop is read (a literal one is written at each read instead, as it has no identity to keep).
|
|
163
163
|
- Props stay reactive: the compiler turns each destructured name into a live read. A read at the top of the script, outside a function, `memo` or `effect`, runs once, so `const last = items.length - 1` keeps the first length: write `const last = () => items.length - 1` and read `last()`.
|
|
164
164
|
- Props are read-only.
|
|
165
165
|
- To require children or a block a template only passes on with `slot`, type it and destructure nothing: `const {} = props<{ children: Snippet }>()`, as a destructured name nothing reads is `unread-name`.
|
package/llms/islands.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Islands
|
|
2
2
|
|
|
3
|
-
A component is an island when its own code needs the browser: an `on*`, `bind:` or `ref` in its template, a browser value of `kay` in its script (a `live` value a module exports included), or a `--- island` or `--- client` fence line; what an island renders is part of it, and nothing a component passes makes it one. It is decided at compile time, from the file and its imports.
|
|
3
|
+
A component is an island when its own code needs the browser: an `on*`, `bind:` or `ref` in its template, a browser value of `kay` in its script (a `live` or `persisted` value a module exports included, whether the component imports it from that module, from one re-exporting it or from one importing it and handing it on; a component with a `--- server` fence stays on the server; a function of that module reading the value inside does not count, only the value itself being imported), or a `--- island` or `--- client` fence line; what an island renders is part of it, and nothing a component passes makes it one. It is decided at compile time, from the file and its imports.
|
|
4
4
|
|
|
5
5
|
## Common tasks
|
|
6
6
|
|
|
@@ -34,15 +34,15 @@ kay generate resource post title:string body:text published:boolean
|
|
|
34
34
|
|
|
35
35
|
- `kay new <dir> [--kay <dependency>] [--template blank|server|site|app] [--with <features>] [--without <features>] [--forge forgejo|github] [--agents none] [--runner <label>] [--editor helix,zed|none] [-y] [--dry-run] [--format text|json] [--quiet]`:
|
|
36
36
|
- Scaffold a project in an empty directory.
|
|
37
|
-
- A project is a set of features: `server` (an Elysia server; off, a static site), `starter` (a header, a skip link, a `_404.kay`, a home page greeting from the server with a counter island), `tailwind` (Tailwind through `bun-plugin-tailwind` over
|
|
37
|
+
- A project is a set of features: `server` (an Elysia server; off, a static site), `starter` (a header, a skip link, a `_404.kay`, a home page greeting from the server with a counter island), `tailwind` (Tailwind through `bun-plugin-tailwind` over orbit's near-black palette (kayjs-ui's token names: `background`, `foreground`, `border`, `muted`, `accent`) with a hairline on every box, no shadows and, with `ui`, a starfield behind the page, with the `.vscode/settings.json` every project gets also pointing Tailwind IntelliSense at the shorthand and `class="..."`; off, the markup carries no classes), `ui` (kayjs-ui: its space skin imported in `app.css`, Space Grotesk and JetBrains Mono served through `fonts`, `ui()` in `kay.config.ts` and the header drawn with `AppHeader`; in every preset, and it needs `tailwind`), `accents` (an accent picker in the header, twelve accents kept in a cookie, `starlight` by default, in no preset: `--with accents` or `kay add accents`, and it needs `starter` and `tailwind`), `eslint`, `tests`, `ci` (the workflow below, Forgejo's or GitHub's), `docker` (the container below; a static site's brings a `_404.kay` when `starter` is off, for its nginx 404), `auth` (kayjs-auth: what `kay add auth` writes, its users in a SQLite file, which needs `server` and `tailwind`), `postgres` (kayjs-auth's users in Postgres instead, with its compose stack and roles, which needs `auth`) and `ws` (the app's API module and websocket island, shown on the home page, which needs `server`).
|
|
38
38
|
- A preset names a set: `blank` none, one layout and one bare page built as a static site; `server`, `site` and `app` as described below.
|
|
39
39
|
- Run in a terminal with none of `--template`, `--with`, `--without` or `-y`, it asks for a preset, then shows its features as a checklist. Checking a feature checks what it needs, and unchecking one unchecks what needs it.
|
|
40
40
|
- Otherwise it takes `--template`, `server` by default, adds the comma-separated `--with` features and drops the `--without` ones, and refuses a feature listed in both, or one missing what it needs (`kay: accents needs tailwind: add --with tailwind, or drop it with --without accents`); when `ci` or `docker` is left out, the next steps name `kay add ci` and `kay add docker`;
|
|
41
|
-
- `--with` and `--without` take every name `kay add` takes, `ai`, `mail`, `cms` and `ui` among them (one table of features, shown in the checklist too, `ui` needing `tailwind`): after the files are written, `kay new --with
|
|
41
|
+
- `--with` and `--without` take every name `kay add` takes, `ai`, `mail`, `cms` and `ui` among them (one table of features, shown in the checklist too, `ui` needing `tailwind`): after the files are written, `kay new --with ai,mail` runs `kay add ai,mail` on the new project, installing the libraries (so it needs the network, and `--dry-run` reads them from beside kay instead and installs nothing), and prints the notes `kay add` prints. `auth` and `ui` stay written by the templates, as `package.json` dependencies for `bun install`; `auth` holds `ui` too.
|
|
42
42
|
- `--forge forgejo|github` names where the repository lives, which decides the `ci` workflow: `.forgejo/workflows/*.yml` on a `debian` runner, or `.github/workflows/*.yml` on `ubuntu-latest` with `oven-sh/setup-bun` and, for an app with `postgres`, its Postgres service on `localhost:5432`; both run `kay check --format github`, so each problem shows on the diff, with `contents: read` permission alone (the Pages workflows add what publishing needs) and every action pinned to the commit of a release, its version in a comment. Without it the host is read from the `origin` remote of `dir`, or of the directory above it that exists, `github` for github.com and `forgejo` for any other remote or none. `--runner <label>` names another runner label for either; the Forgejo install step adds only the `git` and `unzip` the image lacks, with `apt-get` or `apk`, and skips Setup Bun when bun is already installed, so an Alpine image with bun and git runs it as written.
|
|
43
43
|
- `--editor helix,zed` also sets those editors up as `kay editor install` does, with the server run from the project's own kay since it is installed next; in a terminal with none of `--editor` and `-y`, and Helix or Zed on the PATH, it asks once whether to set up the ones found, and it sets nothing up otherwise. A failure is printed and does not fail the scaffold: [editor commands](editor-and-agent-commands.md#set-up-helix-or-zed).
|
|
44
|
-
-
|
|
45
|
-
- The `server`, `site` and `app` presets have a layout with `seo` defaults and a skip link, a header over
|
|
44
|
+
- No project carries an `.npmrc`: kay and every package a preset installs come from npm.
|
|
45
|
+
- The `server`, `site` and `app` presets have a layout with `seo` defaults and a skip link, a header over orbit's near-black palette, drawn with kayjs-ui's `AppHeader` (with `--with accents`, an accent picker kept in a cookie), Tailwind through `bun-plugin-tailwind`, and Tabler icons.
|
|
46
46
|
- `server`, the default, is an Elysia server, with a `Dockerfile` and `compose.prod.yaml` running the executable `bun run compile` makes; the compose requires `SITE_URL`, which `.env.example` lists.
|
|
47
47
|
- `site` is a static site whose `bun run build` runs `kay build --static`, with a Forgejo Pages workflow publishing `dist` to the `gitea-pages` branch under `/<owner>/<repo>`, its `SITE_URL` the forge's own address until a repository variable named `SITE_URL` gives the host the Forgejo instance publishes Pages on (`--forge github`: a workflow deploying `dist` with GitHub Pages, `SITE_URL` and `SITE_BASE` read from the repository), and a `Dockerfile` serving it with `nginxinc/nginx-unprivileged` on port 8080 instead.
|
|
48
48
|
- `app` is the server with kayjs-auth as `kay add auth` writes it (`auth({ name })` and `ui()` in `kay.config.ts`, a root `src/routes/_guard.ts` exporting kayjs-auth's `authGuard()` to put every page behind sign-in, and no `src/auth.ts`), an API module and an island over its websocket, its session secret written to a `.env` git ignores, `.env.test` holding a test-only secret, and `.env.example` naming what production sets (`SESSION_SECRET`, `SITE_URL`);
|
|
@@ -64,4 +64,4 @@ kay generate resource post title:string body:text published:boolean
|
|
|
64
64
|
- Applies `kay new` features, comma-separated, to the project in `dir` (the current directory by default): the files and edits `kay new --with` would have made, then `bun install`.
|
|
65
65
|
- The features the project holds are read off its files. A feature missing what it needs is refused naming the command that adds them together (`kay add server,ws`); `kay add postgres` on a project without kayjs-auth plans it too, `kay add auth,postgres` writes both in one run, and `postgres` over an app whose `data/auth.db` exists stops there, as that file holds the users.
|
|
66
66
|
- It writes only when every file has the shape `kay new` writes: a file both feature sets write differently (`_layout.kay`, `bunfig.toml`, `kay.config.ts`) is replaced while it is still what `kay new` wrote, `package.json` gets the scripts and dependencies it lacks (a script is replaced only while it is still the generated one), `.gitignore`, `.dockerignore` and `.env` get the lines or keys they lack, and `AGENTS.md` is left once edited; a deleted file is not written back and is named in the output. The CI workflow follows the `origin` remote (`.github` for GitHub, `.forgejo` otherwise), else the folder the project has, and the runner label is the one its workflow already runs on. Any other file, or a file that exists with other content, stops it with `kay add: nothing was written` and the lines to remove (`-`) and add (`+`) by hand.
|
|
67
|
-
- `ai`, `mail`, `cms`, `ui` and `auth` are features of kay's libraries (`auth` is kayjs-auth, which `kay new --with auth` writes the same files for; `kay new --with ai,mail,cms
|
|
67
|
+
- `ai`, `mail`, `cms`, `ui` and `auth` are features of kay's libraries (`auth` is kayjs-auth, which `kay new --with auth` writes the same files for; `kay new --with ai,mail,cms` runs this same step after scaffolding): it adds `@kayjs/ai`, `@kayjs/mail`, `@kayjs/cms`, `@kayjs/ui` or `@kayjs/auth` (the last two with `@iconify-json/tabler`, kayjs-auth with `@kaynooo/pg-orm` and kayjs-ui) at kay's own minor, then writes what the package's `add` export says (`{ description, files?, edits?, env?, example?, ignore?, extension?: { import, expression }, notes? }`, or a function of the project returning it) and adds the extension to `extensions` in `kay.config.ts`, which needs a plain `defineConfig({ ... })`. `ui` needs `tailwind` and `auth` needs `server` and `tailwind`, refused like a core feature; `kay add ui` writes only `ui()`, or in a static site the `@kayjs/ui/theme.css` import in `src/app.css` (see [Extensions](component-libraries.md#extensions)), and `kay add auth` writes `auth({ name })` in `kay.config.ts` (no `src/auth.ts`: the mailer of `src/mail.ts`, themed when `mail()` is registered, is found by `auth()`; over the app's pg-orm `Database` it adds `store: async () => pgAuth(...)` and `...authTables` to its `tables`, else users live in SQLite, `AUTH_DATABASE_URL` in `.env.example`; `.gitignore` is created when absent and `data` is added unless `/data` or `data/` is there), `src/routes/_guard.ts` exporting `authGuard()` from kayjs-auth to guard every page, `ui()`, and `KAY_SECRET` and `SITE_URL` in `.env.example`. The import goes where the app's `perfectionist/sort-imports` puts it (groups, then natural order), so a config with sorted imports passes `kay lint` with no fixer run.
|
package/llms/project.md
CHANGED
|
@@ -51,8 +51,7 @@ kay migrate astro ../my-astro-site --outdir ../my-kay-site
|
|
|
51
51
|
|
|
52
52
|
### Project setup
|
|
53
53
|
|
|
54
|
-
- kay is published as `@kayjs/kay` to npm and to the registry at `https://git.kaynooo.fr/api/packages/kaynooo/npm/`, its libraries as `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai` (`@kaynooo/kayjs*` up to 1.103, which `kay upgrade` moves an app off), and installed under the name its imports use: `"kay": "npm:@kayjs/kay@~<version>"` in `package.json`, a tilde since a minor release may break what the one before it took, each break listed in [Upgrading](upgrading.md) and every one `kay check` can recognise a `deprecated` lint with a fix, which `kay upgrade` applies as it moves the app, and a major is a rewrite,
|
|
55
|
-
- Before the first `kay new`, Bun is told once where the `@kaynooo` scope lives (pg-orm and the other `@kaynooo` packages of a project are on the Forgejo registry only), in `~/.bunfig.toml`: `[install.scopes]` with `"@kaynooo" = "https://git.kaynooo.fr/api/packages/kaynooo/npm/"`.
|
|
54
|
+
- kay is published as `@kayjs/kay` to npm, and as a mirror to the Forgejo registry at `https://git.kaynooo.fr/api/packages/kaynooo/npm/`, its libraries as `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai` (`@kaynooo/kayjs*` up to 1.103, which `kay upgrade` moves an app off), and installed under the name its imports use: `"kay": "npm:@kayjs/kay@~<version>"` in `package.json`, a tilde since a minor release may break what the one before it took, each break listed in [Upgrading](upgrading.md) and every one `kay check` can recognise a `deprecated` lint with a fix, which `kay upgrade` applies as it moves the app, and a major is a rewrite. Every package a project installs, pg-orm and eslint included, is on npm, so a project carries no `.npmrc` and Bun needs no registry setup.
|
|
56
55
|
- `bunx -p @kayjs/kay kay new my-app` writes a project that, after `cd my-app && bun install`, checks, builds and runs (`bun run dev`), both of those included: this setup, a layout, a page, a `_404.kay` and islands, or only what is picked of them (see [Commands](#commands) for the presets and features).
|
|
57
56
|
|
|
58
57
|
- kay runs on Bun 1.4.4 or later, as its `engines` says: the CLI and `pages()` refuse an older one, naming its version, its path and the fix, `bun update bun` when it is the project's npm `bun` package, which a plugin's peer dependency installs and package scripts run ahead of the system Bun.
|
|
@@ -82,7 +82,7 @@ section
|
|
|
82
82
|
`Card(title="Hi" tone="danger" compact)` renders the danger classes on the root and the head, and the compact ones on the head and the body. A variant with only `true` and `false` values is a boolean prop.
|
|
83
83
|
|
|
84
84
|
- Classes merge in the order the part's own classes, the recipe's base, its variants in the order they are declared, then the caller's `class`, so `Card(compact class={{ head: 'p-6' }})` gives `p-6` ([Override a class a component sets](#override-a-class-a-component-sets)).
|
|
85
|
-
- In an app with Tailwind, a recipe's utility classes are lifted at build: each string becomes one short class (`k1a2b3c4`) whose rule sits in the `utilities.recipe` cascade layer, so the HTML and the island JS carry the short name and no class table entry. The layer beats `components` (theme.css, skins) and loses to Tailwind's utilities, so an app `class` still wins; names with no utility (`kui-*`, `group`) stay as written. A variant's utility replaces the base's at every width (`md:px-4` in the base against `px-8` in a variant gives `px-8` at `md` too), and a `!` utility of the recipe beats an app's. A utility left unlifted (one quoted, holding `;`, or from an `as const` value) stays in `utilities` and beats the lifted variants.
|
|
85
|
+
- In an app with Tailwind, a recipe's utility classes are lifted at build: each string becomes one short class (`k1a2b3c4`) whose rule sits in the `utilities.recipe` cascade layer, so the HTML and the island JS carry the short name and no class table entry. The layer beats `components` (theme.css, skins) and loses to Tailwind's utilities, so an app `class` still wins; names with no utility (`kui-*`, `group`) stay as written. A variant's utility replaces the base's at every width (`md:px-4` in the base against `px-8` in a variant gives `px-8` at `md` too), and a `!` utility of the recipe beats an app's. A utility left unlifted (one quoted, holding `;`, or from an `as const` value) stays in `utilities` and beats the lifted variants. A lifted utility's `utilities` rule is cut unless a file, a word the build read or an `@source inline` names it too.
|
|
86
86
|
- The recipe reaches the same parts `class` does: `part="head"` elements, the root, and a part that is a component, which takes its entry as a string. The variant props never reach `...rest`.
|
|
87
87
|
- In an island, a variant changed at runtime swaps its classes. `kay check` reports a value no variant has at the call, `Card(tone="nope")`.
|
|
88
88
|
- A component takes one recipe, declared with `const` at the top of its script, which moves to module level: it cannot read the component's props, signals or any name the script declares, and `kay check` reports one that does, a recipe that shares its `const` or sits in a `--- server` fence, and root classes in a template with no `part="root"`. As with parts, it also declares no `class` prop.
|
package/llms/testing-browser.md
CHANGED
|
@@ -46,6 +46,7 @@ expect(await page.path()).toBe('/account')
|
|
|
46
46
|
- `fill(selector, text)` replaces a field's text as typing does, once the field's island hydrated (hydrating would write the text away); `type(text)` and `press(key)` go to the focused element.
|
|
47
47
|
- `text`, `value` and `count` read the page at once, `text` and `value` null when nothing matches.
|
|
48
48
|
- `waitFor(selector, { text, gone })` and `waitUntil(fn, { what })` poll until they hold, 5 seconds at most unless `timeout` gives other milliseconds, and fail naming what they waited for (`what` names a `waitUntil`, as in a server test) with the stack of the test's own call.
|
|
49
|
+
- `waitFor`'s `text` is compared as the page reads it with the no-break spaces folded (U+00A0 and U+202F, which kay writes in French typography) into plain ones, on both sides, so the text as the template writes it matches; any other difference is exact, and a timeout names an element that holds the text up to its whitespace (a thin space, a line break). `page.text` and `evaluate` return the page's own characters, so compare those with `.replace(/[\u00A0\u202F]/g, ' ')`; `site.visit(...).text` and `find(...).text` already fold every whitespace run into one space, `html` is raw.
|
|
49
50
|
- A wait whose function keeps throwing names the last error when it times out.
|
|
50
51
|
- `evaluate(fn, ...args)` runs a function in the page, its arguments and result crossing as JSON.
|
|
51
52
|
- Only the source of that function crosses, so it sees no variable or helper of the test, only its arguments, and `waitUntil` runs its function the same way.
|
package/llms/upgrading.md
CHANGED
|
@@ -17,6 +17,10 @@ What each minor release breaks, and what an app changes to move to it. kay and i
|
|
|
17
17
|
|
|
18
18
|
kay is `@kayjs/kay`, and kayjs-ui, kayjs-auth, kayjs-mail, kayjs-cms and kayjs-ai are `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai`, published to npm and to the Forgejo registry; `@kaynooo/kayjs` and `@kaynooo/kayjs-*` stop at 1.103, which stays installable. `kay upgrade` writes the new names in `package.json` (the `kay` alias becomes `"kay": "npm:@kayjs/kay@~1.104.0"`, so imports of `kay` are unchanged), installs, and rewrites every `@kaynooo/kayjs-*` import, config key and stylesheet import (`deprecated-package-names`). From an app on 1.103 or before, run it from the new kay: `bunx -p @kayjs/kay kay upgrade`. By hand: replace each name in `package.json`, run `bun install`, then `kay check --fix` for the sources. `@kaynooo/utils`, `@kaynooo/eslint`, `@kaynooo/pg-orm` and `@kaynooo/cli-kit` keep their names.
|
|
19
19
|
|
|
20
|
+
### The optional peers are the app's dev dependencies
|
|
21
|
+
|
|
22
|
+
`typescript7` and `axe-core` (since 1.97) and `@happy-dom/global-registrator` and `@kaynooo/pg-orm` are optional peers of kay, which a fresh install no longer brings: an app that only had them because an older install or the renamed package left them in `node_modules` loses them when the install is redone, and `kay check` stops with "typescript7 is not installed", the a11y tests with "axe-core is not installed". `kay upgrade` adds each one the app had installed without declaring it to `devDependencies`. By hand: `bun add -d typescript7@npm:typescript@^7.0.2 axe-core@^4.14.0`, plus `@happy-dom/global-registrator@^21.0.3` for an app testing with `kay/test/dom` and `@kaynooo/pg-orm@^8.0.0` for one using the database.
|
|
23
|
+
|
|
20
24
|
## 1.103.0
|
|
21
25
|
|
|
22
26
|
### A page with `--- island` or `--- client` is refused
|