jitar 0.2.2 → 0.3.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 (206) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/package.json +7 -7
  3. package/dist/client.d.ts +0 -3
  4. package/dist/client.js +0 -24
  5. package/dist/core/ErrorManager.d.ts +0 -3
  6. package/dist/core/ErrorManager.js +0 -11
  7. package/dist/core/Implementation.d.ts +0 -10
  8. package/dist/core/Implementation.js +0 -39
  9. package/dist/core/Procedure.d.ts +0 -13
  10. package/dist/core/Procedure.js +0 -58
  11. package/dist/core/Segment.d.ts +0 -13
  12. package/dist/core/Segment.js +0 -36
  13. package/dist/core/SegmentBuilder.d.ts +0 -6
  14. package/dist/core/SegmentBuilder.js +0 -32
  15. package/dist/core/Version.d.ts +0 -13
  16. package/dist/core/Version.js +0 -50
  17. package/dist/core/definitions/AccessLevel.d.ts +0 -2
  18. package/dist/core/definitions/AccessLevel.js +0 -2
  19. package/dist/core/errors/ImplementationNotFound.d.ts +0 -3
  20. package/dist/core/errors/ImplementationNotFound.js +0 -6
  21. package/dist/core/errors/InvalidVersionNumber.d.ts +0 -3
  22. package/dist/core/errors/InvalidVersionNumber.js +0 -6
  23. package/dist/core/errors/MissingParameterValue.d.ts +0 -3
  24. package/dist/core/errors/MissingParameterValue.js +0 -6
  25. package/dist/core/errors/NotImplemented.d.ts +0 -3
  26. package/dist/core/errors/NotImplemented.js +0 -6
  27. package/dist/core/errors/ProcedureNotFound.d.ts +0 -3
  28. package/dist/core/errors/ProcedureNotFound.js +0 -6
  29. package/dist/core/errors/UnknownParameter.d.ts +0 -3
  30. package/dist/core/errors/UnknownParameter.js +0 -6
  31. package/dist/core/interfaces/Runner.d.ts +0 -4
  32. package/dist/core/interfaces/Runner.js +0 -1
  33. package/dist/core/reflection/ParameterParser.d.ts +0 -5
  34. package/dist/core/reflection/ParameterParser.js +0 -51
  35. package/dist/core/reflection/ReflectionHelper.d.ts +0 -13
  36. package/dist/core/reflection/ReflectionHelper.js +0 -69
  37. package/dist/core/reflection/models/ReflectionField.d.ts +0 -8
  38. package/dist/core/reflection/models/ReflectionField.js +0 -14
  39. package/dist/core/reflection/models/ReflectionParameter.d.ts +0 -7
  40. package/dist/core/reflection/models/ReflectionParameter.js +0 -11
  41. package/dist/core/types/Component.d.ts +0 -5
  42. package/dist/core/types/Component.js +0 -1
  43. package/dist/core/types/FlexObject.d.ts +0 -4
  44. package/dist/core/types/FlexObject.js +0 -1
  45. package/dist/core/types/Module.d.ts +0 -3
  46. package/dist/core/types/Module.js +0 -1
  47. package/dist/core/types/SegmentImplementation.d.ts +0 -6
  48. package/dist/core/types/SegmentImplementation.js +0 -1
  49. package/dist/core/types/SegmentModule.d.ts +0 -5
  50. package/dist/core/types/SegmentModule.js +0 -1
  51. package/dist/core/types/SegmentProcedure.d.ts +0 -7
  52. package/dist/core/types/SegmentProcedure.js +0 -1
  53. package/dist/core/utils/FqnBuilder.d.ts +0 -3
  54. package/dist/core/utils/FqnBuilder.js +0 -5
  55. package/dist/hooks.d.ts +0 -2
  56. package/dist/hooks.js +0 -2
  57. package/dist/lib.d.ts +0 -31
  58. package/dist/lib.js +0 -27
  59. package/dist/runtime/ClientId.d.ts +0 -4
  60. package/dist/runtime/ClientId.js +0 -11
  61. package/dist/runtime/Gateway.d.ts +0 -10
  62. package/dist/runtime/Gateway.js +0 -3
  63. package/dist/runtime/LocalGateway.d.ts +0 -14
  64. package/dist/runtime/LocalGateway.js +0 -61
  65. package/dist/runtime/LocalNode.d.ts +0 -18
  66. package/dist/runtime/LocalNode.js +0 -75
  67. package/dist/runtime/LocalRepository.d.ts +0 -17
  68. package/dist/runtime/LocalRepository.js +0 -94
  69. package/dist/runtime/Node.d.ts +0 -8
  70. package/dist/runtime/Node.js +0 -3
  71. package/dist/runtime/NodeBalancer.d.ts +0 -10
  72. package/dist/runtime/NodeBalancer.js +0 -34
  73. package/dist/runtime/NodeMonitor.d.ts +0 -7
  74. package/dist/runtime/NodeMonitor.js +0 -38
  75. package/dist/runtime/Proxy.d.ts +0 -19
  76. package/dist/runtime/Proxy.js +0 -31
  77. package/dist/runtime/Remote.d.ts +0 -15
  78. package/dist/runtime/Remote.js +0 -100
  79. package/dist/runtime/RemoteGateway.d.ts +0 -11
  80. package/dist/runtime/RemoteGateway.js +0 -22
  81. package/dist/runtime/RemoteNode.d.ts +0 -12
  82. package/dist/runtime/RemoteNode.js +0 -29
  83. package/dist/runtime/RemoteRepository.d.ts +0 -14
  84. package/dist/runtime/RemoteRepository.js +0 -34
  85. package/dist/runtime/Repository.d.ts +0 -11
  86. package/dist/runtime/Repository.js +0 -3
  87. package/dist/runtime/Runtime.d.ts +0 -9
  88. package/dist/runtime/Runtime.js +0 -27
  89. package/dist/runtime/caching/CacheBuilder.d.ts +0 -6
  90. package/dist/runtime/caching/CacheBuilder.js +0 -249
  91. package/dist/runtime/caching/ImportRewriter.d.ts +0 -4
  92. package/dist/runtime/caching/ImportRewriter.js +0 -49
  93. package/dist/runtime/caching/RemoteBuilder.d.ts +0 -5
  94. package/dist/runtime/caching/RemoteBuilder.js +0 -31
  95. package/dist/runtime/caching/SourceAppender.d.ts +0 -5
  96. package/dist/runtime/caching/SourceAppender.js +0 -30
  97. package/dist/runtime/caching/definitions/Keywords.d.ts +0 -2
  98. package/dist/runtime/caching/definitions/Keywords.js +0 -2
  99. package/dist/runtime/caching/errors/InvalidSegmentFilename.d.ts +0 -3
  100. package/dist/runtime/caching/errors/InvalidSegmentFilename.js +0 -5
  101. package/dist/runtime/caching/errors/MissingModuleExport.d.ts +0 -3
  102. package/dist/runtime/caching/errors/MissingModuleExport.js +0 -5
  103. package/dist/runtime/caching/errors/SegmentFileNotLoaded.d.ts +0 -3
  104. package/dist/runtime/caching/errors/SegmentFileNotLoaded.js +0 -5
  105. package/dist/runtime/caching/errors/SegmentModuleNotLoaded.d.ts +0 -3
  106. package/dist/runtime/caching/errors/SegmentModuleNotLoaded.js +0 -5
  107. package/dist/runtime/caching/models/ApplicationModule.d.ts +0 -9
  108. package/dist/runtime/caching/models/ApplicationModule.js +0 -19
  109. package/dist/runtime/caching/models/Implementation.d.ts +0 -12
  110. package/dist/runtime/caching/models/Implementation.js +0 -27
  111. package/dist/runtime/caching/models/Procedure.d.ts +0 -9
  112. package/dist/runtime/caching/models/Procedure.js +0 -15
  113. package/dist/runtime/caching/models/Segment.d.ts +0 -10
  114. package/dist/runtime/caching/models/Segment.js +0 -16
  115. package/dist/runtime/caching/models/SegmentModule.d.ts +0 -10
  116. package/dist/runtime/caching/models/SegmentModule.js +0 -14
  117. package/dist/runtime/caching/types/SegmentFile.d.ts +0 -5
  118. package/dist/runtime/caching/types/SegmentFile.js +0 -1
  119. package/dist/runtime/caching/types/SegmentImportProperties.d.ts +0 -6
  120. package/dist/runtime/caching/types/SegmentImportProperties.js +0 -1
  121. package/dist/runtime/caching/types/SegmentImports.d.ts +0 -5
  122. package/dist/runtime/caching/types/SegmentImports.js +0 -1
  123. package/dist/runtime/errors/ClientNotFound.d.ts +0 -3
  124. package/dist/runtime/errors/ClientNotFound.js +0 -6
  125. package/dist/runtime/errors/FileNotFound.d.ts +0 -3
  126. package/dist/runtime/errors/FileNotFound.js +0 -6
  127. package/dist/runtime/errors/InvalidClientId.d.ts +0 -3
  128. package/dist/runtime/errors/InvalidClientId.js +0 -6
  129. package/dist/runtime/errors/InvalidJitarHooks.d.ts +0 -3
  130. package/dist/runtime/errors/InvalidJitarHooks.js +0 -6
  131. package/dist/runtime/errors/InvalidSegmentFile.d.ts +0 -3
  132. package/dist/runtime/errors/InvalidSegmentFile.js +0 -6
  133. package/dist/runtime/errors/ModuleNotLoaded.d.ts +0 -3
  134. package/dist/runtime/errors/ModuleNotLoaded.js +0 -6
  135. package/dist/runtime/errors/NoNodeAvailable.d.ts +0 -3
  136. package/dist/runtime/errors/NoNodeAvailable.js +0 -6
  137. package/dist/runtime/errors/RepositoryNotAvaiable.d.ts +0 -3
  138. package/dist/runtime/errors/RepositoryNotAvaiable.js +0 -6
  139. package/dist/runtime/errors/RuntimeNotAvailable.d.ts +0 -3
  140. package/dist/runtime/errors/RuntimeNotAvailable.js +0 -6
  141. package/dist/runtime/errors/SegmentNotFound.d.ts +0 -3
  142. package/dist/runtime/errors/SegmentNotFound.js +0 -6
  143. package/dist/runtime/hooks/dependencies.d.ts +0 -2
  144. package/dist/runtime/hooks/dependencies.js +0 -9
  145. package/dist/runtime/hooks/runtime.d.ts +0 -3
  146. package/dist/runtime/hooks/runtime.js +0 -14
  147. package/dist/runtime/interfaces/FileManager.d.ts +0 -11
  148. package/dist/runtime/interfaces/FileManager.js +0 -1
  149. package/dist/runtime/interfaces/HealthCheck.d.ts +0 -3
  150. package/dist/runtime/interfaces/HealthCheck.js +0 -1
  151. package/dist/runtime/interfaces/ProcedureContainer.d.ts +0 -5
  152. package/dist/runtime/interfaces/ProcedureContainer.js +0 -1
  153. package/dist/runtime/models/File.d.ts +0 -9
  154. package/dist/runtime/models/File.js +0 -14
  155. package/dist/runtime/serialization/ArrayBufferSerializer.d.ts +0 -10
  156. package/dist/runtime/serialization/ArrayBufferSerializer.js +0 -54
  157. package/dist/runtime/serialization/ArraySerializer.d.ts +0 -7
  158. package/dist/runtime/serialization/ArraySerializer.js +0 -15
  159. package/dist/runtime/serialization/ClassSerializer.d.ts +0 -10
  160. package/dist/runtime/serialization/ClassSerializer.js +0 -74
  161. package/dist/runtime/serialization/DateSerializer.d.ts +0 -9
  162. package/dist/runtime/serialization/DateSerializer.js +0 -21
  163. package/dist/runtime/serialization/MapSerializer.d.ts +0 -9
  164. package/dist/runtime/serialization/MapSerializer.js +0 -35
  165. package/dist/runtime/serialization/ObjectSerializer.d.ts +0 -9
  166. package/dist/runtime/serialization/ObjectSerializer.js +0 -21
  167. package/dist/runtime/serialization/SetSerializer.d.ts +0 -9
  168. package/dist/runtime/serialization/SetSerializer.js +0 -23
  169. package/dist/runtime/serialization/ValueSerializer.d.ts +0 -8
  170. package/dist/runtime/serialization/ValueSerializer.js +0 -69
  171. package/dist/runtime/serialization/errors/ClassNotFound.d.ts +0 -3
  172. package/dist/runtime/serialization/errors/ClassNotFound.js +0 -6
  173. package/dist/runtime/serialization/errors/InvalidClass.d.ts +0 -3
  174. package/dist/runtime/serialization/errors/InvalidClass.js +0 -6
  175. package/dist/runtime/serialization/errors/InvalidPropertyType.d.ts +0 -3
  176. package/dist/runtime/serialization/errors/InvalidPropertyType.js +0 -6
  177. package/dist/runtime/serialization/interfaces/Serializer.d.ts +0 -4
  178. package/dist/runtime/serialization/interfaces/Serializer.js +0 -1
  179. package/dist/runtime/serialization/types/SerializableObject.d.ts +0 -3
  180. package/dist/runtime/serialization/types/SerializableObject.js +0 -1
  181. package/dist/runtime/serialization/types/Serialized.d.ts +0 -5
  182. package/dist/runtime/serialization/types/Serialized.js +0 -1
  183. package/dist/runtime/serialization/types/SerializedArrayBuffer.d.ts +0 -6
  184. package/dist/runtime/serialization/types/SerializedArrayBuffer.js +0 -1
  185. package/dist/runtime/serialization/types/SerializedClass.d.ts +0 -8
  186. package/dist/runtime/serialization/types/SerializedClass.js +0 -1
  187. package/dist/runtime/serialization/types/SerializedDate.d.ts +0 -5
  188. package/dist/runtime/serialization/types/SerializedDate.js +0 -1
  189. package/dist/runtime/serialization/types/SerializedMap.d.ts +0 -8
  190. package/dist/runtime/serialization/types/SerializedMap.js +0 -1
  191. package/dist/runtime/serialization/types/SerializedObject.d.ts +0 -4
  192. package/dist/runtime/serialization/types/SerializedObject.js +0 -1
  193. package/dist/runtime/serialization/types/SerializedSet.d.ts +0 -5
  194. package/dist/runtime/serialization/types/SerializedSet.js +0 -1
  195. package/dist/runtime/serialization/types/TypedArray.d.ts +0 -2
  196. package/dist/runtime/serialization/types/TypedArray.js +0 -1
  197. package/dist/runtime/types/JitarHooks.d.ts +0 -6
  198. package/dist/runtime/types/JitarHooks.js +0 -1
  199. package/dist/runtime/types/ModuleImporter.d.ts +0 -3
  200. package/dist/runtime/types/ModuleImporter.js +0 -1
  201. package/dist/runtime/utils/ModuleAnalyser.d.ts +0 -7
  202. package/dist/runtime/utils/ModuleAnalyser.js +0 -34
  203. package/dist/runtime/utils/ModuleLoader.d.ts +0 -8
  204. package/dist/runtime/utils/ModuleLoader.js +0 -30
  205. package/dist/runtime/utils/UrlRewriter.d.ts +0 -4
  206. package/dist/runtime/utils/UrlRewriter.js +0 -36
