effect-start 0.29.0 → 0.30.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/README.md +1 -1
- package/dist/{_Development.d.ts → Development.d.ts} +2 -1
- package/dist/Development.d.ts.map +1 -0
- package/dist/{_Development.js → Development.js} +2 -1
- package/dist/Development.js.map +1 -0
- package/dist/Fetch.d.ts +0 -8
- package/dist/Fetch.d.ts.map +1 -1
- package/dist/Fetch.js +6 -22
- package/dist/Fetch.js.map +1 -1
- package/dist/FileRouter.js +1 -1
- package/dist/FileRouter.js.map +1 -1
- package/dist/GlobalLayer.d.ts.map +1 -1
- package/dist/GlobalLayer.js +1 -1
- package/dist/GlobalLayer.js.map +1 -1
- package/dist/Html.d.ts +32 -0
- package/dist/Html.d.ts.map +1 -0
- package/dist/{hyper/HyperHtml.js → Html.js} +45 -26
- package/dist/Html.js.map +1 -0
- package/dist/Route.d.ts +20 -7
- package/dist/Route.d.ts.map +1 -1
- package/dist/Route.js +24 -3
- package/dist/Route.js.map +1 -1
- package/dist/RouteBody.d.ts +13 -6
- package/dist/RouteBody.d.ts.map +1 -1
- package/dist/RouteBody.js +38 -27
- package/dist/RouteBody.js.map +1 -1
- package/dist/RouteHttp.d.ts.map +1 -1
- package/dist/RouteHttp.js +18 -1
- package/dist/RouteHttp.js.map +1 -1
- package/dist/RouteMount.js +1 -1
- package/dist/RouteMount.js.map +1 -1
- package/dist/System.d.ts +1 -1
- package/dist/System.d.ts.map +1 -1
- package/dist/System.js.map +1 -1
- package/dist/_ChildProcess.d.ts +1 -1
- package/dist/_ChildProcess.d.ts.map +1 -1
- package/dist/_ChildProcess.js.map +1 -1
- package/dist/bun/BunRoute.d.ts +1 -1
- package/dist/bun/BunRoute.d.ts.map +1 -1
- package/dist/bun/BunRoute.js +102 -33
- package/dist/bun/BunRoute.js.map +1 -1
- package/dist/bun/BunServer.d.ts.map +1 -1
- package/dist/bun/BunServer.js.map +1 -1
- package/dist/cloudflare/CloudflareTunnel.d.ts +12 -0
- package/dist/cloudflare/CloudflareTunnel.d.ts.map +1 -0
- package/dist/{x/cloudflare → cloudflare}/CloudflareTunnel.js +1 -1
- package/dist/cloudflare/CloudflareTunnel.js.map +1 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime.d.ts +8 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/{hyper/jsx-runtime.js → jsx-runtime.js} +2 -2
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/studio/routes/errors/route.d.ts.map +1 -1
- package/dist/studio/routes/errors/route.js +3 -4
- package/dist/studio/routes/errors/route.js.map +1 -1
- package/dist/studio/routes/fiberDetail.d.ts.map +1 -1
- package/dist/studio/routes/fiberDetail.js +1 -2
- package/dist/studio/routes/fiberDetail.js.map +1 -1
- package/dist/studio/routes/fibers/route.d.ts.map +1 -1
- package/dist/studio/routes/fibers/route.js +3 -4
- package/dist/studio/routes/fibers/route.js.map +1 -1
- package/dist/studio/routes/logs/route.d.ts.map +1 -1
- package/dist/studio/routes/logs/route.js +3 -4
- package/dist/studio/routes/logs/route.js.map +1 -1
- package/dist/studio/routes/metrics/route.d.ts.map +1 -1
- package/dist/studio/routes/metrics/route.js +3 -4
- package/dist/studio/routes/metrics/route.js.map +1 -1
- package/dist/studio/routes/route.d.ts +1 -1
- package/dist/studio/routes/routes/route.d.ts.map +1 -1
- package/dist/studio/routes/routes/route.js +1 -2
- package/dist/studio/routes/routes/route.js.map +1 -1
- package/dist/studio/routes/services/route.d.ts.map +1 -1
- package/dist/studio/routes/services/route.js +1 -2
- package/dist/studio/routes/services/route.js.map +1 -1
- package/dist/studio/routes/system/route.d.ts.map +1 -1
- package/dist/studio/routes/system/route.js +3 -4
- package/dist/studio/routes/system/route.js.map +1 -1
- package/dist/studio/routes/traceDetail.d.ts.map +1 -1
- package/dist/studio/routes/traceDetail.js +1 -2
- package/dist/studio/routes/traceDetail.js.map +1 -1
- package/dist/studio/routes/traces/route.d.ts.map +1 -1
- package/dist/studio/routes/traces/route.js +3 -4
- package/dist/studio/routes/traces/route.js.map +1 -1
- package/dist/studio/routes/tree.d.ts +1 -1
- package/dist/studio/ui/Errors.d.ts +1 -1
- package/dist/studio/ui/Errors.d.ts.map +1 -1
- package/dist/studio/ui/Fibers.d.ts +2 -2
- package/dist/studio/ui/Fibers.d.ts.map +1 -1
- package/dist/studio/ui/Logs.d.ts +1 -1
- package/dist/studio/ui/Logs.d.ts.map +1 -1
- package/dist/studio/ui/Metrics.d.ts +1 -1
- package/dist/studio/ui/Metrics.d.ts.map +1 -1
- package/dist/studio/ui/Routes.d.ts +1 -1
- package/dist/studio/ui/Routes.d.ts.map +1 -1
- package/dist/studio/ui/Services.d.ts +1 -1
- package/dist/studio/ui/Services.d.ts.map +1 -1
- package/dist/studio/ui/Shell.d.ts +2 -2
- package/dist/studio/ui/Shell.d.ts.map +1 -1
- package/dist/studio/ui/System.d.ts +1 -1
- package/dist/studio/ui/System.d.ts.map +1 -1
- package/dist/studio/ui/Traces.d.ts +3 -3
- package/dist/studio/ui/Traces.d.ts.map +1 -1
- package/dist/tailscale/TailscaleTunnel.d.ts +16 -0
- package/dist/tailscale/TailscaleTunnel.d.ts.map +1 -0
- package/dist/{x/tailscale → tailscale}/TailscaleTunnel.js +2 -2
- package/dist/tailscale/TailscaleTunnel.js.map +1 -0
- package/dist/tailscale/index.d.ts.map +1 -0
- package/dist/tailscale/index.js.map +1 -0
- package/dist/tailwind/TailwindPlugin.d.ts.map +1 -0
- package/dist/tailwind/TailwindPlugin.js.map +1 -0
- package/dist/tailwind/compile.d.ts.map +1 -0
- package/dist/{x/tailwind → tailwind}/compile.js +1 -1
- package/dist/tailwind/compile.js.map +1 -0
- package/dist/tailwind/index.d.ts +3 -0
- package/dist/tailwind/index.d.ts.map +1 -0
- package/dist/tailwind/index.js +3 -0
- package/dist/tailwind/index.js.map +1 -0
- package/dist/tailwind/plugin.d.ts.map +1 -0
- package/dist/{x/tailwind → tailwind}/plugin.js +1 -1
- package/dist/tailwind/plugin.js.map +1 -0
- package/package.json +37 -37
- package/src/{_Development.ts → Development.ts} +5 -0
- package/src/Fetch.ts +10 -37
- package/src/FileRouter.ts +1 -1
- package/src/GlobalLayer.ts +3 -1
- package/src/{hyper/HyperHtml.ts → Html.ts} +90 -30
- package/src/Route.ts +67 -11
- package/src/RouteBody.ts +87 -62
- package/src/RouteHttp.ts +19 -1
- package/src/RouteMount.ts +1 -1
- package/src/System.ts +1 -1
- package/src/_ChildProcess.ts +1 -1
- package/src/bun/BunRoute.ts +125 -37
- package/src/bun/BunServer.ts +1 -0
- package/src/{x/cloudflare → cloudflare}/CloudflareTunnel.ts +1 -1
- package/src/index.ts +3 -1
- package/src/jsx-runtime.ts +15 -0
- package/src/{hyper/jsx.d.ts → jsx.d.ts} +3 -3
- package/src/studio/routes/errors/route.tsx +3 -4
- package/src/studio/routes/fiberDetail.tsx +1 -2
- package/src/studio/routes/fibers/route.tsx +3 -4
- package/src/studio/routes/logs/route.tsx +3 -4
- package/src/studio/routes/metrics/route.tsx +3 -4
- package/src/studio/routes/routes/route.tsx +1 -2
- package/src/studio/routes/services/route.tsx +1 -2
- package/src/studio/routes/system/route.tsx +3 -4
- package/src/studio/routes/traceDetail.tsx +1 -2
- package/src/studio/routes/traces/route.tsx +3 -4
- package/src/{x/tailscale → tailscale}/TailscaleTunnel.ts +2 -2
- package/src/{x/tailwind → tailwind}/compile.ts +1 -1
- package/src/tailwind/index.ts +2 -0
- package/src/{x/tailwind → tailwind}/plugin.ts +1 -1
- package/dist/_Development.d.ts.map +0 -1
- package/dist/_Development.js.map +0 -1
- package/dist/hyper/Hyper.d.ts +0 -26
- package/dist/hyper/Hyper.d.ts.map +0 -1
- package/dist/hyper/Hyper.js +0 -24
- package/dist/hyper/Hyper.js.map +0 -1
- package/dist/hyper/HyperHtml.d.ts +0 -24
- package/dist/hyper/HyperHtml.d.ts.map +0 -1
- package/dist/hyper/HyperHtml.js.map +0 -1
- package/dist/hyper/HyperHtml.test.d.ts +0 -2
- package/dist/hyper/HyperHtml.test.d.ts.map +0 -1
- package/dist/hyper/HyperHtml.test.js +0 -283
- package/dist/hyper/HyperHtml.test.js.map +0 -1
- package/dist/hyper/HyperNode.d.ts +0 -14
- package/dist/hyper/HyperNode.d.ts.map +0 -1
- package/dist/hyper/HyperNode.js +0 -12
- package/dist/hyper/HyperNode.js.map +0 -1
- package/dist/hyper/HyperRoute.d.ts +0 -9
- package/dist/hyper/HyperRoute.d.ts.map +0 -1
- package/dist/hyper/HyperRoute.js +0 -33
- package/dist/hyper/HyperRoute.js.map +0 -1
- package/dist/hyper/HyperRoute.test.d.ts +0 -2
- package/dist/hyper/HyperRoute.test.d.ts.map +0 -1
- package/dist/hyper/HyperRoute.test.js +0 -84
- package/dist/hyper/HyperRoute.test.js.map +0 -1
- package/dist/hyper/html.d.ts +0 -12
- package/dist/hyper/html.d.ts.map +0 -1
- package/dist/hyper/html.js +0 -31
- package/dist/hyper/html.js.map +0 -1
- package/dist/hyper/index.d.ts +0 -7
- package/dist/hyper/index.d.ts.map +0 -1
- package/dist/hyper/index.js +0 -6
- package/dist/hyper/index.js.map +0 -1
- package/dist/hyper/jsx-runtime.d.ts +0 -8
- package/dist/hyper/jsx-runtime.d.ts.map +0 -1
- package/dist/hyper/jsx-runtime.js.map +0 -1
- package/dist/x/cloudflare/CloudflareTunnel.d.ts +0 -12
- package/dist/x/cloudflare/CloudflareTunnel.d.ts.map +0 -1
- package/dist/x/cloudflare/CloudflareTunnel.js.map +0 -1
- package/dist/x/cloudflare/index.d.ts.map +0 -1
- package/dist/x/cloudflare/index.js.map +0 -1
- package/dist/x/tailscale/TailscaleTunnel.d.ts +0 -16
- package/dist/x/tailscale/TailscaleTunnel.d.ts.map +0 -1
- package/dist/x/tailscale/TailscaleTunnel.js.map +0 -1
- package/dist/x/tailscale/index.d.ts.map +0 -1
- package/dist/x/tailscale/index.js.map +0 -1
- package/dist/x/tailwind/TailwindPlugin.d.ts.map +0 -1
- package/dist/x/tailwind/TailwindPlugin.js.map +0 -1
- package/dist/x/tailwind/compile.d.ts.map +0 -1
- package/dist/x/tailwind/compile.js.map +0 -1
- package/dist/x/tailwind/plugin.d.ts.map +0 -1
- package/dist/x/tailwind/plugin.js.map +0 -1
- package/src/hyper/Hyper.ts +0 -55
- package/src/hyper/HyperHtml.test.tsx +0 -395
- package/src/hyper/HyperNode.ts +0 -33
- package/src/hyper/HyperRoute.test.tsx +0 -166
- package/src/hyper/HyperRoute.ts +0 -59
- package/src/hyper/html.ts +0 -47
- package/src/hyper/index.ts +0 -6
- package/src/hyper/jsx-runtime.ts +0 -15
- /package/dist/{x/cloudflare → cloudflare}/index.d.ts +0 -0
- /package/dist/{x/cloudflare → cloudflare}/index.js +0 -0
- /package/dist/{x/tailscale → tailscale}/index.d.ts +0 -0
- /package/dist/{x/tailscale → tailscale}/index.js +0 -0
- /package/dist/{x/tailwind → tailwind}/TailwindPlugin.d.ts +0 -0
- /package/dist/{x/tailwind → tailwind}/TailwindPlugin.js +0 -0
- /package/dist/{x/tailwind → tailwind}/compile.d.ts +0 -0
- /package/dist/{x/tailwind → tailwind}/plugin.d.ts +0 -0
- /package/src/{x/cloudflare → cloudflare}/index.ts +0 -0
- /package/src/{x/tailscale → tailscale}/index.ts +0 -0
- /package/src/{x/tailwind → tailwind}/TailwindPlugin.ts +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource effect-start */
|
|
2
|
-
import * as test from "bun:test"
|
|
3
|
-
import type * as Engine from "../datastar/engine.ts"
|
|
4
|
-
import * as Effect from "effect/Effect"
|
|
5
|
-
import * as Entity from "../Entity.ts"
|
|
6
|
-
import * as Fetch from "../Fetch.ts"
|
|
7
|
-
import * as Route from "../Route.ts"
|
|
8
|
-
import * as RouteHttp from "../RouteHttp.ts"
|
|
9
|
-
import * as HyperRoute from "./HyperRoute.ts"
|
|
10
|
-
|
|
11
|
-
test.describe("HyperRoute.html", () => {
|
|
12
|
-
test.it("renders JSX to HTML string", async () => {
|
|
13
|
-
const handler = RouteHttp.toWebHandler(Route.get(HyperRoute.html(<div>Hello World</div>)))
|
|
14
|
-
|
|
15
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
16
|
-
|
|
17
|
-
test.expect(response.status).toBe(200)
|
|
18
|
-
test.expect(response.headers.get("Content-Type")).toBe("text/html; charset=utf-8")
|
|
19
|
-
test.expect(await response.text()).toBe("<div>Hello World</div>")
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test.it("renders nested JSX elements", async () => {
|
|
23
|
-
const handler = RouteHttp.toWebHandler(
|
|
24
|
-
Route.get(
|
|
25
|
-
HyperRoute.html(
|
|
26
|
-
<div class="container">
|
|
27
|
-
<h1>Title</h1>
|
|
28
|
-
<p>Paragraph</p>
|
|
29
|
-
</div>,
|
|
30
|
-
),
|
|
31
|
-
),
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
35
|
-
|
|
36
|
-
test
|
|
37
|
-
.expect(await response.text())
|
|
38
|
-
.toBe('<div class="container"><h1>Title</h1><p>Paragraph</p></div>')
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test.it("renders JSX from Effect", async () => {
|
|
42
|
-
const handler = RouteHttp.toWebHandler(
|
|
43
|
-
Route.get(HyperRoute.html(Effect.succeed(<span>From Effect</span>))),
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
47
|
-
|
|
48
|
-
test.expect(await response.text()).toBe("<span>From Effect</span>")
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test.it("renders JSX from generator function", async () => {
|
|
52
|
-
const handler = RouteHttp.toWebHandler(
|
|
53
|
-
Route.get(
|
|
54
|
-
HyperRoute.html(
|
|
55
|
-
Effect.gen(function* () {
|
|
56
|
-
const name = yield* Effect.succeed("World")
|
|
57
|
-
return <div>Hello {name}</div>
|
|
58
|
-
}),
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
64
|
-
|
|
65
|
-
test.expect(await response.text()).toBe("<div>Hello World</div>")
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test.it("renders JSX from handler function", async () => {
|
|
69
|
-
const handler = RouteHttp.toWebHandler(
|
|
70
|
-
Route.get(HyperRoute.html((context) => Effect.succeed(<div>Request received</div>))),
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
74
|
-
|
|
75
|
-
test.expect(await response.text()).toBe("<div>Request received</div>")
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
test.it("renders JSX with dynamic content", async () => {
|
|
79
|
-
const items = ["Apple", "Banana", "Cherry"]
|
|
80
|
-
|
|
81
|
-
const handler = RouteHttp.toWebHandler(
|
|
82
|
-
Route.get(
|
|
83
|
-
HyperRoute.html(
|
|
84
|
-
<ul>
|
|
85
|
-
{items.map((item) => (
|
|
86
|
-
<li>{item}</li>
|
|
87
|
-
))}
|
|
88
|
-
</ul>,
|
|
89
|
-
),
|
|
90
|
-
),
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
94
|
-
|
|
95
|
-
test.expect(await response.text()).toBe("<ul><li>Apple</li><li>Banana</li><li>Cherry</li></ul>")
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test.it("handles Entity with JSX body", async () => {
|
|
99
|
-
const handler = RouteHttp.toWebHandler(
|
|
100
|
-
Route.get(HyperRoute.html(Entity.make(<div>With Entity</div>, { status: 201 }))),
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
104
|
-
|
|
105
|
-
test.expect(response.status).toBe(201)
|
|
106
|
-
test.expect(await response.text()).toBe("<div>With Entity</div>")
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test.it("renders data-* attributes with object values as JSON", async () => {
|
|
110
|
-
const handler = RouteHttp.toWebHandler(
|
|
111
|
-
Route.get(
|
|
112
|
-
HyperRoute.html(
|
|
113
|
-
<div
|
|
114
|
-
data-signals={{
|
|
115
|
-
draft: "",
|
|
116
|
-
pendingDraft: "",
|
|
117
|
-
username: "User123",
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
Content
|
|
121
|
-
</div>,
|
|
122
|
-
),
|
|
123
|
-
),
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
127
|
-
|
|
128
|
-
test
|
|
129
|
-
.expect(await response.text())
|
|
130
|
-
.toBe(`<div data-signals='{"draft":"","pendingDraft":"","username":"User123"}'>Content</div>`)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test.it("data-on-click function argument is typed as DataEvent", () => {
|
|
134
|
-
const node = (
|
|
135
|
-
<button
|
|
136
|
-
data-on:click={(e) => {
|
|
137
|
-
test.expectTypeOf(e).toMatchTypeOf<Engine.DataEvent>()
|
|
138
|
-
test.expectTypeOf(e.window).toMatchTypeOf<Window & typeof globalThis>()
|
|
139
|
-
}}
|
|
140
|
-
/>
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
test.expect(node).toBeDefined()
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
test.it("renders script with function child as IIFE", async () => {
|
|
147
|
-
const handler = RouteHttp.toWebHandler(
|
|
148
|
-
Route.get(
|
|
149
|
-
HyperRoute.html(
|
|
150
|
-
<script>
|
|
151
|
-
{(window) => {
|
|
152
|
-
console.log("Hello from", window.document.title)
|
|
153
|
-
}}
|
|
154
|
-
</script>,
|
|
155
|
-
),
|
|
156
|
-
),
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
const response = await Fetch.fromHandler(handler, { path: "/" })
|
|
160
|
-
const text = await response.text()
|
|
161
|
-
|
|
162
|
-
test.expect(text).toContain("<script>(")
|
|
163
|
-
test.expect(text).toContain(")(window)</script>")
|
|
164
|
-
test.expect(text).toContain("window.document.title")
|
|
165
|
-
})
|
|
166
|
-
})
|
package/src/hyper/HyperRoute.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect"
|
|
2
|
-
import * as Entity from "../Entity.ts"
|
|
3
|
-
import * as Route from "../Route.ts"
|
|
4
|
-
import type * as RouteBody from "../RouteBody.ts"
|
|
5
|
-
import type * as Values from "../_Values.ts"
|
|
6
|
-
import * as HyperHtml from "./HyperHtml.ts"
|
|
7
|
-
import type { JSX } from "./jsx.d.ts"
|
|
8
|
-
|
|
9
|
-
function renderValue(
|
|
10
|
-
value: JSX.Children | Entity.Entity<JSX.Children>,
|
|
11
|
-
): string | Entity.Entity<string> {
|
|
12
|
-
if (Entity.isEntity(value)) {
|
|
13
|
-
return Entity.make(HyperHtml.renderToString(value.body), {
|
|
14
|
-
status: value.status,
|
|
15
|
-
url: value.url,
|
|
16
|
-
headers: value.headers,
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
return HyperHtml.renderToString(value)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function normalizeToEffect<B, A, E, R>(
|
|
23
|
-
handler: RouteBody.HandlerInput<B, A, E, R>,
|
|
24
|
-
context: Values.Simplify<B>,
|
|
25
|
-
next: (context?: Partial<B> & Record<string, unknown>) => Entity.Entity<A>,
|
|
26
|
-
): Effect.Effect<A | Entity.Entity<A>, E, R> {
|
|
27
|
-
if (Effect.isEffect(handler)) {
|
|
28
|
-
return handler
|
|
29
|
-
}
|
|
30
|
-
if (typeof handler === "function") {
|
|
31
|
-
const result = (handler as Function)(context, next)
|
|
32
|
-
if (Effect.isEffect(result)) {
|
|
33
|
-
return result as Effect.Effect<A | Entity.Entity<A>, E, R>
|
|
34
|
-
}
|
|
35
|
-
return Effect.gen(function* () {
|
|
36
|
-
return yield* result
|
|
37
|
-
}) as Effect.Effect<A | Entity.Entity<A>, E, R>
|
|
38
|
-
}
|
|
39
|
-
return Effect.succeed(handler as A | Entity.Entity<A>)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function html<
|
|
43
|
-
D extends Route.RouteDescriptor.Any,
|
|
44
|
-
B extends {},
|
|
45
|
-
I extends Route.Route.Tuple,
|
|
46
|
-
E = never,
|
|
47
|
-
R = never,
|
|
48
|
-
>(
|
|
49
|
-
handler: RouteBody.HandlerInput<
|
|
50
|
-
NoInfer<D & B & Route.ExtractBindings<I> & { format: "html" }>,
|
|
51
|
-
JSX.Children,
|
|
52
|
-
E,
|
|
53
|
-
R
|
|
54
|
-
>,
|
|
55
|
-
) {
|
|
56
|
-
return Route.html<D, B, I, string, E, R>((context, next) =>
|
|
57
|
-
Effect.map(normalizeToEffect(handler, context, next as never), renderValue),
|
|
58
|
-
)
|
|
59
|
-
}
|
package/src/hyper/html.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const HtmlStringSymbol = Symbol.for("HtmlString")
|
|
2
|
-
|
|
3
|
-
export interface HtmlString {
|
|
4
|
-
readonly [HtmlStringSymbol]: true
|
|
5
|
-
readonly value: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const makeHtmlString = (value: string): HtmlString => ({
|
|
9
|
-
[HtmlStringSymbol]: true,
|
|
10
|
-
value,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const isHtmlString = (value: unknown): value is HtmlString =>
|
|
14
|
-
typeof value === "object" && value !== null && HtmlStringSymbol in value
|
|
15
|
-
|
|
16
|
-
export type HtmlValue =
|
|
17
|
-
| string
|
|
18
|
-
| number
|
|
19
|
-
| bigint
|
|
20
|
-
| boolean
|
|
21
|
-
| null
|
|
22
|
-
| undefined
|
|
23
|
-
| HtmlString
|
|
24
|
-
| Function
|
|
25
|
-
| Record<string, unknown>
|
|
26
|
-
| ReadonlyArray<HtmlValue>
|
|
27
|
-
|
|
28
|
-
const resolveValue = (value: HtmlValue): string => {
|
|
29
|
-
if (value === null || value === undefined || value === false || value === true) return ""
|
|
30
|
-
if (isHtmlString(value)) return value.value
|
|
31
|
-
if (Array.isArray(value)) return (value as Array<HtmlValue>).map(resolveValue).join("")
|
|
32
|
-
if (typeof value === "function") return value.toString()
|
|
33
|
-
if (typeof value === "object") return JSON.stringify(value)
|
|
34
|
-
if (typeof value === "string") return value
|
|
35
|
-
return String(value)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const html = (strings: TemplateStringsArray, ...values: Array<HtmlValue>): HtmlString => {
|
|
39
|
-
let result = strings[0]
|
|
40
|
-
for (let i = 0; i < values.length; i++) {
|
|
41
|
-
result += resolveValue(values[i])
|
|
42
|
-
result += strings[i + 1]
|
|
43
|
-
}
|
|
44
|
-
return makeHtmlString(result)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
html.raw = (value: string): HtmlString => makeHtmlString(value)
|
package/src/hyper/index.ts
DELETED
package/src/hyper/jsx-runtime.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as HyperNode from "./HyperNode.ts"
|
|
2
|
-
import type { JSX } from "./jsx.d.ts"
|
|
3
|
-
|
|
4
|
-
function Fragment(props: { children: JSX.Element }) {
|
|
5
|
-
return props.children
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function jsx<T extends HyperNode.Type>(
|
|
9
|
-
type: T,
|
|
10
|
-
props: T extends string ? HyperNode.Props : T extends (props: infer P) => any ? P : never,
|
|
11
|
-
): HyperNode.HyperNode {
|
|
12
|
-
return HyperNode.make(type, props)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { Fragment, type JSX, jsx, jsx as jsxDEV, jsx as jsxs }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|