@eggjs/tegg-plugin 4.0.0-beta.34 → 4.0.0-beta.36
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/dist/app/extend/application.d.ts +28 -24
- package/dist/app/extend/application.js +69 -75
- package/dist/app/extend/application.unittest.d.ts +9 -5
- package/dist/app/extend/application.unittest.js +39 -50
- package/dist/app/extend/context.d.ts +12 -8
- package/dist/app/extend/context.js +27 -32
- package/dist/app/middleware/tegg_ctx_lifecycle_middleware.d.ts +5 -2
- package/dist/app/middleware/tegg_ctx_lifecycle_middleware.js +7 -3
- package/dist/app.d.ts +20 -16
- package/dist/app.js +50 -57
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -3
- package/dist/lib/AppLoadUnit.d.ts +23 -19
- package/dist/lib/AppLoadUnit.js +77 -92
- package/dist/lib/AppLoadUnitInstance.d.ts +23 -19
- package/dist/lib/AppLoadUnitInstance.js +69 -82
- package/dist/lib/CompatibleUtil.d.ts +22 -18
- package/dist/lib/CompatibleUtil.js +99 -104
- package/dist/lib/ConfigSourceLoadUnitHook.d.ts +13 -8
- package/dist/lib/ConfigSourceLoadUnitHook.js +20 -19
- package/dist/lib/EggAppLoader.d.ts +19 -15
- package/dist/lib/EggAppLoader.js +104 -115
- package/dist/lib/EggCompatibleObject.d.ts +19 -15
- package/dist/lib/EggCompatibleObject.js +34 -41
- package/dist/lib/EggCompatibleProtoImpl.d.ts +25 -21
- package/dist/lib/EggCompatibleProtoImpl.js +49 -52
- package/dist/lib/EggContextCompatibleHook.d.ts +13 -9
- package/dist/lib/EggContextCompatibleHook.js +32 -44
- package/dist/lib/EggContextHandler.d.ts +12 -8
- package/dist/lib/EggContextHandler.js +28 -25
- package/dist/lib/EggContextImpl.d.ts +9 -5
- package/dist/lib/EggContextImpl.js +18 -15
- package/dist/lib/EggModuleLoader.d.ts +14 -10
- package/dist/lib/EggModuleLoader.js +48 -52
- package/dist/lib/EggQualifierProtoHook.d.ts +13 -9
- package/dist/lib/EggQualifierProtoHook.js +46 -60
- package/dist/lib/ModuleConfigLoader.d.ts +11 -7
- package/dist/lib/ModuleConfigLoader.js +81 -79
- package/dist/lib/ModuleHandler.d.ts +16 -12
- package/dist/lib/ModuleHandler.js +44 -51
- package/dist/lib/Utils.d.ts +4 -1
- package/dist/lib/Utils.js +30 -33
- package/dist/lib/ctx_lifecycle_middleware.d.ts +6 -2
- package/dist/lib/ctx_lifecycle_middleware.js +24 -30
- package/dist/lib/run_in_background.d.ts +7 -3
- package/dist/lib/run_in_background.js +46 -54
- package/dist/types.d.ts +54 -53
- package/dist/types.js +3 -2
- package/package.json +47 -51
|
@@ -1,58 +1,50 @@
|
|
|
1
|
-
import { PrototypeUtil } from '@eggjs/core-decorator';
|
|
2
|
-
import { BackgroundTaskHelper } from '@eggjs/background-task';
|
|
3
|
-
import { TEGG_CONTEXT } from '@eggjs/module-common';
|
|
4
1
|
import { getCalleeFromStack } from "./Utils.js";
|
|
5
|
-
|
|
2
|
+
import { PrototypeUtil } from "@eggjs/core-decorator";
|
|
3
|
+
import { BackgroundTaskHelper } from "@eggjs/background-task";
|
|
4
|
+
import { TEGG_CONTEXT } from "@eggjs/module-common";
|
|
5
|
+
|
|
6
|
+
//#region src/lib/run_in_background.ts
|
|
7
|
+
const LONG_STACK_DELIMITER = "\n --------------------\n";
|
|
6
8
|
function addLongStackTrace(err, causeError) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const index = callSiteStack.indexOf('\n');
|
|
12
|
-
if (index !== -1) {
|
|
13
|
-
err.stack += LONG_STACK_DELIMITER + callSiteStack.substring(index + 1);
|
|
14
|
-
}
|
|
9
|
+
const callSiteStack = causeError.stack;
|
|
10
|
+
if (!callSiteStack || typeof callSiteStack !== "string") return;
|
|
11
|
+
const index = callSiteStack.indexOf("\n");
|
|
12
|
+
if (index !== -1) err.stack += LONG_STACK_DELIMITER + callSiteStack.substring(index + 1);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Reflect.apply(eggRunInBackground, this, [newScope]);
|
|
50
|
-
const proto = PrototypeUtil.getClazzProto(BackgroundTaskHelper);
|
|
51
|
-
const eggObject = app.eggContainerFactory.getEggObject(proto);
|
|
52
|
-
const backgroundTaskHelper = eggObject.obj;
|
|
53
|
-
backgroundTaskHelper.run(async () => {
|
|
54
|
-
await backgroundTaskPromise;
|
|
55
|
-
});
|
|
56
|
-
};
|
|
14
|
+
function hijackRunInBackground(app) {
|
|
15
|
+
const eggRunInBackground = app.context.runInBackground;
|
|
16
|
+
app.context.runInBackground = function runInBackground(scope) {
|
|
17
|
+
if (!this[TEGG_CONTEXT]) return Reflect.apply(eggRunInBackground, this, [scope]);
|
|
18
|
+
const caseError = /* @__PURE__ */ new Error("cause");
|
|
19
|
+
let resolveBackgroundTask;
|
|
20
|
+
const backgroundTaskPromise = new Promise((resolve) => {
|
|
21
|
+
resolveBackgroundTask = resolve;
|
|
22
|
+
});
|
|
23
|
+
const newScope = async () => {
|
|
24
|
+
try {
|
|
25
|
+
await scope(this);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
addLongStackTrace(e, caseError);
|
|
28
|
+
throw e;
|
|
29
|
+
} finally {
|
|
30
|
+
resolveBackgroundTask();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const taskName = scope._name || scope.name || getCalleeFromStack(true, 2);
|
|
34
|
+
scope._name = taskName;
|
|
35
|
+
Object.defineProperty(newScope, "name", {
|
|
36
|
+
value: taskName,
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: false
|
|
40
|
+
});
|
|
41
|
+
Reflect.apply(eggRunInBackground, this, [newScope]);
|
|
42
|
+
const proto = PrototypeUtil.getClazzProto(BackgroundTaskHelper);
|
|
43
|
+
app.eggContainerFactory.getEggObject(proto).obj.run(async () => {
|
|
44
|
+
await backgroundTaskPromise;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
57
47
|
}
|
|
58
|
-
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { LONG_STACK_DELIMITER, hijackRunInBackground };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
1
|
+
import { EggContextHandler } from "./lib/EggContextHandler.js";
|
|
2
|
+
import { ModuleHandler } from "./lib/ModuleHandler.js";
|
|
3
|
+
import { QualifierInfo } from "@eggjs/core-decorator";
|
|
4
|
+
import { IdenticalUtil } from "@eggjs/lifecycle";
|
|
5
|
+
import { EggPrototypeCreatorFactory, EggPrototypeFactory, EggPrototypeLifecycleUtil, LoadUnitFactory, LoadUnitLifecycleUtil } from "@eggjs/metadata";
|
|
6
|
+
import { AbstractEggContext, EggContainerFactory, EggContext, EggContextLifecycleUtil, EggObjectFactory, EggObjectLifecycleUtil, LoadUnitInstanceFactory, LoadUnitInstanceLifecycleUtil } from "@eggjs/tegg-runtime";
|
|
7
|
+
import { LoaderFactory } from "@eggjs/tegg-loader";
|
|
8
|
+
import "@eggjs/tegg-config/types";
|
|
9
|
+
|
|
10
|
+
//#region src/types.d.ts
|
|
11
|
+
declare module "egg" {
|
|
12
|
+
interface EggModule {}
|
|
13
|
+
interface Application {
|
|
14
|
+
eggPrototypeCreatorFactory: typeof EggPrototypeCreatorFactory;
|
|
15
|
+
eggPrototypeFactory: EggPrototypeFactory;
|
|
16
|
+
eggContainerFactory: typeof EggContainerFactory;
|
|
17
|
+
loadUnitFactory: typeof LoadUnitFactory;
|
|
18
|
+
eggObjectFactory: typeof EggObjectFactory;
|
|
19
|
+
loadUnitInstanceFactory: typeof LoadUnitInstanceFactory;
|
|
20
|
+
abstractEggContext: typeof AbstractEggContext;
|
|
21
|
+
identicalUtil: typeof IdenticalUtil;
|
|
22
|
+
loaderFactory: typeof LoaderFactory;
|
|
23
|
+
loadUnitLifecycleUtil: typeof LoadUnitLifecycleUtil;
|
|
24
|
+
loadUnitInstanceLifecycleUtil: typeof LoadUnitInstanceLifecycleUtil;
|
|
25
|
+
eggPrototypeLifecycleUtil: typeof EggPrototypeLifecycleUtil;
|
|
26
|
+
eggContextLifecycleUtil: typeof EggContextLifecycleUtil;
|
|
27
|
+
eggObjectLifecycleUtil: typeof EggObjectLifecycleUtil;
|
|
28
|
+
teggContext: EggContext;
|
|
29
|
+
moduleHandler: ModuleHandler;
|
|
30
|
+
eggContextHandler: EggContextHandler;
|
|
31
|
+
getEggObject<T>(clazz: new (...args: any[]) => T, name?: string, qualifiers?: QualifierInfo | QualifierInfo[]): Promise<T>;
|
|
32
|
+
getEggObjectFromName<T extends object>(name: string, qualifiers?: QualifierInfo | QualifierInfo[]): Promise<T>;
|
|
33
|
+
module: EggModule;
|
|
34
|
+
/**
|
|
35
|
+
* Mock the module context, only for unittest
|
|
36
|
+
*/
|
|
37
|
+
mockModuleContext(data?: any): Promise<Context>;
|
|
38
|
+
/**
|
|
39
|
+
* Mock the module context scope, only for unittest
|
|
40
|
+
*/
|
|
41
|
+
mockModuleContextScope<R = any>(fn: (ctx: Context) => Promise<R>, data?: any): Promise<R>;
|
|
42
|
+
/**
|
|
43
|
+
* Destroy the module context, only for unittest
|
|
44
|
+
*/
|
|
45
|
+
destroyModuleContext(context: Context): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
interface Context {
|
|
48
|
+
beginModuleScope(func: () => Promise<void>): Promise<void>;
|
|
49
|
+
getEggObject<T>(clazz: new (...args: any[]) => T, name?: string, qualifiers?: QualifierInfo | QualifierInfo[]): Promise<T>;
|
|
50
|
+
getEggObjectFromName<T>(name: string, qualifiers?: QualifierInfo | QualifierInfo[]): Promise<T>;
|
|
51
|
+
teggContext: EggContext;
|
|
52
|
+
module: EggModule;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import "@eggjs/tegg-config/types";
|
|
2
|
+
|
|
3
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/tegg-plugin",
|
|
3
|
-
"
|
|
4
|
-
"name": "tegg",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"teggConfig"
|
|
7
|
-
]
|
|
8
|
-
},
|
|
9
|
-
"version": "4.0.0-beta.34",
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
10
4
|
"description": "module plugin for egg",
|
|
11
5
|
"keywords": [
|
|
12
6
|
"egg",
|
|
13
|
-
"plugin",
|
|
14
|
-
"typescript",
|
|
15
7
|
"module",
|
|
16
|
-
"
|
|
8
|
+
"plugin",
|
|
9
|
+
"tegg",
|
|
10
|
+
"typescript"
|
|
17
11
|
],
|
|
12
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/tegg/plugin/tegg",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/eggjs/egg/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/eggjs/egg.git",
|
|
19
|
+
"directory": "tegg/plugin/tegg"
|
|
20
|
+
},
|
|
18
21
|
"files": [
|
|
19
22
|
"dist"
|
|
20
23
|
],
|
|
21
24
|
"type": "module",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
22
28
|
"exports": {
|
|
23
29
|
".": "./dist/index.js",
|
|
24
30
|
"./app": "./dist/app.js",
|
|
@@ -46,57 +52,47 @@
|
|
|
46
52
|
"./types": "./dist/types.js",
|
|
47
53
|
"./package.json": "./package.json"
|
|
48
54
|
},
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
"url": "https://github.com/eggjs/egg/issues"
|
|
52
|
-
},
|
|
53
|
-
"repository": {
|
|
54
|
-
"type": "git",
|
|
55
|
-
"url": "git@github.com:eggjs/egg.git",
|
|
56
|
-
"directory": "tegg/plugin/tegg"
|
|
57
|
-
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=22.18.0"
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
60
57
|
},
|
|
61
58
|
"dependencies": {
|
|
62
59
|
"extend2": "^4.0.0",
|
|
63
60
|
"sdk-base": "^5.0.1",
|
|
64
|
-
"@eggjs/
|
|
65
|
-
"@eggjs/
|
|
66
|
-
"@eggjs/
|
|
67
|
-
"@eggjs/
|
|
68
|
-
"@eggjs/
|
|
69
|
-
"@eggjs/
|
|
70
|
-
"@eggjs/
|
|
71
|
-
"@eggjs/tegg-
|
|
72
|
-
"@eggjs/tegg-
|
|
73
|
-
"@eggjs/
|
|
74
|
-
},
|
|
75
|
-
"peerDependencies": {
|
|
76
|
-
"@eggjs/tegg-config": "4.0.0-beta.34",
|
|
77
|
-
"egg": "4.1.0-beta.34"
|
|
61
|
+
"@eggjs/background-task": "4.0.0-beta.36",
|
|
62
|
+
"@eggjs/core-decorator": "4.0.0-beta.36",
|
|
63
|
+
"@eggjs/dynamic-inject-runtime": "4.0.0-beta.36",
|
|
64
|
+
"@eggjs/lifecycle": "4.0.0-beta.36",
|
|
65
|
+
"@eggjs/metadata": "4.0.0-beta.36",
|
|
66
|
+
"@eggjs/module-common": "4.0.0-beta.36",
|
|
67
|
+
"@eggjs/tegg-loader": "4.0.0-beta.36",
|
|
68
|
+
"@eggjs/tegg-common-util": "4.0.0-beta.36",
|
|
69
|
+
"@eggjs/tegg-runtime": "4.0.0-beta.36",
|
|
70
|
+
"@eggjs/tegg-types": "4.0.0-beta.36"
|
|
78
71
|
},
|
|
79
72
|
"devDependencies": {
|
|
80
|
-
"@types/node": "^24.
|
|
73
|
+
"@types/node": "^24.10.2",
|
|
81
74
|
"egg-logger": "^3.5.0",
|
|
82
|
-
"tsdown": "0.15.11",
|
|
83
75
|
"typescript": "^5.9.3",
|
|
84
|
-
"
|
|
85
|
-
"@eggjs/
|
|
86
|
-
"@eggjs/tegg": "4.0.0-beta.
|
|
87
|
-
"@eggjs/
|
|
88
|
-
"
|
|
89
|
-
"egg": "4.1.0-beta.34"
|
|
76
|
+
"@eggjs/mock": "7.0.0-beta.36",
|
|
77
|
+
"@eggjs/tegg": "4.0.0-beta.36",
|
|
78
|
+
"@eggjs/tegg-config": "4.0.0-beta.36",
|
|
79
|
+
"@eggjs/tracer": "4.0.0-beta.36",
|
|
80
|
+
"egg": "4.1.0-beta.36"
|
|
90
81
|
},
|
|
91
|
-
"
|
|
92
|
-
"
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"@eggjs/tegg-config": "4.0.0-beta.36",
|
|
84
|
+
"egg": "4.1.0-beta.36"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=22.18.0"
|
|
88
|
+
},
|
|
89
|
+
"eggPlugin": {
|
|
90
|
+
"name": "tegg",
|
|
91
|
+
"dependencies": [
|
|
92
|
+
"teggConfig"
|
|
93
|
+
]
|
|
93
94
|
},
|
|
94
|
-
"main": "./dist/index.js",
|
|
95
|
-
"module": "./dist/index.js",
|
|
96
|
-
"types": "./dist/index.d.ts",
|
|
97
95
|
"scripts": {
|
|
98
|
-
"typecheck": "
|
|
99
|
-
"clean": "rimraf dist *.tsbuildinfo",
|
|
100
|
-
"build": "tsdown && npm run clean && tsc -p tsconfig.build.json"
|
|
96
|
+
"typecheck": "tsgo --noEmit"
|
|
101
97
|
}
|
|
102
98
|
}
|