effect-start 0.22.0 → 0.23.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.
Files changed (313) hide show
  1. package/dist/BlobStore.d.ts +80 -0
  2. package/dist/BlobStore.js +19 -0
  3. package/dist/ChildProcess.d.ts +60 -0
  4. package/dist/ChildProcess.js +30 -0
  5. package/dist/Commander.d.ts +3 -6
  6. package/dist/Commander.js +6 -13
  7. package/dist/ContentNegotiation.d.ts +8 -9
  8. package/dist/ContentNegotiation.js +32 -37
  9. package/dist/Cookies.d.ts +47 -0
  10. package/dist/Cookies.js +273 -363
  11. package/dist/Development.d.ts +2 -2
  12. package/dist/Development.js +3 -4
  13. package/dist/Effectify.d.ts +1 -4
  14. package/dist/FilePathPattern.d.ts +3 -3
  15. package/dist/FileRouter.d.ts +5 -8
  16. package/dist/FileRouter.js +9 -10
  17. package/dist/FileRouterCodegen.d.ts +1 -1
  18. package/dist/FileRouterCodegen.js +33 -13
  19. package/dist/FileSystem.d.ts +158 -0
  20. package/dist/FileSystem.js +64 -125
  21. package/dist/Http.js +2 -6
  22. package/dist/PathPattern.d.ts +7 -7
  23. package/dist/PathPattern.js +1 -3
  24. package/dist/PlatformError.d.ts +24 -32
  25. package/dist/PlatformError.js +3 -21
  26. package/dist/PlatformRuntime.js +5 -10
  27. package/dist/Route.d.ts +14 -19
  28. package/dist/Route.js +8 -11
  29. package/dist/RouteBody.d.ts +6 -12
  30. package/dist/RouteBody.js +2 -2
  31. package/dist/RouteError.d.ts +98 -0
  32. package/dist/RouteError.js +55 -0
  33. package/dist/RouteHook.js +6 -11
  34. package/dist/RouteHttp.d.ts +3 -3
  35. package/dist/RouteHttp.js +27 -22
  36. package/dist/RouteMount.d.ts +16 -50
  37. package/dist/RouteMount.js +6 -20
  38. package/dist/RouteSchema.d.ts +22 -1
  39. package/dist/RouteSchema.js +33 -0
  40. package/dist/RouteSse.js +4 -10
  41. package/dist/RouteTree.d.ts +2 -1
  42. package/dist/RouteTree.js +17 -15
  43. package/dist/RouteTrie.d.ts +2 -2
  44. package/dist/RouteTrie.js +4 -9
  45. package/dist/SchemaExtra.d.ts +1 -1
  46. package/dist/Socket.d.ts +27 -0
  47. package/dist/Socket.js +20 -28
  48. package/dist/Sql.d.ts +34 -0
  49. package/dist/Sql.js +5 -0
  50. package/dist/SqlIntrospect.d.ts +91 -0
  51. package/dist/SqlIntrospect.js +466 -0
  52. package/dist/Start.d.ts +4 -6
  53. package/dist/Start.js +10 -2
  54. package/dist/StreamExtra.d.ts +1 -1
  55. package/dist/StreamExtra.js +9 -9
  56. package/dist/System.d.ts +7 -0
  57. package/dist/System.js +22 -0
  58. package/dist/TuplePathPattern.js +55 -50
  59. package/dist/Unique.js +7 -7
  60. package/dist/Values.d.ts +2 -1
  61. package/dist/Values.js +19 -13
  62. package/dist/bun/BunBlobStoreDisk.d.ts +6 -0
  63. package/dist/bun/BunBlobStoreDisk.js +116 -0
  64. package/dist/bun/BunBlobStoreS3.d.ts +11 -0
  65. package/dist/bun/BunBlobStoreS3.js +89 -0
  66. package/dist/bun/BunBlobWatcherDisk.d.ts +6 -0
  67. package/dist/bun/BunBlobWatcherDisk.js +60 -0
  68. package/dist/bun/BunBlobWatcherQueue.d.ts +6 -0
  69. package/dist/bun/BunBlobWatcherQueue.js +17 -0
  70. package/dist/bun/BunBundle.d.ts +5 -6
  71. package/dist/bun/BunBundle.js +7 -15
  72. package/dist/bun/BunChildProcessSpawner.d.ts +3 -0
  73. package/dist/bun/BunChildProcessSpawner.js +103 -0
  74. package/dist/bun/BunImportTrackerPlugin.d.ts +1 -1
  75. package/dist/bun/BunImportTrackerPlugin.js +3 -5
  76. package/dist/bun/BunRoute.d.ts +3 -2
  77. package/dist/bun/BunRoute.js +5 -7
  78. package/dist/bun/BunRuntime.js +1 -1
  79. package/dist/bun/BunServer.d.ts +11 -4
  80. package/dist/bun/BunServer.js +35 -11
  81. package/dist/bun/BunSql.d.ts +4 -0
  82. package/dist/bun/BunSql.js +81 -0
  83. package/dist/bun/_BunEnhancedResolve.d.ts +3 -3
  84. package/dist/bun/_BunEnhancedResolve.js +2 -4
  85. package/dist/bun/index.d.ts +1 -0
  86. package/dist/bun/index.js +1 -0
  87. package/dist/bundler/Bundle.d.ts +2 -1
  88. package/dist/bundler/Bundle.js +1 -1
  89. package/dist/bundler/BundleFiles.d.ts +5 -5
  90. package/dist/bundler/BundleFiles.js +10 -8
  91. package/dist/bundler/BundleRoute.d.ts +27 -0
  92. package/dist/bundler/BundleRoute.js +51 -0
  93. package/dist/client/ScrollState.js +2 -6
  94. package/dist/client/index.js +6 -8
  95. package/dist/console/Console.d.ts +6 -0
  96. package/dist/console/Console.js +26 -0
  97. package/dist/console/ConsoleErrors.d.ts +3 -0
  98. package/dist/console/ConsoleErrors.js +200 -0
  99. package/dist/console/ConsoleLogger.d.ts +3 -0
  100. package/dist/console/ConsoleLogger.js +47 -0
  101. package/dist/console/ConsoleMetrics.d.ts +3 -0
  102. package/dist/console/ConsoleMetrics.js +61 -0
  103. package/dist/console/ConsoleProcess.d.ts +3 -0
  104. package/dist/console/ConsoleProcess.js +49 -0
  105. package/dist/console/ConsoleStore.d.ts +144 -0
  106. package/dist/console/ConsoleStore.js +61 -0
  107. package/dist/console/ConsoleTracer.d.ts +3 -0
  108. package/dist/console/ConsoleTracer.js +94 -0
  109. package/dist/console/Simulation.d.ts +2 -0
  110. package/dist/console/Simulation.js +633 -0
  111. package/dist/console/index.d.ts +3 -0
  112. package/dist/console/index.js +3 -0
  113. package/dist/console/routes/errors/route.d.ts +10 -0
  114. package/dist/console/routes/errors/route.js +47 -0
  115. package/dist/console/routes/fiberDetail.d.ts +16 -0
  116. package/dist/console/routes/fiberDetail.js +38 -0
  117. package/dist/console/routes/fibers/route.d.ts +10 -0
  118. package/dist/console/routes/fibers/route.js +19 -0
  119. package/dist/console/routes/git/route.d.ts +11 -0
  120. package/dist/console/routes/git/route.js +33 -0
  121. package/dist/console/routes/layout.d.ts +9 -0
  122. package/dist/console/routes/layout.js +3 -0
  123. package/dist/console/routes/logs/route.d.ts +10 -0
  124. package/dist/console/routes/logs/route.js +32 -0
  125. package/dist/console/routes/metrics/route.d.ts +10 -0
  126. package/dist/console/routes/metrics/route.js +17 -0
  127. package/dist/console/routes/route.d.ts +6 -0
  128. package/dist/console/routes/route.js +5 -0
  129. package/dist/console/routes/routes/route.d.ts +6 -0
  130. package/dist/console/routes/routes/route.js +20 -0
  131. package/dist/console/routes/services/route.d.ts +6 -0
  132. package/dist/console/routes/services/route.js +12 -0
  133. package/dist/console/routes/system/route.d.ts +10 -0
  134. package/dist/console/routes/system/route.js +18 -0
  135. package/dist/console/routes/traceDetail.d.ts +16 -0
  136. package/dist/console/routes/traceDetail.js +14 -0
  137. package/dist/console/routes/traces/route.d.ts +10 -0
  138. package/dist/console/routes/traces/route.js +39 -0
  139. package/dist/console/routes/tree.d.ts +153 -0
  140. package/dist/console/routes/tree.js +29 -0
  141. package/dist/console/ui/Errors.d.ts +4 -0
  142. package/dist/console/ui/Errors.js +15 -0
  143. package/dist/console/ui/Fibers.d.ts +24 -0
  144. package/dist/console/ui/Fibers.js +121 -0
  145. package/dist/console/ui/Git.d.ts +20 -0
  146. package/dist/console/ui/Git.js +95 -0
  147. package/dist/console/ui/Logs.d.ts +4 -0
  148. package/dist/console/ui/Logs.js +25 -0
  149. package/dist/console/ui/Metrics.d.ts +4 -0
  150. package/dist/console/ui/Metrics.js +26 -0
  151. package/dist/console/ui/Routes.d.ts +8 -0
  152. package/dist/console/ui/Routes.js +70 -0
  153. package/dist/console/ui/Services.d.ts +10 -0
  154. package/dist/console/ui/Services.js +246 -0
  155. package/dist/console/ui/Shell.d.ts +10 -0
  156. package/dist/console/ui/Shell.js +7 -0
  157. package/dist/console/ui/System.d.ts +4 -0
  158. package/dist/console/ui/System.js +35 -0
  159. package/dist/console/ui/Traces.d.ts +12 -0
  160. package/dist/console/ui/Traces.js +179 -0
  161. package/dist/datastar/actions/fetch.d.ts +1 -1
  162. package/dist/datastar/actions/fetch.js +10 -18
  163. package/dist/datastar/actions/peek.js +1 -2
  164. package/dist/datastar/actions/setAll.js +1 -2
  165. package/dist/datastar/actions/toggleAll.js +1 -2
  166. package/dist/datastar/attributes/attr.js +1 -2
  167. package/dist/datastar/attributes/bind.js +10 -18
  168. package/dist/datastar/attributes/class.js +2 -5
  169. package/dist/datastar/attributes/computed.js +2 -3
  170. package/dist/datastar/attributes/effect.js +1 -2
  171. package/dist/datastar/attributes/indicator.js +2 -4
  172. package/dist/datastar/attributes/init.js +2 -3
  173. package/dist/datastar/attributes/jsonSignals.js +1 -2
  174. package/dist/datastar/attributes/on.js +41 -22
  175. package/dist/datastar/attributes/onIntersect.js +2 -3
  176. package/dist/datastar/attributes/onInterval.js +2 -3
  177. package/dist/datastar/attributes/onSignalPatch.js +2 -4
  178. package/dist/datastar/attributes/ref.js +1 -2
  179. package/dist/datastar/attributes/show.js +1 -2
  180. package/dist/datastar/attributes/signals.js +1 -2
  181. package/dist/datastar/attributes/style.js +6 -12
  182. package/dist/datastar/attributes/text.js +1 -2
  183. package/dist/datastar/engine.d.ts +13 -7
  184. package/dist/datastar/engine.js +76 -48
  185. package/dist/datastar/happydom.d.ts +1 -0
  186. package/dist/datastar/happydom.js +8 -0
  187. package/dist/datastar/index.d.ts +1 -1
  188. package/dist/datastar/index.js +1 -1
  189. package/dist/datastar/utils.js +4 -7
  190. package/dist/datastar/watchers/patchElements.js +24 -45
  191. package/dist/datastar/watchers/patchSignals.js +1 -2
  192. package/dist/experimental/EncryptedCookies.d.ts +2 -5
  193. package/dist/experimental/EncryptedCookies.js +17 -48
  194. package/dist/experimental/index.d.ts +0 -1
  195. package/dist/experimental/index.js +0 -1
  196. package/dist/hyper/Hyper.d.ts +2 -9
  197. package/dist/hyper/Hyper.js +1 -12
  198. package/dist/hyper/HyperHtml.d.ts +1 -1
  199. package/dist/hyper/HyperHtml.js +18 -12
  200. package/dist/hyper/HyperHtml.test.d.ts +1 -0
  201. package/dist/hyper/HyperHtml.test.js +197 -0
  202. package/dist/hyper/HyperRoute.test.js +14 -3
  203. package/dist/hyper/html.d.ts +11 -0
  204. package/dist/hyper/html.js +30 -0
  205. package/dist/hyper/index.d.ts +2 -0
  206. package/dist/hyper/index.js +1 -0
  207. package/dist/hyper/jsx-runtime.d.ts +1 -1
  208. package/dist/hyper/jsx-runtime.js +1 -1
  209. package/dist/index.d.ts +1 -0
  210. package/dist/index.js +1 -0
  211. package/dist/lint/plugin.d.ts +86 -0
  212. package/dist/lint/plugin.js +341 -0
  213. package/dist/node/NodeFileSystem.d.ts +2 -2
  214. package/dist/node/NodeFileSystem.js +4 -14
  215. package/dist/sql/bun/index.d.ts +3 -0
  216. package/dist/sql/bun/index.js +75 -0
  217. package/dist/sql/mssql/docker.d.ts +2 -0
  218. package/dist/sql/mssql/docker.js +67 -0
  219. package/dist/sql/mssql/index.d.ts +21 -0
  220. package/dist/sql/mssql/index.js +113 -0
  221. package/dist/testing/TestLogger.js +4 -1
  222. package/dist/testing/index.d.ts +0 -1
  223. package/dist/testing/index.js +0 -1
  224. package/dist/testing/utils.d.ts +3 -3
  225. package/dist/testing/utils.js +4 -4
  226. package/dist/x/cloudflare/CloudflareTunnel.d.ts +2 -5
  227. package/dist/x/cloudflare/CloudflareTunnel.js +14 -27
  228. package/dist/x/datastar/Datastar.d.ts +1 -1
  229. package/dist/x/datastar/Datastar.js +13 -12
  230. package/dist/x/datastar/index.d.ts +1 -2
  231. package/dist/x/datastar/index.js +1 -2
  232. package/dist/x/tailscale/TailscaleTunnel.d.ts +15 -0
  233. package/dist/x/tailscale/TailscaleTunnel.js +68 -0
  234. package/dist/x/tailscale/index.d.ts +1 -0
  235. package/dist/x/tailscale/index.js +1 -0
  236. package/dist/x/tailwind/TailwindPlugin.js +19 -19
  237. package/dist/x/tailwind/compile.d.ts +2 -2
  238. package/dist/x/tailwind/compile.js +2 -4
  239. package/package.json +22 -10
  240. package/src/ChildProcess.ts +145 -0
  241. package/src/PlatformError.ts +27 -50
  242. package/src/Route.ts +2 -2
  243. package/src/RouteError.ts +76 -0
  244. package/src/RouteHttp.ts +13 -5
  245. package/src/RouteSchema.ts +96 -1
  246. package/src/RouteTree.ts +12 -0
  247. package/src/Sql.ts +51 -0
  248. package/src/SqlIntrospect.ts +620 -0
  249. package/src/Start.ts +15 -3
  250. package/src/System.ts +43 -0
  251. package/src/Values.ts +7 -0
  252. package/src/bun/BunChildProcessSpawner.ts +143 -0
  253. package/src/bun/BunRoute.ts +5 -2
  254. package/src/bun/BunServer.ts +22 -1
  255. package/src/bun/index.ts +1 -0
  256. package/src/bundler/BundleRoute.ts +66 -0
  257. package/src/console/Console.ts +42 -0
  258. package/src/console/ConsoleErrors.ts +213 -0
  259. package/src/console/ConsoleLogger.ts +56 -0
  260. package/src/console/ConsoleMetrics.ts +72 -0
  261. package/src/console/ConsoleProcess.ts +59 -0
  262. package/src/console/ConsoleStore.ts +187 -0
  263. package/src/console/ConsoleTracer.ts +107 -0
  264. package/src/console/Simulation.ts +814 -0
  265. package/src/console/console.html +340 -0
  266. package/src/console/index.ts +3 -0
  267. package/src/console/routes/errors/route.tsx +97 -0
  268. package/src/console/routes/fiberDetail.tsx +54 -0
  269. package/src/console/routes/fibers/route.tsx +45 -0
  270. package/src/console/routes/git/route.tsx +64 -0
  271. package/src/console/routes/layout.tsx +4 -0
  272. package/src/console/routes/logs/route.tsx +77 -0
  273. package/src/console/routes/metrics/route.tsx +36 -0
  274. package/src/console/routes/route.tsx +8 -0
  275. package/src/console/routes/routes/route.tsx +30 -0
  276. package/src/console/routes/services/route.tsx +21 -0
  277. package/src/console/routes/system/route.tsx +43 -0
  278. package/src/console/routes/traceDetail.tsx +22 -0
  279. package/src/console/routes/traces/route.tsx +81 -0
  280. package/src/console/routes/tree.ts +30 -0
  281. package/src/console/ui/Errors.tsx +76 -0
  282. package/src/console/ui/Fibers.tsx +321 -0
  283. package/src/console/ui/Git.tsx +182 -0
  284. package/src/console/ui/Logs.tsx +46 -0
  285. package/src/console/ui/Metrics.tsx +78 -0
  286. package/src/console/ui/Routes.tsx +125 -0
  287. package/src/console/ui/Services.tsx +273 -0
  288. package/src/console/ui/Shell.tsx +62 -0
  289. package/src/console/ui/System.tsx +131 -0
  290. package/src/console/ui/Traces.tsx +426 -0
  291. package/src/datastar/README.md +6 -1
  292. package/src/datastar/actions/fetch.ts +0 -1
  293. package/src/datastar/attributes/on.ts +40 -20
  294. package/src/datastar/engine.ts +51 -0
  295. package/src/datastar/jsx.d.ts +79 -0
  296. package/src/hyper/Hyper.ts +1 -16
  297. package/src/hyper/HyperHtml.ts +6 -4
  298. package/src/hyper/HyperRoute.ts +2 -1
  299. package/src/hyper/html.ts +47 -0
  300. package/src/hyper/index.ts +2 -0
  301. package/src/hyper/jsx.d.ts +5 -3
  302. package/src/index.ts +1 -0
  303. package/src/lint/plugin.js +129 -0
  304. package/src/sql/bun/index.ts +147 -0
  305. package/src/sql/mssql/docker.ts +117 -0
  306. package/src/sql/mssql/index.ts +223 -0
  307. package/src/sql/mssql/mssql.d.ts +41 -0
  308. package/src/x/cloudflare/CloudflareTunnel.ts +8 -36
  309. package/src/x/tailscale/TailscaleTunnel.ts +113 -0
  310. package/src/x/tailscale/index.ts +1 -0
  311. package/src/x/datastar/Datastar.ts +0 -61
  312. package/src/x/datastar/index.ts +0 -2
  313. package/src/x/datastar/jsx-datastar.d.ts +0 -60
