effect-start 0.25.0 → 0.26.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 +18 -86
- package/dist/ChildProcess.js +0 -42
- package/dist/Commander.js +0 -410
- package/dist/ContentNegotiation.js +0 -465
- package/dist/Cookies.js +0 -371
- package/dist/Development.js +0 -94
- package/dist/Effectify.js +0 -27
- package/dist/Entity.js +0 -289
- package/dist/Fetch.js +0 -192
- package/dist/FilePathPattern.js +0 -97
- package/dist/FileRouter.js +0 -204
- package/dist/FileRouterCodegen.js +0 -298
- package/dist/FileSystem.js +0 -132
- package/dist/Http.js +0 -107
- package/dist/PathPattern.js +0 -451
- package/dist/PlatformError.js +0 -40
- package/dist/PlatformRuntime.js +0 -71
- package/dist/Route.js +0 -143
- package/dist/RouteBody.js +0 -92
- package/dist/RouteError.js +0 -76
- package/dist/RouteHook.js +0 -64
- package/dist/RouteHttp.js +0 -367
- package/dist/RouteHttpTracer.js +0 -90
- package/dist/RouteMount.js +0 -86
- package/dist/RouteSchema.js +0 -271
- package/dist/RouteSse.js +0 -94
- package/dist/RouteTree.js +0 -119
- package/dist/RouteTrie.js +0 -179
- package/dist/SchemaExtra.js +0 -99
- package/dist/Socket.js +0 -40
- package/dist/SqlIntrospect.js +0 -515
- package/dist/Start.js +0 -79
- package/dist/StartApp.js +0 -3
- package/dist/StreamExtra.js +0 -135
- package/dist/System.js +0 -38
- package/dist/TuplePathPattern.js +0 -74
- package/dist/Unique.js +0 -226
- package/dist/Values.js +0 -52
- package/dist/bun/BunBundle.js +0 -186
- package/dist/bun/BunChildProcessSpawner.js +0 -142
- package/dist/bun/BunImportTrackerPlugin.js +0 -91
- package/dist/bun/BunRoute.js +0 -157
- package/dist/bun/BunRuntime.js +0 -41
- package/dist/bun/BunServer.js +0 -285
- package/dist/bun/BunVirtualFilesPlugin.js +0 -54
- package/dist/bun/_BunEnhancedResolve.js +0 -127
- package/dist/bun/index.js +0 -5
- package/dist/bundler/Bundle.js +0 -92
- package/dist/bundler/BundleFiles.js +0 -154
- package/dist/bundler/BundleRoute.js +0 -62
- package/dist/client/Overlay.js +0 -33
- package/dist/client/ScrollState.js +0 -106
- package/dist/client/index.js +0 -97
- package/dist/console/Console.js +0 -42
- package/dist/console/ConsoleErrors.js +0 -211
- package/dist/console/ConsoleLogger.js +0 -56
- package/dist/console/ConsoleMetrics.js +0 -72
- package/dist/console/ConsoleProcess.js +0 -59
- package/dist/console/ConsoleStore.js +0 -72
- package/dist/console/ConsoleTracer.js +0 -107
- package/dist/console/Simulation.js +0 -784
- package/dist/console/index.js +0 -3
- package/dist/console/routes/tree.js +0 -30
- package/dist/datastar/actions/fetch.js +0 -536
- package/dist/datastar/actions/peek.js +0 -13
- package/dist/datastar/actions/setAll.js +0 -19
- package/dist/datastar/actions/toggleAll.js +0 -19
- package/dist/datastar/attributes/attr.js +0 -49
- package/dist/datastar/attributes/bind.js +0 -194
- package/dist/datastar/attributes/class.js +0 -54
- package/dist/datastar/attributes/computed.js +0 -25
- package/dist/datastar/attributes/effect.js +0 -10
- package/dist/datastar/attributes/indicator.js +0 -33
- package/dist/datastar/attributes/init.js +0 -27
- package/dist/datastar/attributes/jsonSignals.js +0 -33
- package/dist/datastar/attributes/on.js +0 -81
- package/dist/datastar/attributes/onIntersect.js +0 -53
- package/dist/datastar/attributes/onInterval.js +0 -31
- package/dist/datastar/attributes/onSignalPatch.js +0 -51
- package/dist/datastar/attributes/ref.js +0 -11
- package/dist/datastar/attributes/show.js +0 -32
- package/dist/datastar/attributes/signals.js +0 -18
- package/dist/datastar/attributes/style.js +0 -57
- package/dist/datastar/attributes/text.js +0 -29
- package/dist/datastar/engine.js +0 -1145
- package/dist/datastar/index.js +0 -25
- package/dist/datastar/utils.js +0 -250
- package/dist/datastar/watchers/patchElements.js +0 -486
- package/dist/datastar/watchers/patchSignals.js +0 -14
- package/dist/experimental/EncryptedCookies.js +0 -328
- package/dist/experimental/index.js +0 -1
- package/dist/hyper/Hyper.js +0 -28
- package/dist/hyper/HyperHtml.js +0 -165
- package/dist/hyper/HyperNode.js +0 -13
- package/dist/hyper/HyperRoute.js +0 -45
- package/dist/hyper/html.js +0 -30
- package/dist/hyper/index.js +0 -5
- package/dist/hyper/jsx-runtime.js +0 -14
- package/dist/index.js +0 -8
- package/dist/node/NodeFileSystem.js +0 -675
- package/dist/node/NodeUtils.js +0 -23
- package/dist/sql/Sql.js +0 -8
- package/dist/sql/bun/index.js +0 -142
- package/dist/sql/index.js +0 -1
- package/dist/sql/libsql/index.js +0 -156
- package/dist/sql/mssql/docker.js +0 -110
- package/dist/sql/mssql/index.js +0 -194
- package/dist/testing/TestLogger.js +0 -42
- package/dist/testing/index.js +0 -2
- package/dist/testing/utils.js +0 -61
- package/dist/x/cloudflare/CloudflareTunnel.js +0 -63
- package/dist/x/cloudflare/index.js +0 -1
- package/dist/x/tailscale/TailscaleTunnel.js +0 -94
- package/dist/x/tailscale/index.js +0 -1
- package/dist/x/tailwind/TailwindPlugin.js +0 -294
- package/dist/x/tailwind/compile.js +0 -210
- package/dist/x/tailwind/plugin.js +0 -17
package/dist/Http.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import * as Values from "./Values.js"
|
|
2
|
-
|
|
3
|
-
export function fetch(
|
|
4
|
-
handler,
|
|
5
|
-
init,
|
|
6
|
-
) {
|
|
7
|
-
const url = "path" in init ? `http://localhost${init.path}` : init.url
|
|
8
|
-
|
|
9
|
-
const isPlain = Values.isPlainObject(init.body)
|
|
10
|
-
|
|
11
|
-
const headers = new Headers(init.headers)
|
|
12
|
-
if (isPlain && !headers.has("Content-Type")) {
|
|
13
|
-
headers.set("Content-Type", "application/json")
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const body = isPlain ? JSON.stringify(init.body) : init.body
|
|
17
|
-
|
|
18
|
-
const request = new Request(url, {
|
|
19
|
-
...init,
|
|
20
|
-
headers,
|
|
21
|
-
body: body,
|
|
22
|
-
})
|
|
23
|
-
return Promise.resolve(handler(request))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function createAbortableRequest(
|
|
27
|
-
init,
|
|
28
|
-
) {
|
|
29
|
-
const url = "path" in init ? `http://localhost${init.path}` : init.url
|
|
30
|
-
const controller = new AbortController()
|
|
31
|
-
const request = new Request(url, { ...init, signal: controller.signal })
|
|
32
|
-
return { request, abort: () => controller.abort() }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function mapHeaders(headers) {
|
|
36
|
-
const result = {}
|
|
37
|
-
headers.forEach((value, key) => {
|
|
38
|
-
result[key.toLowerCase()] = value
|
|
39
|
-
})
|
|
40
|
-
return result
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function parseCookies(cookieHeader) {
|
|
44
|
-
if (!cookieHeader) return {}
|
|
45
|
-
const result = {}
|
|
46
|
-
for (const part of cookieHeader.split(";")) {
|
|
47
|
-
const idx = part.indexOf("=")
|
|
48
|
-
if (idx === -1) {
|
|
49
|
-
// Cookie without value (e.g., "name" or just whitespace)
|
|
50
|
-
const key = part.trim()
|
|
51
|
-
if (key) {
|
|
52
|
-
result[key] = undefined
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
const key = part.slice(0, idx).trim()
|
|
56
|
-
const value = part.slice(idx + 1).trim()
|
|
57
|
-
if (key) {
|
|
58
|
-
result[key] = value
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return result
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function mapUrlSearchParams(
|
|
66
|
-
params,
|
|
67
|
-
) {
|
|
68
|
-
const result = {}
|
|
69
|
-
for (const key of new Set(params.keys())) {
|
|
70
|
-
const values = params.getAll(key)
|
|
71
|
-
result[key] = values.length === 1 ? values[0] : values
|
|
72
|
-
}
|
|
73
|
-
return result
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export async function parseFormData(
|
|
77
|
-
request,
|
|
78
|
-
) {
|
|
79
|
-
const formData = await request.formData()
|
|
80
|
-
const result = {}
|
|
81
|
-
|
|
82
|
-
for (const key of new Set(formData.keys())) {
|
|
83
|
-
const values = formData.getAll(key)
|
|
84
|
-
const first = values[0]
|
|
85
|
-
|
|
86
|
-
if (typeof first === "string") {
|
|
87
|
-
result[key] = values.length === 1 ? first : (values)
|
|
88
|
-
} else {
|
|
89
|
-
const files = []
|
|
90
|
-
for (const value of values) {
|
|
91
|
-
if (typeof value !== "string") {
|
|
92
|
-
const content = new Uint8Array(await value.arrayBuffer())
|
|
93
|
-
files.push({
|
|
94
|
-
_tag: "File",
|
|
95
|
-
key,
|
|
96
|
-
name: value.name,
|
|
97
|
-
contentType: value.type || "application/octet-stream",
|
|
98
|
-
content,
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
result[key] = files
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return result
|
|
107
|
-
}
|
package/dist/PathPattern.js
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function isValidSegment(segment) {
|
|
4
|
-
if (segment.startsWith(":")) {
|
|
5
|
-
const rest = segment.slice(1)
|
|
6
|
-
if (rest.endsWith("*") || rest.endsWith("+") || rest.endsWith("?")) {
|
|
7
|
-
const name = rest.slice(0, -1)
|
|
8
|
-
return name !== "" && /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)
|
|
9
|
-
}
|
|
10
|
-
return rest !== "" && /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(rest)
|
|
11
|
-
}
|
|
12
|
-
return /^[\p{L}\p{N}._~-]+$/u.test(segment)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function validate(path) {
|
|
16
|
-
const segments = path.split("/").filter(Boolean)
|
|
17
|
-
for (const segment of segments) {
|
|
18
|
-
if (!isValidSegment(segment)) {
|
|
19
|
-
return {
|
|
20
|
-
ok: false,
|
|
21
|
-
error: `Invalid segment "${segment}" in "${path}"`,
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return { ok: true, segments }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function match(pattern, path) {
|
|
29
|
-
const patternSegments = pattern.split("/").filter(Boolean)
|
|
30
|
-
const pathSegments = path.split("/").filter(Boolean)
|
|
31
|
-
const params = {}
|
|
32
|
-
let patternIndex = 0
|
|
33
|
-
let pathIndex = 0
|
|
34
|
-
|
|
35
|
-
while (patternIndex < patternSegments.length) {
|
|
36
|
-
const seg = patternSegments[patternIndex]
|
|
37
|
-
|
|
38
|
-
if (seg.startsWith(":")) {
|
|
39
|
-
const rest = seg.slice(1)
|
|
40
|
-
|
|
41
|
-
if (rest.endsWith("+")) {
|
|
42
|
-
const name = rest.slice(0, -1)
|
|
43
|
-
const remaining = pathSegments.slice(pathIndex)
|
|
44
|
-
if (remaining.length === 0) {
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
params[name] = remaining.join("/")
|
|
48
|
-
return params
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (rest.endsWith("*")) {
|
|
52
|
-
const name = rest.slice(0, -1)
|
|
53
|
-
const remaining = pathSegments.slice(pathIndex)
|
|
54
|
-
if (remaining.length > 0) {
|
|
55
|
-
params[name] = remaining.join("/")
|
|
56
|
-
}
|
|
57
|
-
return params
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (rest.endsWith("?")) {
|
|
61
|
-
const name = rest.slice(0, -1)
|
|
62
|
-
if (pathIndex < pathSegments.length) {
|
|
63
|
-
params[name] = pathSegments[pathIndex]
|
|
64
|
-
pathIndex++
|
|
65
|
-
}
|
|
66
|
-
patternIndex++
|
|
67
|
-
continue
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (pathIndex >= pathSegments.length) {
|
|
71
|
-
return null
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
params[rest] = pathSegments[pathIndex]
|
|
75
|
-
pathIndex++
|
|
76
|
-
patternIndex++
|
|
77
|
-
continue
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (pathIndex >= pathSegments.length) {
|
|
81
|
-
return null
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (seg !== pathSegments[pathIndex]) {
|
|
85
|
-
return null
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
pathIndex++
|
|
89
|
-
patternIndex++
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (pathIndex !== pathSegments.length) {
|
|
93
|
-
return null
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return params
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function toRegex(path) {
|
|
100
|
-
const result = path
|
|
101
|
-
.replace(/\/+(\/|$)/g, "$1")
|
|
102
|
-
.replace(/\./g, "\\.")
|
|
103
|
-
.replace(/(\/?):(\w+)\+/g, "($1(?<$2>*))")
|
|
104
|
-
.replace(/(\/?):(\w+)\*/g, "(?:\\/(?<$2>.*))?")
|
|
105
|
-
.replace(/(\/?):(\w+)/g, "($1(?<$2>[^$1/]+?))")
|
|
106
|
-
.replace(/(\/?)\*/g, "($1.*)?")
|
|
107
|
-
|
|
108
|
-
return new RegExp(`^${result}/*$`)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function getModifier(seg) {
|
|
112
|
-
const last = seg[seg.length - 1]
|
|
113
|
-
if (last === "?" || last === "*" || last === "+") return last
|
|
114
|
-
return ""
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function getParamName(seg) {
|
|
118
|
-
const modifier = getModifier(seg)
|
|
119
|
-
return modifier ? seg.slice(1, -1) : seg.slice(1)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Converts to Express path pattern.
|
|
124
|
-
*
|
|
125
|
-
* @see https://expressjs.com/en/guide/routing.html
|
|
126
|
-
*
|
|
127
|
-
* - `:param` → `:param`
|
|
128
|
-
* - `:param?` → `{/:param}`
|
|
129
|
-
* - `:param+` → `/*param`
|
|
130
|
-
* - `:param*` → `/`, `/*param`
|
|
131
|
-
*/
|
|
132
|
-
export function toExpress(path) {
|
|
133
|
-
const segments = path.split("/").filter(Boolean)
|
|
134
|
-
const optionalWildcardIndex = segments.findIndex((s) => s.startsWith(":") && s.endsWith("*"))
|
|
135
|
-
|
|
136
|
-
if (optionalWildcardIndex !== -1) {
|
|
137
|
-
const before = segments.slice(0, optionalWildcardIndex)
|
|
138
|
-
const rest = segments[optionalWildcardIndex]
|
|
139
|
-
const name = getParamName(rest)
|
|
140
|
-
const beforeJoined = before
|
|
141
|
-
.map((s) => (s.startsWith(":") ? `:${getParamName(s)}` : s))
|
|
142
|
-
.join("/")
|
|
143
|
-
const basePath = beforeJoined ? "/" + beforeJoined : "/"
|
|
144
|
-
const withWildcard = basePath === "/" ? `/*${name}` : basePath + `/*${name}`
|
|
145
|
-
return [basePath, withWildcard]
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let result = ""
|
|
149
|
-
for (const seg of segments) {
|
|
150
|
-
if (!seg.startsWith(":")) {
|
|
151
|
-
result += "/" + seg
|
|
152
|
-
} else {
|
|
153
|
-
const name = getParamName(seg)
|
|
154
|
-
const modifier = getModifier(seg)
|
|
155
|
-
switch (modifier) {
|
|
156
|
-
case "":
|
|
157
|
-
result += `/:${name}`
|
|
158
|
-
break
|
|
159
|
-
case "?":
|
|
160
|
-
result += `{/:${name}}`
|
|
161
|
-
break
|
|
162
|
-
case "+":
|
|
163
|
-
result += `/*${name}`
|
|
164
|
-
break
|
|
165
|
-
case "*":
|
|
166
|
-
result += `/*${name}`
|
|
167
|
-
break
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return [result || "/"]
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Converts to URLPattern path pattern.
|
|
176
|
-
*
|
|
177
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API
|
|
178
|
-
*
|
|
179
|
-
* - `:param` → `:param`
|
|
180
|
-
* - `:param?` → `:param?`
|
|
181
|
-
* - `:param+` → `:param+`
|
|
182
|
-
* - `:param*` → `:param*`
|
|
183
|
-
*/
|
|
184
|
-
export function toURLPattern(path) {
|
|
185
|
-
const segments = path.split("/").filter(Boolean)
|
|
186
|
-
const joined = segments
|
|
187
|
-
.map((seg) => {
|
|
188
|
-
if (!seg.startsWith(":")) return seg
|
|
189
|
-
const name = getParamName(seg)
|
|
190
|
-
const modifier = getModifier(seg)
|
|
191
|
-
return `:${name}${modifier}`
|
|
192
|
-
})
|
|
193
|
-
.join("/")
|
|
194
|
-
return [joined ? "/" + joined : "/"]
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Converts to React Router path pattern.
|
|
199
|
-
*
|
|
200
|
-
* @see https://reactrouter.com/start/framework/routing
|
|
201
|
-
*
|
|
202
|
-
* - `:param` → `:param`
|
|
203
|
-
* - `:param?` → `:param?`
|
|
204
|
-
* - `:param+` → `*` (splat, required)
|
|
205
|
-
* - `:param*` → `/`, `/*` (splat, optional - two routes)
|
|
206
|
-
*/
|
|
207
|
-
export function toReactRouter(path) {
|
|
208
|
-
const segments = path.split("/").filter(Boolean)
|
|
209
|
-
const optionalWildcardIndex = segments.findIndex((s) => s.startsWith(":") && s.endsWith("*"))
|
|
210
|
-
|
|
211
|
-
if (optionalWildcardIndex !== -1) {
|
|
212
|
-
const before = segments.slice(0, optionalWildcardIndex)
|
|
213
|
-
const beforeJoined = before
|
|
214
|
-
.map((s) => {
|
|
215
|
-
if (!s.startsWith(":")) return s
|
|
216
|
-
const name = getParamName(s)
|
|
217
|
-
const modifier = getModifier(s)
|
|
218
|
-
return modifier === "?" ? `:${name}?` : `:${name}`
|
|
219
|
-
})
|
|
220
|
-
.join("/")
|
|
221
|
-
const basePath = beforeJoined ? "/" + beforeJoined : "/"
|
|
222
|
-
const withWildcard = basePath === "/" ? "/*" : basePath + "/*"
|
|
223
|
-
return [basePath, withWildcard]
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const joined = segments
|
|
227
|
-
.map((s) => {
|
|
228
|
-
if (!s.startsWith(":")) return s
|
|
229
|
-
const name = getParamName(s)
|
|
230
|
-
const modifier = getModifier(s)
|
|
231
|
-
switch (modifier) {
|
|
232
|
-
case "":
|
|
233
|
-
return `:${name}`
|
|
234
|
-
case "?":
|
|
235
|
-
return `:${name}?`
|
|
236
|
-
case "+":
|
|
237
|
-
case "*":
|
|
238
|
-
return "*"
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
.join("/")
|
|
242
|
-
return [joined ? "/" + joined : "/"]
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Alias for toReactRouter.
|
|
247
|
-
*
|
|
248
|
-
* @see https://reactrouter.com/start/framework/routing
|
|
249
|
-
*/
|
|
250
|
-
export const toRemix = toReactRouter
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Converts to Remix file-based route naming convention.
|
|
254
|
-
*
|
|
255
|
-
* Returns a file path segment (without extension) for Remix's
|
|
256
|
-
* flat file routing convention.
|
|
257
|
-
*
|
|
258
|
-
* @see https://remix.run/docs/file-conventions/routes
|
|
259
|
-
*
|
|
260
|
-
* - `:param` → `$param`
|
|
261
|
-
* - `:param?` → `($param)`
|
|
262
|
-
* - `:param+` → `$` (splat)
|
|
263
|
-
* - `:param*` → `($)` (optional splat) - Note: not officially supported
|
|
264
|
-
*/
|
|
265
|
-
export function toRemixFile(path) {
|
|
266
|
-
const segments = path.split("/").filter(Boolean)
|
|
267
|
-
|
|
268
|
-
const mapped = segments.map((seg) => {
|
|
269
|
-
if (!seg.startsWith(":")) return seg
|
|
270
|
-
const name = getParamName(seg)
|
|
271
|
-
const modifier = getModifier(seg)
|
|
272
|
-
switch (modifier) {
|
|
273
|
-
case "":
|
|
274
|
-
return `$${name}`
|
|
275
|
-
case "?":
|
|
276
|
-
return `($${name})`
|
|
277
|
-
case "+":
|
|
278
|
-
return "$"
|
|
279
|
-
case "*":
|
|
280
|
-
return "($)"
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
return mapped.join(".")
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Converts to TanStack Router path/file pattern.
|
|
289
|
-
*
|
|
290
|
-
* TanStack uses the same `$param` syntax for both route paths and file names.
|
|
291
|
-
* Returns a dot-separated file name (without extension).
|
|
292
|
-
*
|
|
293
|
-
* @see https://tanstack.com/router/v1/docs/framework/react/guide/path-params
|
|
294
|
-
* @see https://tanstack.com/router/v1/docs/framework/react/routing/file-naming-conventions
|
|
295
|
-
*
|
|
296
|
-
* - `:param` → `$param`
|
|
297
|
-
* - `:param?` → `{-$param}` (optional segment)
|
|
298
|
-
* - `:param+` → `$` (splat)
|
|
299
|
-
* - `:param*` → `$` (splat, optional not supported - treated as required)
|
|
300
|
-
*/
|
|
301
|
-
export function toTanStack(path) {
|
|
302
|
-
const segments = path.split("/").filter(Boolean)
|
|
303
|
-
|
|
304
|
-
const mapped = segments.map((seg) => {
|
|
305
|
-
if (!seg.startsWith(":")) return seg
|
|
306
|
-
const name = getParamName(seg)
|
|
307
|
-
const modifier = getModifier(seg)
|
|
308
|
-
switch (modifier) {
|
|
309
|
-
case "":
|
|
310
|
-
return `$${name}`
|
|
311
|
-
case "?":
|
|
312
|
-
return `{-$${name}}`
|
|
313
|
-
case "+":
|
|
314
|
-
return "$"
|
|
315
|
-
case "*":
|
|
316
|
-
return "$"
|
|
317
|
-
}
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
return mapped.join(".")
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Converts to Hono path pattern.
|
|
325
|
-
*
|
|
326
|
-
* Hono uses unnamed wildcards - they are NOT accessible via c.req.param().
|
|
327
|
-
* Use c.req.path to access the matched path for wildcard routes.
|
|
328
|
-
*
|
|
329
|
-
* @see https://hono.dev/docs/api/routing
|
|
330
|
-
*
|
|
331
|
-
* - `:param` → `:param`
|
|
332
|
-
* - `:param?` → `:param?`
|
|
333
|
-
* - `:param+` → `*` (unnamed, required)
|
|
334
|
-
* - `:param*` → `/`, `/*` (unnamed, optional - two routes)
|
|
335
|
-
*/
|
|
336
|
-
export function toHono(path) {
|
|
337
|
-
const segments = path.split("/").filter(Boolean)
|
|
338
|
-
const optionalWildcardIndex = segments.findIndex((s) => s.startsWith(":") && s.endsWith("*"))
|
|
339
|
-
|
|
340
|
-
if (optionalWildcardIndex !== -1) {
|
|
341
|
-
const before = segments.slice(0, optionalWildcardIndex)
|
|
342
|
-
const beforeJoined = before
|
|
343
|
-
.map((s) => {
|
|
344
|
-
if (!s.startsWith(":")) return s
|
|
345
|
-
const name = getParamName(s)
|
|
346
|
-
const modifier = getModifier(s)
|
|
347
|
-
return modifier === "?" ? `:${name}?` : `:${name}`
|
|
348
|
-
})
|
|
349
|
-
.join("/")
|
|
350
|
-
const basePath = beforeJoined ? "/" + beforeJoined : "/"
|
|
351
|
-
const withWildcard = basePath === "/" ? "/*" : basePath + "/*"
|
|
352
|
-
return [basePath, withWildcard]
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const joined = segments
|
|
356
|
-
.map((s) => {
|
|
357
|
-
if (!s.startsWith(":")) return s
|
|
358
|
-
const name = getParamName(s)
|
|
359
|
-
const modifier = getModifier(s)
|
|
360
|
-
switch (modifier) {
|
|
361
|
-
case "":
|
|
362
|
-
return `:${name}`
|
|
363
|
-
case "?":
|
|
364
|
-
return `:${name}?`
|
|
365
|
-
case "+":
|
|
366
|
-
case "*":
|
|
367
|
-
return "*"
|
|
368
|
-
}
|
|
369
|
-
})
|
|
370
|
-
.join("/")
|
|
371
|
-
return [joined ? "/" + joined : "/"]
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Converts to Effect HttpRouter / find-my-way path pattern.
|
|
376
|
-
*
|
|
377
|
-
* Effect uses colon-style params with unnamed wildcards.
|
|
378
|
-
*
|
|
379
|
-
* @see https://effect.website/docs/platform/http-router
|
|
380
|
-
*
|
|
381
|
-
* - `:param` → `:param`
|
|
382
|
-
* - `:param?` → `:param?`
|
|
383
|
-
* - `:param+` → `*` (unnamed)
|
|
384
|
-
* - `:param*` → `/`, `/*` (two routes)
|
|
385
|
-
*/
|
|
386
|
-
export function toEffect(path) {
|
|
387
|
-
return toHono(path)
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Converts to Bun.serve path pattern.
|
|
392
|
-
*
|
|
393
|
-
* Since Bun doesn't support optional params (`:param?`), optional segments
|
|
394
|
-
* are expanded into multiple routes.
|
|
395
|
-
*
|
|
396
|
-
* @see https://bun.sh/docs/api/http#routing
|
|
397
|
-
*
|
|
398
|
-
* - `:param` → `:param`
|
|
399
|
-
* - `:param?` → `/`, `/:param` (two routes)
|
|
400
|
-
* - `:param+` → `/*`
|
|
401
|
-
* - `:param*` → `/`, `/*` (two routes)
|
|
402
|
-
*/
|
|
403
|
-
export function toBun(path) {
|
|
404
|
-
const segments = path.split("/").filter(Boolean)
|
|
405
|
-
|
|
406
|
-
const optionalIndex = segments.findIndex(
|
|
407
|
-
(s) => s.startsWith(":") && (s.endsWith("?") || s.endsWith("*")),
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
if (optionalIndex === -1) {
|
|
411
|
-
const joined = segments
|
|
412
|
-
.map((s) => {
|
|
413
|
-
if (!s.startsWith(":")) return s
|
|
414
|
-
const modifier = getModifier(s)
|
|
415
|
-
const name = getParamName(s)
|
|
416
|
-
return modifier === "+" || modifier === "*" ? "*" : `:${name}`
|
|
417
|
-
})
|
|
418
|
-
.join("/")
|
|
419
|
-
return [joined ? `/${joined}` : "/"]
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const before = segments.slice(0, optionalIndex)
|
|
423
|
-
const optional = segments[optionalIndex]
|
|
424
|
-
const after = segments.slice(optionalIndex + 1)
|
|
425
|
-
|
|
426
|
-
const formatSegment = (s) => {
|
|
427
|
-
if (!s.startsWith(":")) return s
|
|
428
|
-
const modifier = getModifier(s)
|
|
429
|
-
const name = getParamName(s)
|
|
430
|
-
switch (modifier) {
|
|
431
|
-
case "":
|
|
432
|
-
case "?":
|
|
433
|
-
return `:${name}`
|
|
434
|
-
case "+":
|
|
435
|
-
case "*":
|
|
436
|
-
return "*"
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
const beforePath = before.map(formatSegment).join("/")
|
|
441
|
-
const basePath = beforePath ? `/${beforePath}` : "/"
|
|
442
|
-
|
|
443
|
-
const optionalModifier = getModifier(optional)
|
|
444
|
-
const optionalName = getParamName(optional)
|
|
445
|
-
const requiredOptional = optionalModifier === "*" ? `:${optionalName}+` : `:${optionalName}`
|
|
446
|
-
|
|
447
|
-
const withOptionalSegments = [...before, requiredOptional, ...after]
|
|
448
|
-
const withOptionalPath = `/${withOptionalSegments.map(formatSegment).join("/")}`
|
|
449
|
-
|
|
450
|
-
return [...toBun(basePath), ...toBun(withOptionalPath)]
|
|
451
|
-
}
|
package/dist/PlatformError.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Adapted from @effect/platform
|
|
3
|
-
*/
|
|
4
|
-
import * as Data from "effect/Data"
|
|
5
|
-
import * as Predicate from "effect/Predicate"
|
|
6
|
-
|
|
7
|
-
export const TypeId = Symbol.for("@effect/platform/Error/PlatformError")
|
|
8
|
-
|
|
9
|
-
export const isPlatformError = (u) => Predicate.hasProperty(u, TypeId)
|
|
10
|
-
|
|
11
|
-
export const TypeIdError = (
|
|
12
|
-
typeId,
|
|
13
|
-
tag,
|
|
14
|
-
) => {
|
|
15
|
-
class Base extends Data.Error {
|
|
16
|
-
_tag = tag
|
|
17
|
-
}
|
|
18
|
-
;(Base.prototype)[typeId] = typeId
|
|
19
|
-
;(Base.prototype).name = tag
|
|
20
|
-
return Base
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class BadArgument extends Data.TaggedError("BadArgument") {
|
|
24
|
-
[TypeId] = TypeId
|
|
25
|
-
|
|
26
|
-
get message() {
|
|
27
|
-
return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class SystemError extends Data.TaggedError("SystemError") {
|
|
32
|
-
[TypeId] = TypeId
|
|
33
|
-
|
|
34
|
-
get message() {
|
|
35
|
-
return `${this.reason}: ${this.module}.${this.method}${
|
|
36
|
-
this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""
|
|
37
|
-
}${this.description ? `: ${this.description}` : ""}`
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
package/dist/PlatformRuntime.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as Cause from "effect/Cause"
|
|
2
|
-
import * as Effect from "effect/Effect"
|
|
3
|
-
import * as Exit from "effect/Exit"
|
|
4
|
-
import * as FiberRef from "effect/FiberRef"
|
|
5
|
-
import * as FiberRefs from "effect/FiberRefs"
|
|
6
|
-
import * as Function from "effect/Function"
|
|
7
|
-
import * as HashSet from "effect/HashSet"
|
|
8
|
-
import * as Logger from "effect/Logger"
|
|
9
|
-
|
|
10
|
-
export const defaultTeardown = (
|
|
11
|
-
exit,
|
|
12
|
-
onExit,
|
|
13
|
-
) => {
|
|
14
|
-
onExit(Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause) ? 1 : 0)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const addPrettyLogger = (refs, fiberId) => {
|
|
18
|
-
const loggers = FiberRefs.getOrDefault(refs, FiberRef.currentLoggers)
|
|
19
|
-
if (!HashSet.has(loggers, Logger.defaultLogger)) {
|
|
20
|
-
return refs
|
|
21
|
-
}
|
|
22
|
-
return FiberRefs.updateAs(refs, {
|
|
23
|
-
fiberId,
|
|
24
|
-
fiberRef: FiberRef.currentLoggers,
|
|
25
|
-
value: loggers.pipe(
|
|
26
|
-
HashSet.remove(Logger.defaultLogger),
|
|
27
|
-
HashSet.add(Logger.prettyLoggerDefault),
|
|
28
|
-
),
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const makeRunMain = (
|
|
33
|
-
f,
|
|
34
|
-
) =>
|
|
35
|
-
Function.dual(
|
|
36
|
-
(args) => Effect.isEffect(args[0]),
|
|
37
|
-
(
|
|
38
|
-
effect,
|
|
39
|
-
options,
|
|
40
|
-
) => {
|
|
41
|
-
const fiber =
|
|
42
|
-
options?.disableErrorReporting === true
|
|
43
|
-
? Effect.runFork(effect, {
|
|
44
|
-
updateRefs: options?.disablePrettyLogger === true ? undefined : addPrettyLogger,
|
|
45
|
-
})
|
|
46
|
-
: Effect.runFork(
|
|
47
|
-
Effect.tapErrorCause(effect, (cause) => {
|
|
48
|
-
if (Cause.isInterruptedOnly(cause)) {
|
|
49
|
-
return Effect.void
|
|
50
|
-
}
|
|
51
|
-
return Effect.logError(cause)
|
|
52
|
-
}),
|
|
53
|
-
{
|
|
54
|
-
updateRefs: options?.disablePrettyLogger === true ? undefined : addPrettyLogger,
|
|
55
|
-
},
|
|
56
|
-
)
|
|
57
|
-
const teardown = options?.teardown ?? defaultTeardown
|
|
58
|
-
return f({ fiber, teardown })
|
|
59
|
-
},
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Are we running within an agent harness, like Claude Code?
|
|
64
|
-
*/
|
|
65
|
-
export function isAgentHarness() {
|
|
66
|
-
return (
|
|
67
|
-
typeof process !== "undefined" &&
|
|
68
|
-
!process.stdout.isTTY &&
|
|
69
|
-
(process.env.CLAUDECODE || process.env.CURSOR_AGENT)
|
|
70
|
-
)
|
|
71
|
-
}
|