@kayjs/kay 1.109.0 → 1.111.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/eslint.js +488 -75
- package/editors/zed/extension.toml +2 -2
- package/llms/actions-from-islands.md +1 -1
- package/llms/build-and-start.md +1 -1
- package/llms/checks.md +1 -0
- package/llms/component-libraries.md +1 -1
- package/llms/components.md +1 -1
- package/llms/deprecated-lints.md +1 -1
- package/llms/dev-tool.md +1 -1
- package/llms/effects.md +1 -0
- package/llms/head.md +1 -1
- package/llms/images.md +2 -0
- package/llms/island-and-form-lints.md +2 -1
- package/llms/islands-lazy-components.md +23 -0
- package/llms/islands.md +4 -14
- package/llms/lints.md +1 -1
- package/llms/live-values.md +1 -1
- package/llms/navigation-from-code.md +1 -1
- package/llms/navigation.md +5 -3
- package/llms/performance-lints.md +1 -0
- package/llms/prerendering.md +1 -1
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +1 -1
- package/llms/templates-elements-slots-snippets.md +4 -4
- package/llms/upgrading-archive.md +121 -42
- package/llms/upgrading.md +17 -133
- package/llms/whats-new-archive.md +31 -31
- package/llms/whats-new.md +45 -30
- package/llms.txt +3 -2
- package/package.json +11 -11
- package/src/build/client.ts +10 -8
- package/src/build/island-images.ts +277 -0
- package/src/build/pipeline.ts +10 -4
- package/src/build/static.ts +99 -24
- package/src/build/variants.ts +132 -18
- package/src/check/env-types.ts +1 -1
- package/src/check/project.ts +4 -0
- package/src/check/schema-builders.ts +230 -26
- package/src/check/shadow-types.ts +3 -3
- package/src/commands/upgrade.ts +2 -1
- package/src/compiler/allow-comments.ts +38 -2
- package/src/compiler/ast.ts +4 -4
- package/src/compiler/codegen.ts +4 -4
- package/src/compiler/deprecated-lints-1-106.ts +2 -2
- package/src/compiler/dom.ts +4 -3
- package/src/compiler/hand-parts.ts +36 -8
- package/src/compiler/handed-data.ts +15 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/html.ts +3 -7
- package/src/compiler/index.ts +7 -4
- package/src/compiler/island-arguments.ts +9 -0
- package/src/compiler/island-lints.ts +7 -0
- package/src/compiler/items.ts +174 -0
- package/src/compiler/jsx.ts +10 -11
- package/src/compiler/kay-exports.ts +1 -0
- package/src/compiler/lints.ts +6 -7
- package/src/compiler/markup.ts +26 -24
- package/src/compiler/names.ts +1 -1
- package/src/compiler/removed-lints.ts +90 -0
- package/src/compiler/rewrite-types.ts +2 -0
- package/src/compiler/rewrite.ts +4 -2
- package/src/compiler/route-lints.ts +8 -0
- package/src/compiler/signal-from-prop.ts +141 -0
- package/src/compiler/template-reads.ts +16 -0
- package/src/compiler/template-walk.ts +2 -1
- package/src/config-shape.ts +4 -1
- package/src/config.ts +2 -2
- package/src/new.ts +16 -4
- package/src/project.ts +3 -3
- package/src/runtime/await.server.ts +4 -2
- package/src/runtime/checks.ts +14 -2
- package/src/runtime/client.ts +5 -9
- package/src/runtime/dev-tab-env.ts +28 -3
- package/src/runtime/dom-loop.ts +2 -4
- package/src/runtime/dom.ts +2 -2
- package/src/runtime/html.ts +53 -7
- package/src/runtime/image.ts +24 -23
- package/src/runtime/index.ts +2 -2
- package/src/runtime/island.server.ts +41 -11
- package/src/runtime/navigate.ts +14 -0
- package/src/runtime/navigation.ts +9 -1
- package/src/runtime/page-swap.ts +6 -3
- package/src/runtime/reactive.ts +72 -0
- package/src/runtime/row-key.ts +4 -0
- package/src/runtime/swap-flight.ts +10 -10
- package/src/runtime/swap-focus.ts +56 -9
- package/src/runtime/swap-kept.ts +97 -29
- package/src/runtime/swap-morph.ts +49 -9
- package/src/runtime/text-hash.ts +17 -0
- package/src/runtime/uid.server.ts +6 -4
- package/src/runtime/values.ts +12 -0
- package/src/server/client.ts +3 -0
- package/src/server/dev.ts +2 -0
- package/src/server/image.ts +1 -1
- package/src/server/kept-exports.ts +1 -0
- package/src/server/render-document.ts +11 -8
- package/src/server/render.ts +3 -3
- package/types/build/client.d.ts +6 -0
- package/types/build/client.d.ts.map +1 -1
- package/types/build/island-images.d.ts +45 -0
- package/types/build/island-images.d.ts.map +1 -0
- package/types/build/pipeline.d.ts.map +1 -1
- package/types/build/static.d.ts.map +1 -1
- package/types/build/variants.d.ts +9 -1
- package/types/build/variants.d.ts.map +1 -1
- package/types/check/project.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts.map +1 -1
- package/types/commands/upgrade.d.ts.map +1 -1
- package/types/compiler/allow-comments.d.ts +2 -0
- package/types/compiler/allow-comments.d.ts.map +1 -1
- package/types/compiler/ast.d.ts +1 -1
- package/types/compiler/ast.d.ts.map +1 -1
- package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +2 -2
- package/types/compiler/dom.d.ts.map +1 -1
- package/types/compiler/hand-parts.d.ts +6 -3
- package/types/compiler/hand-parts.d.ts.map +1 -1
- package/types/compiler/handed-data.d.ts +5 -0
- package/types/compiler/handed-data.d.ts.map +1 -0
- package/types/compiler/html.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-arguments.d.ts +5 -0
- package/types/compiler/island-arguments.d.ts.map +1 -1
- package/types/compiler/island-lints.d.ts +7 -0
- package/types/compiler/island-lints.d.ts.map +1 -1
- package/types/compiler/items.d.ts +14 -0
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/jsx.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +20 -5
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/markup.d.ts +3 -1
- package/types/compiler/markup.d.ts.map +1 -1
- package/types/compiler/names.d.ts.map +1 -1
- package/types/compiler/removed-lints.d.ts +3 -0
- package/types/compiler/removed-lints.d.ts.map +1 -0
- package/types/compiler/rewrite-types.d.ts +1 -0
- package/types/compiler/rewrite-types.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/signal-from-prop.d.ts +4 -0
- package/types/compiler/signal-from-prop.d.ts.map +1 -0
- package/types/compiler/template-reads.d.ts +1 -0
- package/types/compiler/template-reads.d.ts.map +1 -1
- package/types/compiler/template-walk.d.ts.map +1 -1
- package/types/config-shape.d.ts.map +1 -1
- package/types/config.d.ts +3 -1
- package/types/config.d.ts.map +1 -1
- package/types/new.d.ts.map +1 -1
- package/types/project.d.ts +2 -2
- package/types/project.d.ts.map +1 -1
- package/types/runtime/await.server.d.ts.map +1 -1
- package/types/runtime/checks.d.ts +8 -2
- package/types/runtime/checks.d.ts.map +1 -1
- package/types/runtime/client.d.ts.map +1 -1
- package/types/runtime/dev-tab-env.d.ts.map +1 -1
- package/types/runtime/dom-loop.d.ts +2 -1
- package/types/runtime/dom-loop.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +2 -2
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/runtime/html.d.ts +6 -3
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/image.d.ts.map +1 -1
- package/types/runtime/index.d.ts +2 -2
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +1 -0
- package/types/runtime/island.server.d.ts.map +1 -1
- package/types/runtime/navigate.d.ts.map +1 -1
- package/types/runtime/navigation.d.ts +4 -0
- package/types/runtime/navigation.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +5 -0
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/row-key.d.ts +2 -0
- package/types/runtime/row-key.d.ts.map +1 -0
- package/types/runtime/swap-flight.d.ts +1 -1
- package/types/runtime/swap-flight.d.ts.map +1 -1
- package/types/runtime/swap-focus.d.ts +2 -0
- package/types/runtime/swap-focus.d.ts.map +1 -1
- package/types/runtime/swap-kept.d.ts.map +1 -1
- package/types/runtime/swap-morph.d.ts.map +1 -1
- package/types/runtime/text-hash.d.ts +2 -0
- package/types/runtime/text-hash.d.ts.map +1 -0
- package/types/runtime/uid.server.d.ts.map +1 -1
- package/types/runtime/values.d.ts +4 -0
- package/types/runtime/values.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +3 -1
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +3 -1
- package/types/server/app.d.ts.map +1 -1
- package/types/server/client.d.ts +2 -0
- package/types/server/client.d.ts.map +1 -1
- package/types/server/dev.d.ts +1 -0
- package/types/server/dev.d.ts.map +1 -1
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/render-document.d.ts +1 -1
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/render.d.ts +2 -2
- package/types/server/render.d.ts.map +1 -1
package/dist/eslint.js
CHANGED
|
@@ -25,11 +25,11 @@ var __esm = (fn, res, err) => () => {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// package.json
|
|
28
|
-
var version = "1.
|
|
28
|
+
var version = "1.111.0", peerDependencies;
|
|
29
29
|
var init_package = __esm(() => {
|
|
30
30
|
peerDependencies = {
|
|
31
31
|
"@happy-dom/global-registrator": "^20.14.6 || ^21.0.3",
|
|
32
|
-
"@kaynooo/pg-orm": "^7.0.0 || ^8.0.0",
|
|
32
|
+
"@kaynooo/pg-orm": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
33
33
|
"@types/bun": "^1.4.4",
|
|
34
34
|
"axe-core": "^4.14.0",
|
|
35
35
|
"happy-dom": "^20.14.6 || ^21.0.3",
|
|
@@ -100,7 +100,7 @@ function nameDestructuredRows(file) {
|
|
|
100
100
|
node.row = row;
|
|
101
101
|
node.children.unshift({ kind: "const", ...node.item, pattern: node.item, value: at, row });
|
|
102
102
|
});
|
|
103
|
-
return { ...file, template };
|
|
103
|
+
return { ...file, template, facts: undefined };
|
|
104
104
|
}
|
|
105
105
|
var PATTERN_ITEM;
|
|
106
106
|
var init_template_walk = __esm(() => {
|
|
@@ -428,7 +428,7 @@ function addRecipe(facts, file, recipe) {
|
|
|
428
428
|
if (facts.parts.root !== "none")
|
|
429
429
|
facts.helpers.add("partClass");
|
|
430
430
|
if (facts.parts.implicit?.component) {
|
|
431
|
-
facts.helpers.add("
|
|
431
|
+
facts.helpers.add("partProps");
|
|
432
432
|
facts.helpers.add("handParts");
|
|
433
433
|
}
|
|
434
434
|
}
|
|
@@ -462,7 +462,7 @@ function factsOf(file) {
|
|
|
462
462
|
}
|
|
463
463
|
facts.helpers.add("partClass");
|
|
464
464
|
if (node.component) {
|
|
465
|
-
facts.helpers.add("
|
|
465
|
+
facts.helpers.add("partProps");
|
|
466
466
|
facts.helpers.add("handParts");
|
|
467
467
|
}
|
|
468
468
|
if (index > 0)
|
|
@@ -489,7 +489,7 @@ function factsOf(file) {
|
|
|
489
489
|
if (facts.parts) {
|
|
490
490
|
markRoot(facts.parts, file.template);
|
|
491
491
|
if (facts.parts.implicit?.component) {
|
|
492
|
-
facts.helpers.add("
|
|
492
|
+
facts.helpers.add("partProps");
|
|
493
493
|
facts.helpers.add("handParts");
|
|
494
494
|
}
|
|
495
495
|
}
|
|
@@ -3764,7 +3764,7 @@ function defaultName(index) {
|
|
|
3764
3764
|
var PROPS = "__props", CURRENT = "KayCurrent", VALUES = "__values", WRITABLE = "KayWritable(", DEFAULTED = "KayDefault(", HANDED = "KayHanded(", WRITE_HELPERS, PROBE = "(KayTarget, KayKey) => { KayTarget[KayKey] = undefined as never }", SUBJECT = "KaySubject", LOAD = "load", LOAD_TABLE = "KayLoadTable", LOAD_RUN = "KayKept", LOAD_KEY = "Symbol.for('kay.kept')", SELF = "KaySelf", DEFAULT_PREFIX = "__default_", GENERATED_NAME;
|
|
3765
3765
|
var init_names = __esm(() => {
|
|
3766
3766
|
WRITE_HELPERS = { to: "KayWriteTo", update: "KayUpdateTo", back: "KayWriteBack", updateBack: "KayUpdateBack" };
|
|
3767
|
-
GENERATED_NAME = new RegExp(`^(?:${[PROPS, VALUES, CURRENT, "kayEvent", "kayMatched", "kayAwaited", "kayEach"].join("|")}|${DEFAULT_PREFIX}\\d+|Kay(?:Default|LoopFor|StaticFor|Show|Omit|ComponentClass|PartClass|PartsClass|HandParts|PartOf|HandedPart|Dynamic|TemplateHelpers|Island|IslandBrand|HydrateWhen|Href|Html|ComputedHtml|Field|FormValues|FormError|Prop|PlainProp|FunctionProp|PromotedProp|PromotedFunctionProp|HandsPart|Children|Row|List|Truthy|Unmatched|Keyed|Radio|Writable|WriteTo|UpdateTo|WriteBack|UpdateBack|Bound|Bindable|Handed|PageContext|PrerenderedContext|PageSettings|QueryOf|PageData|JSX|FormAction|RegisterActions|ActionStub|ReviveActions|UseHead|Await|Awaited|Try))$`);
|
|
3767
|
+
GENERATED_NAME = new RegExp(`^(?:${[PROPS, VALUES, CURRENT, "kayEvent", "kayMatched", "kayAwaited", "kayEach"].join("|")}|${DEFAULT_PREFIX}\\d+|Kay(?:Default|LoopFor|StaticFor|Show|Omit|ComponentClass|PartClass|PartsClass|PartProps|HandParts|PartOf|HandedPart|Dynamic|TemplateHelpers|Island|IslandBrand|IslandAsked|IslandExport|HydrateWhen|Href|Html|ComputedHtml|Field|FormValues|FormError|Prop|PlainProp|FunctionProp|PromotedProp|PromotedFunctionProp|HandsPart|Children|Row|List|Truthy|Unmatched|Keyed|Radio|Writable|WriteTo|UpdateTo|WriteBack|UpdateBack|Bound|Bindable|Handed|PageContext|PrerenderedContext|PageSettings|QueryOf|PageData|JSX|FormAction|RegisterActions|ActionStub|ReviveActions|UseHead|Await|Awaited|Try))$`);
|
|
3768
3768
|
});
|
|
3769
3769
|
|
|
3770
3770
|
// src/compiler/pattern-names.ts
|
|
@@ -3900,6 +3900,87 @@ function constDeclaration(b, node, src, memo) {
|
|
|
3900
3900
|
function parameterNames(pattern) {
|
|
3901
3901
|
return parsedBindingNames(pattern) ?? [];
|
|
3902
3902
|
}
|
|
3903
|
+
function skipString(text, from) {
|
|
3904
|
+
const quote = text[from];
|
|
3905
|
+
let index = from + 1;
|
|
3906
|
+
while (index < text.length && text[index] !== quote)
|
|
3907
|
+
index += text[index] === "\\" ? 2 : 1;
|
|
3908
|
+
return index;
|
|
3909
|
+
}
|
|
3910
|
+
function accessorParameters(params) {
|
|
3911
|
+
const names = [];
|
|
3912
|
+
let depth = 0;
|
|
3913
|
+
let from = 0;
|
|
3914
|
+
let defaulted = false;
|
|
3915
|
+
let position = 0;
|
|
3916
|
+
const close = (to) => {
|
|
3917
|
+
const name = defaulted ? undefined : PLAIN_PARAMETER.exec(params.slice(from, to).trim())?.[1];
|
|
3918
|
+
if (name !== undefined)
|
|
3919
|
+
names.push({ name, position });
|
|
3920
|
+
position++;
|
|
3921
|
+
from = to + 1;
|
|
3922
|
+
defaulted = false;
|
|
3923
|
+
};
|
|
3924
|
+
for (let index = 0;index < params.length; index++) {
|
|
3925
|
+
const char = params[index];
|
|
3926
|
+
if (char === "=" && params[index + 1] === ">") {
|
|
3927
|
+
index++;
|
|
3928
|
+
} else if (QUOTES.includes(char)) {
|
|
3929
|
+
index = skipString(params, index);
|
|
3930
|
+
} else if (OPENING.includes(char)) {
|
|
3931
|
+
depth++;
|
|
3932
|
+
} else if (CLOSING.includes(char)) {
|
|
3933
|
+
depth--;
|
|
3934
|
+
} else if (char === "," && depth === 0) {
|
|
3935
|
+
close(index);
|
|
3936
|
+
} else if (char === "=" && depth === 0) {
|
|
3937
|
+
defaulted = true;
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
close(params.length);
|
|
3941
|
+
return depth === 0 && names.length > 0 ? names : undefined;
|
|
3942
|
+
}
|
|
3943
|
+
function simpleArguments(src, args) {
|
|
3944
|
+
const text = src.slice(args.start, args.end);
|
|
3945
|
+
if (!CHAINS.test(text))
|
|
3946
|
+
return;
|
|
3947
|
+
const spans = [];
|
|
3948
|
+
let from = 0;
|
|
3949
|
+
for (const cut of [...[...text.matchAll(COMMA)].map((match) => match.index), text.length]) {
|
|
3950
|
+
const piece = text.slice(from, cut);
|
|
3951
|
+
const lead = piece.length - piece.trimStart().length;
|
|
3952
|
+
spans.push({ start: args.start + from + lead, end: args.start + from + piece.trimEnd().length });
|
|
3953
|
+
from = cut + 1;
|
|
3954
|
+
}
|
|
3955
|
+
return spans;
|
|
3956
|
+
}
|
|
3957
|
+
function addSlotCall(b, src, slot, helper) {
|
|
3958
|
+
const spans = slot.outlet?.args && simpleArguments(src, slot.outlet.args);
|
|
3959
|
+
if (!slot.outlet || !spans)
|
|
3960
|
+
return false;
|
|
3961
|
+
b.add(`${helper}(${PROPS}.`).addSource(slot.outlet.name);
|
|
3962
|
+
for (const span of spans)
|
|
3963
|
+
b.add(", () => ").addSource(span);
|
|
3964
|
+
b.add(")");
|
|
3965
|
+
return true;
|
|
3966
|
+
}
|
|
3967
|
+
function markBlock(sites, b, src, params, staticLoops) {
|
|
3968
|
+
if (!staticLoops && accessorParameters(src.slice(params.start, params.end)))
|
|
3969
|
+
sites.blocks.add(b.code.length);
|
|
3970
|
+
}
|
|
3971
|
+
function addBlockParameters(sites, b, src, params, staticLoops) {
|
|
3972
|
+
const bare = BARE_PARAMETER.test(src.slice(params.start, params.end));
|
|
3973
|
+
b.add(bare ? "" : "(");
|
|
3974
|
+
markBlock(sites, b, src, params, staticLoops);
|
|
3975
|
+
b.addSource(params).add(bare ? " => " : ") => ");
|
|
3976
|
+
}
|
|
3977
|
+
function addParameterReads(b, names, param, render) {
|
|
3978
|
+
if (names)
|
|
3979
|
+
b.add(`(${names.map(({ name, position }) => `${name} = ${param}(${name}${position === 0 ? "" : `, ${position}`}), `).join("")}`);
|
|
3980
|
+
render();
|
|
3981
|
+
if (names)
|
|
3982
|
+
b.add(")");
|
|
3983
|
+
}
|
|
3903
3984
|
function slotValue(b, slot) {
|
|
3904
3985
|
if (!slot.outlet) {
|
|
3905
3986
|
b.add(`${PROPS}.children`);
|
|
@@ -3930,6 +4011,25 @@ function addKeyParameters(b, node, src) {
|
|
|
3930
4011
|
b.add(", ").addSource(node.index);
|
|
3931
4012
|
b.add(")");
|
|
3932
4013
|
}
|
|
4014
|
+
function addLoopTail(b, node, src, accessorLoops, rowKey) {
|
|
4015
|
+
const keying = rowKeying(node, src);
|
|
4016
|
+
const keyed = !accessorLoops && keying.kind !== "positional";
|
|
4017
|
+
if (!node.fallback && (accessorLoops || keyed))
|
|
4018
|
+
b.add(", undefined");
|
|
4019
|
+
if (accessorLoops)
|
|
4020
|
+
b.add(keying.kind === "positional" ? ', "positional"' : ', "keyed"');
|
|
4021
|
+
else if (keyed)
|
|
4022
|
+
b.add(", undefined");
|
|
4023
|
+
if (!keyed)
|
|
4024
|
+
return;
|
|
4025
|
+
b.add(", ");
|
|
4026
|
+
if (keying.kind === "expression") {
|
|
4027
|
+
addKeyParameters(b, node, src);
|
|
4028
|
+
b.add(" => (").addSource(keying.key).add(")");
|
|
4029
|
+
} else {
|
|
4030
|
+
b.add(rowKey);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
3933
4033
|
function readsName(expression, name) {
|
|
3934
4034
|
return new RegExp(`(?<![\\w$.])${name.replaceAll("$", "\\$")}(?![\\w$])`).test(expression);
|
|
3935
4035
|
}
|
|
@@ -3946,12 +4046,24 @@ function fixedSource(element) {
|
|
|
3946
4046
|
function ambientHelpers(facts, mode) {
|
|
3947
4047
|
return [...facts.ambientForm ? ["formHere", "formError"] : [], ...mode === "dom" && facts.snippet && facts.forms.size > 0 ? ["issueScope"] : []];
|
|
3948
4048
|
}
|
|
3949
|
-
|
|
4049
|
+
function usedProps(element, text) {
|
|
4050
|
+
if (element.attributes.some((attribute) => attribute.kind === "spread"))
|
|
4051
|
+
return "";
|
|
4052
|
+
const names = [...element.attributes.flatMap((attribute) => attribute.kind === "spread" ? [] : [attribute.name]), ...element.children.flatMap((child) => child.kind === "slot" ? [child.name] : [])];
|
|
4053
|
+
return `, { ${names.map((name) => `${JSON.stringify(text(name).replace(BOUND, ""))}: 0`).join(", ")} }`;
|
|
4054
|
+
}
|
|
4055
|
+
var pendingElements, PLAIN_PARAMETER, OPENING = "([{<", CLOSING = ")]}>", QUOTES = "\"'`", CHAIN, CHAINS, COMMA, BARE_PARAMETER, BOUND;
|
|
3950
4056
|
var init_items = __esm(() => {
|
|
3951
4057
|
init_ast();
|
|
3952
4058
|
init_names();
|
|
3953
4059
|
init_pattern_names();
|
|
3954
4060
|
pendingElements = new WeakMap;
|
|
4061
|
+
PLAIN_PARAMETER = /^([\p{ID_Start}$_][\p{ID_Continue}$]*)(?:\s*\?)?\s*(?::|$)/u;
|
|
4062
|
+
CHAIN = String.raw`[\p{ID_Start}$_][\p{ID_Continue}$]*(?:\.[\p{ID_Start}$_][\p{ID_Continue}$]*)*`;
|
|
4063
|
+
CHAINS = new RegExp(String.raw`^\s*${CHAIN}(?:\s*,\s*${CHAIN})*\s*$`, "u");
|
|
4064
|
+
COMMA = /,/g;
|
|
4065
|
+
BARE_PARAMETER = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u;
|
|
4066
|
+
BOUND = /^bind:/;
|
|
3955
4067
|
});
|
|
3956
4068
|
|
|
3957
4069
|
// src/compiler/kay-exports.ts
|
|
@@ -3990,6 +4102,7 @@ var init_kay_exports = __esm(() => {
|
|
|
3990
4102
|
flush: "browser",
|
|
3991
4103
|
focusInvalid: "browser",
|
|
3992
4104
|
followLog: "browser",
|
|
4105
|
+
followed: "shared",
|
|
3993
4106
|
formErrors: "shared",
|
|
3994
4107
|
guard: "browser",
|
|
3995
4108
|
guardLeave: "browser",
|
|
@@ -5757,12 +5870,30 @@ function writtenParts(element, source) {
|
|
|
5757
5870
|
const hand = element.attributes.find((one) => one.kind === "expression" && source.slice(one.name.start, one.name.end) === "parts");
|
|
5758
5871
|
return [...element.attributes.filter((one) => one.kind === "spread"), hand].filter((attribute) => attribute !== undefined);
|
|
5759
5872
|
}
|
|
5760
|
-
function
|
|
5761
|
-
|
|
5762
|
-
|
|
5873
|
+
function writesTogether(element, source, facts) {
|
|
5874
|
+
return element.component && partsOf(element, source, facts).length > 0 && handedParts(element, source, facts).length === 0;
|
|
5875
|
+
}
|
|
5876
|
+
function handedItem(b, part, recipe) {
|
|
5877
|
+
return {
|
|
5878
|
+
emit: () => {
|
|
5879
|
+
b.add(`${helperName("partHanded")}(${JSON.stringify(part)}, [`);
|
|
5880
|
+
for (const emit of recipe) {
|
|
5881
|
+
emit();
|
|
5882
|
+
b.add(", ");
|
|
5883
|
+
}
|
|
5884
|
+
b.add(`${helperName("partClass")}(${PROPS}, ${JSON.stringify(part)})])`);
|
|
5885
|
+
}
|
|
5886
|
+
};
|
|
5887
|
+
}
|
|
5888
|
+
function openClassList(b, component, handing, together) {
|
|
5889
|
+
if (together) {
|
|
5890
|
+
b.add(`${helperName("partProps")}(() => [[`);
|
|
5891
|
+
return;
|
|
5892
|
+
}
|
|
5893
|
+
b.add(component ? `${helperName(handing ? "handParts" : "componentClass")}([` : "[");
|
|
5763
5894
|
}
|
|
5764
|
-
function closeHandParts(b, component, written) {
|
|
5765
|
-
b.add(component && !written ? "])" : "]");
|
|
5895
|
+
function closeHandParts(b, component, written, together) {
|
|
5896
|
+
b.add(component && !written && !together ? "])" : "]");
|
|
5766
5897
|
const given = written?.filter((attribute) => attribute.kind === "expression" || attribute.kind === "spread") ?? [];
|
|
5767
5898
|
const emit = (attribute) => {
|
|
5768
5899
|
if (attribute.kind === "spread")
|
|
@@ -5782,13 +5913,15 @@ function closeHandParts(b, component, written) {
|
|
|
5782
5913
|
b.add(" }");
|
|
5783
5914
|
}
|
|
5784
5915
|
if (written)
|
|
5785
|
-
b.add(")");
|
|
5916
|
+
b.add(together ? "])" : ")");
|
|
5786
5917
|
}
|
|
5787
5918
|
function handsEntry(element, source, attribute, hands) {
|
|
5788
5919
|
return hands && writtenParts(element, source).includes(attribute);
|
|
5789
5920
|
}
|
|
5790
5921
|
var init_hand_parts = __esm(() => {
|
|
5922
|
+
init_ast();
|
|
5791
5923
|
init_markup();
|
|
5924
|
+
init_names();
|
|
5792
5925
|
});
|
|
5793
5926
|
|
|
5794
5927
|
// src/compiler/image-attributes.ts
|
|
@@ -7185,6 +7318,7 @@ class TemplateWriter {
|
|
|
7185
7318
|
classTable = undefined;
|
|
7186
7319
|
mergesAtRuntime = false;
|
|
7187
7320
|
lazySlots = false;
|
|
7321
|
+
accessorBlocks = true;
|
|
7188
7322
|
scoping = "formScope";
|
|
7189
7323
|
wiresLoose = true;
|
|
7190
7324
|
formOf(node) {
|
|
@@ -7313,13 +7447,16 @@ class TemplateWriter {
|
|
|
7313
7447
|
const { b } = this;
|
|
7314
7448
|
b.wrap(node, () => {
|
|
7315
7449
|
b.add("const ").addSource(node.name).add(" = (").addSource(node.params).add(") => ");
|
|
7316
|
-
this.childrenValue(node.children);
|
|
7450
|
+
this.readingParameters(node.params, () => this.childrenValue(node.children));
|
|
7317
7451
|
b.add("; ");
|
|
7318
7452
|
});
|
|
7319
7453
|
}
|
|
7454
|
+
readingParameters(params, render) {
|
|
7455
|
+
addParameterReads(this.b, this.accessorBlocks ? accessorParameters(this.source(params)) : undefined, helperName("param"), render);
|
|
7456
|
+
}
|
|
7320
7457
|
componentProps(element, getters, except) {
|
|
7321
7458
|
const { b } = this;
|
|
7322
|
-
const spreads = element.attributes.some((attribute) => attribute.kind === "spread");
|
|
7459
|
+
const spreads = element.attributes.some((attribute) => attribute.kind === "spread") || writesTogether(element, this.src, this.facts.parts);
|
|
7323
7460
|
if (spreads)
|
|
7324
7461
|
b.add(`${helperName("merge")}(`);
|
|
7325
7462
|
const props = this.sources(element, getters, true);
|
|
@@ -7328,7 +7465,7 @@ class TemplateWriter {
|
|
|
7328
7465
|
props.separate();
|
|
7329
7466
|
if (slot.params) {
|
|
7330
7467
|
b.add(`${JSON.stringify(this.source(slot.name))}: (`).addSource(slot.params).add(") => ");
|
|
7331
|
-
this.childrenValue(slot.children);
|
|
7468
|
+
this.readingParameters(slot.params, () => this.childrenValue(slot.children));
|
|
7332
7469
|
} else {
|
|
7333
7470
|
b.add(`get ${JSON.stringify(this.source(slot.name))}() { return `);
|
|
7334
7471
|
this.childrenValue(slot.children, this.lazySlots, scope, spreads);
|
|
@@ -7456,9 +7593,15 @@ class TemplateWriter {
|
|
|
7456
7593
|
if (element.name === "img" && ownStyle !== undefined && element.attributes.lastIndexOf(ownStyle) < lastSpread)
|
|
7457
7594
|
namedEntry(ownStyle, "style");
|
|
7458
7595
|
const hands = element.component && handedParts(element, this.src, this.facts.parts).length > 0;
|
|
7459
|
-
|
|
7596
|
+
const together = writesTogether(element, this.src, this.facts.parts);
|
|
7597
|
+
if (together) {
|
|
7598
|
+
closeObject();
|
|
7599
|
+
b.add(objects++ > 0 ? ", " : "");
|
|
7600
|
+
this.mergedClass(element, classAttribute, spreads, writtenParts(element, this.src), true);
|
|
7601
|
+
}
|
|
7602
|
+
if (!together && (hands ? spreads : mergedClass))
|
|
7460
7603
|
entry("class", () => hands ? b.add("undefined") : this.mergedClass(element, classAttribute, spreads), !hands);
|
|
7461
|
-
if (element.component && parts.length > 0)
|
|
7604
|
+
if (!together && element.component && parts.length > 0)
|
|
7462
7605
|
entry("parts", () => this.mergedClass(element, classAttribute, spreads, writtenParts(element, this.src)), true);
|
|
7463
7606
|
if (!keepOpen)
|
|
7464
7607
|
close();
|
|
@@ -7549,7 +7692,7 @@ class TemplateWriter {
|
|
|
7549
7692
|
if (defaults.length > 0)
|
|
7550
7693
|
this.b.add(`, { ${defaults.map(([name, value]) => `${JSON.stringify(name)}: ${JSON.stringify(value)}`).join(", ")} }`);
|
|
7551
7694
|
}
|
|
7552
|
-
mergedClass(element, classAttribute, spreads, handing) {
|
|
7695
|
+
mergedClass(element, classAttribute, spreads, handing, together = false) {
|
|
7553
7696
|
const { b } = this;
|
|
7554
7697
|
const shorthand = element.classes.length > 0 ? this.shorthand(element) : undefined;
|
|
7555
7698
|
const parts = partsOf(element, this.src, this.facts.parts);
|
|
@@ -7569,22 +7712,12 @@ class TemplateWriter {
|
|
|
7569
7712
|
else if (attribute === classAttribute && attribute.kind === "expression")
|
|
7570
7713
|
items.push({ emit: () => b.add("(").addSource(attribute.expression).add(")") });
|
|
7571
7714
|
}
|
|
7572
|
-
for (const part of handed)
|
|
7573
|
-
items.push(
|
|
7574
|
-
emit: () => {
|
|
7575
|
-
b.add(`${helperName("partHanded")}(${JSON.stringify(part)}, [`);
|
|
7576
|
-
for (const emit of this.recipeItem(part)) {
|
|
7577
|
-
emit();
|
|
7578
|
-
b.add(", ");
|
|
7579
|
-
}
|
|
7580
|
-
b.add(`${helperName("partClass")}(${PROPS}, ${JSON.stringify(part)})])`);
|
|
7581
|
-
}
|
|
7582
|
-
});
|
|
7583
|
-
}
|
|
7715
|
+
for (const part of handed)
|
|
7716
|
+
items.push(handedItem(b, part, this.recipeItem(part)));
|
|
7584
7717
|
for (const part of parts)
|
|
7585
7718
|
items.push(...this.recipeItem(part).map((emit) => ({ emit })), { emit: () => b.add(`${helperName("partClass")}(${PROPS}, ${JSON.stringify(part)})`) });
|
|
7586
7719
|
const written = this.classTable === undefined ? items : joinTexts(items, (texts) => this.joinLiterals(texts));
|
|
7587
|
-
openClassList(b, element.component,
|
|
7720
|
+
openClassList(b, element.component, handing, together);
|
|
7588
7721
|
for (const [index, item] of written.entries()) {
|
|
7589
7722
|
if (index > 0)
|
|
7590
7723
|
b.add(", ");
|
|
@@ -7593,7 +7726,7 @@ class TemplateWriter {
|
|
|
7593
7726
|
else
|
|
7594
7727
|
item.emit();
|
|
7595
7728
|
}
|
|
7596
|
-
closeHandParts(b, element.component, handing);
|
|
7729
|
+
closeHandParts(b, element.component, handing, together);
|
|
7597
7730
|
}
|
|
7598
7731
|
childrenValue(nodes, lazy = false, scope, fromSource = false) {
|
|
7599
7732
|
const { b } = this;
|
|
@@ -7894,8 +8027,8 @@ function awaitAlertTail(alert, target) {
|
|
|
7894
8027
|
var HTML_HELPERS, DOM_HELPERS, APART;
|
|
7895
8028
|
var init_helper_imports = __esm(() => {
|
|
7896
8029
|
init_markup();
|
|
7897
|
-
HTML_HELPERS = ["attempt", "attribute", "checkedMarkup", "child", "className", "component", "componentClass", "currentPage", "dynamic", "element", "errorParagraph", "fieldDescribed", "formConstraints", "formKey", "formOptions", "formType", "handParts", "head", "html", "imageAttributes", "innerMarkup", "leadingNewline", "linkHref", "localHref", "loop", "memo", "merge", "nonEmptyAttribute", "omit", "outsideLink", "partClass", "partHanded", "
|
|
7898
|
-
DOM_HELPERS = ["append", "attribute", "branches", "checkedMarkup", "choose", "close", "component", "componentClass", "effect", "errorParagraph", "fragment", "handParts", "holdSubmits", "insert", "listen", "listenSubmit", "listenSubmitWith", "listenWith", "markers", "memo", "merge", "omit", "outside", "part", "partClass", "partHanded", "
|
|
8030
|
+
HTML_HELPERS = ["attempt", "attribute", "checkedMarkup", "child", "className", "component", "componentClass", "currentPage", "dynamic", "element", "errorParagraph", "fieldDescribed", "formConstraints", "formKey", "formOptions", "formType", "handParts", "head", "html", "imageAttributes", "innerMarkup", "leadingNewline", "linkHref", "localHref", "loop", "memo", "merge", "nonEmptyAttribute", "omit", "outsideLink", "param", "partClass", "partHanded", "partProps", "raw", "rawData", "rawTyped", "refillOptions", "rowKey", "schemaFill", "selectOptions", "serverIsland", "show", "spreadAttributes", "spreadWith", "style", "untrack"];
|
|
8031
|
+
DOM_HELPERS = ["append", "attribute", "branches", "checkedMarkup", "choose", "close", "component", "componentClass", "effect", "errorParagraph", "fragment", "handParts", "holdSubmits", "insert", "listen", "listenSubmit", "listenSubmitWith", "listenWith", "markers", "memo", "merge", "omit", "outside", "param", "part", "partClass", "partHanded", "partProps", "property", "ref", "setClass", "setStyle", "slotCall", "spreadAttributes", "spreadWith", "template", "text", "transition", "untrack"];
|
|
7899
8032
|
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"]]];
|
|
7900
8033
|
});
|
|
7901
8034
|
|
|
@@ -8013,14 +8146,15 @@ var init_dom = __esm(() => {
|
|
|
8013
8146
|
if (form) {
|
|
8014
8147
|
b.add(`${helperName(this.scoping)}((`).addSource(form).add("), () => ");
|
|
8015
8148
|
if (item.node.outlet) {
|
|
8016
|
-
|
|
8149
|
+
if (!addSlotCall(b, this.src, item.node, helperName("slotCall")))
|
|
8150
|
+
slotValue(b, item.node);
|
|
8017
8151
|
} else {
|
|
8018
8152
|
b.add("{ const KayC = ");
|
|
8019
8153
|
slotValue(b, item.node);
|
|
8020
8154
|
b.add('; return typeof KayC === "function" ? KayC() : KayC }');
|
|
8021
8155
|
}
|
|
8022
8156
|
b.add(")");
|
|
8023
|
-
} else {
|
|
8157
|
+
} else if (!addSlotCall(b, this.src, item.node, helperName("slotCall"))) {
|
|
8024
8158
|
slotValue(b, item.node);
|
|
8025
8159
|
}
|
|
8026
8160
|
if (item.node.children.length > 0) {
|
|
@@ -8700,6 +8834,7 @@ var init_html = __esm(() => {
|
|
|
8700
8834
|
constructor(b, src, facts, ownMarkup, options = {}) {
|
|
8701
8835
|
super(b, src, facts, ownMarkup);
|
|
8702
8836
|
this.options = options;
|
|
8837
|
+
this.accessorBlocks = options.accessorLoops === true;
|
|
8703
8838
|
this.mergesAtRuntime = options.classMerge === true;
|
|
8704
8839
|
}
|
|
8705
8840
|
markup(nodes, inElement = false) {
|
|
@@ -8891,11 +9026,8 @@ var init_html = __esm(() => {
|
|
|
8891
9026
|
if (node.fallback) {
|
|
8892
9027
|
b.add(", () => ");
|
|
8893
9028
|
this.markup(node.fallback);
|
|
8894
|
-
} else if (this.options.accessorLoops) {
|
|
8895
|
-
b.add(", undefined");
|
|
8896
9029
|
}
|
|
8897
|
-
|
|
8898
|
-
b.add(rowKeying(node, this.src).kind === "positional" ? ', "positional"' : ', "keyed"');
|
|
9030
|
+
addLoopTail(b, node, this.src, this.options.accessorLoops === true, helperName("rowKey"));
|
|
8899
9031
|
b.add(")");
|
|
8900
9032
|
});
|
|
8901
9033
|
}
|
|
@@ -9404,6 +9536,17 @@ function islandMessages(source, client = false, lives = [], cause, fallback = fa
|
|
|
9404
9536
|
return `, ${JSON.stringify(keys)}, true`;
|
|
9405
9537
|
return keys.length > 0 ? `, ${JSON.stringify(keys)}` : "";
|
|
9406
9538
|
}
|
|
9539
|
+
function islandExport(expression, island, options) {
|
|
9540
|
+
if (island?.interactive === undefined || options.client || (options.lives?.length ?? 0) > 0 || island.hydrate !== undefined || island.persist !== undefined)
|
|
9541
|
+
return `
|
|
9542
|
+
export default ${expression}
|
|
9543
|
+
`;
|
|
9544
|
+
return `
|
|
9545
|
+
import type { IslandAsked as KayIslandAsked } from 'kay'
|
|
9546
|
+
const KayIslandExport = ${expression}
|
|
9547
|
+
export default KayIslandExport as typeof KayIslandExport & KayIslandAsked<${JSON.stringify(island.interactive)}>
|
|
9548
|
+
`;
|
|
9549
|
+
}
|
|
9407
9550
|
var MESSAGE_KEY, AWAIT_LINE, KAY_IMPORT;
|
|
9408
9551
|
var init_island_arguments = __esm(() => {
|
|
9409
9552
|
MESSAGE_KEY = /(?:\b(?:t|T|wording)\(\s*|\bT\([^)]*?\bkey=)(['"`])([\w.-]+)\1/g;
|
|
@@ -9877,7 +10020,9 @@ class JsxTemplate {
|
|
|
9877
10020
|
b.wrap(node, () => {
|
|
9878
10021
|
b.add("const ");
|
|
9879
10022
|
this.sites.snippets.add(b.code.length);
|
|
9880
|
-
b.addSource(node.name).add(" = (")
|
|
10023
|
+
b.addSource(node.name).add(" = (");
|
|
10024
|
+
markBlock(this.sites, b, this.src, node.params, this.options.staticLoops);
|
|
10025
|
+
b.addSource(node.params).add("): KayJSX.Element => (");
|
|
9881
10026
|
this.emitRoot(node.children);
|
|
9882
10027
|
b.add(");");
|
|
9883
10028
|
});
|
|
@@ -10192,10 +10337,8 @@ class JsxTemplate {
|
|
|
10192
10337
|
this.emitFunctionPropCheck(element, slot.name);
|
|
10193
10338
|
}
|
|
10194
10339
|
b.add(" ").addSource(slot.name).add("={");
|
|
10195
|
-
if (slot.params
|
|
10196
|
-
b.
|
|
10197
|
-
else if (slot.params)
|
|
10198
|
-
b.add("(").addSource(slot.params).add(") => ");
|
|
10340
|
+
if (slot.params)
|
|
10341
|
+
addBlockParameters(this.sites, b, this.src, slot.params, this.options.staticLoops);
|
|
10199
10342
|
this.emitRoot(slot.children);
|
|
10200
10343
|
b.add("}");
|
|
10201
10344
|
}
|
|
@@ -10355,7 +10498,7 @@ class JsxTemplate {
|
|
|
10355
10498
|
const sent = sentParts(this.src.slice(start, end)) ?? { parts: [{ start: 0, end: end - start }], functions: false };
|
|
10356
10499
|
let at = start;
|
|
10357
10500
|
if (sent.functions) {
|
|
10358
|
-
this.emitFunctionPropCheck(element, attribute.name);
|
|
10501
|
+
this.emitFunctionPropCheck(element, attribute.name, false);
|
|
10359
10502
|
b.add(" ");
|
|
10360
10503
|
}
|
|
10361
10504
|
this.attributeName(attribute).add("={");
|
|
@@ -10371,8 +10514,8 @@ class JsxTemplate {
|
|
|
10371
10514
|
return this.b.wrap(attribute.name, () => this.b.add(this.text(attribute.name)));
|
|
10372
10515
|
return this.b.addSource(attribute.name);
|
|
10373
10516
|
}
|
|
10374
|
-
emitFunctionPropCheck(element, name) {
|
|
10375
|
-
this.b.add("{...KayFunctionProp(").addSource(element.tag).add(")(").wrap(name, () => this.b.add("0")).add(")}");
|
|
10517
|
+
emitFunctionPropCheck(element, name, whole = true) {
|
|
10518
|
+
this.b.add("{...KayFunctionProp(").addSource(element.tag).add(whole ? usedProps(element, (span) => this.text(span)) : "").add(")(").wrap(name, () => this.b.add("0")).add(")}");
|
|
10376
10519
|
}
|
|
10377
10520
|
emitBind(element, attribute, property) {
|
|
10378
10521
|
const { b } = this;
|
|
@@ -10423,7 +10566,7 @@ class JsxTemplate {
|
|
|
10423
10566
|
return this.src.slice(span.start, span.end);
|
|
10424
10567
|
}
|
|
10425
10568
|
}
|
|
10426
|
-
var CALLED2, TYPED_SUBJECT, UNIT_VALUE, JSX_TEXT_ESCAPES, MARKUP_ATTRIBUTES, EVENT_HANDLER2
|
|
10569
|
+
var CALLED2, TYPED_SUBJECT, UNIT_VALUE, JSX_TEXT_ESCAPES, MARKUP_ATTRIBUTES, EVENT_HANDLER2;
|
|
10427
10570
|
var init_jsx = __esm(() => {
|
|
10428
10571
|
init_ast();
|
|
10429
10572
|
init_expression();
|
|
@@ -10441,7 +10584,6 @@ var init_jsx = __esm(() => {
|
|
|
10441
10584
|
JSX_TEXT_ESCAPES = /[{}<>]|[ \t]{2,}/g;
|
|
10442
10585
|
MARKUP_ATTRIBUTES = new Set(["innerHTML", "srcdoc"]);
|
|
10443
10586
|
EVENT_HANDLER2 = /^on[A-Z]/;
|
|
10444
|
-
PLAIN_PARAMETER = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u;
|
|
10445
10587
|
});
|
|
10446
10588
|
|
|
10447
10589
|
// src/compiler/lazy-imports.ts
|
|
@@ -10787,6 +10929,16 @@ function templateWords(file) {
|
|
|
10787
10929
|
});
|
|
10788
10930
|
return [...words];
|
|
10789
10931
|
}
|
|
10932
|
+
function templateWrites(file) {
|
|
10933
|
+
const names = new Set;
|
|
10934
|
+
visitNodes(file.template, (node) => {
|
|
10935
|
+
for (const span of nodeExpressions(node)) {
|
|
10936
|
+
for (const [, after, before] of file.source.slice(span.start, span.end).matchAll(WRITE))
|
|
10937
|
+
names.add(after ?? before);
|
|
10938
|
+
}
|
|
10939
|
+
});
|
|
10940
|
+
return names;
|
|
10941
|
+
}
|
|
10790
10942
|
function scopedBlocks(node) {
|
|
10791
10943
|
switch (node.kind) {
|
|
10792
10944
|
case "for":
|
|
@@ -10836,7 +10988,7 @@ function shadowedBinds(file) {
|
|
|
10836
10988
|
walk(file.template, new Set);
|
|
10837
10989
|
return shadowed;
|
|
10838
10990
|
}
|
|
10839
|
-
var WORD4, FIRST_NAME, TYPED_VALUES, IDENTIFIER2, FUNCTIONS2;
|
|
10991
|
+
var WORD4, FIRST_NAME, TYPED_VALUES, IDENTIFIER2, FUNCTIONS2, WRITE;
|
|
10840
10992
|
var init_template_reads = __esm(() => {
|
|
10841
10993
|
init_ast();
|
|
10842
10994
|
init_estree();
|
|
@@ -10847,6 +10999,7 @@ var init_template_reads = __esm(() => {
|
|
|
10847
10999
|
TYPED_VALUES = new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression", "TSTypeAssertion"]);
|
|
10848
11000
|
IDENTIFIER2 = /(?<![\w$.])[A-Z_$][\w$]*/gi;
|
|
10849
11001
|
FUNCTIONS2 = new Set(["ArrowFunctionExpression", "FunctionExpression", "FunctionDeclaration"]);
|
|
11002
|
+
WRITE = /([\w$]+)\s*(?:\.(?:set|update)\s*\(|(?:\*\*|<<|>>>?|&&|\|\||\?\?|[-+*/%&|^])?=(?![=>])|\+\+|--)|(?:\+\+|--)\s*([\w$]+)/g;
|
|
10850
11003
|
});
|
|
10851
11004
|
|
|
10852
11005
|
// src/compiler/load-plan.ts
|
|
@@ -11172,7 +11325,7 @@ class ModuleShell {
|
|
|
11172
11325
|
server;
|
|
11173
11326
|
options;
|
|
11174
11327
|
b;
|
|
11175
|
-
sites = { rows: new Set, consts: new Map, loopItems: new Set, snippets: new Set, props: new Map };
|
|
11328
|
+
sites = { rows: new Set, blocks: new Set, consts: new Map, loopItems: new Set, snippets: new Set, props: new Map };
|
|
11176
11329
|
src;
|
|
11177
11330
|
mode;
|
|
11178
11331
|
kind;
|
|
@@ -11507,17 +11660,13 @@ ${name}.kayFailed = KayFailed
|
|
|
11507
11660
|
export default ${this.mode === "html" && this.options.failedCode !== undefined ? `Object.assign((props: never) => KayInsideIsland() ? KayHydrated(props) : ${name}(props), { kayFailed: KayFailed })` : `((props: never) => KayInsideIsland() ? KayHydrated(props) : ${name}(props))`} as typeof ${name}${widened ? this.widenedCall(`typeof ${name}`) : ""}
|
|
11508
11661
|
`);
|
|
11509
11662
|
else if (this.kind === "island" && widened && !this.genericComponent)
|
|
11510
|
-
b.add(`
|
|
11511
|
-
export default KayIsland(${JSON.stringify(this.options.island)}, ${name}${this.islandTail(src)}) as unknown as ReturnType<typeof KayIsland<Parameters<typeof ${name}>[0]>>${this.widenedCall(`ReturnType<typeof KayIsland<Parameters<typeof ${name}>[0]>>`)}
|
|
11512
|
-
`);
|
|
11663
|
+
b.add(islandExport(`KayIsland(${JSON.stringify(this.options.island)}, ${name}${this.islandTail(src)}) as unknown as ReturnType<typeof KayIsland<Parameters<typeof ${name}>[0]>>${this.widenedCall(`ReturnType<typeof KayIsland<Parameters<typeof ${name}>[0]>>`)}`, this.script.island, this.options));
|
|
11513
11664
|
else if (widened && this.kind !== "island")
|
|
11514
11665
|
b.add(`
|
|
11515
11666
|
export default ${name} as typeof ${name}${this.widenedCall(`typeof ${name}`)}
|
|
11516
11667
|
`);
|
|
11517
11668
|
else if (this.kind === "island")
|
|
11518
|
-
b.add(`
|
|
11519
|
-
export default KayIsland(${JSON.stringify(this.options.island)}, ${name}${this.genericComponent ? " as never" : ""}${this.islandTail(src)})${this.genericIslandType()}${widened ? this.widenedCall(`typeof ${name}`) : ""}
|
|
11520
|
-
`);
|
|
11669
|
+
b.add(islandExport(`KayIsland(${JSON.stringify(this.options.island)}, ${name}${this.genericComponent ? " as never" : ""}${this.islandTail(src)})${this.genericIslandType()}${widened ? this.widenedCall(`typeof ${name}`) : ""}`, this.script.island, this.options));
|
|
11521
11670
|
}
|
|
11522
11671
|
islandTail(src) {
|
|
11523
11672
|
const html = this.options.output === "html";
|
|
@@ -12989,13 +13138,132 @@ var init_a11y = __esm(() => {
|
|
|
12989
13138
|
WALKS = { element: "element", text: "within", slot: "within", if: "alternatives", match: "alternatives", for: "alternatives", await: "alternatives", try: "alternatives", pending: "within", snippet: "within", const: "none", error: "none" };
|
|
12990
13139
|
});
|
|
12991
13140
|
|
|
13141
|
+
// src/compiler/removed-lints.ts
|
|
13142
|
+
var REMOVED_LINTS;
|
|
13143
|
+
var init_removed_lints = __esm(() => {
|
|
13144
|
+
REMOVED_LINTS = [
|
|
13145
|
+
"deprecated-action-readers",
|
|
13146
|
+
"deprecated-action-type",
|
|
13147
|
+
"deprecated-ai-labels",
|
|
13148
|
+
"deprecated-ai-language",
|
|
13149
|
+
"deprecated-ai-links",
|
|
13150
|
+
"deprecated-ai-options",
|
|
13151
|
+
"deprecated-ai-props",
|
|
13152
|
+
"deprecated-analytics-options",
|
|
13153
|
+
"deprecated-app-hooks",
|
|
13154
|
+
"deprecated-auth-methods",
|
|
13155
|
+
"deprecated-auth-rate-limits",
|
|
13156
|
+
"deprecated-auth-signed",
|
|
13157
|
+
"deprecated-await-consent",
|
|
13158
|
+
"deprecated-call-result",
|
|
13159
|
+
"deprecated-callback-handler",
|
|
13160
|
+
"deprecated-children-prop",
|
|
13161
|
+
"deprecated-client-keys",
|
|
13162
|
+
"deprecated-cms-options",
|
|
13163
|
+
"deprecated-cms-test-helpers",
|
|
13164
|
+
"deprecated-config-groups",
|
|
13165
|
+
"deprecated-config-keys",
|
|
13166
|
+
"deprecated-config-switch",
|
|
13167
|
+
"deprecated-context-import",
|
|
13168
|
+
"deprecated-ctx-fail",
|
|
13169
|
+
"deprecated-deny-call",
|
|
13170
|
+
"deprecated-disk-files",
|
|
13171
|
+
"deprecated-env-files",
|
|
13172
|
+
"deprecated-event-names",
|
|
13173
|
+
"deprecated-filter-options",
|
|
13174
|
+
"deprecated-format-duration",
|
|
13175
|
+
"deprecated-guard-option",
|
|
13176
|
+
"deprecated-hook-context",
|
|
13177
|
+
"deprecated-hook-names",
|
|
13178
|
+
"deprecated-i18n-keys",
|
|
13179
|
+
"deprecated-if-alias",
|
|
13180
|
+
"deprecated-image-options",
|
|
13181
|
+
"deprecated-images-keys",
|
|
13182
|
+
"deprecated-import-path",
|
|
13183
|
+
"deprecated-infinite-list-options",
|
|
13184
|
+
"deprecated-island-attributes",
|
|
13185
|
+
"deprecated-island-events",
|
|
13186
|
+
"deprecated-island-fence",
|
|
13187
|
+
"deprecated-job-handler",
|
|
13188
|
+
"deprecated-job-options",
|
|
13189
|
+
"deprecated-link-flags",
|
|
13190
|
+
"deprecated-listen-target",
|
|
13191
|
+
"deprecated-live-api",
|
|
13192
|
+
"deprecated-local-state",
|
|
13193
|
+
"deprecated-mail-form",
|
|
13194
|
+
"deprecated-mail-send",
|
|
13195
|
+
"deprecated-navigate-query",
|
|
13196
|
+
"deprecated-navigation-hooks",
|
|
13197
|
+
"deprecated-package-names",
|
|
13198
|
+
"deprecated-page-cache",
|
|
13199
|
+
"deprecated-page-island",
|
|
13200
|
+
"deprecated-page-seo",
|
|
13201
|
+
"deprecated-pages-options",
|
|
13202
|
+
"deprecated-parts-class",
|
|
13203
|
+
"deprecated-persisted-call",
|
|
13204
|
+
"deprecated-persisted-query",
|
|
13205
|
+
"deprecated-persisted-storage",
|
|
13206
|
+
"deprecated-rate-enforce",
|
|
13207
|
+
"deprecated-redirect-permanent",
|
|
13208
|
+
"deprecated-refuse-call",
|
|
13209
|
+
"deprecated-route-keys",
|
|
13210
|
+
"deprecated-schedule-call",
|
|
13211
|
+
"deprecated-schedule-tz",
|
|
13212
|
+
"deprecated-schema-type",
|
|
13213
|
+
"deprecated-script-fence",
|
|
13214
|
+
"deprecated-secret-keys",
|
|
13215
|
+
"deprecated-socket-frames",
|
|
13216
|
+
"deprecated-source-readers",
|
|
13217
|
+
"deprecated-store-ms",
|
|
13218
|
+
"deprecated-store-names",
|
|
13219
|
+
"deprecated-test-helpers",
|
|
13220
|
+
"deprecated-ttl-names",
|
|
13221
|
+
"deprecated-ui-callbacks",
|
|
13222
|
+
"deprecated-ui-hotkey",
|
|
13223
|
+
"deprecated-ui-input",
|
|
13224
|
+
"deprecated-ui-item-keys",
|
|
13225
|
+
"deprecated-ui-items",
|
|
13226
|
+
"deprecated-uncaught-await",
|
|
13227
|
+
"deprecated-workflow-start-id",
|
|
13228
|
+
"uncaught-await",
|
|
13229
|
+
"unreturned-fail"
|
|
13230
|
+
];
|
|
13231
|
+
});
|
|
13232
|
+
|
|
12992
13233
|
// src/compiler/allow-comments.ts
|
|
12993
13234
|
function allowComments(source) {
|
|
12994
13235
|
return Array.from(source.matchAll(ALLOW_COMMENT), (comment) => {
|
|
12995
13236
|
const { line, column } = positionAt(source, comment.index);
|
|
12996
13237
|
const listStart = comment.index + comment[0].length - comment[3].length - comment[2].length;
|
|
12997
13238
|
const names = Array.from(comment[2].matchAll(LINT_NAME), (name) => ({ name: name[0], start: listStart + name.index }));
|
|
12998
|
-
return { names, file: comment[1] === "kay-allow-file", line: source.slice(comment.index - column + 1, comment.index).trim() === "" ? line + 1 : line, start: comment.index, reasoned: REASON.test(comment[3]) };
|
|
13239
|
+
return { names, file: comment[1] === "kay-allow-file", line: source.slice(comment.index - column + 1, comment.index).trim() === "" ? line + 1 : line, start: comment.index, end: comment.index + comment[0].length, reasoned: REASON.test(comment[3]) };
|
|
13240
|
+
});
|
|
13241
|
+
}
|
|
13242
|
+
function unknownNames(comment, source, known, help) {
|
|
13243
|
+
const unknown = comment.names.filter(({ name }) => !known(name));
|
|
13244
|
+
const removed = new Set(REMOVED_LINTS);
|
|
13245
|
+
const lastKept = comment.names.findLastIndex(({ name }) => !removed.has(name));
|
|
13246
|
+
const lineStart = source.lastIndexOf(`
|
|
13247
|
+
`, comment.start - 1) + 1;
|
|
13248
|
+
const whole = source.slice(lineStart, comment.start).trim() === "";
|
|
13249
|
+
const after = comment.end + (source.startsWith(`\r
|
|
13250
|
+
`, comment.end) ? 2 : Number(source[comment.end] === `
|
|
13251
|
+
`));
|
|
13252
|
+
const before = comment.start - (BLANK_END.exec(source.slice(lineStart, comment.start))?.[0].length ?? 0);
|
|
13253
|
+
const last = comment.names.at(-1);
|
|
13254
|
+
return unknown.map(({ name, start }) => {
|
|
13255
|
+
const end = start + name.length;
|
|
13256
|
+
if (!removed.has(name))
|
|
13257
|
+
return { start, end, code: "unknown-lint", message: `Unknown lint \`${name}\``, help, checkOnly: true };
|
|
13258
|
+
const position = comment.names.findIndex((other) => other.start === start);
|
|
13259
|
+
const diagnostic = { start, end, code: "unknown-lint", severity: "warning", message: `\`${name}\` is a lint kay has removed`, help: "remove it from the comment: it allows nothing", checkOnly: true };
|
|
13260
|
+
if (position > lastKept && position !== lastKept + 1)
|
|
13261
|
+
return diagnostic;
|
|
13262
|
+
const kept = comment.names[lastKept];
|
|
13263
|
+
const dropped = whole ? { start: lineStart, end: after } : { start: before, end: comment.end };
|
|
13264
|
+
const tail = kept ? { start: kept.start + kept.name.length, end: last.start + last.name.length } : dropped;
|
|
13265
|
+
const edit = position > lastKept ? tail : { start, end: comment.names[position + 1].start };
|
|
13266
|
+
return { ...diagnostic, fixes: [{ title: kept || position < lastKept ? `remove \`${name}\`` : "remove the comment", safe: true, edits: [{ ...edit, text: "" }] }] };
|
|
12999
13267
|
});
|
|
13000
13268
|
}
|
|
13001
13269
|
function refusal(comment, rules) {
|
|
@@ -13016,11 +13284,13 @@ function refusedComments(comments, rules) {
|
|
|
13016
13284
|
return message === undefined ? [] : [{ start: comment.start, end: comment.start + 2, code: "allow-refused", message, checkOnly: true }];
|
|
13017
13285
|
});
|
|
13018
13286
|
}
|
|
13019
|
-
var ALLOW_COMMENT, LINT_NAME, REASON;
|
|
13287
|
+
var ALLOW_COMMENT, LINT_NAME, BLANK_END, REASON;
|
|
13020
13288
|
var init_allow_comments = __esm(() => {
|
|
13021
13289
|
init_mapping();
|
|
13290
|
+
init_removed_lints();
|
|
13022
13291
|
ALLOW_COMMENT = /\/\/[ \t]*(kay-allow(?:-file)?)[ \t]+(\w[\w-]*(?:[ \t]*,[ \t]*\w[\w-]*)*)([^\n]*)/g;
|
|
13023
13292
|
LINT_NAME = /[\w-]+/g;
|
|
13293
|
+
BLANK_END = /[ \t]*$/;
|
|
13024
13294
|
REASON = /^[ \t]*--[ \t]*\S/;
|
|
13025
13295
|
});
|
|
13026
13296
|
|
|
@@ -13033,7 +13303,7 @@ var init_deprecated_lints_1_106 = __esm(() => {
|
|
|
13033
13303
|
group: "deprecated",
|
|
13034
13304
|
since: "1.106",
|
|
13035
13305
|
site: true,
|
|
13036
|
-
summary: "The PascalCase builders of `s` before 1.106, which kay's own lowercase builders replace, each taking the same field options (`optional`, `default`, `error`, `label`, `description`, `example`) and short names for the rest: `s.String` is `s.string` (`min`, `max`), `s.Integer` `s.int`, `s.Number` and `s.Numeric` `s.number`, `s.Boolean` and `s.BooleanString` `s.boolean`, `s.Array` `s.list`, `s.UnionEnum` and `s.UnionKeys` `s.enum`, and `s.Date`, `s.Literal`, `s.Union`, `s.Object`, `s.File`, `s.Files`, `s.Secret` and `s.Public` their lowercase names; `s.Optional(field)` is `optional: true` in the options of the field; an `s.Object({ ... })` that is the schema of
|
|
13306
|
+
summary: "The PascalCase builders of `s` before 1.106, which kay's own lowercase builders replace, each taking the same field options (`optional`, `default`, `error`, `label`, `description`, `example`) and short names for the rest: `s.String` is `s.string` (`min`, `max`), `s.Integer` `s.int`, `s.Number` and `s.Numeric` `s.number`, `s.Boolean` and `s.BooleanString` `s.boolean`, `s.Array` `s.list`, `s.UnionEnum` and `s.UnionKeys` `s.enum`, and `s.Date`, `s.Literal`, `s.Union`, `s.Object`, `s.File`, `s.Files`, `s.Secret` and `s.Public` their lowercase names; `s.Optional(field)` is `optional: true` in the options of the field; an `s.Object({ ... })` that is the schema of a `defineEnv` is the record of fields alone, as an env reads only the names it declares; and a file size written `'2m'` is `'2mb'`. The old names work until 2.0. Found on the `s` a file imports from `kay`, in the TypeScript files and the fences of `.kay` files. The fix renames the builder and the options that changed, and keeps what each did: an `s.Array` takes `max: Number.MAX_SAFE_INTEGER` (the lowercase list stops at 1,000 items) and an `s.Object` `extra: 'strip'`, a rewrite whose options are not an object literal being reported without a fix; an `s.Union` of `Object.keys(R).map(key => s.Literal(key))` is `s.enum(R)`, and any other `s.Union` of a mapped array is reported without a fix; an `s.Optional` around anything but one of these builders, such as a helper of `kay/content`, is left as it is. A lowercase `s.object` refuses a key its shape lacks where kay reads the schema itself (an action's input, an API route's body, `defineEnv`, collection frontmatter), where `s.Object` let it by, so the fix writes `{ extra: 'strip' }`. A query, the headers and the cookies of a request carry keys no schema names, so their unknown keys are dropped whatever the schema says.",
|
|
13037
13307
|
wrong: `--- server
|
|
13038
13308
|
import { action, s } from 'kay'
|
|
13039
13309
|
|
|
@@ -13043,7 +13313,7 @@ p x`,
|
|
|
13043
13313
|
right: `--- server
|
|
13044
13314
|
import { action, s } from 'kay'
|
|
13045
13315
|
|
|
13046
|
-
export const add = action({ title: s.string({ max: 200 }), note: s.string({ optional: true }) }, ({ title }) => title)
|
|
13316
|
+
export const add = action(s.object({ title: s.string({ max: 200 }), note: s.string({ optional: true }) }, { extra: 'strip' }), ({ title }) => title)
|
|
13047
13317
|
---
|
|
13048
13318
|
p x`
|
|
13049
13319
|
}
|
|
@@ -13161,6 +13431,25 @@ button(onClick={() => count.set(count() + 1)}) {count()}`,
|
|
|
13161
13431
|
import Counter from '../components/counter.kay'
|
|
13162
13432
|
---
|
|
13163
13433
|
Counter`
|
|
13434
|
+
},
|
|
13435
|
+
"signal-from-prop": {
|
|
13436
|
+
level: "warn",
|
|
13437
|
+
group: "islands",
|
|
13438
|
+
summary: "A `signal` seeded from a destructured prop at the top of an island's script, `signal(light)` or `signal(todo.title)`, that the island never writes: an island stays when the page gives it new props, as after an action or a refresh, so the signal keeps the first value. `linked(() => light)` follows the prop; `kay check --fix` writes it. A signal the island writes, as a counter starting from a prop, is its own state and is left alone, as is a prop named `initial...` or `default...` or a comment `// kay-allow signal-from-prop`.",
|
|
13439
|
+
wrong: `---
|
|
13440
|
+
import { signal } from 'kay'
|
|
13441
|
+
|
|
13442
|
+
const { light } = props<{ light: string }>()
|
|
13443
|
+
const picked = signal(light)
|
|
13444
|
+
---
|
|
13445
|
+
p {picked()}`,
|
|
13446
|
+
right: `---
|
|
13447
|
+
import { linked } from 'kay'
|
|
13448
|
+
|
|
13449
|
+
const { light } = props<{ light: string }>()
|
|
13450
|
+
const picked = linked(() => light)
|
|
13451
|
+
---
|
|
13452
|
+
p {picked()}`
|
|
13164
13453
|
}
|
|
13165
13454
|
};
|
|
13166
13455
|
});
|
|
@@ -13464,6 +13753,14 @@ var init_route_lints = __esm(() => {
|
|
|
13464
13753
|
...LOOP_LINTS,
|
|
13465
13754
|
...LINK_LINTS,
|
|
13466
13755
|
...SCHEMA_LINTS,
|
|
13756
|
+
"static-remote-image": {
|
|
13757
|
+
level: "warn",
|
|
13758
|
+
group: "performance",
|
|
13759
|
+
site: true,
|
|
13760
|
+
summary: "On a `kay build --static` export, an island image the build cannot write files for: an `image(source, { width, height })` whose source is neither an imported image nor a literal URL, a literal URL on a host `assets.images.remote` does not list, a width or height that is no number literal, or an `aspect`, `quality` or `sizes` that is no literal. The export has no image route, so the browser links the original image, or asks for a file that does not exist. Give `image()` the URL as a literal on a listed host, with its size and options as literals, and the build fetches and resizes it. A best-effort read of the island's source. Reported by `kay build --static`.",
|
|
13761
|
+
wrong: 'img({...image(post.cover, { width: 1200, height: 800 })} alt="")',
|
|
13762
|
+
right: `img({...image('https://cms.example.com/cover.jpg', { width: 1200, height: 800 })} alt="")`
|
|
13763
|
+
},
|
|
13467
13764
|
"text-size-colour": {
|
|
13468
13765
|
level: "warn",
|
|
13469
13766
|
group: "code",
|
|
@@ -13928,9 +14225,6 @@ var init_template_scopes = __esm(() => {
|
|
|
13928
14225
|
WORD8 = /[\w$]+/g;
|
|
13929
14226
|
});
|
|
13930
14227
|
|
|
13931
|
-
// src/compiler/minor.ts
|
|
13932
|
-
var init_minor = () => {};
|
|
13933
|
-
|
|
13934
14228
|
// src/compiler/lints.ts
|
|
13935
14229
|
function isLint(code) {
|
|
13936
14230
|
return code !== undefined && Object.hasOwn(LINTS, code);
|
|
@@ -13971,7 +14265,7 @@ function applyLints(diagnostics, source, levels = {}) {
|
|
|
13971
14265
|
return [...leveled, ...unknownLints(source), ...refusedComments(allowComments(source), levels.comments)];
|
|
13972
14266
|
}
|
|
13973
14267
|
function unknownLints(source) {
|
|
13974
|
-
return allowComments(source).flatMap((comment) => comment
|
|
14268
|
+
return allowComments(source).flatMap((comment) => unknownNames(comment, source, isLint, `the lints are ${Object.keys(LINTS).map((lint) => `\`${lint}\``).join(", ")}`));
|
|
13975
14269
|
}
|
|
13976
14270
|
function templateLints(file) {
|
|
13977
14271
|
const found = [];
|
|
@@ -14087,7 +14381,6 @@ var init_lints = __esm(() => {
|
|
|
14087
14381
|
init_style_lints();
|
|
14088
14382
|
init_template_scopes();
|
|
14089
14383
|
init_deprecated_lints();
|
|
14090
|
-
init_minor();
|
|
14091
14384
|
LINTS = {
|
|
14092
14385
|
"unread-name": {
|
|
14093
14386
|
level: "deny",
|
|
@@ -14777,7 +15070,7 @@ button(onClick={() => open.set(true)}) Log`
|
|
|
14777
15070
|
site: true,
|
|
14778
15071
|
summary: "A root Dockerfile whose `FROM oven/bun:<version>` is older than the Bun kay needs (`engines.bun`), so the image fails to build once kay moves up, as `kay upgrade` does. `--fix` moves the tag to the oldest Bun kay runs on, dropping a digest pin that would keep the old image; a tag that is no full version, as `1` or `latest`, is left alone.",
|
|
14779
15072
|
wrong: "FROM oven/bun:1.0.0 AS build",
|
|
14780
|
-
right: "FROM oven/bun:1.4.
|
|
15073
|
+
right: "FROM oven/bun:1.4.5 AS build"
|
|
14781
15074
|
},
|
|
14782
15075
|
"untyped-socket": {
|
|
14783
15076
|
level: "warn",
|
|
@@ -15890,6 +16183,17 @@ var init_fence_checks = __esm(() => {
|
|
|
15890
16183
|
CAPTCHA_OFF = /\bcaptcha\s*:\s*false\b/;
|
|
15891
16184
|
});
|
|
15892
16185
|
|
|
16186
|
+
// src/compiler/handed-data.ts
|
|
16187
|
+
function handedServer(island, output, file, script, server, unread) {
|
|
16188
|
+
if (!island || output !== "html" || !server || script.unparsed !== undefined || server.unparsed !== undefined)
|
|
16189
|
+
return server;
|
|
16190
|
+
const words = new Set(templateWords(file));
|
|
16191
|
+
return { ...server, data: server.data.filter((data) => !unread.has(data.local.start) || words.has(data.name)) };
|
|
16192
|
+
}
|
|
16193
|
+
var init_handed_data = __esm(() => {
|
|
16194
|
+
init_template_reads();
|
|
16195
|
+
});
|
|
16196
|
+
|
|
15893
16197
|
// src/compiler/island-cause.ts
|
|
15894
16198
|
function describeCause(cause) {
|
|
15895
16199
|
return cause.interactive === undefined ? causeText(cause) : `${causeText(cause)}; a use that turns on none of ${staticUse(cause.interactive)} renders as markup with no script`;
|
|
@@ -17217,9 +17521,10 @@ class RewriteFinder {
|
|
|
17217
17521
|
}
|
|
17218
17522
|
}
|
|
17219
17523
|
rows(path) {
|
|
17524
|
+
const block = this.input.sites.blocks.has(path.node.params[0]?.start ?? -1);
|
|
17220
17525
|
for (const [index, param] of path.node.params.entries()) {
|
|
17221
|
-
if (param.type === "Identifier" && this.input.sites.rows.has(param.start))
|
|
17222
|
-
this.rowBinding(path.scope, param.name, index === 0 ? loopKey(path, param.name) : undefined);
|
|
17526
|
+
if (param.type === "Identifier" && (block || this.input.sites.rows.has(param.start)))
|
|
17527
|
+
this.rowBinding(path.scope, param.name, index === 0 && !block ? loopKey(path, param.name) : undefined);
|
|
17223
17528
|
}
|
|
17224
17529
|
}
|
|
17225
17530
|
rowBinding(scope, name, key) {
|
|
@@ -17488,6 +17793,108 @@ var init_server_imports = __esm(() => {
|
|
|
17488
17793
|
WORD9 = /(?<![\w$.])[a-z_$][\w$]*/gi;
|
|
17489
17794
|
});
|
|
17490
17795
|
|
|
17796
|
+
// src/compiler/signal-from-prop.ts
|
|
17797
|
+
function propRoot(node) {
|
|
17798
|
+
if (node.type === "Identifier")
|
|
17799
|
+
return node.name;
|
|
17800
|
+
return node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier" ? propRoot(node.object) : undefined;
|
|
17801
|
+
}
|
|
17802
|
+
function importedAs(node, name) {
|
|
17803
|
+
return node.type === "ImportSpecifier" && node.importKind !== "type" && node.local.name === name && (node.imported.type === "Identifier" ? node.imported.name : node.imported.value) === name;
|
|
17804
|
+
}
|
|
17805
|
+
function followedByEffects(ast) {
|
|
17806
|
+
const names = new Set;
|
|
17807
|
+
eachNode(ast, (node) => {
|
|
17808
|
+
if (node.type !== "CallExpression" || node.callee.type !== "Identifier" || node.callee.name !== "effect")
|
|
17809
|
+
return;
|
|
17810
|
+
eachNode(node, (inner) => {
|
|
17811
|
+
if (inner.type === "AssignmentExpression" && inner.left.type === "Identifier")
|
|
17812
|
+
names.add(inner.left.name);
|
|
17813
|
+
if (inner.type === "CallExpression" && inner.callee.type === "MemberExpression" && inner.callee.property.type === "Identifier" && inner.callee.property.name === "set" && inner.callee.object.type === "Identifier")
|
|
17814
|
+
names.add(inner.callee.object.name);
|
|
17815
|
+
});
|
|
17816
|
+
return false;
|
|
17817
|
+
});
|
|
17818
|
+
return names;
|
|
17819
|
+
}
|
|
17820
|
+
function writtenNames(ast) {
|
|
17821
|
+
const names = new Set;
|
|
17822
|
+
eachNode(ast, (node) => {
|
|
17823
|
+
if (node.type === "AssignmentExpression" && node.left.type === "Identifier")
|
|
17824
|
+
names.add(node.left.name);
|
|
17825
|
+
if (node.type === "UpdateExpression" && node.argument.type === "Identifier")
|
|
17826
|
+
names.add(node.argument.name);
|
|
17827
|
+
if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && (node.callee.property.name === "set" || node.callee.property.name === "update"))
|
|
17828
|
+
names.add(node.callee.object.name);
|
|
17829
|
+
});
|
|
17830
|
+
return names;
|
|
17831
|
+
}
|
|
17832
|
+
function signalFromProps(fence, props, writtenInTemplate) {
|
|
17833
|
+
if (!props || !fence.code.includes("signal"))
|
|
17834
|
+
return [];
|
|
17835
|
+
const watched = new Set(props.bindings.filter((binding) => !INITIAL_PROP.test(binding.key)).map((binding) => fence.code.slice(binding.local.start - fence.offset, binding.local.end - fence.offset)));
|
|
17836
|
+
const declaration = fence.ast.body.find((node) => node.type === "ImportDeclaration" && node.source.value === KAY && node.importKind !== "type");
|
|
17837
|
+
const specifier = declaration?.type === "ImportDeclaration" ? declaration.specifiers.find((node) => importedAs(node, "signal")) : undefined;
|
|
17838
|
+
if (watched.size === 0 || specifier?.type !== "ImportSpecifier")
|
|
17839
|
+
return [];
|
|
17840
|
+
const linked = declaration?.type === "ImportDeclaration" && declaration.specifiers.some((node) => importedAs(node, "linked"));
|
|
17841
|
+
let others = 0;
|
|
17842
|
+
let taken = false;
|
|
17843
|
+
const seeds = [];
|
|
17844
|
+
eachNode(fence.ast, (node) => {
|
|
17845
|
+
if (node.type === "ImportDeclaration" || node.type === "VariableDeclaration" && fence.shift(node).start === props.statement.start)
|
|
17846
|
+
return false;
|
|
17847
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
|
|
17848
|
+
for (const param of node.params) {
|
|
17849
|
+
for (const name of patternNames(param))
|
|
17850
|
+
watched.delete(name);
|
|
17851
|
+
}
|
|
17852
|
+
}
|
|
17853
|
+
if (node.type === "VariableDeclarator") {
|
|
17854
|
+
for (const name of patternNames(node.id)) {
|
|
17855
|
+
watched.delete(name);
|
|
17856
|
+
taken ||= name === "linked";
|
|
17857
|
+
}
|
|
17858
|
+
const { init } = node;
|
|
17859
|
+
if (init?.type === "CallExpression" && init.callee.type === "Identifier" && init.callee.name === "signal" && init.arguments.length === 1 && init.arguments[0].type !== "SpreadElement")
|
|
17860
|
+
seeds.push({ call: init, name: node.id.type === "Identifier" ? node.id.name : undefined });
|
|
17861
|
+
}
|
|
17862
|
+
if (node.type === "Identifier" && node.name === "signal")
|
|
17863
|
+
others++;
|
|
17864
|
+
return true;
|
|
17865
|
+
});
|
|
17866
|
+
const diagnostics = [];
|
|
17867
|
+
const followed = followedByEffects(fence.ast);
|
|
17868
|
+
const written = writtenNames(fence.ast);
|
|
17869
|
+
const found = seeds.filter(({ call, name }) => {
|
|
17870
|
+
const root = call.typeArguments || name !== undefined && (followed.has(name) || written.has(name) || writtenInTemplate.has(name)) ? undefined : propRoot(call.arguments[0]);
|
|
17871
|
+
return root !== undefined && watched.has(root);
|
|
17872
|
+
});
|
|
17873
|
+
for (const { call } of found) {
|
|
17874
|
+
const seed = call.arguments[0];
|
|
17875
|
+
const root = propRoot(seed);
|
|
17876
|
+
const text = fence.code.slice(seed.start, seed.end);
|
|
17877
|
+
const imports = linked || taken ? [] : [{ ...fence.shift(specifier), text: others > found.length ? "linked, signal" : "linked" }];
|
|
17878
|
+
const fix = { title: `Write \`linked(() => ${text})\``, safe: !taken, edits: [{ ...fence.shift(call), text: `linked(() => ${text})` }, ...imports] };
|
|
17879
|
+
diagnostics.push({
|
|
17880
|
+
...fence.shift(call),
|
|
17881
|
+
code: "signal-from-prop",
|
|
17882
|
+
message: `\`signal(${text})\` keeps the first value of \`${root}\`, as a signal made from a prop does not follow it`,
|
|
17883
|
+
note: "the island stays when the page gives it new props, as after an action or a refresh, so a seed read once shows the old value",
|
|
17884
|
+
help: `write \`linked(() => ${text})\`, which follows the prop and can still be written, or \`// kay-allow signal-from-prop\` when the first value is meant`,
|
|
17885
|
+
checkOnly: true,
|
|
17886
|
+
fixes: taken ? [] : [fix]
|
|
17887
|
+
});
|
|
17888
|
+
}
|
|
17889
|
+
return diagnostics;
|
|
17890
|
+
}
|
|
17891
|
+
var KAY = "kay";
|
|
17892
|
+
var init_signal_from_prop = __esm(() => {
|
|
17893
|
+
init_each_node();
|
|
17894
|
+
init_live_reads();
|
|
17895
|
+
init_pattern_names();
|
|
17896
|
+
});
|
|
17897
|
+
|
|
17491
17898
|
// src/compiler/twin.ts
|
|
17492
17899
|
var ISLAND_TWIN = "?island";
|
|
17493
17900
|
|
|
@@ -17681,7 +18088,7 @@ function compileKay(original, filename, options = {}) {
|
|
|
17681
18088
|
const fences = [file.script, file.server, file.module].map((span) => span ? source.slice(span.start, span.end) : "").join(`
|
|
17682
18089
|
`);
|
|
17683
18090
|
const name = freeName(componentName(filename), fences, found.findings.globalReads);
|
|
17684
|
-
const final = generate(file, script, server, { ...generateOptions, name, rewrites: found.plan.rewrites, writes: found.plan.writes, values: found.plan.values });
|
|
18091
|
+
const final = generate(file, script, handedServer(island !== undefined, options.output, file, script, server, found.findings.unread), { ...generateOptions, name, rewrites: found.plan.rewrites, writes: found.plan.writes, values: found.plan.values });
|
|
17685
18092
|
const unparsed = script.unparsed !== undefined || server?.unparsed !== undefined;
|
|
17686
18093
|
const diagnostics = [
|
|
17687
18094
|
...coded(file.diagnostics, "template-syntax"),
|
|
@@ -17708,7 +18115,7 @@ function compileKay(original, filename, options = {}) {
|
|
|
17708
18115
|
const fenceLints = [script.fence, script.moduleFence, server?.fence].flatMap((fence) => fence ? [...cssImportsWithoutText(fence), ...asyncReplies(fence), ...openRedirects(fence), ...missingCaptchas(fence)] : []);
|
|
17709
18116
|
const browserScript = (island !== undefined || options.insideIsland === true) && !routeFile ? scriptFences(script) : [];
|
|
17710
18117
|
const unusedLints = broken ? [] : [...unreadNames(source, file.template, script, server, found.findings), ...constantSignals(source, [file.script, file.module], found.findings)];
|
|
17711
|
-
diagnostics.push(...unboundedFields(server), ...fenceLints, ...serialAwaits(server), ...browserScript.flatMap((fence) => serverOnlyImports(fence)), ...browserScript.includes(script.fence) ? onceReadProps(script.fence, script.props, templateWords(file)) : [], ...unusedLints, ...templateLints(file), ...linkFlags(file));
|
|
18118
|
+
diagnostics.push(...unboundedFields(server), ...fenceLints, ...serialAwaits(server), ...browserScript.flatMap((fence) => serverOnlyImports(fence)), ...browserScript.includes(script.fence) ? [...onceReadProps(script.fence, script.props, templateWords(file)), ...signalFromProps(script.fence, script.props, templateWrites(file))] : [], ...unusedLints, ...templateLints(file), ...linkFlags(file));
|
|
17712
18119
|
}
|
|
17713
18120
|
if (checked && pin !== undefined)
|
|
17714
18121
|
diagnostics.push(...markerMismatch(pin, pageFile));
|
|
@@ -17770,6 +18177,7 @@ function takeBlock(file, filename, options, script, scope, which = "fallback") {
|
|
|
17770
18177
|
if (block?.kind !== "slot")
|
|
17771
18178
|
return;
|
|
17772
18179
|
file.template.splice(index, 1);
|
|
18180
|
+
file.facts = undefined;
|
|
17773
18181
|
let lineStart = block.start;
|
|
17774
18182
|
const written = file.source.slice(block.start, block.end).split(`
|
|
17775
18183
|
`).map((text) => {
|
|
@@ -17900,6 +18308,7 @@ var init_compiler = __esm(() => {
|
|
|
17900
18308
|
init_codegen();
|
|
17901
18309
|
init_fence_checks();
|
|
17902
18310
|
init_fence_redirects();
|
|
18311
|
+
init_handed_data();
|
|
17903
18312
|
init_host();
|
|
17904
18313
|
init_island_arguments();
|
|
17905
18314
|
init_island_cause();
|
|
@@ -17917,6 +18326,7 @@ var init_compiler = __esm(() => {
|
|
|
17917
18326
|
init_script();
|
|
17918
18327
|
init_serial_awaits();
|
|
17919
18328
|
init_server_imports();
|
|
18329
|
+
init_signal_from_prop();
|
|
17920
18330
|
init_status_pages();
|
|
17921
18331
|
init_template_reads();
|
|
17922
18332
|
init_unowned_effects();
|
|
@@ -18467,7 +18877,10 @@ var init_config_shape = __esm(() => {
|
|
|
18467
18877
|
seo: bag(SEO),
|
|
18468
18878
|
robots: either(bool, bag(ROBOTS)),
|
|
18469
18879
|
sitemap: either(bool, bag(SITEMAP)),
|
|
18470
|
-
head: list(obj)
|
|
18880
|
+
head: list(bag({ tag: str, props: obj }, (entry, path, out) => {
|
|
18881
|
+
if ("children" in entry)
|
|
18882
|
+
out.push(`\`${path}.children\` is ignored: a tag's text goes in \`props.children\``);
|
|
18883
|
+
})),
|
|
18471
18884
|
budget: bag(BUDGET),
|
|
18472
18885
|
entry: str,
|
|
18473
18886
|
security: either(bool, bag(SECURITY_KEYS)),
|