@expressive/react
Version:
Use classes to define state in React!
37 lines • 1.02 kB
JavaScript
// src/jsx-runtime.ts
import { Context, METHOD, Model } from "@expressive/mvc";
import Runtime from "react/jsx-runtime";
import { createProvider } from "./context";
import { Fragment } from "react";
function MC(props) {
const local = this.use((self) => {
self.set(props);
if (props.is)
return props.is(self);
});
local.set(props);
const render = METHOD.get(local.render) || props.render;
return createProvider(
Context.get(local),
render ? render.call(local, props, local) : props.children
);
}
var RENDER = /* @__PURE__ */ new WeakMap();
function compat(type, ...args) {
if (typeof type == "function") {
if (RENDER.has(type))
type = RENDER.get(type);
else if (typeof type == "function")
RENDER.set(type, type = type.prototype instanceof Model ? MC.bind(type) : type);
}
return this(type, ...args);
}
var jsx = compat.bind(Runtime.jsx);
var jsxs = compat.bind(Runtime.jsxs);
export {
Fragment,
compat,
jsx,
jsxs
};
//# sourceMappingURL=jsx-runtime.js.map