@expressive/react 0.74.1 → 0.74.2-canary.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/{context-DEag_HVs.js → context-DT3kwoQN.js} +2 -2
- package/dist/{context-DEag_HVs.js.map → context-DT3kwoQN.js.map} +1 -1
- package/dist/esm/context.js +1 -1
- package/dist/esm/context.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/state.js +1 -1
- package/package.json +3 -3
|
@@ -14,7 +14,7 @@ function Consumer(props) {
|
|
|
14
14
|
function Provider(props) {
|
|
15
15
|
const context = _expressive_state.Context.use(true);
|
|
16
16
|
(0, react.useEffect)(() => () => context.pop(), [context]);
|
|
17
|
-
context.
|
|
17
|
+
context.set(props.for, (state) => {
|
|
18
18
|
if (props.forEach) {
|
|
19
19
|
const cleanup = props.forEach(state);
|
|
20
20
|
if (cleanup) state.set(cleanup, null);
|
|
@@ -59,4 +59,4 @@ Object.defineProperty(exports, 'provide', {
|
|
|
59
59
|
return provide;
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
//# sourceMappingURL=context-
|
|
62
|
+
//# sourceMappingURL=context-DT3kwoQN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-
|
|
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"}
|
package/dist/esm/context.js
CHANGED
|
@@ -13,7 +13,7 @@ function Consumer(props) {
|
|
|
13
13
|
function Provider(props) {
|
|
14
14
|
const context = Context.use(true);
|
|
15
15
|
useEffect(() => () => context.pop(), [context]);
|
|
16
|
-
context.
|
|
16
|
+
context.set(props.for, (state) => {
|
|
17
17
|
if (props.forEach) {
|
|
18
18
|
const cleanup = props.forEach(state);
|
|
19
19
|
if (cleanup) state.set(cleanup, null);
|
package/dist/esm/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../src/context.ts"],"sourcesContent":["import State,
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"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,SAAS,cAAc,IAAI,SAAS,CAAC;AASlD,QAAQ,OAAO,WAAqB;CAClC,MAAM,UAAU,WAAW,OAAO;AAElC,QAAO,SAAS,cAAc,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,UAAU,QAAQ,IAAI,KAAK;AAEjC,uBAAsB,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,YAAW,cAAc,UAAU;EAAE;EAAU;EAAM,EAAE,SAAS;AAElE,QAAO,cAAc,OAAO,UAAU;EACpC,KAAK,QAAQ;EACb,OAAO;EACP;EACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pragma, ReactState } from "./state";
|
|
2
|
-
import
|
|
2
|
+
import { Context, Context as Context$1, Observable, State, get, ref, set, use } from "@expressive/state";
|
|
3
3
|
import * as react from "react";
|
|
4
4
|
import { Fragment, ReactNode, createElement } from "react";
|
|
5
5
|
|
|
@@ -11,8 +11,8 @@ declare module '@expressive/state' {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
declare namespace Consumer {
|
|
14
|
-
type Props<T extends State
|
|
15
|
-
/** Type of controller to fetch from context. */for: State
|
|
14
|
+
type Props<T extends State> = {
|
|
15
|
+
/** Type of controller to fetch from context. */for: State.Extends<T>;
|
|
16
16
|
/**
|
|
17
17
|
* Render function, will receive instance of desired controller.
|
|
18
18
|
*
|
|
@@ -23,9 +23,9 @@ declare namespace Consumer {
|
|
|
23
23
|
children: (value: T) => ReactNode | void;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
declare function Consumer<T extends State
|
|
26
|
+
declare function Consumer<T extends State>(props: Consumer.Props<T>): string | number | bigint | boolean | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | react.ReactPortal | null;
|
|
27
27
|
declare namespace Provider {
|
|
28
|
-
interface Props<T extends State
|
|
28
|
+
interface Props<T extends State> {
|
|
29
29
|
/** State or group of States to provide to descendant Consumers. */
|
|
30
30
|
for: Context$1.Accept<T>;
|
|
31
31
|
/**
|
|
@@ -45,7 +45,7 @@ declare namespace Provider {
|
|
|
45
45
|
name?: string | undefined;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
declare function Provider<T extends State
|
|
48
|
+
declare function Provider<T extends State>(props: Provider.Props<T>): ReactNode;
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region src/index.d.ts
|
|
51
51
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_chunk = require('./chunk-BE-pF4vm.js');
|
|
3
|
-
const require_context = require('./context-
|
|
3
|
+
const require_context = require('./context-DT3kwoQN.js');
|
|
4
4
|
let _expressive_state = require("@expressive/state");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let src_state = require("./state");
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_chunk = require('./chunk-BE-pF4vm.js');
|
|
3
|
-
const require_context = require('./context-
|
|
3
|
+
const require_context = require('./context-DT3kwoQN.js');
|
|
4
4
|
let _expressive_state = require("@expressive/state");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let src_state = require("./state");
|
package/dist/state.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_chunk = require('./chunk-BE-pF4vm.js');
|
|
3
|
-
const require_context = require('./context-
|
|
3
|
+
const require_context = require('./context-DT3kwoQN.js');
|
|
4
4
|
let _expressive_state = require("@expressive/state");
|
|
5
5
|
|
|
6
6
|
//#region src/state.ts
|
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"preversion": "npm run test && npm run build"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@expressive/state": "^0.74.0"
|
|
56
|
+
"@expressive/state": "^0.74.2-canary.0+50f98d7"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": ">=16.8.0 <20.0.0"
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"tsup": "^8.0.2",
|
|
75
75
|
"vitest": "^4.0.18"
|
|
76
76
|
},
|
|
77
|
-
"version": "0.74.
|
|
78
|
-
"gitHead": "
|
|
77
|
+
"version": "0.74.2-canary.0+50f98d7",
|
|
78
|
+
"gitHead": "50f98d704c222d3d6bf4b046845e6ba3ad1f6954"
|
|
79
79
|
}
|