@expressive/mvc 0.7.1 → 0.7.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.js CHANGED
@@ -930,12 +930,15 @@ function createProxy(emit, watch) {
930
930
  assign(proxy, {
931
931
  from,
932
932
  delete(key) {
933
+ // TODO: this commit's fix needs tests.
934
+ // Was not cause by coverage.
935
+ const out = from.delete(key);
933
936
  emit(key);
934
- return from.delete(key);
937
+ return out;
935
938
  },
936
939
  clear() {
937
- emit(ANY);
938
940
  from.clear();
941
+ emit(ANY);
939
942
  },
940
943
  has(key) {
941
944
  watch(this, key);
@@ -1115,26 +1118,10 @@ class Lookup {
1115
1118
  get(T) {
1116
1119
  return this[this.key(T)];
1117
1120
  }
1118
- push(I) {
1119
- const next = create(this);
1120
- if (I instanceof Model || typeof I == "function")
1121
- next.register(I);
1122
- else
1123
- for (const i of values(I))
1124
- next.register(i);
1125
- return next;
1121
+ push() {
1122
+ return create(this);
1126
1123
  }
1127
- register(I) {
1128
- let writable = true;
1129
- let T;
1130
- if (I instanceof Model) {
1131
- T = I.constructor;
1132
- writable = false;
1133
- }
1134
- else {
1135
- T = I;
1136
- I = I.create();
1137
- }
1124
+ inject(T, I, writable) {
1138
1125
  do {
1139
1126
  const key = this.key(T);
1140
1127
  const conflict = this.hasOwnProperty(key);
@@ -1145,7 +1132,6 @@ class Lookup {
1145
1132
  });
1146
1133
  T = getPrototypeOf(T);
1147
1134
  } while (T !== Model);
1148
- return I;
1149
1135
  }
1150
1136
  pop() {
1151
1137
  for (const key of getOwnPropertySymbols(this)) {
@@ -1428,7 +1414,28 @@ const Oops$1 = issues({
1428
1414
  function Provider(props) {
1429
1415
  if ("of" in props)
1430
1416
  throw Oops$1.PropDeprecated();
1431
- const context = useNewContext(props.for);
1417
+ const from = useLookup();
1418
+ const context = React__default["default"].useMemo(() => {
1419
+ const I = props.for;
1420
+ if (!I)
1421
+ throw Oops$1.NoType();
1422
+ const layer = from.push();
1423
+ function register(I) {
1424
+ if (I instanceof Model)
1425
+ layer.inject(I.constructor, I, false);
1426
+ else
1427
+ layer.inject(I, I.create(), true);
1428
+ }
1429
+ if (I instanceof Model || typeof I == "function")
1430
+ register(I);
1431
+ else
1432
+ values(I).forEach(register);
1433
+ for (const instance of layer.local)
1434
+ if (instance)
1435
+ for (const apply of getPending(instance))
1436
+ apply(layer);
1437
+ return layer;
1438
+ }, []);
1432
1439
  const render = props.children;
1433
1440
  useAppliedProps(context, props);
1434
1441
  React__default["default"].useLayoutEffect(() => () => context.pop(), []);
@@ -1436,19 +1443,6 @@ function Provider(props) {
1436
1443
  ? React__default["default"].createElement(RenderFunction, { context, render })
1437
1444
  : render);
1438
1445
  }
1439
- function useNewContext(inject) {
1440
- const from = useLookup();
1441
- return React__default["default"].useMemo(() => {
1442
- if (!inject)
1443
- throw Oops$1.NoType();
1444
- const context = from.push(inject);
1445
- for (const instance of context.local)
1446
- if (instance)
1447
- for (const apply of getPending(instance))
1448
- apply(context);
1449
- return context;
1450
- }, []);
1451
- }
1452
1446
  function useAppliedProps(within, props) {
1453
1447
  const update = React__default["default"].useMemo(() => {
1454
1448
  const targets = within.local;