@krate/runtime 0.5.0-rc.2 → 0.5.0-rc.4

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.
Files changed (155) hide show
  1. package/dist/actions.d.ts +7 -0
  2. package/dist/actions.js +21 -3
  3. package/dist/actions.test.js +8 -410
  4. package/dist/after.d.ts +28 -0
  5. package/dist/after.js +48 -0
  6. package/dist/after.test.js +58 -0
  7. package/dist/assets-static.d.ts +10 -1
  8. package/dist/assets-static.js +10 -2
  9. package/dist/base-path.js +4 -3
  10. package/dist/builtin-tags.d.ts +12 -0
  11. package/dist/builtin-tags.js +42 -0
  12. package/dist/builtin-tags.test.js +12 -0
  13. package/dist/cache-adapter.test.js +4 -203
  14. package/dist/cache-scope.d.ts +2 -0
  15. package/dist/cache.test.js +1 -197
  16. package/dist/cloudflare-workers.d.ts +2 -0
  17. package/dist/cloudflare-workers.js +27 -0
  18. package/dist/dev-overlay.d.ts +54 -3
  19. package/dist/dev-overlay.js +469 -76
  20. package/dist/dom.js +3 -1
  21. package/dist/events.test.js +2 -407
  22. package/dist/handler-html.test.js +1 -202
  23. package/dist/handler-routing.js +3 -0
  24. package/dist/handler-segments.d.ts +6 -0
  25. package/dist/handler-segments.js +16 -2
  26. package/dist/handler-segments.test.js +8 -200
  27. package/dist/head-tags.d.ts +9 -0
  28. package/dist/head-tags.js +85 -1
  29. package/dist/head-tags.test.js +18 -125
  30. package/dist/index.d.ts +1 -5
  31. package/dist/index.js +3 -0
  32. package/dist/inline-action-token.test.js +31 -0
  33. package/dist/jsx-svg-types.test.js +58 -0
  34. package/dist/jsx-types.d.ts +92 -1
  35. package/dist/krate-core.js +1 -1
  36. package/dist/krate-dev.js +384 -65
  37. package/dist/krate-f-actions.js +1 -1
  38. package/dist/krate-f-navigation.js +1 -1
  39. package/dist/krate-f-router-lite.js +1 -1
  40. package/dist/krate-f-router.js +1 -1
  41. package/dist/krate-features.json +2 -0
  42. package/dist/krate-hydrate-lite.js +5 -5
  43. package/dist/krate-hydrate.js +5 -5
  44. package/dist/krate-runtime.js +5 -5
  45. package/dist/link-base-path.test.js +28 -0
  46. package/dist/node-server.test.js +1 -355
  47. package/dist/platform.d.ts +52 -0
  48. package/dist/platform.js +57 -0
  49. package/dist/platform.test.js +44 -0
  50. package/dist/router-nav.test.js +15 -444
  51. package/dist/router.js +39 -1
  52. package/dist/server-handler.d.ts +48 -0
  53. package/dist/server-handler.js +279 -17
  54. package/dist/server-handler.test.js +54 -388
  55. package/dist/server-renderer.test.js +0 -104
  56. package/dist/server.d.ts +15 -5
  57. package/dist/server.js +149 -22
  58. package/dist/server.test.js +52 -60
  59. package/dist/site-config.d.ts +13 -0
  60. package/dist/site-config.js +28 -0
  61. package/dist/site-config.test.js +30 -0
  62. package/dist/slot.d.ts +12 -0
  63. package/dist/slot.js +23 -0
  64. package/dist/slot.test.js +25 -0
  65. package/dist/ssr-core-behavior.test.js +3 -515
  66. package/dist/testing.d.ts +59 -0
  67. package/dist/testing.js +88 -0
  68. package/dist/testing.test.js +73 -0
  69. package/package.json +9 -1
  70. package/dist/action-context.test.js +0 -72
  71. package/dist/base-path.test.js +0 -88
  72. package/dist/class-component.test.js +0 -462
  73. package/dist/class-helpers.test.js +0 -169
  74. package/dist/context.test.js +0 -57
  75. package/dist/derived.test.js +0 -140
  76. package/dist/dev-overlay.test.js +0 -165
  77. package/dist/discrete.test.js +0 -100
  78. package/dist/dom.test.js +0 -39
  79. package/dist/effect-errors.test.d.ts +0 -1
  80. package/dist/effect-errors.test.js +0 -199
  81. package/dist/effects.test.d.ts +0 -1
  82. package/dist/effects.test.js +0 -485
  83. package/dist/handler-routing.test.d.ts +0 -1
  84. package/dist/handler-routing.test.js +0 -99
  85. package/dist/highlight-bind.test.d.ts +0 -1
  86. package/dist/highlight-bind.test.js +0 -124
  87. package/dist/highlight.test.d.ts +0 -1
  88. package/dist/highlight.test.js +0 -56
  89. package/dist/lanes.test.d.ts +0 -1
  90. package/dist/lanes.test.js +0 -59
  91. package/dist/list.test.d.ts +0 -1
  92. package/dist/list.test.js +0 -435
  93. package/dist/metadata.test.d.ts +0 -1
  94. package/dist/metadata.test.js +0 -167
  95. package/dist/navigation.test.d.ts +0 -1
  96. package/dist/navigation.test.js +0 -130
  97. package/dist/optimistic-lanes.test.d.ts +0 -1
  98. package/dist/optimistic-lanes.test.js +0 -45
  99. package/dist/patterns.test.d.ts +0 -1
  100. package/dist/patterns.test.js +0 -125
  101. package/dist/portal.test.d.ts +0 -1
  102. package/dist/portal.test.js +0 -99
  103. package/dist/react-effects.test.d.ts +0 -1
  104. package/dist/react-effects.test.js +0 -133
  105. package/dist/react-suspense.test.d.ts +0 -1
  106. package/dist/react-suspense.test.js +0 -194
  107. package/dist/react.test.d.ts +0 -1
  108. package/dist/react.test.js +0 -60
  109. package/dist/react19.test.d.ts +0 -1
  110. package/dist/react19.test.js +0 -176
  111. package/dist/reactivity-core.test.d.ts +0 -1
  112. package/dist/reactivity-core.test.js +0 -152
  113. package/dist/reconcile.test.d.ts +0 -1
  114. package/dist/reconcile.test.js +0 -110
  115. package/dist/refs.test.d.ts +0 -1
  116. package/dist/refs.test.js +0 -257
  117. package/dist/router-layout.test.d.ts +0 -1
  118. package/dist/router-layout.test.js +0 -249
  119. package/dist/router-slots.test.d.ts +0 -1
  120. package/dist/router-slots.test.js +0 -144
  121. package/dist/router-speculation.test.d.ts +0 -1
  122. package/dist/router-speculation.test.js +0 -25
  123. package/dist/router-styles.test.d.ts +0 -1
  124. package/dist/router-styles.test.js +0 -98
  125. package/dist/router.test.d.ts +0 -1
  126. package/dist/router.test.js +0 -36
  127. package/dist/server-async.test.d.ts +0 -1
  128. package/dist/server-async.test.js +0 -216
  129. package/dist/server-highlight.test.d.ts +0 -1
  130. package/dist/server-highlight.test.js +0 -32
  131. package/dist/signal-lanes.test.d.ts +0 -1
  132. package/dist/signal-lanes.test.js +0 -32
  133. package/dist/slots.test.d.ts +0 -1
  134. package/dist/slots.test.js +0 -187
  135. package/dist/snapshots.test.d.ts +0 -1
  136. package/dist/snapshots.test.js +0 -208
  137. package/dist/ssr-core.test.d.ts +0 -1
  138. package/dist/ssr-core.test.js +0 -324
  139. package/dist/static-memory.test.d.ts +0 -1
  140. package/dist/static-memory.test.js +0 -26
  141. package/dist/storage.test.d.ts +0 -1
  142. package/dist/storage.test.js +0 -46
  143. package/dist/suspense-actions.test.d.ts +0 -1
  144. package/dist/suspense-actions.test.js +0 -72
  145. package/dist/suspense.test.d.ts +0 -1
  146. package/dist/suspense.test.js +0 -556
  147. /package/dist/{action-context.test.d.ts → after.test.d.ts} +0 -0
  148. /package/dist/{base-path.test.d.ts → builtin-tags.test.d.ts} +0 -0
  149. /package/dist/{class-component.test.d.ts → inline-action-token.test.d.ts} +0 -0
  150. /package/dist/{class-helpers.test.d.ts → jsx-svg-types.test.d.ts} +0 -0
  151. /package/dist/{context.test.d.ts → link-base-path.test.d.ts} +0 -0
  152. /package/dist/{derived.test.d.ts → platform.test.d.ts} +0 -0
  153. /package/dist/{dev-overlay.test.d.ts → site-config.test.d.ts} +0 -0
  154. /package/dist/{discrete.test.d.ts → slot.test.d.ts} +0 -0
  155. /package/dist/{dom.test.d.ts → testing.test.d.ts} +0 -0
