typespeed 2.4.1 → 2.4.2

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 (246) hide show
  1. package/dist/introduction/decorator/example-import.class.js +17 -0
  2. package/dist/introduction/decorator/main-app.js +14 -0
  3. package/dist/introduction/decorator/main-decorator.js +127 -0
  4. package/dist/introduction/decorator/main-import.js +1 -0
  5. package/dist/introduction/decorator/main-reflect.js +38 -0
  6. package/dist/introduction/web-services/db-init.js +33 -0
  7. package/dist/introduction/web-services/db-singleton.js +49 -0
  8. package/dist/introduction/web-services/http-if.js +12 -0
  9. package/dist/introduction/web-services/http-init.js +7 -0
  10. package/dist/introduction/web-services/http-router.js +23 -0
  11. package/dist/{database.decorator.js → src/database.decorator.js} +2 -4
  12. package/package.json +2 -4
  13. package/src/database.decorator.ts +2 -4
  14. package/tsconfig.json +2 -1
  15. package/app/node_modules/.package-lock.json +0 -134
  16. package/app/node_modules/@types/body-parser/LICENSE +0 -21
  17. package/app/node_modules/@types/body-parser/README.md +0 -16
  18. package/app/node_modules/@types/body-parser/index.d.ts +0 -107
  19. package/app/node_modules/@types/body-parser/package.json +0 -58
  20. package/app/node_modules/@types/connect/LICENSE +0 -21
  21. package/app/node_modules/@types/connect/README.md +0 -16
  22. package/app/node_modules/@types/connect/index.d.ts +0 -93
  23. package/app/node_modules/@types/connect/package.json +0 -32
  24. package/app/node_modules/@types/express/LICENSE +0 -21
  25. package/app/node_modules/@types/express/README.md +0 -16
  26. package/app/node_modules/@types/express/index.d.ts +0 -136
  27. package/app/node_modules/@types/express/package.json +0 -45
  28. package/app/node_modules/@types/express-serve-static-core/LICENSE +0 -21
  29. package/app/node_modules/@types/express-serve-static-core/README.md +0 -16
  30. package/app/node_modules/@types/express-serve-static-core/index.d.ts +0 -1281
  31. package/app/node_modules/@types/express-serve-static-core/package.json +0 -55
  32. package/app/node_modules/@types/mime/LICENSE +0 -21
  33. package/app/node_modules/@types/mime/Mime.d.ts +0 -10
  34. package/app/node_modules/@types/mime/README.md +0 -16
  35. package/app/node_modules/@types/mime/index.d.ts +0 -35
  36. package/app/node_modules/@types/mime/lite.d.ts +0 -7
  37. package/app/node_modules/@types/mime/package.json +0 -29
  38. package/app/node_modules/@types/node/LICENSE +0 -21
  39. package/app/node_modules/@types/node/README.md +0 -16
  40. package/app/node_modules/@types/node/assert/strict.d.ts +0 -8
  41. package/app/node_modules/@types/node/assert.d.ts +0 -961
  42. package/app/node_modules/@types/node/async_hooks.d.ts +0 -518
  43. package/app/node_modules/@types/node/buffer.d.ts +0 -2323
  44. package/app/node_modules/@types/node/child_process.d.ts +0 -1399
  45. package/app/node_modules/@types/node/cluster.d.ts +0 -410
  46. package/app/node_modules/@types/node/console.d.ts +0 -412
  47. package/app/node_modules/@types/node/constants.d.ts +0 -18
  48. package/app/node_modules/@types/node/crypto.d.ts +0 -3973
  49. package/app/node_modules/@types/node/dgram.d.ts +0 -545
  50. package/app/node_modules/@types/node/diagnostics_channel.d.ts +0 -192
  51. package/app/node_modules/@types/node/dns/promises.d.ts +0 -370
  52. package/app/node_modules/@types/node/dns.d.ts +0 -660
  53. package/app/node_modules/@types/node/dom-events.d.ts +0 -126
  54. package/app/node_modules/@types/node/domain.d.ts +0 -170
  55. package/app/node_modules/@types/node/events.d.ts +0 -682
  56. package/app/node_modules/@types/node/fs/promises.d.ts +0 -1159
  57. package/app/node_modules/@types/node/fs.d.ts +0 -3976
  58. package/app/node_modules/@types/node/globals.d.ts +0 -303
  59. package/app/node_modules/@types/node/globals.global.d.ts +0 -1
  60. package/app/node_modules/@types/node/http.d.ts +0 -1714
  61. package/app/node_modules/@types/node/http2.d.ts +0 -2133
  62. package/app/node_modules/@types/node/https.d.ts +0 -542
  63. package/app/node_modules/@types/node/index.d.ts +0 -134
  64. package/app/node_modules/@types/node/inspector.d.ts +0 -2741
  65. package/app/node_modules/@types/node/module.d.ts +0 -115
  66. package/app/node_modules/@types/node/net.d.ts +0 -883
  67. package/app/node_modules/@types/node/os.d.ts +0 -473
  68. package/app/node_modules/@types/node/package.json +0 -237
  69. package/app/node_modules/@types/node/path.d.ts +0 -191
  70. package/app/node_modules/@types/node/perf_hooks.d.ts +0 -625
  71. package/app/node_modules/@types/node/process.d.ts +0 -1488
  72. package/app/node_modules/@types/node/punycode.d.ts +0 -117
  73. package/app/node_modules/@types/node/querystring.d.ts +0 -131
  74. package/app/node_modules/@types/node/readline/promises.d.ts +0 -143
  75. package/app/node_modules/@types/node/readline.d.ts +0 -653
  76. package/app/node_modules/@types/node/repl.d.ts +0 -424
  77. package/app/node_modules/@types/node/stream/consumers.d.ts +0 -12
  78. package/app/node_modules/@types/node/stream/promises.d.ts +0 -42
  79. package/app/node_modules/@types/node/stream/web.d.ts +0 -330
  80. package/app/node_modules/@types/node/stream.d.ts +0 -1440
  81. package/app/node_modules/@types/node/string_decoder.d.ts +0 -67
  82. package/app/node_modules/@types/node/test.d.ts +0 -783
  83. package/app/node_modules/@types/node/timers/promises.d.ts +0 -93
  84. package/app/node_modules/@types/node/timers.d.ts +0 -101
  85. package/app/node_modules/@types/node/tls.d.ts +0 -1111
  86. package/app/node_modules/@types/node/trace_events.d.ts +0 -171
  87. package/app/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  88. package/app/node_modules/@types/node/ts4.8/assert.d.ts +0 -961
  89. package/app/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -518
  90. package/app/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2323
  91. package/app/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1399
  92. package/app/node_modules/@types/node/ts4.8/cluster.d.ts +0 -410
  93. package/app/node_modules/@types/node/ts4.8/console.d.ts +0 -412
  94. package/app/node_modules/@types/node/ts4.8/constants.d.ts +0 -18
  95. package/app/node_modules/@types/node/ts4.8/crypto.d.ts +0 -3972
  96. package/app/node_modules/@types/node/ts4.8/dgram.d.ts +0 -545
  97. package/app/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -192
  98. package/app/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -370
  99. package/app/node_modules/@types/node/ts4.8/dns.d.ts +0 -660
  100. package/app/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -126
  101. package/app/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  102. package/app/node_modules/@types/node/ts4.8/events.d.ts +0 -682
  103. package/app/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1138
  104. package/app/node_modules/@types/node/ts4.8/fs.d.ts +0 -3875
  105. package/app/node_modules/@types/node/ts4.8/globals.d.ts +0 -302
  106. package/app/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  107. package/app/node_modules/@types/node/ts4.8/http.d.ts +0 -1651
  108. package/app/node_modules/@types/node/ts4.8/http2.d.ts +0 -2133
  109. package/app/node_modules/@types/node/ts4.8/https.d.ts +0 -542
  110. package/app/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  111. package/app/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2741
  112. package/app/node_modules/@types/node/ts4.8/module.d.ts +0 -115
  113. package/app/node_modules/@types/node/ts4.8/net.d.ts +0 -883
  114. package/app/node_modules/@types/node/ts4.8/os.d.ts +0 -473
  115. package/app/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  116. package/app/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -625
  117. package/app/node_modules/@types/node/ts4.8/process.d.ts +0 -1488
  118. package/app/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  119. package/app/node_modules/@types/node/ts4.8/querystring.d.ts +0 -131
  120. package/app/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -143
  121. package/app/node_modules/@types/node/ts4.8/readline.d.ts +0 -653
  122. package/app/node_modules/@types/node/ts4.8/repl.d.ts +0 -424
  123. package/app/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  124. package/app/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -42
  125. package/app/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -330
  126. package/app/node_modules/@types/node/ts4.8/stream.d.ts +0 -1440
  127. package/app/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  128. package/app/node_modules/@types/node/ts4.8/test.d.ts +0 -784
  129. package/app/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  130. package/app/node_modules/@types/node/ts4.8/timers.d.ts +0 -94
  131. package/app/node_modules/@types/node/ts4.8/tls.d.ts +0 -1111
  132. package/app/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -171
  133. package/app/node_modules/@types/node/ts4.8/tty.d.ts +0 -206
  134. package/app/node_modules/@types/node/ts4.8/url.d.ts +0 -902
  135. package/app/node_modules/@types/node/ts4.8/util.d.ts +0 -2017
  136. package/app/node_modules/@types/node/ts4.8/v8.d.ts +0 -541
  137. package/app/node_modules/@types/node/ts4.8/vm.d.ts +0 -644
  138. package/app/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  139. package/app/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -695
  140. package/app/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  141. package/app/node_modules/@types/node/tty.d.ts +0 -206
  142. package/app/node_modules/@types/node/url.d.ts +0 -902
  143. package/app/node_modules/@types/node/util.d.ts +0 -2017
  144. package/app/node_modules/@types/node/v8.d.ts +0 -541
  145. package/app/node_modules/@types/node/vm.d.ts +0 -644
  146. package/app/node_modules/@types/node/wasi.d.ts +0 -158
  147. package/app/node_modules/@types/node/worker_threads.d.ts +0 -695
  148. package/app/node_modules/@types/node/zlib.d.ts +0 -517
  149. package/app/node_modules/@types/qs/LICENSE +0 -21
  150. package/app/node_modules/@types/qs/README.md +0 -16
  151. package/app/node_modules/@types/qs/index.d.ts +0 -62
  152. package/app/node_modules/@types/qs/package.json +0 -65
  153. package/app/node_modules/@types/range-parser/LICENSE +0 -21
  154. package/app/node_modules/@types/range-parser/README.md +0 -55
  155. package/app/node_modules/@types/range-parser/index.d.ts +0 -35
  156. package/app/node_modules/@types/range-parser/package.json +0 -25
  157. package/app/node_modules/@types/send/LICENSE +0 -21
  158. package/app/node_modules/@types/send/README.md +0 -16
  159. package/app/node_modules/@types/send/index.d.ts +0 -231
  160. package/app/node_modules/@types/send/package.json +0 -33
  161. package/app/node_modules/@types/serve-static/LICENSE +0 -21
  162. package/app/node_modules/@types/serve-static/README.md +0 -16
  163. package/app/node_modules/@types/serve-static/index.d.ts +0 -113
  164. package/app/node_modules/@types/serve-static/package.json +0 -38
  165. package/app/node_modules/colors/LICENSE +0 -25
  166. package/app/node_modules/colors/README.md +0 -221
  167. package/app/node_modules/colors/examples/normal-usage.js +0 -82
  168. package/app/node_modules/colors/examples/safe-string.js +0 -79
  169. package/app/node_modules/colors/index.d.ts +0 -136
  170. package/app/node_modules/colors/lib/colors.js +0 -211
  171. package/app/node_modules/colors/lib/custom/trap.js +0 -46
  172. package/app/node_modules/colors/lib/custom/zalgo.js +0 -110
  173. package/app/node_modules/colors/lib/extendStringPrototype.js +0 -110
  174. package/app/node_modules/colors/lib/index.js +0 -13
  175. package/app/node_modules/colors/lib/maps/america.js +0 -10
  176. package/app/node_modules/colors/lib/maps/rainbow.js +0 -12
  177. package/app/node_modules/colors/lib/maps/random.js +0 -11
  178. package/app/node_modules/colors/lib/maps/zebra.js +0 -5
  179. package/app/node_modules/colors/lib/styles.js +0 -95
  180. package/app/node_modules/colors/lib/system/has-flag.js +0 -35
  181. package/app/node_modules/colors/lib/system/supports-colors.js +0 -151
  182. package/app/node_modules/colors/package.json +0 -45
  183. package/app/node_modules/colors/safe.d.ts +0 -48
  184. package/app/node_modules/colors/safe.js +0 -10
  185. package/app/node_modules/colors/themes/generic-logging.js +0 -12
  186. package/app/node_modules/dateformat/LICENSE +0 -20
  187. package/app/node_modules/dateformat/Readme.md +0 -204
  188. package/app/node_modules/dateformat/lib/dateformat.js +0 -1
  189. package/app/node_modules/dateformat/package.json +0 -38
  190. package/app/node_modules/mkdirp/CHANGELOG.md +0 -15
  191. package/app/node_modules/mkdirp/LICENSE +0 -21
  192. package/app/node_modules/mkdirp/bin/cmd.js +0 -68
  193. package/app/node_modules/mkdirp/index.js +0 -31
  194. package/app/node_modules/mkdirp/lib/find-made.js +0 -29
  195. package/app/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
  196. package/app/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
  197. package/app/node_modules/mkdirp/lib/opts-arg.js +0 -23
  198. package/app/node_modules/mkdirp/lib/path-arg.js +0 -29
  199. package/app/node_modules/mkdirp/lib/use-native.js +0 -10
  200. package/app/node_modules/mkdirp/package.json +0 -44
  201. package/app/node_modules/mkdirp/readme.markdown +0 -266
  202. package/app/node_modules/tinytim/.travis.yml +0 -5
  203. package/app/node_modules/tinytim/README.md +0 -212
  204. package/app/node_modules/tinytim/index.js +0 -1
  205. package/app/node_modules/tinytim/lib/index.js +0 -55
  206. package/app/node_modules/tinytim/lib/tinytim.js +0 -50
  207. package/app/node_modules/tinytim/package.json +0 -24
  208. package/app/node_modules/tinytim/test/files/html.tim +0 -1
  209. package/app/node_modules/tinytim/test/files/string.tim +0 -1
  210. package/app/node_modules/tinytim/test/files/string2.tim +0 -1
  211. package/app/node_modules/tinytim/test/render-file-replace.js +0 -39
  212. package/app/node_modules/tinytim/test/render-replace.js +0 -94
  213. package/app/node_modules/tinytim/test/tim-replace.js +0 -95
  214. package/app/node_modules/tracer/README.md +0 -747
  215. package/app/node_modules/tracer/lib/color_console.js +0 -15
  216. package/app/node_modules/tracer/lib/console.js +0 -165
  217. package/app/node_modules/tracer/lib/dailyfile.js +0 -92
  218. package/app/node_modules/tracer/lib/index.js +0 -10
  219. package/app/node_modules/tracer/lib/settings.js +0 -25
  220. package/app/node_modules/tracer/lib/utils.js +0 -58
  221. package/app/node_modules/tracer/package.json +0 -53
  222. package/app/node_modules/tracer/types/index.d.ts +0 -189
  223. package/dist/scaffold/templates/front-page.class.ts.tpl +0 -12
  224. package/dist/scaffold/templates/main.ts.tpl +0 -13
  225. package/dist/scaffold/templates/nodemon.json.tpl +0 -7
  226. package/dist/scaffold/templates/package.json.tpl +0 -16
  227. package/dist/scaffold/templates/tsconfig.json.tpl +0 -20
  228. /package/dist/{core.decorator.js → src/core.decorator.js} +0 -0
  229. /package/dist/{default → src/default}/default-authentication.class.js +0 -0
  230. /package/dist/{default → src/default}/express-server.class.js +0 -0
  231. /package/dist/{default → src/default}/log-default.class.js +0 -0
  232. /package/dist/{default → src/default}/node-cache.class.js +0 -0
  233. /package/dist/{default → src/default}/pages/404.html +0 -0
  234. /package/dist/{default → src/default}/pages/500.html +0 -0
  235. /package/dist/{default → src/default}/rabbitmq.class.js +0 -0
  236. /package/dist/{default → src/default}/read-write-db.class.js +0 -0
  237. /package/dist/{default → src/default}/redis.class.js +0 -0
  238. /package/dist/{default → src/default}/socket-io.class.js +0 -0
  239. /package/dist/{factory → src/factory}/authentication-factory.class.js +0 -0
  240. /package/dist/{factory → src/factory}/cache-factory.class.js +0 -0
  241. /package/dist/{factory → src/factory}/data-source-factory.class.js +0 -0
  242. /package/dist/{factory → src/factory}/log-factory.class.js +0 -0
  243. /package/dist/{factory → src/factory}/server-factory.class.js +0 -0
  244. /package/dist/{route.decorator.js → src/route.decorator.js} +0 -0
  245. /package/dist/{scaffold → src/scaffold}/command.js +0 -0
  246. /package/dist/{typespeed.js → src/typespeed.js} +0 -0
