@expressive/react 0.57.0 → 0.57.1
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/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
has
|
|
13
13
|
} from "@expressive/mvc";
|
|
14
14
|
import { Consumer, Provider } from "./context";
|
|
15
|
+
import { Fragment, createElement } from "react";
|
|
15
16
|
Pragma.useContext = () => useContext(Context);
|
|
16
17
|
Pragma.useLifecycle = (callback) => useEffect(() => callback(), []);
|
|
17
18
|
Pragma.useFactory = (factory) => {
|
|
@@ -22,8 +23,10 @@ Pragma.useFactory = (factory) => {
|
|
|
22
23
|
};
|
|
23
24
|
export {
|
|
24
25
|
Consumer,
|
|
26
|
+
Fragment,
|
|
25
27
|
Model,
|
|
26
28
|
Provider,
|
|
29
|
+
createElement,
|
|
27
30
|
Model2 as default,
|
|
28
31
|
get,
|
|
29
32
|
has,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { useContext, useEffect, useState } from 'react';\n\nimport { Pragma } from './adapter';\nimport { Context } from './context';\n\nPragma.useContext = () => useContext(Context);\n\nPragma.useLifecycle = (callback) => useEffect(() => callback(), []);\n\nPragma.useFactory = (factory) => {\n const state = useState(() => factory(() => {\n state[1](x => x.bind(null) as any);\n }));\n\n return state[0];\n}\n\nexport {\n Model, Model as default,\n get, use, ref, set, has\n} from '@expressive/mvc';\n\nexport { Consumer, Provider } from './context';\nexport { type Pragma };\n"],"mappings":";AAAA,SAAS,YAAY,WAAW,gBAAgB;AAEhD,SAAS,cAAc;AACvB,SAAS,eAAe;AAcxB;AAAA,EACE;AAAA,EAAgB,SAATA;AAAA,EACP;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,OACf;AAEP,SAAS,UAAU,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { useContext, useEffect, useState } from 'react';\n\nimport { Pragma } from './adapter';\nimport { Context } from './context';\n\nPragma.useContext = () => useContext(Context);\n\nPragma.useLifecycle = (callback) => useEffect(() => callback(), []);\n\nPragma.useFactory = (factory) => {\n const state = useState(() => factory(() => {\n state[1](x => x.bind(null) as any);\n }));\n\n return state[0];\n}\n\nexport {\n Model, Model as default,\n get, use, ref, set, has\n} from '@expressive/mvc';\n\nexport { Consumer, Provider } from './context';\nexport { Fragment, createElement } from 'react';\nexport { type Pragma };\n"],"mappings":";AAAA,SAAS,YAAY,WAAW,gBAAgB;AAEhD,SAAS,cAAc;AACvB,SAAS,eAAe;AAcxB;AAAA,EACE;AAAA,EAAgB,SAATA;AAAA,EACP;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,OACf;AAEP,SAAS,UAAU,gBAAgB;AACnC,SAAS,UAAU,qBAAqB;AAlBxC,OAAO,aAAa,MAAM,WAAW,OAAO;AAE5C,OAAO,eAAe,CAAC,aAAa,UAAU,MAAM,SAAS,GAAG,CAAC,CAAC;AAElE,OAAO,aAAa,CAAC,YAAY;AAC/B,QAAM,QAAQ,SAAS,MAAM,QAAQ,MAAM;AACzC,UAAM,CAAC,EAAE,OAAK,EAAE,KAAK,IAAI,CAAQ;AAAA,EACnC,CAAC,CAAC;AAEF,SAAO,MAAM,CAAC;AAChB;","names":["Model"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Model, { Context } from '@expressive/mvc';
|
|
|
3
3
|
export { Model, Model as default, get, has, ref, set, use } from '@expressive/mvc';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
+
export { Fragment, createElement } from 'react';
|
|
6
7
|
|
|
7
8
|
declare namespace Consumer {
|
|
8
9
|
type Props<T extends Model> = {
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Consumer: () => Consumer,
|
|
24
|
+
Fragment: () => import_react3.Fragment,
|
|
24
25
|
Model: () => import_mvc2.Model,
|
|
25
26
|
Provider: () => Provider,
|
|
27
|
+
createElement: () => import_react3.createElement,
|
|
26
28
|
default: () => import_mvc2.Model,
|
|
27
29
|
get: () => import_mvc2.get,
|
|
28
30
|
has: () => import_mvc2.has,
|
|
@@ -62,6 +64,7 @@ function Provider(props) {
|
|
|
62
64
|
|
|
63
65
|
// src/index.ts
|
|
64
66
|
var import_mvc2 = require("@expressive/mvc");
|
|
67
|
+
var import_react3 = require("react");
|
|
65
68
|
import_adapter.Pragma.useContext = () => (0, import_react2.useContext)(Lookup);
|
|
66
69
|
import_adapter.Pragma.useLifecycle = (callback) => (0, import_react2.useEffect)(() => callback(), []);
|
|
67
70
|
import_adapter.Pragma.useFactory = (factory) => {
|
|
@@ -73,8 +76,10 @@ import_adapter.Pragma.useFactory = (factory) => {
|
|
|
73
76
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
77
|
0 && (module.exports = {
|
|
75
78
|
Consumer,
|
|
79
|
+
Fragment,
|
|
76
80
|
Model,
|
|
77
81
|
Provider,
|
|
82
|
+
createElement,
|
|
78
83
|
get,
|
|
79
84
|
has,
|
|
80
85
|
ref,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/context.ts"],"sourcesContent":["import { useContext, useEffect, useState } from 'react';\n\nimport { Pragma } from './adapter';\nimport { Context } from './context';\n\nPragma.useContext = () => useContext(Context);\n\nPragma.useLifecycle = (callback) => useEffect(() => callback(), []);\n\nPragma.useFactory = (factory) => {\n const state = useState(() => factory(() => {\n state[1](x => x.bind(null) as any);\n }));\n\n return state[0];\n}\n\nexport {\n Model, Model as default,\n get, use, ref, set, has\n} from '@expressive/mvc';\n\nexport { Consumer, Provider } from './context';\nexport { type Pragma };\n","import Model, { Context } from '@expressive/mvc';\nimport { ReactNode, createContext, createElement, useContext, useEffect, useMemo } from 'react';\n\nconst Lookup = createContext(new Context());\n\ndeclare namespace Consumer {\n type Props<T extends Model> = {\n /** Type of controller to fetch from context. */\n for: Model.Type<T>;\n\n /**\n * Render function, will receive instance of desired controller.\n *\n * Called every render of parent component.\n * Similar to `Model.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 Model>(props: Consumer.Props<T>){\n return props.for.get(i => props.children(i));\n}\n\ndeclare namespace Provider {\n interface Props<T extends Model> {\n for: Context.Accept<T>;\n forEach?: Context.Expect<T>;\n children?: ReactNode;\n }\n}\n\nfunction Provider<T extends Model>(props: Provider.Props<T>){\n const ambient = useContext(Lookup);\n const context = useMemo(() => ambient.push(), [ambient]);\n\n useEffect(() => () => context.pop(), [ambient]);\n \n context.include(props.for, (model) => {\n // TODO: remove next minor release\n if(\"set\" in props)\n throw new Error(`The \\`set\\` prop is deprecated. Use \\`forEach\\` or <${model.constructor} {...props} /> instead.`);\n\n if(props.forEach){\n const cleanup = props.forEach(model);\n\n if(cleanup)\n model.set(null, cleanup);\n }\n });\n\n return createElement(Lookup.Provider, {\n key: context.id,\n value: context\n }, props.children);\n}\n\nexport { Consumer, Provider, Lookup as Context }"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAgD;AAEhD,qBAAuB;;;ACFvB,iBAA+B;AAC/B,mBAAwF;AAExF,IAAM,aAAS,4BAAc,IAAI,mBAAQ,CAAC;AAkB1C,SAAS,SAA0B,OAAyB;AAC1D,SAAO,MAAM,IAAI,IAAI,OAAK,MAAM,SAAS,CAAC,CAAC;AAC7C;AAUA,SAAS,SAA0B,OAAyB;AAC1D,QAAM,cAAU,yBAAW,MAAM;AACjC,QAAM,cAAU,sBAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC,OAAO,CAAC;AAEvD,8BAAU,MAAM,MAAM,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC;AAE9C,UAAQ,QAAQ,MAAM,KAAK,CAAC,UAAU;AAEpC,QAAG,SAAS;AACV,YAAM,IAAI,MAAM,uDAAuD,MAAM,WAAW,yBAAyB;AAEnH,QAAG,MAAM,SAAQ;AACf,YAAM,UAAU,MAAM,QAAQ,KAAK;AAEnC,UAAG;AACD,cAAM,IAAI,MAAM,OAAO;AAAA,IAC3B;AAAA,EACF,CAAC;AAED,aAAO,4BAAc,OAAO,UAAU;AAAA,IACpC,KAAK,QAAQ;AAAA,IACb,OAAO;AAAA,EACT,GAAG,MAAM,QAAQ;AACnB;;;ADvCA,IAAAC,cAGO;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/context.ts"],"sourcesContent":["import { useContext, useEffect, useState } from 'react';\n\nimport { Pragma } from './adapter';\nimport { Context } from './context';\n\nPragma.useContext = () => useContext(Context);\n\nPragma.useLifecycle = (callback) => useEffect(() => callback(), []);\n\nPragma.useFactory = (factory) => {\n const state = useState(() => factory(() => {\n state[1](x => x.bind(null) as any);\n }));\n\n return state[0];\n}\n\nexport {\n Model, Model as default,\n get, use, ref, set, has\n} from '@expressive/mvc';\n\nexport { Consumer, Provider } from './context';\nexport { Fragment, createElement } from 'react';\nexport { type Pragma };\n","import Model, { Context } from '@expressive/mvc';\nimport { ReactNode, createContext, createElement, useContext, useEffect, useMemo } from 'react';\n\nconst Lookup = createContext(new Context());\n\ndeclare namespace Consumer {\n type Props<T extends Model> = {\n /** Type of controller to fetch from context. */\n for: Model.Type<T>;\n\n /**\n * Render function, will receive instance of desired controller.\n *\n * Called every render of parent component.\n * Similar to `Model.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 Model>(props: Consumer.Props<T>){\n return props.for.get(i => props.children(i));\n}\n\ndeclare namespace Provider {\n interface Props<T extends Model> {\n for: Context.Accept<T>;\n forEach?: Context.Expect<T>;\n children?: ReactNode;\n }\n}\n\nfunction Provider<T extends Model>(props: Provider.Props<T>){\n const ambient = useContext(Lookup);\n const context = useMemo(() => ambient.push(), [ambient]);\n\n useEffect(() => () => context.pop(), [ambient]);\n \n context.include(props.for, (model) => {\n // TODO: remove next minor release\n if(\"set\" in props)\n throw new Error(`The \\`set\\` prop is deprecated. Use \\`forEach\\` or <${model.constructor} {...props} /> instead.`);\n\n if(props.forEach){\n const cleanup = props.forEach(model);\n\n if(cleanup)\n model.set(null, cleanup);\n }\n });\n\n return createElement(Lookup.Provider, {\n key: context.id,\n value: context\n }, props.children);\n}\n\nexport { Consumer, Provider, Lookup as Context }"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAgD;AAEhD,qBAAuB;;;ACFvB,iBAA+B;AAC/B,mBAAwF;AAExF,IAAM,aAAS,4BAAc,IAAI,mBAAQ,CAAC;AAkB1C,SAAS,SAA0B,OAAyB;AAC1D,SAAO,MAAM,IAAI,IAAI,OAAK,MAAM,SAAS,CAAC,CAAC;AAC7C;AAUA,SAAS,SAA0B,OAAyB;AAC1D,QAAM,cAAU,yBAAW,MAAM;AACjC,QAAM,cAAU,sBAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC,OAAO,CAAC;AAEvD,8BAAU,MAAM,MAAM,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC;AAE9C,UAAQ,QAAQ,MAAM,KAAK,CAAC,UAAU;AAEpC,QAAG,SAAS;AACV,YAAM,IAAI,MAAM,uDAAuD,MAAM,WAAW,yBAAyB;AAEnH,QAAG,MAAM,SAAQ;AACf,YAAM,UAAU,MAAM,QAAQ,KAAK;AAEnC,UAAG;AACD,cAAM,IAAI,MAAM,OAAO;AAAA,IAC3B;AAAA,EACF,CAAC;AAED,aAAO,4BAAc,OAAO,UAAU;AAAA,IACpC,KAAK,QAAQ;AAAA,IACb,OAAO;AAAA,EACT,GAAG,MAAM,QAAQ;AACnB;;;ADvCA,IAAAC,cAGO;AAGP,IAAAC,gBAAwC;AAlBxC,sBAAO,aAAa,UAAM,0BAAW,MAAO;AAE5C,sBAAO,eAAe,CAAC,iBAAa,yBAAU,MAAM,SAAS,GAAG,CAAC,CAAC;AAElE,sBAAO,aAAa,CAAC,YAAY;AAC/B,QAAM,YAAQ,wBAAS,MAAM,QAAQ,MAAM;AACzC,UAAM,CAAC,EAAE,OAAK,EAAE,KAAK,IAAI,CAAQ;AAAA,EACnC,CAAC,CAAC;AAEF,SAAO,MAAM,CAAC;AAChB;","names":["import_react","import_mvc","import_react"]}
|
package/package.json
CHANGED