@voltro/testing 0.85.0 → 0.86.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.
@@ -1,11 +1,11 @@
1
1
  # Third-Party Notices — @voltro/testing
2
2
 
3
- This package depends on the open-source software listed below. Each is the
3
+ This package uses the open-source software listed below. Each is the
4
4
  property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/testing itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (42 packages).
8
+ Generated from the resolved runtime dependency closure (41 packages).
9
9
 
10
10
  ---
11
11
 
@@ -3636,34 +3636,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3636
3636
  SOFTWARE.
3637
3637
  ```
3638
3638
 
3639
- ## layerr@3.0.0
3640
-
3641
- License: MIT
3642
-
3643
- ```
3644
- MIT License
3645
-
3646
- Copyright (c) 2020 Perry Mitchell
3647
-
3648
- Permission is hereby granted, free of charge, to any person obtaining a copy
3649
- of this software and associated documentation files (the "Software"), to deal
3650
- in the Software without restriction, including without limitation the rights
3651
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3652
- copies of the Software, and to permit persons to whom the Software is
3653
- furnished to do so, subject to the following conditions:
3654
-
3655
- The above copyright notice and this permission notice shall be included in all
3656
- copies or substantial portions of the Software.
3657
-
3658
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3659
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3660
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3661
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3662
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3663
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3664
- SOFTWARE.
3665
- ```
3666
-
3667
3639
  ## lib0@0.2.117
3668
3640
 
3669
3641
  License: MIT
@@ -4013,14 +3985,14 @@ Apache License
4013
3985
  limitations under the License.
4014
3986
  ```
4015
3987
 
4016
- ## ulidx@2.4.1
3988
+ ## ulid@3.0.2
4017
3989
 
4018
3990
  License: MIT
4019
3991
 
