@hamur/adapter-solid 0.0.0-stage → 0.0.2
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/LICENSE +22 -0
- package/README.md +35 -2
- package/dist/chunks/browser-index-8rhv2s58.js +14 -0
- package/dist/chunks/browser-index-b05qbzsh.js +165 -0
- package/dist/chunks/browser-index-n80jt19y.js +114 -0
- package/dist/chunks/browser-index-ncnkshd9.js +39 -0
- package/dist/chunks/browser-index-r4jwfgh7.js +407 -0
- package/dist/src/adapter.js +556 -0
- package/dist/src/error-page.js +466 -0
- package/dist/src/index.js +1535 -0
- package/dist/src/keepalive.js +6 -0
- package/dist/src/runtime/client.js +174 -0
- package/dist/src/runtime/island.js +58 -0
- package/dist/src/runtime/server.js +138 -0
- package/dist/types/src/activation.d.ts +15 -0
- package/dist/types/src/adapter.d.ts +4 -0
- package/dist/types/src/async-data.d.ts +21 -0
- package/dist/types/src/client-component.d.ts +10 -0
- package/dist/types/src/client-fallback.d.ts +2 -0
- package/dist/types/src/context.d.ts +89 -0
- package/dist/types/src/error-page.d.ts +1 -0
- package/dist/types/src/index.d.ts +392 -0
- package/dist/types/src/island-html.d.ts +13 -0
- package/dist/types/src/island.d.ts +20 -0
- package/dist/types/src/jsx-locator.d.ts +6 -0
- package/dist/types/src/keepalive.d.ts +30 -0
- package/dist/types/src/lazy-hydration.d.ts +13 -0
- package/dist/types/src/markdown-page.d.ts +9 -0
- package/dist/types/src/markdown.d.ts +13 -0
- package/dist/types/src/plugin.d.ts +44 -0
- package/dist/types/src/runtime/client.d.ts +13 -0
- package/dist/types/src/runtime/hmr-solid.d.ts +5 -0
- package/dist/types/src/runtime/hmr.d.ts +27 -0
- package/dist/types/src/runtime/hydration-dev.d.ts +1 -0
- package/dist/types/src/runtime/hydration.d.ts +10 -0
- package/dist/types/src/runtime/island.d.ts +8 -0
- package/dist/types/src/runtime/portal.d.ts +13 -0
- package/dist/types/src/runtime/server.d.ts +14 -0
- package/dist/types/src/runtime/trusted.d.ts +2 -0
- package/dist/types/src/server-island.d.ts +10 -0
- package/dist/types/src/svg.d.ts +10 -0
- package/package.json +74 -4
- package/src/activation.ts +51 -0
- package/src/adapter.ts +42 -0
- package/src/async-data.ts +105 -0
- package/src/client-component.ts +40 -0
- package/src/client-fallback.ts +2 -0
- package/src/context.ts +495 -0
- package/src/env.d.ts +3 -0
- package/src/error-page.ts +1 -0
- package/src/index.ts +1900 -0
- package/src/island-html.ts +58 -0
- package/src/island.ts +55 -0
- package/src/jsx-locator.ts +199 -0
- package/src/keepalive.ts +147 -0
- package/src/lazy-hydration.ts +146 -0
- package/src/markdown-page.ts +18 -0
- package/src/markdown.ts +70 -0
- package/src/plugin.ts +310 -0
- package/src/runtime/client.ts +175 -0
- package/src/runtime/hmr-solid.ts +19 -0
- package/src/runtime/hmr.ts +231 -0
- package/src/runtime/hydration-dev.ts +41 -0
- package/src/runtime/hydration.ts +9 -0
- package/src/runtime/island.ts +66 -0
- package/src/runtime/portal.ts +64 -0
- package/src/runtime/server.ts +160 -0
- package/src/runtime/trusted.ts +16 -0
- package/src/server-island.ts +47 -0
- package/src/solid.d.ts +4 -0
- package/src/svg.ts +53 -0
- package/src/webmcp.d.ts +20 -0
package/src/svg.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { svgCode, type SvgCode, type SvgNode, type SvgSource, type SvgValue } from "hamur/adapter"
|
|
2
|
+
|
|
3
|
+
// Solid's client writes a style prop through cssText, which rewrites the server's text; a ref sets it as written.
|
|
4
|
+
const attributesCode = (code: SvgCode, attrs: Record<string, SvgValue>): string =>
|
|
5
|
+
Object.entries(attrs)
|
|
6
|
+
.map(([name, value]) =>
|
|
7
|
+
name === "style"
|
|
8
|
+
? ` style={isServer ? ${code.value(value)} : undefined} ref={(element) => element.setAttribute("style", ${code.value(value)})}`
|
|
9
|
+
: ` ${name}={${code.value(value)}}`,
|
|
10
|
+
)
|
|
11
|
+
.join("")
|
|
12
|
+
|
|
13
|
+
function nodeCode(code: SvgCode, node: SvgNode): string {
|
|
14
|
+
if (typeof node === "string" || Array.isArray(node)) return `{${code.value(node)}}`
|
|
15
|
+
return `<${node.tag}${attributesCode(code, code.attrs(node))}>${node.children.map((child) => nodeCode(code, child)).join("")}</${node.tag}>`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function module(svg: SvgSource): { contents: string; extension: string } {
|
|
19
|
+
const code = svgCode(svg, { title: "props.title", props: "rest" })
|
|
20
|
+
const hidden = code.hidden ? ` aria-hidden={${code.hidden} ? "true" : undefined}` : ""
|
|
21
|
+
const contents = `import { createRenderEffect, createUniqueId, isHydrating, omit } from "solid-js";
|
|
22
|
+
import { dynamic, isServer } from "@solidjs/web";
|
|
23
|
+
|
|
24
|
+
const Title = dynamic(() => "title", { static: true });
|
|
25
|
+
|
|
26
|
+
// Solid compiles a title element outside the root template as an HTML element; a client render makes it in the SVG namespace.
|
|
27
|
+
function SvgTitle(props) {
|
|
28
|
+
if (isServer || isHydrating()) return <Title>{props.text}</Title>;
|
|
29
|
+
const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
|
|
30
|
+
createRenderEffect(() => props.text, (text) => {
|
|
31
|
+
title.textContent = text;
|
|
32
|
+
});
|
|
33
|
+
return title;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default function SvgComponent(props) {
|
|
37
|
+
const rest = omit(props, "title");
|
|
38
|
+
const uid = createUniqueId().replace(/[^\\w-]/g, "_");
|
|
39
|
+
return (
|
|
40
|
+
<svg${attributesCode(code, svg.attrs)}${hidden} {...rest}>
|
|
41
|
+
{props.title != null && <SvgTitle text={props.title} />}
|
|
42
|
+
${svg.children.map((child) => nodeCode(code, child)).join("")}
|
|
43
|
+
</svg>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
`
|
|
47
|
+
return { contents, extension: ".jsx" }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const svgComponent = {
|
|
51
|
+
types: `import("solid-js").Component<import("@solidjs/web").JSX.SvgSVGAttributes<SVGSVGElement> & { title?: string }>`,
|
|
52
|
+
module,
|
|
53
|
+
}
|
package/src/webmcp.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "@solidjs/web/jsx-runtime"
|
|
2
|
+
|
|
3
|
+
declare module "@solidjs/web/jsx-runtime" {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface FormHTMLAttributes<T> {
|
|
6
|
+
toolname?: string
|
|
7
|
+
tooldescription?: string
|
|
8
|
+
toolautosubmit?: boolean
|
|
9
|
+
}
|
|
10
|
+
interface InputHTMLAttributes<T> {
|
|
11
|
+
toolparamdescription?: string
|
|
12
|
+
}
|
|
13
|
+
interface SelectHTMLAttributes<T> {
|
|
14
|
+
toolparamdescription?: string
|
|
15
|
+
}
|
|
16
|
+
interface TextareaHTMLAttributes<T> {
|
|
17
|
+
toolparamdescription?: string
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|