@expressive/react 0.72.0 → 0.73.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.
- package/dist/chunk-kSYXY2_d.js +34 -0
- package/dist/context-DpbK9_2_.js +62 -0
- package/dist/context-DpbK9_2_.js.map +1 -0
- package/dist/esm/component.js +67 -0
- package/dist/esm/component.js.map +1 -0
- package/dist/esm/context.js +38 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/index.js +13 -34
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jsx-dev-runtime.js +7 -7
- package/dist/esm/jsx-dev-runtime.js.map +1 -1
- package/dist/esm/jsx-runtime.js +14 -21
- package/dist/esm/jsx-runtime.js.map +1 -1
- package/dist/esm/state.js +145 -0
- package/dist/esm/state.js.map +1 -0
- package/dist/index-zVvhW0uD.d.ts +130 -0
- package/dist/index.d.ts +2 -52
- package/dist/index.js +125 -89
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +9 -7
- package/dist/jsx-dev-runtime.js +15 -43
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +21 -27
- package/dist/jsx-runtime.js +24 -125
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/state.d.ts +88 -0
- package/dist/state.js +148 -0
- package/dist/state.js.map +1 -0
- package/package.json +10 -9
- package/dist/adapter.d.ts +0 -105
- package/dist/adapter.js +0 -207
- package/dist/adapter.js.map +0 -1
- package/dist/esm/adapter.js +0 -113
- package/dist/esm/adapter.js.map +0 -1
- package/dist/esm/chunk-4MR23TOU.js +0 -45
- package/dist/esm/chunk-4MR23TOU.js.map +0 -1
- package/dist/esm/chunk-UIHA4AT6.js +0 -58
- package/dist/esm/chunk-UIHA4AT6.js.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Pragma, ReactState, ReactState as ReactState$1 } from "./state";
|
|
2
|
+
import State$1, { Context, Context as Context$1, Observable, get, ref, set, use } from "@expressive/mvc";
|
|
3
|
+
import * as react3 from "react";
|
|
4
|
+
import React, { Fragment, FunctionComponent, ReactNode, createElement } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/component.d.ts
|
|
7
|
+
type HasProps<T extends ReactState> = { [K in Exclude<keyof T, keyof ReactState>]?: T[K] };
|
|
8
|
+
type ComponentProps<T extends ReactState> = HasProps<T> & {
|
|
9
|
+
/**
|
|
10
|
+
* Callback for newly created instance. Only called once.
|
|
11
|
+
* @returns Callback to run when instance is destroyed.
|
|
12
|
+
*/
|
|
13
|
+
is?: (instance: T) => void;
|
|
14
|
+
/**
|
|
15
|
+
* A fallback react tree to show when suspended.
|
|
16
|
+
* If not provided, `fallback` property of the State will be used.
|
|
17
|
+
*/
|
|
18
|
+
fallback?: React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
type Props$1<T extends ReactState> = T extends {
|
|
21
|
+
render(props: infer P, self: any): any;
|
|
22
|
+
} ? ComponentProps<T> & Omit<P, keyof AsComponent$1> : ComponentProps<T> & {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Props which will not conflict with a State's use as a Component.
|
|
27
|
+
*
|
|
28
|
+
* Built-in properties must be optional, as they will always be omitted.
|
|
29
|
+
*/
|
|
30
|
+
type RenderProps<T extends ReactState> = HasProps<T> & {
|
|
31
|
+
is?: never;
|
|
32
|
+
get?: never;
|
|
33
|
+
set?: never;
|
|
34
|
+
};
|
|
35
|
+
/** State which is not incompatable as Component in React. */
|
|
36
|
+
interface AsComponent$1 extends ReactState {
|
|
37
|
+
render?(props: RenderProps<this>, self: this): React.ReactNode;
|
|
38
|
+
fallback?: React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
interface FC<T extends ReactState, P extends ReactState.Assign<T>> extends FunctionComponent<P & Props$1<T>> {
|
|
41
|
+
displayName?: string;
|
|
42
|
+
State: ReactState.Extends<T>;
|
|
43
|
+
}
|
|
44
|
+
declare module './state' {
|
|
45
|
+
namespace ReactState {
|
|
46
|
+
export { ComponentProps, Props$1 as Props, RenderProps, AsComponent$1 as AsComponent, FC };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
declare class Component extends ReactState {
|
|
50
|
+
static contextType: React.Context<Context$1>;
|
|
51
|
+
private _props;
|
|
52
|
+
get props(): ReactState.ComponentProps<this>;
|
|
53
|
+
set props(props: ReactState.ComponentProps<this>);
|
|
54
|
+
get context(): Context$1;
|
|
55
|
+
set context(context: Context$1);
|
|
56
|
+
state: ReactState.Values<this>;
|
|
57
|
+
children: ReactNode | ((self: this) => ReactNode);
|
|
58
|
+
fallback?: ReactNode;
|
|
59
|
+
constructor({
|
|
60
|
+
is,
|
|
61
|
+
...props
|
|
62
|
+
}: any);
|
|
63
|
+
render(): ReactNode;
|
|
64
|
+
/** @deprecated This is purely for React JSX compatibility in typescript. */
|
|
65
|
+
setState: (state: any, callback?: () => void) => void;
|
|
66
|
+
/** @deprecated This is purely for React JSX compatibility in typescript. */
|
|
67
|
+
forceUpdate: (callback?: () => void) => void;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/context.d.ts
|
|
71
|
+
declare module '@expressive/mvc' {
|
|
72
|
+
namespace Context {
|
|
73
|
+
function use(create?: true): Context;
|
|
74
|
+
function use(create: boolean): Context | null | undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
declare namespace Consumer {
|
|
78
|
+
type Props<T extends State$1> = {
|
|
79
|
+
/** Type of controller to fetch from context. */for: State$1.Extends<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Render function, will receive instance of desired controller.
|
|
82
|
+
*
|
|
83
|
+
* Called every render of parent component.
|
|
84
|
+
* Similar to `State.get()`, updates to properties accessed in
|
|
85
|
+
* this function will cause a refresh when they change.
|
|
86
|
+
*/
|
|
87
|
+
children: (value: T) => ReactNode | void;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
declare function Consumer<T extends State$1>(props: Consumer.Props<T>): string | number | bigint | boolean | react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>> | Iterable<ReactNode> | react3.ReactPortal | null;
|
|
91
|
+
declare namespace Provider {
|
|
92
|
+
interface Props<T extends State$1> {
|
|
93
|
+
/** State or group of States to provide to descendant Consumers. */
|
|
94
|
+
for: Context.Accept<T>;
|
|
95
|
+
/**
|
|
96
|
+
* Callback to run for each provided State.
|
|
97
|
+
*/
|
|
98
|
+
forEach?: Context.Expect<T>;
|
|
99
|
+
/**
|
|
100
|
+
* Children to render within this Provider.
|
|
101
|
+
*/
|
|
102
|
+
children?: ReactNode;
|
|
103
|
+
/** A fallback tree to show when suspended. */
|
|
104
|
+
fallback?: ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* A name for this Suspense boundary for instrumentation purposes.
|
|
107
|
+
* The name will help identify this boundary in React DevTools.
|
|
108
|
+
*/
|
|
109
|
+
name?: string | undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
declare function Provider<T extends State$1>(props: Provider.Props<T>): ReactNode;
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/index.d.ts
|
|
115
|
+
/**
|
|
116
|
+
* Augmented State namespace to include ReactState hooks as static methods.
|
|
117
|
+
*
|
|
118
|
+
* This retroactively adds React support to agnostic State defined
|
|
119
|
+
* by component libraries which import `@expressive/mvc` directly.
|
|
120
|
+
*/
|
|
121
|
+
declare module '@expressive/mvc' {
|
|
122
|
+
namespace State {
|
|
123
|
+
export import as = ReactState.as;
|
|
124
|
+
export import get = ReactState.get;
|
|
125
|
+
export import use = ReactState.use;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { Props$1 as _, ReactState$1 as a, ref as c, Consumer as d, Provider as f, HasProps as g, FC as h, Pragma as i, set as l, Component as m, Fragment as n, createElement as o, AsComponent$1 as p, Observable as r, get as s, Context$1 as t, use as u };
|
|
130
|
+
//# sourceMappingURL=index-zVvhW0uD.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { Context, Observable,
|
|
3
|
-
export { Pragma } from './adapter';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
6
|
-
export { Fragment, createElement } from 'react';
|
|
7
|
-
|
|
8
|
-
declare module '@expressive/mvc' {
|
|
9
|
-
namespace Context {
|
|
10
|
-
function use(create?: true): Context;
|
|
11
|
-
function use(create: boolean): Context | null | undefined;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare namespace Consumer {
|
|
15
|
-
type Props<T extends State__default> = {
|
|
16
|
-
/** Type of controller to fetch from context. */
|
|
17
|
-
for: State__default.Extends<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Render function, will receive instance of desired controller.
|
|
20
|
-
*
|
|
21
|
-
* Called every render of parent component.
|
|
22
|
-
* Similar to `State.get()`, updates to properties accessed in
|
|
23
|
-
* this function will cause a refresh when they change.
|
|
24
|
-
*/
|
|
25
|
-
children: (value: T) => ReactNode | void;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
declare function Consumer<T extends State__default>(props: Consumer.Props<T>): string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal | null;
|
|
29
|
-
declare namespace Provider {
|
|
30
|
-
interface Props<T extends State__default> {
|
|
31
|
-
/** State or group of States to provide to descendant Consumers. */
|
|
32
|
-
for: Context.Accept<T>;
|
|
33
|
-
/**
|
|
34
|
-
* Callback to run for each provided State.
|
|
35
|
-
*/
|
|
36
|
-
forEach?: Context.Expect<T>;
|
|
37
|
-
/**
|
|
38
|
-
* Children to render within this Provider.
|
|
39
|
-
*/
|
|
40
|
-
children?: ReactNode;
|
|
41
|
-
/** A fallback tree to show when suspended. */
|
|
42
|
-
fallback?: ReactNode;
|
|
43
|
-
/**
|
|
44
|
-
* A name for this Suspense boundary for instrumentation purposes.
|
|
45
|
-
* The name will help identify this boundary in React DevTools.
|
|
46
|
-
*/
|
|
47
|
-
name?: string | undefined;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
declare function Provider<T extends State__default>(props: Provider.Props<T>): ReactNode;
|
|
51
|
-
|
|
52
|
-
export { Consumer, Provider };
|
|
1
|
+
import { a as ReactState, c as ref, d as Consumer, f as Provider, i as Pragma, l as set, m as Component, n as Fragment, o as createElement, r as Observable, s as get, t as Context, u as use } from "./index-zVvhW0uD.js";
|
|
2
|
+
export { Component, Consumer, Context, Fragment, Observable, Pragma, Provider, ReactState as State, ReactState as default, createElement, get, ref, set, use };
|
package/dist/index.js
CHANGED
|
@@ -1,95 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_chunk = require('./chunk-kSYXY2_d.js');
|
|
3
|
+
const require_context = require('./context-DpbK9_2_.js');
|
|
4
|
+
let _expressive_mvc = require("@expressive/mvc");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let src_state = require("./state");
|
|
19
7
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
8
|
+
//#region src/component.ts
|
|
9
|
+
const OUTER = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
var Component = class extends src_state.ReactState {
|
|
11
|
+
static {
|
|
12
|
+
this.contextType = require_context.Layers;
|
|
13
|
+
}
|
|
14
|
+
get props() {
|
|
15
|
+
return this._props;
|
|
16
|
+
}
|
|
17
|
+
set props(props) {
|
|
18
|
+
this._props = props;
|
|
19
|
+
this.set(props);
|
|
20
|
+
}
|
|
21
|
+
get context() {
|
|
22
|
+
return _expressive_mvc.Context.get(this);
|
|
23
|
+
}
|
|
24
|
+
set context(context) {
|
|
25
|
+
if (OUTER.get(this) === context) return;
|
|
26
|
+
OUTER.set(this, context);
|
|
27
|
+
context.push(this);
|
|
28
|
+
}
|
|
29
|
+
constructor({ is, ...props }) {
|
|
30
|
+
super(props, is);
|
|
31
|
+
const self = Render.bind(this, _expressive_mvc.METHOD.get(this.render));
|
|
32
|
+
this.render = () => src_state.Pragma.createElement(self);
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return typeof this.children === "function" ? this.children(this) : this.children;
|
|
36
|
+
}
|
|
49
37
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
38
|
+
Object.defineProperty(Component.prototype, "isReactComponent", { get: () => true });
|
|
39
|
+
function Render(render) {
|
|
40
|
+
const state = src_state.Pragma.useState(() => {
|
|
41
|
+
(0, _expressive_mvc.event)(this);
|
|
42
|
+
const { context } = this;
|
|
43
|
+
let ready;
|
|
44
|
+
let active;
|
|
45
|
+
(0, _expressive_mvc.watch)(this, (current) => {
|
|
46
|
+
active = current;
|
|
47
|
+
if (ready) state[1]((x) => x.bind(null));
|
|
48
|
+
});
|
|
49
|
+
const didMount = () => {
|
|
50
|
+
ready = true;
|
|
51
|
+
return () => {
|
|
52
|
+
context.pop();
|
|
53
|
+
this.set(null);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const Render = () => render.call(active);
|
|
57
|
+
return () => {
|
|
58
|
+
ready = false;
|
|
59
|
+
src_state.Pragma.useEffect(didMount, []);
|
|
60
|
+
setTimeout(() => ready = true, 0);
|
|
61
|
+
return require_context.provide(context, src_state.Pragma.createElement(Render), active.fallback, String(this));
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return state[0]();
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/index.ts
|
|
69
|
+
src_state.Pragma.useEffect = react.useEffect;
|
|
70
|
+
src_state.Pragma.useState = react.useState;
|
|
71
|
+
src_state.Pragma.createElement = react.createElement;
|
|
72
|
+
_expressive_mvc.State.get = src_state.ReactState.get;
|
|
73
|
+
_expressive_mvc.State.use = src_state.ReactState.use;
|
|
74
|
+
_expressive_mvc.State.as = src_state.ReactState.as;
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
exports.Component = Component;
|
|
78
|
+
exports.Consumer = require_context.Consumer;
|
|
79
|
+
Object.defineProperty(exports, 'Context', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _expressive_mvc.Context;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, 'Fragment', {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () {
|
|
88
|
+
return react.Fragment;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, 'Observable', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return _expressive_mvc.Observable;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
exports.Pragma = src_state.Pragma;
|
|
98
|
+
exports.Provider = require_context.Provider;
|
|
99
|
+
exports.State = src_state.ReactState;
|
|
100
|
+
exports.default = src_state.ReactState;
|
|
101
|
+
Object.defineProperty(exports, 'createElement', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return react.createElement;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'get', {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return _expressive_mvc.get;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, 'ref', {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return _expressive_mvc.ref;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, 'set', {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return _expressive_mvc.set;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, 'use', {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () {
|
|
128
|
+
return _expressive_mvc.use;
|
|
129
|
+
}
|
|
94
130
|
});
|
|
95
131
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","names":["State","Layers","Context","METHOD","Pragma","provide","useEffect","useState","createElement","ReactState"],"sources":["../src/component.ts","../src/index.ts"],"sourcesContent":["import { event, METHOD, watch } from '@expressive/mvc';\nimport React, { FunctionComponent, ReactNode } from 'react';\n\nimport { Pragma, ReactState as State } from './state';\nimport { provide, Layers } from './context';\nimport { Context } from '.';\n\nconst OUTER = new WeakMap<Component, Context>();\n\ntype HasProps<T extends State> = {\n [K in Exclude<keyof T, keyof State>]?: T[K];\n};\n\ntype ComponentProps<T extends State> = HasProps<T> & {\n /**\n * Callback for newly created instance. Only called once.\n * @returns Callback to run when instance is destroyed.\n */\n is?: (instance: T) => void;\n\n /**\n * A fallback react tree to show when suspended.\n * If not provided, `fallback` property of the State will be used.\n */\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\n/**\n * Props which will not conflict with a State's use as a Component.\n *\n * Built-in properties must be optional, as they will always be omitted.\n */\ntype RenderProps<T extends State> = HasProps<T> & {\n is?: never;\n get?: never;\n set?: never;\n};\n\n/** State which is not incompatable as Component in React. */\ninterface AsComponent extends State {\n render?(props: RenderProps<this>, self: this): React.ReactNode;\n fallback?: React.ReactNode;\n}\n\ninterface FC<\n T extends State,\n P extends State.Assign<T>\n> extends FunctionComponent<P & Props<T>> {\n displayName?: string;\n State: State.Extends<T>;\n}\n\ndeclare module './state' {\n namespace ReactState {\n export { ComponentProps, Props, RenderProps, AsComponent, FC };\n }\n}\n\nclass Component extends State {\n static contextType = Layers;\n\n private _props!: State.ComponentProps<this>;\n\n get props(): State.ComponentProps<this> {\n return this._props;\n }\n\n set props(props: State.ComponentProps<this>) {\n this._props = props;\n this.set(props as {});\n }\n\n get context(): Context {\n return Context.get(this)!;\n }\n\n set context(context: Context) {\n if (OUTER.get(this) === context) return;\n\n OUTER.set(this, context);\n context.push(this);\n }\n\n state!: State.Values<this>;\n children!: ReactNode | ((self: this) => ReactNode);\n fallback?: ReactNode;\n\n constructor({ is, ...props }: any) {\n super(props, is);\n const self = Render.bind(this, METHOD.get(this.render));\n this.render = () => Pragma.createElement(self);\n }\n\n render(): ReactNode {\n return typeof this.children === 'function'\n ? this.children(this)\n : this.children;\n }\n\n /** @deprecated This is purely for React JSX compatibility in typescript. */\n setState!: (state: any, callback?: () => void) => void;\n\n /** @deprecated This is purely for React JSX compatibility in typescript. */\n forceUpdate!: (callback?: () => void) => void;\n}\n\nObject.defineProperty(Component.prototype, 'isReactComponent', {\n get: () => true\n});\n\nfunction Render<T extends Component>(this: T, render: () => ReactNode) {\n const state = Pragma.useState(() => {\n event(this);\n\n const { context } = this;\n\n let ready: boolean | undefined;\n let active: T;\n\n watch(this, (current) => {\n active = current;\n\n if (ready) state[1]((x) => x.bind(null));\n });\n\n const didMount = () => {\n ready = true;\n return () => {\n context.pop();\n this.set(null);\n };\n };\n\n const Render = () => render.call(active);\n\n return () => {\n ready = false;\n\n Pragma.useEffect(didMount, []);\n setTimeout(() => (ready = true), 0);\n\n return provide(\n context,\n Pragma.createElement(Render),\n active.fallback,\n String(this)\n );\n };\n });\n\n return state[0]();\n}\n\nexport { Component, FC, AsComponent, Props, RenderProps, HasProps };\n","import { State } from '@expressive/mvc';\n\nimport { createElement, useEffect, useState } from 'react';\n\nimport { ReactState, Pragma } from './state';\n\nPragma.useEffect = useEffect;\nPragma.useState = useState;\nPragma.createElement = createElement;\n\n/**\n * Augmented State namespace to include ReactState hooks as static methods.\n *\n * This retroactively adds React support to agnostic State defined\n * by component libraries which import `@expressive/mvc` directly.\n */\ndeclare module '@expressive/mvc' {\n namespace State {\n export import as = ReactState.as;\n export import get = ReactState.get;\n export import use = ReactState.use;\n }\n}\n\nState.get = ReactState.get;\nState.use = ReactState.use;\nState.as = ReactState.as;\n\nexport { ReactState as State, ReactState as default };\nexport { Context, Observable, get, use, ref, set } from '@expressive/mvc';\nexport { Component } from './component';\nexport { Consumer, Provider } from './context';\nexport { Fragment, createElement } from 'react';\nexport { Pragma };"],"mappings":";;;;;;;;AAOA,MAAM,wBAAQ,IAAI,SAA6B;AAyD/C,IAAM,YAAN,cAAwBA,qBAAM;;qBACPC;;CAIrB,IAAI,QAAoC;AACtC,SAAO,KAAK;;CAGd,IAAI,MAAM,OAAmC;AAC3C,OAAK,SAAS;AACd,OAAK,IAAI,MAAY;;CAGvB,IAAI,UAAmB;AACrB,SAAOC,wBAAQ,IAAI,KAAK;;CAG1B,IAAI,QAAQ,SAAkB;AAC5B,MAAI,MAAM,IAAI,KAAK,KAAK,QAAS;AAEjC,QAAM,IAAI,MAAM,QAAQ;AACxB,UAAQ,KAAK,KAAK;;CAOpB,YAAY,EAAE,IAAI,GAAG,SAAc;AACjC,QAAM,OAAO,GAAG;EAChB,MAAM,OAAO,OAAO,KAAK,MAAMC,uBAAO,IAAI,KAAK,OAAO,CAAC;AACvD,OAAK,eAAeC,iBAAO,cAAc,KAAK;;CAGhD,SAAoB;AAClB,SAAO,OAAO,KAAK,aAAa,aAC5B,KAAK,SAAS,KAAK,GACnB,KAAK;;;AAUb,OAAO,eAAe,UAAU,WAAW,oBAAoB,EAC7D,WAAW,MACZ,CAAC;AAEF,SAAS,OAAqC,QAAyB;CACrE,MAAM,QAAQA,iBAAO,eAAe;AAClC,6BAAM,KAAK;EAEX,MAAM,EAAE,YAAY;EAEpB,IAAI;EACJ,IAAI;AAEJ,6BAAM,OAAO,YAAY;AACvB,YAAS;AAET,OAAI,MAAO,OAAM,IAAI,MAAM,EAAE,KAAK,KAAK,CAAC;IACxC;EAEF,MAAM,iBAAiB;AACrB,WAAQ;AACR,gBAAa;AACX,YAAQ,KAAK;AACb,SAAK,IAAI,KAAK;;;EAIlB,MAAM,eAAe,OAAO,KAAK,OAAO;AAExC,eAAa;AACX,WAAQ;AAER,oBAAO,UAAU,UAAU,EAAE,CAAC;AAC9B,oBAAkB,QAAQ,MAAO,EAAE;AAEnC,UAAOC,wBACL,SACAD,iBAAO,cAAc,OAAO,EAC5B,OAAO,UACP,OAAO,KAAK,CACb;;GAEH;AAEF,QAAO,MAAM,IAAI;;;;;ACtJnB,iBAAO,YAAYE;AACnB,iBAAO,WAAWC;AAClB,iBAAO,gBAAgBC;AAgBvB,sBAAM,MAAMC,qBAAW;AACvB,sBAAM,MAAMA,qBAAW;AACvB,sBAAM,KAAKA,qBAAW"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as _expressive_mvc0 from "@expressive/mvc";
|
|
2
|
+
import * as react0 from "react";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { JSX } from "./jsx-runtime";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
//#region src/jsx-dev-runtime.d.ts
|
|
7
|
+
declare const jsxDEV: (type: react0.ElementType<any, keyof react0.JSX.IntrinsicElements> | _expressive_mvc0.State.Type<_expressive_mvc0.State>, ...args: any[]) => react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Fragment, type JSX, jsxDEV };
|
|
10
|
+
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -1,46 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
const require_chunk = require('./chunk-kSYXY2_d.js');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let react_jsx_dev_runtime = require("react/jsx-dev-runtime");
|
|
4
|
+
react_jsx_dev_runtime = require_chunk.__toESM(react_jsx_dev_runtime);
|
|
5
|
+
let src_jsx_runtime = require("./jsx-runtime");
|
|
29
6
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var import_react = require("react");
|
|
40
|
-
var jsxDEV = import_jsx_runtime.patch.bind(import_jsx_dev_runtime.default.jsxDEV);
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
Fragment,
|
|
44
|
-
jsxDEV
|
|
7
|
+
//#region src/jsx-dev-runtime.ts
|
|
8
|
+
const jsxDEV = src_jsx_runtime.patch.bind(react_jsx_dev_runtime.default.jsxDEV);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
Object.defineProperty(exports, 'Fragment', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return react.Fragment;
|
|
15
|
+
}
|
|
45
16
|
});
|
|
17
|
+
exports.jsxDEV = jsxDEV;
|
|
46
18
|
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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":"
|
|
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"}
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { AsComponent, Props } from "./state";
|
|
2
|
+
import State$1 from "@expressive/mvc";
|
|
3
|
+
import React, { Fragment } from "react";
|
|
4
4
|
|
|
5
|
+
//#region src/jsx-runtime.d.ts
|
|
5
6
|
declare namespace JSX {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
interface IntrinsicAttributes extends React__default.JSX.IntrinsicAttributes {
|
|
19
|
-
}
|
|
20
|
-
interface IntrinsicClassAttributes<T> extends React__default.JSX
|
|
21
|
-
.IntrinsicClassAttributes<T> {
|
|
22
|
-
}
|
|
23
|
-
interface IntrinsicElements extends React__default.JSX.IntrinsicElements {
|
|
24
|
-
}
|
|
7
|
+
type ElementType = State$1.Extends<AsComponent> | React.JSX.ElementType | ((props: {}, ref?: any) => void);
|
|
8
|
+
type LibraryManagedAttributes<C, P> = C extends (new (...args: any[]) => {
|
|
9
|
+
props: infer U;
|
|
10
|
+
}) ? U : C extends State$1.Extends<infer U> ? Props<U> : React.JSX.LibraryManagedAttributes<C, P>;
|
|
11
|
+
interface Element extends React.JSX.Element {}
|
|
12
|
+
interface ElementClass extends React.JSX.ElementClass {}
|
|
13
|
+
interface ElementAttributesProperty {}
|
|
14
|
+
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
|
|
15
|
+
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
|
|
16
|
+
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
|
17
|
+
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
|
25
18
|
}
|
|
26
|
-
declare function patch(this: (type:
|
|
27
|
-
declare const jsx: (type:
|
|
28
|
-
declare const jsxs: (type:
|
|
29
|
-
|
|
30
|
-
export { JSX, jsx, jsxs, patch };
|
|
19
|
+
declare function patch(this: (type: React.ElementType, ...args: any[]) => React.ReactElement, type: React.ElementType | State$1.Type, ...args: any[]): React.ReactElement;
|
|
20
|
+
declare const jsx: (type: React.ElementType<any, keyof React.JSX.IntrinsicElements> | State$1.Type<State$1>, ...args: any[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
21
|
+
declare const jsxs: (type: React.ElementType<any, keyof React.JSX.IntrinsicElements> | State$1.Type<State$1>, ...args: any[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Fragment, JSX, jsx, jsxs, patch };
|
|
24
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|