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.
Files changed (155) hide show
  1. package/README.md +699 -156
  2. package/lib/cjs/ClassPersistor.js +177 -112
  3. package/lib/cjs/Esserializer/DeserializationOptions.js +4 -4
  4. package/lib/cjs/Esserializer/SerializeOptions.js +4 -4
  5. package/lib/cjs/Esserializer/builtins.js +258 -0
  6. package/lib/cjs/Esserializer/constant.js +39 -131
  7. package/lib/cjs/Esserializer/deserializer.js +293 -313
  8. package/lib/cjs/Esserializer/general.js +91 -39
  9. package/lib/cjs/Esserializer/index.js +47 -43
  10. package/lib/cjs/Esserializer/serializer.js +168 -133
  11. package/lib/cjs/Evt.js +132 -0
  12. package/lib/cjs/Hooks.js +1474 -969
  13. package/lib/cjs/KissAction.js +4762 -1333
  14. package/lib/cjs/LoadPages.js +336 -0
  15. package/lib/cjs/Persistor.js +189 -120
  16. package/lib/cjs/ProcessPersistence.js +579 -262
  17. package/lib/cjs/Store.js +4342 -1534
  18. package/lib/cjs/StoreException.js +162 -75
  19. package/lib/cjs/StoreProvider.js +166 -0
  20. package/lib/cjs/UserException.js +212 -218
  21. package/lib/cjs/Wait.js +309 -309
  22. package/lib/cjs/index.js +69 -42
  23. package/lib/cjs/server.js +54 -0
  24. package/lib/cjs/types/ClassPersistor.d.ts +143 -112
  25. package/lib/cjs/types/ClassPersistor.d.ts.map +1 -1
  26. package/lib/cjs/types/Esserializer/DeserializationOptions.d.ts +13 -6
  27. package/lib/cjs/types/Esserializer/DeserializationOptions.d.ts.map +1 -1
  28. package/lib/cjs/types/Esserializer/SerializeOptions.d.ts +11 -5
  29. package/lib/cjs/types/Esserializer/SerializeOptions.d.ts.map +1 -1
  30. package/lib/cjs/types/Esserializer/builtins.d.ts +36 -0
  31. package/lib/cjs/types/Esserializer/builtins.d.ts.map +1 -0
  32. package/lib/cjs/types/Esserializer/constant.d.ts +25 -49
  33. package/lib/cjs/types/Esserializer/constant.d.ts.map +1 -1
  34. package/lib/cjs/types/Esserializer/deserializer.d.ts +27 -17
  35. package/lib/cjs/types/Esserializer/deserializer.d.ts.map +1 -1
  36. package/lib/cjs/types/Esserializer/general.d.ts +28 -4
  37. package/lib/cjs/types/Esserializer/general.d.ts.map +1 -1
  38. package/lib/cjs/types/Esserializer/index.d.ts +33 -29
  39. package/lib/cjs/types/Esserializer/index.d.ts.map +1 -1
  40. package/lib/cjs/types/Esserializer/serializer.d.ts +14 -3
  41. package/lib/cjs/types/Esserializer/serializer.d.ts.map +1 -1
  42. package/lib/cjs/types/Evt.d.ts +124 -0
  43. package/lib/cjs/types/Evt.d.ts.map +1 -0
  44. package/lib/cjs/types/Hooks.d.ts +1174 -837
  45. package/lib/cjs/types/Hooks.d.ts.map +1 -1
  46. package/lib/cjs/types/KissAction.d.ts +5257 -1398
  47. package/lib/cjs/types/KissAction.d.ts.map +1 -1
  48. package/lib/cjs/types/LoadPages.d.ts +287 -0
  49. package/lib/cjs/types/LoadPages.d.ts.map +1 -0
  50. package/lib/cjs/types/Persistor.d.ts +187 -118
  51. package/lib/cjs/types/Persistor.d.ts.map +1 -1
  52. package/lib/cjs/types/ProcessPersistence.d.ts +197 -99
  53. package/lib/cjs/types/ProcessPersistence.d.ts.map +1 -1
  54. package/lib/cjs/types/Store.d.ts +2266 -1042
  55. package/lib/cjs/types/Store.d.ts.map +1 -1
  56. package/lib/cjs/types/StoreException.d.ts +97 -28
  57. package/lib/cjs/types/StoreException.d.ts.map +1 -1
  58. package/lib/cjs/types/StoreProvider.d.ts +95 -0
  59. package/lib/cjs/types/StoreProvider.d.ts.map +1 -0
  60. package/lib/cjs/types/UserException.d.ts +178 -169
  61. package/lib/cjs/types/UserException.d.ts.map +1 -1
  62. package/lib/cjs/types/index.d.ts +12 -9
  63. package/lib/cjs/types/index.d.ts.map +1 -1
  64. package/lib/cjs/types/server.d.ts +12 -0
  65. package/lib/cjs/types/server.d.ts.map +1 -0
  66. package/lib/cjs/types/utils.d.ts +15 -1
  67. package/lib/cjs/types/utils.d.ts.map +1 -1
  68. package/lib/cjs/utils.js +45 -7
  69. package/lib/esm/ClassPersistor.mjs +177 -0
  70. package/lib/esm/Esserializer/{DeserializationOptions.js → DeserializationOptions.mjs} +3 -3
  71. package/lib/esm/Esserializer/{SerializeOptions.js → SerializeOptions.mjs} +3 -3
  72. package/lib/esm/Esserializer/builtins.mjs +254 -0
  73. package/lib/esm/Esserializer/constant.mjs +28 -0
  74. package/lib/esm/Esserializer/deserializer.mjs +288 -0
  75. package/lib/esm/Esserializer/general.mjs +81 -0
  76. package/lib/esm/Esserializer/index.mjs +43 -0
  77. package/lib/esm/Esserializer/serializer.mjs +164 -0
  78. package/lib/esm/Evt.mjs +151 -0
  79. package/lib/esm/Hooks.mjs +1448 -0
  80. package/lib/esm/KissAction.mjs +4816 -0
  81. package/lib/esm/LoadPages.mjs +340 -0
  82. package/lib/esm/Persistor.mjs +180 -0
  83. package/lib/esm/ProcessPersistence.mjs +581 -0
  84. package/lib/esm/Store.mjs +4464 -0
  85. package/lib/esm/StoreException.mjs +153 -0
  86. package/lib/esm/StoreProvider.mjs +162 -0
  87. package/lib/esm/{UserException.js → UserException.mjs} +240 -246
  88. package/lib/esm/{Wait.js → Wait.mjs} +309 -309
  89. package/lib/esm/index.mjs +12 -9
  90. package/lib/esm/server.mjs +23 -0
  91. package/lib/esm/types/ClassPersistor.d.ts +143 -112
  92. package/lib/esm/types/ClassPersistor.d.ts.map +1 -1
  93. package/lib/esm/types/Esserializer/DeserializationOptions.d.ts +13 -6
  94. package/lib/esm/types/Esserializer/DeserializationOptions.d.ts.map +1 -1
  95. package/lib/esm/types/Esserializer/SerializeOptions.d.ts +11 -5
  96. package/lib/esm/types/Esserializer/SerializeOptions.d.ts.map +1 -1
  97. package/lib/esm/types/Esserializer/builtins.d.ts +36 -0
  98. package/lib/esm/types/Esserializer/builtins.d.ts.map +1 -0
  99. package/lib/esm/types/Esserializer/constant.d.ts +25 -49
  100. package/lib/esm/types/Esserializer/constant.d.ts.map +1 -1
  101. package/lib/esm/types/Esserializer/deserializer.d.ts +27 -17
  102. package/lib/esm/types/Esserializer/deserializer.d.ts.map +1 -1
  103. package/lib/esm/types/Esserializer/general.d.ts +28 -4
  104. package/lib/esm/types/Esserializer/general.d.ts.map +1 -1
  105. package/lib/esm/types/Esserializer/index.d.ts +33 -29
  106. package/lib/esm/types/Esserializer/index.d.ts.map +1 -1
  107. package/lib/esm/types/Esserializer/serializer.d.ts +14 -3
  108. package/lib/esm/types/Esserializer/serializer.d.ts.map +1 -1
  109. package/lib/esm/types/Evt.d.ts +124 -0
  110. package/lib/esm/types/Evt.d.ts.map +1 -0
  111. package/lib/esm/types/Hooks.d.ts +1174 -837
  112. package/lib/esm/types/Hooks.d.ts.map +1 -1
  113. package/lib/esm/types/KissAction.d.ts +5257 -1398
  114. package/lib/esm/types/KissAction.d.ts.map +1 -1
  115. package/lib/esm/types/LoadPages.d.ts +287 -0
  116. package/lib/esm/types/LoadPages.d.ts.map +1 -0
  117. package/lib/esm/types/Persistor.d.ts +187 -118
  118. package/lib/esm/types/Persistor.d.ts.map +1 -1
  119. package/lib/esm/types/ProcessPersistence.d.ts +197 -99
  120. package/lib/esm/types/ProcessPersistence.d.ts.map +1 -1
  121. package/lib/esm/types/Store.d.ts +2266 -1042
  122. package/lib/esm/types/Store.d.ts.map +1 -1
  123. package/lib/esm/types/StoreException.d.ts +97 -28
  124. package/lib/esm/types/StoreException.d.ts.map +1 -1
  125. package/lib/esm/types/StoreProvider.d.ts +95 -0
  126. package/lib/esm/types/StoreProvider.d.ts.map +1 -0
  127. package/lib/esm/types/UserException.d.ts +178 -169
  128. package/lib/esm/types/UserException.d.ts.map +1 -1
  129. package/lib/esm/types/index.d.ts +12 -9
  130. package/lib/esm/types/index.d.ts.map +1 -1
  131. package/lib/esm/types/server.d.ts +12 -0
  132. package/lib/esm/types/server.d.ts.map +1 -0
  133. package/lib/esm/types/utils.d.ts +15 -1
  134. package/lib/esm/types/utils.d.ts.map +1 -1
  135. package/lib/esm/utils.mjs +38 -0
  136. package/package.json +54 -30
  137. package/lib/cjs/UnmodifiableSetView.js +0 -53
  138. package/lib/cjs/types/UnmodifiableSetView.d.ts +0 -24
  139. package/lib/cjs/types/UnmodifiableSetView.d.ts.map +0 -1
  140. package/lib/esm/ClassPersistor.js +0 -112
  141. package/lib/esm/Esserializer/constant.js +0 -81
  142. package/lib/esm/Esserializer/deserializer.js +0 -307
  143. package/lib/esm/Esserializer/general.js +0 -34
  144. package/lib/esm/Esserializer/index.js +0 -39
  145. package/lib/esm/Esserializer/serializer.js +0 -130
  146. package/lib/esm/Hooks.js +0 -955
  147. package/lib/esm/KissAction.js +0 -1459
  148. package/lib/esm/Persistor.js +0 -113
  149. package/lib/esm/ProcessPersistence.js +0 -262
  150. package/lib/esm/Store.js +0 -1606
  151. package/lib/esm/StoreException.js +0 -69
  152. package/lib/esm/UnmodifiableSetView.js +0 -50
  153. package/lib/esm/types/UnmodifiableSetView.d.ts +0 -24
  154. package/lib/esm/types/UnmodifiableSetView.d.ts.map +0 -1
  155. package/lib/esm/utils.js +0 -3