@@ -1,74 +0,0 @@
1
- import ReflectionHelper from '../../core/reflection/ReflectionHelper.js';
2
- import ModuleLoader from '../utils/ModuleLoader.js';
3
- import ClassNotFound from './errors/ClassNotFound.js';
4
- import InvalidClass from './errors/InvalidClass.js';
5
- import InvalidPropertyType from './errors/InvalidPropertyType.js';
6
- import ValueSerializer from './ValueSerializer.js';
7
- class ClassSerializer {
8
- serialize(object) {
9
- const clazz = ReflectionHelper.getObjectClass(object);
10
- const classFields = ReflectionHelper.getObjectFields(object);
11
- const constructParameters = ReflectionHelper.getConstructorParameters(clazz);
12
- const name = clazz.name;
13
- const source = clazz.source || null;
14
- const args = [];
15
- const fields = {};
16
- for (const parameter of constructParameters) {
17
- const objectValue = object[parameter.name];
18
- const classFieldIndex = classFields.findIndex(field => field.name === parameter.name);
19
- if (classFieldIndex !== -1) {
20
- classFields.splice(classFieldIndex, 1);
21
- }
22
- args.push(ValueSerializer.serialize(objectValue));
23
- }
24
- for (const field of classFields) {
25
- if (field.canGetAndSet === false) {
26
- continue;
27
- }
28
- const objectValue = object[field.name];
29
- fields[field.name] = ValueSerializer.serialize(objectValue);
30
- }
31
- return { serialized: true, name: name, source: source, args: args, fields: fields };
32
- }
33
- async deserialize(object) {
34
- this.#validateSerializedClass(object);
35
- const clazz = await this.#loadClass(object.source, object.name);
36
- if (clazz === undefined) {
37
- throw new ClassNotFound(object.name);
38
- }
39
- if ((clazz instanceof Function) === false) {
40
- throw new InvalidClass(object.name);
41
- }
42
- const args = await Promise.all(object.args.map(async (value) => await ValueSerializer.deserialize(value)));
43
- const instance = ReflectionHelper.createInstance(clazz, args);
44
- for (const name in object.fields) {
45
- const fieldValue = object.fields[name];
46
- instance[name] = await ValueSerializer.deserialize(fieldValue);
47
- }
48
- return instance;
49
- }
50
- #validateSerializedClass(object) {
51
- if (typeof object.name !== 'string') {
52
- throw new InvalidPropertyType('class', 'name', 'string');
53
- }
54
- if (object.source !== null && typeof object.source !== 'string') {
55
- throw new InvalidPropertyType(`class '${object.name}'`, 'source', 'string | null');
56
- }
57
- if ((object.args instanceof Array) === false) {
58
- throw new InvalidPropertyType(`class '${object.name}'`, 'args', 'Array');
59
- }
60
- if ((object.fields instanceof Object) === false) {
61
- throw new InvalidPropertyType(`class '${object.name}'`, 'fields', 'Object');
62
- }
63
- }
64
- async #loadClass(source, name) {
65
- if (source === null) {
66
- const system = typeof window !== 'undefined' ? window : global;
67
- return system[name];
68
- }
69
- const module = await ModuleLoader.load(source);
70
- return module[name] ?? module.default;
71
- }
72
- }
73
- const instance = new ClassSerializer();
74
- export default instance;
@@ -1,9 +0,0 @@
1
- import Serializer from './interfaces/Serializer.js';
2
- import SerializedDate from './types/SerializedDate.js';
3
- declare class DateSerializer implements Serializer {
4
- #private;
5
- serialize(date: Date): SerializedDate;
6
- deserialize(serializedDate: SerializedDate): Promise<Date>;
7
- }
8
- declare const instance: DateSerializer;
9
- export default instance;
@@ -1,21 +0,0 @@
1
- import InvalidPropertyType from './errors/InvalidPropertyType.js';
2
- class DateSerializer {
3
- serialize(date) {
4
- return { serialized: true, name: 'Date', value: date.toISOString() };
5
- }
6
- async deserialize(serializedDate) {
7
- this.#validateDate(serializedDate);
8
- return new Date(serializedDate.value);
9
- }
10
- #validateDate(serializedDate) {
11
- if (typeof serializedDate.value !== 'string') {
12
- throw new InvalidPropertyType('date', 'value', 'string');
13
- }
14
- const date = Date.parse(serializedDate.value);
15
- if (Number.isNaN(date)) {
16
- throw new InvalidPropertyType('date', 'value', 'date');
17
- }
18
- }
19
- }
20
- const instance = new DateSerializer();
21
- export default instance;
@@ -1,9 +0,0 @@
1
- import Serializer from './interfaces/Serializer.js';
2
- import SerializedMap from './types/SerializedMap.js';
3
- declare class MapSerializer implements Serializer {
4
- #private;
5
- serialize(map: Map<unknown, unknown>): SerializedMap;
6
- deserialize(object: SerializedMap): Promise<Map<unknown, unknown>>;
7
- }
8
- declare const instance: MapSerializer;
9
- export default instance;
@@ -1,35 +0,0 @@
1
- import InvalidPropertyType from './errors/InvalidPropertyType.js';
2
- import ValueSerializer from './ValueSerializer.js';
3
- class MapSerializer {
4
- serialize(map) {
5
- const keys = [];
6
- const values = [];
7
- for (const [key, value] of map) {
8
- keys.push(ValueSerializer.serialize(key));
9
- values.push(ValueSerializer.serialize(value));
10
- }
11
- return { serialized: true, name: 'Map', entries: { keys: keys, values: values } };
12
- }
13
- async deserialize(object) {
14
- this.#validateSerializedMap(object);
15
- const keys = object.entries.keys;
16
- const values = object.entries.values;
17
- const result = new Map();
18
- for (let index = 0; index < keys.length; index++) {
19
- const key = await ValueSerializer.deserialize(keys[index]);
20
- const value = await ValueSerializer.deserialize(values[index]);
21
- result.set(key, value);
22
- }
23
- return result;
24
- }
25
- #validateSerializedMap(object) {
26
- if ((object.entries?.keys instanceof Array) === false) {
27
- throw new InvalidPropertyType('map', 'entries.keys', 'Array');
28
- }
29
- if ((object.entries?.values instanceof Array) === false) {
30
- throw new InvalidPropertyType('map', 'entries.values', 'Array');
31
- }
32
- }
33
- }
34
- const instance = new MapSerializer();
35
- export default instance;
@@ -1,9 +0,0 @@
1
- import Serializer from './interfaces/Serializer.js';
2
- import SerializableObject from './types/SerializableObject.js';
3
- import SerializedObject from './types/SerializedObject.js';
4
- declare class ObjectSerializer implements Serializer {
5
- serialize(object: SerializableObject): SerializedObject;
6
- deserialize(object: SerializedObject): Promise<SerializableObject>;
7
- }
8
- declare const instance: ObjectSerializer;
9
- export default instance;
@@ -1,21 +0,0 @@
1
- import ValueSerializer from './ValueSerializer.js';
2
- class ObjectSerializer {
3
- serialize(object) {
4
- const result = {};
5
- for (const key in object) {
6
- const value = object[key];
7
- result[key] = ValueSerializer.serialize(value);
8
- }
9
- return result;
10
- }
11
- async deserialize(object) {
12
- const result = {};
13
- for (const key in object) {
14
- const value = object[key];
15
- result[key] = await ValueSerializer.deserialize(value);
16
- }
17
- return result;
18
- }
19
- }
20
- const instance = new ObjectSerializer();
21
- export default instance;
@@ -1,9 +0,0 @@
1
- import Serializer from './interfaces/Serializer.js';
2
- import SerializedSet from './types/SerializedSet.js';
3
- declare class SetSerializer implements Serializer {
4
- #private;
5
- serialize(set: Set<unknown>): SerializedSet;
6
- deserialize(object: SerializedSet): Promise<Set<unknown>>;
7
- }
8
- declare const instance: SetSerializer;
9
- export default instance;
@@ -1,23 +0,0 @@
1
- import InvalidPropertyType from './errors/InvalidPropertyType.js';
2
- import ValueSerializer from './ValueSerializer.js';
3
- class SetSerializer {
4
- serialize(set) {
5
- const values = [];
6
- for (const value of set.values()) {
7
- values.push(ValueSerializer.serialize(value));
8
- }
9
- return { serialized: true, name: 'Set', values: values };
10
- }
11
- async deserialize(object) {
12
- this.#validateSerializedSet(object);
13
- const values = await Promise.all(object.values.map(async (value) => await ValueSerializer.deserialize(value)));
14
- return new Set([...values]);
15
- }
16
- #validateSerializedSet(object) {
17
- if ((object.values instanceof Array) === false) {
18
- throw new InvalidPropertyType('set', 'values', 'Array');
19
- }
20
- }
21
- }
22
- const instance = new SetSerializer();
23
- export default instance;
@@ -1,8 +0,0 @@
1
- import Serializer from './interfaces/Serializer.js';
2
- declare class ValueSerializer implements Serializer {
3
- #private;
4
- serialize(value: unknown): unknown;
5
- deserialize(value: unknown): Promise<unknown>;
6
- }
7
- declare const instance: ValueSerializer;
8
- export default instance;
@@ -1,69 +0,0 @@
1
- import ReflectionHelper from '../../core/reflection/ReflectionHelper.js';
2
- import ArrayBufferSerializer from './ArrayBufferSerializer.js';
3
- import ArraySerializer from './ArraySerializer.js';
4
- import ClassSerializer from './ClassSerializer.js';
5
- import MapSerializer from './MapSerializer.js';
6
- import ObjectSerializer from './ObjectSerializer.js';
7
- import SetSerializer from './SetSerializer.js';
8
- import DateSerializer from './DateSerializer.js';
9
- class ValueSerializer {
10
- serialize(value) {
11
- if (this.#isTypedArray(value)) {
12
- return ArrayBufferSerializer.serialize(value);
13
- }
14
- else if (value instanceof Array) {
15
- return ArraySerializer.serialize(value);
16
- }
17
- else if (value instanceof Map) {
18
- return MapSerializer.serialize(value);
19
- }
20
- else if (value instanceof Set) {
21
- return SetSerializer.serialize(value);
22
- }
23
- if (value instanceof Date) {
24
- return DateSerializer.serialize(value);
25
- }
26
- else if (value instanceof Error) {
27
- return ClassSerializer.serialize(value);
28
- }
29
- else if (value instanceof Object) {
30
- return ReflectionHelper.isClassObject(value)
31
- ? ClassSerializer.serialize(value)
32
- : ObjectSerializer.serialize(value);
33
- }
34
- return value;
35
- }
36
- async deserialize(value) {
37
- if ((value instanceof Object) === false) {
38
- return value;
39
- }
40
- if (value instanceof Array) {
41
- return await ArraySerializer.deserialize(value);
42
- }
43
- if (value.serialized !== true) {
44
- return await ObjectSerializer.deserialize(value);
45
- }
46
- switch (value.name) {
47
- case 'Map': return await MapSerializer.deserialize(value);
48
- case 'Set': return await SetSerializer.deserialize(value);
49
- case 'Date': return await DateSerializer.deserialize(value);
50
- case 'ArrayBuffer': return await ArrayBufferSerializer.deserialize(value);
51
- default: return await ClassSerializer.deserialize(value);
52
- }
53
- }
54
- #isTypedArray(value) {
55
- return (value instanceof Int8Array)
56
- || (value instanceof Uint8Array)
57
- || (value instanceof Uint8ClampedArray)
58
- || (value instanceof Int16Array)
59
- || (value instanceof Uint16Array)
60
- || (value instanceof Int32Array)
61
- || (value instanceof Uint32Array)
62
- || (value instanceof Float32Array)
63
- || (value instanceof Float64Array)
64
- || (value instanceof BigInt64Array)
65
- || (value instanceof BigUint64Array);
66
- }
67
- }
68
- const instance = new ValueSerializer();
69
- export default instance;
@@ -1,3 +0,0 @@
1
- export default class ClassNotFound extends Error {
2
- constructor(name: string);
3
- }
@@ -1,6 +0,0 @@
1
- export default class ClassNotFound extends Error {
2
- constructor(name) {
3
- super(`The class '${name}' could not be found`);
4
- }
5
- }
6
- ClassNotFound.source = '/jitar/runtime/serialization/errors/ClassNotFound.js';
@@ -1,3 +0,0 @@
1
- export default class InvalidClass extends Error {
2
- constructor(name: string);
3
- }
@@ -1,6 +0,0 @@
1
- export default class InvalidClass extends Error {
2
- constructor(name) {
3
- super(`The class '${name}' is invalid`);
4
- }
5
- }
6
- InvalidClass.source = '/jitar/runtime/serialization/errors/InvalidClass.js';
@@ -1,3 +0,0 @@
1
- export default class InvalidPropertyType extends Error {
2
- constructor(typeName: string, propertyName: string, expectedType: string);
3
- }
@@ -1,6 +0,0 @@
1
- export default class InvalidPropertyType extends Error {
2
- constructor(typeName, propertyName, expectedType) {
3
- super(`The ${typeName} property '${propertyName}' has an invalid type (expected '${expectedType}')`);
4
- }
5
- }
6
- InvalidPropertyType.source = '/jitar/runtime/serialization/errors/InvalidPropertyType.js';
@@ -1,4 +0,0 @@
1
- export default interface Serializer {
2
- serialize(value: unknown): unknown;
3
- deserialize(value: unknown): Promise<unknown>;
4
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import FlexObject from '../../../core/types/FlexObject.js';
2
- type SerializableObject = FlexObject;
3
- export default SerializableObject;
@@ -1,5 +0,0 @@
1
- type Serialized = {
2
- serialized: boolean;
3
- name: string;
4
- };
5
- export default Serialized;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import Serialized from './Serialized.js';
2
- type SerializedArrayBuffer = Serialized & {
3
- type: string;
4
- bytes: number[];
5
- };
6
- export default SerializedArrayBuffer;
@@ -1,8 +0,0 @@
1
- import FlexObject from '../../../core/types/FlexObject.js';
2
- import Serialized from './Serialized.js';
3
- type SerializedClass = Serialized & {
4
- source: string | null;
5
- args: unknown[];
6
- fields: FlexObject;
7
- };
8
- export default SerializedClass;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import Serialized from './Serialized.js';
2
- type SerializedDate = Serialized & {
3
- value: string;
4
- };
5
- export default SerializedDate;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import Serialized from './Serialized.js';
2
- type SerializedMap = Serialized & {
3
- entries: {
4
- keys: unknown[];
5
- values: unknown[];
6
- };
7
- };
8
- export default SerializedMap;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- type SerializedObject = {
2
- [key: string]: unknown;
3
- };
4
- export default SerializedObject;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import Serialized from './Serialized.js';
2
- type SerializedSet = Serialized & {
3
- values: unknown[];
4
- };
5
- export default SerializedSet;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
2
- export default TypedArray;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import Runtime from '../Runtime.js';
2
- type JitarHooks = {
3
- setRuntime: (runtime: Runtime) => void;
4
- setDependencyLoader: (loader: Function) => void;
5
- };
6
- export default JitarHooks;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import Module from '../../core/types/Module.js';
2
- type ModuleImporter = (name: string) => Promise<Module>;
3
- export default ModuleImporter;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import Module from '../../core/types/Module.js';
2
- export default class ModuleAnalyser {
3
- #private;
4
- static filterObjects(module: Module): Map<string, Object>;
5
- static filterFunctions(module: Module): Map<string, Function>;
6
- static filterClasses(module: Module): Map<string, Function>;
7
- }
@@ -1,34 +0,0 @@
1
- export default class ModuleAnalyser {
2
- static filterObjects(module) {
3
- return this.#filterexported(module, Object);
4
- }
5
- static filterFunctions(module) {
6
- const functions = this.#filterexported(module, Function);
7
- return this.#filterFunctionTypes(functions, false);
8
- }
9
- static filterClasses(module) {
10
- const functions = this.#filterexported(module, Function);
11
- return this.#filterFunctionTypes(functions, true);
12
- }
13
- static #filterexported(module, type) {
14
- const keys = Object.keys(module);
15
- const filtered = new Map();
16
- for (const key of keys) {
17
- const exported = module[key];
18
- if (exported instanceof type) {
19
- filtered.set(key, exported);
20
- }
21
- }
22
- return filtered;
23
- }
24
- static #filterFunctionTypes(functions, filterClasses) {
25
- const filtered = new Map();
26
- for (const [key, value] of functions) {
27
- const code = value.toString();
28
- if (code.startsWith('class') === filterClasses) {
29
- filtered.set(key, value);
30
- }
31
- }
32
- return filtered;
33
- }
34
- }
@@ -1,8 +0,0 @@
1
- import Module from '../../core/types/Module.js';
2
- import ModuleImporter from '../types/ModuleImporter.js';
3
- export default class ModuleLoader {
4
- static setBaseUrl(baseUrl: string): void;
5
- static setImporter(importer: ModuleImporter): void;
6
- static load(url: string): Promise<Module>;
7
- static import(specifier: string): Promise<import("../../core/types/FlexObject.js").default>;
8
- }
@@ -1,30 +0,0 @@
1
- import ModuleNotLoaded from '../errors/ModuleNotLoaded.js';
2
- import UrlRewriter from './UrlRewriter.js';
3
- let _baseUrl;
4
- let _import = async (name) => { return import(name); };
5
- export default class ModuleLoader {
6
- static setBaseUrl(baseUrl) {
7
- _baseUrl = baseUrl;
8
- }
9
- static setImporter(importer) {
10
- _import = importer;
11
- }
12
- static async load(url) {
13
- if (url.startsWith('/jitar')) {
14
- url = `../..${url}`;
15
- }
16
- if (_baseUrl !== undefined && url.startsWith(_baseUrl) === false) {
17
- url = UrlRewriter.addBase(url, _baseUrl);
18
- }
19
- return this.import(url);
20
- }
21
- static async import(specifier) {
22
- try {
23
- return await _import(specifier);
24
- }
25
- catch (error) {
26
- const message = error instanceof Error ? error.message : String(error);
27
- throw new ModuleNotLoaded(specifier, message);
28
- }
29
- }
30
- }
@@ -1,4 +0,0 @@
1
- export default class UrlRewriter {
2
- #private;
3
- static addBase(url: string, base: string): string;
4
- }
@@ -1,36 +0,0 @@
1
- export default class UrlRewriter {
2
- static addBase(url, base) {
3
- url = this.#ensureStartsWithoutSlash(url);
4
- base = this.#assureEndWithSlash(base);
5
- return this.#translateRelativeParts(`${base}${url}`);
6
- }
7
- static #ensureStartsWithoutSlash(url) {
8
- if (url.startsWith('/')) {
9
- return url.substring(1);
10
- }
11
- return url;
12
- }
13
- static #assureEndWithSlash(base) {
14
- if (base.endsWith('/')) {
15
- return base;
16
- }
17
- return `${base}/`;
18
- }
19
- static #translateRelativeParts(url) {
20
- const parts = url.split('/');
21
- const translated = [];
22
- translated.push(parts[0]);
23
- for (let index = 1; index < parts.length; index++) {
24
- const part = parts[index].trim();
25
- if (part === '.' || part === '') {
26
- continue;
27
- }
28
- else if (part === '..') {
29
- translated.pop();
30
- continue;
31
- }
32
- translated.push(part);
33
- }
34
- return translated.join('/');
35
- }
36
- }