effect-start 0.9.0 → 0.10.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/package.json +12 -13
- package/src/BundleHttp.test.ts +1 -1
- package/src/Commander.test.ts +15 -15
- package/src/Commander.ts +58 -88
- package/src/EncryptedCookies.test.ts +4 -4
- package/src/FileHttpRouter.test.ts +81 -12
- package/src/FileHttpRouter.ts +115 -26
- package/src/FileRouter.ts +60 -162
- package/src/FileRouterCodegen.test.ts +250 -64
- package/src/FileRouterCodegen.ts +13 -56
- package/src/FileRouterPattern.test.ts +116 -0
- package/src/FileRouterPattern.ts +59 -0
- package/src/FileRouter_path.test.ts +63 -102
- package/src/FileSystemExtra.test.ts +226 -0
- package/src/FileSystemExtra.ts +24 -60
- package/src/HttpUtils.test.ts +68 -0
- package/src/HttpUtils.ts +15 -0
- package/src/HyperHtml.ts +24 -5
- package/src/JsModule.test.ts +1 -1
- package/src/NodeFileSystem.ts +764 -0
- package/src/Random.ts +59 -0
- package/src/Route.test.ts +471 -0
- package/src/Route.ts +298 -153
- package/src/RouteRender.ts +38 -0
- package/src/Router.ts +11 -33
- package/src/RouterPattern.test.ts +629 -0
- package/src/RouterPattern.ts +391 -0
- package/src/Start.ts +14 -52
- package/src/bun/BunBundle.test.ts +0 -3
- package/src/bun/BunHttpServer.ts +246 -0
- package/src/bun/BunHttpServer_web.ts +384 -0
- package/src/bun/BunRoute.test.ts +341 -0
- package/src/bun/BunRoute.ts +326 -0
- package/src/bun/BunRoute_bundles.test.ts +218 -0
- package/src/bun/BunRuntime.ts +33 -0
- package/src/bun/BunTailwindPlugin.test.ts +1 -1
- package/src/bun/_empty.html +1 -0
- package/src/bun/index.ts +2 -1
- package/src/testing.ts +12 -3
- package/src/Datastar.test.ts +0 -267
- package/src/Datastar.ts +0 -68
- package/src/bun/BunFullstackServer.ts +0 -45
- package/src/bun/BunFullstackServer_httpServer.ts +0 -541
- package/src/jsx-datastar.d.ts +0 -63
package/src/HttpUtils.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as HttpServerRequest from "@effect/platform/HttpServerRequest"
|
|
2
|
+
|
|
3
|
+
export function makeUrlFromRequest(
|
|
4
|
+
request: HttpServerRequest.HttpServerRequest,
|
|
5
|
+
): URL {
|
|
6
|
+
const origin = request.headers.origin
|
|
7
|
+
?? request.headers.host
|
|
8
|
+
?? "http://localhost"
|
|
9
|
+
const protocol = request.headers["x-forwarded-proto"] ?? "http"
|
|
10
|
+
const host = request.headers.host ?? "localhost"
|
|
11
|
+
const base = origin.startsWith("http")
|
|
12
|
+
? origin
|
|
13
|
+
: `${protocol}://${host}`
|
|
14
|
+
return new URL(request.url, base)
|
|
15
|
+
}
|
package/src/HyperHtml.ts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders Hyper JSX nodes to HTML.
|
|
3
|
+
*
|
|
4
|
+
* Effect Start comes with {@link Hyper} and {@link JsxRuntime} to enable
|
|
5
|
+
* JSX support. The advantage of using JSX over HTML strings or templates
|
|
6
|
+
* is type safety and better editor support.
|
|
7
|
+
*
|
|
8
|
+
* JSX nodes are compatible with React's and Solid's.
|
|
9
|
+
|
|
10
|
+
* You can enable JSX support by updating `tsconfig.json`:
|
|
11
|
+
*
|
|
12
|
+
* {
|
|
13
|
+
* compilerOptions: {
|
|
14
|
+
* jsx: "react-jsx",
|
|
15
|
+
* jsxImportSource: "effect-start" | "react" | "praect" // etc.
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type * as Hyper from "./Hyper.tsx"
|
|
1
21
|
import * as HyperNode from "./HyperNode.ts"
|
|
2
22
|
import { JSX } from "./jsx"
|
|
23
|
+
import type * as JsxRuntime from "./jsx-runtime.ts"
|
|
3
24
|
|
|
4
|
-
/**
|
|
5
|
-
* From: https://github.com/developit/vhtml
|
|
6
|
-
*/
|
|
7
25
|
const EMPTY_TAGS = [
|
|
8
26
|
"area",
|
|
9
27
|
"base",
|
|
@@ -93,8 +111,8 @@ export function renderToString(
|
|
|
93
111
|
for (const key in props) {
|
|
94
112
|
if (
|
|
95
113
|
key !== "children"
|
|
96
|
-
&& key !== "innerHTML"
|
|
97
|
-
&& key !== "dangerouslySetInnerHTML"
|
|
114
|
+
&& key !== "innerHTML" // Solid-specific
|
|
115
|
+
&& key !== "dangerouslySetInnerHTML" // React-specific
|
|
98
116
|
&& props[key] !== false
|
|
99
117
|
&& props[key] != null
|
|
100
118
|
) {
|
|
@@ -113,6 +131,7 @@ export function renderToString(
|
|
|
113
131
|
if (!EMPTY_TAGS.includes(type)) {
|
|
114
132
|
stack.push(`</${type}>`)
|
|
115
133
|
|
|
134
|
+
// React-specific
|
|
116
135
|
const html = props.dangerouslySetInnerHTML?.__html
|
|
117
136
|
?? props.innerHTML
|
|
118
137
|
|
package/src/JsModule.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "bun:test"
|
|
2
2
|
import * as JsModule from "./JsModule.ts"
|
|
3
3
|
|
|
4
|
-
t.describe(
|
|
4
|
+
t.describe(`${JsModule.importSource.name}`, () => {
|
|
5
5
|
t.it("imports a string", async () => {
|
|
6
6
|
const mod = await JsModule.importSource<any>(`
|
|
7
7
|
export const b = "B"
|