@@ -0,0 +1,8 @@
1
+ import { GlobalRegistrator } from "@happy-dom/global-registrator";
2
+ GlobalRegistrator.register();
3
+ // happy-dom doesn't define MathMLElement
4
+ if (typeof globalThis.MathMLElement === "undefined") {
5
+ ;
6
+ globalThis.MathMLElement = class MathMLElement extends HTMLElement {
7
+ };
8
+ }
@@ -1,4 +1,3 @@
1
- export * from "./engine.ts";
2
1
  import "./actions/peek.ts";
3
2
  import "./actions/setAll.ts";
4
3
  import "./actions/toggleAll.ts";
@@ -22,3 +21,4 @@ import "./attributes/style.ts";
22
21
  import "./attributes/text.ts";
23
22
  import "./watchers/patchElements.ts";
24
23
  import "./watchers/patchSignals.ts";
24
+ export * from "./engine.ts";
@@ -1,4 +1,3 @@
1
- export * from "./engine.js";
2
1
  import "./actions/peek.js";
3
2
  import "./actions/setAll.js";
4
3
  import "./actions/toggleAll.js";
@@ -22,3 +21,4 @@ import "./attributes/style.js";
22
21
  import "./attributes/text.js";
23
22
  import "./watchers/patchElements.js";
