acrylblends 0.6.2 → 0.6.3

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 (181) hide show
  1. package/README.md +4 -1
  2. package/docs/framework/README.md +3 -2
  3. package/docs/framework/UPSTREAM.md +1 -1
  4. package/docs/framework/cordis/acryl-in-a-cordis-app.md +6 -0
  5. package/docs/framework/getting-started/basic.md +1 -0
  6. package/docs/framework/getting-started/desktop.md +41 -0
  7. package/docs/framework/guides/jsx-dom.md +0 -3
  8. package/docs/framework/guides/jsx.md +0 -3
  9. package/docs/framework/helpers/css.md +0 -3
  10. package/docs/framework/upstream.json +3 -3
  11. package/lib/accepts.d.ts +1 -1
  12. package/lib/acryl-base.d.ts +1 -1
  13. package/lib/adapter.d.ts +1 -1
  14. package/lib/{app-BdrVHBlJ.d.ts → app-wFwpg-bt.d.ts} +1 -1
  15. package/lib/base-BpQy2Rk7.d.ts +783 -0
  16. package/lib/base-ddiVmiE7.js +721 -0
  17. package/lib/basic-auth.d.ts +1 -1
  18. package/lib/bearer-auth.d.ts +1 -1
  19. package/lib/body-limit.d.ts +1 -1
  20. package/lib/cache.d.ts +1 -1
  21. package/lib/client.d.ts +2 -2
  22. package/lib/combine.d.ts +1 -1
  23. package/lib/common-D8Z4JRCw.d.ts +46 -0
  24. package/lib/components-Ce5FRyHU.js +268 -0
  25. package/lib/components-DYZdxJIJ.js +24 -0
  26. package/lib/compress.d.ts +1 -1
  27. package/lib/conninfo.d.ts +2 -2
  28. package/lib/constants-BR9jM9BC.js +9 -0
  29. package/lib/{context-B5Y1lLha.d.ts → context-DVQBjuns.d.ts} +1 -1
  30. package/lib/context-DxFdY_un.d.ts +250 -0
  31. package/lib/context-storage.d.ts +1 -1
  32. package/lib/{cookie-D9_nQbsM.d.ts → cookie-CCelEqky.d.ts} +1 -1
  33. package/lib/cookie.d.ts +3 -3
  34. package/lib/cors.d.ts +1 -1
  35. package/lib/csrf.d.ts +1 -1
  36. package/lib/css-D2jb7X8b.js +320 -0
  37. package/lib/css.d.ts +82 -0
  38. package/lib/css.js +134 -0
  39. package/lib/dev.d.ts +2 -2
  40. package/lib/etag.d.ts +1 -1
  41. package/lib/factory.d.ts +2 -2
  42. package/lib/hooks-Bq5q9IMl.js +762 -0
  43. package/lib/html-SllAe0YT.d.ts +46 -0
  44. package/lib/html.d.ts +1 -1
  45. package/lib/index-C850MeBA.d.ts +94 -0
  46. package/lib/{index-m12zcmph.d.ts → index-CUTfU69R.d.ts} +3 -3
  47. package/lib/{index-DtEoak1i.d.ts → index-Cqcdluyn.d.ts} +2 -2
  48. package/lib/{index-Kqou8Fjh.d.ts → index-CsvB-F9j.d.ts} +2 -2
  49. package/lib/index.d.ts +4 -4
  50. package/lib/ip-restriction.d.ts +2 -2
  51. package/lib/jsx/dom/client.d.ts +30 -0
  52. package/lib/jsx/dom/client.js +49 -0
  53. package/lib/jsx/dom/css.d.ts +84 -0
  54. package/lib/jsx/dom/css.js +2 -0
  55. package/lib/jsx/dom/jsx-dev-runtime.d.ts +3 -0
  56. package/lib/jsx/dom/jsx-dev-runtime.js +2 -0
  57. package/lib/jsx/dom/jsx-runtime.d.ts +3 -0
  58. package/lib/jsx/dom/jsx-runtime.js +2 -0
  59. package/lib/jsx/dom/server.d.ts +105 -0
  60. package/lib/jsx/dom/server.js +37 -0
  61. package/lib/jsx/dom.d.ts +5 -0
  62. package/lib/jsx/dom.js +74 -0
  63. package/lib/jsx/jsx-dev-runtime.d.ts +6 -0
  64. package/lib/jsx/jsx-dev-runtime.js +14 -0
  65. package/lib/jsx/jsx-runtime.d.ts +10 -0
  66. package/lib/jsx/jsx-runtime.js +30 -0
  67. package/lib/jsx/streaming.d.ts +2 -0
  68. package/lib/jsx/streaming.js +2 -0
  69. package/lib/jsx-dev-runtime-B22O-Npk.d.ts +7 -0
  70. package/lib/jsx-dev-runtime-kAhR_4C7.js +354 -0
  71. package/lib/jsx-runtime-BVVgDSdq.d.ts +1 -0
  72. package/lib/jsx.d.ts +3 -0
  73. package/lib/jsx.js +47 -0
  74. package/lib/jwk.d.ts +4 -4
  75. package/lib/{jwt-BA65QhnJ.d.ts → jwt-BARhotDz.d.ts} +1 -1
  76. package/lib/jwt.d.ts +4 -4
  77. package/lib/language.d.ts +1 -1
  78. package/lib/logger.d.ts +1 -1
  79. package/lib/loopback-only.d.ts +1 -1
  80. package/lib/method-not-allowed.d.ts +2 -2
  81. package/lib/method-override.d.ts +2 -2
  82. package/lib/mount.d.ts +1 -1
  83. package/lib/node-server/conninfo.d.ts +1 -1
  84. package/lib/node-server/serve-static.d.ts +1 -1
  85. package/lib/node-server/serve-static.js +1 -1
  86. package/lib/node-server.d.ts +1 -1
  87. package/lib/node-server.js +1 -1
  88. package/lib/powered-by.d.ts +1 -1
  89. package/lib/pretty-json.d.ts +1 -1
  90. package/lib/proxy.d.ts +1 -1
  91. package/lib/quick.d.ts +1 -1
  92. package/lib/request-id.d.ts +1 -1
  93. package/lib/request.d.ts +1 -1
  94. package/lib/route.d.ts +1 -1
  95. package/lib/schema-validator.d.ts +1 -1
  96. package/lib/secure-headers.d.ts +1 -1
  97. package/lib/{serve-static-Dw_m6KxR.js → serve-static-Cw23shXv.js} +1 -0
  98. package/lib/serve-static.d.ts +1 -1
  99. package/lib/streaming.d.ts +1 -1
  100. package/lib/testing.d.ts +4 -4
  101. package/lib/timeout.d.ts +1 -1
  102. package/lib/timing.d.ts +1 -1
  103. package/lib/tiny.d.ts +1 -1
  104. package/lib/trailing-slash.d.ts +1 -1
  105. package/lib/{types-Bd29gh2o.d.ts → types-CQiGmsWW.d.ts} +3 -3
  106. package/lib/{types-D9DEXMjE.d.ts → types-Lqx5BxQF.d.ts} +8 -1
  107. package/lib/{types-ZM9gIiKh.d.ts → types-nEL8VPDC.d.ts} +1 -1
  108. package/lib/types.d.ts +1 -1
  109. package/lib/utils/body.d.ts +1 -1
  110. package/lib/utils/cookie.d.ts +1 -1
  111. package/lib/utils/crypto.d.ts +1 -1
  112. package/lib/utils/html.d.ts +1 -45
  113. package/lib/utils/ipaddr.d.ts +1 -1
  114. package/lib/utils/jwt.d.ts +1 -1
  115. package/lib/utils/types.d.ts +2 -2
  116. package/lib/validator.d.ts +2 -2
  117. package/lib/ws.d.ts +1 -1
  118. package/package.json +45 -1
  119. package/plugins/acryl-inspect/upstream.json +1 -1
  120. package/plugins/acryl-node-server/upstream.json +1 -1
  121. package/plugins/acryl-router/src/core/helper/css/common.case.test.tsx +506 -0
  122. package/plugins/acryl-router/src/core/helper/css/common.ts +337 -0
  123. package/plugins/acryl-router/src/core/helper/css/index.test.tsx +678 -0
  124. package/plugins/acryl-router/src/core/helper/css/index.ts +262 -0
  125. package/plugins/acryl-router/src/core/helper/streaming/sse.test.tsx +557 -0
  126. package/plugins/acryl-router/src/core/jsx/base.test.tsx +97 -0
  127. package/plugins/acryl-router/src/core/jsx/base.ts +490 -0
  128. package/plugins/acryl-router/src/core/jsx/children.test.ts +52 -0
  129. package/plugins/acryl-router/src/core/jsx/children.ts +20 -0
  130. package/plugins/acryl-router/src/core/jsx/components.test.tsx +936 -0
  131. package/plugins/acryl-router/src/core/jsx/components.ts +257 -0
  132. package/plugins/acryl-router/src/core/jsx/constants.ts +6 -0
  133. package/plugins/acryl-router/src/core/jsx/context-isolation.test.ts +655 -0
  134. package/plugins/acryl-router/src/core/jsx/context.ts +266 -0
  135. package/plugins/acryl-router/src/core/jsx/dom/client.test.tsx +128 -0
  136. package/plugins/acryl-router/src/core/jsx/dom/client.ts +89 -0
  137. package/plugins/acryl-router/src/core/jsx/dom/components.test.tsx +330 -0
  138. package/plugins/acryl-router/src/core/jsx/dom/components.ts +39 -0
  139. package/plugins/acryl-router/src/core/jsx/dom/context.test.tsx +184 -0
  140. package/plugins/acryl-router/src/core/jsx/dom/context.ts +52 -0
  141. package/plugins/acryl-router/src/core/jsx/dom/css.test.tsx +149 -0
  142. package/plugins/acryl-router/src/core/jsx/dom/css.ts +263 -0
  143. package/plugins/acryl-router/src/core/jsx/dom/hooks/index.test.tsx +172 -0
  144. package/plugins/acryl-router/src/core/jsx/dom/hooks/index.ts +91 -0
  145. package/plugins/acryl-router/src/core/jsx/dom/index.test.tsx +3681 -0
  146. package/plugins/acryl-router/src/core/jsx/dom/index.ts +170 -0
  147. package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.test.tsx +1344 -0
  148. package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.ts +438 -0
  149. package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.ts +23 -0
  150. package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.ts +8 -0
  151. package/plugins/acryl-router/src/core/jsx/dom/render.ts +879 -0
  152. package/plugins/acryl-router/src/core/jsx/dom/server.test.tsx +199 -0
  153. package/plugins/acryl-router/src/core/jsx/dom/server.ts +76 -0
  154. package/plugins/acryl-router/src/core/jsx/dom/utils.ts +7 -0
  155. package/plugins/acryl-router/src/core/jsx/hooks/dom.test.tsx +859 -0
  156. package/plugins/acryl-router/src/core/jsx/hooks/index.ts +437 -0
  157. package/plugins/acryl-router/src/core/jsx/hooks/string.test.tsx +40 -0
  158. package/plugins/acryl-router/src/core/jsx/index.test.tsx +1744 -0
  159. package/plugins/acryl-router/src/core/jsx/index.ts +115 -0
  160. package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.ts +23 -0
  161. package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.test.tsx +666 -0
  162. package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.ts +210 -0
  163. package/plugins/acryl-router/src/core/jsx/intrinsic-elements.ts +938 -0
  164. package/plugins/acryl-router/src/core/jsx/jsx-dev-runtime.ts +26 -0
  165. package/plugins/acryl-router/src/core/jsx/jsx-runtime.test.tsx +85 -0
  166. package/plugins/acryl-router/src/core/jsx/jsx-runtime.ts +51 -0
  167. package/plugins/acryl-router/src/core/jsx/streaming.test.tsx +1281 -0
  168. package/plugins/acryl-router/src/core/jsx/streaming.ts +231 -0
  169. package/plugins/acryl-router/src/core/jsx/types.ts +41 -0
  170. package/plugins/acryl-router/src/core/jsx/utils.test.ts +366 -0
  171. package/plugins/acryl-router/src/core/jsx/utils.ts +202 -0
  172. package/plugins/acryl-router/src/core/utils/types.ts +6 -0
  173. package/plugins/acryl-router/src/helpers/index.ts +1 -0
  174. package/plugins/acryl-router/tests/jsx.spec.tsx +63 -0
  175. package/plugins/acryl-router/upstream.json +3 -3
  176. package/plugins/acryl-router-http/upstream.json +1 -1
  177. package/plugins/acryl-state/upstream.json +1 -1
  178. package/plugins/desktop/upstream.json +1 -1
  179. package/plugins/desktop-web/upstream.json +1 -1
  180. package/plugins/save/plugin.json +1 -1
  181. package/templates/todo/upstream.json +1 -1
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
1
+ import { I as MiddlewareHandler, t as Context } from "./context-DVQBjuns.js";
2
2
 