@@ -1,50 +1,26 @@
1
- declare const ESSERIALIZER_NULL = "__ESSERIALIZER_NULL__";
2
- declare const ARRAY_FIELD = "ess_arr";
3
- declare const BOOLEAN_FIELD = "ess_bool";
4
- declare const CLASS_NAME_FIELD = "*type";
5
- declare const OPTIONS_FIELD = "ess_opt";
6
- declare const TIMESTAMP_FIELD = "ess_ts";
7
- declare const TO_STRING_FIELD = "ess_str";
8
- declare const BUILTIN_CLASS_INT8ARRAY = "Int8Array";
9
- declare const BUILTIN_CLASS_UINT8ARRAY = "Uint8Array";
10
- declare const BUILTIN_CLASS_UINT8CLAMPEDARRAY = "Uint8ClampedArray";
11
- declare const BUILTIN_CLASS_INT16ARRAY = "Int16Array";
12
- declare const BUILTIN_CLASS_UINT16ARRAY = "Uint16Array";
13
- declare const BUILTIN_CLASS_INT32ARRAY = "Int32Array";
14
- declare const BUILTIN_CLASS_UINT32ARRAY = "Uint32Array";
15
- declare const BUILTIN_CLASS_FLOAT32ARRAY = "Float32Array";
16
- declare const BUILTIN_CLASS_FLOAT64ARRAY = "Float64Array";
17
- declare const BUILTIN_CLASS_BIGINT64ARRAY = "BigInt64Array";
18
- declare const BUILTIN_CLASS_BIGUINT64ARRAY = "BigUint64Array";
19
- declare const BUILTIN_CLASS_ARRAYBUFFER = "ArrayBuffer";
20
- declare const BUILTIN_CLASS_SHAREDARRAYBUFFER = "SharedArrayBuffer";
21
- declare const BUILTIN_CLASS_BOOLEAN = "Boolean";
22
- declare const BUILTIN_CLASS_DATAVIEW = "DataView";
23
- declare const BUILTIN_CLASS_DATE = "Date";
24
- declare const BUILTIN_CLASS_INTL_COLLATOR = "Collator";
25
- declare const BUILTIN_CLASS_INTL_DATETIMEFORMAT = "DateTimeFormat";
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/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0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EAChB,CAAC"}
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
- declare function deserializeFromParsedObj(parsedObj: any, classes: Array<ClassOrEnum>, options: DeserializeOptions): any;
4
- declare function deserializeFromParsedObjWithClassMapping(parsedObj: any, classMapping: object, options?: DeserializeOptions): any;
5
- /**
6
- *
7
- * @param classes It's an array of Class definition. "any" is used in code only
8
- * because there is no TypeScript type definition for Class.
9
- */
10
- declare function getClassMappingFromClassArray(classes?: Array<any>): object;
11
- /**
12
- *
13
- * @param classObj It's a Class definition. "any" is used in code only
14
- * because there is no TypeScript type definition for Class.
15
- */
16
- declare function getParentClassName(classObj: any): string;
17
- export { deserializeFromParsedObj, deserializeFromParsedObjWithClassMapping, getClassMappingFromClassArray, getParentClassName };
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;AAgDhC,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAI1D,iBAAS,wBAAwB,CAC/B,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,KAAK,CAAC,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@@ -1,5 +1,29 @@
1
- declare function notObject(target: any): boolean;
2
- declare function getValueFromToStringResult(result: string): number | null;
3
- declare function isClass(target: any): boolean;
4
- export { getValueFromToStringResult, notObject, isClass };
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":"AAGA,iBAAS,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAEvC;AAED,iBAAS,0BAA0B,CAAC,MAAM,EAAE,MAAM,iBAWjD;AAMD,iBAAS,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAYrC;AAED,OAAO,EACL,0BAA0B,EAC1B,SAAS,EACT,OAAO,EACR,CAAC"}
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"}
@@ -1,30 +1,34 @@
1
- import DeserializeOptions from './DeserializationOptions';
2
- import SerializeOptions from './SerializeOptions';
3
- export declare type ClassOrEnum = {
4
- new (...args: any[]): any;
5
- } | object;
6
- export declare class ESSerializer {
7
- private static registeredClasses;
8
- /**
9
- * Globally register classes or enums.
10
- */
11
- static registerClasses(classesOrEnums: Array<ClassOrEnum>): void;
12
- static registerClass(classOrEnum: ClassOrEnum): void;
13
- /**
14
- * Clear all registered classes.
15
- */
16
- static clearRegisteredClasses(): void;
17
- /**
18
- * @param target
19
- * @param options Serialization options
20
- */
21
- static serialize(target: any, options?: SerializeOptions): string;
22
- /**
23
- * @param serializedText
24
- * @param classes
25
- * because there is no TypeScript type definition for Class.
26
- * @param options Deserialization options
27
- */
28
- static deserialize(serializedText: string, classes?: Array<ClassOrEnum>, options?: DeserializeOptions): any;
29
- }
1
+ import DeserializeOptions from './DeserializationOptions';
2
+ import SerializeOptions from './SerializeOptions';
3
+ export type ClassOrEnum = {
4
+ new (...args: any[]): any;
5
+ } | object;
6
+ /**
7
+ * Serializes values into JSON text, keeping their classes, and deserializes them back
8
+ * into instances of those classes. Also supports built-in types JSON doesn't, like
9
+ * `undefined`, `NaN`, BigInt, Date, Map, Set, typed arrays, errors and Intl objects.
10
+ */
11
+ export declare class ESSerializer {
12
+ /** Classes available to every `deserialize` call, in addition to the ones passed to it. */
13
+ private static registeredClasses;
14
+ /** Globally registers classes or enums. */
15
+ static registerClasses(classesOrEnums: Array<ClassOrEnum>): void;
16
+ /** Globally registers a class or enum. */
17
+ static registerClass(classOrEnum: ClassOrEnum): void;
18
+ /** Clears all globally registered classes. */
19
+ static clearRegisteredClasses(): void;
20
+ /**
21
+ * Converts `target` into JSON text. The `target` is not changed.
22
+ * @param target The value to serialize.
23
+ * @param options Serialization options.
24
+ */
25
+ static serialize(target: any, options?: SerializeOptions): string;
26
+ /**
27
+ * Converts JSON text created by `serialize` back into the original value.
28
+ * @param serializedText The JSON text.
29
+ * @param classes Classes needed to deserialize the text, in addition to the registered ones.
30
+ * @param options Deserialization options.
31
+ */
32
+ static deserialize(serializedText: string, classes?: Array<ClassOrEnum>, options?: DeserializeOptions): any;
33
+ }
30
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAKlD,oBAAY,WAAW,GAAG;IAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAAE,GAAG,MAAM,CAAC;AAEhE,qBAAa,YAAY;IAEvB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA0B;IAE1D;;OAEG;WACW,eAAe,CAAC,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC;WAIlD,aAAa,CAAC,WAAW,EAAE,WAAW;IAIpD;;OAEG;WACW,sBAAsB;IAIpC;;;OAGG;WACW,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM;IAI5E;;;;;OAKG;WACW,WAAW,CACvB,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,KAAK,CAAC,WAAW,CAAM,EAChC,OAAO,GAAE,kBAAuB,GAAG,GAAG;CAQzC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAKlD,MAAM,MAAM,WAAW,GAAG;IAAE,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAAE,GAAG,MAAM,CAAC;AAEhE;;;;GAIG;AACH,qBAAa,YAAY;IAEvB,2FAA2F;IAC3F,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA0B;IAE1D,2CAA2C;WAC7B,eAAe,CAAC,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC;IAIhE,0CAA0C;WAC5B,aAAa,CAAC,WAAW,EAAE,WAAW;IAIpD,8CAA8C;WAChC,sBAAsB;IAIpC;;;;OAIG;WACW,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM;IAI5E;;;;;OAKG;WACW,WAAW,CACvB,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,KAAK,CAAC,WAAW,CAAM,EAChC,OAAO,GAAE,kBAAuB,GAAG,GAAG;CAQzC"}
@@ -1,4 +1,15 @@
1
- import SerializeOptions from './SerializeOptions';
2
- declare function getSerializeValueWithClassName(target: any, options?: SerializeOptions): any;
3
- export { getSerializeValueWithClassName };
1
+ import SerializeOptions from './SerializeOptions';
2
+ /**
3
+ * Converts `target` into a plain JSON-compatible value. Objects get a `*type` field with
4
+ * their class name, so that they can be deserialized back into instances of that class.
5
+ *
6
+ * The `options` apply only to the top-level object, not to nested ones.
7
+ * The `target` itself is never changed.
8
+ *
9
+ * Throws for values that can't be deserialized back: functions and symbols (except as
10
+ * object properties, which are skipped), circular references, and built-in classes that
11
+ * are not supported (like `WeakMap` or `Promise`).
12
+ */
13
+ declare function getSerializeValueWithClassName(target: any, options?: SerializeOptions): any;
14
+ export { getSerializeValueWithClassName };
4
15
  //# sourceMappingURL=serializer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/serializer.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AA6BlD,iBAAS,8BAA8B,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAE,gBAAqB,GAAG,GAAG,CA4BxF;AAyGD,OAAO,EACL,8BAA8B,EAC/B,CAAC"}
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../../../src/Esserializer/serializer.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAclD;;;;;;;;;;GAUG;AACH,iBAAS,8BAA8B,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAE,gBAAqB,GAAG,GAAG,CAExF;AA8KD,OAAO,EACL,8BAA8B,EAC/B,CAAC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * An event: a one-time notification kept in the store state, for an action to ask the UI to
3
+ * do something once, that is not a state change: scroll a list to the top, clear or focus an
4
+ * input, open a dialog. The UI keeps these things itself (DOM elements, refs, scroll
5
+ * positions), so the reducer can't reach them.
6
+ *
7
+ * Name event fields with the `Evt` suffix, like `scrollToTopEvt`. In the initial state, use
8
+ * `Evt.spent()`, an event that was already used, so that nothing fires when the app starts.
9
+ * Actions then put a new event in the state:
10
+ *
11
+ * ```ts
12
+ * class State {
13
+ * constructor(
14
+ * readonly messages: readonly Message[],
15
+ * readonly scrollToTopEvt: Evt, // A boolean event.
16
+ * readonly changeTextEvt: Evt<string>, // An event with a value.
17
+ * ) {}
18
+ *
19
+ * static initialState = new State([], Evt.spent(), Evt.spent());
20
+ * }
21
+ *
22
+ * class ScrollFeedToTop extends Action {
23
+ * reduce() { return this.state.copy({ scrollToTopEvt: new Evt() }); }
24
+ * }
25
+ *
26
+ * class ChangeText extends Action {
27
+ * async reduce() {
28
+ * const text = await api.fetchText();
29
+ * return (state: State) => state.copy({ changeTextEvt: new Evt(text) });
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * Components handle the event with the `useEvent` hook (or `useLayoutEvent`), which calls the
35
+ * callback once per event, with its value, and then marks the event as **spent**:
36
+ *
37
+ * ```tsx
38
+ * useEvent((state: State) => state.scrollToTopEvt, () => listRef.current?.scrollTo({ top: 0 }));
39
+ * useEvent((state: State) => state.changeTextEvt, (text) => { inputRef.current!.value = text; });
40
+ * ```
41
+ *
42
+ * `new Evt()` is a boolean event, whose `value` is `true`. `new Evt(value)` holds a value of
43
+ * any type. Each new event is a new object, so a new event always fires, even if its value is
44
+ * the same as the previous one. Reading `value` doesn't spend the event.
45
+ *
46
+ * The event object itself is immutable: the store keeps which events were spent (see
47
+ * `store.isEventSpent`). So the state stays immutable, and two stores that share the same
48
+ * state (in two tests, for example) each spend the event on their own.
49
+ *
50
+ * Each event is handled by one component only: the first one whose effect runs. For two
51
+ * components to react, create two events in the state. Or use `EvtState`, when it's fine to
52
+ * miss events that happen while the component is not mounted.
53
+ *
54
+ * Persistence: the `ClassPersistor` saves events as spent, and restores them as `Evt.spent()`,
55
+ * so an old event doesn't fire when the app starts. A custom persistor must do the same: never
56
+ * save events, or restore them as `Evt.spent()`.
57
+ *
58
+ * You don't need events when:
59
+ * - The component dispatched the action itself. It can wait for the action, and then act:
60
+ * `await dispatchAndWait(new SendMessage(text)); inputRef.current!.value = '';`
61
+ * - There's already a state change to react to. Do it in an effect: for example, scroll to
62
+ * the end when a message arrives: `useEffect(() => scrollToEnd(), [messages.length])`.
63
+ */
64
+ export declare class Evt<T = true> {
65
+ /**
66
+ * The value of the event: `true` for a boolean event (`new Evt()`), or the value given to
67
+ * the constructor. Reading it doesn't spend the event. It's `undefined` for `Evt.spent()`,
68
+ * and for a restored (persisted) event. Components should get the value from `useEvent`,
69
+ * which also spends the event.
70
+ */
71
+ readonly value: T | undefined;
72
+ /**
73
+ * Creates a new, unspent event. `new Evt()` is a boolean event, whose `value` is `true`.
74
+ * `new Evt(value)` holds a value of any type.
75
+ */
76
+ constructor(value?: T);
77
+ /**
78
+ * An event that was already used, for the initial state. It never fires, in any store, and
79
+ * has no value (`undefined`).
80
+ */
81
+ static spent<T = true>(): Evt<T>;
82
+ toString(): string;
83
+ }
84
+ /**
85
+ * An event that is never spent, so that all the mounted components that use it react to it,
86
+ * but only while they are mounted. It's an alternative to `Evt`, which fires once, in one
87
+ * component only, even if the component mounts later.
88
+ *
89
+ * Each `new EvtState(value)` is a new object. A component that uses it with `useEvent` (or
90
+ * `useLayoutEvent`) is called when the state has a different `EvtState` than the last one the
91
+ * component saw. So it doesn't fire when the component mounts (or remounts), nor on unrelated
92
+ * re-renders, and it fires in every mounted component that uses it, even if the value is the
93
+ * same as the previous one.
94
+ *
95
+ * In the initial state, use `EvtState.spent()`, which never fires, so that nothing fires after
96
+ * a `logOut` puts the initial state back. The `ClassPersistor` also restores an `EvtState` as
97
+ * `EvtState.spent()`.
98
+ *
99
+ * ```ts
100
+ * class State {
101
+ * constructor(readonly highlightEvt: EvtState<string>) {}
102
+ * static initialState = new State(EvtState.spent());
103
+ * }
104
+ *
105
+ * // In an action:
106
+ * reduce() { return this.state.copy({ highlightEvt: new EvtState(this.itemId) }); }
107
+ *
108
+ * // In any number of components:
109
+ * useEvent((state: State) => state.highlightEvt, (itemId) => highlight(itemId));
110
+ * ```
111
+ */
112
+ export declare class EvtState<T = true> {
113
+ /**
114
+ * The value of the event: `true` for `new EvtState()`, or the value given to the constructor.
115
+ * It's `undefined` for `EvtState.spent()`, and for a restored (persisted) event.
116
+ */
117
+ readonly value: T | undefined;
118
+ /** Creates a new event. `new EvtState()` has the value `true`. `new EvtState(value)` holds a value. */
119
+ constructor(value?: T);
120
+ /** An event that never fires, for the initial state. It has no value (`undefined`). */
121
+ static spent<T = true>(): EvtState<T>;
122
+ toString(): string;
123
+ }
124
+ //# sourceMappingURL=Evt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Evt.d.ts","sourceRoot":"","sources":["../../../src/Evt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,qBAAa,GAAG,CAAC,CAAC,GAAG,IAAI;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAS9B;;;OAGG;gBACS,KAAK,CAAC,EAAE,CAAC;IAKrB;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IAKhC,QAAQ,IAAI,MAAM;CAGnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,QAAQ,CAAC,CAAC,GAAG,IAAI;IAE5B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAS9B,uGAAuG;gBAC3F,KAAK,CAAC,EAAE,CAAC;IAKrB,uFAAuF;IACvF,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;IAKrC,QAAQ,IAAI,MAAM;CAGnB"}