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.
- package/README.md +4 -1
- package/docs/framework/README.md +3 -2
- package/docs/framework/UPSTREAM.md +1 -1
- package/docs/framework/cordis/acryl-in-a-cordis-app.md +6 -0
- package/docs/framework/getting-started/basic.md +1 -0
- package/docs/framework/getting-started/desktop.md +41 -0
- package/docs/framework/guides/jsx-dom.md +0 -3
- package/docs/framework/guides/jsx.md +0 -3
- package/docs/framework/helpers/css.md +0 -3
- package/docs/framework/upstream.json +3 -3
- package/lib/accepts.d.ts +1 -1
- package/lib/acryl-base.d.ts +1 -1
- package/lib/adapter.d.ts +1 -1
- package/lib/{app-BdrVHBlJ.d.ts → app-wFwpg-bt.d.ts} +1 -1
- package/lib/base-BpQy2Rk7.d.ts +783 -0
- package/lib/base-ddiVmiE7.js +721 -0
- package/lib/basic-auth.d.ts +1 -1
- package/lib/bearer-auth.d.ts +1 -1
- package/lib/body-limit.d.ts +1 -1
- package/lib/cache.d.ts +1 -1
- package/lib/client.d.ts +2 -2
- package/lib/combine.d.ts +1 -1
- package/lib/common-D8Z4JRCw.d.ts +46 -0
- package/lib/components-Ce5FRyHU.js +268 -0
- package/lib/components-DYZdxJIJ.js +24 -0
- package/lib/compress.d.ts +1 -1
- package/lib/conninfo.d.ts +2 -2
- package/lib/constants-BR9jM9BC.js +9 -0
- package/lib/{context-B5Y1lLha.d.ts → context-DVQBjuns.d.ts} +1 -1
- package/lib/context-DxFdY_un.d.ts +250 -0
- package/lib/context-storage.d.ts +1 -1
- package/lib/{cookie-D9_nQbsM.d.ts → cookie-CCelEqky.d.ts} +1 -1
- package/lib/cookie.d.ts +3 -3
- package/lib/cors.d.ts +1 -1
- package/lib/csrf.d.ts +1 -1
- package/lib/css-D2jb7X8b.js +320 -0
- package/lib/css.d.ts +82 -0
- package/lib/css.js +134 -0
- package/lib/dev.d.ts +2 -2
- package/lib/etag.d.ts +1 -1
- package/lib/factory.d.ts +2 -2
- package/lib/hooks-Bq5q9IMl.js +762 -0
- package/lib/html-SllAe0YT.d.ts +46 -0
- package/lib/html.d.ts +1 -1
- package/lib/index-C850MeBA.d.ts +94 -0
- package/lib/{index-m12zcmph.d.ts → index-CUTfU69R.d.ts} +3 -3
- package/lib/{index-DtEoak1i.d.ts → index-Cqcdluyn.d.ts} +2 -2
- package/lib/{index-Kqou8Fjh.d.ts → index-CsvB-F9j.d.ts} +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/ip-restriction.d.ts +2 -2
- package/lib/jsx/dom/client.d.ts +30 -0
- package/lib/jsx/dom/client.js +49 -0
- package/lib/jsx/dom/css.d.ts +84 -0
- package/lib/jsx/dom/css.js +2 -0
- package/lib/jsx/dom/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx/dom/jsx-dev-runtime.js +2 -0
- package/lib/jsx/dom/jsx-runtime.d.ts +3 -0
- package/lib/jsx/dom/jsx-runtime.js +2 -0
- package/lib/jsx/dom/server.d.ts +105 -0
- package/lib/jsx/dom/server.js +37 -0
- package/lib/jsx/dom.d.ts +5 -0
- package/lib/jsx/dom.js +74 -0
- package/lib/jsx/jsx-dev-runtime.d.ts +6 -0
- package/lib/jsx/jsx-dev-runtime.js +14 -0
- package/lib/jsx/jsx-runtime.d.ts +10 -0
- package/lib/jsx/jsx-runtime.js +30 -0
- package/lib/jsx/streaming.d.ts +2 -0
- package/lib/jsx/streaming.js +2 -0
- package/lib/jsx-dev-runtime-B22O-Npk.d.ts +7 -0
- package/lib/jsx-dev-runtime-kAhR_4C7.js +354 -0
- package/lib/jsx-runtime-BVVgDSdq.d.ts +1 -0
- package/lib/jsx.d.ts +3 -0
- package/lib/jsx.js +47 -0
- package/lib/jwk.d.ts +4 -4
- package/lib/{jwt-BA65QhnJ.d.ts → jwt-BARhotDz.d.ts} +1 -1
- package/lib/jwt.d.ts +4 -4
- package/lib/language.d.ts +1 -1
- package/lib/logger.d.ts +1 -1
- package/lib/loopback-only.d.ts +1 -1
- package/lib/method-not-allowed.d.ts +2 -2
- package/lib/method-override.d.ts +2 -2
- package/lib/mount.d.ts +1 -1
- package/lib/node-server/conninfo.d.ts +1 -1
- package/lib/node-server/serve-static.d.ts +1 -1
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +1 -1
- package/lib/node-server.js +1 -1
- package/lib/powered-by.d.ts +1 -1
- package/lib/pretty-json.d.ts +1 -1
- package/lib/proxy.d.ts +1 -1
- package/lib/quick.d.ts +1 -1
- package/lib/request-id.d.ts +1 -1
- package/lib/request.d.ts +1 -1
- package/lib/route.d.ts +1 -1
- package/lib/schema-validator.d.ts +1 -1
- package/lib/secure-headers.d.ts +1 -1
- package/lib/{serve-static-Dw_m6KxR.js → serve-static-Cw23shXv.js} +1 -0
- package/lib/serve-static.d.ts +1 -1
- package/lib/streaming.d.ts +1 -1
- package/lib/testing.d.ts +4 -4
- package/lib/timeout.d.ts +1 -1
- package/lib/timing.d.ts +1 -1
- package/lib/tiny.d.ts +1 -1
- package/lib/trailing-slash.d.ts +1 -1
- package/lib/{types-Bd29gh2o.d.ts → types-CQiGmsWW.d.ts} +3 -3
- package/lib/{types-D9DEXMjE.d.ts → types-Lqx5BxQF.d.ts} +8 -1
- package/lib/{types-ZM9gIiKh.d.ts → types-nEL8VPDC.d.ts} +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/utils/body.d.ts +1 -1
- package/lib/utils/cookie.d.ts +1 -1
- package/lib/utils/crypto.d.ts +1 -1
- package/lib/utils/html.d.ts +1 -45
- package/lib/utils/ipaddr.d.ts +1 -1
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/types.d.ts +2 -2
- package/lib/validator.d.ts +2 -2
- package/lib/ws.d.ts +1 -1
- package/package.json +45 -1
- package/plugins/acryl-inspect/upstream.json +1 -1
- package/plugins/acryl-node-server/upstream.json +1 -1
- package/plugins/acryl-router/src/core/helper/css/common.case.test.tsx +506 -0
- package/plugins/acryl-router/src/core/helper/css/common.ts +337 -0
- package/plugins/acryl-router/src/core/helper/css/index.test.tsx +678 -0
- package/plugins/acryl-router/src/core/helper/css/index.ts +262 -0
- package/plugins/acryl-router/src/core/helper/streaming/sse.test.tsx +557 -0
- package/plugins/acryl-router/src/core/jsx/base.test.tsx +97 -0
- package/plugins/acryl-router/src/core/jsx/base.ts +490 -0
- package/plugins/acryl-router/src/core/jsx/children.test.ts +52 -0
- package/plugins/acryl-router/src/core/jsx/children.ts +20 -0
- package/plugins/acryl-router/src/core/jsx/components.test.tsx +936 -0
- package/plugins/acryl-router/src/core/jsx/components.ts +257 -0
- package/plugins/acryl-router/src/core/jsx/constants.ts +6 -0
- package/plugins/acryl-router/src/core/jsx/context-isolation.test.ts +655 -0
- package/plugins/acryl-router/src/core/jsx/context.ts +266 -0
- package/plugins/acryl-router/src/core/jsx/dom/client.test.tsx +128 -0
- package/plugins/acryl-router/src/core/jsx/dom/client.ts +89 -0
- package/plugins/acryl-router/src/core/jsx/dom/components.test.tsx +330 -0
- package/plugins/acryl-router/src/core/jsx/dom/components.ts +39 -0
- package/plugins/acryl-router/src/core/jsx/dom/context.test.tsx +184 -0
- package/plugins/acryl-router/src/core/jsx/dom/context.ts +52 -0
- package/plugins/acryl-router/src/core/jsx/dom/css.test.tsx +149 -0
- package/plugins/acryl-router/src/core/jsx/dom/css.ts +263 -0
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.test.tsx +172 -0
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.ts +91 -0
- package/plugins/acryl-router/src/core/jsx/dom/index.test.tsx +3681 -0
- package/plugins/acryl-router/src/core/jsx/dom/index.ts +170 -0
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.test.tsx +1344 -0
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.ts +438 -0
- package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.ts +23 -0
- package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.ts +8 -0
- package/plugins/acryl-router/src/core/jsx/dom/render.ts +879 -0
- package/plugins/acryl-router/src/core/jsx/dom/server.test.tsx +199 -0
- package/plugins/acryl-router/src/core/jsx/dom/server.ts +76 -0
- package/plugins/acryl-router/src/core/jsx/dom/utils.ts +7 -0
- package/plugins/acryl-router/src/core/jsx/hooks/dom.test.tsx +859 -0
- package/plugins/acryl-router/src/core/jsx/hooks/index.ts +437 -0
- package/plugins/acryl-router/src/core/jsx/hooks/string.test.tsx +40 -0
- package/plugins/acryl-router/src/core/jsx/index.test.tsx +1744 -0
- package/plugins/acryl-router/src/core/jsx/index.ts +115 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.ts +23 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.test.tsx +666 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.ts +210 -0
- package/plugins/acryl-router/src/core/jsx/intrinsic-elements.ts +938 -0
- package/plugins/acryl-router/src/core/jsx/jsx-dev-runtime.ts +26 -0
- package/plugins/acryl-router/src/core/jsx/jsx-runtime.test.tsx +85 -0
- package/plugins/acryl-router/src/core/jsx/jsx-runtime.ts +51 -0
- package/plugins/acryl-router/src/core/jsx/streaming.test.tsx +1281 -0
- package/plugins/acryl-router/src/core/jsx/streaming.ts +231 -0
- package/plugins/acryl-router/src/core/jsx/types.ts +41 -0
- package/plugins/acryl-router/src/core/jsx/utils.test.ts +366 -0
- package/plugins/acryl-router/src/core/jsx/utils.ts +202 -0
- package/plugins/acryl-router/src/core/utils/types.ts +6 -0
- package/plugins/acryl-router/src/helpers/index.ts +1 -0
- package/plugins/acryl-router/tests/jsx.spec.tsx +63 -0
- package/plugins/acryl-router/upstream.json +3 -3
- package/plugins/acryl-router-http/upstream.json +1 -1
- package/plugins/acryl-state/upstream.json +1 -1
- package/plugins/desktop/upstream.json +1 -1
- package/plugins/desktop-web/upstream.json +1 -1
- package/plugins/save/plugin.json +1 -1
- package/templates/todo/upstream.json +1 -1
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import { escapeToBuffer, raw, resolveCallbackSync, stringBufferToString } from "./utils/html.js";
|
|
2
|
+
import { i as DOM_RENDERER, n as DOM_INTERNAL_TAG, o as PERMALINK, r as DOM_MEMO, t as DOM_ERROR_HANDLER } from "./constants-BR9jM9BC.js";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region ../../plugins/acryl-router/src/core/jsx/dom/utils.ts
|
|
16
|
+
const setInternalTagFlag = (fn) => {
|
|
17
|
+
fn[DOM_INTERNAL_TAG] = true;
|
|
18
|
+
return fn;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../../plugins/acryl-router/src/core/jsx/dom/context.ts
|
|
22
|
+
const createContextProviderFunction = (values) => ({ value, children }) => {
|
|
23
|
+
if (!children) return;
|
|
24
|
+
const props = { children: [{
|
|
25
|
+
tag: setInternalTagFlag(() => {
|
|
26
|
+
values.push(value);
|
|
27
|
+
}),
|
|
28
|
+
props: {}
|
|
29
|
+
}] };
|
|
30
|
+
if (Array.isArray(children)) props.children.push(...children.flat());
|
|
31
|
+
else props.children.push(children);
|
|
32
|
+
props.children.push({
|
|
33
|
+
tag: setInternalTagFlag(() => {
|
|
34
|
+
values.pop();
|
|
35
|
+
}),
|
|
36
|
+
props: {}
|
|
37
|
+
});
|
|
38
|
+
const res = {
|
|
39
|
+
tag: "",
|
|
40
|
+
props,
|
|
41
|
+
type: ""
|
|
42
|
+
};
|
|
43
|
+
res[DOM_ERROR_HANDLER] = (err) => {
|
|
44
|
+
values.pop();
|
|
45
|
+
throw err;
|
|
46
|
+
};
|
|
47
|
+
return res;
|
|
48
|
+
};
|
|
49
|
+
const createContext$1 = (defaultValue) => {
|
|
50
|
+
const values = [defaultValue];
|
|
51
|
+
const context = createContextProviderFunction(values);
|
|
52
|
+
context.values = values;
|
|
53
|
+
context.Provider = context;
|
|
54
|
+
globalContexts.push(context);
|
|
55
|
+
return context;
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../../plugins/acryl-router/src/core/jsx/context.ts
|
|
59
|
+
const globalContexts = [];
|
|
60
|
+
let alsProbed = false;
|
|
61
|
+
let asyncLocalStorage;
|
|
62
|
+
let fallbackStore;
|
|
63
|
+
let fallbackRendersInFlight = 0;
|
|
64
|
+
let warnedFallbackDefault = false;
|
|
65
|
+
const loadAsyncLocalStorage = () => {
|
|
66
|
+
if (alsProbed) return asyncLocalStorage;
|
|
67
|
+
alsProbed = true;
|
|
68
|
+
const global = globalThis;
|
|
69
|
+
let AsyncLocalStorage;
|
|
70
|
+
for (const probe of [() => global.process?.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage, () => global.process?.mainModule?.require?.("node:async_hooks")?.AsyncLocalStorage]) {
|
|
71
|
+
try {
|
|
72
|
+
AsyncLocalStorage = probe();
|
|
73
|
+
} catch {}
|
|
74
|
+
if (AsyncLocalStorage) break;
|
|
75
|
+
}
|
|
76
|
+
if (AsyncLocalStorage) asyncLocalStorage = new AsyncLocalStorage();
|
|
77
|
+
return asyncLocalStorage;
|
|
78
|
+
};
|
|
79
|
+
const getCurrentStore = () => {
|
|
80
|
+
return loadAsyncLocalStorage()?.getStore() || fallbackStore;
|
|
81
|
+
};
|
|
82
|
+
const warnIfStorelessAccess = () => {
|
|
83
|
+
if (fallbackRendersInFlight > 0 && !warnedFallbackDefault) {
|
|
84
|
+
warnedFallbackDefault = true;
|
|
85
|
+
console.warn("acryl-router/jsx: AsyncLocalStorage is unavailable in this runtime, so useContext() after an await in an async component falls back to the context default value during server-side rendering. To get provided values across await boundaries, use a runtime with AsyncLocalStorage (Node.js >= 20.16, Deno, Bun, or Cloudflare Workers with the nodejs_compat flag).");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const getContextValuesIn = (store, context) => {
|
|
89
|
+
if (!store) {
|
|
90
|
+
warnIfStorelessAccess();
|
|
91
|
+
return context.values;
|
|
92
|
+
}
|
|
93
|
+
let values = store.get(context);
|
|
94
|
+
if (!values) {
|
|
95
|
+
values = [context.values[0]];
|
|
96
|
+
store.set(context, values);
|
|
97
|
+
}
|
|
98
|
+
return values;
|
|
99
|
+
};
|
|
100
|
+
const readContextValueIn = (store, context) => {
|
|
101
|
+
if (!store) {
|
|
102
|
+
warnIfStorelessAccess();
|
|
103
|
+
return context.values.at(-1);
|
|
104
|
+
}
|
|
105
|
+
const values = store.get(context);
|
|
106
|
+
return values?.length ? values.at(-1) : context.values[0];
|
|
107
|
+
};
|
|
108
|
+
const captureContextValues = (store) => (store ? globalContexts.filter((c) => store.has(c)) : globalContexts).map((c) => [c, readContextValueIn(store, c)]);
|
|
109
|
+
const resumeWithContextValues = (callback, store, contexts) => runWithRenderContext(() => {
|
|
110
|
+
const currentStore = getCurrentStore();
|
|
111
|
+
const valuesPerContext = contexts.map(([context, value]) => {
|
|
112
|
+
const values = getContextValuesIn(currentStore, context);
|
|
113
|
+
values.push(value);
|
|
114
|
+
return values;
|
|
115
|
+
});
|
|
116
|
+
const popContextValues = () => {
|
|
117
|
+
valuesPerContext.forEach((values) => {
|
|
118
|
+
values.pop();
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
try {
|
|
122
|
+
const result = callback();
|
|
123
|
+
if (result instanceof Promise) return result.finally(popContextValues);
|
|
124
|
+
popContextValues();
|
|
125
|
+
return result;
|
|
126
|
+
} catch (e) {
|
|
127
|
+
popContextValues();
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
130
|
+
}, store);
|
|
131
|
+
/**
|
|
132
|
+
* Establish the request-scoped context store for a render.
|
|
133
|
+
*
|
|
134
|
+
* `resumeStore` continues a suspended subtree in the same store on the fallback
|
|
135
|
+
* path (ignored when `AsyncLocalStorage` is available, where isolation is
|
|
136
|
+
* automatic).
|
|
137
|
+
*
|
|
138
|
+
* Without `AsyncLocalStorage` a render can't be followed across `await`, so the
|
|
139
|
+
* store lives in `fallbackStore` only during synchronous work (mirroring
|
|
140
|
+
* React's request storage). Reading context after `await` then finds no store
|
|
141
|
+
* and falls back to the default value — never another request's value.
|
|
142
|
+
*/
|
|
143
|
+
const runWithRenderContext = (callback, resumeStore) => {
|
|
144
|
+
if (getCurrentStore()) return callback();
|
|
145
|
+
const store = resumeStore ?? /* @__PURE__ */ new WeakMap();
|
|
146
|
+
const storage = loadAsyncLocalStorage();
|
|
147
|
+
if (storage) return storage.run(store, callback);
|
|
148
|
+
fallbackStore = store;
|
|
149
|
+
let result;
|
|
150
|
+
try {
|
|
151
|
+
result = callback();
|
|
152
|
+
} finally {
|
|
153
|
+
fallbackStore = void 0;
|
|
154
|
+
}
|
|
155
|
+
if (!warnedFallbackDefault && result instanceof Promise) {
|
|
156
|
+
fallbackRendersInFlight++;
|
|
157
|
+
result = result.finally(() => {
|
|
158
|
+
fallbackRendersInFlight--;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Capture the current render store and return a resumer that re-establishes it
|
|
165
|
+
* around a deferred continuation (e.g. a re-render after a suspended promise
|
|
166
|
+
* settles). Shared by every suspension point so none reimplements it.
|
|
167
|
+
*/
|
|
168
|
+
const captureRenderContext = () => {
|
|
169
|
+
const store = getCurrentStore();
|
|
170
|
+
const contexts = captureContextValues(store);
|
|
171
|
+
return (callback) => resumeWithContextValues(callback, store, contexts);
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Create a context whose value can be provided with `<Context.Provider>` and
|
|
175
|
+
* read with {@link useContext}.
|
|
176
|
+
*
|
|
177
|
+
* Server-side renders are isolated per request, so a provided value never leaks
|
|
178
|
+
* into a concurrent request — even across `await` in an async component, when
|
|
179
|
+
* `AsyncLocalStorage` is available (Node.js >= 20.16, Deno, Bun, Cloudflare
|
|
180
|
+
* Workers with `nodejs_compat`). Without it, reading context after `await`
|
|
181
|
+
* returns the default value; synchronous components and `use()`-based
|
|
182
|
+
* suspension are unaffected.
|
|
183
|
+
*/
|
|
184
|
+
const createContext = (defaultValue) => {
|
|
185
|
+
const values = [defaultValue];
|
|
186
|
+
const context = ((props) => {
|
|
187
|
+
const contextValues = getContextValuesIn(getCurrentStore(), context);
|
|
188
|
+
contextValues.push(props.value);
|
|
189
|
+
let rendered;
|
|
190
|
+
try {
|
|
191
|
+
rendered = typeof props.children === "string" ? renderChildren([props.children]) : isUntrustedObject(props.children) ? renderUntrustedObject(props.children) : props.children ? (Array.isArray(props.children) ? new JSXFragmentNode("", {}, props.children) : props.children).toString() : raw("");
|
|
192
|
+
} catch (e) {
|
|
193
|
+
contextValues.pop();
|
|
194
|
+
throw e;
|
|
195
|
+
}
|
|
196
|
+
if (rendered instanceof Promise) return rendered.finally(() => contextValues.pop()).then((resString) => raw(resString, resString.callbacks));
|
|
197
|
+
else {
|
|
198
|
+
contextValues.pop();
|
|
199
|
+
return raw(rendered);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
context.values = values;
|
|
203
|
+
context.Provider = context;
|
|
204
|
+
context[DOM_RENDERER] = createContextProviderFunction(values);
|
|
205
|
+
globalContexts.push(context);
|
|
206
|
+
return context;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Read the current value of a context created with {@link createContext}.
|
|
210
|
+
*
|
|
211
|
+
* Safe to call from async components after `await`. See {@link createContext}
|
|
212
|
+
* for the per-runtime isolation guarantees.
|
|
213
|
+
*/
|
|
214
|
+
const useContext = (context) => {
|
|
215
|
+
return readContextValueIn(getCurrentStore(), context);
|
|
216
|
+
};
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region ../../plugins/acryl-router/src/core/jsx/intrinsic-element/common.ts
|
|
219
|
+
const deDupeKeyMap = {
|
|
220
|
+
title: [],
|
|
221
|
+
script: ["src"],
|
|
222
|
+
style: ["data-href"],
|
|
223
|
+
link: ["href"],
|
|
224
|
+
meta: [
|
|
225
|
+
"name",
|
|
226
|
+
"httpEquiv",
|
|
227
|
+
"charset",
|
|
228
|
+
"itemProp"
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
const domRenderers = {};
|
|
232
|
+
const dataPrecedenceAttr = "data-precedence";
|
|
233
|
+
const isStylesheetLinkWithPrecedence = (props) => props.rel === "stylesheet" && "precedence" in props;
|
|
234
|
+
const shouldDeDupeByKey = (tagName, supportSort) => {
|
|
235
|
+
if (tagName === "link") return supportSort;
|
|
236
|
+
return deDupeKeyMap[tagName].length > 0;
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region ../../plugins/acryl-router/src/core/jsx/children.ts
|
|
240
|
+
const toArray = (children) => Array.isArray(children) ? children : [children];
|
|
241
|
+
const Children = {
|
|
242
|
+
map: (children, fn) => toArray(children).map(fn),
|
|
243
|
+
forEach: (children, fn) => {
|
|
244
|
+
toArray(children).forEach(fn);
|
|
245
|
+
},
|
|
246
|
+
count: (children) => toArray(children).length,
|
|
247
|
+
only: (_children) => {
|
|
248
|
+
const children = toArray(_children);
|
|
249
|
+
if (children.length !== 1) throw new Error("Children.only() expects only one child");
|
|
250
|
+
return children[0];
|
|
251
|
+
},
|
|
252
|
+
toArray
|
|
253
|
+
};
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region ../../plugins/acryl-router/src/core/jsx/intrinsic-element/components.ts
|
|
256
|
+
var components_exports = /* @__PURE__ */ __exportAll({
|
|
257
|
+
button: () => button,
|
|
258
|
+
form: () => form,
|
|
259
|
+
input: () => input,
|
|
260
|
+
link: () => link,
|
|
261
|
+
meta: () => meta,
|
|
262
|
+
script: () => script,
|
|
263
|
+
style: () => style,
|
|
264
|
+
title: () => title
|
|
265
|
+
});
|
|
266
|
+
const metaTagMap = /* @__PURE__ */ new WeakMap();
|
|
267
|
+
const insertIntoHead = (tagName, tag, props, precedence) => ({ buffer, context }) => {
|
|
268
|
+
if (!buffer) return;
|
|
269
|
+
const map = metaTagMap.get(context) || {};
|
|
270
|
+
metaTagMap.set(context, map);
|
|
271
|
+
const tags = map[tagName] ||= [];
|
|
272
|
+
let duped = false;
|
|
273
|
+
const deDupeKeys = deDupeKeyMap[tagName];
|
|
274
|
+
const deDupeByKey = shouldDeDupeByKey(tagName, precedence !== void 0);
|
|
275
|
+
if (deDupeByKey) LOOP: for (const [, tagProps] of tags) {
|
|
276
|
+
if (tagName === "link" && !(tagProps.rel === "stylesheet" && tagProps["data-precedence"] !== void 0)) continue;
|
|
277
|
+
for (const key of deDupeKeys) if ((tagProps?.[key] ?? null) === props?.[key]) {
|
|
278
|
+
duped = true;
|
|
279
|
+
break LOOP;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (duped) buffer[0] = buffer[0].replaceAll(tag, "");
|
|
283
|
+
else if (deDupeByKey || tagName === "link") tags.push([
|
|
284
|
+
tag,
|
|
285
|
+
props,
|
|
286
|
+
precedence
|
|
287
|
+
]);
|
|
288
|
+
else tags.unshift([
|
|
289
|
+
tag,
|
|
290
|
+
props,
|
|
291
|
+
precedence
|
|
292
|
+
]);
|
|
293
|
+
if (buffer[0].indexOf("</head>") !== -1) {
|
|
294
|
+
let insertTags;
|
|
295
|
+
if (tagName === "link" || precedence !== void 0) {
|
|
296
|
+
const precedences = [];
|
|
297
|
+
insertTags = tags.map(([tag, , tagPrecedence], index) => {
|
|
298
|
+
if (tagPrecedence === void 0) return [
|
|
299
|
+
tag,
|
|
300
|
+
Number.MAX_SAFE_INTEGER,
|
|
301
|
+
index
|
|
302
|
+
];
|
|
303
|
+
let order = precedences.indexOf(tagPrecedence);
|
|
304
|
+
if (order === -1) {
|
|
305
|
+
precedences.push(tagPrecedence);
|
|
306
|
+
order = precedences.length - 1;
|
|
307
|
+
}
|
|
308
|
+
return [
|
|
309
|
+
tag,
|
|
310
|
+
order,
|
|
311
|
+
index
|
|
312
|
+
];
|
|
313
|
+
}).sort((a, b) => a[1] - b[1] || a[2] - b[2]).map(([tag]) => tag);
|
|
314
|
+
} else insertTags = tags.map(([tag]) => tag);
|
|
315
|
+
insertTags.forEach((tag) => {
|
|
316
|
+
buffer[0] = buffer[0].replaceAll(tag, "");
|
|
317
|
+
});
|
|
318
|
+
buffer[0] = buffer[0].replace(/(?=<\/head>)/, () => insertTags.join(""));
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const returnWithoutSpecialBehavior = (tag, children, props) => renderChildren([new JSXNode(tag, props, toArray(children ?? []))]);
|
|
322
|
+
const documentMetadataTag = (tag, children, props, sort) => {
|
|
323
|
+
if ("itemProp" in props) return returnWithoutSpecialBehavior(tag, children, props);
|
|
324
|
+
let { precedence, blocking, ...restProps } = props;
|
|
325
|
+
precedence = sort ? precedence ?? "" : void 0;
|
|
326
|
+
if (sort) restProps[dataPrecedenceAttr] = precedence;
|
|
327
|
+
const string = new JSXNode(tag, restProps, toArray(children || [])).toString();
|
|
328
|
+
if (string instanceof Promise) return string.then((resString) => raw(resString, [...resString.callbacks || [], insertIntoHead(tag, resString, restProps, precedence)]));
|
|
329
|
+
else return raw(string, [insertIntoHead(tag, string, restProps, precedence)]);
|
|
330
|
+
};
|
|
331
|
+
const title = ({ children, ...props }) => {
|
|
332
|
+
const nameSpaceContext = getNameSpaceContext();
|
|
333
|
+
if (nameSpaceContext) {
|
|
334
|
+
const context = useContext(nameSpaceContext);
|
|
335
|
+
if (context === "svg" || context === "head") return new JSXNode("title", props, toArray(children ?? []));
|
|
336
|
+
}
|
|
337
|
+
return documentMetadataTag("title", children, props, false);
|
|
338
|
+
};
|
|
339
|
+
const script = ({ children, ...props }) => {
|
|
340
|
+
const nameSpaceContext = getNameSpaceContext();
|
|
341
|
+
if (["src", "async"].some((k) => !props[k]) || nameSpaceContext && useContext(nameSpaceContext) === "head") return returnWithoutSpecialBehavior("script", children, props);
|
|
342
|
+
return documentMetadataTag("script", children, props, false);
|
|
343
|
+
};
|
|
344
|
+
const style = ({ children, ...props }) => {
|
|
345
|
+
if (!["href", "precedence"].every((k) => k in props)) return returnWithoutSpecialBehavior("style", children, props);
|
|
346
|
+
props["data-href"] = props.href;
|
|
347
|
+
delete props.href;
|
|
348
|
+
return documentMetadataTag("style", children, props, true);
|
|
349
|
+
};
|
|
350
|
+
const link = ({ children, ...props }) => {
|
|
351
|
+
if (["onLoad", "onError"].some((k) => k in props) || props.rel === "stylesheet" && (!("precedence" in props) || "disabled" in props)) return returnWithoutSpecialBehavior("link", children, props);
|
|
352
|
+
return documentMetadataTag("link", children, props, isStylesheetLinkWithPrecedence(props));
|
|
353
|
+
};
|
|
354
|
+
const meta = ({ children, ...props }) => {
|
|
355
|
+
const nameSpaceContext = getNameSpaceContext();
|
|
356
|
+
if (nameSpaceContext && useContext(nameSpaceContext) === "head") return returnWithoutSpecialBehavior("meta", children, props);
|
|
357
|
+
return documentMetadataTag("meta", children, props, false);
|
|
358
|
+
};
|
|
359
|
+
const newJSXNode = (tag, { children, ...props }) => new JSXNode(tag, props, toArray(children ?? []));
|
|
360
|
+
const form = (props) => {
|
|
361
|
+
if (typeof props.action === "function") props.action = PERMALINK in props.action ? props.action[PERMALINK] : void 0;
|
|
362
|
+
return newJSXNode("form", props);
|
|
363
|
+
};
|
|
364
|
+
const formActionableElement = (tag, props) => {
|
|
365
|
+
if (typeof props.formAction === "function") props.formAction = PERMALINK in props.formAction ? props.formAction[PERMALINK] : void 0;
|
|
366
|
+
return newJSXNode(tag, props);
|
|
367
|
+
};
|
|
368
|
+
const input = (props) => formActionableElement("input", props);
|
|
369
|
+
const button = (props) => formActionableElement("button", props);
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region ../../plugins/acryl-router/src/core/jsx/utils.ts
|
|
372
|
+
const normalizeElementKeyMap = /* @__PURE__ */ new Map([
|
|
373
|
+
["className", "class"],
|
|
374
|
+
["htmlFor", "for"],
|
|
375
|
+
["crossOrigin", "crossorigin"],
|
|
376
|
+
["httpEquiv", "http-equiv"],
|
|
377
|
+
["itemProp", "itemprop"],
|
|
378
|
+
["fetchPriority", "fetchpriority"],
|
|
379
|
+
["noModule", "nomodule"],
|
|
380
|
+
["formAction", "formaction"]
|
|
381
|
+
]);
|
|
382
|
+
const normalizeIntrinsicElementKey = (key) => normalizeElementKeyMap.get(key) || key;
|
|
383
|
+
const invalidAttributeNameCharRe = /[\s"'<>/=`\\\x00-\x1f\x7f-\x9f]/;
|
|
384
|
+
const validAttributeNameCache = /* @__PURE__ */ new Set();
|
|
385
|
+
const validAttributeNameCacheMax = 1024;
|
|
386
|
+
const invalidTagNameCharRe = /^[!?]|[\s"'<>/=`\\\x00-\x1f\x7f-\x9f]/;
|
|
387
|
+
const validTagNameCache = /* @__PURE__ */ new Set();
|
|
388
|
+
const validTagNameCacheMax = 256;
|
|
389
|
+
const cacheValidName = (cache, max, name) => {
|
|
390
|
+
if (cache.size >= max) cache.clear();
|
|
391
|
+
cache.add(name);
|
|
392
|
+
};
|
|
393
|
+
const isValidTagName = (name) => {
|
|
394
|
+
if (validTagNameCache.has(name)) return true;
|
|
395
|
+
if (typeof name !== "string") return false;
|
|
396
|
+
if (name.length === 0) return true;
|
|
397
|
+
if (invalidTagNameCharRe.test(name)) return false;
|
|
398
|
+
cacheValidName(validTagNameCache, validTagNameCacheMax, name);
|
|
399
|
+
return true;
|
|
400
|
+
};
|
|
401
|
+
const isValidAttributeName = (name) => {
|
|
402
|
+
if (validAttributeNameCache.has(name)) return true;
|
|
403
|
+
const len = name.length;
|
|
404
|
+
if (len === 0) return false;
|
|
405
|
+
for (let i = 0; i < len; i++) {
|
|
406
|
+
const c = name.charCodeAt(i);
|
|
407
|
+
if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 45 || c === 95 || c === 46 || c === 58)) if (!invalidAttributeNameCharRe.test(name)) {
|
|
408
|
+
cacheValidName(validAttributeNameCache, validAttributeNameCacheMax, name);
|
|
409
|
+
return true;
|
|
410
|
+
} else return false;
|
|
411
|
+
}
|
|
412
|
+
cacheValidName(validAttributeNameCache, validAttributeNameCacheMax, name);
|
|
413
|
+
return true;
|
|
414
|
+
};
|
|
415
|
+
const invalidStylePropertyNameCharRe = /[\s"'():;\\/\[\]{}\x00-\x1f\x7f-\x9f]/;
|
|
416
|
+
const validStylePropertyNameCache = /* @__PURE__ */ new Set();
|
|
417
|
+
const validStylePropertyNameCacheMax = 1024;
|
|
418
|
+
const isValidStylePropertyName = (name) => {
|
|
419
|
+
if (validStylePropertyNameCache.has(name)) return true;
|
|
420
|
+
const len = name.length;
|
|
421
|
+
if (len === 0) return false;
|
|
422
|
+
for (let i = 0; i < len; i++) {
|
|
423
|
+
const c = name.charCodeAt(i);
|
|
424
|
+
if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 45 || c === 95)) if (!invalidStylePropertyNameCharRe.test(name)) {
|
|
425
|
+
cacheValidName(validStylePropertyNameCache, validStylePropertyNameCacheMax, name);
|
|
426
|
+
return true;
|
|
427
|
+
} else return false;
|
|
428
|
+
}
|
|
429
|
+
cacheValidName(validStylePropertyNameCache, validStylePropertyNameCacheMax, name);
|
|
430
|
+
return true;
|
|
431
|
+
};
|
|
432
|
+
const unsafeStyleValueCharRe = /[;"'\\/\[\](){}]/;
|
|
433
|
+
const hasUnsafeStyleValue = (value) => {
|
|
434
|
+
if (!unsafeStyleValueCharRe.test(value)) return false;
|
|
435
|
+
let quote = 0;
|
|
436
|
+
const blockStack = [];
|
|
437
|
+
for (let i = 0, len = value.length; i < len; i++) {
|
|
438
|
+
const c = value.charCodeAt(i);
|
|
439
|
+
if (c === 92) {
|
|
440
|
+
if (i === len - 1) return true;
|
|
441
|
+
i++;
|
|
442
|
+
} else if (quote !== 0) {
|
|
443
|
+
if (c === 10 || c === 12 || c === 13) return true;
|
|
444
|
+
if (c === quote) quote = 0;
|
|
445
|
+
} else if (c === 47 && value.charCodeAt(i + 1) === 42) {
|
|
446
|
+
const end = value.indexOf("*/", i + 2);
|
|
447
|
+
if (end === -1) return true;
|
|
448
|
+
i = end + 1;
|
|
449
|
+
} else if (c === 34 || c === 39) quote = c;
|
|
450
|
+
else if (c === 40) blockStack.push(41);
|
|
451
|
+
else if (c === 91) blockStack.push(93);
|
|
452
|
+
else if (c === 123 || c === 125) return true;
|
|
453
|
+
else if (c === 41 || c === 93) {
|
|
454
|
+
if (blockStack[blockStack.length - 1] !== c) return true;
|
|
455
|
+
blockStack.pop();
|
|
456
|
+
} else if (c === 59 && blockStack.length === 0) return true;
|
|
457
|
+
}
|
|
458
|
+
return quote !== 0 || blockStack.length !== 0;
|
|
459
|
+
};
|
|
460
|
+
const styleObjectForEach = (style, fn) => {
|
|
461
|
+
for (const [k, v] of Object.entries(style)) {
|
|
462
|
+
const key = k[0] === "-" || !/[A-Z]/.test(k) ? k : k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
463
|
+
if (!isValidStylePropertyName(key)) continue;
|
|
464
|
+
if (v == null) {
|
|
465
|
+
fn(key, null);
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
let value;
|
|
469
|
+
if (typeof v === "number") value = !key.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?!.*gap)(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/) ? `${v}px` : `${v}`;
|
|
470
|
+
else if (typeof v === "string") {
|
|
471
|
+
if (hasUnsafeStyleValue(v)) continue;
|
|
472
|
+
value = v;
|
|
473
|
+
} else continue;
|
|
474
|
+
fn(key, value);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region ../../plugins/acryl-router/src/core/jsx/base.ts
|
|
479
|
+
let nameSpaceContext = void 0;
|
|
480
|
+
const getNameSpaceContext = () => nameSpaceContext;
|
|
481
|
+
const toSVGAttributeName = (key) => /[A-Z]/.test(key) && key.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key;
|
|
482
|
+
const emptyTags = [
|
|
483
|
+
"area",
|
|
484
|
+
"base",
|
|
485
|
+
"br",
|
|
486
|
+
"col",
|
|
487
|
+
"embed",
|
|
488
|
+
"hr",
|
|
489
|
+
"img",
|
|
490
|
+
"input",
|
|
491
|
+
"keygen",
|
|
492
|
+
"link",
|
|
493
|
+
"meta",
|
|
494
|
+
"param",
|
|
495
|
+
"source",
|
|
496
|
+
"track",
|
|
497
|
+
"wbr"
|
|
498
|
+
];
|
|
499
|
+
const booleanAttributes = [
|
|
500
|
+
"allowfullscreen",
|
|
501
|
+
"async",
|
|
502
|
+
"autofocus",
|
|
503
|
+
"autoplay",
|
|
504
|
+
"checked",
|
|
505
|
+
"controls",
|
|
506
|
+
"default",
|
|
507
|
+
"defer",
|
|
508
|
+
"disabled",
|
|
509
|
+
"download",
|
|
510
|
+
"formnovalidate",
|
|
511
|
+
"hidden",
|
|
512
|
+
"inert",
|
|
513
|
+
"ismap",
|
|
514
|
+
"itemscope",
|
|
515
|
+
"loop",
|
|
516
|
+
"multiple",
|
|
517
|
+
"muted",
|
|
518
|
+
"nomodule",
|
|
519
|
+
"novalidate",
|
|
520
|
+
"open",
|
|
521
|
+
"playsinline",
|
|
522
|
+
"readonly",
|
|
523
|
+
"required",
|
|
524
|
+
"reversed",
|
|
525
|
+
"selected"
|
|
526
|
+
];
|
|
527
|
+
const resolveFunctionComponentResult = (result, suspendedContext) => result.then((resolved) => {
|
|
528
|
+
if (typeof resolved !== "string" && !Array.isArray(resolved) && !(resolved instanceof JSXNode)) return resolved;
|
|
529
|
+
const children = Array.isArray(resolved) ? resolved : [resolved];
|
|
530
|
+
const render = () => {
|
|
531
|
+
const buffer = [""];
|
|
532
|
+
childrenToStringToBuffer(children, buffer);
|
|
533
|
+
return buffer.length === 1 ? raw(buffer[0], buffer.callbacks) : stringBufferToString(buffer, buffer.callbacks);
|
|
534
|
+
};
|
|
535
|
+
return suspendedContext ? suspendedContext(render) : runWithRenderContext(render);
|
|
536
|
+
});
|
|
537
|
+
const childrenToStringToBuffer = (children, buffer) => {
|
|
538
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
539
|
+
const child = children[i];
|
|
540
|
+
if (typeof child === "string") escapeToBuffer(child, buffer);
|
|
541
|
+
else if (typeof child === "boolean" || child === null || child === void 0) continue;
|
|
542
|
+
else if (child instanceof JSXNode) child.toStringToBuffer(buffer);
|
|
543
|
+
else if (typeof child === "number") buffer[0] += child;
|
|
544
|
+
else if (child.isEscaped) {
|
|
545
|
+
buffer[0] += child;
|
|
546
|
+
const callbacks = child.callbacks;
|
|
547
|
+
if (callbacks) {
|
|
548
|
+
buffer.callbacks ||= [];
|
|
549
|
+
buffer.callbacks.push(...callbacks);
|
|
550
|
+
}
|
|
551
|
+
} else if (child instanceof Promise) buffer.unshift("", child);
|
|
552
|
+
else childrenToStringToBuffer(child, buffer);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const renderChildren = (children) => runWithRenderContext(() => {
|
|
556
|
+
const buffer = [""];
|
|
557
|
+
childrenToStringToBuffer(children, buffer);
|
|
558
|
+
return buffer.length === 1 ? raw(buffer[0], buffer.callbacks) : stringBufferToString(buffer, buffer.callbacks);
|
|
559
|
+
});
|
|
560
|
+
const isUntrustedObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof JSXNode) && !(value instanceof Promise) && !value.isEscaped && typeof value.toString === "function";
|
|
561
|
+
const renderUntrustedObject = (value) => {
|
|
562
|
+
const stringified = value.toString();
|
|
563
|
+
const escape = (result) => renderChildren([String(result)]);
|
|
564
|
+
return stringified instanceof Promise ? stringified.then(escape) : escape(stringified);
|
|
565
|
+
};
|
|
566
|
+
var JSXNode = class {
|
|
567
|
+
tag;
|
|
568
|
+
props;
|
|
569
|
+
key;
|
|
570
|
+
children;
|
|
571
|
+
isEscaped = true;
|
|
572
|
+
constructor(tag, props, children) {
|
|
573
|
+
if (typeof tag !== "function" && !isValidTagName(tag)) throw new Error(`Invalid JSX tag name: ${tag}`);
|
|
574
|
+
this.tag = tag;
|
|
575
|
+
this.props = props;
|
|
576
|
+
this.children = children;
|
|
577
|
+
}
|
|
578
|
+
get type() {
|
|
579
|
+
return this.tag;
|
|
580
|
+
}
|
|
581
|
+
get ref() {
|
|
582
|
+
return this.props.ref || null;
|
|
583
|
+
}
|
|
584
|
+
toString() {
|
|
585
|
+
const render = () => {
|
|
586
|
+
const buffer = [""];
|
|
587
|
+
this.toStringToBuffer(buffer);
|
|
588
|
+
return buffer.length === 1 ? "callbacks" in buffer ? resolveCallbackSync(raw(buffer[0], buffer.callbacks)).toString() : buffer[0] : stringBufferToString(buffer, buffer.callbacks);
|
|
589
|
+
};
|
|
590
|
+
return runWithRenderContext(render);
|
|
591
|
+
}
|
|
592
|
+
toStringToBuffer(buffer) {
|
|
593
|
+
const tag = this.tag;
|
|
594
|
+
const props = this.props;
|
|
595
|
+
let { children } = this;
|
|
596
|
+
buffer[0] += `<${tag}`;
|
|
597
|
+
const normalizeKey = tag === "svg" || nameSpaceContext && useContext(nameSpaceContext) === "svg" ? (key) => toSVGAttributeName(normalizeIntrinsicElementKey(key)) : (key) => normalizeIntrinsicElementKey(key);
|
|
598
|
+
for (let [key, v] of Object.entries(props)) {
|
|
599
|
+
key = normalizeKey(key);
|
|
600
|
+
if (!isValidAttributeName(key)) continue;
|
|
601
|
+
if (key === "children") {} else if (key === "style" && typeof v === "object") {
|
|
602
|
+
let styleStr = "";
|
|
603
|
+
styleObjectForEach(v, (property, value) => {
|
|
604
|
+
if (value != null) styleStr += `${styleStr ? ";" : ""}${property}:${value}`;
|
|
605
|
+
});
|
|
606
|
+
buffer[0] += " style=\"";
|
|
607
|
+
escapeToBuffer(styleStr, buffer);
|
|
608
|
+
buffer[0] += "\"";
|
|
609
|
+
} else if (typeof v === "string") {
|
|
610
|
+
buffer[0] += ` ${key}="`;
|
|
611
|
+
escapeToBuffer(v, buffer);
|
|
612
|
+
buffer[0] += "\"";
|
|
613
|
+
} else if (v === null || v === void 0) {} else if (typeof v === "number" || v.isEscaped) buffer[0] += ` ${key}="${v}"`;
|
|
614
|
+
else if (typeof v === "boolean" && booleanAttributes.includes(key)) {
|
|
615
|
+
if (v) buffer[0] += ` ${key}=""`;
|
|
616
|
+
} else if (key === "dangerouslySetInnerHTML") {
|
|
617
|
+
if (children.length > 0) throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
|
|
618
|
+
children = [raw(v.__html)];
|
|
619
|
+
} else if (v instanceof Promise) {
|
|
620
|
+
buffer[0] += ` ${key}="`;
|
|
621
|
+
buffer.unshift("\"", v);
|
|
622
|
+
} else if (typeof v === "function") {
|
|
623
|
+
if (!key.startsWith("on") && key !== "ref") throw new Error(`Invalid prop '${key}' of type 'function' supplied to '${tag}'.`);
|
|
624
|
+
} else {
|
|
625
|
+
buffer[0] += ` ${key}="`;
|
|
626
|
+
escapeToBuffer(v.toString(), buffer);
|
|
627
|
+
buffer[0] += "\"";
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (emptyTags.includes(tag) && children.length === 0) {
|
|
631
|
+
buffer[0] += "/>";
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
buffer[0] += ">";
|
|
635
|
+
childrenToStringToBuffer(children, buffer);
|
|
636
|
+
buffer[0] += `</${tag}>`;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
var JSXFunctionNode = class extends JSXNode {
|
|
640
|
+
toStringToBuffer(buffer) {
|
|
641
|
+
const { children } = this;
|
|
642
|
+
const props = { ...this.props };
|
|
643
|
+
if (children.length) props.children = children.length === 1 ? children[0] : children;
|
|
644
|
+
const res = this.tag.call(null, props);
|
|
645
|
+
if (typeof res === "boolean" || res == null) return;
|
|
646
|
+
else if (res instanceof Promise) if (globalContexts.length === 0) buffer.unshift("", resolveFunctionComponentResult(res));
|
|
647
|
+
else buffer.unshift("", resolveFunctionComponentResult(res, captureRenderContext()));
|
|
648
|
+
else if (res instanceof JSXNode) res.toStringToBuffer(buffer);
|
|
649
|
+
else if (Array.isArray(res)) childrenToStringToBuffer(res, buffer);
|
|
650
|
+
else if (typeof res === "number" || res.isEscaped) {
|
|
651
|
+
buffer[0] += res;
|
|
652
|
+
if (res.callbacks) {
|
|
653
|
+
buffer.callbacks ||= [];
|
|
654
|
+
buffer.callbacks.push(...res.callbacks);
|
|
655
|
+
}
|
|
656
|
+
} else escapeToBuffer(res, buffer);
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
var JSXFragmentNode = class extends JSXNode {
|
|
660
|
+
toStringToBuffer(buffer) {
|
|
661
|
+
childrenToStringToBuffer(this.children, buffer);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const jsx = (tag, props, ...children) => {
|
|
665
|
+
props ??= {};
|
|
666
|
+
if (children.length) props.children = children.length === 1 ? children[0] : children;
|
|
667
|
+
const key = props.key;
|
|
668
|
+
delete props["key"];
|
|
669
|
+
const node = jsxFn(tag, props, children);
|
|
670
|
+
node.key = key;
|
|
671
|
+
return node;
|
|
672
|
+
};
|
|
673
|
+
let initDomRenderer = false;
|
|
674
|
+
const jsxFn = (tag, props, children) => {
|
|
675
|
+
if (!initDomRenderer) {
|
|
676
|
+
for (const k in domRenderers) components_exports[k][DOM_RENDERER] = domRenderers[k];
|
|
677
|
+
initDomRenderer = true;
|
|
678
|
+
}
|
|
679
|
+
if (typeof tag === "function") return new JSXFunctionNode(tag, props, children);
|
|
680
|
+
else if (components_exports[tag]) return new JSXFunctionNode(components_exports[tag], props, children);
|
|
681
|
+
else if (tag === "svg" || tag === "head") {
|
|
682
|
+
nameSpaceContext ||= createContext("");
|
|
683
|
+
return new JSXNode(tag, props, [new JSXFunctionNode(nameSpaceContext, { value: tag }, children)]);
|
|
684
|
+
} else return new JSXNode(tag, props, children);
|
|
685
|
+
};
|
|
686
|
+
const shallowEqual = (a, b) => {
|
|
687
|
+
if (a === b) return true;
|
|
688
|
+
const aKeys = Object.keys(a).sort();
|
|
689
|
+
const bKeys = Object.keys(b).sort();
|
|
690
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
691
|
+
for (let i = 0, len = aKeys.length; i < len; i++) if (aKeys[i] === "children" && bKeys[i] === "children" && !a.children?.length && !b.children?.length) continue;
|
|
692
|
+
else if (a[aKeys[i]] !== b[aKeys[i]]) return false;
|
|
693
|
+
return true;
|
|
694
|
+
};
|
|
695
|
+
const memo = (component, propsAreEqual = shallowEqual) => {
|
|
696
|
+
const wrapper = ((props) => component(props));
|
|
697
|
+
wrapper[DOM_MEMO] = propsAreEqual;
|
|
698
|
+
wrapper[DOM_RENDERER] = component;
|
|
699
|
+
return wrapper;
|
|
700
|
+
};
|
|
701
|
+
const Fragment = ({ children }) => {
|
|
702
|
+
return new JSXFragmentNode("", { children }, Array.isArray(children) ? children : children ? [children] : []);
|
|
703
|
+
};
|
|
704
|
+
const isValidElement = (element) => {
|
|
705
|
+
return !!(element && typeof element === "object" && "tag" in element && "props" in element);
|
|
706
|
+
};
|
|
707
|
+
const cloneElement = (element, props, ...children) => {
|
|
708
|
+
let childrenToClone;
|
|
709
|
+
if (children.length > 0) childrenToClone = children;
|
|
710
|
+
else {
|
|
711
|
+
const c = element.props.children;
|
|
712
|
+
childrenToClone = c !== void 0 ? Array.isArray(c) ? c : [c] : [];
|
|
713
|
+
}
|
|
714
|
+
return jsx(element.tag, {
|
|
715
|
+
...element.props,
|
|
716
|
+
...props
|
|
717
|
+
}, ...childrenToClone);
|
|
718
|
+
};
|
|
719
|
+
const reactAPICompatVersion = "19.0.0-acryl-jsx";
|
|
720
|
+
//#endregion
|
|
721
|
+
export { captureRenderContext as C, createContext$1 as D, useContext as E, __exportAll as O, shouldDeDupeByKey as S, globalContexts as T, toArray as _, isValidElement as a, domRenderers as b, memo as c, renderUntrustedObject as d, shallowEqual as f, Children as g, styleObjectForEach as h, isUntrustedObject as i, reactAPICompatVersion as l, normalizeIntrinsicElementKey as m, JSXNode as n, jsx as o, isValidAttributeName as p, cloneElement as r, jsxFn as s, Fragment as t, renderChildren as u, dataPrecedenceAttr as v, createContext as w, isStylesheetLinkWithPrecedence as x, deDupeKeyMap as y };
|