3
3
  //#region ../../plugins/acryl-router/src/core/middleware/basic-auth/index.d.ts
4
4
  type MessageFunction = (c: Context) => string | object | Promise<string | object>;
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler, _ as Env, t as Context } from "./context-B5Y1lLha.js";
1
+ import { I as MiddlewareHandler, _ as Env, t as Context } from "./context-DVQBjuns.js";
2
2
 
3
3
  //#region ../../plugins/acryl-router/src/core/middleware/bearer-auth/index.d.ts
4
4
  type MessageFunction = (c: Context) => string | object | Promise<string | object>;
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
1
+ import { I as MiddlewareHandler, t as Context } from "./context-DVQBjuns.js";
2
2
 
3
3
  //#region ../../plugins/acryl-router/src/core/middleware/body-limit/index.d.ts
4
4
  type OnError = (c: Context) => Response | Promise<Response>;
package/lib/cache.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
1
+ import { I as MiddlewareHandler, t as Context } from "./context-DVQBjuns.js";
2
2
  import { c as StatusCode } from "./http-status-DaAwGAFL.js";
3
3
 
4
4
  //#region ../../plugins/acryl-router/src/core/middleware/cache/index.d.ts
package/lib/client.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as ClientResponse, c as InferRequestType, i as ClientRequestOptions, l as InferResponseType, o as Fetch, r as ClientRequest, t as ApplyGlobalResponse, u as PickResponseByStatusCode } from "./types-Bd29gh2o.js";
2
- import { n as DetailedError, r as hc, t as parseResponse } from "./index-m12zcmph.js";
1
+ import { a as ClientResponse, c as InferRequestType, i as ClientRequestOptions, l as InferResponseType, o as Fetch, r as ClientRequest, t as ApplyGlobalResponse, u as PickResponseByStatusCode } from "./types-CQiGmsWW.js";
2
+ import { n as DetailedError, r as hc, t as parseResponse } from "./index-CUTfU69R.js";
3
3
  export { type ApplyGlobalResponse, type ClientRequest, type ClientRequestOptions, type ClientResponse, DetailedError, type Fetch, type InferRequestType, type InferResponseType, type PickResponseByStatusCode, hc, parseResponse };
