@eggjs/mock 6.0.6 → 6.1.0-beta.10
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/README.md +35 -56
- package/README.zh_CN.md +30 -50
- package/dist/_virtual/rolldown_runtime.js +30 -0
- package/dist/app/extend/agent.d.ts +39 -0
- package/dist/app/extend/agent.js +48 -0
- package/dist/app/extend/application.d.ts +175 -0
- package/dist/app/extend/application.js +385 -0
- package/dist/app/middleware/cluster_app_mock.d.ts +6 -0
- package/dist/app/middleware/cluster_app_mock.js +97 -0
- package/dist/app.d.ts +10 -0
- package/dist/app.js +17 -0
- package/dist/bootstrap.d.ts +9 -0
- package/dist/bootstrap.js +14 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +47 -0
- package/dist/inject_mocha.d.ts +1 -0
- package/dist/inject_mocha.js +35 -0
- package/dist/lib/agent_handler.d.ts +7 -0
- package/dist/lib/agent_handler.js +26 -0
- package/dist/lib/app.d.ts +7 -0
- package/dist/lib/app.js +251 -0
- package/dist/lib/app_handler.d.ts +9 -0
- package/dist/lib/app_handler.js +56 -0
- package/dist/lib/cluster.d.ts +126 -0
- package/dist/lib/cluster.js +283 -0
- package/dist/lib/context.d.ts +4 -0
- package/dist/lib/context.js +12 -0
- package/dist/lib/format_options.d.ts +10 -0
- package/dist/lib/format_options.js +65 -0
- package/dist/lib/inject_context.d.ts +9 -0
- package/dist/lib/inject_context.js +106 -0
- package/dist/lib/mock_agent.d.ts +9 -0
- package/dist/lib/mock_agent.js +45 -0
- package/dist/lib/mock_custom_loader.d.ts +4 -0
- package/dist/lib/mock_custom_loader.js +35 -0
- package/dist/lib/mock_http_server.d.ts +6 -0
- package/dist/lib/mock_http_server.js +17 -0
- package/dist/lib/mock_httpclient.d.ts +40 -0
- package/dist/lib/mock_httpclient.js +110 -0
- package/dist/lib/parallel/agent.d.ts +24 -0
- package/dist/lib/parallel/agent.js +111 -0
- package/dist/lib/parallel/app.d.ts +24 -0
- package/dist/lib/parallel/app.js +99 -0
- package/dist/lib/parallel/util.d.ts +6 -0
- package/dist/lib/parallel/util.js +59 -0
- package/dist/lib/prerequire.d.ts +1 -0
- package/dist/lib/prerequire.js +1 -0
- package/dist/lib/request_call_function.d.ts +1 -0
- package/dist/lib/request_call_function.js +37 -0
- package/dist/lib/restore.d.ts +4 -0
- package/dist/lib/restore.js +16 -0
- package/dist/lib/start-cluster.d.ts +1 -0
- package/dist/lib/start-cluster.js +19 -0
- package/dist/lib/supertest.d.ts +16 -0
- package/dist/lib/supertest.js +39 -0
- package/dist/lib/tmp/empty.d.ts +1 -0
- package/dist/lib/tmp/empty.js +1 -0
- package/{src/lib/types.ts → dist/lib/types.d.ts} +12 -29
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils.d.ts +12 -0
- package/dist/lib/utils.js +40 -0
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +142 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +157 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +97 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +40 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +814 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +50 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +68 -0
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +752 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +203 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +209 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +18 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +215 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +24 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +33 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +29 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +185 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +83 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +51 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +151 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +178 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +168 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +301 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +137 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +367 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +91 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +99 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +30 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +22 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +97 -0
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +14 -0
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +16 -0
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +4093 -0
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +14 -0
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +27 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +12 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +83 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +35 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +392 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +86 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +104 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +99 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +65 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +18 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +95 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +1037 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +24 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +152 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +74 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +329 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +314 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +417 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +79 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +75 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +283 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +40 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +90 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +145 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +107 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +77 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +106 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +57 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +233 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +92 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +91 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +261 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +166 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +346 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +922 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +72 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +517 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +505 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +225 -0
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +124 -0
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +11 -0
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +114 -0
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +76 -0
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +89 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +366 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +248 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +419 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +27 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +18 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +16 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +63 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +21 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +9 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +277 -0
- package/dist/register.d.ts +10 -0
- package/dist/register.js +40 -0
- package/dist/typings/index.d.ts +1 -0
- package/package.json +71 -98
- package/dist/commonjs/app/extend/agent.d.ts +0 -34
- package/dist/commonjs/app/extend/agent.js +0 -49
- package/dist/commonjs/app/extend/application.d.ts +0 -171
- package/dist/commonjs/app/extend/application.js +0 -450
- package/dist/commonjs/app/middleware/cluster_app_mock.d.ts +0 -3
- package/dist/commonjs/app/middleware/cluster_app_mock.js +0 -101
- package/dist/commonjs/app.d.ts +0 -6
- package/dist/commonjs/app.js +0 -20
- package/dist/commonjs/bootstrap.d.ts +0 -5
- package/dist/commonjs/bootstrap.js +0 -59
- package/dist/commonjs/index.d.ts +0 -77
- package/dist/commonjs/index.js +0 -114
- package/dist/commonjs/lib/agent_handler.d.ts +0 -3
- package/dist/commonjs/lib/agent_handler.js +0 -28
- package/dist/commonjs/lib/app.d.ts +0 -3
- package/dist/commonjs/lib/app.js +0 -301
- package/dist/commonjs/lib/app_handler.d.ts +0 -5
- package/dist/commonjs/lib/app_handler.js +0 -71
- package/dist/commonjs/lib/cluster.d.ts +0 -114
- package/dist/commonjs/lib/cluster.js +0 -337
- package/dist/commonjs/lib/context.d.ts +0 -1
- package/dist/commonjs/lib/context.js +0 -16
- package/dist/commonjs/lib/format_options.d.ts +0 -5
- package/dist/commonjs/lib/format_options.js +0 -100
- package/dist/commonjs/lib/inject_context.d.ts +0 -6
- package/dist/commonjs/lib/inject_context.js +0 -132
- package/dist/commonjs/lib/mock_agent.d.ts +0 -5
- package/dist/commonjs/lib/mock_agent.js +0 -49
- package/dist/commonjs/lib/mock_custom_loader.d.ts +0 -1
- package/dist/commonjs/lib/mock_custom_loader.js +0 -37
- package/dist/commonjs/lib/mock_http_server.d.ts +0 -2
- package/dist/commonjs/lib/mock_http_server.js +0 -24
- package/dist/commonjs/lib/mock_httpclient.d.ts +0 -36
- package/dist/commonjs/lib/mock_httpclient.js +0 -147
- package/dist/commonjs/lib/parallel/agent.d.ts +0 -20
- package/dist/commonjs/lib/parallel/agent.js +0 -125
- package/dist/commonjs/lib/parallel/app.d.ts +0 -20
- package/dist/commonjs/lib/parallel/app.js +0 -115
- package/dist/commonjs/lib/parallel/util.d.ts +0 -3
- package/dist/commonjs/lib/parallel/util.js +0 -77
- package/dist/commonjs/lib/prerequire.d.ts +0 -1
- package/dist/commonjs/lib/prerequire.js +0 -26
- package/dist/commonjs/lib/request_call_function.d.ts +0 -1
- package/dist/commonjs/lib/request_call_function.js +0 -52
- package/dist/commonjs/lib/restore.d.ts +0 -1
- package/dist/commonjs/lib/restore.js +0 -16
- package/dist/commonjs/lib/start-cluster.d.ts +0 -2
- package/dist/commonjs/lib/start-cluster.js +0 -23
- package/dist/commonjs/lib/supertest.d.ts +0 -11
- package/dist/commonjs/lib/supertest.js +0 -48
- package/dist/commonjs/lib/tmp/empty.d.ts +0 -1
- package/dist/commonjs/lib/tmp/empty.js +0 -3
- package/dist/commonjs/lib/types.d.ts +0 -68
- package/dist/commonjs/lib/types.js +0 -3
- package/dist/commonjs/lib/utils.d.ts +0 -9
- package/dist/commonjs/lib/utils.js +0 -80
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/register.d.ts +0 -8
- package/dist/commonjs/register.js +0 -80
- package/dist/esm/app/extend/agent.d.ts +0 -34
- package/dist/esm/app/extend/agent.js +0 -46
- package/dist/esm/app/extend/application.d.ts +0 -171
- package/dist/esm/app/extend/application.js +0 -444
- package/dist/esm/app/middleware/cluster_app_mock.d.ts +0 -3
- package/dist/esm/app/middleware/cluster_app_mock.js +0 -99
- package/dist/esm/app.d.ts +0 -6
- package/dist/esm/app.js +0 -17
- package/dist/esm/bootstrap.d.ts +0 -5
- package/dist/esm/bootstrap.js +0 -15
- package/dist/esm/index.d.ts +0 -77
- package/dist/esm/index.js +0 -91
- package/dist/esm/lib/agent_handler.d.ts +0 -3
- package/dist/esm/lib/agent_handler.js +0 -24
- package/dist/esm/lib/app.d.ts +0 -3
- package/dist/esm/lib/app.js +0 -295
- package/dist/esm/lib/app_handler.d.ts +0 -5
- package/dist/esm/lib/app_handler.js +0 -65
- package/dist/esm/lib/cluster.d.ts +0 -114
- package/dist/esm/lib/cluster.js +0 -328
- package/dist/esm/lib/context.d.ts +0 -1
- package/dist/esm/lib/context.js +0 -13
- package/dist/esm/lib/format_options.d.ts +0 -5
- package/dist/esm/lib/format_options.js +0 -94
- package/dist/esm/lib/inject_context.d.ts +0 -6
- package/dist/esm/lib/inject_context.js +0 -126
- package/dist/esm/lib/mock_agent.d.ts +0 -5
- package/dist/esm/lib/mock_agent.js +0 -45
- package/dist/esm/lib/mock_custom_loader.d.ts +0 -1
- package/dist/esm/lib/mock_custom_loader.js +0 -34
- package/dist/esm/lib/mock_http_server.d.ts +0 -2
- package/dist/esm/lib/mock_http_server.js +0 -18
- package/dist/esm/lib/mock_httpclient.d.ts +0 -36
- package/dist/esm/lib/mock_httpclient.js +0 -144
- package/dist/esm/lib/parallel/agent.d.ts +0 -20
- package/dist/esm/lib/parallel/agent.js +0 -117
- package/dist/esm/lib/parallel/app.d.ts +0 -20
- package/dist/esm/lib/parallel/app.js +0 -110
- package/dist/esm/lib/parallel/util.d.ts +0 -3
- package/dist/esm/lib/parallel/util.js +0 -73
- package/dist/esm/lib/prerequire.d.ts +0 -1
- package/dist/esm/lib/prerequire.js +0 -25
- package/dist/esm/lib/request_call_function.d.ts +0 -1
- package/dist/esm/lib/request_call_function.js +0 -47
- package/dist/esm/lib/restore.d.ts +0 -1
- package/dist/esm/lib/restore.js +0 -13
- package/dist/esm/lib/start-cluster.d.ts +0 -2
- package/dist/esm/lib/start-cluster.js +0 -18
- package/dist/esm/lib/supertest.d.ts +0 -11
- package/dist/esm/lib/supertest.js +0 -40
- package/dist/esm/lib/tmp/empty.d.ts +0 -1
- package/dist/esm/lib/tmp/empty.js +0 -2
- package/dist/esm/lib/types.d.ts +0 -68
- package/dist/esm/lib/types.js +0 -2
- package/dist/esm/lib/utils.d.ts +0 -9
- package/dist/esm/lib/utils.js +0 -69
- package/dist/esm/package.json +0 -3
- package/dist/esm/register.d.ts +0 -8
- package/dist/esm/register.js +0 -75
- package/dist/package.json +0 -4
- package/src/app/extend/agent.ts +0 -57
- package/src/app/extend/application.ts +0 -510
- package/src/app/middleware/cluster_app_mock.ts +0 -102
- package/src/app.ts +0 -18
- package/src/bootstrap.ts +0 -25
- package/src/index.ts +0 -112
- package/src/lib/agent_handler.ts +0 -28
- package/src/lib/app.ts +0 -314
- package/src/lib/app_handler.ts +0 -77
- package/src/lib/cluster.ts +0 -363
- package/src/lib/context.ts +0 -14
- package/src/lib/format_options.ts +0 -103
- package/src/lib/inject_context.ts +0 -134
- package/src/lib/mock_agent.ts +0 -57
- package/src/lib/mock_custom_loader.ts +0 -36
- package/src/lib/mock_http_server.ts +0 -19
- package/src/lib/mock_httpclient.ts +0 -183
- package/src/lib/parallel/agent.ts +0 -128
- package/src/lib/parallel/app.ts +0 -123
- package/src/lib/parallel/util.ts +0 -66
- package/src/lib/prerequire.ts +0 -25
- package/src/lib/request_call_function.ts +0 -49
- package/src/lib/restore.ts +0 -14
- package/src/lib/start-cluster.ts +0 -23
- package/src/lib/supertest.ts +0 -45
- package/src/lib/tmp/.gitkeep +0 -0
- package/src/lib/tmp/empty.ts +0 -0
- package/src/lib/utils.ts +0 -82
- package/src/register.ts +0 -80
- package/src/typings/index.d.ts +0 -4
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { require_Promise } from "./Promise.js";
|
|
3
|
+
import { require_transfer } from "./transfer.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js
|
|
6
|
+
var require_worker = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js": ((exports) => {
|
|
7
|
+
/**
|
|
8
|
+
* worker must be started as a child process or a web worker.
|
|
9
|
+
* It listens for RPC messages from the parent process.
|
|
10
|
+
*/
|
|
11
|
+
var Transfer = require_transfer();
|
|
12
|
+
/**
|
|
13
|
+
* worker must handle async cleanup handlers. Use custom Promise implementation.
|
|
14
|
+
*/
|
|
15
|
+
var Promise$1 = require_Promise().Promise;
|
|
16
|
+
/**
|
|
17
|
+
* Special message sent by parent which causes the worker to terminate itself.
|
|
18
|
+
* Not a "message object"; this string is the entire message.
|
|
19
|
+
*/
|
|
20
|
+
var TERMINATE_METHOD_ID = "__workerpool-terminate__";
|
|
21
|
+
/**
|
|
22
|
+
* Special message by parent which causes a child process worker to perform cleaup
|
|
23
|
+
* steps before determining if the child process worker should be terminated.
|
|
24
|
+
*/
|
|
25
|
+
var CLEANUP_METHOD_ID = "__workerpool-cleanup__";
|
|
26
|
+
var TIMEOUT_DEFAULT = 1e3;
|
|
27
|
+
var worker = { exit: function() {} };
|
|
28
|
+
var publicWorker = {
|
|
29
|
+
addAbortListener: function(listener) {
|
|
30
|
+
worker.abortListeners.push(listener);
|
|
31
|
+
},
|
|
32
|
+
emit: worker.emit
|
|
33
|
+
};
|
|
34
|
+
if (typeof self !== "undefined" && typeof postMessage === "function" && typeof addEventListener === "function") {
|
|
35
|
+
worker.on = function(event, callback) {
|
|
36
|
+
addEventListener(event, function(message) {
|
|
37
|
+
callback(message.data);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
worker.send = function(message, transfer) {
|
|
41
|
+
transfer ? postMessage(message, transfer) : postMessage(message);
|
|
42
|
+
};
|
|
43
|
+
} else if (typeof process !== "undefined") {
|
|
44
|
+
var WorkerThreads;
|
|
45
|
+
try {
|
|
46
|
+
WorkerThreads = __require("worker_threads");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (typeof error === "object" && error !== null && error.code === "MODULE_NOT_FOUND") {} else throw error;
|
|
49
|
+
}
|
|
50
|
+
if (WorkerThreads && WorkerThreads.parentPort !== null) {
|
|
51
|
+
var parentPort = WorkerThreads.parentPort;
|
|
52
|
+
worker.send = parentPort.postMessage.bind(parentPort);
|
|
53
|
+
worker.on = parentPort.on.bind(parentPort);
|
|
54
|
+
worker.exit = process.exit.bind(process);
|
|
55
|
+
} else {
|
|
56
|
+
worker.on = process.on.bind(process);
|
|
57
|
+
worker.send = function(message) {
|
|
58
|
+
process.send(message);
|
|
59
|
+
};
|
|
60
|
+
worker.on("disconnect", function() {
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
63
|
+
worker.exit = process.exit.bind(process);
|
|
64
|
+
}
|
|
65
|
+
} else throw new Error("Script must be executed as a worker");
|
|
66
|
+
function convertError(error) {
|
|
67
|
+
if (error && error.toJSON) return JSON.parse(JSON.stringify(error));
|
|
68
|
+
return JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Test whether a value is a Promise via duck typing.
|
|
72
|
+
* @param {*} value
|
|
73
|
+
* @returns {boolean} Returns true when given value is an object
|
|
74
|
+
* having functions `then` and `catch`.
|
|
75
|
+
*/
|
|
76
|
+
function isPromise(value) {
|
|
77
|
+
return value && typeof value.then === "function" && typeof value.catch === "function";
|
|
78
|
+
}
|
|
79
|
+
worker.methods = {};
|
|
80
|
+
/**
|
|
81
|
+
* Execute a function with provided arguments
|
|
82
|
+
* @param {String} fn Stringified function
|
|
83
|
+
* @param {Array} [args] Function arguments
|
|
84
|
+
* @returns {*}
|
|
85
|
+
*/
|
|
86
|
+
worker.methods.run = function run(fn, args) {
|
|
87
|
+
var f = new Function("return (" + fn + ").apply(this, arguments);");
|
|
88
|
+
f.worker = publicWorker;
|
|
89
|
+
return f.apply(f, args);
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Get a list with methods available on this worker
|
|
93
|
+
* @return {String[]} methods
|
|
94
|
+
*/
|
|
95
|
+
worker.methods.methods = function methods() {
|
|
96
|
+
return Object.keys(worker.methods);
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Custom handler for when the worker is terminated.
|
|
100
|
+
*/
|
|
101
|
+
worker.terminationHandler = void 0;
|
|
102
|
+
worker.abortListenerTimeout = TIMEOUT_DEFAULT;
|
|
103
|
+
/**
|
|
104
|
+
* Abort handlers for resolving errors which may cause a timeout or cancellation
|
|
105
|
+
* to occur from a worker context
|
|
106
|
+
*/
|
|
107
|
+
worker.abortListeners = [];
|
|
108
|
+
/**
|
|
109
|
+
* Cleanup and exit the worker.
|
|
110
|
+
* @param {Number} code
|
|
111
|
+
* @returns {Promise<void>}
|
|
112
|
+
*/
|
|
113
|
+
worker.terminateAndExit = function(code) {
|
|
114
|
+
var _exit = function() {
|
|
115
|
+
worker.exit(code);
|
|
116
|
+
};
|
|
117
|
+
if (!worker.terminationHandler) return _exit();
|
|
118
|
+
var result = worker.terminationHandler(code);
|
|
119
|
+
if (isPromise(result)) {
|
|
120
|
+
result.then(_exit, _exit);
|
|
121
|
+
return result;
|
|
122
|
+
} else {
|
|
123
|
+
_exit();
|
|
124
|
+
return new Promise$1(function(_resolve, reject) {
|
|
125
|
+
reject(/* @__PURE__ */ new Error("Worker terminating"));
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Called within the worker message handler to run abort handlers if registered to perform cleanup operations.
|
|
131
|
+
* @param {Integer} [requestId] id of task which is currently executing in the worker
|
|
132
|
+
* @return {Promise<void>}
|
|
133
|
+
*/
|
|
134
|
+
worker.cleanup = function(requestId) {
|
|
135
|
+
if (!worker.abortListeners.length) {
|
|
136
|
+
worker.send({
|
|
137
|
+
id: requestId,
|
|
138
|
+
method: CLEANUP_METHOD_ID,
|
|
139
|
+
error: convertError(/* @__PURE__ */ new Error("Worker terminating"))
|
|
140
|
+
});
|
|
141
|
+
return new Promise$1(function(resolve) {
|
|
142
|
+
resolve();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
var _exit = function() {
|
|
146
|
+
worker.exit();
|
|
147
|
+
};
|
|
148
|
+
var _abort = function() {
|
|
149
|
+
if (!worker.abortListeners.length) worker.abortListeners = [];
|
|
150
|
+
};
|
|
151
|
+
const promises = worker.abortListeners.map((listener) => listener());
|
|
152
|
+
let timerId;
|
|
153
|
+
const timeoutPromise = new Promise$1((_resolve, reject) => {
|
|
154
|
+
timerId = setTimeout(function() {
|
|
155
|
+
reject(/* @__PURE__ */ new Error("Timeout occured waiting for abort handler, killing worker"));
|
|
156
|
+
}, worker.abortListenerTimeout);
|
|
157
|
+
});
|
|
158
|
+
const settlePromise = Promise$1.all(promises).then(function() {
|
|
159
|
+
clearTimeout(timerId);
|
|
160
|
+
_abort();
|
|
161
|
+
}, function() {
|
|
162
|
+
clearTimeout(timerId);
|
|
163
|
+
_exit();
|
|
164
|
+
});
|
|
165
|
+
return new Promise$1(function(resolve, reject) {
|
|
166
|
+
settlePromise.then(resolve, reject);
|
|
167
|
+
timeoutPromise.then(resolve, reject);
|
|
168
|
+
}).then(function() {
|
|
169
|
+
worker.send({
|
|
170
|
+
id: requestId,
|
|
171
|
+
method: CLEANUP_METHOD_ID,
|
|
172
|
+
error: null
|
|
173
|
+
});
|
|
174
|
+
}, function(err) {
|
|
175
|
+
worker.send({
|
|
176
|
+
id: requestId,
|
|
177
|
+
method: CLEANUP_METHOD_ID,
|
|
178
|
+
error: err ? convertError(err) : null
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
var currentRequestId = null;
|
|
183
|
+
worker.on("message", function(request) {
|
|
184
|
+
if (request === TERMINATE_METHOD_ID) return worker.terminateAndExit(0);
|
|
185
|
+
if (request.method === CLEANUP_METHOD_ID) return worker.cleanup(request.id);
|
|
186
|
+
try {
|
|
187
|
+
var method = worker.methods[request.method];
|
|
188
|
+
if (method) {
|
|
189
|
+
currentRequestId = request.id;
|
|
190
|
+
var result = method.apply(method, request.params);
|
|
191
|
+
if (isPromise(result)) result.then(function(result$1) {
|
|
192
|
+
if (result$1 instanceof Transfer) worker.send({
|
|
193
|
+
id: request.id,
|
|
194
|
+
result: result$1.message,
|
|
195
|
+
error: null
|
|
196
|
+
}, result$1.transfer);
|
|
197
|
+
else worker.send({
|
|
198
|
+
id: request.id,
|
|
199
|
+
result: result$1,
|
|
200
|
+
error: null
|
|
201
|
+
});
|
|
202
|
+
currentRequestId = null;
|
|
203
|
+
}).catch(function(err) {
|
|
204
|
+
worker.send({
|
|
205
|
+
id: request.id,
|
|
206
|
+
result: null,
|
|
207
|
+
error: convertError(err)
|
|
208
|
+
});
|
|
209
|
+
currentRequestId = null;
|
|
210
|
+
});
|
|
211
|
+
else {
|
|
212
|
+
if (result instanceof Transfer) worker.send({
|
|
213
|
+
id: request.id,
|
|
214
|
+
result: result.message,
|
|
215
|
+
error: null
|
|
216
|
+
}, result.transfer);
|
|
217
|
+
else worker.send({
|
|
218
|
+
id: request.id,
|
|
219
|
+
result,
|
|
220
|
+
error: null
|
|
221
|
+
});
|
|
222
|
+
currentRequestId = null;
|
|
223
|
+
}
|
|
224
|
+
} else throw new Error("Unknown method \"" + request.method + "\"");
|
|
225
|
+
} catch (err) {
|
|
226
|
+
worker.send({
|
|
227
|
+
id: request.id,
|
|
228
|
+
result: null,
|
|
229
|
+
error: convertError(err)
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
/**
|
|
234
|
+
* Register methods to the worker
|
|
235
|
+
* @param {Object} [methods]
|
|
236
|
+
* @param {import('./types.js').WorkerRegisterOptions} [options]
|
|
237
|
+
*/
|
|
238
|
+
worker.register = function(methods, options) {
|
|
239
|
+
if (methods) {
|
|
240
|
+
for (var name in methods) if (methods.hasOwnProperty(name)) {
|
|
241
|
+
worker.methods[name] = methods[name];
|
|
242
|
+
worker.methods[name].worker = publicWorker;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (options) {
|
|
246
|
+
worker.terminationHandler = options.onTerminate;
|
|
247
|
+
worker.abortListenerTimeout = options.abortListenerTimeout || TIMEOUT_DEFAULT;
|
|
248
|
+
}
|
|
249
|
+
worker.send("ready");
|
|
250
|
+
};
|
|
251
|
+
worker.emit = function(payload) {
|
|
252
|
+
if (currentRequestId) {
|
|
253
|
+
if (payload instanceof Transfer) {
|
|
254
|
+
worker.send({
|
|
255
|
+
id: currentRequestId,
|
|
256
|
+
isEvent: true,
|
|
257
|
+
payload: payload.message
|
|
258
|
+
}, payload.transfer);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
worker.send({
|
|
262
|
+
id: currentRequestId,
|
|
263
|
+
isEvent: true,
|
|
264
|
+
payload
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
if (typeof exports !== "undefined") {
|
|
269
|
+
exports.add = worker.register;
|
|
270
|
+
exports.emit = worker.emit;
|
|
271
|
+
}
|
|
272
|
+
}) });
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
export default require_worker();
|
|
276
|
+
|
|
277
|
+
export { require_worker };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/register.d.ts
|
|
2
|
+
declare function mochaGlobalSetup(): Promise<void>;
|
|
3
|
+
declare function mochaGlobalTeardown(): Promise<void>;
|
|
4
|
+
declare const mochaHooks: {
|
|
5
|
+
beforeAll(): Promise<void>;
|
|
6
|
+
afterEach(): Promise<void>;
|
|
7
|
+
afterAll(): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { mochaGlobalSetup, mochaGlobalTeardown, mochaHooks };
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { closeAgent, setupAgent } from "./lib/agent_handler.js";
|
|
2
|
+
import { getApp } from "./lib/app_handler.js";
|
|
3
|
+
import { mm as proxyMock } from "./index.js";
|
|
4
|
+
import "./inject_mocha.js";
|
|
5
|
+
import { debuglog } from "node:util";
|
|
6
|
+
|
|
7
|
+
//#region src/register.ts
|
|
8
|
+
const debug = debuglog("egg/mock/register");
|
|
9
|
+
async function mochaGlobalSetup() {
|
|
10
|
+
debug("mochaGlobalSetup, agent.setupAgent() start");
|
|
11
|
+
await setupAgent();
|
|
12
|
+
debug("mochaGlobalSetup, agent.setupAgent() end");
|
|
13
|
+
}
|
|
14
|
+
async function mochaGlobalTeardown() {
|
|
15
|
+
debug("mochaGlobalTeardown, agent.closeAgent() start");
|
|
16
|
+
await closeAgent();
|
|
17
|
+
debug("mochaGlobalTeardown, agent.closeAgent() end");
|
|
18
|
+
}
|
|
19
|
+
const mochaHooks = {
|
|
20
|
+
async beforeAll() {
|
|
21
|
+
const app = await getApp();
|
|
22
|
+
debug("mochaHooks.beforeAll call, _app: %s", app);
|
|
23
|
+
if (app) await app.ready();
|
|
24
|
+
},
|
|
25
|
+
async afterEach() {
|
|
26
|
+
const app = await getApp();
|
|
27
|
+
debug("mochaHooks.afterEach call, _app: %s", app);
|
|
28
|
+
if (app) await app.backgroundTasksFinished();
|
|
29
|
+
await proxyMock.restore();
|
|
30
|
+
},
|
|
31
|
+
async afterAll() {
|
|
32
|
+
if (process.env.ENABLE_MOCHA_PARALLEL) return;
|
|
33
|
+
const app = await getApp();
|
|
34
|
+
debug("mochaHooks.afterAll call, _app: %s", app);
|
|
35
|
+
if (app) await app.close();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { mochaGlobalSetup, mochaGlobalTeardown, mochaHooks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "egg";
|
package/package.json
CHANGED
|
@@ -1,136 +1,109 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/mock",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.1.0-beta.10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"eggPlugin": {
|
|
8
|
-
"name": "egg-mock"
|
|
9
|
-
"exports": {
|
|
10
|
-
"import": "./dist/esm",
|
|
11
|
-
"require": "./dist/commonjs"
|
|
12
|
-
}
|
|
8
|
+
"name": "egg-mock"
|
|
13
9
|
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./dist/index.js",
|
|
16
|
+
"./app": "./dist/app.js",
|
|
17
|
+
"./app/extend/agent": "./dist/app/extend/agent.js",
|
|
18
|
+
"./app/extend/application": "./dist/app/extend/application.js",
|
|
19
|
+
"./app/middleware/cluster_app_mock": "./dist/app/middleware/cluster_app_mock.js",
|
|
20
|
+
"./bootstrap": "./dist/bootstrap.js",
|
|
21
|
+
"./inject_mocha": "./dist/inject_mocha.js",
|
|
22
|
+
"./lib/agent_handler": "./dist/lib/agent_handler.js",
|
|
23
|
+
"./lib/app": "./dist/lib/app.js",
|
|
24
|
+
"./lib/app_handler": "./dist/lib/app_handler.js",
|
|
25
|
+
"./lib/cluster": "./dist/lib/cluster.js",
|
|
26
|
+
"./lib/context": "./dist/lib/context.js",
|
|
27
|
+
"./lib/format_options": "./dist/lib/format_options.js",
|
|
28
|
+
"./lib/inject_context": "./dist/lib/inject_context.js",
|
|
29
|
+
"./lib/mock_agent": "./dist/lib/mock_agent.js",
|
|
30
|
+
"./lib/mock_custom_loader": "./dist/lib/mock_custom_loader.js",
|
|
31
|
+
"./lib/mock_http_server": "./dist/lib/mock_http_server.js",
|
|
32
|
+
"./lib/mock_httpclient": "./dist/lib/mock_httpclient.js",
|
|
33
|
+
"./lib/parallel/agent": "./dist/lib/parallel/agent.js",
|
|
34
|
+
"./lib/parallel/app": "./dist/lib/parallel/app.js",
|
|
35
|
+
"./lib/parallel/util": "./dist/lib/parallel/util.js",
|
|
36
|
+
"./lib/prerequire": "./dist/lib/prerequire.js",
|
|
37
|
+
"./lib/request_call_function": "./dist/lib/request_call_function.js",
|
|
38
|
+
"./lib/restore": "./dist/lib/restore.js",
|
|
39
|
+
"./lib/start-cluster": "./dist/lib/start-cluster.js",
|
|
40
|
+
"./lib/supertest": "./dist/lib/supertest.js",
|
|
41
|
+
"./lib/tmp/empty": "./dist/lib/tmp/empty.js",
|
|
42
|
+
"./lib/types": "./dist/lib/types.js",
|
|
43
|
+
"./lib/utils": "./dist/lib/utils.js",
|
|
44
|
+
"./register": "./dist/register.js",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist"
|
|
49
|
+
],
|
|
14
50
|
"description": "mock server plugin for egg",
|
|
15
|
-
"homepage": "https://github.com/eggjs/mock",
|
|
16
51
|
"repository": {
|
|
17
52
|
"type": "git",
|
|
18
|
-
"url": "git
|
|
53
|
+
"url": "git://github.com/eggjs/egg.git",
|
|
54
|
+
"directory": "packages/mock"
|
|
19
55
|
},
|
|
20
56
|
"bugs": {
|
|
21
57
|
"url": "https://github.com/eggjs/egg/issues"
|
|
22
58
|
},
|
|
59
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/packages/mock",
|
|
23
60
|
"keywords": [
|
|
24
61
|
"egg",
|
|
25
62
|
"mock"
|
|
26
63
|
],
|
|
27
64
|
"author": "popomore <sakura9515@gmail.com>",
|
|
28
65
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
66
|
+
"node": ">= 20.19.0"
|
|
30
67
|
},
|
|
31
68
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"@eggjs/supertest": "^8.1.0",
|
|
34
|
-
"@eggjs/utils": "^4.0.3",
|
|
35
|
-
"coffee": "^5.2.1",
|
|
69
|
+
"coffee": "5",
|
|
36
70
|
"detect-port": "^2.1.0",
|
|
37
71
|
"egg-logger": "^3.5.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"globby": "^11.1.0",
|
|
72
|
+
"get-ready": "^3.1.0",
|
|
73
|
+
"globby": "^11.0.2",
|
|
41
74
|
"is-type-of": "^2.2.0",
|
|
42
75
|
"merge-descriptors": "^2.0.0",
|
|
43
|
-
"mm": "^4.0.
|
|
44
|
-
"sdk-base": "^5.0.
|
|
76
|
+
"mm": "^4.0.2",
|
|
77
|
+
"sdk-base": "^5.0.1",
|
|
45
78
|
"urllib": "^4.6.11",
|
|
46
|
-
"utility": "^2.
|
|
79
|
+
"utility": "^2.5.0",
|
|
80
|
+
"@eggjs/core": "6.6.0-beta.10",
|
|
81
|
+
"@eggjs/extend2": "4.1.0-beta.10",
|
|
82
|
+
"@eggjs/supertest": "8.3.0-beta.10",
|
|
83
|
+
"@eggjs/utils": "4.5.0-beta.10"
|
|
47
84
|
},
|
|
48
85
|
"peerDependencies": {
|
|
49
|
-
"
|
|
86
|
+
"egg": "4.1.0-beta.10"
|
|
50
87
|
},
|
|
51
88
|
"devDependencies": {
|
|
52
|
-
"@arethetypeswrong/cli": "^0.17.1",
|
|
53
|
-
"@eggjs/bin": "^7.0.0",
|
|
54
89
|
"@eggjs/tegg": "^3.2.2",
|
|
55
90
|
"@eggjs/tegg-config": "^3.2.2",
|
|
56
91
|
"@eggjs/tegg-controller-plugin": "^3.2.2",
|
|
57
92
|
"@eggjs/tegg-plugin": "^3.2.2",
|
|
58
|
-
"@eggjs/tsconfig": "1",
|
|
59
93
|
"@types/methods": "^1.1.4",
|
|
60
|
-
"@types/
|
|
61
|
-
"
|
|
62
|
-
"egg": "^
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"pedding": "^2.0.0",
|
|
69
|
-
"rimraf": "6",
|
|
70
|
-
"tsd": "^0.31.2",
|
|
71
|
-
"tshy": "3",
|
|
72
|
-
"tshy-after": "^1.3.1",
|
|
73
|
-
"typescript": "5"
|
|
94
|
+
"@types/node": "24.5.2",
|
|
95
|
+
"egg-errors": "^2.3.2",
|
|
96
|
+
"egg-tracer": "^2.1.0",
|
|
97
|
+
"pedding": "^2.0.1",
|
|
98
|
+
"tsd": "^0.33.0",
|
|
99
|
+
"tsdown": "^0.15.4",
|
|
100
|
+
"typescript": "5.9.2",
|
|
101
|
+
"egg": "4.1.0-beta.10"
|
|
74
102
|
},
|
|
75
103
|
"scripts": {
|
|
76
|
-
"
|
|
77
|
-
"lint": "
|
|
78
|
-
"
|
|
79
|
-
"test": "
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"preci": "npm run clean && npm run lint && npm run prepublishOnly",
|
|
83
|
-
"ci": "egg-bin test",
|
|
84
|
-
"postci": "npm run clean",
|
|
85
|
-
"prepublishOnly": "tshy && tshy-after && attw --pack --profile node16"
|
|
86
|
-
},
|
|
87
|
-
"type": "module",
|
|
88
|
-
"tshy": {
|
|
89
|
-
"exports": {
|
|
90
|
-
".": "./src/index.ts",
|
|
91
|
-
"./bootstrap": "./src/bootstrap.ts",
|
|
92
|
-
"./register": "./src/register.ts",
|
|
93
|
-
"./package.json": "./package.json"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"exports": {
|
|
97
|
-
".": {
|
|
98
|
-
"import": {
|
|
99
|
-
"types": "./dist/esm/index.d.ts",
|
|
100
|
-
"default": "./dist/esm/index.js"
|
|
101
|
-
},
|
|
102
|
-
"require": {
|
|
103
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
104
|
-
"default": "./dist/commonjs/index.js"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"./bootstrap": {
|
|
108
|
-
"import": {
|
|
109
|
-
"types": "./dist/esm/bootstrap.d.ts",
|
|
110
|
-
"default": "./dist/esm/bootstrap.js"
|
|
111
|
-
},
|
|
112
|
-
"require": {
|
|
113
|
-
"types": "./dist/commonjs/bootstrap.d.ts",
|
|
114
|
-
"default": "./dist/commonjs/bootstrap.js"
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
"./register": {
|
|
118
|
-
"import": {
|
|
119
|
-
"types": "./dist/esm/register.d.ts",
|
|
120
|
-
"default": "./dist/esm/register.js"
|
|
121
|
-
},
|
|
122
|
-
"require": {
|
|
123
|
-
"types": "./dist/commonjs/register.d.ts",
|
|
124
|
-
"default": "./dist/commonjs/register.js"
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
"./package.json": "./package.json"
|
|
128
|
-
},
|
|
129
|
-
"files": [
|
|
130
|
-
"dist",
|
|
131
|
-
"src"
|
|
132
|
-
],
|
|
133
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
134
|
-
"main": "./dist/commonjs/index.js",
|
|
135
|
-
"module": "./dist/esm/index.js"
|
|
136
|
-
}
|
|
104
|
+
"build": "tsdown",
|
|
105
|
+
"lint": "oxlint",
|
|
106
|
+
"typecheck": "tsc --noEmit",
|
|
107
|
+
"test": "vitest run"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { mock, restore } from 'mm';
|
|
2
|
-
import { EggCore } from '@eggjs/core';
|
|
3
|
-
import { MockResultFunction, MockResultOptions, MockHttpClientMethod } from '../../lib/mock_httpclient.js';
|
|
4
|
-
export default abstract class AgentUnittest extends EggCore {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
_mockHttpClient: MockHttpClientMethod;
|
|
7
|
-
/**
|
|
8
|
-
* mock httpclient
|
|
9
|
-
* @alias mockHttpClient
|
|
10
|
-
* @function App#mockHttpclient
|
|
11
|
-
*/
|
|
12
|
-
mockHttpclient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): void;
|
|
13
|
-
/**
|
|
14
|
-
* mock httpclient
|
|
15
|
-
* @function App#mockHttpClient
|
|
16
|
-
*/
|
|
17
|
-
mockHttpClient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): void;
|
|
18
|
-
/**
|
|
19
|
-
* get mock httpclient agent
|
|
20
|
-
* @function Agent#mockHttpclientAgent
|
|
21
|
-
*/
|
|
22
|
-
mockAgent(): import("urllib").MockAgent<import("urllib").MockAgent.Options>;
|
|
23
|
-
mockAgentRestore(): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* @see mm#restore
|
|
26
|
-
* @function Agent#mockRestore
|
|
27
|
-
*/
|
|
28
|
-
mockRestore: typeof restore;
|
|
29
|
-
/**
|
|
30
|
-
* @see mm
|
|
31
|
-
* @function Agent#mm
|
|
32
|
-
*/
|
|
33
|
-
mm: typeof mock;
|
|
34
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mm_1 = require("mm");
|
|
4
|
-
const core_1 = require("@eggjs/core");
|
|
5
|
-
const mock_httpclient_js_1 = require("../../lib/mock_httpclient.js");
|
|
6
|
-
const mock_agent_js_1 = require("../../lib/mock_agent.js");
|
|
7
|
-
class AgentUnittest extends core_1.EggCore {
|
|
8
|
-
_mockHttpClient;
|
|
9
|
-
/**
|
|
10
|
-
* mock httpclient
|
|
11
|
-
* @alias mockHttpClient
|
|
12
|
-
* @function App#mockHttpclient
|
|
13
|
-
*/
|
|
14
|
-
mockHttpclient(mockUrl, mockMethod, mockResult) {
|
|
15
|
-
return this.mockHttpClient(mockUrl, mockMethod, mockResult);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* mock httpclient
|
|
19
|
-
* @function App#mockHttpClient
|
|
20
|
-
*/
|
|
21
|
-
mockHttpClient(mockUrl, mockMethod, mockResult) {
|
|
22
|
-
if (!this._mockHttpClient) {
|
|
23
|
-
this._mockHttpClient = (0, mock_httpclient_js_1.createMockHttpClient)(this);
|
|
24
|
-
}
|
|
25
|
-
return this._mockHttpClient(mockUrl, mockMethod, mockResult);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* get mock httpclient agent
|
|
29
|
-
* @function Agent#mockHttpclientAgent
|
|
30
|
-
*/
|
|
31
|
-
mockAgent() {
|
|
32
|
-
return (0, mock_agent_js_1.getMockAgent)(this);
|
|
33
|
-
}
|
|
34
|
-
async mockAgentRestore() {
|
|
35
|
-
await (0, mock_agent_js_1.restoreMockAgent)();
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @see mm#restore
|
|
39
|
-
* @function Agent#mockRestore
|
|
40
|
-
*/
|
|
41
|
-
mockRestore = mm_1.restore;
|
|
42
|
-
/**
|
|
43
|
-
* @see mm
|
|
44
|
-
* @function Agent#mm
|
|
45
|
-
*/
|
|
46
|
-
mm = mm_1.mock;
|
|
47
|
-
}
|
|
48
|
-
exports.default = AgentUnittest;
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hZ2VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDJCQUFtQztBQUNuQyxzQ0FBc0M7QUFDdEMscUVBSXNDO0FBQ3RDLDJEQUF5RTtBQUV6RSxNQUE4QixhQUFjLFNBQVEsY0FBTztJQUV6RCxlQUFlLENBQXVCO0lBRXRDOzs7O09BSUc7SUFDSCxjQUFjLENBQUMsT0FBd0IsRUFBRSxVQUFzRSxFQUFFLFVBQTREO1FBQzNLLE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLEVBQUUsVUFBVSxFQUFFLFVBQVUsQ0FBQyxDQUFDO0lBQzlELENBQUM7SUFFRDs7O09BR0c7SUFDSCxjQUFjLENBQUMsT0FBd0IsRUFBRSxVQUFzRSxFQUFFLFVBQTREO1FBQzNLLElBQUksQ0FBQyxJQUFJLENBQUMsZUFBZSxFQUFFLENBQUM7WUFDMUIsSUFBSSxDQUFDLGVBQWUsR0FBRyxJQUFBLHlDQUFvQixFQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3BELENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsT0FBTyxFQUFFLFVBQVUsRUFBRSxVQUFVLENBQUMsQ0FBQztJQUMvRCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsU0FBUztRQUNQLE9BQU8sSUFBQSw0QkFBWSxFQUFDLElBQVcsQ0FBQyxDQUFDO0lBQ25DLENBQUM7SUFFRCxLQUFLLENBQUMsZ0JBQWdCO1FBQ3BCLE1BQU0sSUFBQSxnQ0FBZ0IsR0FBRSxDQUFDO0lBQzNCLENBQUM7SUFFRDs7O09BR0c7SUFDSCxXQUFXLEdBQUcsWUFBTyxDQUFDO0lBRXRCOzs7T0FHRztJQUNILEVBQUUsR0FBRyxTQUFJLENBQUM7Q0FDWDtBQS9DRCxnQ0ErQ0MifQ==
|