@magicdoor/magic-use-case-solid 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @magicdoor/magic-use-case-solid
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Close a use case's mutation window on the scope it opened, rather than on
8
+ whichever scope is current when it finishes.
9
+
10
+ A run can outlive the scope it started in — a detached one, or one still in
11
+ flight when a request ends. Resolving the scope again at closing time made that
12
+ run decrement a scope it never belonged to, shutting a window another run was
13
+ depending on: the second run's next write to application state failed with
14
+ "Cannot set property … outside a use case" even though it was squarely inside
15
+ `runLogic`. On a server it was worse than a wrong count, since resolving a scope
16
+ with no request in progress throws, and it threw from inside a `finally`.
17
+
3
18
  ## 0.1.0
4
19
 
5
20
  ### Minor Changes
package/dist/index.js CHANGED
@@ -120,21 +120,22 @@ function onNavigation(handler) {
120
120
  return () => emitter.unregisterFromNavigation(wrapper);
121
121
  }
122
122
  function openMutationWindow() {
123
- currentScope().openMutationWindows += 1;
124
- }
125
- function closeMutationWindow() {
126
123
  const scope = currentScope();
124
+ scope.openMutationWindows += 1;
125
+ return scope;
126
+ }
127
+ function closeMutationWindow(scope) {
127
128
  scope.openMutationWindows = Math.max(0, scope.openMutationWindows - 1);
128
129
  }
129
130
  function isMutationWindowOpen() {
130
131
  return currentScope().openMutationWindows > 0;
131
132
  }
132
133
  async function withMutationWindow(run) {
133
- openMutationWindow();
134
+ const scope = openMutationWindow();
134
135
  try {
135
136
  return await run();
136
137
  } finally {
137
- closeMutationWindow();
138
+ closeMutationWindow(scope);
138
139
  }
139
140
  }
140
141
  function assertMutationWindowOpen(operation) {
package/dist/server.js CHANGED
@@ -120,21 +120,22 @@ function onNavigation(handler) {
120
120
  return () => emitter.unregisterFromNavigation(wrapper);
121
121
  }
122
122
  function openMutationWindow() {
123
- currentScope().openMutationWindows += 1;
124
- }
125
- function closeMutationWindow() {
126
123
  const scope = currentScope();
124
+ scope.openMutationWindows += 1;
125
+ return scope;
126
+ }
127
+ function closeMutationWindow(scope) {
127
128
  scope.openMutationWindows = Math.max(0, scope.openMutationWindows - 1);
128
129
  }
129
130
  function isMutationWindowOpen() {
130
131
  return currentScope().openMutationWindows > 0;
131
132
  }
132
133
  async function withMutationWindow(run) {
133
- openMutationWindow();
134
+ const scope = openMutationWindow();
134
135
  try {
135
136
  return await run();
136
137
  } finally {
137
- closeMutationWindow();
138
+ closeMutationWindow(scope);
138
139
  }
139
140
  }
140
141
  function assertMutationWindowOpen(operation) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@magicdoor/magic-use-case-solid",
3
- "version": "0.1.0",
4
- "description": "SolidJS bindings for magic-use-case \u2014 clean-architecture use cases and presenters for front-end TypeScript.",
3
+ "version": "0.1.1",
4
+ "description": "SolidJS bindings for magic-use-case clean-architecture use cases and presenters for front-end TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",