24
23
  import "./watchers/patchSignals.js";
24
+ export * from "./engine.js";
@@ -1,9 +1,7 @@
1
1
  /*********
2
2
  * dom.ts
3
3
  *********/
4
- export const isHTMLOrSVG = (el) => el instanceof HTMLElement
5
- || el instanceof SVGElement
6
- || el instanceof MathMLElement;
4
+ export const isHTMLOrSVG = (el) => el instanceof HTMLElement || el instanceof SVGElement || el instanceof MathMLElement;
7
5
  /*********
8
6
  * math.ts
9
7
  *********/
@@ -102,10 +100,9 @@ Object.hasOwn ?? Object.prototype.hasOwnProperty.call;
102
100
  /*********
103
101
  * paths.ts
104
102
  *********/
105
- export const isPojo = (obj) => obj !== null
106
- && typeof obj === "object"
107
- && (Object.getPrototypeOf(obj) === Object.prototype
108
- || Object.getPrototypeOf(obj) === null);
103
+ export const isPojo = (obj) => obj !== null &&
104
+ typeof obj === "object" &&
105
+ (Object.getPrototypeOf(obj) === Object.prototype || Object.getPrototypeOf(obj) === null);
109
106
  export const isEmpty = (obj) => {
110
107
  for (const prop in obj) {
111
108
  if (hasOwn(obj, prop)) {
@@ -1,5 +1,5 @@
1
1
  import { watcher } from "../engine.js";
2
- import { aliasify, isHTMLOrSVG, supportsViewTransitions, } from "../utils.js";
2
+ import { aliasify, isHTMLOrSVG, supportsViewTransitions } from "../utils.js";
3
3
  const isValidType = (arr, value) => arr.includes(value);
4
4
  const PATCH_MODES = [
5
5
  "remove",
@@ -14,7 +14,7 @@ const PATCH_MODES = [
14
14
  const NAMESPACES = ["html", "svg", "mathml"];
15
15
  watcher({
16
16
  name: "datastar-patch-elements",
17
- apply(ctx, { selector = "", mode = "outer", namespace = "html", useViewTransition = "", elements = "", }) {
17
+ apply(ctx, { selector = "", mode = "outer", namespace = "html", useViewTransition = "", elements = "" }) {
18
18
  if (!isValidType(PATCH_MODES, mode)) {
19
19
  throw ctx.error("PatchElementsInvalidMode", { mode });
20
20
  }
@@ -44,17 +44,9 @@ const onPatchElements = ({ error }, { selector, mode, namespace, elements }) =>
44
44
  const hasHtml = /<\/html>/.test(elementsWithSvgsRemoved);
45
45
  const hasHead = /<\/head>/.test(elementsWithSvgsRemoved);
46
46
  const hasBody = /<\/body>/.test(elementsWithSvgsRemoved);
47
- const wrapperTag = namespace === "svg"
48
- ? "svg"
49
- : namespace === "mathml"
50
- ? "math"
51
- : "";
52
- const wrappedEls = wrapperTag
53
- ? `<${wrapperTag}>${elements}</${wrapperTag}>`
54
- : elements;
55
- const newDocument = new DOMParser().parseFromString(hasHtml || hasHead || hasBody
56
- ? elements
57
- : `<body><template>${wrappedEls}</template></body>`, "text/html");
47
+ const wrapperTag = namespace === "svg" ? "svg" : namespace === "mathml" ? "math" : "";
48
+ const wrappedEls = wrapperTag ? `<${wrapperTag}>${elements}</${wrapperTag}>` : elements;
49
+ const newDocument = new DOMParser().parseFromString(hasHtml || hasHead || hasBody ? elements : `<body><template>${wrappedEls}</template></body>`, "text/html");
58
50
  let newContent = document.createDocumentFragment();
59
51
  if (hasHtml) {
60
52
  newContent.appendChild(newDocument.documentElement);
@@ -70,10 +62,7 @@ const onPatchElements = ({ error }, { selector, mode, namespace, elements }) =>
70
62
  newContent.appendChild(newDocument.body);
71
63
  }
72
64
  else if (wrapperTag) {
73
- const wrapperEl = newDocument
74
- .querySelector("template")
75
- .content
76
- .querySelector(wrapperTag);
65
+ const wrapperEl = newDocument.querySelector("template").content.querySelector(wrapperTag);
77
66
  for (const child of wrapperEl.childNodes) {
78
67
  newContent.appendChild(child);
79
68
  }
@@ -119,9 +108,7 @@ for (const script of document.querySelectorAll("script")) {
119
108
  scripts.add(script);
120
109
  }
121
110
  const execute = (target) => {
122
- const elScripts = target instanceof HTMLScriptElement
123
- ? [target]
124
- : target.querySelectorAll("script");
111
+ const elScripts = target instanceof HTMLScriptElement ? [target] : target.querySelectorAll("script");
125
112
  for (const old of elScripts) {
126
113
  if (!scripts.has(old)) {
127
114
  const script = document.createElement("script");
@@ -175,11 +162,11 @@ ctxPantry.hidden = true;
175
162
  const aliasedIgnoreMorph = aliasify("ignore-morph");
176
163
  const aliasedIgnoreMorphAttr = `[${aliasedIgnoreMorph}]`;
177
164
  const morph = (oldElt, newContent, mode = "outer") => {
178
- if ((isHTMLOrSVG(oldElt)
179
- && isHTMLOrSVG(newContent)
180
- && oldElt.hasAttribute(aliasedIgnoreMorph)
181
- && newContent.hasAttribute(aliasedIgnoreMorph))
182
- || oldElt.parentElement?.closest(aliasedIgnoreMorphAttr)) {
165
+ if ((isHTMLOrSVG(oldElt) &&
166
+ isHTMLOrSVG(newContent) &&
167
+ oldElt.hasAttribute(aliasedIgnoreMorph) &&
168
+ newContent.hasAttribute(aliasedIgnoreMorph)) ||
169
+ oldElt.parentElement?.closest(aliasedIgnoreMorphAttr)) {
183
170
  return;
184
171
  }
185
172
  const normalizedElt = document.createElement("div");
@@ -225,8 +212,7 @@ const morph = (oldElt, newContent, mode = "outer") => {
225
212
  ctxPantry.remove();
226
213
  };
227
214
  const morphChildren = (oldParent, newParent, insertionPoint = null, endPoint = null) => {
228
- if (oldParent instanceof HTMLTemplateElement
229
- && newParent instanceof HTMLTemplateElement) {
215
+ if (oldParent instanceof HTMLTemplateElement && newParent instanceof HTMLTemplateElement) {
230
216
  oldParent = oldParent.content;
231
217
  newParent = newParent.content;
232
218
  }
@@ -332,14 +318,11 @@ const findBestMatch = (node, startPoint, endPoint) => {
332
318
  }
333
319
  return bestMatch || null;
334
320
  };
335
- const isSoftMatch = (oldNode, newNode) => oldNode.nodeType === newNode.nodeType
336
- && oldNode.tagName === newNode.tagName
337
- && (!oldNode.id
338
- || oldNode.id === newNode.id);
321
+ const isSoftMatch = (oldNode, newNode) => oldNode.nodeType === newNode.nodeType &&
322
+ oldNode.tagName === newNode.tagName &&
323
+ (!oldNode.id || oldNode.id === newNode.id);
339
324
  const removeNode = (node) => {
340
- ctxIdMap.has(node)
341
- ? moveBefore(ctxPantry, node, null)
342
- : node.parentNode?.removeChild(node);
325
+ ctxIdMap.has(node) ? moveBefore(ctxPantry, node, null) : node.parentNode?.removeChild(node);
343
326
  };
344
327
  const moveBefore =
345
328
  // @ts-expect-error
@@ -351,19 +334,17 @@ const morphNode = (oldNode, newNode) => {
351
334
  const oldElt = oldNode;
352
335
  const newElt = newNode;
353
336
  const shouldScopeChildren = oldElt.hasAttribute("data-scope-children");
354
- if (oldElt.hasAttribute(aliasedIgnoreMorph)
355
- && newElt.hasAttribute(aliasedIgnoreMorph)) {
337
+ if (oldElt.hasAttribute(aliasedIgnoreMorph) && newElt.hasAttribute(aliasedIgnoreMorph)) {
356
338
  return oldNode;
357
339
  }
358
- if (oldElt instanceof HTMLInputElement
359
- && newElt instanceof HTMLInputElement
360
- && newElt.type !== "file") {
340
+ if (oldElt instanceof HTMLInputElement &&
341
+ newElt instanceof HTMLInputElement &&
342
+ newElt.type !== "file") {
361
343
  if (newElt.getAttribute("value") !== oldElt.getAttribute("value")) {
362
344
  oldElt.value = newElt.getAttribute("value") ?? "";
363
345
  }
364
346
  }
365
- else if (oldElt instanceof HTMLTextAreaElement
366
- && newElt instanceof HTMLTextAreaElement) {
347
+ else if (oldElt instanceof HTMLTextAreaElement && newElt instanceof HTMLTextAreaElement) {
367
348
  if (newElt.value !== oldElt.value) {
368
349
  oldElt.value = newElt.value;
369
350
  }
@@ -371,11 +352,9 @@ const morphNode = (oldNode, newNode) => {
371
352
  oldElt.firstChild.nodeValue = newElt.value;
372
353
  }
373
354
  }
374
- const preserveAttrs = (newNode.getAttribute(aliasedPreserveAttr) ?? "")
375
- .split(" ");
355
+ const preserveAttrs = (newNode.getAttribute(aliasedPreserveAttr) ?? "").split(" ");
376
356
  for (const { name, value } of newElt.attributes) {
377
- if (oldElt.getAttribute(name) !== value
378
- && !preserveAttrs.includes(name)) {
357
+ if (oldElt.getAttribute(name) !== value && !preserveAttrs.includes(name)) {
379
358
  oldElt.setAttribute(name, value);
380
359
  }
381
360
  }
@@ -1,5 +1,4 @@
1
- import { watcher } from "../engine.js";
2
- import { mergePatch } from "../engine.js";
1
+ import { mergePatch, watcher } from "../engine.js";
3
2
  import { jsStrToObject } from "../utils.js";
4
3
  watcher({
5
4
  name: "datastar-patch-signals",
@@ -1,6 +1,6 @@
1
- import { Cookies, HttpApp, HttpServerResponse } from "@effect/platform";
2
- import { Effect } from "effect";
1
+ import * as Cookies from "../Cookies.ts";
3
2
  import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  type CookieValue = string | number | boolean | null | undefined | {
6
6
  [key: string]: CookieValue | unknown;
@@ -45,7 +45,4 @@ export declare function decrypt(encryptedValue: string, options: {
45
45
  } | {
46
46
  secret: string;
47
47
  }): Effect.Effect<CookieValue, EncryptedCookiesError>;
48
- export declare function handleError<E>(app: HttpApp.Default<E | EncryptedCookiesError>): Effect.Effect<HttpServerResponse.HttpServerResponse, Exclude<E, {
49
- _tag: "EncryptedCookiesError";
50
- }>, import("@effect/platform/HttpServerRequest").HttpServerRequest>;
51
48
  export {};
@@ -1,8 +1,8 @@
1
- import { Cookies, HttpServerResponse, } from "@effect/platform";
2
- import { Effect, pipe, } from "effect";
1
+ import * as Cookies from "../Cookies.js";
3
2
  import * as Config from "effect/Config";
4
3
  import * as Context from "effect/Context";
5
4
  import * as Data from "effect/Data";
5
+ import * as Effect from "effect/Effect";
6
6
  import * as Layer from "effect/Layer";
7
7
  export class EncryptedCookiesError extends Data.TaggedError("EncryptedCookiesError") {
8
8
  }
@@ -23,33 +23,21 @@ export function layer(options) {
23
23
  }));
24
24
  }
25
25
  export function layerConfig(name = "SECRET_KEY_BASE") {
26
- return Effect
27
- .gen(function* () {
28
- const secret = yield* pipe(Config.nonEmptyString(name), Effect.flatMap((value) => {
29
- return (value.length < 40)
30
- ? Effect.fail(new Error("ba"))
31
- : Effect.succeed(value);
26
+ return Effect.gen(function* () {
27
+ const secret = yield* Config.nonEmptyString(name).pipe(Effect.flatMap((value) => {
28
+ return value.length < 40 ? Effect.fail(new Error("ba")) : Effect.succeed(value);
32
29
  }), Effect.catchAll((err) => {
33
30
  return Effect.dieMessage("SECRET_KEY_BASE must be at least 40 characters");
34
31
  }));
35
32
  return layer({ secret });
36
- })
37
- .pipe(Layer.unwrapEffect);
33
+ }).pipe(Layer.unwrapEffect);
38
34
  }
39
35
  function encodeToBase64Segments(ciphertext, iv, authTag) {
40
- return [
41
- base64urlEncode(ciphertext),
42
- base64urlEncode(iv),
43
- base64urlEncode(authTag),
44
- ]
45
- .join(".");
36
+ return [base64urlEncode(ciphertext), base64urlEncode(iv), base64urlEncode(authTag)].join(".");
46
37
  }
47
38
  function base64urlEncode(data) {
48
39
  const base64 = btoa(String.fromCharCode(...data));
49
- return base64
50
- .replace(/\+/g, "-")
51
- .replace(/\//g, "_")
52
- .replace(/=/g, "");
40
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
53
41
  }
54
42
  function decodeFromBase64Segments(segments) {
55
43
  return Effect.gen(function* () {
@@ -71,14 +59,12 @@ function decodeFromBase64Segments(segments) {
71
59
  }
72
60
  function base64urlDecode(data) {
73
61
  // Convert base64url back to standard base64
74
- let base64 = data
75
- .replace(/-/g, "+")
76
- .replace(/_/g, "/");
62
+ let base64 = data.replace(/-/g, "+").replace(/_/g, "/");
77
63
  // Add padding if needed
78
64
  while (base64.length % 4) {
79
65
  base64 += "=";
80
66
  }
81
- return Uint8Array.from(atob(base64), c => c.charCodeAt(0));
67
+ return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
82
68
  }
83
69
  /**
84
70
  * Encrypts cookie value using the SECRET_KEY_BASE.
@@ -143,8 +129,7 @@ function decryptWithDerivedKey(encryptedValue, derivedKey) {
143
129
  }
144
130
  function encryptCookieWithDerivedKey(cookie, derivedKey) {
145
131
  return Effect.gen(function* () {
146
- const encryptedValue = yield* encryptWithDerivedKey(cookie.value, derivedKey)
147
- .pipe(Effect.mapError(error => new EncryptedCookiesError({
132
+ const encryptedValue = yield* encryptWithDerivedKey(cookie.value, derivedKey).pipe(Effect.mapError((error) => new EncryptedCookiesError({
148
133
  cause: error.cause,
149
134
  cookie,
150
135
  })));
@@ -153,8 +138,7 @@ function encryptCookieWithDerivedKey(cookie, derivedKey) {
153
138
  }
154
139
  function decryptCookieWithDerivedKey(cookie, derivedKey) {
155
140
  return Effect.gen(function* () {
156
- const decryptedValue = yield* decryptWithDerivedKey(cookie.value, derivedKey)
157
- .pipe(Effect.mapError(error => new EncryptedCookiesError({
141
+ const decryptedValue = yield* decryptWithDerivedKey(cookie.value, derivedKey).pipe(Effect.mapError((error) => new EncryptedCookiesError({
158
142
  cause: error.cause,
159
143
  cookie,
160
144
  })));
@@ -168,8 +152,7 @@ export function encryptCookie(cookie, options) {
168
152
  }
169
153
  const encryptedValue = yield* encrypt(cookie.value, {
170
154
  secret: options.secret,
171
- })
172
- .pipe(Effect.mapError(error => new EncryptedCookiesError({
155
+ }).pipe(Effect.mapError((error) => new EncryptedCookiesError({
173
156
  cause: error.cause,
174
157
  cookie,
175
158
  })));
@@ -183,8 +166,7 @@ export function decryptCookie(cookie, options) {
183
166
  }
184
167
  const decryptedValue = yield* decrypt(cookie.value, {
185
168
  secret: options.secret,
186
- })
187
- .pipe(Effect.mapError(error => new EncryptedCookiesError({
169
+ }).pipe(Effect.mapError((error) => new EncryptedCookiesError({
188
170
  cause: error.cause,
189
171
  cookie,
190
172
  })));
@@ -205,7 +187,9 @@ function deriveKeyMaterial(secret) {
205
187
  return Effect.gen(function* () {
206
188
  const encoder = new TextEncoder();
207
189
  const keyMaterial = yield* Effect.tryPromise({
208
- try: () => crypto.subtle.importKey("raw", encoder.encode(secret), { name: "HKDF" }, false, ["deriveKey"]),
190
+ try: () => crypto.subtle.importKey("raw", encoder.encode(secret), { name: "HKDF" }, false, [
191
+ "deriveKey",
192
+ ]),
209
193
  catch: (error) => new EncryptedCookiesError({ cause: error }),
210
194
  });
211
195
  return keyMaterial;
@@ -226,18 +210,3 @@ function deriveKey(keyMaterial, usage) {
226
210
  return key;
227
211
  });
228
212
  }
229
- // TODO something si wrong with return type
230
- export function handleError(app) {
231
- return Effect.gen(function* () {
232
- const res = yield* app.pipe(Effect.catchTag("EncryptedCookiesError", (error) => {
233
- return HttpServerResponse.empty();
234
- }));
235
- return res;
236
- });
237
- }
238
- function generateFriendlyKey(bits = 128) {
239
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
240
- const length = Math.ceil(bits / Math.log2(chars.length));
241
- const bytes = crypto.getRandomValues(new Uint8Array(length));
242
- return Array.from(bytes, b => chars[b % chars.length]).join("");
243
- }
@@ -1,2 +1 @@
1
1
  export * as EncryptedCookies from "./EncryptedCookies.ts";
2
- export * as SseHttpResponse from "./SseHttpResponse.ts";
@@ -1,2 +1 @@
1
1
  export * as EncryptedCookies from "./EncryptedCookies.js";
2
- export * as SseHttpResponse from "./SseHttpResponse.js";
@@ -1,18 +1,11 @@
1
1
  import * as Context from "effect/Context";
2
- import * as Layer from "effect/Layer";
3
- import { HyperHooks } from "../x/datastar/index.ts";
4
2
  import type { JSX } from "./jsx.d.ts";
5
3
  type Elements = JSX.IntrinsicElements;
6
4
  type Children = JSX.Children;
7
- export type { Children, Elements, JSX, };
8
- declare const Hyper_base: Context.TagClass<Hyper, "Hyper", {
9
- hooks: typeof HyperHooks | undefined;
10
- }>;
5
+ export type { Children, Elements, JSX };
6
+ declare const Hyper_base: Context.TagClass<Hyper, "Hyper", {}>;
11
7
  export declare class Hyper extends Hyper_base {
12
8
  }
13
- export declare function layer(opts: {
14
- hooks: typeof HyperHooks;
15
- }): Layer.Layer<Hyper, never, never>;
16
9
  type Primitive = string | number | boolean | null | undefined;
17
10
  export type HyperType = string | HyperComponent;
18
11
  export type HyperProps = {
@@ -1,16 +1,8 @@
1
1
  import * as Context from "effect/Context";
2
2
  import * as Fiber from "effect/Fiber";
3
- import * as Layer from "effect/Layer";
4
3
  import * as Option from "effect/Option";
5
4
  export class Hyper extends Context.Tag("Hyper")() {
6
5
  }
7
- export function layer(opts) {
8
- return Layer.sync(Hyper, () => {
9
- return {
10
- hooks: opts.hooks,
11
- };
12
- });
13
- }
14
6
  const NoChildren = Object.freeze([]);
15
7
  export function h(type, props) {
16
8
  return {
@@ -27,8 +19,5 @@ export function unsafeUse(tag) {
27
19
  return Context.unsafeGet(context, tag);
28
20
  }
29
21
  export function isGenericJsxObject(value) {
30
- return typeof value === "object"
31
- && value !== null
32
- && "type" in value
33
- && "props" in value;
22
+ return typeof value === "object" && value !== null && "type" in value && "props" in value;
34
23
  }
@@ -16,7 +16,7 @@
16
16
  * }
17
17
  * }
18
18
  */
19
- import * as HyperNode from "./HyperNode.ts";
19
+ import type * as HyperNode from "./HyperNode.ts";
20
20
  import type { JSX } from "./jsx.d.ts";
21
21
  export declare function renderToString(node: JSX.Children, hooks?: {
22
22
  onNode?: (node: HyperNode.HyperNode) => void;
@@ -34,15 +34,16 @@ const EMPTY_TAGS = [
34
34
  "track",
35
35
  "wbr",
36
36
  ];
37
- // escape an attribute
38
37
  let esc = (str) => String(str).replace(/[&<>"']/g, (s) => `&${map[s]};`);
38
+ let escSQ = (str) => String(str).replace(/[&<>']/g, (s) => `&${map[s]};`);
39
39
  let map = {
40
40
  "&": "amp",
41
41
  "<": "lt",
42
42
  ">": "gt",
43
- "\"": "quot",
44
- "'": "apos",
43
+ '"': "quot",
44
+ "'": "#39",
45
45
  };
46
+ const RAW_TEXT_TAGS = ["script", "style"];
46
47
  export function renderToString(node, hooks) {
47
48
  const stack = [node];
48
49
  let result = "";
@@ -89,19 +90,22 @@ export function renderToString(node, hooks) {
89
90
  const { type, props } = current;
90
91
  result += `<${type}`;
91
92
  for (const key in props) {
92
- if (key !== "children"
93
- && key !== "innerHTML" // Solid-specific
94
- && key !== "dangerouslySetInnerHTML" // React-specific
95
- && props[key] !== false
96
- && props[key] != null) {
93
+ if (key !== "children" &&
94
+ key !== "innerHTML" && // Solid-specific
95
+ key !== "dangerouslySetInnerHTML" && // React-specific
96
+ props[key] !== false &&
97
+ props[key] != null) {
97
98
  if (props[key] === true) {
98
99
  result += ` ${esc(key)}`;
99
100
  }
100
101
  else {
101
102
  const resolvedKey = key === "className" ? "class" : key;
102
103
  const value = props[key];
103
- if (key.startsWith("data-") && typeof value === "object") {
104
- result += ` ${esc(resolvedKey)}="${esc(JSON.stringify(value))}"`;
104
+ if (key.startsWith("data-") && typeof value === "function") {
105
+ result += ` ${esc(resolvedKey)}="${esc(value.toString())}"`;
106
+ }
107
+ else if (key.startsWith("data-") && typeof value === "object") {
108
+ result += ` ${esc(resolvedKey)}='${escSQ(JSON.stringify(value))}'`;
105
109
  }
106
110
  else {
107
111
  result += ` ${esc(resolvedKey)}="${esc(value)}"`;
@@ -113,8 +117,7 @@ export function renderToString(node, hooks) {
113
117
  if (!EMPTY_TAGS.includes(type)) {
114
118
  stack.push(`</${type}>`);
115
119
  // React-specific
116
- const html = props.dangerouslySetInnerHTML?.__html
117
- ?? props.innerHTML;
120
+ const html = props.dangerouslySetInnerHTML?.__html ?? props.innerHTML;
118
121
  if (html) {
119
122
  result += html;
120
123
  }
@@ -123,6 +126,9 @@ export function renderToString(node, hooks) {
123
126
  if (type === "script" && typeof children === "function") {
124
127
  result += `(${children.toString()})(window)`;
125
128
  }
129
+ else if (RAW_TEXT_TAGS.includes(type) && children != null) {
130
+ result += Array.isArray(children) ? children.join("") : children;
131
+ }
126
132
  else if (Array.isArray(children)) {
127
133
  for (let i = children.length - 1; i >= 0; i--) {
128
134
  stack.push(children[i]);
@@ -0,0 +1 @@
1
+ export {};