package/lib/combine.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
1
+ import { I as MiddlewareHandler, t as Context } from "./context-DVQBjuns.js";
2
2
 
3
3
  //#region ../../plugins/acryl-router/src/core/middleware/combine/index.d.ts
4
4
  type Condition = (c: Context) => boolean;
@@ -0,0 +1,46 @@
1
+ //#region ../../plugins/acryl-router/src/core/helper/css/common.d.ts
2
+ declare const SELECTOR: unique symbol;
3
+ declare const CLASS_NAME: unique symbol;
4
+ declare const STYLE_STRING: unique symbol;
5
+ declare const SELECTORS: unique symbol;
6
+ declare const EXTERNAL_CLASS_NAMES: unique symbol;
7
+ declare const CSS_ESCAPED: unique symbol;
8
+ interface CssClassName {
9
+ [SELECTOR]: string;
10
+ [CLASS_NAME]: string;
11
+ [STYLE_STRING]: string;
12
+ [SELECTORS]: CssClassName[];
13
+ [EXTERNAL_CLASS_NAMES]: string[];
14
+ }
15
+ interface CssEscapedString {
16
+ [CSS_ESCAPED]: string;
17
+ }
18
+ /**
19
+ * @experimental
20
+ * `rawCssString` is an experimental feature.
21
+ * The API might be changed.
22
+ */
23
+ declare const rawCssString: (value: string) => CssEscapedString;
24
+ type CssVariableBasicType = CssClassName | CssEscapedString | string | number | boolean | null | undefined;
25
+ type CssVariableAsyncType = Promise<CssVariableBasicType>;
26
+ type CssVariableArrayType = (CssVariableBasicType | CssVariableAsyncType)[];
27
+ type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType;
28
+ /**
29
+ * A function that customizes generated CSS class names.
30
+ *
31
+ * @param hash - The default hash-based class name (e.g. `css-1234567890`)
32
+ * @param label - The comment label extracted from the CSS template, may be empty.
33
+ * Whitespace is trimmed and inner spaces are replaced with hyphens.
34
+ * @param styleString - The minified CSS style string
35
+ * @returns The custom class name to use. Must be a safe CSS identifier;
36
+ * otherwise, the default hash is used as a fallback.
37
+ */
38
+ type ClassNameSlug = (hash: string, label: string, styleString: string) => string;
39
+ /**
40
+ * A callback function called when an invalid slug is returned from ClassNameSlug.
41
+ *
42
+ * @param slug - The invalid slug
43
+ */
44
+ type OnInvalidSlug = (slug: string) => void;
45
+ //#endregion
46
+ export { rawCssString as a, OnInvalidSlug as i, CssClassName as n, CssVariableType as r, ClassNameSlug as t };
@@ -0,0 +1,268 @@
1
+ import { C as captureRenderContext, E as useContext, d as renderUntrustedObject, i as isUntrustedObject, n as JSXNode, o as jsx, t as Fragment, u as renderChildren, w as createContext } from "./base-ddiVmiE7.js";
2
+ import { HtmlEscapedCallbackPhase, raw, resolveCallback } from "./utils/html.js";
3
+ import { a as DOM_STASH, i as DOM_RENDERER } from "./constants-BR9jM9BC.js";
4
+ import { x as buildDataStack } from "./hooks-Bq5q9IMl.js";
5
+ import { n as Suspense$1, t as ErrorBoundary$1 } from "./components-DYZdxJIJ.js";
6
+ //#region ../../plugins/acryl-router/src/core/jsx/streaming.ts
7
+ /**
8
+ * @module
9
+ * This module enables JSX to supports streaming Response.
10
+ */
11
+ /**
12
+ * Used to specify nonce for scripts generated by `Suspense` and `ErrorBoundary`.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <StreamingContext.Provider value={{ scriptNonce: 'test-nonce' }}>
17
+ * <Suspense fallback={<p>Loading...</p>}>
18
+ * <Content />
19
+ * </Suspense>
20
+ * </StreamingContext.Provider>
21
+ * ```
22
+ */
23
+ const StreamingContext = createContext(null);
24
+ let suspenseCounter = 0;
25
+ const serializeBoundaryChild = (child) => typeof child === "string" || Array.isArray(child) ? renderChildren([child]) : child == null || typeof child === "boolean" ? "" : isUntrustedObject(child) ? renderUntrustedObject(child) : child.toString();
26
+ /**
27
+ * @experimental
28
+ * `Suspense` is an experimental feature.
29
+ * The API might be changed.
30
+ */
31
+ const Suspense = async ({ children, fallback }) => {
32
+ if (!Array.isArray(children)) children = [children];
33
+ const nonce = useContext(StreamingContext)?.scriptNonce;
34
+ let resArray = [];
35
+ const stackNode = { [DOM_STASH]: [0, []] };
36
+ const popNodeStack = () => {
37
+ buildDataStack.pop();
38
+ };
39
+ try {
40
+ stackNode[DOM_STASH][0] = 0;
41
+ buildDataStack.push([[], stackNode]);
42
+ resArray = children.map(serializeBoundaryChild);
43
+ } catch (e) {
44
+ if (e instanceof Promise) {
45
+ const resume = captureRenderContext();
46
+ resArray = [e.then(() => resume(() => {
47
+ stackNode[DOM_STASH][0] = 0;
48
+ buildDataStack.push([[], stackNode]);
49
+ return childrenToString(children).finally(popNodeStack);
50
+ }))];
51
+ } else throw e;
52
+ } finally {
53
+ popNodeStack();
54
+ }
55
+ if (resArray.some((res) => res instanceof Promise)) {
56
+ const index = suspenseCounter++;
57
+ const fallbackStr = await (typeof fallback === "string" || Array.isArray(fallback) ? renderChildren([fallback]) : isUntrustedObject(fallback) ? renderUntrustedObject(fallback) : fallback.toString());
58
+ return raw(`<template id="H:${index}"></template>${fallbackStr}<!--/$-->`, [...fallbackStr.callbacks || [], ({ phase, buffer, context }) => {
59
+ if (phase === HtmlEscapedCallbackPhase.BeforeStream) return;
60
+ return Promise.all(resArray).then(async (htmlArray) => {
61
+ htmlArray = htmlArray.flat();
62
+ const content = htmlArray.join("");
63
+ if (buffer) buffer[0] = buffer[0].replace(new RegExp(`<template id="H:${index}"></template>.*?<!--/\\$-->`, "s"), () => content);
64
+ let html = buffer ? "" : `<template data-acryl-target="H:${index}">${content}</template><script${nonce ? ` nonce="${nonce}"` : ""}>
65
+ ((d,c,n) => {
66
+ c=d.currentScript.previousSibling
67
+ d=d.getElementById('H:${index}')
68
+ if(!d)return
69
+ do{n=d.nextSibling;n.remove()}while(n.nodeType!=8||n.nodeValue!='/$')
70
+ d.replaceWith(c.content)
71
+ })(document)
72
+ <\/script>`;
73
+ const callbacks = htmlArray.map((html) => html.callbacks || []).flat();
74
+ if (!callbacks.length) return html;
75
+ if (phase === HtmlEscapedCallbackPhase.Stream) html = await resolveCallback(html, HtmlEscapedCallbackPhase.BeforeStream, true, context);
76
+ return raw(html, callbacks);
77
+ });
78
+ }]);
79
+ } else return raw(resArray.join(""));
80
+ };
81
+ Suspense[DOM_RENDERER] = Suspense$1;
82
+ const textEncoder = new TextEncoder();
83
+ /**
84
+ * @experimental
85
+ * `renderToReadableStream()` is an experimental feature.
86
+ * The API might be changed.
87
+ */
88
+ const renderToReadableStream = (content, onError = console.trace) => {
89
+ let cancelled = false;
90
+ return new ReadableStream({
91
+ async start(controller) {
92
+ try {
93
+ if (content instanceof JSXNode) content = content.toString();
94
+ const context = typeof content === "object" ? content : {};
95
+ const resolved = await resolveCallback(content, HtmlEscapedCallbackPhase.BeforeStream, true, context);
96
+ if (!cancelled) controller.enqueue(textEncoder.encode(resolved));
97
+ let resolvedCount = 0;
98
+ const callbacks = [];
99
+ const then = (promise) => {
100
+ callbacks.push(promise.catch((err) => {
101
+ console.log(err);
102
+ onError(err);
103
+ return "";
104
+ }).then(async (res) => {
105
+ res = await resolveCallback(res, HtmlEscapedCallbackPhase.BeforeStream, true, context);
106
+ res.callbacks?.map((c) => c({
107
+ phase: HtmlEscapedCallbackPhase.Stream,
108
+ context
109
+ })).filter(Boolean).forEach(then);
110
+ resolvedCount++;
111
+ if (!cancelled) controller.enqueue(textEncoder.encode(res));
112
+ }));
113
+ };
114
+ resolved.callbacks?.map((c) => c({
115
+ phase: HtmlEscapedCallbackPhase.Stream,
116
+ context
117
+ })).filter(Boolean).forEach(then);
118
+ while (resolvedCount !== callbacks.length) await Promise.all(callbacks);
119
+ } catch (e) {
120
+ onError(e);
121
+ }
122
+ if (!cancelled) controller.close();
123
+ },
124
+ cancel() {
125
+ cancelled = true;
126
+ }
127
+ });
128
+ };
129
+ //#endregion
130
+ //#region ../../plugins/acryl-router/src/core/jsx/components.ts
131
+ let errorBoundaryCounter = 0;
132
+ const childrenToString = async (children) => {
133
+ try {
134
+ return children.flat().map(resolveChildEarly);
135
+ } catch (e) {
136
+ if (e instanceof Promise) {
137
+ const resume = captureRenderContext();
138
+ await e;
139
+ return resume(() => childrenToString(children));
140
+ } else throw e;
141
+ }
142
+ };
143
+ const resolveChildEarly = (child) => {
144
+ if (child == null || typeof child === "boolean") return "";
145
+ else if (typeof child === "string" || Array.isArray(child)) return renderChildren([child]);
146
+ else if (isUntrustedObject(child)) return renderUntrustedObject(child);
147
+ else {
148
+ const str = child.toString();
149
+ return str instanceof Promise ? str : raw(str);
150
+ }
151
+ };
152
+ /**
153
+ * @experimental
154
+ * `ErrorBoundary` is an experimental feature.
155
+ * The API might be changed.
156
+ */
157
+ const ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
158
+ if (!children) return raw("");
159
+ if (!Array.isArray(children)) children = [children];
160
+ const nonce = useContext(StreamingContext)?.scriptNonce;
161
+ let resume;
162
+ const getResume = () => resume ||= captureRenderContext();
163
+ let fallbackStrPromise;
164
+ const resolveFallbackStr = () => fallbackStrPromise ||= (async () => {
165
+ const awaitedFallback = await fallback;
166
+ if (awaitedFallback === null || awaitedFallback === void 0) return;
167
+ if (typeof awaitedFallback === "string" || Array.isArray(awaitedFallback)) return getResume()(() => renderChildren([awaitedFallback]));
168
+ if (isUntrustedObject(awaitedFallback)) return getResume()(() => renderUntrustedObject(awaitedFallback));
169
+ const fallbackResult = await getResume()(() => awaitedFallback.toString());
170
+ return raw(fallbackResult, fallbackResult.callbacks || awaitedFallback.callbacks);
171
+ })();
172
+ const renderFallback = async (error) => {
173
+ const fallbackStr = await resolveFallbackStr();
174
+ return getResume()(async () => {
175
+ onError?.(error);
176
+ const fallbackRes = fallbackStr !== void 0 ? fallbackStr : fallbackRender && jsx(Fragment, {}, fallbackRender(error)) || "";
177
+ const fallbackResString = await Fragment({ children: fallbackRes }).toString();
178
+ return raw(fallbackResString, fallbackResString.callbacks || fallbackRes.callbacks);
179
+ });
180
+ };
181
+ let resArray = [];
182
+ try {
183
+ resArray = children.map(resolveChildEarly);
184
+ } catch (e) {
185
+ const resume = getResume();
186
+ if (e instanceof Promise) resArray = [e.then(() => resume(() => childrenToString(children))).catch((e) => renderFallback(e))];
187
+ else resArray = [await renderFallback(e)];
188
+ }
189
+ if (resArray.some((res) => res instanceof Promise)) {
190
+ getResume();
191
+ const index = errorBoundaryCounter++;
192
+ const replaceRe = RegExp(`(<template id="E:${index}"></template>)(.*?)(<!--E:${index}-->)`, "s");
193
+ let caught = false;
194
+ const catchCallback = async ({ error, buffer }) => {
195
+ if (caught) return "";
196
+ caught = true;
197
+ const fallbackResString = await renderFallback(error);
198
+ const fallbackCallbacks = fallbackResString.callbacks;
199
+ if (buffer) {
200
+ buffer[0] = buffer[0].replace(replaceRe, () => fallbackResString);
201
+ return fallbackCallbacks?.length ? raw("", fallbackCallbacks) : "";
202
+ }
203
+ return raw(`<template data-acryl-target="E:${index}">${fallbackResString}</template><script>
204
+ ((d,c,n) => {
205
+ c=d.currentScript.previousSibling
206
+ d=d.getElementById('E:${index}')
207
+ if(!d)return
208
+ do{n=d.nextSibling;n.remove()}while(n.nodeType!=8||n.nodeValue!='E:${index}')
209
+ d.replaceWith(c.content)
210
+ })(document)
211
+ <\/script>`, fallbackCallbacks);
212
+ };
213
+ let error;
214
+ const promiseAll = Promise.all(resArray).catch((e) => error = e);
215
+ return raw(`<template id="E:${index}"></template><!--E:${index}-->`, [({ phase, buffer, context }) => {
216
+ if (phase === HtmlEscapedCallbackPhase.BeforeStream) return;
217
+ return promiseAll.then(async (htmlArray) => {
218
+ if (error) throw error;
219
+ htmlArray = htmlArray.flat();
220
+ const content = htmlArray.join("");
221
+ let html = buffer ? "" : `<template data-acryl-target="E:${index}">${content}</template><script${nonce ? ` nonce="${nonce}"` : ""}>
222
+ ((d,c) => {
223
+ c=d.currentScript.previousSibling
224
+ d=d.getElementById('E:${index}')
225
+ if(!d)return
226
+ d.parentElement.insertBefore(c.content,d.nextSibling)
227
+ })(document)
228
+ <\/script>`;
229
+ if (htmlArray.every((html) => !html.callbacks?.length)) {
230
+ if (buffer) buffer[0] = buffer[0].replace(replaceRe, () => content);
231
+ return html;
232
+ }
233
+ if (buffer) buffer[0] = buffer[0].replace(replaceRe, (_all, pre, _, post) => `${pre}${content}${post}`);
234
+ const callbacks = htmlArray.map((html) => html.callbacks || []).flat();
235
+ if (phase === HtmlEscapedCallbackPhase.Stream) html = await resolveCallback(html, HtmlEscapedCallbackPhase.BeforeStream, true, context);
236
+ let resolvedCount = 0;
237
+ const promises = callbacks.map((c) => (...args) => c(...args)?.then((content) => {
238
+ resolvedCount++;
239
+ if (buffer) {
240
+ if (resolvedCount === callbacks.length) buffer[0] = buffer[0].replace(replaceRe, (_all, _pre, content) => content);
241
+ buffer[0] += content;
242
+ return raw("", content.callbacks);
243
+ }
244
+ return raw(content + (resolvedCount !== callbacks.length ? "" : `<script>
245
+ ((d,c,n) => {
246
+ d=d.getElementById('E:${index}')
247
+ if(!d)return
248
+ n=d.nextSibling
249
+ while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
250
+ n.remove()
251
+ d.remove()
252
+ })(document)
253
+ <\/script>`), content.callbacks);
254
+ }).catch((error) => catchCallback({
255
+ error,
256
+ buffer
257
+ })));
258
+ return raw(html, promises);
259
+ }).catch((error) => catchCallback({
260
+ error,
261
+ buffer
262
+ }));
263
+ }]);
264
+ } else return Fragment({ children: resArray });
265
+ };
266
+ ErrorBoundary[DOM_RENDERER] = ErrorBoundary$1;
267
+ //#endregion
268
+ export { renderToReadableStream as i, StreamingContext as n, Suspense as r, ErrorBoundary as t };
@@ -0,0 +1,24 @@
1
+ import { t as DOM_ERROR_HANDLER } from "./constants-BR9jM9BC.js";
2
+ import { t as Fragment } from "./jsx-dev-runtime-kAhR_4C7.js";
3
+ import "./jsx/dom/jsx-runtime.js";
4
+ //#region ../../plugins/acryl-router/src/core/jsx/dom/components.ts
5
+ const ErrorBoundary = (({ children, fallback, fallbackRender, onError }) => {
6
+ const res = Fragment({ children });
7
+ res[DOM_ERROR_HANDLER] = (err) => {
8
+ if (err instanceof Promise) throw err;
9
+ onError?.(err);
10
+ return fallbackRender?.(err) || fallback;
11
+ };
12
+ return res;
13
+ });
14
+ const Suspense = (({ children, fallback }) => {
15
+ const res = Fragment({ children });
16
+ res[DOM_ERROR_HANDLER] = (err, retry) => {
17
+ if (!(err instanceof Promise)) throw err;
18
+ err.finally(retry);
19
+ return fallback;
20
+ };
21
+ return res;
22
+ });
23
+ //#endregion
24
+ export { Suspense as n, ErrorBoundary as t };
package/lib/compress.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler } from "./context-B5Y1lLha.js";
1
+ import { I as MiddlewareHandler } from "./context-DVQBjuns.js";
2
2
  import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from "./utils/compress.js";
