@opra/core 1.0.0-beta.3 → 1.0.0-beta.5
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/cjs/asset-cache.js +6 -0
- package/cjs/execution-context.js +1 -0
- package/cjs/service-base.js +9 -4
- package/esm/asset-cache.js +6 -0
- package/esm/execution-context.js +1 -0
- package/esm/service-base.js +9 -4
- package/package.json +2 -2
- package/types/asset-cache.d.ts +1 -0
- package/types/execution-context.d.ts +1 -0
- package/types/platform-adapter.d.ts +3 -0
- package/types/service-base.d.ts +2 -1
package/cjs/asset-cache.js
CHANGED
package/cjs/execution-context.js
CHANGED
|
@@ -8,6 +8,7 @@ const node_events_async_1 = require("node-events-async");
|
|
|
8
8
|
class ExecutionContext extends node_events_async_1.AsyncEventEmitter {
|
|
9
9
|
constructor(init) {
|
|
10
10
|
super();
|
|
11
|
+
this.shared = new Map();
|
|
11
12
|
this.errors = [];
|
|
12
13
|
this.document = init.document;
|
|
13
14
|
this.protocol = init.protocol;
|
package/cjs/service-base.js
CHANGED
|
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ServiceBase = void 0;
|
|
4
4
|
class ServiceBase {
|
|
5
5
|
get context() {
|
|
6
|
-
|
|
7
|
-
throw new Error(`No context assigned for ${Object.getPrototypeOf(this).constructor.name}`);
|
|
6
|
+
this._assertContext();
|
|
8
7
|
return this._context;
|
|
9
8
|
}
|
|
10
9
|
for(context, overwriteProperties, overwriteContext) {
|
|
11
|
-
|
|
10
|
+
if (context instanceof ServiceBase)
|
|
11
|
+
context = context.context;
|
|
12
|
+
/** Create new context instance */
|
|
12
13
|
const ctx = {};
|
|
13
14
|
Object.setPrototypeOf(ctx, context);
|
|
14
15
|
if (overwriteContext)
|
|
15
16
|
Object.assign(ctx, overwriteContext);
|
|
16
|
-
|
|
17
|
+
/** Create new service instance */
|
|
17
18
|
const instance = { _context: ctx };
|
|
18
19
|
Object.setPrototypeOf(instance, this);
|
|
19
20
|
if (overwriteProperties)
|
|
@@ -22,6 +23,10 @@ class ServiceBase {
|
|
|
22
23
|
this[ServiceBase.extendSymbol](instance);
|
|
23
24
|
return instance;
|
|
24
25
|
}
|
|
26
|
+
_assertContext() {
|
|
27
|
+
if (!this._context)
|
|
28
|
+
throw new Error(`No context assigned for ${Object.getPrototypeOf(this).constructor.name}`);
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
exports.ServiceBase = ServiceBase;
|
|
27
32
|
(function (ServiceBase) {
|
package/esm/asset-cache.js
CHANGED
package/esm/execution-context.js
CHANGED
package/esm/service-base.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export class ServiceBase {
|
|
2
2
|
get context() {
|
|
3
|
-
|
|
4
|
-
throw new Error(`No context assigned for ${Object.getPrototypeOf(this).constructor.name}`);
|
|
3
|
+
this._assertContext();
|
|
5
4
|
return this._context;
|
|
6
5
|
}
|
|
7
6
|
for(context, overwriteProperties, overwriteContext) {
|
|
8
|
-
|
|
7
|
+
if (context instanceof ServiceBase)
|
|
8
|
+
context = context.context;
|
|
9
|
+
/** Create new context instance */
|
|
9
10
|
const ctx = {};
|
|
10
11
|
Object.setPrototypeOf(ctx, context);
|
|
11
12
|
if (overwriteContext)
|
|
12
13
|
Object.assign(ctx, overwriteContext);
|
|
13
|
-
|
|
14
|
+
/** Create new service instance */
|
|
14
15
|
const instance = { _context: ctx };
|
|
15
16
|
Object.setPrototypeOf(instance, this);
|
|
16
17
|
if (overwriteProperties)
|
|
@@ -19,6 +20,10 @@ export class ServiceBase {
|
|
|
19
20
|
this[ServiceBase.extendSymbol](instance);
|
|
20
21
|
return instance;
|
|
21
22
|
}
|
|
23
|
+
_assertContext() {
|
|
24
|
+
if (!this._context)
|
|
25
|
+
throw new Error(`No context assigned for ${Object.getPrototypeOf(this).constructor.name}`);
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
(function (ServiceBase) {
|
|
24
29
|
ServiceBase.extendSymbol = Symbol('extend');
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "Opra schema package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@opra/common": "^1.0.0-beta.
|
|
8
|
+
"@opra/common": "^1.0.0-beta.5",
|
|
9
9
|
"node-events-async": "^1.0.0",
|
|
10
10
|
"reflect-metadata": "^0.2.2",
|
|
11
11
|
"tslib": "^2.7.0"
|
package/types/asset-cache.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare namespace ExecutionContext {
|
|
|
14
14
|
* @class ExecutionContext
|
|
15
15
|
*/
|
|
16
16
|
export declare abstract class ExecutionContext extends AsyncEventEmitter {
|
|
17
|
+
readonly shared: Map<any, any>;
|
|
17
18
|
readonly document: ApiDocument;
|
|
18
19
|
readonly protocol: OpraSchema.Transport;
|
|
19
20
|
readonly platform: string;
|
|
@@ -3,12 +3,14 @@ import { ApiDocument, I18n, OpraSchema } from '@opra/common';
|
|
|
3
3
|
import { AsyncEventEmitter } from 'node-events-async';
|
|
4
4
|
import { AssetCache } from './asset-cache.js';
|
|
5
5
|
import { kAssetCache } from './constants.js';
|
|
6
|
+
import { ILogger } from './interfaces/logger.interface.js';
|
|
6
7
|
/**
|
|
7
8
|
* @namespace PlatformAdapter
|
|
8
9
|
*/
|
|
9
10
|
export declare namespace PlatformAdapter {
|
|
10
11
|
interface Options {
|
|
11
12
|
i18n?: I18n;
|
|
13
|
+
logger?: ILogger;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
@@ -19,6 +21,7 @@ export declare abstract class PlatformAdapter extends AsyncEventEmitter {
|
|
|
19
21
|
readonly document: ApiDocument;
|
|
20
22
|
abstract readonly protocol: OpraSchema.Transport;
|
|
21
23
|
i18n: I18n;
|
|
24
|
+
logger?: ILogger;
|
|
22
25
|
protected constructor(document: ApiDocument, options?: PlatformAdapter.Options);
|
|
23
26
|
abstract close(): Promise<void>;
|
|
24
27
|
}
|
package/types/service-base.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { ExecutionContext } from './execution-context.js';
|
|
|
3
3
|
export declare abstract class ServiceBase {
|
|
4
4
|
protected _context: ExecutionContext;
|
|
5
5
|
get context(): ExecutionContext;
|
|
6
|
-
for<C extends ExecutionContext, P extends Partial<this>>(context: C, overwriteProperties?: Nullish<P>, overwriteContext?: Partial<C>): this & Required<P>;
|
|
6
|
+
for<C extends ExecutionContext, P extends Partial<this>>(context: C | ServiceBase, overwriteProperties?: Nullish<P>, overwriteContext?: Partial<C>): this & Required<P>;
|
|
7
|
+
protected _assertContext(): void;
|
|
7
8
|
}
|
|
8
9
|
export declare namespace ServiceBase {
|
|
9
10
|
const extendSymbol: unique symbol;
|