@eggjs/tegg-plugin 4.0.0-beta.6 → 4.0.0-beta.8
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/AppLoadUnit-BOWdS4O9.d.ts +23 -0
- package/dist/AppLoadUnit-uyHgElRL.js +78 -0
- package/dist/AppLoadUnitInstance-4Z_vSQV3.js +69 -0
- package/dist/AppLoadUnitInstance-DQ-DxlmR.d.ts +24 -0
- package/dist/CompatibleUtil-CNhydb0E.js +96 -0
- package/dist/ConfigSourceLoadUnitHook-BV-R31vA.js +22 -0
- package/dist/EggAppLoader-DFYg65ry.js +106 -0
- package/dist/EggCompatibleObject-XfIZyirS.js +37 -0
- package/dist/EggCompatibleObject-lzUCfsIY.d.ts +21 -0
- package/dist/EggCompatibleProtoImpl-CPxLvSu4.js +50 -0
- package/dist/EggCompatibleProtoImpl-DpacWKFB.d.ts +25 -0
- package/dist/EggContextCompatibleHook-eFfN2xm6.js +31 -0
- package/dist/EggContextHandler-D8gfTbZs.js +29 -0
- package/dist/EggContextHandler-vGi67He5.d.ts +13 -0
- package/dist/EggContextImpl-DkCLPTzT.js +18 -0
- package/dist/EggModuleLoader-CCfQMmp5.js +50 -0
- package/dist/EggQualifierProtoHook-D5jNm-1y.js +48 -0
- package/dist/ModuleConfigLoader-CvZLf99E.js +84 -0
- package/dist/ModuleHandler-Dyx7JGj-.d.ts +17 -0
- package/dist/ModuleHandler-fKcUqWca.js +46 -0
- package/dist/Utils-11aRpnkd.js +33 -0
- package/dist/app/extend/application.d.ts +3 -56
- package/dist/app/extend/application.js +8 -70
- package/dist/app/extend/application.unittest.d.ts +1 -25
- package/dist/app/extend/application.unittest.js +2 -41
- package/dist/app/extend/context.d.ts +1 -23
- package/dist/app/extend/context.js +3 -28
- package/dist/app/middleware/tegg_ctx_lifecycle_middleware.d.ts +1 -1
- package/dist/app/middleware/tegg_ctx_lifecycle_middleware.js +2 -1
- package/dist/app.d.ts +4 -1
- package/dist/app.js +18 -10
- package/dist/application-Ccljinuy.d.ts +57 -0
- package/dist/application-DFI1junS.js +70 -0
- package/dist/application.unittest-Cmia71Fx.js +43 -0
- package/dist/application.unittest-CpoCu6-E.d.ts +26 -0
- package/dist/context-BWYE1dif.js +30 -0
- package/dist/context-BoIt2G5h.d.ts +24 -0
- package/dist/ctx_lifecycle_middleware-CIeSrbVY.js +27 -0
- package/dist/ctx_lifecycle_middleware-DV7uN5PG.d.ts +6 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +13 -3
- package/dist/lib/AppLoadUnit.d.ts +1 -22
- package/dist/lib/AppLoadUnit.js +1 -76
- package/dist/lib/AppLoadUnitInstance.d.ts +1 -23
- package/dist/lib/AppLoadUnitInstance.js +1 -67
- package/dist/lib/CompatibleUtil.js +1 -94
- package/dist/lib/ConfigSourceLoadUnitHook.js +1 -20
- package/dist/lib/EggAppLoader.js +3 -104
- package/dist/lib/EggCompatibleObject.d.ts +2 -20
- package/dist/lib/EggCompatibleObject.js +2 -35
- package/dist/lib/EggCompatibleProtoImpl.d.ts +1 -24
- package/dist/lib/EggCompatibleProtoImpl.js +1 -48
- package/dist/lib/EggContextCompatibleHook.d.ts +1 -1
- package/dist/lib/EggContextCompatibleHook.js +7 -30
- package/dist/lib/EggContextHandler.d.ts +1 -12
- package/dist/lib/EggContextHandler.js +1 -27
- package/dist/lib/EggContextImpl.js +1 -16
- package/dist/lib/EggModuleLoader.js +4 -48
- package/dist/lib/EggQualifierProtoHook.js +4 -46
- package/dist/lib/ModuleConfigLoader.js +2 -82
- package/dist/lib/ModuleHandler.d.ts +1 -16
- package/dist/lib/ModuleHandler.js +6 -44
- package/dist/lib/Utils.js +1 -31
- package/dist/lib/ctx_lifecycle_middleware.d.ts +1 -5
- package/dist/lib/ctx_lifecycle_middleware.js +2 -25
- package/dist/lib/run_in_background.js +5 -50
- package/dist/run_in_background-CEUPBmDB.js +51 -0
- package/dist/types-BHg5p4Xk.js +3 -0
- package/dist/types-CuoKQV4X.d.ts +7 -0
- package/dist/types.d.ts +6 -7
- package/dist/types.js +13 -4
- package/package.json +11 -11
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/lib/ctx_lifecycle_middleware.d.ts
|
|
4
|
-
declare function ctxLifecycleMiddleware(ctx: Context, next: Next): Promise<void>;
|
|
5
|
-
//#endregion
|
|
1
|
+
import { ctxLifecycleMiddleware } from "../ctx_lifecycle_middleware-DV7uN5PG.js";
|
|
6
2
|
export { ctxLifecycleMiddleware };
|
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
import { ROOT_PROTO, TEGG_CONTEXT } from "@eggjs/egg-module-common";
|
|
1
|
+
import "../EggContextImpl-DkCLPTzT.js";
|
|
2
|
+
import { ctxLifecycleMiddleware } from "../ctx_lifecycle_middleware-CIeSrbVY.js";
|
|
4
3
|
|
|
5
|
-
//#region src/lib/ctx_lifecycle_middleware.ts
|
|
6
|
-
async function ctxLifecycleMiddleware(ctx, next) {
|
|
7
|
-
if (ctx[TEGG_CONTEXT]) {
|
|
8
|
-
await next();
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const lifecycleCtx = {};
|
|
12
|
-
const teggCtx = new EggContextImpl(ctx);
|
|
13
|
-
const rootProto = ctx[ROOT_PROTO];
|
|
14
|
-
if (rootProto) teggCtx.set(ROOT_PROTO, rootProto);
|
|
15
|
-
if (teggCtx.init) await teggCtx.init(lifecycleCtx);
|
|
16
|
-
try {
|
|
17
|
-
await next();
|
|
18
|
-
} finally {
|
|
19
|
-
if (teggCtx.destroy) teggCtx.destroy(lifecycleCtx).catch((e) => {
|
|
20
|
-
e.message = `[tegg/ctxLifecycleMiddleware] destroy tegg ctx failed: ${e.message}`;
|
|
21
|
-
ctx.logger.error(e);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
4
|
export { ctxLifecycleMiddleware };
|
|
@@ -1,52 +1,7 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { Application } from "egg";
|
|
1
|
+
import "../EggContextImpl-DkCLPTzT.js";
|
|
2
|
+
import "../ctx_lifecycle_middleware-CIeSrbVY.js";
|
|
3
|
+
import "../context-BWYE1dif.js";
|
|
4
|
+
import "../Utils-11aRpnkd.js";
|
|
5
|
+
import { LONG_STACK_DELIMITER, hijackRunInBackground } from "../run_in_background-CEUPBmDB.js";
|
|
7
6
|
|
|
8
|
-
//#region src/lib/run_in_background.ts
|
|
9
|
-
const LONG_STACK_DELIMITER = "\n --------------------\n";
|
|
10
|
-
function addLongStackTrace(err, causeError) {
|
|
11
|
-
const callSiteStack = causeError.stack;
|
|
12
|
-
if (!callSiteStack || typeof callSiteStack !== "string") return;
|
|
13
|
-
const index = callSiteStack.indexOf("\n");
|
|
14
|
-
if (index !== -1) err.stack += LONG_STACK_DELIMITER + callSiteStack.substring(index + 1);
|
|
15
|
-
}
|
|
16
|
-
function hijackRunInBackground(app) {
|
|
17
|
-
const eggRunInBackground = app.context.runInBackground;
|
|
18
|
-
app.context.runInBackground = function runInBackground(scope) {
|
|
19
|
-
if (!this[TEGG_CONTEXT]) return Reflect.apply(eggRunInBackground, this, [scope]);
|
|
20
|
-
const caseError = /* @__PURE__ */ new Error("cause");
|
|
21
|
-
let resolveBackgroundTask;
|
|
22
|
-
const backgroundTaskPromise = new Promise((resolve) => {
|
|
23
|
-
resolveBackgroundTask = resolve;
|
|
24
|
-
});
|
|
25
|
-
const newScope = async () => {
|
|
26
|
-
try {
|
|
27
|
-
await scope(this);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
addLongStackTrace(e, caseError);
|
|
30
|
-
throw e;
|
|
31
|
-
} finally {
|
|
32
|
-
resolveBackgroundTask();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const taskName = scope._name || scope.name || getCalleeFromStack(true, 2);
|
|
36
|
-
scope._name = taskName;
|
|
37
|
-
Object.defineProperty(newScope, "name", {
|
|
38
|
-
value: taskName,
|
|
39
|
-
enumerable: false,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: false
|
|
42
|
-
});
|
|
43
|
-
Reflect.apply(eggRunInBackground, this, [newScope]);
|
|
44
|
-
const proto = PrototypeUtil.getClazzProto(BackgroundTaskHelper);
|
|
45
|
-
app.eggContainerFactory.getEggObject(proto).obj.run(async () => {
|
|
46
|
-
await backgroundTaskPromise;
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
7
|
export { LONG_STACK_DELIMITER, hijackRunInBackground };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getCalleeFromStack } from "./Utils-11aRpnkd.js";
|
|
2
|
+
import "@eggjs/tegg-metadata";
|
|
3
|
+
import { BackgroundTaskHelper, PrototypeUtil } from "@eggjs/tegg";
|
|
4
|
+
import { TEGG_CONTEXT } from "@eggjs/egg-module-common";
|
|
5
|
+
import { Application } from "egg";
|
|
6
|
+
|
|
7
|
+
//#region src/lib/run_in_background.ts
|
|
8
|
+
const LONG_STACK_DELIMITER = "\n --------------------\n";
|
|
9
|
+
function addLongStackTrace(err, causeError) {
|
|
10
|
+
const callSiteStack = causeError.stack;
|
|
11
|
+
if (!callSiteStack || typeof callSiteStack !== "string") return;
|
|
12
|
+
const index = callSiteStack.indexOf("\n");
|
|
13
|
+
if (index !== -1) err.stack += LONG_STACK_DELIMITER + callSiteStack.substring(index + 1);
|
|
14
|
+
}
|
|
15
|
+
function hijackRunInBackground(app) {
|
|
16
|
+
const eggRunInBackground = app.context.runInBackground;
|
|
17
|
+
app.context.runInBackground = function runInBackground(scope) {
|
|
18
|
+
if (!this[TEGG_CONTEXT]) return Reflect.apply(eggRunInBackground, this, [scope]);
|
|
19
|
+
const caseError = /* @__PURE__ */ new Error("cause");
|
|
20
|
+
let resolveBackgroundTask;
|
|
21
|
+
const backgroundTaskPromise = new Promise((resolve) => {
|
|
22
|
+
resolveBackgroundTask = resolve;
|
|
23
|
+
});
|
|
24
|
+
const newScope = async () => {
|
|
25
|
+
try {
|
|
26
|
+
await scope(this);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
addLongStackTrace(e, caseError);
|
|
29
|
+
throw e;
|
|
30
|
+
} finally {
|
|
31
|
+
resolveBackgroundTask();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const taskName = scope._name || scope.name || getCalleeFromStack(true, 2);
|
|
35
|
+
scope._name = taskName;
|
|
36
|
+
Object.defineProperty(newScope, "name", {
|
|
37
|
+
value: taskName,
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: false
|
|
41
|
+
});
|
|
42
|
+
Reflect.apply(eggRunInBackground, this, [newScope]);
|
|
43
|
+
const proto = PrototypeUtil.getClazzProto(BackgroundTaskHelper);
|
|
44
|
+
app.eggContainerFactory.getEggObject(proto).obj.run(async () => {
|
|
45
|
+
await backgroundTaskPromise;
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { LONG_STACK_DELIMITER, hijackRunInBackground };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import "./ModuleHandler-Dyx7JGj-.js";
|
|
2
|
+
import "./EggContextHandler-vGi67He5.js";
|
|
3
|
+
import "./application-Ccljinuy.js";
|
|
4
|
+
import "./application.unittest-CpoCu6-E.js";
|
|
5
|
+
import "./context-BoIt2G5h.js";
|
|
6
|
+
import "./types-CuoKQV4X.js";
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "
|
|
1
|
+
import "./EggCompatibleProtoImpl-CPxLvSu4.js";
|
|
2
|
+
import "./ModuleConfigLoader-CvZLf99E.js";
|
|
3
|
+
import "./EggAppLoader-DFYg65ry.js";
|
|
4
|
+
import "./EggModuleLoader-CCfQMmp5.js";
|
|
5
|
+
import "./CompatibleUtil-CNhydb0E.js";
|
|
6
|
+
import "./ModuleHandler-fKcUqWca.js";
|
|
7
|
+
import "./EggContextHandler-D8gfTbZs.js";
|
|
8
|
+
import "./EggContextImpl-DkCLPTzT.js";
|
|
9
|
+
import "./ctx_lifecycle_middleware-CIeSrbVY.js";
|
|
10
|
+
import "./context-BWYE1dif.js";
|
|
11
|
+
import "./application-DFI1junS.js";
|
|
12
|
+
import "./application.unittest-Cmia71Fx.js";
|
|
13
|
+
import "./types-BHg5p4Xk.js";
|
|
5
14
|
|
|
6
15
|
export { };
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"teggConfig"
|
|
7
7
|
]
|
|
8
8
|
},
|
|
9
|
-
"version": "4.0.0-beta.
|
|
9
|
+
"version": "4.0.0-beta.8",
|
|
10
10
|
"description": "module plugin for egg",
|
|
11
11
|
"keywords": [
|
|
12
12
|
"egg",
|
|
@@ -61,18 +61,18 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"extend2": "^4.0.0",
|
|
63
63
|
"sdk-base": "^5.0.1",
|
|
64
|
-
"@eggjs/
|
|
65
|
-
"@eggjs/tegg-background-task": "4.0.0-beta.
|
|
66
|
-
"@eggjs/tegg-common-util": "4.0.0-beta.
|
|
67
|
-
"@eggjs/tegg": "4.0.0-beta.
|
|
68
|
-
"@eggjs/tegg-
|
|
69
|
-
"@eggjs/
|
|
70
|
-
"@eggjs/tegg-
|
|
71
|
-
"@eggjs/tegg-metadata": "4.0.0-beta.
|
|
64
|
+
"@eggjs/tegg": "4.0.0-beta.8",
|
|
65
|
+
"@eggjs/tegg-background-task": "4.0.0-beta.8",
|
|
66
|
+
"@eggjs/tegg-common-util": "4.0.0-beta.8",
|
|
67
|
+
"@eggjs/tegg-dynamic-inject-runtime": "4.0.0-beta.8",
|
|
68
|
+
"@eggjs/tegg-loader": "4.0.0-beta.8",
|
|
69
|
+
"@eggjs/egg-module-common": "4.0.0-beta.8",
|
|
70
|
+
"@eggjs/tegg-runtime": "4.0.0-beta.8",
|
|
71
|
+
"@eggjs/tegg-metadata": "4.0.0-beta.8"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"egg": "beta",
|
|
75
|
-
"@eggjs/tegg-config": "4.0.0-beta.
|
|
75
|
+
"@eggjs/tegg-config": "4.0.0-beta.8"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@eggjs/bin": "beta",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"typescript": "^5.9.3",
|
|
87
87
|
"tsdown": "^0.15.6",
|
|
88
88
|
"unplugin-unused": "^0.5.3",
|
|
89
|
-
"@eggjs/tegg-config": "4.0.0-beta.
|
|
89
|
+
"@eggjs/tegg-config": "4.0.0-beta.8"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|