@@ -1,644 +0,0 @@
1
- /**
2
- * The `vm` module enables compiling and running code within V8 Virtual
3
- * Machine contexts.
4
- *
5
- * **The `vm` module is not a security**
6
- * **mechanism. Do not use it to run untrusted code.**
7
- *
8
- * JavaScript code can be compiled and run immediately or
9
- * compiled, saved, and run later.
10
- *
11
- * A common use case is to run the code in a different V8 Context. This means
12
- * invoked code has a different global object than the invoking code.
13
- *
14
- * One can provide the context by `contextifying` an
15
- * object. The invoked code treats any property in the context like a
16
- * global variable. Any changes to global variables caused by the invoked
17
- * code are reflected in the context object.
18
- *
19
- * ```js
20
- * const vm = require('vm');
21
- *
22
- * const x = 1;
23
- *
24
- * const context = { x: 2 };
25
- * vm.createContext(context); // Contextify the object.
26
- *
27
- * const code = 'x += 40; var y = 17;';
28
- * // `x` and `y` are global variables in the context.
29
- * // Initially, x has the value 2 because that is the value of context.x.
30
- * vm.runInContext(code, context);
31
- *
32
- * console.log(context.x); // 42
33
- * console.log(context.y); // 17
34
- *
35
- * console.log(x); // 1; y is not defined.
36
- * ```
37
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/vm.js)
38
- */
39
- declare module 'vm' {
40
- interface Context extends NodeJS.Dict<any> {}
41
- interface BaseOptions {
42
- /**
43
- * Specifies the filename used in stack traces produced by this script.
44
- * Default: `''`.
45
- */
46
- filename?: string | undefined;
47
- /**
48
- * Specifies the line number offset that is displayed in stack traces produced by this script.
49
- * Default: `0`.
50
- */
51
- lineOffset?: number | undefined;
52
- /**
53
- * Specifies the column number offset that is displayed in stack traces produced by this script.
54
- * @default 0
55
- */
56
- columnOffset?: number | undefined;
57
- }
58
- interface ScriptOptions extends BaseOptions {
59
- /**
60
- * V8's code cache data for the supplied source.
61
- */
62
- cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
63
- /** @deprecated in favor of `script.createCachedData()` */
64
- produceCachedData?: boolean | undefined;
65
- /**
66
- * Called during evaluation of this module when `import()` is called.
67
- * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
68
- */
69
- importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined;
70
- }
71
- interface RunningScriptOptions extends BaseOptions {
72
- /**
73
- * When `true`, if an `Error` occurs while compiling the `code`, the line of code causing the error is attached to the stack trace.
74
- * Default: `true`.
75
- */
76
- displayErrors?: boolean | undefined;
77
- /**
78
- * Specifies the number of milliseconds to execute code before terminating execution.
79
- * If execution is terminated, an `Error` will be thrown. This value must be a strictly positive integer.
80
- */
81
- timeout?: number | undefined;
82
- /**
83
- * If `true`, the execution will be terminated when `SIGINT` (Ctrl+C) is received.
84
- * Existing handlers for the event that have been attached via `process.on('SIGINT')` will be disabled during script execution, but will continue to work after that.
85
- * If execution is terminated, an `Error` will be thrown.
86
- * Default: `false`.
87
- */
88
- breakOnSigint?: boolean | undefined;
89
- }
90
- interface RunningScriptInNewContextOptions extends RunningScriptOptions {
91
- /**
92
- * Human-readable name of the newly created context.
93
- */
94
- contextName?: CreateContextOptions['name'];
95
- /**
96
- * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
97
- * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
98
- * Most notably, this string should omit the trailing slash, as that denotes a path.
99
- */
100
- contextOrigin?: CreateContextOptions['origin'];
101
- contextCodeGeneration?: CreateContextOptions['codeGeneration'];
102
- /**
103
- * If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
104
- */
105
- microtaskMode?: CreateContextOptions['microtaskMode'];
106
- }
107
- interface RunningCodeOptions extends RunningScriptOptions {
108
- cachedData?: ScriptOptions['cachedData'];
109
- importModuleDynamically?: ScriptOptions['importModuleDynamically'];
110
- }
111
- interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
112
- cachedData?: ScriptOptions['cachedData'];
113
- importModuleDynamically?: ScriptOptions['importModuleDynamically'];
114
- }
115
- interface CompileFunctionOptions extends BaseOptions {
116
- /**
117
- * Provides an optional data with V8's code cache data for the supplied source.
118
- */
119
- cachedData?: Buffer | undefined;
120
- /**
121
- * Specifies whether to produce new cache data.
122
- * Default: `false`,
123
- */
124
- produceCachedData?: boolean | undefined;
125
- /**
126
- * The sandbox/context in which the said function should be compiled in.
127
- */
128
- parsingContext?: Context | undefined;
129
- /**
130
- * An array containing a collection of context extensions (objects wrapping the current scope) to be applied while compiling
131
- */
132
- contextExtensions?: Object[] | undefined;
133
- }
134
- interface CreateContextOptions {
135
- /**
136
- * Human-readable name of the newly created context.
137
- * @default 'VM Context i' Where i is an ascending numerical index of the created context.
138
- */
139
- name?: string | undefined;
140
- /**
141
- * Corresponds to the newly created context for display purposes.
142
- * The origin should be formatted like a `URL`, but with only the scheme, host, and port (if necessary),
143
- * like the value of the `url.origin` property of a URL object.
144
- * Most notably, this string should omit the trailing slash, as that denotes a path.
145
- * @default ''
146
- */
147
- origin?: string | undefined;
148
- codeGeneration?:
149
- | {
150
- /**
151
- * If set to false any calls to eval or function constructors (Function, GeneratorFunction, etc)
152
- * will throw an EvalError.
153
- * @default true
154
- */
155
- strings?: boolean | undefined;
156
- /**
157
- * If set to false any attempt to compile a WebAssembly module will throw a WebAssembly.CompileError.
158
- * @default true
159
- */
160
- wasm?: boolean | undefined;
161
- }
162
- | undefined;
163
- /**
164
- * If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
165
- */
166
- microtaskMode?: 'afterEvaluate' | undefined;
167
- }
168
- type MeasureMemoryMode = 'summary' | 'detailed';
169
- interface MeasureMemoryOptions {
170
- /**
171
- * @default 'summary'
172
- */
173
- mode?: MeasureMemoryMode | undefined;
174
- /**
175
- * @default 'default'
176
- */
177
- execution?: 'default' | 'eager' | undefined;
178
- }
179
- interface MemoryMeasurement {
180
- total: {
181
- jsMemoryEstimate: number;
182
- jsMemoryRange: [number, number];
183
- };
184
- }
185
- /**
186
- * Instances of the `vm.Script` class contain precompiled scripts that can be
187
- * executed in specific contexts.
188
- * @since v0.3.1
189
- */
190
- class Script {
191
- constructor(code: string, options?: ScriptOptions | string);
192
- /**
193
- * Runs the compiled code contained by the `vm.Script` object within the given`contextifiedObject` and returns the result. Running code does not have access
194
- * to local scope.
195
- *
196
- * The following example compiles code that increments a global variable, sets
197
- * the value of another global variable, then execute the code multiple times.
198
- * The globals are contained in the `context` object.
199
- *
200
- * ```js
201
- * const vm = require('vm');
202
- *
203
- * const context = {
204
- * animal: 'cat',
205
- * count: 2
206
- * };
207
- *
208
- * const script = new vm.Script('count += 1; name = "kitty";');
209
- *
210
- * vm.createContext(context);
211
- * for (let i = 0; i < 10; ++i) {
212
- * script.runInContext(context);
213
- * }
214
- *
215
- * console.log(context);
216
- * // Prints: { animal: 'cat', count: 12, name: 'kitty' }
217
- * ```
218
- *
219
- * Using the `timeout` or `breakOnSigint` options will result in new event loops
220
- * and corresponding threads being started, which have a non-zero performance
221
- * overhead.
222
- * @since v0.3.1
223
- * @param contextifiedObject A `contextified` object as returned by the `vm.createContext()` method.
224
- * @return the result of the very last statement executed in the script.
225
- */
226
- runInContext(contextifiedObject: Context, options?: RunningScriptOptions): any;
227
- /**
228
- * First contextifies the given `contextObject`, runs the compiled code contained
229
- * by the `vm.Script` object within the created context, and returns the result.
230
- * Running code does not have access to local scope.
231
- *
232
- * The following example compiles code that sets a global variable, then executes
233
- * the code multiple times in different contexts. The globals are set on and
234
- * contained within each individual `context`.
235
- *
236
- * ```js
237
- * const vm = require('vm');
238
- *
239
- * const script = new vm.Script('globalVar = "set"');
240
- *
241
- * const contexts = [{}, {}, {}];
242
- * contexts.forEach((context) => {
243
- * script.runInNewContext(context);
244
- * });
245
- *
246
- * console.log(contexts);
247
- * // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }]
248
- * ```
249
- * @since v0.3.1
250
- * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
251
- * @return the result of the very last statement executed in the script.
252
- */
253
- runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any;
254
- /**
255
- * Runs the compiled code contained by the `vm.Script` within the context of the
256
- * current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
257
- *
258
- * The following example compiles code that increments a `global` variable then
259
- * executes that code multiple times:
260
- *
261
- * ```js
262
- * const vm = require('vm');
263
- *
264
- * global.globalVar = 0;
265
- *
266
- * const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' });
267
- *
268
- * for (let i = 0; i < 1000; ++i) {
269
- * script.runInThisContext();
270
- * }
271
- *
272
- * console.log(globalVar);
273
- *
274
- * // 1000
275
- * ```
276
- * @since v0.3.1
277
- * @return the result of the very last statement executed in the script.
278
- */
279
- runInThisContext(options?: RunningScriptOptions): any;
280
- /**
281
- * Creates a code cache that can be used with the `Script` constructor's`cachedData` option. Returns a `Buffer`. This method may be called at any
282
- * time and any number of times.
283
- *
284
- * ```js
285
- * const script = new vm.Script(`
286
- * function add(a, b) {
287
- * return a + b;
288
- * }
289
- *
290
- * const x = add(1, 2);
291
- * `);
292
- *
293
- * const cacheWithoutX = script.createCachedData();
294
- *
295
- * script.runInThisContext();
296
- *
297
- * const cacheWithX = script.createCachedData();
298
- * ```
299
- * @since v10.6.0
300
- */
301
- createCachedData(): Buffer;
302
- /** @deprecated in favor of `script.createCachedData()` */
303
- cachedDataProduced?: boolean | undefined;
304
- cachedDataRejected?: boolean | undefined;
305
- cachedData?: Buffer | undefined;
306
- /**
307
- * When the script is compiled from a source that contains a source map magic comment, this property will be set to the URL of the source map.
308
- */
309
- sourceMapURL?: string | undefined;
310
- }
311
- /**
312
- * If given a `contextObject`, the `vm.createContext()` method will `prepare
313
- * that object` so that it can be used in calls to {@link runInContext} or `script.runInContext()`. Inside such scripts,
314
- * the `contextObject` will be the global object, retaining all of its existing
315
- * properties but also having the built-in objects and functions any standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global variables
316
- * will remain unchanged.
317
- *
318
- * ```js
319
- * const vm = require('vm');
320
- *
321
- * global.globalVar = 3;
322
- *
323
- * const context = { globalVar: 1 };
324
- * vm.createContext(context);
325
- *
326
- * vm.runInContext('globalVar *= 2;', context);
327
- *
328
- * console.log(context);
329
- * // Prints: { globalVar: 2 }
330
- *
331
- * console.log(global.globalVar);
332
- * // Prints: 3
333
- * ```
334
- *
335
- * If `contextObject` is omitted (or passed explicitly as `undefined`), a new,
336
- * empty `contextified` object will be returned.
337
- *
338
- * The `vm.createContext()` method is primarily useful for creating a single
339
- * context that can be used to run multiple scripts. For instance, if emulating a
340
- * web browser, the method can be used to create a single context representing a
341
- * window's global object, then run all `<script>` tags together within that
342
- * context.
343
- *
344
- * The provided `name` and `origin` of the context are made visible through the
345
- * Inspector API.
346
- * @since v0.3.1
347
- * @return contextified object.
348
- */
349
- function createContext(sandbox?: Context, options?: CreateContextOptions): Context;
350
- /**
351
- * Returns `true` if the given `object` object has been `contextified` using {@link createContext}.
352
- * @since v0.11.7
353
- */
354
- function isContext(sandbox: Context): boolean;
355
- /**
356
- * The `vm.runInContext()` method compiles `code`, runs it within the context of
357
- * the `contextifiedObject`, then returns the result. Running code does not have
358
- * access to the local scope. The `contextifiedObject` object _must_ have been
359
- * previously `contextified` using the {@link createContext} method.
360
- *
361
- * If `options` is a string, then it specifies the filename.
362
- *
363
- * The following example compiles and executes different scripts using a single `contextified` object:
364
- *
365
- * ```js
366
- * const vm = require('vm');
367
- *
368
- * const contextObject = { globalVar: 1 };
369
- * vm.createContext(contextObject);
370
- *
371
- * for (let i = 0; i < 10; ++i) {
372
- * vm.runInContext('globalVar *= 2;', contextObject);
373
- * }
374
- * console.log(contextObject);
375
- * // Prints: { globalVar: 1024 }
376
- * ```
377
- * @since v0.3.1
378
- * @param code The JavaScript code to compile and run.
379
- * @param contextifiedObject The `contextified` object that will be used as the `global` when the `code` is compiled and run.
380
- * @return the result of the very last statement executed in the script.
381
- */
382
- function runInContext(code: string, contextifiedObject: Context, options?: RunningCodeOptions | string): any;
383
- /**
384
- * The `vm.runInNewContext()` first contextifies the given `contextObject` (or
385
- * creates a new `contextObject` if passed as `undefined`), compiles the `code`,
386
- * runs it within the created context, then returns the result. Running code
387
- * does not have access to the local scope.
388
- *
389
- * If `options` is a string, then it specifies the filename.
390
- *
391
- * The following example compiles and executes code that increments a global
392
- * variable and sets a new one. These globals are contained in the `contextObject`.
393
- *
394
- * ```js
395
- * const vm = require('vm');
396
- *
397
- * const contextObject = {
398
- * animal: 'cat',
399
- * count: 2
400
- * };
401
- *
402
- * vm.runInNewContext('count += 1; name = "kitty"', contextObject);
403
- * console.log(contextObject);
404
- * // Prints: { animal: 'cat', count: 3, name: 'kitty' }
405
- * ```
406
- * @since v0.3.1
407
- * @param code The JavaScript code to compile and run.
408
- * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created.
409
- * @return the result of the very last statement executed in the script.
410
- */
411
- function runInNewContext(code: string, contextObject?: Context, options?: RunningCodeInNewContextOptions | string): any;
412
- /**
413
- * `vm.runInThisContext()` compiles `code`, runs it within the context of the
414
- * current `global` and returns the result. Running code does not have access to
415
- * local scope, but does have access to the current `global` object.
416
- *
417
- * If `options` is a string, then it specifies the filename.
418
- *
419
- * The following example illustrates using both `vm.runInThisContext()` and
420
- * the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
421
- *
422
- * ```js
423
- * const vm = require('vm');
424
- * let localVar = 'initial value';
425
- *
426
- * const vmResult = vm.runInThisContext('localVar = "vm";');
427
- * console.log(`vmResult: '${vmResult}', localVar: '${localVar}'`);
428
- * // Prints: vmResult: 'vm', localVar: 'initial value'
429
- *
430
- * const evalResult = eval('localVar = "eval";');
431
- * console.log(`evalResult: '${evalResult}', localVar: '${localVar}'`);
432
- * // Prints: evalResult: 'eval', localVar: 'eval'
433
- * ```
434
- *
435
- * Because `vm.runInThisContext()` does not have access to the local scope,`localVar` is unchanged. In contrast,
436
- * [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) _does_ have access to the
437
- * local scope, so the value `localVar` is changed. In this way`vm.runInThisContext()` is much like an [indirect `eval()` call](https://es5.github.io/#x10.4.2), e.g.`(0,eval)('code')`.
438
- *
439
- * ## Example: Running an HTTP server within a VM
440
- *
441
- * When using either `script.runInThisContext()` or {@link runInThisContext}, the code is executed within the current V8 global
442
- * context. The code passed to this VM context will have its own isolated scope.
443
- *
444
- * In order to run a simple web server using the `http` module the code passed to
445
- * the context must either call `require('http')` on its own, or have a reference
446
- * to the `http` module passed to it. For instance:
447
- *
448
- * ```js
449
- * 'use strict';
450
- * const vm = require('vm');
451
- *
452
- * const code = `
453
- * ((require) => {
454
- * const http = require('http');
455
- *
456
- * http.createServer((request, response) => {
457
- * response.writeHead(200, { 'Content-Type': 'text/plain' });
458
- * response.end('Hello World\\n');
459
- * }).listen(8124);
460
- *
461
- * console.log('Server running at http://127.0.0.1:8124/');
462
- * })`;
463
- *
464
- * vm.runInThisContext(code)(require);
465
- * ```
466
- *
467
- * The `require()` in the above case shares the state with the context it is
468
- * passed from. This may introduce risks when untrusted code is executed, e.g.
469
- * altering objects in the context in unwanted ways.
470
- * @since v0.3.1
471
- * @param code The JavaScript code to compile and run.
472
- * @return the result of the very last statement executed in the script.
473
- */
474
- function runInThisContext(code: string, options?: RunningCodeOptions | string): any;
475
- /**
476
- * Compiles the given code into the provided context (if no context is
477
- * supplied, the current context is used), and returns it wrapped inside a
478
- * function with the given `params`.
479
- * @since v10.10.0
480
- * @param code The body of the function to compile.
481
- * @param params An array of strings containing all parameters for the function.
482
- */
483
- function compileFunction(code: string, params?: ReadonlyArray<string>, options?: CompileFunctionOptions): Function & {
484
- cachedData?: Script['cachedData'] | undefined;
485
- cachedDataProduced?: Script['cachedDataProduced'] | undefined;
486
- cachedDataRejected?: Script['cachedDataRejected'] | undefined;
487
- };
488
- /**
489
- * Measure the memory known to V8 and used by all contexts known to the
490
- * current V8 isolate, or the main context.
491
- *
492
- * The format of the object that the returned Promise may resolve with is
493
- * specific to the V8 engine and may change from one version of V8 to the next.
494
- *
495
- * The returned result is different from the statistics returned by`v8.getHeapSpaceStatistics()` in that `vm.measureMemory()` measure the
496
- * memory reachable by each V8 specific contexts in the current instance of
497
- * the V8 engine, while the result of `v8.getHeapSpaceStatistics()` measure
498
- * the memory occupied by each heap space in the current V8 instance.
499
- *
500
- * ```js
501
- * const vm = require('vm');
502
- * // Measure the memory used by the main context.
503
- * vm.measureMemory({ mode: 'summary' })
504
- * // This is the same as vm.measureMemory()
505
- * .then((result) => {
506
- * // The current format is:
507
- * // {
508
- * // total: {
509
- * // jsMemoryEstimate: 2418479, jsMemoryRange: [ 2418479, 2745799 ]
510
- * // }
511
- * // }
512
- * console.log(result);
513
- * });
514
- *
515
- * const context = vm.createContext({ a: 1 });
516
- * vm.measureMemory({ mode: 'detailed', execution: 'eager' })
517
- * .then((result) => {
518
- * // Reference the context here so that it won't be GC'ed
519
- * // until the measurement is complete.
520
- * console.log(context.a);
521
- * // {
522
- * // total: {
523
- * // jsMemoryEstimate: 2574732,
524
- * // jsMemoryRange: [ 2574732, 2904372 ]
525
- * // },
526
- * // current: {
527
- * // jsMemoryEstimate: 2438996,
528
- * // jsMemoryRange: [ 2438996, 2768636 ]
529
- * // },
530
- * // other: [
531
- * // {
532
- * // jsMemoryEstimate: 135736,
533
- * // jsMemoryRange: [ 135736, 465376 ]
534
- * // }
535
- * // ]
536
- * // }
537
- * console.log(result);
538
- * });
539
- * ```
540
- * @since v13.10.0
541
- * @experimental
542
- */
543
- function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
544
-
545
- interface ModuleEvaluateOptions {
546
- timeout?: RunningScriptOptions['timeout'] | undefined;
547
- breakOnSigint?: RunningScriptOptions['breakOnSigint'] | undefined;
548
- }
549
- type ModuleLinker = (specifier: string, referencingModule: Module, extra: { assert: Object }) => Module | Promise<Module>;
550
- type ModuleStatus = 'unlinked' | 'linking' | 'linked' | 'evaluating' | 'evaluated' | 'errored';
551
- class Module {
552
- /**
553
- * The specifiers of all dependencies of this module.
554
- */
555
- dependencySpecifiers: readonly string[];
556
- /**
557
- * If the `module.status` is `'errored'`, this property contains the exception thrown by the module during evaluation.
558
- * If the status is anything else, accessing this property will result in a thrown exception.
559
- */
560
- error: any;
561
- /**
562
- * The identifier of the current module, as set in the constructor.
563
- */
564
- identifier: string;
565
- context: Context;
566
- /**
567
- * The namespace object of the module. This is only available after linking (`module.link()`) has completed.
568
- */
569
- namespace: Object;
570
- /**
571
- * The current status of the module.
572
- */
573
- status: ModuleStatus;
574
- /**
575
- * Evaluate the module.
576
- *
577
- * This must be called after the module has been linked; otherwise it will reject
578
- * It could be called also when the module has already been evaluated, in which case it will either do nothing
579
- * if the initial evaluation ended in success (`module.status` is `'evaluated'`) or it will re-throw the exception
580
- * that the initial evaluation resulted in (`module.status` is `'errored'`).
581
- *
582
- * This method cannot be called while the module is being evaluated (`module.status` is `'evaluating'`).
583
- */
584
- evaluate(options?: ModuleEvaluateOptions): Promise<void>;
585
- /**
586
- * Link module dependencies. This method must be called before evaluation, and can only be called once per module.
587
- */
588
- link(linker: ModuleLinker): Promise<void>;
589
- }
590
-
591
- interface SourceTextModuleOptions {
592
- /**
593
- * String used in stack traces.
594
- * @default 'vm:module(i)' where i is a context-specific ascending index.
595
- */
596
- identifier?: string | undefined;
597
- cachedData?: ScriptOptions['cachedData'] | undefined;
598
- context?: Context | undefined;
599
- lineOffset?: BaseOptions['lineOffset'] | undefined;
600
- columnOffset?: BaseOptions['columnOffset'] | undefined;
601
- /**
602
- * Called during evaluation of this module to initialize the `import.meta`.
603
- */
604
- initializeImportMeta?: ((meta: ImportMeta, module: SourceTextModule) => void) | undefined;
605
- importModuleDynamically?: ScriptOptions['importModuleDynamically'] | undefined;
606
- }
607
- class SourceTextModule extends Module {
608
- /**
609
- * Creates a new `SourceTextModule` instance.
610
- * @param code JavaScript Module code to parse
611
- */
612
- constructor(code: string, options?: SourceTextModuleOptions);
613
- }
614
-
615
- interface SyntheticModuleOptions {
616
- /**
617
- * String used in stack traces.
618
- * @default 'vm:module(i)' where i is a context-specific ascending index.
619
- */
620
- identifier?: string | undefined;
621
- /**
622
- * The contextified object as returned by the `vm.createContext()` method, to compile and evaluate this module in.
623
- */
624
- context?: Context | undefined;
625
- }
626
- class SyntheticModule extends Module {
627
- /**
628
- * Creates a new `SyntheticModule` instance.
629
- * @param exportNames Array of names that will be exported from the module.
630
- * @param evaluateCallback Called when the module is evaluated.
631
- */
632
- constructor(exportNames: string[], evaluateCallback: (this: SyntheticModule) => void, options?: SyntheticModuleOptions);
633
- /**
634
- * This method is used after the module is linked to set the values of exports.
635
- * If it is called before the module is linked, an `ERR_VM_MODULE_STATUS` error will be thrown.
636
- * @param name
637
- * @param value
638
- */
639
- setExport(name: string, value: any): void;
640
- }
641
- }
642
- declare module 'node:vm' {
643
- export * from 'vm';
644
- }