@@ -1,131 +1,24 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { Head, renderToStringAsync, jsx } from "./server.js";
3
- import { mergeHead, parseHeadTags, takeHead } from "./head-tags.js";
4
- // The merge cases below are mirrored in internal/build/headmerge_test.go: the
5
- // Go host and this handler must produce the same document head.
6
- const MERGE_CASES = [
7
- {
8
- name: "adds tags before </head>, title when the shell has none",
9
- doc: "<html><head><meta charset=UTF-8></head><body>x</body></html>",
10
- title: "Post",
11
- head: '<meta name="description" content="d"><link rel="canonical" href="https://e.com/a">',
12
- want: "<html><head><meta charset=UTF-8><title>Post</title>" +
13
- '<meta name="description" content="d"><link rel="canonical" href="https://e.com/a"></head><body>x</body></html>',
14
- },
15
- {
16
- name: "page wins over baked tags with the same name, property and canonical (minified shell)",
17
- doc: "<head><meta name=description content=\"layout\"/><meta property=og:title content=Site /><meta property=og:site_name content=Site />" +
18
- "<link rel=canonical href=https://e.com/layout /><title>Baked</title></head>",
19
- title: "Fresh",
20
- head: '<meta name="description" content="page"><meta property="og:title" content="Page">' +
21
- '<link rel="canonical" href="https://e.com/page">',
22
- want: "<head><meta property=og:site_name content=Site /><title>Fresh</title>" +
23
- '<meta name="description" content="page"><meta property="og:title" content="Page">' +
24
- '<link rel="canonical" href="https://e.com/page"></head>',
25
- },
26
- {
27
- name: "repeated property keeps every tag, repeated name keeps the last",
28
- doc: "<head></head>",
29
- title: "",
30
- head: '<meta property="og:image" content="a"><meta property="og:image" content="b">' +
31
- '<meta name="robots" content="index"><meta name="robots" content="noindex">',
32
- want: '<head><meta property="og:image" content="a"><meta property="og:image" content="b"><meta name="robots" content="noindex"></head>',
33
- },
34
- {
35
- name: "identical tags are not added twice, scripts and links are appended",
36
- doc: '<head><link rel=stylesheet href=/a.css><script type=application/ld+json>{"a":1}</script></head>',
37
- title: "",
38
- head: '<link rel="stylesheet" href="/a.css"><link rel="stylesheet" href="/b.css">' +
39
- '<script type="application/ld+json">{"a":1}</script><script type="application/ld+json">{"b":2}</script>',
40
- want: '<head><link rel=stylesheet href=/a.css><script type=application/ld+json>{"a":1}</script>' +
41
- '<link rel="stylesheet" href="/b.css"><script type="application/ld+json">{"b":2}</script></head>',
42
- },
43
- {
44
- name: "a meta inside a baked script is not a tag, other elements are dropped",
45
- doc: '<head><script>var s="<meta name=description content=x>";</script></head>',
46
- title: "",
47
- head: '<meta name="description" content="p"><div>no</div><p>no</p>',
48
- want: '<head><script>var s="<meta name=description content=x>";</script><meta name="description" content="p"></head>',
49
- },
50
- {
51
- name: "escaped attribute values pass through",
52
- doc: "<head></head>",
53
- title: "A &amp; B",
54
- head: '<meta name="description" content="About &lt;&quot;x&quot;&gt; &amp; more">',
55
- want: '<head><title>A &amp; B</title><meta name="description" content="About &lt;&quot;x&quot;&gt; &amp; more"></head>',
56
- },
57
- {
58
- name: "no head tags and no title leaves the document alone",
59
- doc: "<head><title>Baked</title></head>",
60
- title: "",
61
- head: "",
62
- want: "<head><title>Baked</title></head>",
63
- },
64
- {
65
- name: "title only replaces the baked one",
66
- doc: "<head><title>Baked</title><meta name=description content=keep></head>",
67
- title: "New",
68
- head: "",
69
- want: "<head><title>New</title><meta name=description content=keep></head>",
70
- },
71
- ];
72
- describe("takeHead", () => {
73
- it("lifts the title and the Head content out of the body, in place order", () => {
74
- const html = '<main><!--krate-head--><title>T</title><meta name="description" content="d"><!--/krate-head--><h1>x</h1>' +
75
- '<!--krate-head--><link rel="canonical" href="/c"><!--/krate-head--></main>';
76
- const out = takeHead(html);
77
- expect(out.title).toBe("T");
78
- expect(out.head).toBe('<meta name="description" content="d"><link rel="canonical" href="/c">');
79
- expect(out.html).toBe("<main><h1>x</h1></main>");
2
+ import { HEAD_CLOSE, HEAD_OPEN, mergeHead, setStartTagAttrs, splitDocTags, takeHead } from "./head-tags.js";
3
+ const DOC = '<!DOCTYPE html><html lang="en"><head><title>Base</title></head><body class="base"><div id="root">x</div></body></html>';
4
+ describe("document attributes from <Head>", () => {
5
+ it("splits <html> and <body> out of a head fragment, later elements winning", () => {
6
+ const { rest, html, body } = splitDocTags('<meta name="a" content="b"><html lang="fr" class="a"></html><html class="b"></html><body data-x="1"></body>');
7
+ expect(rest).toBe('<meta name="a" content="b">');
8
+ expect(Object.fromEntries(html)).toEqual({ lang: "fr", class: "b" });
9
+ expect(Object.fromEntries(body)).toEqual({ "data-x": "1" });
80
10
  });
81
- it("keeps a body <meta itemprop> that is not inside <Head>", () => {
82
- const html = '<div itemscope><meta itemprop="name" content="n"><span>x</span></div>';
83
- expect(takeHead(html)).toEqual({ title: "", head: "", html });
11
+ it("sets attributes on the document elements and escapes values", () => {
12
+ const out = mergeHead(DOC, "", '<html class="dark" data-q="a&quot;b"></html><body class="font-sans"></body>');
13
+ expect(out).toContain('<html class="dark" data-q="a&quot;b" lang="en">');
14
+ expect(out).toContain('<body class="font-sans">');
15
+ expect(out).not.toContain("</html></html>");
84
16
  });
85
- it("flattens nested Head blocks and keeps an svg title", () => {
86
- const html = '<!--krate-head--><meta name="a" content="1"><!--krate-head--><meta name="b" content="2"><!--/krate-head--><!--/krate-head-->' +
87
- "<svg><title>icon</title></svg>";
88
- const out = takeHead(html);
89
- expect(out.head).toBe('<meta name="a" content="1"><meta name="b" content="2">');
90
- expect(out.html).toBe("<svg><title>icon</title></svg>");
91
- expect(out.title).toBe("");
17
+ it("keeps the other attributes of a start tag", () => {
18
+ expect(setStartTagAttrs('<body a="1" b="2">', "body", new Map([["b", "3"]]))).toBe('<body a="1" b="3">');
92
19
  });
93
- it("an unterminated Head block does not swallow the page", () => {
94
- const out = takeHead('<p>a</p><!--krate-head--><meta name="x" content="y">');
95
- expect(out.html).toBe("<p>a</p>");
96
- expect(out.head).toBe('<meta name="x" content="y">');
97
- });
98
- });
99
- describe("mergeHead", () => {
100
- for (const c of MERGE_CASES) {
101
- it(c.name, () => {
102
- expect(mergeHead(c.doc, c.title, c.head)).toBe(c.want);
103
- });
104
- }
105
- it("does nothing to a document without a head section", () => {
106
- expect(mergeHead("<p>x</p>", "T", '<meta name="a" content="b">')).toBe("<p>x</p>");
107
- });
108
- });
109
- describe("parseHeadTags", () => {
110
- it("reads unquoted, quoted and valueless attributes", () => {
111
- const tags = parseHeadTags("<script async src=/x.js></script><link rel='canonical' href=\"/c\"/>");
112
- expect(tags.map((t) => t.el.name)).toEqual(["script", "link"]);
113
- expect(tags[0].el.attrs.get("src")).toBe("/x.js");
114
- expect(tags[0].el.attrs.has("async")).toBe(true);
115
- expect(tags[1].key).toBe("link:canonical");
116
- });
117
- });
118
- describe("<Head> in a request-time render", () => {
119
- it("renders its children between markers and script text raw", async () => {
120
- const html = await renderToStringAsync(jsx(Head, {
121
- children: [
122
- jsx("meta", { name: "description", content: 'a "b" <c>' }),
123
- jsx("script", { type: "application/ld+json", children: JSON.stringify({ n: "</script><b>" }) }),
124
- ],
125
- }));
126
- const out = takeHead(html);
127
- expect(out.html).toBe("");
128
- expect(out.head).toContain('<meta name="description" content="a &quot;b&quot; &lt;c&gt;">');
129
- expect(out.head).toContain('<script type="application/ld+json">{"n":"<\\/script><b>"}</script>');
20
+ it("flows from a request-time <Head> through takeHead", () => {
21
+ const split = takeHead("<main>" + HEAD_OPEN + '<html class="dark"></html><title>T</title>' + HEAD_CLOSE + "</main>");
22
+ expect(mergeHead(DOC, split.title, split.head)).toContain('<html class="dark" lang="en">');
130
23
  });
131
24
  });
package/dist/index.d.ts CHANGED
@@ -29,9 +29,5 @@ export type { ResourceReturn, ResourceActions } from './resource.js';
29
29
  export type { Component, PropsWithChildren, ComponentProps, RefCallback } from './dom.js';
30
30
  export type { RefObject, Ref, UseRefResult } from './signal.js';
31
31
  import './jsx-types.js';
32
- export declare const Link: typeof globalThis.Link;
33
- export declare const Head: typeof globalThis.Head;
34
- export declare const Icon: typeof globalThis.Icon;
35
- export declare const Suspense: typeof globalThis.Suspense;
36
- export declare const SyntaxHighlight: typeof globalThis.SyntaxHighlight;
32
+ export { Link, Head, Icon, Image, Script, Style, Suspense, SyntaxHighlight } from './builtin-tags.js';
37
33
  import './css-modules.js';
package/dist/index.js CHANGED
@@ -16,4 +16,7 @@ export { createContext, createScope, createScopeFlags, resetContexts } from './c
16
16
  export { createResource } from './resource.js';
17
17
  export { requestFormReset, getFormStatus, isServerAction, ServerActionError } from './actions.js';
18
18
  import './jsx-types.js';
19
+ // The compiler provides these tags as globals. The values here make
20
+ // `import { Head } from "@krate/runtime"` a real export; see builtin-tags.ts.
21
+ export { Link, Head, Icon, Image, Script, Style, Suspense, SyntaxHighlight } from './builtin-tags.js';
19
22
  import './css-modules.js';
@@ -0,0 +1,31 @@
1
+ import { createCipheriv, createHash, randomBytes } from 'node:crypto';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { openInlineToken } from './server-handler.js';
4
+ // The server renderer seals closed-over values of an inline server action
5
+ // like this (see compiler/internal/build/inline_actions.go).
6
+ function seal(id, values, secret) {
7
+ const key = createHash('sha256').update('krate-inline-action\0' + secret).digest();
8
+ const iv = randomBytes(12);
9
+ const cipher = createCipheriv('aes-256-gcm', key, iv);
10
+ cipher.setAAD(Buffer.from(id));
11
+ const body = Buffer.concat([cipher.update(JSON.stringify(values), 'utf8'), cipher.final()]);
12
+ return 'k1.' + Buffer.concat([iv, body, cipher.getAuthTag()]).toString('base64url');
13
+ }
14
+ const entry = { id: 'a1', export: 'inline_0', file: 'x.mjs', inline: true, captures: ['id', 'when', 'gone'] };
15
+ describe('inline server action closure tokens', () => {
16
+ it('opens a token sealed by the server renderer and restores special values', async () => {
17
+ const token = seal('a1', ['p1', { $: 'd', v: '1970-01-01T00:00:00.000Z' }, { $: 'u' }], 'secret-secret-secret');
18
+ const out = await openInlineToken(token, entry, 'secret-secret-secret');
19
+ expect(out[0]).toBe('p1');
20
+ expect(out[1]).toEqual(new Date(0));
21
+ expect(out[2]).toBeUndefined();
22
+ });
23
+ it('rejects a token for another action, another key, or tampered bytes', async () => {
24
+ const token = seal('a1', ['p1', 1, 2], 'secret-secret-secret');
25
+ await expect(openInlineToken(token, { ...entry, id: 'a2' }, 'secret-secret-secret')).rejects.toThrow();
26
+ await expect(openInlineToken(token, entry, 'another-secret-value')).rejects.toThrow();
27
+ const flipped = token.slice(0, -4) + (token.endsWith('AAAA') ? 'BBBB' : 'AAAA');
28
+ await expect(openInlineToken(flipped, entry, 'secret-secret-secret')).rejects.toThrow();
29
+ await expect(openInlineToken(null, entry, 'secret-secret-secret')).rejects.toThrow();
30
+ });
31
+ });
@@ -0,0 +1,58 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import ts from 'typescript';
3
+ import { resolve } from 'node:path';
4
+ const typesFile = resolve(__dirname, 'jsx-types.ts');
5
+ const virtual = resolve(__dirname, '__svg_fixture__.tsx');
6
+ function check(source) {
7
+ const options = {
8
+ strict: true,
9
+ noEmit: true,
10
+ skipLibCheck: true,
11
+ jsx: ts.JsxEmit.Preserve,
12
+ target: ts.ScriptTarget.ES2020,
13
+ module: ts.ModuleKind.ESNext,
14
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
15
+ types: [],
16
+ };
17
+ const host = ts.createCompilerHost(options);
18
+ const readFile = host.readFile.bind(host);
19
+ const fileExists = host.fileExists.bind(host);
20
+ const getSourceFile = host.getSourceFile.bind(host);
21
+ host.fileExists = (f) => f === virtual || fileExists(f);
22
+ host.readFile = (f) => (f === virtual ? source : readFile(f));
23
+ host.getSourceFile = (f, lang, onError, shouldCreate) => f === virtual ? ts.createSourceFile(f, source, lang) : getSourceFile(f, lang, onError, shouldCreate);
24
+ const program = ts.createProgram([typesFile, virtual], options, host);
25
+ return ts
26
+ .getPreEmitDiagnostics(program)
27
+ .filter((d) => d.file?.fileName === virtual)
28
+ .map((d) => ts.flattenDiagnosticMessageText(d.messageText, '\n'));
29
+ }
30
+ describe('SVG JSX types', () => {
31
+ it('accepts a pasted Figma/Illustrator export', () => {
32
+ const errors = check(`
33
+ export const Pasted = () => (
34
+ <svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
35
+ xmlSpace="preserve" xml:space="preserve" version="1.1" width="24" height="24" viewBox="0 0 24 24" fill="none" onClick={() => {}}>
36
+ <defs>
37
+ <linearGradient id="g" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="1" y2="1">
38
+ <stop offset="0" stopColor="#000" />
39
+ </linearGradient>
40
+ <clipPath id="c"><rect width="24" height="24" /></clipPath>
41
+ <filter id="f"><feColorMatrix type="matrix" values="1 0 0 0 0" /><feGaussianBlur stdDeviation="2" /></filter>
42
+ </defs>
43
+ <g clipPath="url(#c)" filter="url(#f)">
44
+ <use xlinkHref="#g" xlink:href="#g" />
45
+ <ellipse cx="1" cy="1" rx="1" ry="1" />
46
+ <text x="0" y="0"><tspan>hi</tspan></text>
47
+ <path fillRule="evenodd" clipRule="evenodd" d="M0 0h24v24H0z" strokeLinecap="round" />
48
+ </g>
49
+ </svg>
50
+ );
51
+ `);
52
+ expect(errors).toEqual([]);
53
+ });
54
+ it('still rejects unknown SVG attributes', () => {
55
+ const errors = check(`export const Bad = () => <svg notAnAttribute="x" />;`);
56
+ expect(errors.length).toBeGreaterThan(0);
57
+ });
58
+ });
@@ -679,7 +679,7 @@ declare global {
679
679
  width?: number | string;
680
680
  disablePictureInPicture?: boolean;
681
681
  }
682
- interface SVGAttributes extends AriaAttributes, IntrinsicAttributes {
682
+ interface SVGAttributes extends AriaAttributes, ClipboardEventHandler, CompositionEventHandler, FocusEventHandler, FormEventHandler, KeyboardEventHandler, MouseEventHandler, PointerEventHandler, TouchEventHandler, WheelEventHandler, AnimationEventHandler, TransitionEventHandler, UIEventHandler, MediaEventHandler, DOMAttributes {
683
683
  children?: unknown[] | unknown;
684
684
  key?: string | number;
685
685
  ref?: ((el: globalThis.Element) => void) | {
@@ -930,6 +930,40 @@ declare global {
930
930
  yChannelSelector?: string;
931
931
  z?: number | string;
932
932
  zoomAndPan?: string;
933
+ xmlns?: string;
934
+ xmlnsXlink?: string;
935
+ 'xmlns:xlink'?: string;
936
+ xmlSpace?: 'default' | 'preserve';
937
+ 'xml:space'?: 'default' | 'preserve';
938
+ xmlLang?: string;
939
+ 'xml:lang'?: string;
940
+ xmlBase?: string;
941
+ 'xml:base'?: string;
942
+ xlinkHref?: string;
943
+ 'xlink:href'?: string;
944
+ xlinkTitle?: string;
945
+ 'xlink:title'?: string;
946
+ xlinkActuate?: string;
947
+ 'xlink:actuate'?: string;
948
+ xlinkArcrole?: string;
949
+ 'xlink:arcrole'?: string;
950
+ xlinkRole?: string;
951
+ 'xlink:role'?: string;
952
+ xlinkShow?: string;
953
+ 'xlink:show'?: string;
954
+ xlinkType?: string;
955
+ 'xlink:type'?: string;
956
+ type?: string;
957
+ target?: string;
958
+ crossOrigin?: 'anonymous' | 'use-credentials' | '';
959
+ mixBlendMode?: string;
960
+ isolation?: string;
961
+ transformOrigin?: string;
962
+ transformBox?: string;
963
+ color?: string;
964
+ dangerouslySetInnerHTML?: {
965
+ __html: string;
966
+ };
933
967
  }
934
968
  interface IntrinsicElements {
935
969
  a: AnchorHTMLAttributes;
@@ -1051,6 +1085,57 @@ declare global {
1051
1085
  circle: SVGAttributes;
1052
1086
  rect: SVGAttributes;
1053
1087
  g: SVGAttributes;
1088
+ animate: SVGAttributes;
1089
+ animateMotion: SVGAttributes;
1090
+ animateTransform: SVGAttributes;
1091
+ clipPath: SVGAttributes;
1092
+ defs: SVGAttributes;
1093
+ desc: SVGAttributes;
1094
+ ellipse: SVGAttributes;
1095
+ feBlend: SVGAttributes;
1096
+ feColorMatrix: SVGAttributes;
1097
+ feComponentTransfer: SVGAttributes;
1098
+ feComposite: SVGAttributes;
1099
+ feConvolveMatrix: SVGAttributes;
1100
+ feDiffuseLighting: SVGAttributes;
1101
+ feDisplacementMap: SVGAttributes;
1102
+ feDistantLight: SVGAttributes;
1103
+ feDropShadow: SVGAttributes;
1104
+ feFlood: SVGAttributes;
1105
+ feFuncA: SVGAttributes;
1106
+ feFuncB: SVGAttributes;
1107
+ feFuncG: SVGAttributes;
1108
+ feFuncR: SVGAttributes;
1109
+ feGaussianBlur: SVGAttributes;
1110
+ feImage: SVGAttributes;
1111
+ feMerge: SVGAttributes;
1112
+ feMergeNode: SVGAttributes;
1113
+ feMorphology: SVGAttributes;
1114
+ feOffset: SVGAttributes;
1115
+ fePointLight: SVGAttributes;
1116
+ feSpecularLighting: SVGAttributes;
1117
+ feSpotLight: SVGAttributes;
1118
+ feTile: SVGAttributes;
1119
+ feTurbulence: SVGAttributes;
1120
+ filter: SVGAttributes;
1121
+ foreignObject: SVGAttributes;
1122
+ image: SVGAttributes;
1123
+ linearGradient: SVGAttributes;
1124
+ marker: SVGAttributes;
1125
+ mask: SVGAttributes;
1126
+ metadata: SVGAttributes;
1127
+ mpath: SVGAttributes;
1128
+ pattern: SVGAttributes;
1129
+ radialGradient: SVGAttributes;
1130
+ set: SVGAttributes;
1131
+ stop: SVGAttributes;
1132
+ switch: SVGAttributes;
1133
+ symbol: SVGAttributes;
1134
+ text: SVGAttributes;
1135
+ textPath: SVGAttributes;
1136
+ tspan: SVGAttributes;
1137
+ use: SVGAttributes;
1138
+ view: SVGAttributes;
1054
1139
  }
1055
1140
  interface ImageProps {
1056
1141
  src: string;
@@ -1067,6 +1152,12 @@ declare global {
1067
1152
  href: KrateHref;
1068
1153
  className?: string;
1069
1154
  external?: boolean;
1155
+ /**
1156
+ * `false` links to a URL served outside this site on the same domain
1157
+ * (for example the marketing site at `/` while Krate runs under a base
1158
+ * path): the href is used as written and the link is a normal navigation.
1159
+ */
1160
+ basePath?: false;
1070
1161
  children?: any;
1071
1162
  /** Prefetch the target page on hover/focus/viewport entry (default: true). */
1072
1163
  prefetch?: boolean;