@expressive/react 0.74.2-canary.0 → 0.75.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.
@@ -1,62 +0,0 @@
1
- const require_chunk = require('./chunk-BE-pF4vm.js');
2
- let _expressive_state = require("@expressive/state");
3
- let react = require("react");
4
-
5
- //#region src/context.ts
6
- const Layers = (0, react.createContext)(new _expressive_state.Context());
7
- _expressive_state.Context.use = (create) => {
8
- const ambient = (0, react.useContext)(Layers);
9
- return create ? (0, react.useMemo)(() => ambient.push(), [ambient]) : ambient;
10
- };
11
- function Consumer(props) {
12
- return props.for.get((i) => props.children(i));
13
- }
14
- function Provider(props) {
15
- const context = _expressive_state.Context.use(true);
16
- (0, react.useEffect)(() => () => context.pop(), [context]);
17
- context.set(props.for, (state) => {
18
- if (props.forEach) {
19
- const cleanup = props.forEach(state);
20
- if (cleanup) state.set(cleanup, null);
21
- }
22
- });
23
- return provide(context, props.children, props.fallback, props.name);
24
- }
25
- function provide(context, children, fallback, name) {
26
- if (fallback !== void 0) children = (0, react.createElement)(react.Suspense, {
27
- fallback,
28
- name
29
- }, children);
30
- return (0, react.createElement)(Layers.Provider, {
31
- key: context.id,
32
- value: context,
33
- children
34
- });
35
- }
36
-
37
- //#endregion
38
- Object.defineProperty(exports, 'Consumer', {
39
- enumerable: true,
40
- get: function () {
41
- return Consumer;
42
- }
43
- });
44
- Object.defineProperty(exports, 'Layers', {
45
- enumerable: true,
46
- get: function () {
47
- return Layers;
48
- }
49
- });
50
- Object.defineProperty(exports, 'Provider', {
51
- enumerable: true,
52
- get: function () {
53
- return Provider;
54
- }
55
- });
56
- Object.defineProperty(exports, 'provide', {
57
- enumerable: true,
58
- get: function () {
59
- return provide;
60
- }
61
- });
62
- //# sourceMappingURL=context-DT3kwoQN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-DT3kwoQN.js","names":["Context","Suspense"],"sources":["../src/context.ts"],"sourcesContent":["import { State, Context } from '@expressive/state';\nimport {\n createContext,\n createElement,\n ReactNode,\n Suspense,\n useContext,\n useEffect,\n useMemo\n} from 'react';\n\nexport const Layers = createContext(new Context());\n\ndeclare module '@expressive/state' {\n namespace Context {\n function use(create?: true): Context;\n function use(create: boolean): Context | null | undefined;\n }\n}\n\nContext.use = (create?: boolean) => {\n const ambient = useContext(Layers);\n\n return create ? useMemo(() => ambient.push(), [ambient]) : ambient;\n};\n\ndeclare namespace Consumer {\n type Props<T extends State> = {\n /** Type of controller to fetch from context. */\n for: State.Extends<T>;\n\n /**\n * Render function, will receive instance of desired controller.\n *\n * Called every render of parent component.\n * Similar to `State.get()`, updates to properties accessed in\n * this function will cause a refresh when they change.\n */\n children: (value: T) => ReactNode | void;\n };\n}\n\nfunction Consumer<T extends State>(props: Consumer.Props<T>) {\n return props.for.get((i) => props.children(i));\n}\n\ndeclare namespace Provider {\n interface Props<T extends State> {\n /** State or group of States to provide to descendant Consumers. */\n for: Context.Accept<T>;\n\n /**\n * Callback to run for each provided State.\n */\n forEach?: Context.Expect<T>;\n\n /**\n * Children to render within this Provider.\n */\n children?: ReactNode;\n\n /** A fallback tree to show when suspended. */\n fallback?: ReactNode;\n\n /**\n * A name for this Suspense boundary for instrumentation purposes.\n * The name will help identify this boundary in React DevTools.\n */\n name?: string | undefined;\n }\n}\n\nfunction Provider<T extends State>(props: Provider.Props<T>) {\n const context = Context.use(true);\n\n useEffect(() => () => context.pop(), [context]);\n\n context.set(props.for, (state) => {\n if (props.forEach) {\n const cleanup = props.forEach(state);\n\n if (cleanup) state.set(cleanup, null);\n }\n });\n\n return provide(context, props.children, props.fallback, props.name);\n}\n\nfunction provide(\n context: Context,\n children: ReactNode,\n fallback?: ReactNode,\n name?: string | undefined\n): ReactNode {\n if (fallback !== undefined)\n children = createElement(Suspense, { fallback, name }, children);\n\n return createElement(Layers.Provider, {\n key: context.id,\n value: context,\n children\n });\n}\n\nexport { Consumer, Provider, provide };\n"],"mappings":";;;;;AAWA,MAAa,kCAAuB,IAAIA,2BAAS,CAAC;AASlD,0BAAQ,OAAO,WAAqB;CAClC,MAAM,gCAAqB,OAAO;AAElC,QAAO,kCAAuB,QAAQ,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG;;AAmB7D,SAAS,SAA0B,OAA0B;AAC3D,QAAO,MAAM,IAAI,KAAK,MAAM,MAAM,SAAS,EAAE,CAAC;;AA6BhD,SAAS,SAA0B,OAA0B;CAC3D,MAAM,UAAUA,0BAAQ,IAAI,KAAK;AAEjC,kCAAsB,QAAQ,KAAK,EAAE,CAAC,QAAQ,CAAC;AAE/C,SAAQ,IAAI,MAAM,MAAM,UAAU;AAChC,MAAI,MAAM,SAAS;GACjB,MAAM,UAAU,MAAM,QAAQ,MAAM;AAEpC,OAAI,QAAS,OAAM,IAAI,SAAS,KAAK;;GAEvC;AAEF,QAAO,QAAQ,SAAS,MAAM,UAAU,MAAM,UAAU,MAAM,KAAK;;AAGrE,SAAS,QACP,SACA,UACA,UACA,MACW;AACX,KAAI,aAAa,OACf,qCAAyBC,gBAAU;EAAE;EAAU;EAAM,EAAE,SAAS;AAElE,iCAAqB,OAAO,UAAU;EACpC,KAAK,QAAQ;EACb,OAAO;EACP;EACD,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Fragment } from "react";
2
- import Runtime from "react/jsx-dev-runtime";
3
- import { patch } from "./jsx-runtime";
4
-
5
- //#region src/jsx-dev-runtime.ts
6
- const jsxDEV = patch.bind(Runtime.jsxDEV);
7
-
8
- //#endregion
9
- export { Fragment, jsxDEV };
10
- //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../../src/jsx-dev-runtime.ts"],"sourcesContent":["import Runtime from 'react/jsx-dev-runtime';\n\nimport { patch } from './jsx-runtime';\n\nexport const jsxDEV = patch.bind(Runtime.jsxDEV);\n\nexport { type JSX } from './jsx-runtime';\nexport { Fragment } from 'react';\n"],"mappings":";;;;;AAIA,MAAa,SAAS,MAAM,KAAK,QAAQ,OAAO"}
@@ -1,56 +0,0 @@
1
- import { provide } from "./context.js";
2
- import { Context, METHOD, State, watch } from "@expressive/state";
3
- import { Fragment } from "react";
4
- import { Pragma } from "./state";
5
- import Runtime from "react/jsx-runtime";
6
-
7
- //#region src/jsx-runtime.ts
8
- const RENDER = /* @__PURE__ */ new WeakMap();
9
- function patch(type, ...args) {
10
- if (State.is(type)) if (RENDER.has(type)) type = RENDER.get(type);
11
- else RENDER.set(type, type = Render.bind(type));
12
- return this(type, ...args);
13
- }
14
- const jsx = patch.bind(Runtime.jsx);
15
- const jsxs = patch.bind(Runtime.jsxs);
16
- function Render(props, props2) {
17
- const { is, ...rest } = {
18
- ...props,
19
- ...props2
20
- };
21
- const ambient = Context.use();
22
- const state = Pragma.useState(() => {
23
- const instance = this.new(rest, is && ((x) => void is(x)));
24
- const context = ambient.push(instance);
25
- let ready;
26
- let active;
27
- watch(instance, (current) => {
28
- active = current;
29
- if (ready) state[1]((x) => x.bind(null));
30
- });
31
- function didMount() {
32
- ready = true;
33
- return () => {
34
- context.pop();
35
- instance.set(null);
36
- };
37
- }
38
- function Render(props) {
39
- const render = METHOD.get(active.render) || active.render;
40
- return render ? render.call(active, props, active) : props.children;
41
- }
42
- return (props) => {
43
- ready = false;
44
- Pragma.useEffect(didMount, []);
45
- Promise.resolve(instance.set(props)).finally(() => {
46
- ready = true;
47
- });
48
- return provide(context, Pragma.createElement(Render, props), props.fallback || active.fallback, String(instance));
49
- };
50
- });
51
- return state[0](rest);
52
- }
53
-
54
- //#endregion
55
- export { Fragment, jsx, jsxs, patch };
56
- //# sourceMappingURL=jsx-runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../../src/jsx-runtime.ts"],"sourcesContent":["import { State, Context, watch, METHOD } from '@expressive/state';\n\nimport Runtime from 'react/jsx-runtime';\nimport React from 'react';\n\nimport { Pragma } from './state';\nimport { provide } from './context';\n\ntype Reserved = keyof State | 'render' | 'fallback';\n\ntype StateProps<T extends State> = {\n [K in Exclude<keyof T, Reserved>]?: T[K];\n};\n\ntype ComponentProps<T extends State> = StateProps<T> & {\n is?: (instance: T) => void;\n fallback?: React.ReactNode;\n};\n\ntype ValidProps<T extends State> = StateProps<T> & {\n is?: never;\n get?: never;\n set?: never;\n};\n\ninterface AsComponent extends State {\n render?(props: ValidProps<this>, self: this): React.ReactNode;\n fallback?: React.ReactNode;\n}\n\ntype Props<T extends State> = T extends {\n render(props: infer P, self: any): any;\n}\n ? ComponentProps<T> & Omit<P, keyof AsComponent>\n : ComponentProps<T> & { children?: React.ReactNode };\n\nexport declare namespace JSX {\n type ElementType =\n | State.Extends<AsComponent>\n | React.JSX.ElementType\n | ((props: {}, ref?: any) => void);\n\n type LibraryManagedAttributes<C, P> =\n // For normal class components, pull from props property explicitly because we dorked up ElementAttributesProperty.\n C extends new (...args: any[]) => { props: infer U }\n ? U\n : C extends State.Extends<infer U>\n ? Props<U>\n : React.JSX.LibraryManagedAttributes<C, P>;\n\n interface Element extends React.JSX.Element {}\n interface ElementClass extends React.JSX.ElementClass {}\n\n // This is a hack to make TypeScript happy - React's interface insists on `props` property existing.\n // I await the \"Find Out\" phase of this in git issues.\n interface ElementAttributesProperty {}\n interface ElementChildrenAttribute\n extends React.JSX.ElementChildrenAttribute {}\n\n interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}\n interface IntrinsicClassAttributes<T> extends React.JSX\n .IntrinsicClassAttributes<T> {}\n interface IntrinsicElements extends React.JSX.IntrinsicElements {}\n}\n\nconst RENDER = new WeakMap<Function, React.ComponentType>();\n\nexport function patch(\n this: (type: React.ElementType, ...args: any[]) => React.ReactElement,\n type: React.ElementType | State.Type,\n ...args: any[]\n): React.ReactElement {\n if (State.is(type))\n if (RENDER.has(type)) type = RENDER.get(type)!;\n else RENDER.set(type, (type = Render.bind(type)));\n\n return this(type, ...args);\n}\n\nexport const jsx = patch.bind(Runtime.jsx);\nexport const jsxs = patch.bind(Runtime.jsxs);\n\nfunction Render<T extends AsComponent>(\n this: State.Type<T>,\n props: Props<T>,\n props2?: Props<T>\n) {\n const { is, ...rest } = { ...props, ...props2 };\n\n const ambient = Context.use();\n const state = Pragma.useState<(props: any) => any>(() => {\n const instance = this.new(rest as {}, is && ((x) => void is(x)));\n const context = ambient.push(instance);\n\n let ready: boolean | undefined;\n let active: T;\n\n watch(instance, (current) => {\n active = current;\n\n if (ready) state[1]((x) => x.bind(null));\n });\n\n function didMount() {\n ready = true;\n return () => {\n context.pop();\n instance.set(null);\n };\n }\n\n function Render(props: Props<T>) {\n const render = METHOD.get(active.render) || active.render;\n\n return render\n ? render.call(active, props as StateProps<T>, active)\n : props.children;\n }\n\n return (props: Props<T>) => {\n ready = false;\n\n Pragma.useEffect(didMount, []);\n Promise.resolve(instance.set(props as {})).finally(() => {\n ready = true;\n });\n\n return provide(\n context,\n Pragma.createElement(Render, props as any),\n props.fallback || active.fallback,\n String(instance)\n );\n };\n });\n\n return state[0](rest);\n}\n\nexport { Fragment } from 'react';\n"],"mappings":";;;;;;;AAiEA,MAAM,yBAAS,IAAI,SAAwC;AAE3D,SAAgB,MAEd,MACA,GAAG,MACiB;AACpB,KAAI,MAAM,GAAG,KAAK,CAChB,KAAI,OAAO,IAAI,KAAK,CAAE,QAAO,OAAO,IAAI,KAAK;KACxC,QAAO,IAAI,MAAO,OAAO,OAAO,KAAK,KAAK,CAAE;AAEnD,QAAO,KAAK,MAAM,GAAG,KAAK;;AAG5B,MAAa,MAAM,MAAM,KAAK,QAAQ,IAAI;AAC1C,MAAa,OAAO,MAAM,KAAK,QAAQ,KAAK;AAE5C,SAAS,OAEP,OACA,QACA;CACA,MAAM,EAAE,IAAI,GAAG,SAAS;EAAE,GAAG;EAAO,GAAG;EAAQ;CAE/C,MAAM,UAAU,QAAQ,KAAK;CAC7B,MAAM,QAAQ,OAAO,eAAoC;EACvD,MAAM,WAAW,KAAK,IAAI,MAAY,QAAQ,MAAM,KAAK,GAAG,EAAE,EAAE;EAChE,MAAM,UAAU,QAAQ,KAAK,SAAS;EAEtC,IAAI;EACJ,IAAI;AAEJ,QAAM,WAAW,YAAY;AAC3B,YAAS;AAET,OAAI,MAAO,OAAM,IAAI,MAAM,EAAE,KAAK,KAAK,CAAC;IACxC;EAEF,SAAS,WAAW;AAClB,WAAQ;AACR,gBAAa;AACX,YAAQ,KAAK;AACb,aAAS,IAAI,KAAK;;;EAItB,SAAS,OAAO,OAAiB;GAC/B,MAAM,SAAS,OAAO,IAAI,OAAO,OAAO,IAAI,OAAO;AAEnD,UAAO,SACH,OAAO,KAAK,QAAQ,OAAwB,OAAO,GACnD,MAAM;;AAGZ,UAAQ,UAAoB;AAC1B,WAAQ;AAER,UAAO,UAAU,UAAU,EAAE,CAAC;AAC9B,WAAQ,QAAQ,SAAS,IAAI,MAAY,CAAC,CAAC,cAAc;AACvD,YAAQ;KACR;AAEF,UAAO,QACL,SACA,OAAO,cAAc,QAAQ,MAAa,EAC1C,MAAM,YAAY,OAAO,UACzB,OAAO,SAAS,CACjB;;GAEH;AAEF,QAAO,MAAM,GAAG,KAAK"}
@@ -1,10 +0,0 @@
1
- import * as _expressive_state0 from "@expressive/state";
2
- import * as react from "react";
3
- import { Fragment } from "react";
4
- import { JSX } from "./jsx-runtime";
5
-
6
- //#region src/jsx-dev-runtime.d.ts
7
- declare const jsxDEV: (type: react.ElementType<any, keyof react.JSX.IntrinsicElements> | _expressive_state0.State.Type<_expressive_state0.State>, ...args: any[]) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
8
- //#endregion
9
- export { Fragment, type JSX, jsxDEV };
10
- //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -1,19 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('./chunk-BE-pF4vm.js');
3
- let react = require("react");
4
- let react_jsx_dev_runtime = require("react/jsx-dev-runtime");
5
- react_jsx_dev_runtime = require_chunk.__toESM(react_jsx_dev_runtime);
6
- let src_jsx_runtime = require("./jsx-runtime");
7
-
8
- //#region src/jsx-dev-runtime.ts
9
- const jsxDEV = src_jsx_runtime.patch.bind(react_jsx_dev_runtime.default.jsxDEV);
10
-
11
- //#endregion
12
- Object.defineProperty(exports, 'Fragment', {
13
- enumerable: true,
14
- get: function () {
15
- return react.Fragment;
16
- }
17
- });
18
- exports.jsxDEV = jsxDEV;
19
- //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsx-dev-runtime.js","names":["patch","Runtime"],"sources":["../src/jsx-dev-runtime.ts"],"sourcesContent":["import Runtime from 'react/jsx-dev-runtime';\n\nimport { patch } from './jsx-runtime';\n\nexport const jsxDEV = patch.bind(Runtime.jsxDEV);\n\nexport { type JSX } from './jsx-runtime';\nexport { Fragment } from 'react';\n"],"mappings":";;;;;;;;AAIA,MAAa,SAASA,sBAAM,KAAKC,8BAAQ,OAAO"}
@@ -1,43 +0,0 @@
1
- import { State } from "@expressive/state";
2
- import React, { Fragment } from "react";
3
-
4
- //#region src/jsx-runtime.d.ts
5
- type Reserved = keyof State | 'render' | 'fallback';
6
- type StateProps<T extends State> = { [K in Exclude<keyof T, Reserved>]?: T[K] };
7
- type ComponentProps<T extends State> = StateProps<T> & {
8
- is?: (instance: T) => void;
9
- fallback?: React.ReactNode;
10
- };
11
- type ValidProps<T extends State> = StateProps<T> & {
12
- is?: never;
13
- get?: never;
14
- set?: never;
15
- };
16
- interface AsComponent extends State {
17
- render?(props: ValidProps<this>, self: this): React.ReactNode;
18
- fallback?: React.ReactNode;
19
- }
20
- type Props<T extends State> = T extends {
21
- render(props: infer P, self: any): any;
22
- } ? ComponentProps<T> & Omit<P, keyof AsComponent> : ComponentProps<T> & {
23
- children?: React.ReactNode;
24
- };
25
- declare namespace JSX {
26
- type ElementType = State.Extends<AsComponent> | React.JSX.ElementType | ((props: {}, ref?: any) => void);
27
- type LibraryManagedAttributes<C, P> = C extends (new (...args: any[]) => {
28
- props: infer U;
29
- }) ? U : C extends State.Extends<infer U> ? Props<U> : React.JSX.LibraryManagedAttributes<C, P>;
30
- interface Element extends React.JSX.Element {}
31
- interface ElementClass extends React.JSX.ElementClass {}
32
- interface ElementAttributesProperty {}
33
- interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
34
- interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
35
- interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
36
- interface IntrinsicElements extends React.JSX.IntrinsicElements {}
37
- }
38
- declare function patch(this: (type: React.ElementType, ...args: any[]) => React.ReactElement, type: React.ElementType | State.Type, ...args: any[]): React.ReactElement;
39
- declare const jsx: (type: React.ElementType<any, keyof React.JSX.IntrinsicElements> | State.Type<State>, ...args: any[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
40
- declare const jsxs: (type: React.ElementType<any, keyof React.JSX.IntrinsicElements> | State.Type<State>, ...args: any[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
41
- //#endregion
42
- export { Fragment, JSX, jsx, jsxs, patch };
43
- //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -1,67 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('./chunk-BE-pF4vm.js');
3
- const require_context = require('./context-DT3kwoQN.js');
4
- let _expressive_state = require("@expressive/state");
5
- let react = require("react");
6
- let src_state = require("./state");
7
- let react_jsx_runtime = require("react/jsx-runtime");
8
- react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
9
-
10
- //#region src/jsx-runtime.ts
11
- const RENDER = /* @__PURE__ */ new WeakMap();
12
- function patch(type, ...args) {
13
- if (_expressive_state.State.is(type)) if (RENDER.has(type)) type = RENDER.get(type);
14
- else RENDER.set(type, type = Render.bind(type));
15
- return this(type, ...args);
16
- }
17
- const jsx = patch.bind(react_jsx_runtime.default.jsx);
18
- const jsxs = patch.bind(react_jsx_runtime.default.jsxs);
19
- function Render(props, props2) {
20
- const { is, ...rest } = {
21
- ...props,
22
- ...props2
23
- };
24
- const ambient = _expressive_state.Context.use();
25
- const state = src_state.Pragma.useState(() => {
26
- const instance = this.new(rest, is && ((x) => void is(x)));
27
- const context = ambient.push(instance);
28
- let ready;
29
- let active;
30
- (0, _expressive_state.watch)(instance, (current) => {
31
- active = current;
32
- if (ready) state[1]((x) => x.bind(null));
33
- });
34
- function didMount() {
35
- ready = true;
36
- return () => {
37
- context.pop();
38
- instance.set(null);
39
- };
40
- }
41
- function Render(props) {
42
- const render = _expressive_state.METHOD.get(active.render) || active.render;
43
- return render ? render.call(active, props, active) : props.children;
44
- }
45
- return (props) => {
46
- ready = false;
47
- src_state.Pragma.useEffect(didMount, []);
48
- Promise.resolve(instance.set(props)).finally(() => {
49
- ready = true;
50
- });
51
- return require_context.provide(context, src_state.Pragma.createElement(Render, props), props.fallback || active.fallback, String(instance));
52
- };
53
- });
54
- return state[0](rest);
55
- }
56
-
57
- //#endregion
58
- Object.defineProperty(exports, 'Fragment', {
59
- enumerable: true,
60
- get: function () {
61
- return react.Fragment;
62
- }
63
- });
64
- exports.jsx = jsx;
65
- exports.jsxs = jsxs;
66
- exports.patch = patch;
67
- //# sourceMappingURL=jsx-runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsx-runtime.js","names":["State","Runtime","Context","Pragma","METHOD","provide"],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import { State, Context, watch, METHOD } from '@expressive/state';\n\nimport Runtime from 'react/jsx-runtime';\nimport React from 'react';\n\nimport { Pragma } from './state';\nimport { provide } from './context';\n\ntype Reserved = keyof State | 'render' | 'fallback';\n\ntype StateProps<T extends State> = {\n [K in Exclude<keyof T, Reserved>]?: T[K];\n};\n\ntype ComponentProps<T extends State> = StateProps<T> & {\n is?: (instance: T) => void;\n fallback?: React.ReactNode;\n};\n\ntype ValidProps<T extends State> = StateProps<T> & {\n is?: never;\n get?: never;\n set?: never;\n};\n\ninterface AsComponent extends State {\n render?(props: ValidProps<this>, self: this): React.ReactNode;\n fallback?: React.ReactNode;\n}\n\ntype Props<T extends State> = T extends {\n render(props: infer P, self: any): any;\n}\n ? ComponentProps<T> & Omit<P, keyof AsComponent>\n : ComponentProps<T> & { children?: React.ReactNode };\n\nexport declare namespace JSX {\n type ElementType =\n | State.Extends<AsComponent>\n | React.JSX.ElementType\n | ((props: {}, ref?: any) => void);\n\n type LibraryManagedAttributes<C, P> =\n // For normal class components, pull from props property explicitly because we dorked up ElementAttributesProperty.\n C extends new (...args: any[]) => { props: infer U }\n ? U\n : C extends State.Extends<infer U>\n ? Props<U>\n : React.JSX.LibraryManagedAttributes<C, P>;\n\n interface Element extends React.JSX.Element {}\n interface ElementClass extends React.JSX.ElementClass {}\n\n // This is a hack to make TypeScript happy - React's interface insists on `props` property existing.\n // I await the \"Find Out\" phase of this in git issues.\n interface ElementAttributesProperty {}\n interface ElementChildrenAttribute\n extends React.JSX.ElementChildrenAttribute {}\n\n interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}\n interface IntrinsicClassAttributes<T> extends React.JSX\n .IntrinsicClassAttributes<T> {}\n interface IntrinsicElements extends React.JSX.IntrinsicElements {}\n}\n\nconst RENDER = new WeakMap<Function, React.ComponentType>();\n\nexport function patch(\n this: (type: React.ElementType, ...args: any[]) => React.ReactElement,\n type: React.ElementType | State.Type,\n ...args: any[]\n): React.ReactElement {\n if (State.is(type))\n if (RENDER.has(type)) type = RENDER.get(type)!;\n else RENDER.set(type, (type = Render.bind(type)));\n\n return this(type, ...args);\n}\n\nexport const jsx = patch.bind(Runtime.jsx);\nexport const jsxs = patch.bind(Runtime.jsxs);\n\nfunction Render<T extends AsComponent>(\n this: State.Type<T>,\n props: Props<T>,\n props2?: Props<T>\n) {\n const { is, ...rest } = { ...props, ...props2 };\n\n const ambient = Context.use();\n const state = Pragma.useState<(props: any) => any>(() => {\n const instance = this.new(rest as {}, is && ((x) => void is(x)));\n const context = ambient.push(instance);\n\n let ready: boolean | undefined;\n let active: T;\n\n watch(instance, (current) => {\n active = current;\n\n if (ready) state[1]((x) => x.bind(null));\n });\n\n function didMount() {\n ready = true;\n return () => {\n context.pop();\n instance.set(null);\n };\n }\n\n function Render(props: Props<T>) {\n const render = METHOD.get(active.render) || active.render;\n\n return render\n ? render.call(active, props as StateProps<T>, active)\n : props.children;\n }\n\n return (props: Props<T>) => {\n ready = false;\n\n Pragma.useEffect(didMount, []);\n Promise.resolve(instance.set(props as {})).finally(() => {\n ready = true;\n });\n\n return provide(\n context,\n Pragma.createElement(Render, props as any),\n props.fallback || active.fallback,\n String(instance)\n );\n };\n });\n\n return state[0](rest);\n}\n\nexport { Fragment } from 'react';\n"],"mappings":";;;;;;;;;;AAiEA,MAAM,yBAAS,IAAI,SAAwC;AAE3D,SAAgB,MAEd,MACA,GAAG,MACiB;AACpB,KAAIA,wBAAM,GAAG,KAAK,CAChB,KAAI,OAAO,IAAI,KAAK,CAAE,QAAO,OAAO,IAAI,KAAK;KACxC,QAAO,IAAI,MAAO,OAAO,OAAO,KAAK,KAAK,CAAE;AAEnD,QAAO,KAAK,MAAM,GAAG,KAAK;;AAG5B,MAAa,MAAM,MAAM,KAAKC,0BAAQ,IAAI;AAC1C,MAAa,OAAO,MAAM,KAAKA,0BAAQ,KAAK;AAE5C,SAAS,OAEP,OACA,QACA;CACA,MAAM,EAAE,IAAI,GAAG,SAAS;EAAE,GAAG;EAAO,GAAG;EAAQ;CAE/C,MAAM,UAAUC,0BAAQ,KAAK;CAC7B,MAAM,QAAQC,iBAAO,eAAoC;EACvD,MAAM,WAAW,KAAK,IAAI,MAAY,QAAQ,MAAM,KAAK,GAAG,EAAE,EAAE;EAChE,MAAM,UAAU,QAAQ,KAAK,SAAS;EAEtC,IAAI;EACJ,IAAI;AAEJ,+BAAM,WAAW,YAAY;AAC3B,YAAS;AAET,OAAI,MAAO,OAAM,IAAI,MAAM,EAAE,KAAK,KAAK,CAAC;IACxC;EAEF,SAAS,WAAW;AAClB,WAAQ;AACR,gBAAa;AACX,YAAQ,KAAK;AACb,aAAS,IAAI,KAAK;;;EAItB,SAAS,OAAO,OAAiB;GAC/B,MAAM,SAASC,yBAAO,IAAI,OAAO,OAAO,IAAI,OAAO;AAEnD,UAAO,SACH,OAAO,KAAK,QAAQ,OAAwB,OAAO,GACnD,MAAM;;AAGZ,UAAQ,UAAoB;AAC1B,WAAQ;AAER,oBAAO,UAAU,UAAU,EAAE,CAAC;AAC9B,WAAQ,QAAQ,SAAS,IAAI,MAAY,CAAC,CAAC,cAAc;AACvD,YAAQ;KACR;AAEF,UAAOC,wBACL,SACAF,iBAAO,cAAc,QAAQ,MAAa,EAC1C,MAAM,YAAY,OAAO,UACzB,OAAO,SAAS,CACjB;;GAEH;AAEF,QAAO,MAAM,GAAG,KAAK"}