vona-core 5.0.103 → 5.0.105

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 (135) hide show
  1. package/dist/index.js +3194 -2
  2. package/dist/lib/bean/beanBase.d.ts +1 -0
  3. package/dist/lib/bean/beanBaseSimple.d.ts +0 -2
  4. package/dist/lib/bean/beanContainer.d.ts +9 -5
  5. package/dist/lib/core/hmr.d.ts +20 -0
  6. package/dist/lib/core/hmrDeps.d.ts +12 -0
  7. package/dist/lib/core/index.d.ts +2 -0
  8. package/dist/lib/core/meta.d.ts +5 -1
  9. package/dist/lib/core/response.d.ts +7 -0
  10. package/dist/lib/decorator/class/util.d.ts +1 -0
  11. package/dist/lib/decorator/interface/beanOptions.d.ts +1 -0
  12. package/dist/lib/decorator/type/containerScope.d.ts +1 -0
  13. package/dist/lib/mappedClass/extendClass.d.ts +2 -0
  14. package/dist/lib/mappedClass/mappedClass.d.ts +2 -0
  15. package/dist/lib/utils/index.d.ts +1 -0
  16. package/dist/lib/utils/sqlite3.d.ts +4 -0
  17. package/package.json +13 -14
  18. package/dist/lib/bean/beanAopBase.js +0 -3
  19. package/dist/lib/bean/beanAopMethodBase.js +0 -3
  20. package/dist/lib/bean/beanBase.js +0 -41
  21. package/dist/lib/bean/beanBaseSimple.js +0 -32
  22. package/dist/lib/bean/beanContainer.js +0 -586
  23. package/dist/lib/bean/beanSimple.js +0 -9
  24. package/dist/lib/bean/index.js +0 -9
  25. package/dist/lib/bean/resource/config/index.js +0 -1
  26. package/dist/lib/bean/resource/config/type.js +0 -1
  27. package/dist/lib/bean/resource/constant/index.js +0 -1
  28. package/dist/lib/bean/resource/constant/type.js +0 -1
  29. package/dist/lib/bean/resource/error/beanScopeError.js +0 -17
  30. package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +0 -18
  31. package/dist/lib/bean/resource/error/errorApplication.js +0 -1
  32. package/dist/lib/bean/resource/error/errorClass.js +0 -75
  33. package/dist/lib/bean/resource/error/errorGlobal.js +0 -1
  34. package/dist/lib/bean/resource/error/errorInternal.js +0 -68
  35. package/dist/lib/bean/resource/error/errorObject.js +0 -1
  36. package/dist/lib/bean/resource/error/index.js +0 -8
  37. package/dist/lib/bean/resource/error/type.js +0 -1
  38. package/dist/lib/bean/resource/index.js +0 -4
  39. package/dist/lib/bean/resource/locale/appLocale.js +0 -51
  40. package/dist/lib/bean/resource/locale/beanScopeLocale.js +0 -16
  41. package/dist/lib/bean/resource/locale/index.js +0 -4
  42. package/dist/lib/bean/resource/locale/type.js +0 -1
  43. package/dist/lib/bean/resource/locale/utils.js +0 -3
  44. package/dist/lib/bean/scope/beanScopeBase.js +0 -97
  45. package/dist/lib/bean/scope/beanScopeContainer.js +0 -15
  46. package/dist/lib/bean/scope/beanScopeScene.js +0 -20
  47. package/dist/lib/bean/scope/beanScopeUtil.js +0 -18
  48. package/dist/lib/bean/scope/index.js +0 -4
  49. package/dist/lib/bean/type.js +0 -2
  50. package/dist/lib/core/application.js +0 -86
  51. package/dist/lib/core/asyncLocalStorage.js +0 -23
  52. package/dist/lib/core/config.js +0 -54
  53. package/dist/lib/core/context.js +0 -121
  54. package/dist/lib/core/ctxCounter.js +0 -20
  55. package/dist/lib/core/index.js +0 -7
  56. package/dist/lib/core/locales.js +0 -6
  57. package/dist/lib/core/logger/appLogger.js +0 -103
  58. package/dist/lib/core/logger/index.js +0 -2
  59. package/dist/lib/core/logger/utils.js +0 -76
  60. package/dist/lib/core/meta.js +0 -120
  61. package/dist/lib/core/metadata.js +0 -80
  62. package/dist/lib/core/resource.js +0 -146
  63. package/dist/lib/decorator/class/beanInfo.js +0 -8
  64. package/dist/lib/decorator/class/createBeanDecorator.js +0 -22
  65. package/dist/lib/decorator/class/index.js +0 -5
  66. package/dist/lib/decorator/class/proxyDisable.js +0 -8
  67. package/dist/lib/decorator/class/use.js +0 -74
  68. package/dist/lib/decorator/class/util.js +0 -9
  69. package/dist/lib/decorator/class/virtual.js +0 -8
  70. package/dist/lib/decorator/index.js +0 -3
  71. package/dist/lib/decorator/interface/beanOptions.js +0 -1
  72. package/dist/lib/decorator/interface/index.js +0 -2
  73. package/dist/lib/decorator/interface/useOptions.js +0 -1
  74. package/dist/lib/decorator/type/constructable.js +0 -1
  75. package/dist/lib/decorator/type/containerScope.js +0 -1
  76. package/dist/lib/decorator/type/function.js +0 -1
  77. package/dist/lib/decorator/type/index.js +0 -4
  78. package/dist/lib/decorator/type/injectionScope.js +0 -1
  79. package/dist/lib/framework/bootstrap.js +0 -13
  80. package/dist/lib/framework/cluster.js +0 -33
  81. package/dist/lib/framework/createApp.js +0 -73
  82. package/dist/lib/framework/index.js +0 -4
  83. package/dist/lib/framework/process.js +0 -44
  84. package/dist/lib/framework/start.js +0 -79
  85. package/dist/lib/framework/useApp.js +0 -61
  86. package/dist/lib/index.js +0 -6
  87. package/dist/lib/locale/en-us.js +0 -5
  88. package/dist/lib/locale/zh-cn.js +0 -69
  89. package/dist/lib/mappedClass/index.js +0 -4
  90. package/dist/lib/mappedClass/mappedClass.js +0 -10
  91. package/dist/lib/mappedClass/mixinClass.js +0 -8
  92. package/dist/lib/mappedClass/omitClass.js +0 -14
  93. package/dist/lib/mappedClass/partialClass.js +0 -16
  94. package/dist/lib/mappedClass/pickClass.js +0 -6
  95. package/dist/lib/mappedClass/pickClassInner.js +0 -12
  96. package/dist/lib/mappedClass/type.js +0 -1
  97. package/dist/lib/mappedClass/utils.js +0 -80
  98. package/dist/lib/module/config.js +0 -17
  99. package/dist/lib/module/constant.js +0 -16
  100. package/dist/lib/module/errors.js +0 -29
  101. package/dist/lib/module/loader.js +0 -25
  102. package/dist/lib/module/locales.js +0 -49
  103. package/dist/lib/module/module.js +0 -32
  104. package/dist/lib/utils/customKey.js +0 -3
  105. package/dist/lib/utils/index.js +0 -5
  106. package/dist/lib/utils/retry.js +0 -16
  107. package/dist/lib/utils/util.js +0 -316
  108. package/dist/lib/utils/zod-enhance.js +0 -18
  109. package/dist/lib/utils/zod-openapi.js +0 -29
  110. package/dist/types/application/app.js +0 -1
  111. package/dist/types/application/index.js +0 -1
  112. package/dist/types/config/config.js +0 -1
  113. package/dist/types/config/index.js +0 -3
  114. package/dist/types/config/instance.js +0 -1
  115. package/dist/types/config/locale.js +0 -3
  116. package/dist/types/context/contextBase.js +0 -1
  117. package/dist/types/context/contextConfig.js +0 -1
  118. package/dist/types/context/contextOthers.js +0 -1
  119. package/dist/types/context/contextState.js +0 -1
  120. package/dist/types/context/index.js +0 -1
  121. package/dist/types/enum/appEvent.js +0 -4
  122. package/dist/types/enum/index.js +0 -1
  123. package/dist/types/index.js +0 -6
  124. package/dist/types/interface/bootstrap.js +0 -1
  125. package/dist/types/interface/index.js +0 -4
  126. package/dist/types/interface/logger.js +0 -1
  127. package/dist/types/interface/module.js +0 -1
  128. package/dist/types/interface/monkey.js +0 -1
  129. package/dist/types/utils/cast.js +0 -3
  130. package/dist/types/utils/demo.js +0 -1
  131. package/dist/types/utils/env.js +0 -1
  132. package/dist/types/utils/index.js +0 -6
  133. package/dist/types/utils/omitNever.js +0 -1
  134. package/dist/types/utils/powerPartial.js +0 -8
  135. package/dist/types/utils/type.js +0 -1
