Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
48
node_modules/hono/dist/jsx/dom/context.js
generated
vendored
Normal file
48
node_modules/hono/dist/jsx/dom/context.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// src/jsx/dom/context.ts
|
||||
import { DOM_ERROR_HANDLER } from "../constants.js";
|
||||
import { globalContexts } from "../context.js";
|
||||
import { setInternalTagFlag } from "./utils.js";
|
||||
var createContextProviderFunction = (values) => ({ value, children }) => {
|
||||
if (!children) {
|
||||
return void 0;
|
||||
}
|
||||
const props = {
|
||||
children: [
|
||||
{
|
||||
tag: setInternalTagFlag(() => {
|
||||
values.push(value);
|
||||
}),
|
||||
props: {}
|
||||
}
|
||||
]
|
||||
};
|
||||
if (Array.isArray(children)) {
|
||||
props.children.push(...children.flat());
|
||||
} else {
|
||||
props.children.push(children);
|
||||
}
|
||||
props.children.push({
|
||||
tag: setInternalTagFlag(() => {
|
||||
values.pop();
|
||||
}),
|
||||
props: {}
|
||||
});
|
||||
const res = { tag: "", props, type: "" };
|
||||
res[DOM_ERROR_HANDLER] = (err) => {
|
||||
values.pop();
|
||||
throw err;
|
||||
};
|
||||
return res;
|
||||
};
|
||||
var createContext = (defaultValue) => {
|
||||
const values = [defaultValue];
|
||||
const context = createContextProviderFunction(values);
|
||||
context.values = values;
|
||||
context.Provider = context;
|
||||
globalContexts.push(context);
|
||||
return context;
|
||||
};
|
||||
export {
|
||||
createContext,
|
||||
createContextProviderFunction
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue