@expressive/mvc 0.8.1 → 0.8.2

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/lib/index.esm.js CHANGED
@@ -17,7 +17,7 @@ function issues(register) {
17
17
  return Library;
18
18
  }
19
19
 
20
- const Oops$c = issues({
20
+ const Oops$d = issues({
21
21
  BadCallback: () => `Callback for effect-callback may only return a function.`
22
22
  });
23
23
  const { assign, create, defineProperty, entries, getPrototypeOf, getOwnPropertyNames, getOwnPropertyDescriptor, getOwnPropertySymbols, values } = Object;
@@ -30,7 +30,7 @@ function createEffect(callback) {
30
30
  if (unSet instanceof Promise)
31
31
  unSet = undefined;
32
32
  if (unSet && typeof unSet !== "function")
33
- throw Oops$c.BadCallback();
33
+ throw Oops$d.BadCallback();
34
34
  };
35
35
  }
36
36
  function createValueEffect(callback) {
@@ -46,15 +46,15 @@ function createValueEffect(callback) {
46
46
  if (typeof out == "function")
47
47
  unSet = out;
48
48
  else
49
- throw Oops$c.BadCallback();
49
+ throw Oops$d.BadCallback();
50
50
  };
51
51
  }
52
52
 
53
- const Oops$b = issues({
53
+ const Oops$c = issues({
54
54
  NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`,
55
55
  });
56
56
  function suspend(source, key) {
57
- const error = Oops$b.NotReady(source.subject, key);
57
+ const error = Oops$c.NotReady(source.subject, key);
58
58
  const promise = new Promise(resolve => {
59
59
  const release = source.addListener(forKey => {
60
60
  if (forKey == key)
@@ -94,7 +94,7 @@ function mayRetry(fn) {
94
94
  return compute();
95
95
  }
96
96
 
97
- const Oops$a = issues({
97
+ const Oops$b = issues({
98
98
  Failed: (parent, property, initial) => `An exception was thrown while ${initial ? "initializing" : "refreshing"} [${parent}.${property}].`
99
99
  });
100
100
  const INFO = new WeakMap();
@@ -111,7 +111,7 @@ function computeMode(self, source, setter, key, required) {
111
111
  return setter.call(sub.proxy, sub.proxy);
112
112
  }
113
113
  catch (err) {
114
- Oops$a.Failed(subject, key, initial).warn();
114
+ Oops$b.Failed(subject, key, initial).warn();
115
115
  throw err;
116
116
  }
117
117
  };
@@ -253,6 +253,7 @@ class Subscriber {
253
253
  }
254
254
 
255
255
  const REGISTER = new WeakMap();
256
+ const PENDING = new Map();
256
257
  class Control {
257
258
  constructor(subject) {
258
259
  this.subject = subject;
@@ -370,7 +371,6 @@ class Control {
370
371
  }
371
372
  }
372
373
 
373
- const PENDING = new Map();
374
374
  /**
375
375
  * Run instruction as controller sets itself up.
376
376
  * This will specialize the behavior of a given property.
@@ -481,7 +481,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
481
481
  });
482
482
  }
483
483
 
484
- const Oops$9 = issues({
484
+ const Oops$a = issues({
485
485
  DuplicatePending: (key) => `Invoked action ${key} but one is already active.`
486
486
  });
487
487
  function act(task) {
@@ -489,7 +489,7 @@ function act(task) {
489
489
  let pending = false;
490
490
  const invoke = (...args) => __awaiter(this, void 0, void 0, function* () {
491
491
  if (pending)
492
- return Promise.reject(Oops$9.DuplicatePending(key));
492
+ return Promise.reject(Oops$a.DuplicatePending(key));
493
493
  pending = true;
494
494
  this.update(key);
495
495
  try {
@@ -511,6 +511,9 @@ function act(task) {
511
511
  });
512
512
  }
513
513
 
514
+ const Oops$9 = issues({
515
+ NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`
516
+ });
514
517
  function factoryMode(self, output, key, required) {
515
518
  const { subject, state } = self;
516
519
  let pending;
@@ -532,7 +535,7 @@ function factoryMode(self, output, key, required) {
532
535
  const suspend = () => {
533
536
  if (required === false)
534
537
  return undefined;
535
- const issue = Oops$8.NotReady(subject, key);
538
+ const issue = Oops$9.NotReady(subject, key);
536
539
  assign(pending, {
537
540
  message: issue.message,
538
541
  stack: issue.stack
@@ -550,12 +553,8 @@ function factoryMode(self, output, key, required) {
550
553
  }
551
554
 
552
555
  const Oops$8 = issues({
553
- // BadSource: (model, property, got) =>
554
- // `Bad from-instruction provided to ${model}.${property}. Expects an arrow-function or a Model as source. Got ${got}.`,
555
556
  PeerNotAllowed: (model, property) => `Attempted to use an instruction result (probably use or tap) as computed source for ${model}.${property}. This is not possible.`,
556
557
  ComputeFailed: (model, key) => `Generating initial value for ${model}.${key} failed.`,
557
- NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`,
558
- FactoryFailed: (model, key) => `Generating initial value for ${model}.${key} failed.`,
559
558
  Failed: (parent, property, initial) => `An exception was thrown while ${initial ? "initializing" : "refreshing"} [${parent}.${property}].`
560
559
  });
561
560
  function get(arg0, arg1, arg2) {
@@ -1289,10 +1288,10 @@ function useTap(source, arg1, arg2) {
1289
1288
  const instance = useMemo(() => {
1290
1289
  if (typeof source == "object")
1291
1290
  return () => source;
1292
- if (MVC.isTypeof(source))
1293
- return () => source.get(true);
1294
1291
  if (Model.isTypeof(source))
1295
- return () => useContext(source);
1292
+ return "get" in source
1293
+ ? () => source.get(true)
1294
+ : () => useContext(source);
1296
1295
  return source;
1297
1296
  }, [])();
1298
1297
  if (typeof arg1 == "function")