@dynamic-labs-sdk/client 0.0.1-alpha.2 → 0.0.1-alpha.4
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 +16 -0
- package/core.cjs.js +9 -5
- package/core.esm.js +2 -2
- package/getClient.cjs.js +226 -0
- package/getClient.esm.js +210 -0
- package/index.cjs.js +38 -152
- package/index.esm.js +11 -128
- package/package.json +1 -1
- package/src/client/core/createCore/{initialState.d.ts → getInitialState.d.ts} +2 -2
- package/src/client/core/createCore/getInitialState.d.ts.map +1 -0
- package/src/exports/core.d.ts +4 -0
- package/src/exports/core.d.ts.map +1 -1
- package/src/exports/index.d.ts +5 -0
- package/src/exports/index.d.ts.map +1 -1
- package/src/modules/auth/logout/{types.d.ts → events.d.ts} +1 -1
- package/src/modules/auth/logout/events.d.ts.map +1 -0
- package/src/modules/auth/logout/index.d.ts +0 -1
- package/src/modules/auth/logout/index.d.ts.map +1 -1
- package/src/utils/getClient/errors/ClientNotPresentError.d.ts.map +1 -0
- package/events.cjs.js +0 -101
- package/events.esm.js +0 -93
- package/src/client/core/createCore/initialState.d.ts.map +0 -1
- package/src/modules/auth/logout/types.d.ts.map +0 -1
- package/src/utils/getClient/erros/ClientNotPresentError.d.ts.map +0 -1
- /package/src/utils/getClient/{erros → errors}/ClientNotPresentError.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 0.0.1-alpha.4 (2025-05-28)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- allow manual init of client ([#88](https://github.com/dynamic-labs/dynamic-sdk/pull/88))
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- client core accidentally sharing state among different instances ([#89](https://github.com/dynamic-labs/dynamic-sdk/pull/89))
|
|
10
|
+
|
|
11
|
+
## 0.0.1-alpha.3 (2025-05-27)
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- properly export state changed events ([#85](https://github.com/dynamic-labs/dynamic-sdk/pull/85))
|
|
16
|
+
|
|
1
17
|
## 0.0.1-alpha.2 (2025-05-26)
|
|
2
18
|
|
|
3
19
|
### 🚀 Features
|
package/core.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var getClient = require('./getClient.cjs.js');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Registers an extension to the client.
|
|
@@ -12,11 +12,15 @@ var events = require('./events.cjs.js');
|
|
|
12
12
|
* @param extensionKey - The key of the extension to register.
|
|
13
13
|
* @returns The client instance.
|
|
14
14
|
*/ const registerExtension = (client, extensionKey)=>{
|
|
15
|
-
const core =
|
|
15
|
+
const core = getClient.getCore(client);
|
|
16
16
|
core.extensions.add(extensionKey);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
19
|
+
exports.CannotTrackError = getClient.CannotTrackError;
|
|
20
|
+
exports.ClientNotPresentError = getClient.ClientNotPresentError;
|
|
21
|
+
exports.InvalidStorageSet = getClient.InvalidStorageSet;
|
|
22
|
+
exports.emitEvent = getClient.emitEvent;
|
|
23
|
+
exports.getClient = getClient.getClient;
|
|
24
|
+
exports.getCore = getClient.getCore;
|
|
25
|
+
exports.subscribeWithSelector = getClient.subscribeWithSelector;
|
|
22
26
|
exports.registerExtension = registerExtension;
|
package/core.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getCore } from './
|
|
2
|
-
export { e as emitEvent, s as subscribeWithSelector } from './
|
|
1
|
+
import { g as getCore } from './getClient.esm.js';
|
|
2
|
+
export { C as CannotTrackError, f as ClientNotPresentError, I as InvalidStorageSet, e as emitEvent, a as getClient, s as subscribeWithSelector } from './getClient.esm.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Registers an extension to the client.
|
package/getClient.cjs.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getCore = (client)=>{
|
|
4
|
+
// @ts-expect-error - this was hidden from the public API
|
|
5
|
+
return client.__core;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shallow compare two objects.
|
|
10
|
+
*
|
|
11
|
+
* Source: https://github.com/pmndrs/zustand/blob/main/src/vanilla/shallow.ts
|
|
12
|
+
*/ const isEqualShallow = (objA, objB)=>{
|
|
13
|
+
if (Object.is(objA, objB)) return true;
|
|
14
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
15
|
+
return objA === objB;
|
|
16
|
+
}
|
|
17
|
+
if (objA instanceof Map && objB instanceof Map) {
|
|
18
|
+
if (objA.size !== objB.size) return false;
|
|
19
|
+
for (const [key, value] of objA){
|
|
20
|
+
if (!Object.is(value, objB.get(key))) return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (objA instanceof Set && objB instanceof Set) {
|
|
25
|
+
if (objA.size !== objB.size) return false;
|
|
26
|
+
for (const value of objA){
|
|
27
|
+
if (!objB.has(value)) return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const keysA = Object.keys(objA);
|
|
32
|
+
if (keysA.length !== Object.keys(objB).length) return false;
|
|
33
|
+
for (const keyA of keysA){
|
|
34
|
+
if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (objA.constructor !== objB.constructor) return false;
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Allows subscribing to a slice of the state.
|
|
44
|
+
* The slice is a computation of the states.
|
|
45
|
+
*
|
|
46
|
+
* The callback will only be called when the slice has changed.
|
|
47
|
+
* Change is determined by shallow comparison.
|
|
48
|
+
*
|
|
49
|
+
* Returns a function to unsubscribe the callback.
|
|
50
|
+
*/ const subscribeWithSelector = (observable, selector)=>(callback)=>{
|
|
51
|
+
let lastSlice = selector(observable.get());
|
|
52
|
+
return observable.subscribe((value)=>{
|
|
53
|
+
const nextSlice = selector(value);
|
|
54
|
+
if (isEqualShallow(nextSlice, lastSlice)) return;
|
|
55
|
+
lastSlice = nextSlice;
|
|
56
|
+
callback(nextSlice);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
function _extends() {
|
|
61
|
+
_extends = Object.assign || function assign(target) {
|
|
62
|
+
for(var i = 1; i < arguments.length; i++){
|
|
63
|
+
var source = arguments[i];
|
|
64
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
65
|
+
}
|
|
66
|
+
return target;
|
|
67
|
+
};
|
|
68
|
+
return _extends.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var version = "0.0.1-alpha.4";
|
|
72
|
+
var dependencies = {
|
|
73
|
+
"@dynamic-labs/sdk-api-core": "0.0.630"};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Listen to an event from the client.
|
|
77
|
+
*
|
|
78
|
+
* @returns A function that can be called to remove the listener.
|
|
79
|
+
*/ const onEvent = (client, event, listener)=>{
|
|
80
|
+
const { eventEmitter } = getCore(client);
|
|
81
|
+
eventEmitter.on(event, listener);
|
|
82
|
+
return ()=>{
|
|
83
|
+
eventEmitter.off(event, listener);
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Remove a listener from an event.
|
|
88
|
+
*/ const offEvent = (client, event, listener)=>{
|
|
89
|
+
const { eventEmitter } = getCore(client);
|
|
90
|
+
eventEmitter.off(event, listener);
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Listen to an event that will only fire once.
|
|
94
|
+
*
|
|
95
|
+
* @returns A function that can be called to remove the listener.
|
|
96
|
+
*/ const onceEvent = (client, event, listener)=>{
|
|
97
|
+
const { eventEmitter } = getCore(client);
|
|
98
|
+
eventEmitter.once(event, listener);
|
|
99
|
+
return ()=>{
|
|
100
|
+
eventEmitter.off(event, listener);
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Emit an event.
|
|
105
|
+
*/ const emitEvent = (client, event, ...args)=>{
|
|
106
|
+
const { eventEmitter } = getCore(client);
|
|
107
|
+
eventEmitter.emit(event, ...args);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getDetails = ({ details, cause })=>{
|
|
111
|
+
if (cause instanceof BaseError) {
|
|
112
|
+
return cause.details;
|
|
113
|
+
}
|
|
114
|
+
if (cause == null ? void 0 : cause.message) {
|
|
115
|
+
return cause.message;
|
|
116
|
+
}
|
|
117
|
+
return details;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Formats the error message with all available information
|
|
121
|
+
*/ const formatMessage = ({ shortMessage, details, docsUrl, metaMessages })=>{
|
|
122
|
+
return [
|
|
123
|
+
shortMessage,
|
|
124
|
+
'',
|
|
125
|
+
...metaMessages ? [
|
|
126
|
+
...metaMessages,
|
|
127
|
+
''
|
|
128
|
+
] : [],
|
|
129
|
+
...docsUrl ? [
|
|
130
|
+
`Docs: ${docsUrl}`
|
|
131
|
+
] : [],
|
|
132
|
+
...details ? [
|
|
133
|
+
`Details: ${details}`
|
|
134
|
+
] : [],
|
|
135
|
+
`Version: ${version}`,
|
|
136
|
+
`Timestamp: ${new Date().toISOString()}`
|
|
137
|
+
].join('\n');
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Base error class that provides structured error handling with detailed information
|
|
141
|
+
*/ class BaseError extends Error {
|
|
142
|
+
/**
|
|
143
|
+
* Walks the cause chain of the error and returns the root error
|
|
144
|
+
*/ walk() {
|
|
145
|
+
const cause = this.cause;
|
|
146
|
+
if (cause instanceof BaseError) {
|
|
147
|
+
return cause.walk();
|
|
148
|
+
}
|
|
149
|
+
return cause;
|
|
150
|
+
}
|
|
151
|
+
constructor(args){
|
|
152
|
+
const details = getDetails(args);
|
|
153
|
+
super(formatMessage(_extends({}, args, {
|
|
154
|
+
details
|
|
155
|
+
})), args.cause ? {
|
|
156
|
+
cause: args.cause
|
|
157
|
+
} : undefined);
|
|
158
|
+
this.name = 'BaseError';
|
|
159
|
+
this.details = details;
|
|
160
|
+
var _args_name;
|
|
161
|
+
this.name = (_args_name = args.name) != null ? _args_name : this.name;
|
|
162
|
+
var _args_cause;
|
|
163
|
+
this.cause = (_args_cause = args.cause) != null ? _args_cause : this.cause;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
class CannotTrackError extends BaseError {
|
|
168
|
+
constructor(){
|
|
169
|
+
super({
|
|
170
|
+
cause: null,
|
|
171
|
+
docsUrl: null,
|
|
172
|
+
name: 'CannotTrackError',
|
|
173
|
+
shortMessage: 'All track calls must be performed in the same node tick'
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
class InvalidStorageSet extends BaseError {
|
|
179
|
+
constructor({ key, value }){
|
|
180
|
+
super({
|
|
181
|
+
cause: null,
|
|
182
|
+
docsUrl: null,
|
|
183
|
+
metaMessages: [
|
|
184
|
+
`key: ${key}`,
|
|
185
|
+
value
|
|
186
|
+
],
|
|
187
|
+
name: 'InvalidStorageSet',
|
|
188
|
+
shortMessage: 'Tried to store a value that does not match the schema'
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
class ClientNotPresentError extends BaseError {
|
|
194
|
+
constructor(){
|
|
195
|
+
super({
|
|
196
|
+
cause: null,
|
|
197
|
+
docsUrl: null,
|
|
198
|
+
name: 'ClientNotPresentError',
|
|
199
|
+
shortMessage: 'The client is not present in the target object.'
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const getClient = (target)=>{
|
|
205
|
+
if (!Object.prototype.hasOwnProperty.call(target, '__client')) {
|
|
206
|
+
throw new ClientNotPresentError();
|
|
207
|
+
}
|
|
208
|
+
// @ts-expect-error - this was hidden from the public API
|
|
209
|
+
return target.__client;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
exports.BaseError = BaseError;
|
|
213
|
+
exports.CannotTrackError = CannotTrackError;
|
|
214
|
+
exports.ClientNotPresentError = ClientNotPresentError;
|
|
215
|
+
exports.InvalidStorageSet = InvalidStorageSet;
|
|
216
|
+
exports._extends = _extends;
|
|
217
|
+
exports.dependencies = dependencies;
|
|
218
|
+
exports.emitEvent = emitEvent;
|
|
219
|
+
exports.getClient = getClient;
|
|
220
|
+
exports.getCore = getCore;
|
|
221
|
+
exports.isEqualShallow = isEqualShallow;
|
|
222
|
+
exports.offEvent = offEvent;
|
|
223
|
+
exports.onEvent = onEvent;
|
|
224
|
+
exports.onceEvent = onceEvent;
|
|
225
|
+
exports.subscribeWithSelector = subscribeWithSelector;
|
|
226
|
+
exports.version = version;
|
package/getClient.esm.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
const getCore = (client)=>{
|
|
2
|
+
// @ts-expect-error - this was hidden from the public API
|
|
3
|
+
return client.__core;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shallow compare two objects.
|
|
8
|
+
*
|
|
9
|
+
* Source: https://github.com/pmndrs/zustand/blob/main/src/vanilla/shallow.ts
|
|
10
|
+
*/ const isEqualShallow = (objA, objB)=>{
|
|
11
|
+
if (Object.is(objA, objB)) return true;
|
|
12
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
13
|
+
return objA === objB;
|
|
14
|
+
}
|
|
15
|
+
if (objA instanceof Map && objB instanceof Map) {
|
|
16
|
+
if (objA.size !== objB.size) return false;
|
|
17
|
+
for (const [key, value] of objA){
|
|
18
|
+
if (!Object.is(value, objB.get(key))) return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (objA instanceof Set && objB instanceof Set) {
|
|
23
|
+
if (objA.size !== objB.size) return false;
|
|
24
|
+
for (const value of objA){
|
|
25
|
+
if (!objB.has(value)) return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
const keysA = Object.keys(objA);
|
|
30
|
+
if (keysA.length !== Object.keys(objB).length) return false;
|
|
31
|
+
for (const keyA of keysA){
|
|
32
|
+
if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (objA.constructor !== objB.constructor) return false;
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Allows subscribing to a slice of the state.
|
|
42
|
+
* The slice is a computation of the states.
|
|
43
|
+
*
|
|
44
|
+
* The callback will only be called when the slice has changed.
|
|
45
|
+
* Change is determined by shallow comparison.
|
|
46
|
+
*
|
|
47
|
+
* Returns a function to unsubscribe the callback.
|
|
48
|
+
*/ const subscribeWithSelector = (observable, selector)=>(callback)=>{
|
|
49
|
+
let lastSlice = selector(observable.get());
|
|
50
|
+
return observable.subscribe((value)=>{
|
|
51
|
+
const nextSlice = selector(value);
|
|
52
|
+
if (isEqualShallow(nextSlice, lastSlice)) return;
|
|
53
|
+
lastSlice = nextSlice;
|
|
54
|
+
callback(nextSlice);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function _extends() {
|
|
59
|
+
_extends = Object.assign || function assign(target) {
|
|
60
|
+
for(var i = 1; i < arguments.length; i++){
|
|
61
|
+
var source = arguments[i];
|
|
62
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
return target;
|
|
65
|
+
};
|
|
66
|
+
return _extends.apply(this, arguments);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var version = "0.0.1-alpha.4";
|
|
70
|
+
var dependencies = {
|
|
71
|
+
"@dynamic-labs/sdk-api-core": "0.0.630"};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Listen to an event from the client.
|
|
75
|
+
*
|
|
76
|
+
* @returns A function that can be called to remove the listener.
|
|
77
|
+
*/ const onEvent = (client, event, listener)=>{
|
|
78
|
+
const { eventEmitter } = getCore(client);
|
|
79
|
+
eventEmitter.on(event, listener);
|
|
80
|
+
return ()=>{
|
|
81
|
+
eventEmitter.off(event, listener);
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Remove a listener from an event.
|
|
86
|
+
*/ const offEvent = (client, event, listener)=>{
|
|
87
|
+
const { eventEmitter } = getCore(client);
|
|
88
|
+
eventEmitter.off(event, listener);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Listen to an event that will only fire once.
|
|
92
|
+
*
|
|
93
|
+
* @returns A function that can be called to remove the listener.
|
|
94
|
+
*/ const onceEvent = (client, event, listener)=>{
|
|
95
|
+
const { eventEmitter } = getCore(client);
|
|
96
|
+
eventEmitter.once(event, listener);
|
|
97
|
+
return ()=>{
|
|
98
|
+
eventEmitter.off(event, listener);
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Emit an event.
|
|
103
|
+
*/ const emitEvent = (client, event, ...args)=>{
|
|
104
|
+
const { eventEmitter } = getCore(client);
|
|
105
|
+
eventEmitter.emit(event, ...args);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const getDetails = ({ details, cause })=>{
|
|
109
|
+
if (cause instanceof BaseError) {
|
|
110
|
+
return cause.details;
|
|
111
|
+
}
|
|
112
|
+
if (cause == null ? void 0 : cause.message) {
|
|
113
|
+
return cause.message;
|
|
114
|
+
}
|
|
115
|
+
return details;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Formats the error message with all available information
|
|
119
|
+
*/ const formatMessage = ({ shortMessage, details, docsUrl, metaMessages })=>{
|
|
120
|
+
return [
|
|
121
|
+
shortMessage,
|
|
122
|
+
'',
|
|
123
|
+
...metaMessages ? [
|
|
124
|
+
...metaMessages,
|
|
125
|
+
''
|
|
126
|
+
] : [],
|
|
127
|
+
...docsUrl ? [
|
|
128
|
+
`Docs: ${docsUrl}`
|
|
129
|
+
] : [],
|
|
130
|
+
...details ? [
|
|
131
|
+
`Details: ${details}`
|
|
132
|
+
] : [],
|
|
133
|
+
`Version: ${version}`,
|
|
134
|
+
`Timestamp: ${new Date().toISOString()}`
|
|
135
|
+
].join('\n');
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Base error class that provides structured error handling with detailed information
|
|
139
|
+
*/ class BaseError extends Error {
|
|
140
|
+
/**
|
|
141
|
+
* Walks the cause chain of the error and returns the root error
|
|
142
|
+
*/ walk() {
|
|
143
|
+
const cause = this.cause;
|
|
144
|
+
if (cause instanceof BaseError) {
|
|
145
|
+
return cause.walk();
|
|
146
|
+
}
|
|
147
|
+
return cause;
|
|
148
|
+
}
|
|
149
|
+
constructor(args){
|
|
150
|
+
const details = getDetails(args);
|
|
151
|
+
super(formatMessage(_extends({}, args, {
|
|
152
|
+
details
|
|
153
|
+
})), args.cause ? {
|
|
154
|
+
cause: args.cause
|
|
155
|
+
} : undefined);
|
|
156
|
+
this.name = 'BaseError';
|
|
157
|
+
this.details = details;
|
|
158
|
+
var _args_name;
|
|
159
|
+
this.name = (_args_name = args.name) != null ? _args_name : this.name;
|
|
160
|
+
var _args_cause;
|
|
161
|
+
this.cause = (_args_cause = args.cause) != null ? _args_cause : this.cause;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
class CannotTrackError extends BaseError {
|
|
166
|
+
constructor(){
|
|
167
|
+
super({
|
|
168
|
+
cause: null,
|
|
169
|
+
docsUrl: null,
|
|
170
|
+
name: 'CannotTrackError',
|
|
171
|
+
shortMessage: 'All track calls must be performed in the same node tick'
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
class InvalidStorageSet extends BaseError {
|
|
177
|
+
constructor({ key, value }){
|
|
178
|
+
super({
|
|
179
|
+
cause: null,
|
|
180
|
+
docsUrl: null,
|
|
181
|
+
metaMessages: [
|
|
182
|
+
`key: ${key}`,
|
|
183
|
+
value
|
|
184
|
+
],
|
|
185
|
+
name: 'InvalidStorageSet',
|
|
186
|
+
shortMessage: 'Tried to store a value that does not match the schema'
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
class ClientNotPresentError extends BaseError {
|
|
192
|
+
constructor(){
|
|
193
|
+
super({
|
|
194
|
+
cause: null,
|
|
195
|
+
docsUrl: null,
|
|
196
|
+
name: 'ClientNotPresentError',
|
|
197
|
+
shortMessage: 'The client is not present in the target object.'
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const getClient = (target)=>{
|
|
203
|
+
if (!Object.prototype.hasOwnProperty.call(target, '__client')) {
|
|
204
|
+
throw new ClientNotPresentError();
|
|
205
|
+
}
|
|
206
|
+
// @ts-expect-error - this was hidden from the public API
|
|
207
|
+
return target.__client;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export { BaseError as B, CannotTrackError as C, InvalidStorageSet as I, _extends as _, getClient as a, onceEvent as b, onEvent as c, dependencies as d, emitEvent as e, ClientNotPresentError as f, getCore as g, isEqualShallow as i, offEvent as o, subscribeWithSelector as s, version as v };
|