jitar 0.3.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/CHANGELOG.md +1 -94
  2. package/dist/client.js +1 -24
  3. package/dist/globals-d516de70.js +1 -0
  4. package/dist/lib.d.ts +309 -35
  5. package/dist/lib.js +1 -29
  6. package/dist/server.js +1 -0
  7. package/package.json +19 -12
  8. package/LICENCE +0 -23
  9. package/dist/client.d.ts +0 -3
  10. package/dist/core/Context.d.ts +0 -5
  11. package/dist/core/Context.js +0 -7
  12. package/dist/core/ErrorManager.d.ts +0 -3
  13. package/dist/core/ErrorManager.js +0 -11
  14. package/dist/core/Implementation.d.ts +0 -10
  15. package/dist/core/Implementation.js +0 -44
  16. package/dist/core/Procedure.d.ts +0 -13
  17. package/dist/core/Procedure.js +0 -58
  18. package/dist/core/Segment.d.ts +0 -13
  19. package/dist/core/Segment.js +0 -36
  20. package/dist/core/SegmentBuilder.d.ts +0 -6
  21. package/dist/core/SegmentBuilder.js +0 -32
  22. package/dist/core/Version.d.ts +0 -13
  23. package/dist/core/Version.js +0 -50
  24. package/dist/core/definitions/AccessLevel.d.ts +0 -2
  25. package/dist/core/definitions/AccessLevel.js +0 -2
  26. package/dist/core/errors/BadRequest.d.ts +0 -3
  27. package/dist/core/errors/BadRequest.js +0 -6
  28. package/dist/core/errors/Forbidden.d.ts +0 -3
  29. package/dist/core/errors/Forbidden.js +0 -6
  30. package/dist/core/errors/ImplementationNotFound.d.ts +0 -4
  31. package/dist/core/errors/ImplementationNotFound.js +0 -7
  32. package/dist/core/errors/InvalidVersionNumber.d.ts +0 -4
  33. package/dist/core/errors/InvalidVersionNumber.js +0 -7
  34. package/dist/core/errors/MissingParameterValue.d.ts +0 -4
  35. package/dist/core/errors/MissingParameterValue.js +0 -7
  36. package/dist/core/errors/NotFound.d.ts +0 -3
  37. package/dist/core/errors/NotFound.js +0 -6
  38. package/dist/core/errors/NotImplemented.d.ts +0 -3
  39. package/dist/core/errors/NotImplemented.js +0 -6
  40. package/dist/core/errors/PaymentRequired.d.ts +0 -3
  41. package/dist/core/errors/PaymentRequired.js +0 -6
  42. package/dist/core/errors/ProcedureNotFound.d.ts +0 -4
  43. package/dist/core/errors/ProcedureNotFound.js +0 -7
  44. package/dist/core/errors/Teapot.d.ts +0 -3
  45. package/dist/core/errors/Teapot.js +0 -6
  46. package/dist/core/errors/Unauthorized.d.ts +0 -3
  47. package/dist/core/errors/Unauthorized.js +0 -6
  48. package/dist/core/errors/UnknownParameter.d.ts +0 -4
  49. package/dist/core/errors/UnknownParameter.js +0 -7
  50. package/dist/core/interfaces/Runner.d.ts +0 -4
  51. package/dist/core/interfaces/Runner.js +0 -1
  52. package/dist/core/reflection/ParameterParser.d.ts +0 -5
  53. package/dist/core/reflection/ParameterParser.js +0 -51
  54. package/dist/core/reflection/ReflectionHelper.d.ts +0 -13
  55. package/dist/core/reflection/ReflectionHelper.js +0 -69
  56. package/dist/core/reflection/models/ReflectionField.d.ts +0 -8
  57. package/dist/core/reflection/models/ReflectionField.js +0 -14
  58. package/dist/core/reflection/models/ReflectionParameter.d.ts +0 -7
  59. package/dist/core/reflection/models/ReflectionParameter.js +0 -11
  60. package/dist/core/types/Component.d.ts +0 -5
  61. package/dist/core/types/Component.js +0 -1
  62. package/dist/core/types/FlexObject.d.ts +0 -4
  63. package/dist/core/types/FlexObject.js +0 -1
  64. package/dist/core/types/Module.d.ts +0 -3
  65. package/dist/core/types/Module.js +0 -1
  66. package/dist/core/types/SegmentImplementation.d.ts +0 -6
  67. package/dist/core/types/SegmentImplementation.js +0 -1
  68. package/dist/core/types/SegmentModule.d.ts +0 -5
  69. package/dist/core/types/SegmentModule.js +0 -1
  70. package/dist/core/types/SegmentProcedure.d.ts +0 -7
  71. package/dist/core/types/SegmentProcedure.js +0 -1
  72. package/dist/core/utils/FqnBuilder.d.ts +0 -3
  73. package/dist/core/utils/FqnBuilder.js +0 -5
  74. package/dist/hooks.d.ts +0 -2
  75. package/dist/hooks.js +0 -2
  76. package/dist/runtime/ClientId.d.ts +0 -4
  77. package/dist/runtime/ClientId.js +0 -11
  78. package/dist/runtime/Gateway.d.ts +0 -5
  79. package/dist/runtime/Gateway.js +0 -3
  80. package/dist/runtime/LocalGateway.d.ts +0 -14
  81. package/dist/runtime/LocalGateway.js +0 -61
  82. package/dist/runtime/LocalNode.d.ts +0 -18
  83. package/dist/runtime/LocalNode.js +0 -75
  84. package/dist/runtime/LocalRepository.d.ts +0 -17
  85. package/dist/runtime/LocalRepository.js +0 -94
  86. package/dist/runtime/Node.d.ts +0 -3
  87. package/dist/runtime/Node.js +0 -3
  88. package/dist/runtime/NodeBalancer.d.ts +0 -9
  89. package/dist/runtime/NodeBalancer.js +0 -34
  90. package/dist/runtime/NodeMonitor.d.ts +0 -7
  91. package/dist/runtime/NodeMonitor.js +0 -38
  92. package/dist/runtime/ProcedureRunner.d.ts +0 -9
  93. package/dist/runtime/ProcedureRunner.js +0 -11
  94. package/dist/runtime/ProcedureRuntime.d.ts +0 -14
  95. package/dist/runtime/ProcedureRuntime.js +0 -28
  96. package/dist/runtime/Proxy.d.ts +0 -18
  97. package/dist/runtime/Proxy.js +0 -33
  98. package/dist/runtime/Remote.d.ts +0 -15
  99. package/dist/runtime/Remote.js +0 -102
  100. package/dist/runtime/RemoteGateway.d.ts +0 -11
  101. package/dist/runtime/RemoteGateway.js +0 -22
  102. package/dist/runtime/RemoteNode.d.ts +0 -12
  103. package/dist/runtime/RemoteNode.js +0 -29
  104. package/dist/runtime/RemoteRepository.d.ts +0 -14
  105. package/dist/runtime/RemoteRepository.js +0 -34
  106. package/dist/runtime/Repository.d.ts +0 -11
  107. package/dist/runtime/Repository.js +0 -3
  108. package/dist/runtime/Runtime.d.ts +0 -9
  109. package/dist/runtime/Runtime.js +0 -27
  110. package/dist/runtime/caching/CacheBuilder.d.ts +0 -6
  111. package/dist/runtime/caching/CacheBuilder.js +0 -246
  112. package/dist/runtime/caching/ImportRewriter.d.ts +0 -4
  113. package/dist/runtime/caching/ImportRewriter.js +0 -58
  114. package/dist/runtime/caching/RemoteBuilder.d.ts +0 -5
  115. package/dist/runtime/caching/RemoteBuilder.js +0 -31
  116. package/dist/runtime/caching/SourceAppender.d.ts +0 -5
  117. package/dist/runtime/caching/SourceAppender.js +0 -30
  118. package/dist/runtime/caching/definitions/Keywords.d.ts +0 -2
  119. package/dist/runtime/caching/definitions/Keywords.js +0 -2
  120. package/dist/runtime/caching/errors/InvalidSegmentFilename.d.ts +0 -3
  121. package/dist/runtime/caching/errors/InvalidSegmentFilename.js +0 -5
  122. package/dist/runtime/caching/errors/MissingModuleExport.d.ts +0 -3
  123. package/dist/runtime/caching/errors/MissingModuleExport.js +0 -5
  124. package/dist/runtime/caching/errors/SegmentFileNotLoaded.d.ts +0 -3
  125. package/dist/runtime/caching/errors/SegmentFileNotLoaded.js +0 -5
  126. package/dist/runtime/caching/errors/SegmentModuleNotLoaded.d.ts +0 -3
  127. package/dist/runtime/caching/errors/SegmentModuleNotLoaded.js +0 -5
  128. package/dist/runtime/caching/models/ApplicationModule.d.ts +0 -10
  129. package/dist/runtime/caching/models/ApplicationModule.js +0 -19
  130. package/dist/runtime/caching/models/Implementation.d.ts +0 -12
  131. package/dist/runtime/caching/models/Implementation.js +0 -27
  132. package/dist/runtime/caching/models/Procedure.d.ts +0 -9
  133. package/dist/runtime/caching/models/Procedure.js +0 -15
  134. package/dist/runtime/caching/models/Segment.d.ts +0 -10
  135. package/dist/runtime/caching/models/Segment.js +0 -16
  136. package/dist/runtime/caching/models/SegmentModule.d.ts +0 -10
  137. package/dist/runtime/caching/models/SegmentModule.js +0 -14
  138. package/dist/runtime/caching/types/SegmentFile.d.ts +0 -5
  139. package/dist/runtime/caching/types/SegmentFile.js +0 -1
  140. package/dist/runtime/caching/types/SegmentImportProperties.d.ts +0 -6
  141. package/dist/runtime/caching/types/SegmentImportProperties.js +0 -1
  142. package/dist/runtime/caching/types/SegmentImports.d.ts +0 -5
  143. package/dist/runtime/caching/types/SegmentImports.js +0 -1
  144. package/dist/runtime/errors/ClientNotFound.d.ts +0 -3
  145. package/dist/runtime/errors/ClientNotFound.js +0 -6
  146. package/dist/runtime/errors/FileNotFound.d.ts +0 -3
  147. package/dist/runtime/errors/FileNotFound.js +0 -6
  148. package/dist/runtime/errors/InvalidClientId.d.ts +0 -3
  149. package/dist/runtime/errors/InvalidClientId.js +0 -6
  150. package/dist/runtime/errors/InvalidJitarHooks.d.ts +0 -3
  151. package/dist/runtime/errors/InvalidJitarHooks.js +0 -6
  152. package/dist/runtime/errors/InvalidSegmentFile.d.ts +0 -3
  153. package/dist/runtime/errors/InvalidSegmentFile.js +0 -6
  154. package/dist/runtime/errors/ModuleNotLoaded.d.ts +0 -3
  155. package/dist/runtime/errors/ModuleNotLoaded.js +0 -6
  156. package/dist/runtime/errors/NoNodeAvailable.d.ts +0 -3
  157. package/dist/runtime/errors/NoNodeAvailable.js +0 -6
  158. package/dist/runtime/errors/RepositoryNotAvaiable.d.ts +0 -3
  159. package/dist/runtime/errors/RepositoryNotAvaiable.js +0 -6
  160. package/dist/runtime/errors/RuntimeNotAvailable.d.ts +0 -3
  161. package/dist/runtime/errors/RuntimeNotAvailable.js +0 -6
  162. package/dist/runtime/errors/SegmentNotFound.d.ts +0 -3
  163. package/dist/runtime/errors/SegmentNotFound.js +0 -6
  164. package/dist/runtime/hooks/dependencies.d.ts +0 -2
  165. package/dist/runtime/hooks/dependencies.js +0 -9
  166. package/dist/runtime/hooks/runtime.d.ts +0 -3
  167. package/dist/runtime/hooks/runtime.js +0 -16
  168. package/dist/runtime/interfaces/FileManager.d.ts +0 -11
  169. package/dist/runtime/interfaces/FileManager.js +0 -1
  170. package/dist/runtime/interfaces/HealthCheck.d.ts +0 -3
  171. package/dist/runtime/interfaces/HealthCheck.js +0 -1
  172. package/dist/runtime/interfaces/Middleware.d.ts +0 -5
  173. package/dist/runtime/interfaces/Middleware.js +0 -1
  174. package/dist/runtime/middleware/CorsMiddleware.d.ts +0 -11
  175. package/dist/runtime/middleware/CorsMiddleware.js +0 -22
  176. package/dist/runtime/models/File.d.ts +0 -9
  177. package/dist/runtime/models/File.js +0 -14
  178. package/dist/runtime/serialization/ArrayBufferSerializer.d.ts +0 -10
  179. package/dist/runtime/serialization/ArrayBufferSerializer.js +0 -54
  180. package/dist/runtime/serialization/ArraySerializer.d.ts +0 -7
  181. package/dist/runtime/serialization/ArraySerializer.js +0 -15
  182. package/dist/runtime/serialization/ClassSerializer.d.ts +0 -10
  183. package/dist/runtime/serialization/ClassSerializer.js +0 -74
  184. package/dist/runtime/serialization/DateSerializer.d.ts +0 -9
  185. package/dist/runtime/serialization/DateSerializer.js +0 -21
  186. package/dist/runtime/serialization/MapSerializer.d.ts +0 -9
  187. package/dist/runtime/serialization/MapSerializer.js +0 -35
  188. package/dist/runtime/serialization/ObjectSerializer.d.ts +0 -9
  189. package/dist/runtime/serialization/ObjectSerializer.js +0 -21
  190. package/dist/runtime/serialization/SetSerializer.d.ts +0 -9
  191. package/dist/runtime/serialization/SetSerializer.js +0 -23
  192. package/dist/runtime/serialization/ValueSerializer.d.ts +0 -8
  193. package/dist/runtime/serialization/ValueSerializer.js +0 -69
  194. package/dist/runtime/serialization/errors/ClassNotFound.d.ts +0 -3
  195. package/dist/runtime/serialization/errors/ClassNotFound.js +0 -6
  196. package/dist/runtime/serialization/errors/InvalidClass.d.ts +0 -3
  197. package/dist/runtime/serialization/errors/InvalidClass.js +0 -6
  198. package/dist/runtime/serialization/errors/InvalidPropertyType.d.ts +0 -4
  199. package/dist/runtime/serialization/errors/InvalidPropertyType.js +0 -7
  200. package/dist/runtime/serialization/interfaces/Serializer.d.ts +0 -4
  201. package/dist/runtime/serialization/interfaces/Serializer.js +0 -1
  202. package/dist/runtime/serialization/types/SerializableObject.d.ts +0 -3
  203. package/dist/runtime/serialization/types/SerializableObject.js +0 -1
  204. package/dist/runtime/serialization/types/Serialized.d.ts +0 -5
  205. package/dist/runtime/serialization/types/Serialized.js +0 -1
  206. package/dist/runtime/serialization/types/SerializedArrayBuffer.d.ts +0 -6
  207. package/dist/runtime/serialization/types/SerializedArrayBuffer.js +0 -1
  208. package/dist/runtime/serialization/types/SerializedClass.d.ts +0 -8
  209. package/dist/runtime/serialization/types/SerializedClass.js +0 -1
  210. package/dist/runtime/serialization/types/SerializedDate.d.ts +0 -5
  211. package/dist/runtime/serialization/types/SerializedDate.js +0 -1
  212. package/dist/runtime/serialization/types/SerializedMap.d.ts +0 -8
  213. package/dist/runtime/serialization/types/SerializedMap.js +0 -1
  214. package/dist/runtime/serialization/types/SerializedObject.d.ts +0 -4
  215. package/dist/runtime/serialization/types/SerializedObject.js +0 -1
  216. package/dist/runtime/serialization/types/SerializedSet.d.ts +0 -5
  217. package/dist/runtime/serialization/types/SerializedSet.js +0 -1
  218. package/dist/runtime/serialization/types/TypedArray.d.ts +0 -2
  219. package/dist/runtime/serialization/types/TypedArray.js +0 -1
  220. package/dist/runtime/types/JitarHooks.d.ts +0 -6
  221. package/dist/runtime/types/JitarHooks.js +0 -1
  222. package/dist/runtime/types/ModuleImporter.d.ts +0 -3
  223. package/dist/runtime/types/ModuleImporter.js +0 -1
  224. package/dist/runtime/types/NextHandler.d.ts +0 -2
  225. package/dist/runtime/types/NextHandler.js +0 -1
  226. package/dist/runtime/utils/ModuleAnalyser.d.ts +0 -7
  227. package/dist/runtime/utils/ModuleAnalyser.js +0 -23
  228. package/dist/runtime/utils/ModuleLoader.d.ts +0 -8
  229. package/dist/runtime/utils/ModuleLoader.js +0 -30
  230. package/dist/runtime/utils/UrlRewriter.d.ts +0 -4
  231. package/dist/runtime/utils/UrlRewriter.js +0 -36