4020
3992
  ```
4021
- MIT License
3993
+ The MIT License (MIT)
4022
3994
 
4023
- Copyright (c) 2021 Perry Mitchell
3995
+ Copyright (c) 2017 Alizain Feerasta
4024
3996
 
4025
3997
  Permission is hereby granted, free of charge, to any person obtaining a copy
4026
3998
  of this software and associated documentation files (the "Software"), to deal
package/dist/client.js CHANGED
@@ -1,85 +1,47 @@
1
- import { Effect as e } from "effect";
2
- import { act as t, createElement as n } from "react";
3
- import { FrameworkRuntimesContext as r, RpcErrorBus as i, useFormBinding as a } from "@voltro/client";
4
- //#region src/formBindingHarness.tsx
5
- var o = async (e, r = {}) => {
6
- if (globalThis.document === void 0) throw Error("renderFormBinding needs a DOM to render hooks — add `// @vitest-environment jsdom` to the spec.");
7
- let { createRoot: i } = await import("react-dom/client"), o = r.apiName ?? "app", s = c({
8
- apiName: o,
9
- ...r.client ?? {},
10
- mutations: {
11
- [e]: r.mutation ?? (() => ({ ok: !0 })),
12
- ...r.client?.mutations ?? {}
13
- }
14
- }), l, u = () => (l = a(o, e, r.binding ?? {}), null), d = i(globalThis.document.createElement("div"));
15
- return await t(async () => {
16
- d.render(n(s.Provider, null, n(u)));
17
- }), {
18
- binding: () => l,
19
- fill: (e, n) => {
20
- t(() => {
21
- l.field(e).setValue(n);
22
- });
23
- },
24
- blur: (e) => {
25
- t(() => {
26
- l.field(e).onBlur();
27
- });
28
- },
29
- submit: async () => {
30
- let e;
31
- return await t(async () => {
32
- e = await l.submit();
33
- }), e;
34
- },
35
- errors: () => l.errors,
36
- state: () => l.state,
37
- client: s,
38
- unmount: () => {
39
- t(() => {
40
- d.unmount();
41
- });
42
- }
43
- };
44
- }, s = {
45
- runPromise: e.runPromise,
46
- runPromiseExit: e.runPromiseExit,
47
- runFork: e.runFork,
48
- dispose: () => e.void
49
- }, c = (t = {}) => {
50
- let a = t.apiName ?? "app", o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = [];
51
- for (let [e, n] of Object.entries(t.subscriptions ?? {})) o.set(e, {
1
+ import { renderFormBinding as e } from "./formBindingHarness.js";
2
+ import { Effect as t } from "effect";
3
+ import { createElement as n } from "react";
4
+ import { FrameworkRuntimesContext as r, INITIAL_RECOVERY_SNAPSHOT as i, RpcErrorBus as a } from "@voltro/client";
5
+ //#region src/client.tsx
6
+ var o = {
7
+ runPromise: t.runPromise,
8
+ runPromiseExit: t.runPromiseExit,
9
+ runFork: t.runFork,
10
+ dispose: () => t.void
11
+ }, s = (e = {}) => {
12
+ let s = e.apiName ?? "app", c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = [];
13
+ for (let [t, n] of Object.entries(e.subscriptions ?? {})) c.set(t, {
52
14
  data: n,
53
15
  error: void 0,
54
16
  revision: 0,
55
17
  pendingPatches: 0,
56
18
  emittedAt: void 0
57
19
  });
58
- let d = (e) => o.get(e) ?? {
20
+ let f = (e) => c.get(e) ?? {
59
21
  data: void 0,
60
22
  error: void 0,
61
23
  revision: -1,
62
24
  pendingPatches: 0,
63
25
  emittedAt: void 0
64
- }, f = (e) => {
65
- l.delete(e);
66
- for (let t of c.get(e) ?? []) t();
67
- }, p = (e) => String(e[0] ?? ""), m = {
26
+ }, p = (e) => {
27
+ u.delete(e);
28
+ for (let t of l.get(e) ?? []) t();
29
+ }, m = (e) => String(e[0] ?? ""), h = {
68
30
  peek: (e) => {
69
- let t = p(e), n = l.get(t);
31
+ let t = m(e), n = u.get(t);
70
32
  if (n) return n;
71
- let r = d(t), i = {
33
+ let r = f(t), i = {
72
34
  data: r.data,
73
35
  revision: r.revision,
74
36
  emittedAt: r.emittedAt,
75
37
  error: r.error,
76
38
  pendingPatches: r.pendingPatches
77
39
  };
78
- return l.set(t, i), i;
40
+ return u.set(t, i), i;
79
41
  },
80
42
  subscribe: (e, t, n, r) => {
81
- let i = p(e), a = c.get(i) ?? /* @__PURE__ */ new Set();
82
- return a.add(r), c.set(i, a), { unsubscribe: () => {
43
+ let i = m(e), a = l.get(i) ?? /* @__PURE__ */ new Set();
44
+ return a.add(r), l.set(i, a), { unsubscribe: () => {
83
45
  a.delete(r);
84
46
  } };
85
47
  },
@@ -92,9 +54,9 @@ var o = async (e, r = {}) => {
92
54
  update: () => {},
93
55
  forTag: () => ({ patchedCount: 0 }),
94
56
  refreshAll: () => {
95
- h += 1;
57
+ g += 1;
96
58
  }
97
- }, h = 0, g = {
59
+ }, g = 0, _ = {
98
60
  rawTransport: "connected",
99
61
  status: "connected",
100
62
  failureCount: 0,
@@ -102,83 +64,96 @@ var o = async (e, r = {}) => {
102
64
  failedSubscriptions: [],
103
65
  pendingMutationReplays: 0,
104
66
  mutationReplay: "unknown"
105
- }, _ = /* @__PURE__ */ new Set(), v = {
106
- subscribe: (e) => (_.add(e), () => {
107
- _.delete(e);
67
+ }, v = /* @__PURE__ */ new Set(), y = new a(), b = !0, x = {
68
+ subscribe: (e) => (v.add(e), () => {
69
+ v.delete(e);
108
70
  }),
109
- getSnapshot: () => g,
71
+ getSnapshot: () => _,
72
+ getServerSnapshot: () => i,
73
+ getPreloadSeedPermission: () => b,
74
+ invalidatePreloadSeeds: () => {
75
+ if (b) {
76
+ b = !1;
77
+ for (let e of v) e();
78
+ }
79
+ },
80
+ onVisibleError: (e) => y.on(e),
81
+ waitForProtocolReady: async (e, t) => !t?.aborted && _.rawTransport === "connected",
82
+ reserveMutationReplay: () => void 0,
83
+ waitForMutationReplaySupport: async () => !1,
84
+ replayWindowRemaining: () => 0,
110
85
  reportExternalSuccess: () => {},
111
86
  subjectSignal: new AbortController().signal
112
- }, y = {}, b = (t, n, r) => {
113
- let i = t.split("."), a = y;
87
+ }, S = {}, C = (e, n, r) => {
88
+ let i = e.split("."), a = S;
114
89
  for (let e of i.slice(0, -1)) a[e] = a[e] ?? {}, a = a[e];
115
- a[i[i.length - 1]] = (i) => e.tryPromise({
116
- try: async () => (u.push({
90
+ a[i[i.length - 1]] = (i) => t.tryPromise({
91
+ try: async () => (d.push({
117
92
  kind: n,
118
- tag: t,
93
+ tag: e,
119
94
  input: i
120
95
  }), await r(i)),
121
96
  catch: (e) => e
122
97
  });
123
98
  };
124
- for (let [e, n] of Object.entries(t.mutations ?? {})) b(e, "mutation", n);
125
- for (let [e, n] of Object.entries(t.actions ?? {})) b(e, "action", n);
126
- let x = {
127
- runtime: s,
128
- cache: m,
129
- recovery: v,
130
- client: y,
99
+ for (let [t, n] of Object.entries(e.mutations ?? {})) C(t, "mutation", n);
100
+ for (let [t, n] of Object.entries(e.actions ?? {})) C(t, "action", n);
101
+ let w = {
102
+ runtime: o,
103
+ cache: h,
104
+ recovery: x,
105
+ client: S,
131
106
  descriptors: {},
132
107
  inspectBaseUrl: "http://test.local",
133
- errorBus: new i()
134
- }, S = {
108
+ errorBus: y
109
+ }, T = {
135
110
  get: (e) => {
136
- if (e !== a) throw Error(`makeVoltroTestClient: component asked for api '${e}' but the harness was built for '${a}'. Pass { apiName: '${e}' }.`);
137
- return x;
111
+ if (e !== s) throw Error(`makeVoltroTestClient: component asked for api '${e}' but the harness was built for '${s}'. Pass { apiName: '${e}' }.`);
112
+ return w;
138
113
  },
139
- names: [a]
114
+ names: [s]
140
115
  };
141
116
  return {
142
- Provider: ({ children: e }) => n(r.Provider, { value: S }, e),
117
+ Provider: ({ children: e }) => n(r.Provider, { value: T }, e),
143
118
  setSubscription: (e, t, n) => {
144
- let r = d(e);
145
- o.set(e, {
119
+ let r = f(e);
120
+ c.set(e, {
146
121
  data: t,
147
122
  error: void 0,
148
123
  revision: r.revision + 1,
149
124
  pendingPatches: n?.pendingPatches ?? 0,
150
125
  emittedAt: n?.emittedAt
151
- }), f(e);
126
+ }), p(e);
152
127
  },
153
128
  failSubscription: (e, t) => {
154
- o.set(e, {
129
+ c.set(e, {
155
130
  data: void 0,
156
131
  error: t,
157
132
  revision: -1,
158
133
  pendingPatches: 0,
159
134
  emittedAt: void 0
160
- }), f(e);
135
+ }), p(e);
161
136
  },
162
137
  resetSubscription: (e) => {
163
- o.delete(e), f(e);
138
+ c.delete(e), p(e);
164
139
  },
165
- calls: u,
140
+ calls: d,
166
141
  setConnectionStatus: (e, t) => {
167
- g = {
168
- ...g,
142
+ _ = {
143
+ ..._,
169
144
  ...t,
170
145
  status: e,
171
146
  rawTransport: t?.rawTransport ?? (e === "connected" ? "connected" : "disconnected")
172
147
  };
173
- for (let e of _) e();
148
+ for (let e of v) e();
174
149
  },
175
150
  get refreshes() {
176
- return h;
151
+ return g;
177
152
  },
178
153
  emitRpcError: (e) => {
179
- x.errorBus.emit(e);
154
+ w.errorBus.emit(e);
180
155
  }
181
156
  };
182
157
  };
183
158
  //#endregion
184
- export { s as FAKE_RUNTIME, c as makeVoltroTestClient, o as renderFormBinding };
159
+ export { o as FAKE_RUNTIME, s as makeVoltroTestClient, e as renderFormBinding };