kiss-for-react 1.1.0 → 2.0.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/README.md +699 -156
- package/lib/cjs/ClassPersistor.js +177 -112
- package/lib/cjs/Esserializer/DeserializationOptions.js +4 -4
- package/lib/cjs/Esserializer/SerializeOptions.js +4 -4
- package/lib/cjs/Esserializer/builtins.js +258 -0
- package/lib/cjs/Esserializer/constant.js +39 -131
- package/lib/cjs/Esserializer/deserializer.js +293 -313
- package/lib/cjs/Esserializer/general.js +91 -39
- package/lib/cjs/Esserializer/index.js +47 -43
- package/lib/cjs/Esserializer/serializer.js +168 -133
- package/lib/cjs/Evt.js +132 -0
- package/lib/cjs/Hooks.js +1474 -969
- package/lib/cjs/KissAction.js +4762 -1333
- package/lib/cjs/LoadPages.js +336 -0
- package/lib/cjs/Persistor.js +189 -120
- package/lib/cjs/ProcessPersistence.js +579 -262
- package/lib/cjs/Store.js +4342 -1534
- package/lib/cjs/StoreException.js +162 -75
- package/lib/cjs/StoreProvider.js +166 -0
- package/lib/cjs/UserException.js +212 -218
- package/lib/cjs/Wait.js +309 -309
- package/lib/cjs/index.js +69 -42
- package/lib/cjs/server.js +54 -0
- package/lib/cjs/types/ClassPersistor.d.ts +143 -112
- package/lib/cjs/types/ClassPersistor.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/DeserializationOptions.d.ts +13 -6
- package/lib/cjs/types/Esserializer/DeserializationOptions.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/SerializeOptions.d.ts +11 -5
- package/lib/cjs/types/Esserializer/SerializeOptions.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/builtins.d.ts +36 -0
- package/lib/cjs/types/Esserializer/builtins.d.ts.map +1 -0
- package/lib/cjs/types/Esserializer/constant.d.ts +25 -49
- package/lib/cjs/types/Esserializer/constant.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/deserializer.d.ts +27 -17
- package/lib/cjs/types/Esserializer/deserializer.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/general.d.ts +28 -4
- package/lib/cjs/types/Esserializer/general.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/index.d.ts +33 -29
- package/lib/cjs/types/Esserializer/index.d.ts.map +1 -1
- package/lib/cjs/types/Esserializer/serializer.d.ts +14 -3
- package/lib/cjs/types/Esserializer/serializer.d.ts.map +1 -1
- package/lib/cjs/types/Evt.d.ts +124 -0
- package/lib/cjs/types/Evt.d.ts.map +1 -0
- package/lib/cjs/types/Hooks.d.ts +1174 -837
- package/lib/cjs/types/Hooks.d.ts.map +1 -1
- package/lib/cjs/types/KissAction.d.ts +5257 -1398
- package/lib/cjs/types/KissAction.d.ts.map +1 -1
- package/lib/cjs/types/LoadPages.d.ts +287 -0
- package/lib/cjs/types/LoadPages.d.ts.map +1 -0
- package/lib/cjs/types/Persistor.d.ts +187 -118
- package/lib/cjs/types/Persistor.d.ts.map +1 -1
- package/lib/cjs/types/ProcessPersistence.d.ts +197 -99
- package/lib/cjs/types/ProcessPersistence.d.ts.map +1 -1
- package/lib/cjs/types/Store.d.ts +2266 -1042
- package/lib/cjs/types/Store.d.ts.map +1 -1
- package/lib/cjs/types/StoreException.d.ts +97 -28
- package/lib/cjs/types/StoreException.d.ts.map +1 -1
- package/lib/cjs/types/StoreProvider.d.ts +95 -0
- package/lib/cjs/types/StoreProvider.d.ts.map +1 -0
- package/lib/cjs/types/UserException.d.ts +178 -169
- package/lib/cjs/types/UserException.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +12 -9
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/server.d.ts +12 -0
- package/lib/cjs/types/server.d.ts.map +1 -0
- package/lib/cjs/types/utils.d.ts +15 -1
- package/lib/cjs/types/utils.d.ts.map +1 -1
- package/lib/cjs/utils.js +45 -7
- package/lib/esm/ClassPersistor.mjs +177 -0
- package/lib/esm/Esserializer/{DeserializationOptions.js → DeserializationOptions.mjs} +3 -3
- package/lib/esm/Esserializer/{SerializeOptions.js → SerializeOptions.mjs} +3 -3
- package/lib/esm/Esserializer/builtins.mjs +254 -0
- package/lib/esm/Esserializer/constant.mjs +28 -0
- package/lib/esm/Esserializer/deserializer.mjs +288 -0
- package/lib/esm/Esserializer/general.mjs +81 -0
- package/lib/esm/Esserializer/index.mjs +43 -0
- package/lib/esm/Esserializer/serializer.mjs +164 -0
- package/lib/esm/Evt.mjs +151 -0
- package/lib/esm/Hooks.mjs +1448 -0
- package/lib/esm/KissAction.mjs +4816 -0
- package/lib/esm/LoadPages.mjs +340 -0
- package/lib/esm/Persistor.mjs +180 -0
- package/lib/esm/ProcessPersistence.mjs +581 -0
- package/lib/esm/Store.mjs +4464 -0
- package/lib/esm/StoreException.mjs +153 -0
- package/lib/esm/StoreProvider.mjs +162 -0
- package/lib/esm/{UserException.js → UserException.mjs} +240 -246
- package/lib/esm/{Wait.js → Wait.mjs} +309 -309
- package/lib/esm/index.mjs +12 -9
- package/lib/esm/server.mjs +23 -0
- package/lib/esm/types/ClassPersistor.d.ts +143 -112
- package/lib/esm/types/ClassPersistor.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/DeserializationOptions.d.ts +13 -6
- package/lib/esm/types/Esserializer/DeserializationOptions.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/SerializeOptions.d.ts +11 -5
- package/lib/esm/types/Esserializer/SerializeOptions.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/builtins.d.ts +36 -0
- package/lib/esm/types/Esserializer/builtins.d.ts.map +1 -0
- package/lib/esm/types/Esserializer/constant.d.ts +25 -49
- package/lib/esm/types/Esserializer/constant.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/deserializer.d.ts +27 -17
- package/lib/esm/types/Esserializer/deserializer.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/general.d.ts +28 -4
- package/lib/esm/types/Esserializer/general.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/index.d.ts +33 -29
- package/lib/esm/types/Esserializer/index.d.ts.map +1 -1
- package/lib/esm/types/Esserializer/serializer.d.ts +14 -3
- package/lib/esm/types/Esserializer/serializer.d.ts.map +1 -1
- package/lib/esm/types/Evt.d.ts +124 -0
- package/lib/esm/types/Evt.d.ts.map +1 -0
- package/lib/esm/types/Hooks.d.ts +1174 -837
- package/lib/esm/types/Hooks.d.ts.map +1 -1
- package/lib/esm/types/KissAction.d.ts +5257 -1398
- package/lib/esm/types/KissAction.d.ts.map +1 -1
- package/lib/esm/types/LoadPages.d.ts +287 -0
- package/lib/esm/types/LoadPages.d.ts.map +1 -0
- package/lib/esm/types/Persistor.d.ts +187 -118
- package/lib/esm/types/Persistor.d.ts.map +1 -1
- package/lib/esm/types/ProcessPersistence.d.ts +197 -99
- package/lib/esm/types/ProcessPersistence.d.ts.map +1 -1
- package/lib/esm/types/Store.d.ts +2266 -1042
- package/lib/esm/types/Store.d.ts.map +1 -1
- package/lib/esm/types/StoreException.d.ts +97 -28
- package/lib/esm/types/StoreException.d.ts.map +1 -1
- package/lib/esm/types/StoreProvider.d.ts +95 -0
- package/lib/esm/types/StoreProvider.d.ts.map +1 -0
- package/lib/esm/types/UserException.d.ts +178 -169
- package/lib/esm/types/UserException.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +12 -9
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/server.d.ts +12 -0
- package/lib/esm/types/server.d.ts.map +1 -0
- package/lib/esm/types/utils.d.ts +15 -1
- package/lib/esm/types/utils.d.ts.map +1 -1
- package/lib/esm/utils.mjs +38 -0
- package/package.json +54 -30
- package/lib/cjs/UnmodifiableSetView.js +0 -53
- package/lib/cjs/types/UnmodifiableSetView.d.ts +0 -24
- package/lib/cjs/types/UnmodifiableSetView.d.ts.map +0 -1
- package/lib/esm/ClassPersistor.js +0 -112
- package/lib/esm/Esserializer/constant.js +0 -81
- package/lib/esm/Esserializer/deserializer.js +0 -307
- package/lib/esm/Esserializer/general.js +0 -34
- package/lib/esm/Esserializer/index.js +0 -39
- package/lib/esm/Esserializer/serializer.js +0 -130
- package/lib/esm/Hooks.js +0 -955
- package/lib/esm/KissAction.js +0 -1459
- package/lib/esm/Persistor.js +0 -113
- package/lib/esm/ProcessPersistence.js +0 -262
- package/lib/esm/Store.js +0 -1606
- package/lib/esm/StoreException.js +0 -69
- package/lib/esm/UnmodifiableSetView.js +0 -50
- package/lib/esm/types/UnmodifiableSetView.d.ts +0 -24
- package/lib/esm/types/UnmodifiableSetView.d.ts.map +0 -1
- package/lib/esm/utils.js +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// The entry point of the package under the `react-server` export condition (see package.json),
|
|
2
|
+
// which React Server Components bundlers (like the Next.js app router) use for the modules of
|
|
3
|
+
// server components. It has everything of the main entry point except the hooks, which need
|
|
4
|
+
// React's client features. So a server component can create a store, dispatch actions and read
|
|
5
|
+
// the state, and importing a hook from it is a build error, instead of a runtime one. The
|
|
6
|
+
// `StoreProvider` and `StoreSlice` components are exported, so that a server component can
|
|
7
|
+
// render them: their module is marked `'use client'`, and the bundler turns them into client
|
|
8
|
+
// references. It's also exported as `kiss-for-react/server`, for code that must never pull in
|
|
9
|
+
// the hooks.
|
|
10
|
+
//
|
|
11
|
+
// Keep it in sync with `index.ts`: `__tests__/bdd.ServerEntryPoint.test.ts` checks that it
|
|
12
|
+
// exports everything of `index.ts` that is not a hook.
|
|
13
|
+
import { PersistAction, PersistException, Persistor, PersistorDummy, PersistorPrinterDecorator, } from './Persistor.mjs';
|
|
14
|
+
import { ClassPersistor } from './ClassPersistor.mjs';
|
|
15
|
+
import { ProcessPersistence } from './ProcessPersistence.mjs';
|
|
16
|
+
import { ActionStatus, OptimisticCommand, OptimisticSync, OptimisticSyncWithPush, ServerPush, KissAction, MergeServerStateAction, Poll, UserExceptionAction, UpdateStateAction, } from './KissAction.mjs';
|
|
17
|
+
import { LoadPages, Pages } from './LoadPages.mjs';
|
|
18
|
+
import { Store, createStore } from './Store.mjs';
|
|
19
|
+
import { StoreProvider, StoreSlice } from './StoreProvider.mjs';
|
|
20
|
+
import { AbortDispatchException, StoreException, TimeoutException } from './StoreException.mjs';
|
|
21
|
+
import { Evt, EvtState } from './Evt.mjs';
|
|
22
|
+
import { UserException } from './UserException.mjs';
|
|
23
|
+
export { Persistor, PersistorPrinterDecorator, PersistorDummy, PersistException, PersistAction, UpdateStateAction, ClassPersistor, ProcessPersistence, KissAction, MergeServerStateAction, UserExceptionAction, ActionStatus, Store, createStore, StoreProvider, StoreSlice, Evt, EvtState, StoreException, AbortDispatchException, TimeoutException, UserException, OptimisticCommand, OptimisticSync, OptimisticSyncWithPush, ServerPush, Poll, LoadPages, Pages, };
|
|
@@ -1,113 +1,144 @@
|
|
|
1
|
-
import { ClassOrEnum } from './Esserializer';
|
|
2
|
-
import { Persistor } from './Persistor';
|
|
3
|
-
/**
|
|
4
|
-
* Use it like this:
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* const store = createStore<AppState>({
|
|
8
|
-
* initialState: initialState,
|
|
9
|
-
* persistor: new MyPersistor(),
|
|
10
|
-
* });
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Example for web:
|
|
14
|
-
* ```
|
|
15
|
-
* return new ClassPersistor<State>(
|
|
16
|
-
* async () => window.localStorage.getItem('state'),
|
|
17
|
-
* async (serialized) => window.localStorage.setItem('state', serialized),
|
|
18
|
-
* async () => window.localStorage.clear(),
|
|
19
|
-
* [State, TodoList, TodoItem, Filter] // All state classes the app uses.
|
|
20
|
-
* );
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Example for React Native:
|
|
24
|
-
* ```
|
|
25
|
-
* return new ClassPersistor<State>(
|
|
26
|
-
* async () => AsyncStorage.getItem('state'),
|
|
27
|
-
* async (serialized) => AsyncStorage.setItem('state', serialized),
|
|
28
|
-
* async () => AsyncStorage.clear(),
|
|
29
|
-
* [State, TodoList, TodoItem, Filter] // All state classes the app uses.
|
|
30
|
-
* );
|
|
31
|
-
* ```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import { ClassOrEnum } from './Esserializer';
|
|
2
|
+
import { Persistor } from './Persistor';
|
|
3
|
+
/**
|
|
4
|
+
* Use it like this:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const store = createStore<AppState>({
|
|
8
|
+
* initialState: initialState,
|
|
9
|
+
* persistor: new MyPersistor(),
|
|
10
|
+
* });
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Example for web:
|
|
14
|
+
* ```
|
|
15
|
+
* return new ClassPersistor<State>(
|
|
16
|
+
* async () => window.localStorage.getItem('state'),
|
|
17
|
+
* async (serialized) => window.localStorage.setItem('state', serialized),
|
|
18
|
+
* async () => window.localStorage.clear(),
|
|
19
|
+
* [State, TodoList, TodoItem, Filter] // All state classes the app uses.
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Example for React Native:
|
|
24
|
+
* ```
|
|
25
|
+
* return new ClassPersistor<State>(
|
|
26
|
+
* async () => AsyncStorage.getItem('state'),
|
|
27
|
+
* async (serialized) => AsyncStorage.setItem('state', serialized),
|
|
28
|
+
* async () => AsyncStorage.clear(),
|
|
29
|
+
* [State, TodoList, TodoItem, Filter] // All state classes the app uses.
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Classes are saved by their class name. Production builds usually minify class names
|
|
34
|
+
* (`TodoItem` becomes `e`), which would make different classes collide, and change the saved
|
|
35
|
+
* names from one app version to the next. To prevent this, either turn off class name
|
|
36
|
+
* minification in your bundler (see kissforreact.org), or give each state class a stable
|
|
37
|
+
* name with a static `typeName`:
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* class TodoItem {
|
|
41
|
+
* static readonly typeName = 'TodoItem';
|
|
42
|
+
* ...
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* A `typeName` is not inherited: subclasses need their own. The `ClassPersistor` throws a
|
|
47
|
+
* `StoreException` when it's created, if it finds class names are minified and some class has
|
|
48
|
+
* no `typeName`, or if two classes are saved under the same name. A class with no `typeName`
|
|
49
|
+
* whose name looks minified (one or two characters, starting with a lowercase letter, `_` or
|
|
50
|
+
* `$`, like `e` or `ab`) also makes it throw, even if the rest of the code is not minified.
|
|
51
|
+
* Built-in classes, like `Date`, are not checked, as they are not saved by their name.
|
|
52
|
+
*/
|
|
53
|
+
export declare class ClassPersistor<St> extends Persistor<St> {
|
|
54
|
+
/**
|
|
55
|
+
* Returns the serialized state. You can use this to load from localStorage or IndexedDB
|
|
56
|
+
* (in React web), or AsyncStorage (in React Native) or other.
|
|
57
|
+
* It should return a Promise that resolves to the serialized state, or to null if the state
|
|
58
|
+
* is not yet persisted.
|
|
59
|
+
*/
|
|
60
|
+
loadSerialized: () => Promise<string | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Saves the given serialized state. You can use this to save to localStorage or IndexedDB
|
|
63
|
+
* (in React web), or AsyncStorage (in React Native) or other.
|
|
64
|
+
* It should return a Promise that resolves when the state is saved.
|
|
65
|
+
*/
|
|
66
|
+
saveSerialized: (serialized: string) => Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Deletes the serialized state. You can use this to delete from the localStorage or IndexedDB
|
|
69
|
+
* (in React web), or AsyncStorage (in React Native) or other.
|
|
70
|
+
* It should return a Promise that resolves when the state is deleted.
|
|
71
|
+
*/
|
|
72
|
+
deleteSerialized: () => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* You HAVE to list here all the custom classes that are part of your state, directly or
|
|
75
|
+
* indirectly. Note: You don't need to list native JavaScript classes, like Date.
|
|
76
|
+
* For example, suppose you have a class `State` that has a property `todoList` of
|
|
77
|
+
* type `TodoList`.
|
|
78
|
+
* And the class `TodoList` has a property `items` of type `Array<TodoItem>`.
|
|
79
|
+
* Then you have to list all three classes here: `[State, TodoList, TodoItem]`.
|
|
80
|
+
*/
|
|
81
|
+
classesToSerialize: Array<ClassOrEnum>;
|
|
82
|
+
constructor(
|
|
83
|
+
/**
|
|
84
|
+
* Returns the serialized state. You can use this to load from localStorage or IndexedDB
|
|
85
|
+
* (in React web), or AsyncStorage (in React Native) or other.
|
|
86
|
+
* It should return a Promise that resolves to the serialized state, or to null if the state
|
|
87
|
+
* is not yet persisted.
|
|
88
|
+
*/
|
|
89
|
+
loadSerialized: () => Promise<string | null>,
|
|
90
|
+
/**
|
|
91
|
+
* Saves the given serialized state. You can use this to save to localStorage or IndexedDB
|
|
92
|
+
* (in React web), or AsyncStorage (in React Native) or other.
|
|
93
|
+
* It should return a Promise that resolves when the state is saved.
|
|
94
|
+
*/
|
|
95
|
+
saveSerialized: (serialized: string) => Promise<void>,
|
|
96
|
+
/**
|
|
97
|
+
* Deletes the serialized state. You can use this to delete from the localStorage or IndexedDB
|
|
98
|
+
* (in React web), or AsyncStorage (in React Native) or other.
|
|
99
|
+
* It should return a Promise that resolves when the state is deleted.
|
|
100
|
+
*/
|
|
101
|
+
deleteSerialized: () => Promise<void>,
|
|
102
|
+
/**
|
|
103
|
+
* You HAVE to list here all the custom classes that are part of your state, directly or
|
|
104
|
+
* indirectly. Note: You don't need to list native JavaScript classes, like Date.
|
|
105
|
+
* For example, suppose you have a class `State` that has a property `todoList` of
|
|
106
|
+
* type `TodoList`.
|
|
107
|
+
* And the class `TodoList` has a property `items` of type `Array<TodoItem>`.
|
|
108
|
+
* Then you have to list all three classes here: `[State, TodoList, TodoItem]`.
|
|
109
|
+
*/
|
|
110
|
+
classesToSerialize: Array<ClassOrEnum>);
|
|
111
|
+
/**
|
|
112
|
+
* Returns true if the bundler is minifying class names. Since the bundler minifies this library
|
|
113
|
+
* together with the app, we know class names are minified if this class lost its own name.
|
|
114
|
+
*/
|
|
115
|
+
protected classNamesAreMinified(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Returns true if the class name looks minified: one or two characters, starting with a
|
|
118
|
+
* lowercase letter, `_` or `$`, like `e`, `ab` or `$e`. Normal names, like `myState`, don't.
|
|
119
|
+
*/
|
|
120
|
+
private static looksMinified;
|
|
121
|
+
private checkClassNames;
|
|
122
|
+
/**
|
|
123
|
+
* Read the saved state from the persistence. Returns null if the state is not yet persisted.
|
|
124
|
+
* Don't call it yourself: the store calls it once, when it's created, and if there is a
|
|
125
|
+
* saved state, it replaces the store's initial-state. If the saved state can't be read
|
|
126
|
+
* (for example, it's corrupted, or it has a class that is not in `classesToSerialize`),
|
|
127
|
+
* this throws. The store then logs the error, gives it to the `errorObserver`, deletes the
|
|
128
|
+
* saved state, and saves the initial-state instead. See `Persistor.readState`.
|
|
129
|
+
*/
|
|
130
|
+
readState(): Promise<St | null>;
|
|
131
|
+
/**
|
|
132
|
+
* Save an initial-state to the persistence.
|
|
133
|
+
*/
|
|
134
|
+
saveInitialState(state: St): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Delete the saved state from the persistence.
|
|
137
|
+
*/
|
|
138
|
+
deleteState(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* We assume the state is small, and we save `newState` everytime, ignoring `lastPersistedState`.
|
|
141
|
+
*/
|
|
142
|
+
persistDifference(_lastPersistedState: St | null, newState: St): Promise<void>;
|
|
143
|
+
}
|
|
113
144
|
//# sourceMappingURL=ClassPersistor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassPersistor.d.ts","sourceRoot":"","sources":["../../../src/ClassPersistor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassPersistor.d.ts","sourceRoot":"","sources":["../../../src/ClassPersistor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,qBAAa,cAAc,CAAC,EAAE,CAAE,SAAQ,SAAS,CAAC,EAAE,CAAC;IAGjD;;;;;OAKG;IACI,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAEnD;;;;OAIG;IACI,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;IAE5D;;;;OAIG;IACI,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAE5C;;;;;;;OAOG;IACI,kBAAkB,EAAE,KAAK,CAAC,WAAW,CAAC;;IA9B7C;;;;;OAKG;IACI,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAEnD;;;;OAIG;IACI,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;IAE5D;;;;OAIG;IACI,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAE5C;;;;;;;OAOG;IACI,kBAAkB,EAAE,KAAK,CAAC,WAAW,CAAC;IAM/C;;;OAGG;IACH,SAAS,CAAC,qBAAqB,IAAI,OAAO;IAI1C;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAI5B,OAAO,CAAC,eAAe;IAmCvB;;;;;;;OAOG;IACG,SAAS,IAAI,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC;IAWrC;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,EAAE;IAKhC;;OAEG;IACG,WAAW;IAIjB;;OAEG;IACG,iBAAiB,CAAC,mBAAmB,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE;CAIrE"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
1
|
+
/** Options for `ESSerializer.deserialize`. They apply only to the top-level object. */
|
|
2
|
+
interface DeserializeOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Saved fields to pass, in this order, as the parameters of the class constructor.
|
|
5
|
+
* Missing fields are passed as `{}`.
|
|
6
|
+
*/
|
|
7
|
+
fieldsForConstructorParameters?: Array<string>;
|
|
8
|
+
/** Saved properties that are not read back. */
|
|
9
|
+
ignoreProperties?: Array<string>;
|
|
10
|
+
/** Saved properties that are read back as their JSON text, instead of being deserialized. */
|
|
11
|
+
rawProperties?: Array<string>;
|
|
12
|
+
}
|
|
13
|
+
export default DeserializeOptions;
|
|
7
14
|
//# sourceMappingURL=DeserializationOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeserializationOptions.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/DeserializationOptions.ts"],"names":[],"mappings":"AAGA,UAAU,kBAAkB;IAC1B,8BAA8B,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"DeserializationOptions.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/DeserializationOptions.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,UAAU,kBAAkB;IAC1B;;;OAGG;IACH,8BAA8B,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEjC,6FAA6F;IAC7F,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAC9B;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/** Options for `ESSerializer.serialize`. They apply only to the top-level object. */
|
|
2
|
+
interface SerializeOptions {
|
|
3
|
+
/** Properties that are not saved. */
|
|
4
|
+
ignoreProperties?: Array<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Properties whose saved value is the result of the given function, instead of their own value.
|
|
7
|
+
* The function gets the property value, and is called with `this` set to the object.
|
|
8
|
+
*/
|
|
9
|
+
interceptProperties?: Record<string, (value: any) => any>;
|
|
10
|
+
}
|
|
11
|
+
export default SerializeOptions;
|
|
6
12
|
//# sourceMappingURL=SerializeOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerializeOptions.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/SerializeOptions.ts"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SerializeOptions.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/SerializeOptions.ts"],"names":[],"mappings":"AAGA,qFAAqF;AACrF,UAAU,gBAAgB;IACxB,qCAAqC;IACrC,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,CAAA;CAC1D;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Serializes or deserializes a nested value. */
|
|
2
|
+
type Converter = (value: any) => any;
|
|
3
|
+
/** How a built-in class is saved and rebuilt. */
|
|
4
|
+
interface BuiltinType {
|
|
5
|
+
/** The class. Its instances are saved with `*type` `@<name>`. */
|
|
6
|
+
readonly constructor: unknown;
|
|
7
|
+
/** The name the class is saved under, without the `@` prefix. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** Returns the data needed to rebuild `target`, saved in the `*value` field. */
|
|
10
|
+
encode(target: any, serialize: Converter): any;
|
|
11
|
+
/** Rebuilds the value from the saved data. */
|
|
12
|
+
decode(saved: any, deserialize: Converter): any;
|
|
13
|
+
/**
|
|
14
|
+
* Puts the saved data into an instance of a user subclass, created by the subclass
|
|
15
|
+
* constructor. Built-in classes without it can't be subclassed in saved data.
|
|
16
|
+
*/
|
|
17
|
+
fill?(instance: any, saved: any, deserialize: Converter): void;
|
|
18
|
+
/**
|
|
19
|
+
* True if the enumerable properties of the instances are just their items (like the
|
|
20
|
+
* characters of a String), which are already saved in `*value`.
|
|
21
|
+
*/
|
|
22
|
+
readonly hasItemProperties?: boolean;
|
|
23
|
+
/** Properties already saved in `*value`, which must not be saved again as normal properties. */
|
|
24
|
+
readonly keysSavedInValue?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
/** Returns the built-in type of instances of exactly `constructor` (not of subclasses). */
|
|
27
|
+
declare function getBuiltinTypeByConstructor(constructor: unknown): BuiltinType | undefined;
|
|
28
|
+
/** Returns the built-in type saved as `savedType` (like `@Map`). */
|
|
29
|
+
declare function getBuiltinTypeBySavedType(savedType: string): BuiltinType | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the nearest built-in class that `target` inherits from, or undefined if it
|
|
32
|
+
* inherits only from `Object`.
|
|
33
|
+
*/
|
|
34
|
+
declare function findInheritedBuiltinType(target: object): BuiltinType | undefined;
|
|
35
|
+
export { BuiltinType, getBuiltinTypeByConstructor, getBuiltinTypeBySavedType, findInheritedBuiltinType, };
|
|
36
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/builtins.ts"],"names":[],"mappings":"AAOA,iDAAiD;AACjD,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAErC,iDAAiD;AACjD,UAAU,WAAW;IACnB,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,gFAAgF;IAChF,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;IAE/C,8CAA8C;IAC9C,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,GAAG,GAAG,CAAC;IAEhD;;;OAGG;IACH,IAAI,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,GAAG,IAAI,CAAC;IAE/D;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAErC,gGAAgG;IAChG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/C;AA2PD,2FAA2F;AAC3F,iBAAS,2BAA2B,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAElF;AAED,oEAAoE;AACpE,iBAAS,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAE7E;AAED;;;GAGG;AACH,iBAAS,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAQzE;AAED,OAAO,EACL,WAAW,EACX,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,GACzB,CAAC"}
|
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
declare const
|
|
12
|
-
|
|
13
|
-
declare const
|
|
14
|
-
|
|
15
|
-
declare const
|
|
16
|
-
|
|
17
|
-
declare const
|
|
18
|
-
|
|
19
|
-
declare const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
declare const
|
|
25
|
-
|
|
26
|
-
declare const BUILTIN_CLASS_INTL_LISTFORMAT = "ListFormat";
|
|
27
|
-
declare const BUILTIN_CLASS_INTL_LOCALE = "Locale";
|
|
28
|
-
declare const BUILTIN_CLASS_INTL_NUMBERFORMAT = "NumberFormat";
|
|
29
|
-
declare const BUILTIN_CLASS_INTL_PLURALRULES = "PluralRules";
|
|
30
|
-
declare const BUILTIN_CLASS_INTL_RELATIVETIMEFORMAT = "RelativeTimeFormat";
|
|
31
|
-
declare const BUILTIN_CLASS_REGEXP = "RegExp";
|
|
32
|
-
declare const BUILTIN_CLASS_SET = "Set";
|
|
33
|
-
declare const BUILTIN_CLASS_STRING = "String";
|
|
34
|
-
declare const BUILTIN_CLASS_ERROR = "Error";
|
|
35
|
-
declare const BUILTIN_CLASS_EVAL_ERROR = "EvalError";
|
|
36
|
-
declare const BUILTIN_CLASS_RANGE_ERROR = "RangeError";
|
|
37
|
-
declare const BUILTIN_CLASS_REFERENCE_ERROR = "ReferenceError";
|
|
38
|
-
declare const BUILTIN_CLASS_SYNTAX_ERROR = "SyntaxError";
|
|
39
|
-
declare const BUILTIN_CLASS_TYPE_ERROR = "TypeError";
|
|
40
|
-
declare const BUILTIN_CLASS_URI_ERROR = "URIError";
|
|
41
|
-
declare const BUILTIN_CLASS_AGGREGATE_ERROR = "AggregateError";
|
|
42
|
-
declare const BUILTIN_TYPE_BIG_INT = "BI";
|
|
43
|
-
declare const BUILTIN_TYPE_NOT_FINITE = "NF";
|
|
44
|
-
declare const BUILTIN_TYPE_UNDEFINED = "UD";
|
|
45
|
-
declare const ALL_BUILTIN_ARRAYS: string[];
|
|
46
|
-
declare const ALL_BUILTIN_ERRORS: string[];
|
|
47
|
-
declare const ALL_BUILTIN_INTLS: string[];
|
|
48
|
-
declare const CLASSNAMES_WHOSE_ENUMERABLE_PROPERTIES_SHOULD_BE_IGNORED: string[];
|
|
49
|
-
export { ESSERIALIZER_NULL, ALL_BUILTIN_ARRAYS, ALL_BUILTIN_ERRORS, ALL_BUILTIN_INTLS, CLASSNAMES_WHOSE_ENUMERABLE_PROPERTIES_SHOULD_BE_IGNORED, BUILTIN_CLASS_INT8ARRAY, BUILTIN_CLASS_UINT8ARRAY, BUILTIN_CLASS_UINT8CLAMPEDARRAY, BUILTIN_CLASS_INT16ARRAY, BUILTIN_CLASS_UINT16ARRAY, BUILTIN_CLASS_INT32ARRAY, BUILTIN_CLASS_UINT32ARRAY, BUILTIN_CLASS_FLOAT32ARRAY, BUILTIN_CLASS_FLOAT64ARRAY, BUILTIN_CLASS_BIGINT64ARRAY, BUILTIN_CLASS_BIGUINT64ARRAY, BUILTIN_CLASS_ARRAYBUFFER, BUILTIN_CLASS_SHAREDARRAYBUFFER, BUILTIN_CLASS_BOOLEAN, BUILTIN_CLASS_DATAVIEW, BUILTIN_CLASS_DATE, BUILTIN_CLASS_INTL_COLLATOR, BUILTIN_CLASS_INTL_DATETIMEFORMAT, BUILTIN_CLASS_INTL_LISTFORMAT, BUILTIN_CLASS_INTL_LOCALE, BUILTIN_CLASS_INTL_NUMBERFORMAT, BUILTIN_CLASS_INTL_PLURALRULES, BUILTIN_CLASS_INTL_RELATIVETIMEFORMAT, BUILTIN_CLASS_REGEXP, BUILTIN_CLASS_SET, BUILTIN_CLASS_STRING, BUILTIN_CLASS_ERROR, BUILTIN_CLASS_EVAL_ERROR, BUILTIN_CLASS_RANGE_ERROR, BUILTIN_CLASS_REFERENCE_ERROR, BUILTIN_CLASS_SYNTAX_ERROR, BUILTIN_CLASS_TYPE_ERROR, BUILTIN_CLASS_URI_ERROR, BUILTIN_CLASS_AGGREGATE_ERROR, BUILTIN_TYPE_BIG_INT, BUILTIN_TYPE_NOT_FINITE, BUILTIN_TYPE_UNDEFINED, ARRAY_FIELD, BOOLEAN_FIELD, CLASS_NAME_FIELD, OPTIONS_FIELD, TIMESTAMP_FIELD, TO_STRING_FIELD };
|
|
1
|
+
/** The type of a saved object: the name of a user class, or a built-in type (starting with `@`). */
|
|
2
|
+
declare const TYPE_FIELD = "*type";
|
|
3
|
+
/** The data needed to rebuild a built-in value (its items, timestamp, text form, etc.). */
|
|
4
|
+
declare const VALUE_FIELD = "*value";
|
|
5
|
+
/**
|
|
6
|
+
* Prefix of the built-in types, like `@Map` or `@undefined`. User classes can't be saved
|
|
7
|
+
* under names starting with it, so they are never confused with built-in types.
|
|
8
|
+
*/
|
|
9
|
+
declare const BUILTIN_PREFIX = "@";
|
|
10
|
+
/** `undefined`. */
|
|
11
|
+
declare const TYPE_UNDEFINED = "@undefined";
|
|
12
|
+
/** Numbers JSON can't represent: `NaN`, `Infinity`, `-Infinity` and `-0`. Saved as their text. */
|
|
13
|
+
declare const TYPE_NUMBER = "@number";
|
|
14
|
+
/** A `bigint`. Saved as its text. */
|
|
15
|
+
declare const TYPE_BIGINT = "@bigint";
|
|
16
|
+
/** A missing item of a sparse array. */
|
|
17
|
+
declare const TYPE_HOLE = "@hole";
|
|
18
|
+
/** An object with no prototype, like one made with `Object.create(null)`. Its properties are saved as usual. */
|
|
19
|
+
declare const TYPE_NULL_PROTOTYPE = "@nullPrototype";
|
|
20
|
+
/**
|
|
21
|
+
* User keys starting with this are saved with one more of it, so that they are not
|
|
22
|
+
* confused with the metadata fields. For example, a key `*type` is saved as `**type`.
|
|
23
|
+
*/
|
|
24
|
+
declare const KEY_ESCAPE = "*";
|
|
25
|
+
export { TYPE_FIELD, VALUE_FIELD, BUILTIN_PREFIX, TYPE_UNDEFINED, TYPE_NUMBER, TYPE_BIGINT, TYPE_HOLE, TYPE_NULL_PROTOTYPE, KEY_ESCAPE, };
|
|
50
26
|
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/constant.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/constant.ts"],"names":[],"mappings":"AAGA,oGAAoG;AACpG,QAAA,MAAM,UAAU,UAAU,CAAC;AAE3B,2FAA2F;AAC3F,QAAA,MAAM,WAAW,WAAW,CAAC;AAE7B;;;GAGG;AACH,QAAA,MAAM,cAAc,MAAM,CAAC;AAI3B,mBAAmB;AACnB,QAAA,MAAM,cAAc,eAAe,CAAC;AACpC,kGAAkG;AAClG,QAAA,MAAM,WAAW,YAAY,CAAC;AAC9B,qCAAqC;AACrC,QAAA,MAAM,WAAW,YAAY,CAAC;AAC9B,wCAAwC;AACxC,QAAA,MAAM,SAAS,UAAU,CAAC;AAC1B,gHAAgH;AAChH,QAAA,MAAM,mBAAmB,mBAAmB,CAAC;AAE7C;;;GAGG;AACH,QAAA,MAAM,UAAU,MAAM,CAAC;AAEvB,OAAO,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,UAAU,GACX,CAAC"}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import { ClassOrEnum } from '.';
|
|
2
|
-
import DeserializeOptions from './DeserializationOptions';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { ClassOrEnum } from '.';
|
|
2
|
+
import DeserializeOptions from './DeserializationOptions';
|
|
3
|
+
/**
|
|
4
|
+
* Maps the name a class is saved under (see `getClassKey`) to the class itself.
|
|
5
|
+
* Read it with `hasOwnProperty`, so that names like `toString` don't find inherited functions.
|
|
6
|
+
*/
|
|
7
|
+
type ClassMapping = Record<string, any>;
|
|
8
|
+
/**
|
|
9
|
+
* Turns a parsed JSON value back into the original value, creating instances of the
|
|
10
|
+
* given `classes` where the JSON has their names in the `*type` field.
|
|
11
|
+
*/
|
|
12
|
+
declare function deserializeFromParsedObj(parsedObj: any, classes: Array<ClassOrEnum>, options: DeserializeOptions): any;
|
|
13
|
+
/**
|
|
14
|
+
* Same as `deserializeFromParsedObj`, but with the classes already mapped by name.
|
|
15
|
+
* The `options` apply only to the top-level object, not to nested ones.
|
|
16
|
+
*/
|
|
17
|
+
declare function deserializeFromParsedObjWithClassMapping(parsedObj: any, classMapping: ClassMapping, options?: DeserializeOptions): any;
|
|
18
|
+
/**
|
|
19
|
+
* Maps each class to the name it's saved under. Items that are not classes (like enums) are
|
|
20
|
+
* ignored. Warns if two different classes are saved under the same name.
|
|
21
|
+
*
|
|
22
|
+
* @param classes Class definitions. They are typed as `any` because TypeScript has no type for classes.
|
|
23
|
+
*/
|
|
24
|
+
declare function getClassMappingFromClassArray(classes?: Array<any>): ClassMapping;
|
|
25
|
+
/** Returns the name of the parent class of `classObj` (or `Object`, if it has none). */
|
|
26
|
+
declare function getParentClassName(classObj: any): string;
|
|
27
|
+
export { deserializeFromParsedObj, deserializeFromParsedObjWithClassMapping, getClassMappingFromClassArray, getParentClassName };
|
|
18
28
|
//# sourceMappingURL=deserializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/deserializer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/deserializer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAqBhC,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAWxC;;;GAGG;AACH,iBAAS,wBAAwB,CAC/B,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,EAC3B,OAAO,EAAE,kBAAkB,GAAG,GAAG,CAMlC;AAED;;;GAGG;AACH,iBAAS,wCAAwC,CAC/C,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,kBAAuB,GAC/B,GAAG,CA2DL;AAoND;;;;;GAKG;AACH,iBAAS,6BAA6B,CAAC,OAAO,GAAE,KAAK,CAAC,GAAG,CAAM,GAAG,YAAY,CAc7E;AAED,wFAAwF;AACxF,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CAEjD;AAED,OAAO,EACL,wBAAwB,EACxB,wCAAwC,EACxC,6BAA6B,EAC7B,kBAAkB,EACnB,CAAC"}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
declare function
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/** Returns true for primitives (including `null`), and for functions. */
|
|
2
|
+
declare function notObject(target: any): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Converts the text form of a number JSON can't represent back into the number.
|
|
5
|
+
* Returns `null` for any other text.
|
|
6
|
+
*/
|
|
7
|
+
declare function getValueFromToStringResult(text: string): number | null;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the name a class is saved under: its own static `typeName`, if it has one,
|
|
10
|
+
* or else its class name. A `typeName` inherited from a parent class is ignored.
|
|
11
|
+
*/
|
|
12
|
+
declare function getClassKey(classObj: any): string;
|
|
13
|
+
/** Returns true if `target` can be called with `new` (a class, or a function-style class). */
|
|
14
|
+
declare function isClass(target: any): boolean;
|
|
15
|
+
/** Returns true if `fn` is implemented by the JavaScript engine, not by user code. */
|
|
16
|
+
declare function isNativeFunction(fn: object): boolean;
|
|
17
|
+
/** Escapes a user key, so that it's not confused with the metadata fields. */
|
|
18
|
+
declare function escapeKey(key: string): string;
|
|
19
|
+
/** Reverses `escapeKey`. */
|
|
20
|
+
declare function unescapeKey(savedKey: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Sets an own property. Unlike `obj[key] = value`, this also works for the key `__proto__`,
|
|
23
|
+
* which would otherwise change the prototype of `obj`, instead of creating a property.
|
|
24
|
+
*/
|
|
25
|
+
declare function setOwnProperty(obj: any, key: string, value: any): void;
|
|
26
|
+
/** Sets a non-enumerable own property, like the `message` of an error. */
|
|
27
|
+
declare function setHiddenProperty(obj: any, key: string, value: any): void;
|
|
28
|
+
export { getValueFromToStringResult, notObject, isClass, isNativeFunction, getClassKey, escapeKey, unescapeKey, setOwnProperty, setHiddenProperty, };
|
|
5
29
|
//# sourceMappingURL=general.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/general.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/general.ts"],"names":[],"mappings":"AAKA,yEAAyE;AACzE,iBAAS,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAEvC;AAED;;;GAGG;AACH,iBAAS,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa/D;AAED;;;GAGG;AACH,iBAAS,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CAK1C;AAKD,8FAA8F;AAC9F,iBAAS,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAarC;AAED,sFAAsF;AACtF,iBAAS,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,8EAA8E;AAC9E,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED,4BAA4B;AAC5B,iBAAS,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;GAGG;AACH,iBAAS,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,QAMxD;AAED,0EAA0E;AAC1E,iBAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,QAE3D;AAED,OAAO,EACL,0BAA0B,EAC1B,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,WAAW,EACX,cAAc,EACd,iBAAiB,GAClB,CAAC"}
|