@@ -1,8 +0,0 @@
1
- import { appMetadata } from "../../core/metadata.js";
2
- import { SymbolDecoratorBeanInfo } from "../../core/resource.js";
3
- export function BeanInfo(options) {
4
- return function (target) {
5
- // set metadata
6
- appMetadata.defineMetadata(SymbolDecoratorBeanInfo, options, target);
7
- };
8
- }
@@ -1,22 +0,0 @@
1
- import { appResource } from "../../core/resource.js";
2
- import { parseModuleName } from "./util.js";
3
- export function createBeanDecorator(scene, options, optionsPrimitive, fn) {
4
- return function (target) {
5
- const beanClass = target;
6
- // module
7
- const module = parseModuleName(beanClass);
8
- // name
9
- const name = scene === 'scope' ? 'module' : undefined;
10
- // add
11
- appResource.addBean({
12
- module,
13
- scene,
14
- name,
15
- beanClass,
16
- options,
17
- optionsPrimitive,
18
- });
19
- // fn
20
- fn?.(beanClass);
21
- };
22
- }
@@ -1,5 +0,0 @@
1
- export * from "./beanInfo.js";
2
- export * from "./createBeanDecorator.js";
3
- export * from "./proxyDisable.js";
4
- export * from "./use.js";
5
- export * from "./virtual.js";
@@ -1,8 +0,0 @@
1
- import { appMetadata } from "../../core/metadata.js";
2
- import { SymbolDecoratorProxyDisable } from "../../core/resource.js";
3
- export function ProxyDisable() {
4
- return function (target) {
5
- // set metadata
6
- appMetadata.defineMetadata(SymbolDecoratorProxyDisable, true, target);
7
- };
8
- }
@@ -1,74 +0,0 @@
1
- import { evaluateExpressions, isNilOrEmptyString } from '@cabloy/utils';
2
- import { appMetadata } from "../../core/metadata.js";
3
- import { appResource } from "../../core/resource.js";
4
- export function Use(options) {
5
- return function (target, prop, descriptor) {
6
- if (!options)
7
- options = {};
8
- if (typeof options === 'string') {
9
- options = { beanFullName: options };
10
- }
11
- // beanClass maybe has no specific class type
12
- const beanClass = appMetadata.getDesignType(target, prop);
13
- // beanFullName
14
- let beanFullName = options.beanFullName;
15
- if (!beanFullName) {
16
- beanFullName = appResource.getBeanFullName(beanClass);
17
- if (!beanFullName) {
18
- throw new Error(`@Use not found valid beanFullName for: ${target.constructor.name}.${String(prop)}`);
19
- }
20
- }
21
- // record
22
- appResource.addUse(target, {
23
- ...options,
24
- prop,
25
- beanFullName,
26
- descriptor,
27
- });
28
- };
29
- }
30
- export function usePrepareArg(arg, withSelector) {
31
- return {
32
- withSelector,
33
- args: [arg],
34
- };
35
- }
36
- export function usePrepareArgs(args, withSelector) {
37
- return {
38
- withSelector,
39
- args,
40
- };
41
- }
42
- export function __prepareInjectSelectorInfo(beanInstance, useOptions) {
43
- let selectorInfo = __prepareInjectSelectorInfo_descriptor(beanInstance, useOptions);
44
- if (!selectorInfo) {
45
- selectorInfo = __prepareInjectSelectorInfo_init(beanInstance, useOptions);
46
- }
47
- if (!selectorInfo && !isNilOrEmptyString(useOptions.selector)) {
48
- const selector = evaluateExpressions(useOptions.selector, { self: beanInstance, app: beanInstance.app, ctx: beanInstance.ctx });
49
- return { withSelector: true, args: [selector] };
50
- }
51
- return selectorInfo ?? { withSelector: false, args: [] };
52
- }
53
- function __prepareInjectSelectorInfo_descriptor(beanInstance, useOptions) {
54
- const fnGet = useOptions.descriptor?.get;
55
- if (!fnGet)
56
- return;
57
- const res = fnGet.call(beanInstance);
58
- if (!res)
59
- return;
60
- const withSelector = res.withSelector ?? false;
61
- const args = res.args.map(arg => typeof arg === 'function' ? arg() : arg);
62
- return { withSelector, args };
63
- }
64
- function __prepareInjectSelectorInfo_init(beanInstance, useOptions) {
65
- const init = useOptions.init;
66
- if (!init)
67
- return;
68
- const withSelector = init.withSelector ?? false;
69
- const _args = init.args ?? [init.arg];
70
- if (!_args)
71
- return;
72
- const args = _args.map(arg => evaluateExpressions(arg, { self: beanInstance, app: beanInstance.app, ctx: beanInstance.ctx }));
73
- return { withSelector, args };
74
- }
@@ -1,9 +0,0 @@
1
- import { parseModuleName as _parseModuleName, ParseModuleNameLevelInit } from '@cabloy/module-info-pro';
2
- import { appMetadata } from "../../core/metadata.js";
3
- import { SymbolDecoratorBeanInfo } from "../../core/resource.js";
4
- export const ParseModuleNameLevel = ParseModuleNameLevelInit + 5;
5
- export function parseModuleName(beanClass) {
6
- // beanInfo
7
- const beanInfo = appMetadata.getOwnMetadata(SymbolDecoratorBeanInfo, beanClass);
8
- return beanInfo?.module || _parseModuleName(ParseModuleNameLevel);
9
- }
@@ -1,8 +0,0 @@
1
- import { appMetadata } from "../../core/metadata.js";
2
- import { SymbolDecoratorVirtual } from "../../core/resource.js";
3
- export function Virtual() {
4
- return function (target) {
5
- // set metadata
6
- appMetadata.defineMetadata(SymbolDecoratorVirtual, true, target);
7
- };
8
- }
@@ -1,3 +0,0 @@
1
- export * from "./class/index.js";
2
- export * from "./interface/index.js";
3
- export * from "./type/index.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export * from "./beanOptions.js";
2
- export * from "./useOptions.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export const functionNoop = () => { };
@@ -1,4 +0,0 @@
1
- export * from "./constructable.js";
2
- export * from "./containerScope.js";
3
- export * from "./function.js";
4
- export * from "./injectionScope.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import { prepareEnv } from "../utils/util.js";
2
- import { startCluster } from "./cluster.js";
3
- import { createApp } from "./createApp.js";
4
- import { handleProcessWork } from "./process.js";
5
- export async function bootstrap(bootstrapOptions) {
6
- const env = prepareEnv(bootstrapOptions.env);
7
- const workers = Number.parseInt(env.SERVER_WORKERS);
8
- if (workers === 1) {
9
- handleProcessWork();
10
- return await createApp(bootstrapOptions);
11
- }
12
- await startCluster(workers, bootstrapOptions);
13
- }
@@ -1,33 +0,0 @@
1
- import cluster from 'node:cluster';
2
- import { createApp, createAppMaster } from "./createApp.js";
3
- import { handleProcessMaster, handleProcessWork } from "./process.js";
4
- export async function startCluster(workers, bootstrapOptions) {
5
- if (cluster.isPrimary) {
6
- handleProcessMaster();
7
- createAppMaster(bootstrapOptions);
8
- // console.log(`Primary ${process.pid} is running`);
9
- // Fork workers.
10
- for (let i = 0; i < workers; i++) {
11
- cluster.fork();
12
- }
13
- cluster.on('message', (worker, message) => {
14
- if (message === 'reload-worker') {
15
- worker.process.kill('SIGTERM');
16
- cluster.fork();
17
- }
18
- });
19
- cluster.on('exit', (_worker, _code, _signal) => {
20
- // console.log(`worker ${worker.process.pid} died`, code, signal);
21
- // should not kill master self by manual
22
- // master -> worker, rather than worker -> master
23
- // if (cluster.workers && Object.keys(cluster.workers).length === 0) {
24
- // process.kill(process.pid, 'SIGTERM');
25
- // }
26
- });
27
- }
28
- else {
29
- handleProcessWork();
30
- await createApp(bootstrapOptions);
31
- // console.log(`Worker ${process.pid} started`);
32
- }
33
- }
@@ -1,73 +0,0 @@
1
- import { sleep } from '@cabloy/utils';
2
- import { cast } from "../../types/utils/cast.js";
3
- import { VonaApplication } from "../core/application.js";
4
- import { prepareEnv } from "../utils/util.js";
5
- import { zodEnhance } from "../utils/zod-enhance.js";
6
- import { Start } from "./start.js";
7
- export async function createAppMaster(bootstrapOptions) {
8
- globalThis.__bootstrapOptions__ = bootstrapOptions;
9
- const { modulesMeta, locales, config, env, AppMonkey } = bootstrapOptions;
10
- globalThis.__app__ = __createApp({
11
- modulesMeta,
12
- locales,
13
- config,
14
- env,
15
- AppMonkey,
16
- });
17
- }
18
- export async function createApp(bootstrapOptions) {
19
- while (globalThis.__creating__) {
20
- await sleep(100);
21
- }
22
- try {
23
- globalThis.__creating__ = true;
24
- globalThis.__bootstrapOptions__ = bootstrapOptions;
25
- const { modulesMeta, locales, config, env, AppMonkey } = bootstrapOptions;
26
- if (!globalThis.__app__) {
27
- globalThis.__app__ = __createApp({
28
- modulesMeta,
29
- locales,
30
- config,
31
- env,
32
- AppMonkey,
33
- });
34
- const start = new Start(globalThis.__app__);
35
- await start.start();
36
- }
37
- await globalThis.__app__.meta.waitAppStarted();
38
- return globalThis.__app__;
39
- }
40
- finally {
41
- globalThis.__creating__ = false;
42
- }
43
- }
44
- function __createApp({ modulesMeta, locales, config, env, AppMonkey }) {
45
- // patch zod, should before config
46
- zodEnhance();
47
- // env
48
- const env2 = prepareEnv(env);
49
- // appInfo
50
- const appInfo = prepareAppInfo(env2);
51
- // options
52
- const options = {
53
- name: appInfo.name,
54
- projectPath: appInfo.projectPath,
55
- configMeta: appInfo.configMeta,
56
- modulesMeta,
57
- locales,
58
- config,
59
- env: env2,
60
- AppMonkey,
61
- };
62
- return new VonaApplication(options);
63
- }
64
- function prepareAppInfo(env) {
65
- return {
66
- name: env.APP_NAME,
67
- projectPath: process.cwd(),
68
- configMeta: {
69
- flavor: cast(env).META_FLAVOR,
70
- mode: cast(env).META_MODE,
71
- },
72
- };
73
- }
@@ -1,4 +0,0 @@
1
- export * from "./bootstrap.js";
2
- export * from "./createApp.js";
3
- export * from "./process.js";
4
- export * from "./useApp.js";
@@ -1,44 +0,0 @@
1
- import { catchErrorSync } from '@cabloy/utils';
2
- import { closeApp, useApp } from "./useApp.js";
3
- export function handleProcessWork() {
4
- process.once('SIGUSR2', async () => {
5
- // console.log('------------SIGUSR2');
6
- await closeApp(true);
7
- });
8
- process.once('SIGINT', async () => {
9
- // console.log('------------SIGINT');
10
- await closeApp(true);
11
- });
12
- process.on('uncaughtException', async (err) => {
13
- const app = useApp();
14
- if (!app) {
15
- console.error(err);
16
- process.kill(process.pid, 'SIGTERM');
17
- }
18
- else {
19
- const [logger] = catchErrorSync(() => {
20
- return app.meta.logger.get();
21
- });
22
- if (logger) {
23
- logger.error(err);
24
- }
25
- else {
26
- console.error(err);
27
- }
28
- if (!app.meta.appStarted) {
29
- await app.meta.logger.dispose();
30
- process.kill(process.pid, 'SIGTERM');
31
- }
32
- }
33
- });
34
- }
35
- export function handleProcessMaster() {
36
- process.once('SIGUSR2', () => {
37
- // should not kill master self by manual
38
- // process.kill(process.pid, 'SIGTERM');
39
- });
40
- // should not kill master self by manual
41
- // process.once('SIGINT', () => {
42
- // process.kill(process.pid, 'SIGTERM');
43
- // });
44
- }
@@ -1,79 +0,0 @@
1
- import { EnumAppEvent } from "../../types/index.js";
2
- import { ModuleLoader } from "../module/loader.js";
3
- import { deepExtend } from "../utils/util.js";
4
- export class Start {
5
- app;
6
- constructor(app) {
7
- this.app = app;
8
- }
9
- async start() {
10
- const app = this.app;
11
- try {
12
- await this._start_appConfig();
13
- await this._start_appLoad();
14
- await this._start_appStart();
15
- await this._start_appReady();
16
- await this._start_appStarted();
17
- }
18
- catch (err) {
19
- // record
20
- app.meta.appStartError = err;
21
- // event: appReadyError
22
- app.emit(EnumAppEvent.AppStartError, err);
23
- // throw exception
24
- throw err;
25
- }
26
- }
27
- async _start_appLoad() {
28
- const app = this.app;
29
- // module loader
30
- const moduleLoader = app.bean._newBean(ModuleLoader);
31
- await moduleLoader.execute();
32
- }
33
- async _start_appStart() {
34
- const app = this.app;
35
- // hook: appStart
36
- await app.util.monkeyModule(app.meta.appMonkey, app.meta.modulesMonkey, 'appStart');
37
- }
38
- async _start_appReady() {
39
- const app = this.app;
40
- app.meta.appReady = true;
41
- app.meta.appReadyInstances = {};
42
- // hook: appReady
43
- await app.util.monkeyModule(app.meta.appMonkey, app.meta.modulesMonkey, 'appReady');
44
- }
45
- async _start_appStarted() {
46
- const app = this.app;
47
- app.meta.appStarted = true;
48
- // event: appStarted
49
- app.emit(EnumAppEvent.AppStarted);
50
- // hook: appStarted
51
- await app.util.monkeyModule(app.meta.appMonkey, app.meta.modulesMonkey, 'appStarted');
52
- }
53
- async _start_appConfig() {
54
- const app = this.app;
55
- // config
56
- const appConfig = await __prepareConfig(app);
57
- this.app.config = appConfig;
58
- this.app.keys = appConfig.server.keys;
59
- this.app.proxy = appConfig.proxy.enable;
60
- this.app.subdomainOffset = appConfig.server.subdomainOffset;
61
- this.app.proxyIpHeader = appConfig.proxy.ipHeaders;
62
- this.app.maxIpsCount = appConfig.proxy.maxIpsCount;
63
- }
64
- }
65
- async function __prepareConfig(app) {
66
- const config = {};
67
- const configItems = (await app.options.config()).default;
68
- const configItemsPromise = [];
69
- for (const configItem of configItems) {
70
- configItemsPromise.push(configItem(app, app.options.env));
71
- }
72
- const configItemsRes = await Promise.all(configItemsPromise);
73
- for (const configItem of configItemsRes) {
74
- if (configItem) {
75
- deepExtend(config, configItem);
76
- }
77
- }
78
- return config;
79
- }
@@ -1,61 +0,0 @@
1
- var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
- });
6
- }
7
- return path;
8
- };
9
- import path from 'node:path';
10
- import { sleep } from '@cabloy/utils';
11
- import { pathToHref } from "../utils/util.js";
12
- export function useApp() {
13
- return globalThis.__app__;
14
- }
15
- export async function closeApp(terminate) {
16
- while (globalThis.__closing__) {
17
- await sleep(50);
18
- }
19
- try {
20
- globalThis.__closing__ = true;
21
- if (globalThis.__app__) {
22
- await globalThis.__app__.meta.close();
23
- delete globalThis.__app__;
24
- }
25
- }
26
- finally {
27
- globalThis.__closing__ = false;
28
- }
29
- if (terminate) {
30
- process.kill(process.pid, 'SIGTERM');
31
- }
32
- }
33
- export async function createGeneralApp(projectPath, envRuntime) {
34
- if (envRuntime) {
35
- for (const key of Object.keys(envRuntime)) {
36
- process.env[key] = envRuntime[key];
37
- }
38
- }
39
- if (process.env.META_MODE === 'prod') {
40
- const testFile = path.join(projectPath, `dist/${process.env.META_FLAVOR}/bootstrap.js`);
41
- const testInstance = await import(__rewriteRelativeImportExtension(pathToHref(testFile)));
42
- return await testInstance.appBootstrap;
43
- }
44
- else {
45
- const testFile = path.join(projectPath, '.vona/app.ts');
46
- const testInstance = await import(__rewriteRelativeImportExtension(pathToHref(testFile)));
47
- return await testInstance.createSingleApp();
48
- }
49
- }
50
- // export async function reloadApp() {
51
- // while (globalThis.__reloading__) {
52
- // await sleep(100);
53
- // }
54
- // try {
55
- // globalThis.__reloading__ = true;
56
- // await closeApp();
57
- // await createApp(globalThis.__bootstrapOptions__);
58
- // } finally {
59
- // globalThis.__reloading__ = false;
60
- // }
61
- // }
package/dist/lib/index.js DELETED
@@ -1,6 +0,0 @@
1
- export * from "./bean/index.js";
2
- export * from "./core/index.js";
3
- export * from "./decorator/index.js";
4
- export * from "./framework/index.js";
5
- export * from "./mappedClass/index.js";
6
- export * from "./utils/index.js";
@@ -1,5 +0,0 @@
1
- import { errorsInternal } from "../bean/resource/error/errorInternal.js";
2
- export default {
3
- ...errorsInternal,
4
- ValidationFailedDev: 'controller: %s, method: %s, argument: %d',
5
- };
@@ -1,69 +0,0 @@
1
- export default {
2
- ValidationFailedDev: '控制器: %s, 方法: %s, 参数: %d',
3
- // http status
4
- 0: '成功',
5
- 1: '未知错误',
6
- 100: '继续',
7
- 101: '切换协议',
8
- 102: '处理中',
9
- 103: '早期线索',
10
- 200: '成功',
11
- 201: '已创建',
12
- 202: '已接受',
13
- 203: '非认证信息',
14
- 204: '没有内容',
15
- 205: '重置内容',
16
- 206: '部分内容',
17
- 207: '多状态',
18
- 208: '已报告',
19
- 226: 'IM_Used',
20
- 300: '多选择',
21
- 301: '永久转移',
22
- 302: '已发现',
23
- 303: '参考其他',
24
- 304: '未变更',
25
- 305: '使用代理',
26
- 307: '临时转向',
27
- 308: '永久转向',
28
- 400: '无效请求',
29
- 401: '未经认证',
30
- 402: '需要支付',
31
- 403: '访问被禁止',
32
- 404: '未发现',
33
- 405: '方法不允许',
34
- 406: '不可接受',
35
- 407: '需要代理认证',
36
- 408: '请求超时',
37
- 409: '冲突',
38
- 410: '已失效',
39
- 411: '需要指定长度',
40
- 412: '条件不匹配',
41
- 413: '载荷过大',
42
- 414: 'URL地址太长',
43
- 415: '不支持的媒体类型',
44
- 416: '请求的范围不匹配',
45
- 417: '期望值不匹配',
46
- 418: '我是一个茶壶',
47
- 421: '无效转向',
48
- 422: '无法处理的内容',
49
- 423: '已锁定',
50
- 424: '依赖失败',
51
- 425: '太早',
52
- 426: '需要升级',
53
- 428: '需要指定条件',
54
- 429: '请求太多',
55
- 431: '请求头部字段太大',
56
- 451: '由于法律原因无法使用',
57
- 500: '内部服务错误',
58
- 501: '没有实现',
59
- 502: '无效网关',
60
- 503: '服务无法访问',
61
- 504: '网关超时',
62
- 505: 'HTTP版本不支持',
63
- 506: '变量需要协商',
64
- 507: '存储空间不足',
65
- 508: '检测到无限循环',
66
- 509: '超过带宽限制',
67
- 510: '未扩展',
68
- 511: '需要网络认证',
69
- };
@@ -1,4 +0,0 @@
1
- export * from "./mappedClass.js";
2
- export * from "./pickClassInner.js";
3
- export * from "./type.js";
4
- export * from "./utils.js";
@@ -1,10 +0,0 @@
1
- import { MixinClass } from "./mixinClass.js";
2
- import { OmitClass } from "./omitClass.js";
3
- import { PartialClass } from "./partialClass.js";
4
- import { PickClass } from "./pickClass.js";
5
- export const $Class = {
6
- mixin: MixinClass,
7
- omit: OmitClass,
8
- partial: PartialClass,
9
- pick: PickClass,
10
- };
@@ -1,8 +0,0 @@
1
- import { copyMetadataOfClasses, copyPropertiesOfClasses } from "./utils.js";
2
- export function MixinClass(...classRefs) {
3
- class TargetClass {
4
- }
5
- copyMetadataOfClasses(TargetClass.prototype, classRefs.map(item => item.prototype));
6
- copyPropertiesOfClasses(TargetClass, classRefs);
7
- return TargetClass;
8
- }
@@ -1,14 +0,0 @@
1
- import { copyMetadataOfClasses, copyPropertiesOfClasses } from "./utils.js";
2
- export function OmitClass(classRef, keys) {
3
- class TargetClass {
4
- }
5
- copyMetadataOfClasses(TargetClass.prototype, [classRef.prototype], (rules, key) => {
6
- if (!keys.includes(key)) {
7
- return rules[key];
8
- }
9
- });
10
- copyPropertiesOfClasses(TargetClass, [classRef], key => {
11
- return !keys.includes(key);
12
- });
13
- return TargetClass;
14
- }
@@ -1,16 +0,0 @@
1
- import { copyMetadataOfClasses, copyPropertiesOfClasses } from "./utils.js";
2
- export function PartialClass(classRef, keys) {
3
- class TargetClass {
4
- }
5
- copyMetadataOfClasses(TargetClass.prototype, [classRef.prototype], (rules, key, metadataKeyOptions) => {
6
- const schema = rules[key];
7
- if (keys && !keys.includes(key))
8
- return schema;
9
- if (metadataKeyOptions?.partialClass) {
10
- return metadataKeyOptions?.partialClass(schema);
11
- }
12
- return schema;
13
- });
14
- copyPropertiesOfClasses(TargetClass, [classRef]);
15
- return TargetClass;
16
- }
@@ -1,6 +0,0 @@
1
- import { PickClassInner } from "./pickClassInner.js";
2
- export function PickClass(classRef, keys) {
3
- class TargetClass {
4
- }
5
- return PickClassInner(TargetClass, classRef, keys);
6
- }
@@ -1,12 +0,0 @@
1
- import { copyMetadataOfClasses, copyPropertiesOfClasses } from "./utils.js";
2
- export function PickClassInner(classTarget, classRef, keys) {
3
- copyMetadataOfClasses(classTarget.prototype, [classRef.prototype], (rules, key) => {
4
- if (!keys || keys.includes(key)) {
5
- return rules[key];
6
- }
7
- });
8
- copyPropertiesOfClasses(classTarget, [classRef], key => {
9
- return !keys || keys.includes(key);
10
- });
11
- return classTarget;
12
- }
@@ -1 +0,0 @@
1
- export const SymbolMappedClassMetadataKeys = Symbol('SymbolMappedClassMetakeys');