@@ -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,4 +0,0 @@
1
- import BadRequest from '../../../core/errors/BadRequest.js';
2
- export default class InvalidPropertyType extends BadRequest {
3
- constructor(typeName: string, propertyName: string, expectedType: string);
4
- }
@@ -1,7 +0,0 @@
1
- import BadRequest from '../../../core/errors/BadRequest.js';
2
- export default class InvalidPropertyType extends BadRequest {
3
- constructor(typeName, propertyName, expectedType) {
4
- super(`The ${typeName} property '${propertyName}' has an invalid type (expected '${expectedType}')`);
5
- }
6
- }
7
- 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,2 +0,0 @@
1
- type NextHandler = () => Promise<unknown>;
2
- export default NextHandler;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import { ReflectionModule, ReflectionFunction, ReflectionField, ReflectionClass } from 'jitar-reflection';
2
- export default class ModuleAnalyser {
3
- #private;
4
- static filterFields(module: ReflectionModule): Map<string, ReflectionField>;
5
- static filterFunctions(module: ReflectionModule): Map<string, ReflectionFunction>;
6
- static filterClasses(module: ReflectionModule): Map<string, ReflectionClass>;
7
- }
@@ -1,23 +0,0 @@
1
- import { ReflectionFunction, ReflectionField, ReflectionClass } from 'jitar-reflection';
2
- export default class ModuleAnalyser {
3
- static filterFields(module) {
4
- return this.#filterexported(module, ReflectionField);
5
- }
6
- static filterFunctions(module) {
7
- return this.#filterexported(module, ReflectionFunction);
8
- }
9
- static filterClasses(module) {
10
- return this.#filterexported(module, ReflectionClass);
11
- }
12
- static #filterexported(module, type) {
13
- const keys = [...module.exported.keys()];
14
- const filtered = new Map();
15
- for (const key of keys) {
16
- const member = module.getExported(key);
17
- if (member?.constructor.name === type.name) {
18
- filtered.set(key, member);
19
- }
20
- }
21
- return filtered;
22
- }
23
- }
@@ -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
- }