jitar 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/runtime/caching/CacheBuilder.js +5 -8
- package/dist/runtime/caching/RemoteBuilder.js +2 -2
- package/dist/runtime/caching/SourceAppender.js +1 -1
- package/dist/runtime/caching/models/ApplicationModule.d.ts +4 -3
- package/dist/runtime/caching/models/Implementation.d.ts +3 -3
- package/dist/runtime/caching/models/SegmentModule.d.ts +3 -3
- package/dist/runtime/utils/ModuleAnalyser.d.ts +4 -4
- package/dist/runtime/utils/ModuleAnalyser.js +9 -20
- package/package.json +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
3
|
|
|
4
|
+
## 0.3.4 (February 23, 2023)
|
|
5
|
+
|
|
6
|
+
New features:
|
|
7
|
+
- \[[`00a1f4f`](https://github.com/MaskingTechnology/jitar/commit/00a1f4f)] Use the advanced reflection library [basmasking](https://github.com/MaskingTechnology/jitar/pull/168)
|
|
8
|
+
|
|
9
|
+
## 0.3.3 (February 13, 2023)
|
|
10
|
+
|
|
11
|
+
New features:
|
|
12
|
+
- \[[`18d6a4a`](https://github.com/MaskingTechnology/jitar/commit/18d6a4a)] Extended options for CORS middleware [petermasking](https://github.com/MaskingTechnology/jitar/pull/133)
|
|
13
|
+
|
|
4
14
|
## 0.3.2 (February 10, 2023)
|
|
5
15
|
|
|
6
16
|
Fixes:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as AccessLevel from '../../core/definitions/AccessLevel.js';
|
|
2
2
|
import Version from '../../core/Version.js';
|
|
3
|
-
import ModuleLoader from '../utils/ModuleLoader.js';
|
|
4
3
|
import ModuleAnalyser from '../utils/ModuleAnalyser.js';
|
|
5
4
|
import SourceAppender from './SourceAppender.js';
|
|
6
5
|
import ImportRewriter from './ImportRewriter.js';
|
|
@@ -14,9 +13,11 @@ import SegmentFileNotLoaded from './errors/SegmentFileNotLoaded.js';
|
|
|
14
13
|
import SegmentModuleNotLoaded from './errors/SegmentModuleNotLoaded.js';
|
|
15
14
|
import MissingModuleExport from './errors/MissingModuleExport.js';
|
|
16
15
|
import InvalidSegmentFilename from './errors/InvalidSegmentFilename.js';
|
|
16
|
+
import { Reflector } from 'jitar-reflection';
|
|
17
17
|
const IGNORED_SOURCE_FILES = ['.min.js'];
|
|
18
18
|
const DEFAULT_ACCESS_LEVEL = AccessLevel.PRIVATE;
|
|
19
19
|
const DEFAULT_VERSION_NUMBER = Version.DEFAULT.toString();
|
|
20
|
+
const reflector = new Reflector();
|
|
20
21
|
export default class CacheBuilder {
|
|
21
22
|
#sourceManager;
|
|
22
23
|
#cacheManager;
|
|
@@ -81,7 +82,7 @@ export default class CacheBuilder {
|
|
|
81
82
|
const moduleName = this.#extractModuleName(absoluteLocation);
|
|
82
83
|
const implementations = new Map();
|
|
83
84
|
for (const [importKey, properties] of Object.entries(imports)) {
|
|
84
|
-
const executable = exports
|
|
85
|
+
const executable = exports.getExported(importKey);
|
|
85
86
|
if (executable === undefined) {
|
|
86
87
|
throw new MissingModuleExport(moduleName, importKey);
|
|
87
88
|
}
|
|
@@ -128,12 +129,8 @@ export default class CacheBuilder {
|
|
|
128
129
|
return new ApplicationModule(relativeLocation, classes, functions);
|
|
129
130
|
}
|
|
130
131
|
async #loadModule(filename) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
132
|
+
const code = await this.#sourceManager.getContent(filename);
|
|
133
|
+
return reflector.parse(code.toString());
|
|
137
134
|
}
|
|
138
135
|
async #buildSegmentCache(segments) {
|
|
139
136
|
const promises = segments.map(async (segment) => this.#buildSegmentModuleCache(segment));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AccessLevel from '../../core/definitions/AccessLevel.js';
|
|
2
|
-
import ReflectionHelper from '../../core/reflection/ReflectionHelper.js';
|
|
3
2
|
import * as Keywords from './definitions/Keywords.js';
|
|
3
|
+
import { ReflectionField } from 'jitar-reflection';
|
|
4
4
|
export default class RemoteBuilder {
|
|
5
5
|
static build(module) {
|
|
6
6
|
let code = this.#createRemoteImports();
|
|
@@ -17,7 +17,7 @@ export default class RemoteBuilder {
|
|
|
17
17
|
return `import { runProcedure } from "/jitar/hooks.js";\n`;
|
|
18
18
|
}
|
|
19
19
|
static #createRemoteCode(implementation, asDefault) {
|
|
20
|
-
const parameters =
|
|
20
|
+
const parameters = implementation.executable.parameters.filter(parameter => parameter instanceof ReflectionField);
|
|
21
21
|
const parameterNames = parameters.map(parameter => parameter.name);
|
|
22
22
|
const procedureName = implementation.executable.name;
|
|
23
23
|
const procedureFqn = implementation.fqn;
|
|
@@ -13,7 +13,7 @@ export default class SourceAppender {
|
|
|
13
13
|
const names = [];
|
|
14
14
|
for (const key of classes.keys()) {
|
|
15
15
|
const clazz = classes.get(key);
|
|
16
|
-
if (clazz
|
|
16
|
+
if (clazz === undefined) {
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
if (key !== Keywords.DEFAULT && key !== clazz.name) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ReflectionClass, ReflectionFunction } from 'jitar-reflection';
|
|
1
2
|
export default class ApplicationModule {
|
|
2
3
|
#private;
|
|
3
|
-
constructor(filename: string, classes: Map<string,
|
|
4
|
+
constructor(filename: string, classes: Map<string, ReflectionClass>, functions: Map<string, ReflectionFunction>);
|
|
4
5
|
get filename(): string;
|
|
5
|
-
get classes(): Map<string,
|
|
6
|
-
get functions(): Map<string,
|
|
6
|
+
get classes(): Map<string, ReflectionClass>;
|
|
7
|
+
get functions(): Map<string, ReflectionFunction>;
|
|
7
8
|
hasClasses(): boolean;
|
|
8
9
|
hasFunctions(): boolean;
|
|
9
10
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReflectionFunction } from 'jitar-reflection';
|
|
2
2
|
export default class Implementation {
|
|
3
3
|
#private;
|
|
4
|
-
constructor(module: string, name: string, access: string, version: string, executable:
|
|
4
|
+
constructor(module: string, name: string, access: string, version: string, executable: ReflectionFunction);
|
|
5
5
|
get id(): number;
|
|
6
6
|
get module(): string;
|
|
7
7
|
get name(): string;
|
|
8
8
|
get fqn(): string;
|
|
9
9
|
get access(): string;
|
|
10
10
|
get version(): string;
|
|
11
|
-
get executable():
|
|
11
|
+
get executable(): ReflectionFunction;
|
|
12
12
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Module from '../../../core/types/Module.js';
|
|
2
1
|
import Implementation from './Implementation.js';
|
|
2
|
+
import { ReflectionModule } from 'jitar-reflection';
|
|
3
3
|
export default class SegmentModule {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(filename: string, exports:
|
|
5
|
+
constructor(filename: string, exports: ReflectionModule, implementations: Map<string, Implementation>);
|
|
6
6
|
get filename(): string;
|
|
7
|
-
get exports():
|
|
7
|
+
get exports(): ReflectionModule;
|
|
8
8
|
get implementations(): Map<string, Implementation>;
|
|
9
9
|
getImportKeys(): string[];
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReflectionModule, ReflectionFunction, ReflectionField, ReflectionClass } from 'jitar-reflection';
|
|
2
2
|
export default class ModuleAnalyser {
|
|
3
3
|
#private;
|
|
4
|
-
static
|
|
5
|
-
static filterFunctions(module:
|
|
6
|
-
static filterClasses(module:
|
|
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
7
|
}
|
|
@@ -1,32 +1,21 @@
|
|
|
1
|
+
import { ReflectionFunction, ReflectionField, ReflectionClass } from 'jitar-reflection';
|
|
1
2
|
export default class ModuleAnalyser {
|
|
2
|
-
static
|
|
3
|
-
return this.#filterexported(module,
|
|
3
|
+
static filterFields(module) {
|
|
4
|
+
return this.#filterexported(module, ReflectionField);
|
|
4
5
|
}
|
|
5
6
|
static filterFunctions(module) {
|
|
6
|
-
|
|
7
|
-
return this.#filterFunctionTypes(functions, false);
|
|
7
|
+
return this.#filterexported(module, ReflectionFunction);
|
|
8
8
|
}
|
|
9
9
|
static filterClasses(module) {
|
|
10
|
-
|
|
11
|
-
return this.#filterFunctionTypes(functions, true);
|
|
10
|
+
return this.#filterexported(module, ReflectionClass);
|
|
12
11
|
}
|
|
13
12
|
static #filterexported(module, type) {
|
|
14
|
-
const keys =
|
|
13
|
+
const keys = [...module.exported.keys()];
|
|
15
14
|
const filtered = new Map();
|
|
16
15
|
for (const key of keys) {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
filtered.set(key,
|
|
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);
|
|
16
|
+
const member = module.getExported(key);
|
|
17
|
+
if (member?.constructor.name === type.name) {
|
|
18
|
+
filtered.set(key, member);
|
|
30
19
|
}
|
|
31
20
|
}
|
|
32
21
|
return filtered;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jitar",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Distributed runtime for JavaScript and TypeScript to chop monolithic applications into micros.",
|
|
5
5
|
"author": "Masking Technology <info@masking.tech> (https://jitar.dev)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,20 +13,22 @@
|
|
|
13
13
|
"./hooks.js": "./dist/hooks.js"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"test": "
|
|
17
|
-
"test-coverage": "
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test-coverage": "vitest run --coverage",
|
|
18
18
|
"lint": "eslint . --ext .ts",
|
|
19
19
|
"build": "tsc -p tsconfig.json",
|
|
20
20
|
"clean": "rm -rf dist build",
|
|
21
21
|
"release": "npm run clean && npm run build && npm publish"
|
|
22
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"jitar-reflection": "^0.3.4"
|
|
25
|
+
},
|
|
23
26
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@typescript-eslint/
|
|
26
|
-
"@
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
|
28
|
+
"@typescript-eslint/parser": "^5.52.0",
|
|
29
|
+
"@vitest/coverage-c8": "^0.28.5",
|
|
27
30
|
"eslint": "^8.34.0",
|
|
28
|
-
"
|
|
29
|
-
"ts-jest": "^29.0.5"
|
|
31
|
+
"vitest": "^0.28.5"
|
|
30
32
|
},
|
|
31
33
|
"engines": {
|
|
32
34
|
"node": ">=18.7"
|
|
@@ -49,5 +51,5 @@
|
|
|
49
51
|
"full stack",
|
|
50
52
|
"web applications"
|
|
51
53
|
],
|
|
52
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "8ae8248af1cc203f787ad13b4eee3a01f53feb69"
|
|
53
55
|
}
|