3
3
 
4
4
  //#region ../../plugins/acryl-router/src/core/middleware/compress/index.d.ts
package/lib/conninfo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as Context } from "./context-B5Y1lLha.js";
2
- import { i as NetAddrInfo, n as ConnInfo, r as GetConnInfo, t as AddressType } from "./types-ZM9gIiKh.js";
1
+ import { t as Context } from "./context-DVQBjuns.js";
2
+ import { i as NetAddrInfo, n as ConnInfo, r as GetConnInfo, t as AddressType } from "./types-nEL8VPDC.js";
3
3
 
4
4
  //#region ../../plugins/acryl-router/src/connection.d.ts
5
5
  /** An in-process caller (the terminal UI, a test) passes nothing, so a handler that needs a trusted peer must refuse an empty one. */
@@ -0,0 +1,9 @@
1
+ //#region ../../plugins/acryl-router/src/core/jsx/constants.ts
2
+ const DOM_RENDERER = Symbol("RENDERER");
3
+ const DOM_ERROR_HANDLER = Symbol("ERROR_HANDLER");
4
+ const DOM_STASH = Symbol("STASH");
5
+ const DOM_INTERNAL_TAG = Symbol("INTERNAL");
6
+ const DOM_MEMO = Symbol("MEMO");
7
+ const PERMALINK = Symbol("PERMALINK");
8
+ //#endregion
9
+ export { DOM_STASH as a, DOM_RENDERER as i, DOM_INTERNAL_TAG as n, PERMALINK as o, DOM_MEMO as r, DOM_ERROR_HANDLER as t };
@@ -1,7 +1,7 @@
1
1
  import { c as Result, l as Router } from "./router-CvUxUTOq.js";
2
2
  import { i as ResponseHeader, n as CustomHeader, r as RequestHeader } from "./headers-tu2YYN8T.js";
3
3
  import { c as StatusCode, n as ContentfulStatusCode, o as RedirectStatusCode } from "./http-status-DaAwGAFL.js";
4
- import { C as Simplify, E as UnionToIntersection, _ as JSONValue, d as InvalidJSONValue, f as IsAny, h as JSONParsed, l as IfAnyThenEmptyObject, x as RemoveBlankRecord } from "./types-D9DEXMjE.js";
4
+ import { D as UnionToIntersection, S as RemoveBlankRecord, f as InvalidJSONValue, g as JSONParsed, p as IsAny, u as IfAnyThenEmptyObject, v as JSONValue, w as Simplify } from "./types-Lqx5BxQF.js";
5
5
  import { t as BaseMime } from "./mime-BQOYHl-l.js";
6
6
 
7
7
  //#region ../../plugins/acryl-router/src/core/request/constants.d.ts