@expressive/react 0.70.0 → 0.72.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/adapter.d.ts CHANGED
@@ -1,20 +1,59 @@
1
- import { Context } from '@expressive/mvc';
2
- import React__default, { FunctionComponent } from 'react';
1
+ import { FunctionComponent, ReactNode } from 'react';
3
2
 
4
3
  declare module '@expressive/mvc' {
5
- namespace Model {
6
- interface Component<T extends Model, P extends Model.Assign<T>> extends FunctionComponent<P & Model.Props<T>> {
4
+ namespace State {
5
+ type HasProps<T extends State> = {
6
+ [K in Exclude<keyof T, keyof State>]?: T[K];
7
+ };
8
+ type ComponentProps<T extends State> = 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<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
+ /**
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 State> = 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 extends State.Valid {
37
+ render?(props: RenderProps<this>, self: this): React.ReactNode;
38
+ fallback?: React.ReactNode;
39
+ }
40
+ interface FC<T extends State, P extends State.Assign<T>> extends FunctionComponent<P & State.Props<T>> {
7
41
  displayName?: string;
8
- Model: Model.Type<T>;
42
+ State: State.Extends<T>;
9
43
  }
10
- function as<T extends Model, P extends Model.Assign<T>>(this: Model.Init<T>, render: (props: P, self: T) => React__default.ReactNode): Component<T, P>;
44
+ function as<T extends State, P extends State.Assign<T>>(this: State.New<T>, render: (props: P, self: T) => ReactNode): FC<T, P>;
11
45
  }
12
46
  }
13
47
 
14
48
  declare module '@expressive/mvc' {
15
- namespace Model {
16
- function use<T extends Model>(this: Model.Init<T>, apply?: Model.Assign<T>, repeat?: boolean): T;
17
- function use<T extends Model>(this: Model.Init<T>, callback?: Model.Callback<T>, repeat?: boolean): T;
49
+ namespace State {
50
+ interface Valid {
51
+ use?(...props: any[]): Promise<void> | void;
52
+ }
53
+ type UseArgs<T extends State> = T extends {
54
+ use(...props: infer P): any;
55
+ } ? P : State.Args<T>;
56
+ function use<T extends State>(this: New<T>, ...args: UseArgs<T>): T;
18
57
  }
19
58
  }
20
59
 
@@ -42,64 +81,25 @@ type ForceRefresh = {
42
81
  <T = void>(invoke: () => Promise<T>): Promise<T>;
43
82
  };
44
83
  declare module '@expressive/mvc' {
45
- namespace Model {
46
- type GetFactory<T extends Model, R> = (this: T, current: T, refresh: ForceRefresh) => R;
47
- type GetEffect<T extends Model> = (this: T, current: T, refresh: ForceRefresh) => null;
84
+ namespace State {
85
+ type GetFactory<T extends State, R> = (this: T, current: T, refresh: ForceRefresh) => R;
86
+ type GetEffect<T extends State> = (this: T, current: T, refresh: ForceRefresh) => null;
48
87
  /** Fetch instance of this class from context. */
49
- function get<T extends Model>(this: Model.Type<T>): T;
88
+ function get<T extends State>(this: Extends<T>): T;
50
89
  /** Fetch instance of this class optionally. */
51
- function get<T extends Model>(this: Model.Type<T>, required: false): T | undefined;
90
+ function get<T extends State>(this: Extends<T>, required: false): T | undefined;
52
91
  /** Fetch instance of this class from context. */
53
- function get<T extends Model>(this: Model.Type<T>, requireValues: true): Required<T>;
54
- function get<T extends Model, R>(this: Model.Type<T>, factory: GetFactory<T, Promise<R> | R>): NoVoid<R>;
55
- function get<T extends Model>(this: Model.Type<T>, factory: GetEffect<T>): null;
92
+ function get<T extends State>(this: Extends<T>, requireValues: true): Required<T>;
93
+ function get<T extends State, R>(this: Extends<T>, factory: GetFactory<T, Promise<R> | R>): NoVoid<R>;
94
+ function get<T extends State>(this: Extends<T>, factory: GetEffect<T>): null;
56
95
  }
57
96
  }
58
97
 
59
- declare module '@expressive/mvc' {
60
- namespace Model {
61
- type HasProps<T extends Model> = {
62
- [K in Exclude<keyof T, keyof Model>]?: T[K];
63
- };
64
- /**
65
- * Props which will not conflict with a Model's use as a Component.
66
- *
67
- * Built-in properties must be optional, as they will always be omitted.
68
- */
69
- type RenderProps<T extends Model> = HasProps<T> & {
70
- is?: undefined;
71
- get?: undefined;
72
- set?: undefined;
73
- };
74
- /** Model which is not incompatable as Component in React. */
75
- interface Compat extends Model {
76
- render?(props: RenderProps<this>, self: this): React.ReactNode;
77
- fallback?: React.ReactNode;
78
- }
79
- interface BaseProps<T extends Model> {
80
- /**
81
- * Callback for newly created instance. Only called once.
82
- * @returns Callback to run when instance is destroyed.
83
- */
84
- is?: (instance: T) => void | (() => void);
85
- render?(props: HasProps<T>, self: T): React.ReactNode;
86
- /**
87
- * A fallback react tree to show when suspended.
88
- * If not provided, `fallback` property of the Model will be used.
89
- */
90
- fallback?: React.ReactNode;
91
- }
92
- type Props<T extends Model> = T extends {
93
- render(props: infer P, self: any): any;
94
- } ? BaseProps<T> & HasProps<T> & Omit<P, keyof Model> : BaseProps<T> & HasProps<T> & {
95
- children?: React.ReactNode;
96
- };
97
- }
98
- }
98
+ declare namespace Pragma { }
99
99
  declare const Pragma: {
100
- useContext(): Context;
101
- useFactory<T extends Function>(factory: (refresh: () => void) => T): T;
102
- useLifecycle(callback: () => () => void): void;
100
+ useState<S>(initial: () => S): [S, (next: (previous: S) => S) => void];
101
+ useEffect(effect: () => () => void, deps?: any[]): void;
102
+ createElement(type: any, props?: any, ...children: any[]): any;
103
103
  };
104
104
 
105
105
  export { Pragma };
package/dist/adapter.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,144 +15,174 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/adapter.ts
31
21
  var adapter_exports = {};
32
22
  __export(adapter_exports, {
33
- Pragma: () => Pragma3
23
+ Pragma: () => Pragma4
34
24
  });
35
25
  module.exports = __toCommonJS(adapter_exports);
36
26
 
37
- // src/model.as.ts
27
+ // src/state.as.ts
38
28
  var import_mvc2 = require("@expressive/mvc");
39
29
 
40
30
  // src/context.ts
41
- var import_mvc = __toESM(require("@expressive/mvc"));
31
+ var import_mvc = require("@expressive/mvc");
42
32
  var import_react = require("react");
43
- var Lookup = (0, import_react.createContext)(new import_mvc.Context());
33
+ var Layers = (0, import_react.createContext)(new import_mvc.Context());
44
34
  import_mvc.Context.use = (create) => {
45
- const ambient = (0, import_react.useContext)(Lookup);
46
- return create ? (0, import_react.useMemo)(() => ambient.push(), []) : ambient;
35
+ const ambient = (0, import_react.useContext)(Layers);
36
+ return create ? (0, import_react.useMemo)(() => ambient.push(), [ambient]) : ambient;
47
37
  };
48
- function createProvider(context, children, fallback, name) {
49
- if (context instanceof import_mvc.default)
50
- context = import_mvc.Context.get(context);
51
- const element = (0, import_react.createElement)(Lookup.Provider, {
38
+ function provide(context, children, fallback, name) {
39
+ if (fallback !== void 0)
40
+ children = (0, import_react.createElement)(import_react.Suspense, { fallback, name }, children);
41
+ return (0, import_react.createElement)(Layers.Provider, {
52
42
  key: context.id,
53
43
  value: context,
54
44
  children
55
45
  });
56
- return fallback !== void 0 ? (0, import_react.createElement)(import_react.Suspense, { fallback, name }, element) : element;
57
46
  }
58
47
 
59
- // src/model.as.ts
60
- import_mvc2.Model.as = function(render) {
61
- if (this === import_mvc2.Model)
62
- throw new Error("Cannot create component from base Model.");
63
- const Component = (props) => {
64
- const local = this.use((self) => {
65
- self.set(props);
66
- if (props.is)
67
- return props.is(self);
68
- });
69
- local.set(props);
70
- return createProvider(
71
- local,
72
- render(props, local),
73
- props.fallback || local.fallback,
74
- String(local)
75
- );
76
- };
77
- Component.Model = this;
78
- Component.displayName = this.name;
79
- return Component;
48
+ // src/state.as.ts
49
+ var import_adapter = require("./adapter");
50
+ import_mvc2.State.as = function(render) {
51
+ const FC = Render.bind(this, { render });
52
+ return Object.assign(FC, {
53
+ displayName: this.name,
54
+ State: this
55
+ });
80
56
  };
57
+ function Render(props, props2) {
58
+ const { is, ...rest } = { ...props, ...props2 };
59
+ const ambient = import_mvc2.Context.use();
60
+ const state = import_adapter.Pragma.useState(() => {
61
+ const instance = this.new(rest, is && ((x) => void is(x)));
62
+ const context = ambient.push(instance);
63
+ let ready;
64
+ let active;
65
+ (0, import_mvc2.watch)(instance, (current) => {
66
+ active = current;
67
+ if (ready) state[1]((x) => x.bind(null));
68
+ });
69
+ function didMount() {
70
+ ready = true;
71
+ return () => {
72
+ context.pop();
73
+ instance.set(null);
74
+ };
75
+ }
76
+ function Render2(props3) {
77
+ const render = import_mvc2.METHOD.get(active.render) || props3.render || active.render;
78
+ return render ? render.call(active, props3, active) : props3.children;
79
+ }
80
+ return (props3) => {
81
+ ready = false;
82
+ import_adapter.Pragma.useEffect(didMount, []);
83
+ Promise.resolve(instance.set(props3)).finally(() => {
84
+ ready = true;
85
+ });
86
+ return provide(
87
+ context,
88
+ import_adapter.Pragma.createElement(Render2, props3),
89
+ props3.fallback || active.fallback,
90
+ String(instance)
91
+ );
92
+ };
93
+ });
94
+ return state[0](rest);
95
+ }
81
96
 
82
- // src/model.use.ts
97
+ // src/state.use.ts
83
98
  var import_mvc3 = require("@expressive/mvc");
84
- var import_adapter = require("./adapter");
85
- import_mvc3.Model.use = function(argument, repeat) {
86
- const context = import_mvc3.Context.use(true);
87
- const render = import_adapter.Pragma.useFactory((refresh) => {
99
+ var import_adapter2 = require("./adapter");
100
+ import_mvc3.State.use = function(...args) {
101
+ const ambient = import_mvc3.Context.use();
102
+ const state = import_adapter2.Pragma.useState(() => {
88
103
  let ready;
89
- let local;
90
- const instance = new this(argument);
91
- context.include(instance);
92
- const unwatch = (0, import_mvc3.createEffect)(instance, (current) => {
93
- local = current;
94
- if (ready)
95
- refresh();
104
+ let active;
105
+ const instance = this.new(
106
+ (x) => x.use ? Promise.resolve(x.use(...args)) : args
107
+ );
108
+ const context = ambient.push(instance);
109
+ (0, import_mvc3.watch)(instance, (current) => {
110
+ active = current;
111
+ if (ready) state[1]((x) => x.bind(null));
96
112
  });
97
113
  function didMount() {
98
114
  ready = true;
99
115
  return () => {
100
- unwatch();
101
116
  context.pop();
102
117
  instance.set(null);
103
118
  };
104
119
  }
105
- return (props) => {
106
- import_adapter.Pragma.useLifecycle(didMount);
107
- if (ready && repeat && props) {
120
+ return (...args2) => {
121
+ import_adapter2.Pragma.useEffect(didMount, []);
122
+ if (ready) {
108
123
  ready = false;
109
- if (typeof props == "function") {
110
- props.call(instance, instance);
111
- props = void 0;
112
- }
113
- const update = instance.set(props);
114
- if (update)
115
- update.then(() => ready = true);
116
- else
124
+ Promise.resolve(
125
+ instance.use ? instance.use(...args2) : Promise.all(
126
+ args2.flat().map(
127
+ (arg) => typeof arg == "object" && instance.set(arg)
128
+ )
129
+ )
130
+ ).finally(() => {
117
131
  ready = true;
132
+ });
118
133
  }
119
- return local;
134
+ return active;
120
135
  };
121
136
  });
122
- return render(argument);
137
+ return state[0](...args);
123
138
  };
124
139
 
125
- // src/model.get.ts
140
+ // src/state.get.ts
126
141
  var import_mvc4 = require("@expressive/mvc");
127
- var import_adapter2 = require("./adapter");
128
- import_mvc4.Model.get = function(argument) {
129
- const context = import_adapter2.Pragma.useContext();
130
- const render = import_adapter2.Pragma.useFactory((refresh) => {
142
+ var import_adapter3 = require("./adapter");
143
+ import_mvc4.State.get = function(argument) {
144
+ const context = import_mvc4.Context.use();
145
+ const state = import_adapter3.Pragma.useState(() => {
131
146
  const instance = context.get(this);
132
147
  if (!instance)
133
- if (argument === false)
134
- return () => void 0;
135
- else
136
- throw new Error(`Could not find ${this} in context.`);
148
+ if (argument === false) return () => void 0;
149
+ else throw new Error(`Could not find ${this} in context.`);
137
150
  let ready;
138
151
  let value;
139
- const unwatch = (0, import_mvc4.createEffect)(instance, (current) => {
140
- if (typeof argument === "function") {
141
- const next = argument.call(current, current, update);
142
- if (next === value)
143
- return;
144
- value = next;
145
- } else
146
- value = current;
147
- if (ready)
148
- refresh();
149
- }, argument === true);
152
+ function render() {
153
+ state[1]((x) => x.bind(null));
154
+ }
155
+ function refresh(action) {
156
+ if (typeof action == "function") action = action();
157
+ render();
158
+ if (action) return action.finally(render);
159
+ }
160
+ function onMount() {
161
+ ready = true;
162
+ return unwatch;
163
+ }
164
+ const unwatch = (0, import_mvc4.watch)(
165
+ instance,
166
+ (current) => {
167
+ if (typeof argument === "function") {
168
+ const next = argument.call(current, current, refresh);
169
+ if (next === value) return;
170
+ value = next;
171
+ } else value = current;
172
+ if (ready) render();
173
+ },
174
+ argument === true
175
+ );
150
176
  if (value instanceof Promise) {
151
177
  let error;
152
178
  unwatch();
153
- value.then((x) => value = x, (e) => error = e).finally(refresh);
179
+ value.then(
180
+ (x) => value = x,
181
+ (e) => error = e
182
+ ).finally(render);
154
183
  value = null;
155
184
  return () => {
156
- if (error)
157
- throw error;
185
+ if (error) throw error;
158
186
  return value === void 0 ? null : value;
159
187
  };
160
188
  }
@@ -162,28 +190,16 @@ import_mvc4.Model.get = function(argument) {
162
190
  unwatch();
163
191
  return () => null;
164
192
  }
165
- ;
166
- function update(action) {
167
- if (typeof action == "function")
168
- action = action();
169
- refresh();
170
- if (action)
171
- return action.finally(refresh);
172
- }
173
- function didMount() {
174
- ready = true;
175
- return unwatch;
176
- }
177
193
  return () => {
178
- import_adapter2.Pragma.useLifecycle(didMount);
194
+ import_adapter3.Pragma.useEffect(onMount, []);
179
195
  return value === void 0 ? null : value;
180
196
  };
181
197
  });
182
- return render();
198
+ return state[0]();
183
199
  };
184
200
 
185
201
  // src/adapter.ts
186
- var Pragma3 = {};
202
+ var Pragma4 = {};
187
203
  // Annotate the CommonJS export names for ESM import in node:
188
204
  0 && (module.exports = {
189
205
  Pragma
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adapter.ts","../src/model.as.ts","../src/context.ts","../src/model.use.ts","../src/model.get.ts"],"sourcesContent":["import { Context } from '@expressive/mvc';\n\ndeclare module '@expressive/mvc' {\n namespace Model {\n type HasProps<T extends Model> = {\n [K in Exclude<keyof T, keyof Model>]?: T[K];\n }\n\n /**\n * Props which will not conflict with a Model's use as a Component.\n * \n * Built-in properties must be optional, as they will always be omitted.\n */\n type RenderProps<T extends Model> = HasProps<T> & {\n is?: undefined;\n get?: undefined;\n set?: undefined;\n };\n\n /** Model which is not incompatable as Component in React. */\n interface Compat extends Model {\n render?(props: RenderProps<this>, self: this): React.ReactNode;\n fallback?: React.ReactNode;\n }\n\n interface BaseProps<T extends Model> {\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 | (() => void);\n\n render?(props: HasProps<T>, self: T): React.ReactNode;\n\n /**\n * A fallback react tree to show when suspended.\n * If not provided, `fallback` property of the Model will be used.\n */\n fallback?: React.ReactNode;\n }\n\n type Props<T extends Model> = \n T extends { render(props: infer P, self: any): any }\n ? BaseProps<T> & HasProps<T> & Omit<P, keyof Model>\n : BaseProps<T> & HasProps<T> & { children?: React.ReactNode };\n }\n}\n\nconst Pragma = {} as {\n useContext(): Context;\n\n useFactory<T extends Function>(\n factory: (refresh: () => void) => T\n ): T;\n\n useLifecycle(callback: () => () => void): void;\n};\n\nexport { Pragma };\n\nimport \"./model.as\";\nimport './model.use';\nimport './model.get';","import { Model } from '@expressive/mvc';\nimport React, { FunctionComponent } from 'react';\n\nimport { createProvider } from './context';\n\ndeclare module '@expressive/mvc' {\n namespace Model {\n interface Component<T extends Model, P extends Model.Assign<T>> extends FunctionComponent<P & Model.Props<T>> {\n displayName?: string;\n Model: Model.Type<T>;\n }\n\n function as <T extends Model, P extends Model.Assign<T>> (\n this: Model.Init<T>, render: (props: P, self: T) => React.ReactNode\n ): Component<T, P>;\n }\n}\n\nModel.as = function <T extends Model.Compat, P extends Model.Assign<T>> (\n this: Model.Init<T>,\n render: (props: P, self: T) => React.ReactNode\n){\n if(this === Model)\n throw new Error(\"Cannot create component from base Model.\");\n\n const Component: Model.Component<T, P> = (props) => {\n const local = this.use((self) => {\n self.set(props);\n\n if(props.is)\n return props.is(self);\n });\n\n local.set(props);\n\n return createProvider(\n local,\n render(props, local),\n props.fallback || local.fallback,\n String(local)\n );\n }\n\n Component.Model = this;\n Component.displayName = this.name;\n \n return Component;\n}","import Model, { Context } from '@expressive/mvc';\nimport { createContext, createElement, ReactNode, Suspense, useContext, useEffect, useMemo } from 'react';\n\nconst Lookup = createContext(new Context());\n\ndeclare module '@expressive/mvc' {\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(Lookup);\n\n return create ?\n useMemo(() => ambient.push(), []) :\n ambient;\n}\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 /** Model or group of Models to provide to descendant Consumers. */\n for: Context.Accept<T>;\n\n forEach?: Context.Expect<T>;\n children?: ReactNode;\n\n /** A fallback react 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 Model>(props: Provider.Props<T>){\n const context = Context.use(true);\n\n useEffect(() => () => context.pop(), [context]);\n\n context.include(props.for, (model) => {\n if(props.forEach){\n const cleanup = props.forEach(model);\n\n if(cleanup)\n model.set(cleanup, null);\n }\n });\n \n return createProvider(context, props.children, props.fallback, props.name);\n}\n\nexport function createProvider(\n context: Context | Model,\n children: ReactNode,\n fallback?: ReactNode,\n name?: string | undefined){\n\n if(context instanceof Model)\n context = Context.get(context)!;\n\n const element = createElement(Lookup.Provider, {\n key: context.id,\n value: context,\n children\n });\n\n return fallback !== undefined ?\n createElement(Suspense, { fallback, name }, element) :\n element;\n}\n\nexport { Consumer, Provider, Context }\n","import { Model, Context, createEffect } from '@expressive/mvc';\n\nimport { Pragma } from './adapter';\n\ndeclare module '@expressive/mvc' {\n namespace Model {\n function use <T extends Model> (\n this: Model.Init<T>,\n apply?: Model.Assign<T>,\n repeat?: boolean\n ): T;\n\n function use <T extends Model> (\n this: Model.Init<T>,\n callback?: Model.Callback<T>,\n repeat?: boolean\n ): T;\n }\n}\n\nModel.use = function <T extends Model> (\n this: Model.Init<T>,\n argument?: Model.Assign<T> | Model.Callback<T>,\n repeat?: boolean){\n\n const context = Context.use(true);\n const render = Pragma.useFactory((refresh) => {\n let ready: boolean | undefined;\n let local: T;\n\n const instance = new this(argument);\n\n context.include(instance);\n \n const unwatch = createEffect(instance, current => {\n local = current;\n\n if(ready) \n refresh();\n });\n\n function didMount(){\n ready = true;\n return () => {\n unwatch();\n context.pop()\n instance.set(null);\n }\n }\n\n return (props?: Model.Assign<T> | Model.Callback<T>) => {\n Pragma.useLifecycle(didMount);\n\n if(ready && repeat && props){\n ready = false;\n\n if(typeof props == \"function\"){\n props.call(instance, instance);\n props = undefined\n }\n\n const update = instance.set(props);\n\n if(update)\n update.then(() => ready = true);\n else\n ready = true;\n }\n\n return local; \n };\n });\n\n return render(argument);\n}","import { createEffect, Model } from '@expressive/mvc';\n\nimport { Pragma } from './adapter';\n\n/** Type may not be undefined - instead will be null. */\ntype NoVoid<T> = T extends undefined | void ? null : T;\n\ntype ForceRefresh = {\n /** Request a refresh for current component. */\n (): void;\n \n /**\n * Request a refresh and again after promise either resolves or rejects.\n * \n * @param waitFor Promise to wait for.\n * @returns Promise which resolves, after refresh, to same value as `waitFor`.\n */\n <T = void>(waitFor: Promise<T>): Promise<T>;\n\n /**\n * Request refresh before and after async function.\n * A refresh will occur both before and after the given function.\n * \n * **Note:** Any actions performed before first `await` will occur prior to refresh.\n * \n * @param invoke Async function to invoke.\n * @returns Promise which resolves returned value after refresh.\n */\n <T = void>(invoke: () => Promise<T>): Promise<T>;\n};\n\ndeclare module '@expressive/mvc' {\n namespace Model {\n type GetFactory<T extends Model, R> =\n (this: T, current: T, refresh: ForceRefresh) => R;\n\n type GetEffect<T extends Model> =\n (this: T, current: T, refresh: ForceRefresh) => null;\n\n /** Fetch instance of this class from context. */\n function get <T extends Model> (this: Model.Type<T>): T;\n \n /** Fetch instance of this class optionally. */\n function get <T extends Model> (this: Model.Type<T>, required: false): T | undefined;\n\n /** Fetch instance of this class from context. */\n function get <T extends Model> (this: Model.Type<T>, requireValues: true): Required<T>\n \n function get <T extends Model, R> (this: Model.Type<T>, factory: GetFactory<T, Promise<R> | R>): NoVoid<R>;\n \n // TODO: eagerly metch this so any nulls are caught - would prevent updates.\n function get <T extends Model> (this: Model.Type<T>, factory: GetEffect<T>): null;\n }\n}\n\nModel.get = function <T extends Model, R> (\n this: Model.Type<T>,\n argument?: boolean | Model.GetFactory<T, unknown>\n){\n const context = Pragma.useContext();\n const render = Pragma.useFactory((refresh) => {\n const instance = context.get(this);\n\n if(!instance)\n if(argument === false)\n return () => undefined;\n else\n throw new Error(`Could not find ${this} in context.`);\n\n let ready: boolean | undefined;\n let value: any;\n\n const unwatch = createEffect(instance, current => {\n if(typeof argument === \"function\"){\n const next = argument.call(current, current, update);\n\n if(next === value)\n return;\n\n value = next;\n }\n else\n value = current;\n\n if(ready)\n refresh();\n }, argument === true);\n\n if(value instanceof Promise){\n let error: Error | undefined;\n\n unwatch();\n\n value.then(x => value = x, e => error = e).finally(refresh);\n value = null;\n\n return () => {\n if(error)\n throw error;\n\n return value === undefined ? null : value;\n }\n }\n\n if(value === null){\n unwatch();\n return () => null;\n };\n\n function update<T>(action?: Promise<T> | (() => Promise<T>)): any {\n if(typeof action == \"function\")\n action = action();\n\n refresh();\n\n if(action)\n return action.finally(refresh);\n }\n\n function didMount(){\n ready = true;\n return unwatch;\n }\n\n return () => {\n Pragma.useLifecycle(didMount);\n return value === undefined ? null : value;\n }\n });\n\n return render() as R;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA;AAAA;;;ACAA,IAAAC,cAAsB;;;ACAtB,iBAA+B;AAC/B,mBAAkG;AAElG,IAAM,aAAS,4BAAc,IAAI,mBAAQ,CAAC;AAS1C,mBAAQ,MAAM,CAAC,WAAqB;AAClC,QAAM,cAAU,yBAAW,MAAM;AAEjC,SAAO,aACL,sBAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC,CAAC,IAChC;AACJ;AA0DO,SAAS,eACd,SACA,UACA,UACA,MAA0B;AAE1B,MAAG,mBAAmB,WAAAC;AACpB,cAAU,mBAAQ,IAAI,OAAO;AAE/B,QAAM,cAAU,4BAAc,OAAO,UAAU;AAAA,IAC7C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ACjB,cAAQ;AACR,aAAO;AAAA,IACT;AAEA,WAAO,MAAM;AACX,6BAAO,aAAa,QAAQ;AAC5B,aAAO,UAAU,SAAY,OAAO;AAAA,IACtC;AAAA,EACF,CAAC;AAED,SAAO,OAAO;AAChB;;;AJnFA,IAAMC,UAAS,CAAC;","names":["Pragma","import_mvc","Model","import_mvc","import_mvc","import_adapter","Pragma"]}
1
+ {"version":3,"sources":["../src/adapter.ts","../src/state.as.ts","../src/context.ts","../src/state.use.ts","../src/state.get.ts"],"sourcesContent":["namespace Pragma {}\n\nconst Pragma = {} as {\n useState<S>(initial: () => S): [S, (next: (previous: S) => S) => void];\n useEffect(effect: () => () => void, deps?: any[]): void;\n createElement(type: any, props?: any, ...children: any[]): any;\n};\n\nexport { Pragma };\n\nimport './state.as';\nimport './state.use';\nimport './state.get';\n","import { Context, watch, METHOD, State } from '@expressive/mvc';\nimport { FunctionComponent, ReactNode } from 'react';\n\nimport { provide } from './context';\nimport { Pragma } from './adapter';\n\ndeclare module '@expressive/mvc' {\n namespace State {\n type HasProps<T extends State> = {\n [K in Exclude<keyof T, keyof State>]?: T[K];\n };\n\n type 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\n type 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 */\n type 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. */\n interface AsComponent extends State.Valid {\n render?(props: RenderProps<this>, self: this): React.ReactNode;\n fallback?: React.ReactNode;\n }\n\n interface FC<\n T extends State,\n P extends State.Assign<T>\n > extends FunctionComponent<P & State.Props<T>> {\n displayName?: string;\n State: State.Extends<T>;\n }\n\n function as<T extends State, P extends State.Assign<T>>(\n this: State.New<T>,\n render: (props: P, self: T) => ReactNode\n ): FC<T, P>;\n }\n}\n\nState.as = function <T extends State.AsComponent, P extends State.Assign<T>>(\n this: State.Class<T>,\n render: (props: P, self: T) => ReactNode\n): State.FC<T, P> {\n const FC = Render.bind(this as State.Class, { render } as {});\n\n return Object.assign(FC, {\n displayName: this.name,\n State: this\n });\n};\n\nexport function Render<T extends State.AsComponent>(\n this: State.Class<T>,\n props: State.Props<T>,\n props2?: State.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: State.Props<T>) {\n const render = METHOD.get(active.render) || props.render || active.render;\n\n return render\n ? render.call(active, props as State.HasProps<T>, active)\n : props.children;\n }\n\n return (props: State.RenderProps<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","import State, { Context } from '@expressive/mvc';\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/mvc' {\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.use(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","import { State, Context, watch } from '@expressive/mvc';\n\nimport { Pragma } from './adapter';\n\ndeclare module '@expressive/mvc' {\n namespace State {\n interface Valid {\n use?(...props: any[]): Promise<void> | void;\n }\n\n type UseArgs<T extends State> = T extends {\n use(...props: infer P): any;\n }\n ? P\n : State.Args<T>;\n\n function use<T extends State>(this: New<T>, ...args: UseArgs<T>): T;\n }\n}\n\nState.use = function <T extends State.Valid>(\n this: State.New<T>,\n ...args: any[]\n) {\n const ambient = Context.use();\n const state = Pragma.useState(() => {\n let ready: boolean | undefined;\n let active: T;\n\n const instance = this.new((x) =>\n x.use ? Promise.resolve(x.use(...args)) : args\n );\n const context = ambient.push(instance);\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 return (...args: State.Args<T>) => {\n Pragma.useEffect(didMount, []);\n\n if (ready) {\n ready = false;\n\n Promise.resolve(\n instance.use\n ? instance.use(...args)\n : Promise.all(\n args\n .flat()\n .map(\n (arg) =>\n typeof arg == 'object' &&\n instance.set(arg as State.Assign<T>)\n )\n )\n ).finally(() => {\n ready = true;\n });\n }\n\n return active;\n };\n });\n\n return state[0](...args);\n};\n","import { Context, watch, State } from '@expressive/mvc';\n\nimport { Pragma } from './adapter';\n\n/** Type may not be undefined - instead will be null. */\ntype NoVoid<T> = T extends undefined | void ? null : T;\n\ntype ForceRefresh = {\n /** Request a refresh for current component. */\n (): void;\n\n /**\n * Request a refresh and again after promise either resolves or rejects.\n *\n * @param waitFor Promise to wait for.\n * @returns Promise which resolves, after refresh, to same value as `waitFor`.\n */\n <T = void>(waitFor: Promise<T>): Promise<T>;\n\n /**\n * Request refresh before and after async function.\n * A refresh will occur both before and after the given function.\n *\n * **Note:** Any actions performed before first `await` will occur prior to refresh.\n *\n * @param invoke Async function to invoke.\n * @returns Promise which resolves returned value after refresh.\n */\n <T = void>(invoke: () => Promise<T>): Promise<T>;\n};\n\ndeclare module '@expressive/mvc' {\n namespace State {\n type GetFactory<T extends State, R> = (\n this: T,\n current: T,\n refresh: ForceRefresh\n ) => R;\n\n type GetEffect<T extends State> = (\n this: T,\n current: T,\n refresh: ForceRefresh\n ) => null;\n\n /** Fetch instance of this class from context. */\n function get<T extends State>(this: Extends<T>): T;\n\n /** Fetch instance of this class optionally. */\n function get<T extends State>(\n this: Extends<T>,\n required: false\n ): T | undefined;\n\n /** Fetch instance of this class from context. */\n function get<T extends State>(\n this: Extends<T>,\n requireValues: true\n ): Required<T>;\n\n function get<T extends State, R>(\n this: Extends<T>,\n factory: GetFactory<T, Promise<R> | R>\n ): NoVoid<R>;\n\n // TODO: eagerly match this so any nulls are caught - would prevent updates.\n function get<T extends State>(\n this: Extends<T>,\n factory: GetEffect<T>\n ): null;\n }\n}\n\nState.get = function <T extends State, R>(\n this: State.Extends<T>,\n argument?: boolean | State.GetFactory<T, unknown>\n) {\n const context = Context.use();\n const state = Pragma.useState(() => {\n const instance = context.get(this);\n\n if (!instance)\n if (argument === false) return () => undefined;\n else throw new Error(`Could not find ${this} in context.`);\n\n let ready: boolean | undefined;\n let value: any;\n\n function render() {\n state[1]((x) => x.bind(null));\n }\n\n function refresh<T>(action?: Promise<T> | (() => Promise<T>)): any {\n if (typeof action == 'function') action = action();\n\n render();\n\n if (action) return action.finally(render);\n }\n\n function onMount() {\n ready = true;\n return unwatch;\n }\n\n const unwatch = watch(\n instance,\n (current) => {\n if (typeof argument === 'function') {\n const next = argument.call(current, current, refresh);\n\n if (next === value) return;\n\n value = next;\n } else value = current;\n\n if (ready) render();\n },\n argument === true\n );\n\n if (value instanceof Promise) {\n let error: Error | undefined;\n\n unwatch();\n\n value\n .then(\n (x) => (value = x),\n (e) => (error = e)\n )\n .finally(render);\n\n value = null;\n\n return () => {\n if (error) throw error;\n\n return value === undefined ? null : value;\n };\n }\n\n if (value === null) {\n unwatch();\n return () => null;\n }\n\n return () => {\n Pragma.useEffect(onMount, []);\n return value === undefined ? null : value;\n };\n });\n\n return state[0]() as R;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA;AAAA;;;ACAA,IAAAC,cAA8C;;;ACA9C,iBAA+B;AAC/B,mBAQO;AAEA,IAAM,aAAS,4BAAc,IAAI,mBAAQ,CAAC;AASjD,mBAAQ,MAAM,CAAC,WAAqB;AAClC,QAAM,cAAU,yBAAW,MAAM;AAEjC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