@krate/runtime 0.5.0-rc.1 → 0.5.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +7 -0
- package/dist/actions.js +23 -8
- package/dist/actions.test.js +8 -410
- package/dist/after.d.ts +28 -0
- package/dist/after.js +48 -0
- package/dist/after.test.js +58 -0
- package/dist/assets-static.d.ts +10 -1
- package/dist/assets-static.js +10 -2
- package/dist/base-path.d.ts +7 -0
- package/dist/base-path.js +20 -0
- package/dist/builtin-tags.d.ts +12 -0
- package/dist/builtin-tags.js +42 -0
- package/dist/builtin-tags.test.js +12 -0
- package/dist/cache-adapter.test.js +4 -203
- package/dist/cache-scope.d.ts +2 -0
- package/dist/cache.test.js +1 -197
- package/dist/cloudflare-workers.d.ts +2 -0
- package/dist/cloudflare-workers.js +27 -0
- package/dist/dev-overlay.d.ts +54 -3
- package/dist/dev-overlay.js +469 -76
- package/dist/dom.js +17 -2
- package/dist/events.test.js +2 -407
- package/dist/handler-html.test.js +1 -202
- package/dist/handler-routing.js +3 -0
- package/dist/handler-segments.d.ts +6 -0
- package/dist/handler-segments.js +16 -2
- package/dist/handler-segments.test.js +8 -200
- package/dist/head-tags.d.ts +9 -0
- package/dist/head-tags.js +85 -1
- package/dist/head-tags.test.js +18 -125
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/inline-action-token.test.js +31 -0
- package/dist/jsx-svg-types.test.js +58 -0
- package/dist/jsx-types.d.ts +92 -1
- package/dist/krate-core.js +1 -1
- package/dist/krate-dev.js +384 -65
- package/dist/krate-f-actions.js +1 -1
- package/dist/krate-f-navigation.js +1 -1
- package/dist/krate-f-router-lite.js +1 -1
- package/dist/krate-f-router.js +1 -1
- package/dist/krate-features.json +2 -0
- package/dist/krate-hydrate-lite.js +5 -5
- package/dist/krate-hydrate.js +5 -5
- package/dist/krate-runtime.js +5 -5
- package/dist/link-base-path.test.js +28 -0
- package/dist/metadata.js +3 -0
- package/dist/node-server.test.js +1 -355
- package/dist/platform.d.ts +52 -0
- package/dist/platform.js +57 -0
- package/dist/platform.test.js +44 -0
- package/dist/router-lite.js +3 -9
- package/dist/router-nav.test.js +15 -444
- package/dist/router.js +51 -18
- package/dist/server-handler.d.ts +49 -0
- package/dist/server-handler.js +311 -21
- package/dist/server-handler.test.js +56 -344
- package/dist/server-renderer.test.js +0 -104
- package/dist/server.d.ts +15 -5
- package/dist/server.js +150 -22
- package/dist/server.test.js +52 -60
- package/dist/site-config.d.ts +13 -0
- package/dist/site-config.js +28 -0
- package/dist/site-config.test.js +30 -0
- package/dist/ssr-core-behavior.test.js +3 -515
- package/dist/testing.d.ts +59 -0
- package/dist/testing.js +88 -0
- package/dist/testing.test.js +73 -0
- package/package.json +9 -1
- package/dist/action-context.test.js +0 -72
- package/dist/class-component.test.js +0 -462
- package/dist/class-helpers.test.js +0 -169
- package/dist/context.test.js +0 -57
- package/dist/derived.test.js +0 -140
- package/dist/dev-overlay.test.js +0 -165
- package/dist/discrete.test.js +0 -100
- package/dist/dom.test.js +0 -39
- package/dist/effect-errors.test.d.ts +0 -1
- package/dist/effect-errors.test.js +0 -199
- package/dist/effects.test.d.ts +0 -1
- package/dist/effects.test.js +0 -485
- package/dist/handler-routing.test.d.ts +0 -1
- package/dist/handler-routing.test.js +0 -99
- package/dist/highlight-bind.test.d.ts +0 -1
- package/dist/highlight-bind.test.js +0 -124
- package/dist/highlight.test.d.ts +0 -1
- package/dist/highlight.test.js +0 -56
- package/dist/lanes.test.d.ts +0 -1
- package/dist/lanes.test.js +0 -59
- package/dist/list.test.d.ts +0 -1
- package/dist/list.test.js +0 -435
- package/dist/metadata.test.d.ts +0 -1
- package/dist/metadata.test.js +0 -167
- package/dist/navigation.test.d.ts +0 -1
- package/dist/navigation.test.js +0 -130
- package/dist/optimistic-lanes.test.d.ts +0 -1
- package/dist/optimistic-lanes.test.js +0 -45
- package/dist/patterns.test.d.ts +0 -1
- package/dist/patterns.test.js +0 -125
- package/dist/portal.test.d.ts +0 -1
- package/dist/portal.test.js +0 -99
- package/dist/react-effects.test.d.ts +0 -1
- package/dist/react-effects.test.js +0 -133
- package/dist/react-suspense.test.d.ts +0 -1
- package/dist/react-suspense.test.js +0 -194
- package/dist/react.test.d.ts +0 -1
- package/dist/react.test.js +0 -60
- package/dist/react19.test.d.ts +0 -1
- package/dist/react19.test.js +0 -176
- package/dist/reactivity-core.test.d.ts +0 -1
- package/dist/reactivity-core.test.js +0 -152
- package/dist/reconcile.test.d.ts +0 -1
- package/dist/reconcile.test.js +0 -110
- package/dist/refs.test.d.ts +0 -1
- package/dist/refs.test.js +0 -257
- package/dist/router-layout.test.d.ts +0 -1
- package/dist/router-layout.test.js +0 -249
- package/dist/router-slots.test.d.ts +0 -1
- package/dist/router-slots.test.js +0 -144
- package/dist/router-speculation.test.d.ts +0 -1
- package/dist/router-speculation.test.js +0 -25
- package/dist/router-styles.test.d.ts +0 -1
- package/dist/router-styles.test.js +0 -98
- package/dist/router.test.d.ts +0 -1
- package/dist/router.test.js +0 -36
- package/dist/server-async.test.d.ts +0 -1
- package/dist/server-async.test.js +0 -216
- package/dist/server-highlight.test.d.ts +0 -1
- package/dist/server-highlight.test.js +0 -32
- package/dist/signal-lanes.test.d.ts +0 -1
- package/dist/signal-lanes.test.js +0 -32
- package/dist/slots.test.d.ts +0 -1
- package/dist/slots.test.js +0 -187
- package/dist/snapshots.test.d.ts +0 -1
- package/dist/snapshots.test.js +0 -208
- package/dist/ssr-core.test.d.ts +0 -1
- package/dist/ssr-core.test.js +0 -324
- package/dist/static-memory.test.d.ts +0 -1
- package/dist/static-memory.test.js +0 -26
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -46
- package/dist/suspense-actions.test.d.ts +0 -1
- package/dist/suspense-actions.test.js +0 -72
- package/dist/suspense.test.d.ts +0 -1
- package/dist/suspense.test.js +0 -556
- /package/dist/{action-context.test.d.ts → after.test.d.ts} +0 -0
- /package/dist/{class-component.test.d.ts → builtin-tags.test.d.ts} +0 -0
- /package/dist/{class-helpers.test.d.ts → inline-action-token.test.d.ts} +0 -0
- /package/dist/{context.test.d.ts → jsx-svg-types.test.d.ts} +0 -0
- /package/dist/{derived.test.d.ts → link-base-path.test.d.ts} +0 -0
- /package/dist/{dev-overlay.test.d.ts → platform.test.d.ts} +0 -0
- /package/dist/{discrete.test.d.ts → site-config.test.d.ts} +0 -0
- /package/dist/{dom.test.d.ts → testing.test.d.ts} +0 -0
package/dist/head-tags.test.js
CHANGED
|
@@ -1,131 +1,24 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 & B",
|
|
54
|
-
head: '<meta name="description" content="About <"x"> & more">',
|
|
55
|
-
want: '<head><title>A & B</title><meta name="description" content="About <"x"> & 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("
|
|
82
|
-
const
|
|
83
|
-
expect(
|
|
11
|
+
it("sets attributes on the document elements and escapes values", () => {
|
|
12
|
+
const out = mergeHead(DOC, "", '<html class="dark" data-q="a"b"></html><body class="font-sans"></body>');
|
|
13
|
+
expect(out).toContain('<html class="dark" data-q="a"b" lang="en">');
|
|
14
|
+
expect(out).toContain('<body class="font-sans">');
|
|
15
|
+
expect(out).not.toContain("</html></html>");
|
|
84
16
|
});
|
|
85
|
-
it("
|
|
86
|
-
|
|
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("
|
|
94
|
-
const
|
|
95
|
-
expect(
|
|
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 "b" <c>">');
|
|
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,4 +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 { Link, Head, Icon, Image, Script, Style, Suspense, SyntaxHighlight } from './builtin-tags.js';
|
|
32
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
|
+
});
|
package/dist/jsx-types.d.ts
CHANGED
|
@@ -679,7 +679,7 @@ declare global {
|
|
|
679
679
|
width?: number | string;
|
|
680
680
|
disablePictureInPicture?: boolean;
|
|
681
681
|
}
|
|
682
|
-
interface SVGAttributes extends AriaAttributes,
|
|
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;
|