@tstdl/base 0.92.167 → 0.92.168

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 (307) hide show
  1. package/application/application.d.ts +12 -18
  2. package/application/application.js +48 -69
  3. package/application/index.d.ts +1 -5
  4. package/application/index.js +1 -5
  5. package/application/providers.d.ts +10 -0
  6. package/application/providers.js +54 -0
  7. package/authentication/client/authentication.service.d.ts +1 -3
  8. package/authentication/client/authentication.service.js +4 -5
  9. package/browser/browser-context-controller.d.ts +2 -4
  10. package/browser/browser-context-controller.js +5 -6
  11. package/browser/browser-controller.d.ts +2 -4
  12. package/browser/browser-controller.js +3 -4
  13. package/browser/browser.service.d.ts +1 -3
  14. package/browser/browser.service.js +1 -2
  15. package/browser/page-controller.d.ts +2 -4
  16. package/browser/page-controller.js +7 -8
  17. package/browser/utils.js +3 -3
  18. package/cancellation/token.d.ts +104 -41
  19. package/cancellation/token.js +125 -54
  20. package/core.d.ts +1 -13
  21. package/core.js +1 -46
  22. package/disposable/disposable.d.ts +0 -8
  23. package/disposable/disposable.js +1 -3
  24. package/disposable/index.d.ts +0 -6
  25. package/disposable/index.js +0 -6
  26. package/disposable/using.d.ts +0 -1
  27. package/disposable/using.js +2 -3
  28. package/distributed-loop/distributed-loop.js +2 -2
  29. package/errors/utils.js +4 -1
  30. package/examples/api/authentication.js +11 -5
  31. package/examples/api/basic-overview.js +17 -12
  32. package/examples/api/custom-authentication.js +13 -7
  33. package/examples/api/streaming.js +15 -12
  34. package/examples/browser/basic.js +6 -3
  35. package/examples/document-management/main.js +6 -3
  36. package/examples/http/client.js +7 -3
  37. package/examples/mail/basic.js +9 -7
  38. package/examples/pdf/basic.js +8 -6
  39. package/examples/template/basic.js +7 -5
  40. package/http/client/http-client-request.d.ts +1 -2
  41. package/http/client/http-client-request.js +1 -2
  42. package/http/server/http-server.d.ts +1 -3
  43. package/http/server/http-server.js +0 -1
  44. package/http/server/node/node-http-server.d.ts +1 -2
  45. package/http/server/node/node-http-server.js +1 -2
  46. package/import.js +1 -1
  47. package/injector/injector.d.ts +1 -1
  48. package/injector/types.d.ts +3 -4
  49. package/lock/lock.d.ts +40 -21
  50. package/lock/lock.js +74 -1
  51. package/lock/postgres/drizzle/0000_busy_tattoo.sql +7 -0
  52. package/lock/postgres/drizzle/meta/0000_snapshot.json +65 -0
  53. package/lock/postgres/drizzle/meta/_journal.json +13 -0
  54. package/lock/postgres/drizzle.config.js +11 -0
  55. package/lock/postgres/index.d.ts +2 -0
  56. package/lock/postgres/index.js +2 -0
  57. package/lock/postgres/lock.d.ts +14 -0
  58. package/lock/postgres/lock.js +127 -0
  59. package/lock/postgres/models/index.d.ts +2 -0
  60. package/lock/postgres/models/index.js +2 -0
  61. package/lock/postgres/models/lock.model.d.ts +7 -0
  62. package/{examples/orm/user.model.js → lock/postgres/models/lock.model.js} +22 -30
  63. package/lock/postgres/models/schemas.d.ts +3 -0
  64. package/lock/postgres/models/schemas.js +4 -0
  65. package/lock/postgres/module.d.ts +6 -0
  66. package/lock/postgres/module.js +26 -0
  67. package/lock/postgres/provider.d.ts +6 -0
  68. package/lock/postgres/provider.js +29 -0
  69. package/lock/provider.d.ts +12 -2
  70. package/lock/provider.js +24 -1
  71. package/lock/web/web-lock.d.ts +4 -3
  72. package/lock/web/web-lock.js +49 -42
  73. package/lock/web/web-lock.provider.d.ts +0 -3
  74. package/lock/web/web-lock.provider.js +5 -22
  75. package/logger/formatter.d.ts +13 -0
  76. package/logger/formatter.js +3 -0
  77. package/logger/formatters/index.d.ts +2 -0
  78. package/logger/formatters/index.js +2 -0
  79. package/logger/formatters/json.d.ts +5 -0
  80. package/logger/formatters/json.js +33 -0
  81. package/logger/formatters/pretty-print.d.ts +5 -0
  82. package/logger/formatters/pretty-print.js +55 -0
  83. package/logger/index.d.ts +5 -2
  84. package/logger/index.js +5 -2
  85. package/logger/level.d.ts +10 -8
  86. package/logger/level.js +9 -9
  87. package/logger/logger.d.ts +21 -30
  88. package/logger/logger.js +98 -26
  89. package/logger/manager.d.ts +20 -0
  90. package/logger/manager.js +77 -0
  91. package/logger/tokens.d.ts +1 -1
  92. package/logger/tokens.js +1 -1
  93. package/logger/transport.d.ts +14 -0
  94. package/logger/transport.js +16 -0
  95. package/logger/transports/console.d.ts +14 -0
  96. package/logger/transports/console.js +36 -0
  97. package/logger/transports/index.d.ts +1 -0
  98. package/logger/transports/index.js +1 -0
  99. package/mail/clients/nodemailer.mail-client.d.ts +0 -1
  100. package/mail/clients/nodemailer.mail-client.js +9 -7
  101. package/message-bus/local/local-message-bus.js +2 -2
  102. package/message-bus/message-bus-base.d.ts +2 -3
  103. package/message-bus/message-bus-base.js +5 -6
  104. package/message-bus/message-bus.d.ts +1 -2
  105. package/message-bus/message-bus.js +1 -2
  106. package/module/index.d.ts +0 -2
  107. package/module/index.js +0 -2
  108. package/module/module.d.ts +17 -18
  109. package/module/module.js +47 -12
  110. package/module/modules/function.module.d.ts +6 -6
  111. package/module/modules/function.module.js +25 -9
  112. package/module/modules/web-server.module.d.ts +2 -10
  113. package/module/modules/web-server.module.js +3 -11
  114. package/openid-connect/index.d.ts +0 -2
  115. package/openid-connect/index.js +0 -2
  116. package/openid-connect/oidc-state.model.d.ts +4 -5
  117. package/openid-connect/oidc-state.model.js +51 -1
  118. package/openid-connect/oidc.service-model.d.ts +1 -1
  119. package/openid-connect/oidc.service.d.ts +2 -6
  120. package/openid-connect/oidc.service.js +24 -37
  121. package/orm/decorators.d.ts +10 -1
  122. package/orm/decorators.js +8 -0
  123. package/orm/server/repository.d.ts +3 -1
  124. package/orm/server/repository.js +32 -3
  125. package/package.json +17 -28
  126. package/pdf/pdf.service.js +9 -9
  127. package/pool/pool.d.ts +1 -3
  128. package/pool/pool.js +3 -4
  129. package/queue/postgres/job.model.d.ts +1 -2
  130. package/queue/postgres/job.model.js +1 -2
  131. package/queue/postgres/module.js +1 -1
  132. package/threading/thread-pool.d.ts +1 -3
  133. package/threading/thread-pool.js +7 -8
  134. package/utils/format-error.d.ts +7 -0
  135. package/utils/format-error.js +59 -17
  136. package/utils/index.d.ts +1 -0
  137. package/utils/index.js +1 -0
  138. package/utils/object/dereference.d.ts +51 -19
  139. package/utils/object/dereference.js +52 -43
  140. package/utils/timing.js +2 -2
  141. package/utils/try-chain.d.ts +22 -0
  142. package/utils/try-chain.js +46 -0
  143. package/database/entity-repository.d.ts +0 -50
  144. package/database/entity-repository.js +0 -3
  145. package/database/entity.d.ts +0 -7
  146. package/database/entity.js +0 -1
  147. package/database/id.d.ts +0 -1
  148. package/database/id.js +0 -9
  149. package/database/index.d.ts +0 -11
  150. package/database/index.js +0 -11
  151. package/database/module.d.ts +0 -8
  152. package/database/module.js +0 -11
  153. package/database/mongo/classes.d.ts +0 -21
  154. package/database/mongo/classes.js +0 -26
  155. package/database/mongo/index.d.ts +0 -15
  156. package/database/mongo/index.js +0 -15
  157. package/database/mongo/model/document.d.ts +0 -29
  158. package/database/mongo/model/document.js +0 -63
  159. package/database/mongo/model/index.d.ts +0 -1
  160. package/database/mongo/model/index.js +0 -1
  161. package/database/mongo/module.d.ts +0 -8
  162. package/database/mongo/module.js +0 -68
  163. package/database/mongo/mongo-base.repository.d.ts +0 -103
  164. package/database/mongo/mongo-base.repository.js +0 -263
  165. package/database/mongo/mongo-bulk.d.ts +0 -35
  166. package/database/mongo/mongo-bulk.js +0 -90
  167. package/database/mongo/mongo-entity-repository.d.ts +0 -98
  168. package/database/mongo/mongo-entity-repository.js +0 -278
  169. package/database/mongo/operations.d.ts +0 -10
  170. package/database/mongo/operations.js +0 -54
  171. package/database/mongo/query-converter.d.ts +0 -6
  172. package/database/mongo/query-converter.js +0 -83
  173. package/database/mongo/simple-entity-repository.d.ts +0 -7
  174. package/database/mongo/simple-entity-repository.js +0 -6
  175. package/database/mongo/types.d.ts +0 -50
  176. package/database/mongo/types.js +0 -3
  177. package/database/query.d.ts +0 -121
  178. package/database/query.js +0 -7
  179. package/database/utils.d.ts +0 -2
  180. package/database/utils.js +0 -3
  181. package/disposable/async-disposer.d.ts +0 -35
  182. package/disposable/async-disposer.js +0 -125
  183. package/examples/orm/drizzle.config.js +0 -6
  184. package/examples/orm/schemas.d.ts +0 -3
  185. package/examples/orm/schemas.js +0 -4
  186. package/examples/orm/test.d.ts +0 -1
  187. package/examples/orm/test.js +0 -11
  188. package/examples/orm/user.model.d.ts +0 -13
  189. package/key-value-store/mongo/index.d.ts +0 -6
  190. package/key-value-store/mongo/index.js +0 -6
  191. package/key-value-store/mongo/module.d.ts +0 -8
  192. package/key-value-store/mongo/module.js +0 -18
  193. package/key-value-store/mongo/mongo-key-value-store.provider.d.ts +0 -8
  194. package/key-value-store/mongo/mongo-key-value-store.provider.js +0 -26
  195. package/key-value-store/mongo/mongo-key-value.model.d.ts +0 -7
  196. package/key-value-store/mongo/mongo-key-value.model.js +0 -1
  197. package/key-value-store/mongo/mongo-key-value.repository.d.ts +0 -10
  198. package/key-value-store/mongo/mongo-key-value.repository.js +0 -31
  199. package/key-value-store/mongo/mongo-key-value.store.d.ts +0 -15
  200. package/key-value-store/mongo/mongo-key-value.store.js +0 -82
  201. package/key-value-store/mongo/tokens.d.ts +0 -3
  202. package/key-value-store/mongo/tokens.js +0 -2
  203. package/lock/mongo/index.d.ts +0 -5
  204. package/lock/mongo/index.js +0 -5
  205. package/lock/mongo/lock.d.ts +0 -14
  206. package/lock/mongo/lock.js +0 -125
  207. package/lock/mongo/model.d.ts +0 -6
  208. package/lock/mongo/model.js +0 -1
  209. package/lock/mongo/module.d.ts +0 -12
  210. package/lock/mongo/module.js +0 -20
  211. package/lock/mongo/mongo-lock-repository.d.ts +0 -14
  212. package/lock/mongo/mongo-lock-repository.js +0 -67
  213. package/lock/mongo/provider.d.ts +0 -8
  214. package/lock/mongo/provider.js +0 -36
  215. package/logger/console/index.d.ts +0 -1
  216. package/logger/console/index.js +0 -1
  217. package/logger/console/logger.d.ts +0 -11
  218. package/logger/console/logger.js +0 -64
  219. package/logger/noop/index.d.ts +0 -1
  220. package/logger/noop/index.js +0 -1
  221. package/logger/noop/logger.d.ts +0 -9
  222. package/logger/noop/logger.js +0 -21
  223. package/migration/index.d.ts +0 -9
  224. package/migration/index.js +0 -9
  225. package/migration/migration-state-repository.d.ts +0 -4
  226. package/migration/migration-state-repository.js +0 -3
  227. package/migration/migration-state.d.ts +0 -6
  228. package/migration/migration-state.js +0 -1
  229. package/migration/migrator.d.ts +0 -23
  230. package/migration/migrator.js +0 -76
  231. package/migration/mongo/index.d.ts +0 -2
  232. package/migration/mongo/index.js +0 -2
  233. package/migration/mongo/migration-state-repository.d.ts +0 -11
  234. package/migration/mongo/migration-state-repository.js +0 -32
  235. package/migration/mongo/module.d.ts +0 -12
  236. package/migration/mongo/module.js +0 -17
  237. package/module/module-base.d.ts +0 -18
  238. package/module/module-base.js +0 -40
  239. package/module/module-metric-reporter.d.ts +0 -29
  240. package/module/module-metric-reporter.js +0 -62
  241. package/openid-connect/mongo-oidc-state.repository.d.ts +0 -21
  242. package/openid-connect/mongo-oidc-state.repository.js +0 -52
  243. package/openid-connect/oidc-state.repository.d.ts +0 -4
  244. package/openid-connect/oidc-state.repository.js +0 -3
  245. package/process-shutdown.d.ts +0 -9
  246. package/process-shutdown.js +0 -65
  247. package/queue/mongo/index.d.ts +0 -4
  248. package/queue/mongo/index.js +0 -4
  249. package/queue/mongo/job.d.ts +0 -12
  250. package/queue/mongo/job.js +0 -1
  251. package/queue/mongo/mongo-job.repository.d.ts +0 -13
  252. package/queue/mongo/mongo-job.repository.js +0 -54
  253. package/queue/mongo/queue.d.ts +0 -38
  254. package/queue/mongo/queue.js +0 -266
  255. package/queue/mongo/queue.provider.d.ts +0 -18
  256. package/queue/mongo/queue.provider.js +0 -38
  257. package/search-index/elastic/config.d.ts +0 -8
  258. package/search-index/elastic/config.js +0 -26
  259. package/search-index/elastic/index.d.ts +0 -8
  260. package/search-index/elastic/index.js +0 -8
  261. package/search-index/elastic/keyword-rewriter.d.ts +0 -8
  262. package/search-index/elastic/keyword-rewriter.js +0 -18
  263. package/search-index/elastic/model/elastic-query.d.ts +0 -16
  264. package/search-index/elastic/model/elastic-query.js +0 -1
  265. package/search-index/elastic/model/index-mapping.d.ts +0 -26
  266. package/search-index/elastic/model/index-mapping.js +0 -4
  267. package/search-index/elastic/model/index.d.ts +0 -3
  268. package/search-index/elastic/model/index.js +0 -3
  269. package/search-index/elastic/model/sort.d.ts +0 -8
  270. package/search-index/elastic/model/sort.js +0 -1
  271. package/search-index/elastic/module.d.ts +0 -10
  272. package/search-index/elastic/module.js +0 -49
  273. package/search-index/elastic/query-builder/boolean-query-builder.d.ts +0 -11
  274. package/search-index/elastic/query-builder/boolean-query-builder.js +0 -52
  275. package/search-index/elastic/query-builder/index.d.ts +0 -1
  276. package/search-index/elastic/query-builder/index.js +0 -1
  277. package/search-index/elastic/query-converter.d.ts +0 -9
  278. package/search-index/elastic/query-converter.js +0 -183
  279. package/search-index/elastic/search-index.d.ts +0 -30
  280. package/search-index/elastic/search-index.js +0 -144
  281. package/search-index/elastic/sort-converter.d.ts +0 -4
  282. package/search-index/elastic/sort-converter.js +0 -14
  283. package/search-index/elastic/types.d.ts +0 -5
  284. package/search-index/elastic/types.js +0 -1
  285. package/search-index/error.d.ts +0 -10
  286. package/search-index/error.js +0 -14
  287. package/search-index/index.d.ts +0 -3
  288. package/search-index/index.js +0 -3
  289. package/search-index/memory/index.d.ts +0 -1
  290. package/search-index/memory/index.js +0 -1
  291. package/search-index/memory/memory-search-index.d.ts +0 -19
  292. package/search-index/memory/memory-search-index.js +0 -144
  293. package/search-index/search-index.d.ts +0 -46
  294. package/search-index/search-index.js +0 -31
  295. package/search-index/search-result.d.ts +0 -12
  296. package/search-index/search-result.js +0 -1
  297. package/theme/adapters/css-adapter.d.ts +0 -5
  298. package/theme/adapters/css-adapter.js +0 -29
  299. package/theme/adapters/index.d.ts +0 -2
  300. package/theme/adapters/index.js +0 -2
  301. package/theme/adapters/tailwind-adapter.d.ts +0 -18
  302. package/theme/adapters/tailwind-adapter.js +0 -32
  303. package/theme/index.d.ts +0 -1
  304. package/theme/index.js +0 -1
  305. package/theme/theme-service.d.ts +0 -43
  306. package/theme/theme-service.js +0 -128
  307. /package/{examples/orm → lock/postgres}/drizzle.config.d.ts +0 -0
@@ -1,30 +1,24 @@
1
- import type { CancellationSignal } from '../cancellation/token.js';
1
+ import { CancellationSignal } from '../cancellation/token.js';
2
+ import { type ProvidersItem } from '../injector/injector.js';
2
3
  import type { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
3
4
  import type { LoggerArgument } from '../logger/index.js';
4
- import type { Module } from '../module/module.js';
5
- import type { FunctionModuleFunction } from '../module/modules/function.module.js';
5
+ import { Module } from '../module/index.js';
6
6
  import type { OneOrMany, Type } from '../types/index.js';
7
- export type BootstrapFn = () => void | Promise<void>;
8
- export type RunOptions = {
9
- bootstrap?: OneOrMany<BootstrapFn>;
10
- };
7
+ export type InitializerFn = () => void | Promise<void>;
8
+ export type DestructorFn = () => void | Promise<void>;
9
+ export declare const APPLICATION_MODULE: import("../injector/token.js").InjectionToken<Module, never>;
10
+ export declare const APPLICATION_INITIALIZER: import("../injector/token.js").InjectionToken<InitializerFn, never>;
11
+ export declare const APPLICATION_DESTRUCTOR: import("../injector/token.js").InjectionToken<DestructorFn, never>;
11
12
  export type ApplicationArgument = LoggerArgument;
12
13
  export declare class Application implements Resolvable<ApplicationArgument> {
13
14
  #private;
14
- static _instance: Application | undefined;
15
- private static get instance();
16
15
  readonly [resolveArgumentType]: string;
16
+ static create(name: string, providers?: OneOrMany<ProvidersItem>[]): Application;
17
+ static run(name: string, providers?: OneOrMany<ProvidersItem>[]): Application;
17
18
  get shutdownSignal(): CancellationSignal;
18
- static get shutdownSignal(): CancellationSignal;
19
- static registerModule(moduleType: Type<Module>): void;
20
- static registerModuleFunction(fn: FunctionModuleFunction): void;
21
- static run(...functionsAndModules: [RunOptions | OneOrMany<FunctionModuleFunction | Type<Module>>, ...OneOrMany<FunctionModuleFunction | Type<Module>>[]]): void;
22
- static waitForShutdown(): Promise<void>;
23
- static shutdown(): Promise<void>;
24
- static requestShutdown(): void;
25
19
  registerModule(moduleType: Module | Type<Module>): void;
26
- registerModuleFunction(fn: FunctionModuleFunction): void;
27
- run(...optionsFunctionsAndModules: [RunOptions | OneOrMany<FunctionModuleFunction | Type<Module>>, ...OneOrMany<FunctionModuleFunction | Type<Module>>[]]): void;
20
+ run(): void;
21
+ runAndWait(): Promise<void>;
28
22
  shutdown(): Promise<void>;
29
23
  requestShutdown(): void;
30
24
  waitForShutdown(): Promise<void>;
@@ -5,75 +5,54 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  var Application_1;
8
- import { getGlobalInjector } from '../core.js';
8
+ import { CancellationSignal, CancellationToken } from '../cancellation/token.js';
9
9
  import { Singleton } from '../injector/decorators.js';
10
- import { inject, injectArgument, runInInjectionContext } from '../injector/inject.js';
10
+ import { inject, injectAll, injectArgument, runInInjectionContext } from '../injector/inject.js';
11
11
  import { Injector } from '../injector/injector.js';
12
+ import { injectionToken } from '../injector/token.js';
12
13
  import { Logger } from '../logger/index.js';
13
- import { ModuleBase } from '../module/module-base.js';
14
- import { ModuleState } from '../module/module.js';
15
- import { FunctionModule } from '../module/modules/function.module.js';
16
- import { getShutdownSignal, getShutdownToken } from '../process-shutdown.js';
14
+ import { Module, ModuleState } from '../module/index.js';
17
15
  import { DeferredPromise } from '../promise/deferred-promise.js';
18
- import { toArray } from '../utils/array/array.js';
19
16
  import { mapAsync } from '../utils/async-iterable-helpers/map.js';
20
17
  import { toArrayAsync } from '../utils/async-iterable-helpers/to-array.js';
21
- import { isDefined, isFunction, isObject, isUndefined } from '../utils/type-guards.js';
22
- let Application = class Application {
23
- static { Application_1 = this; }
24
- static _instance;
25
- static get instance() {
26
- if (isUndefined(this._instance)) {
27
- this._instance = getGlobalInjector().resolve(Application_1, 'App');
28
- // @ts-expect-error readonly
29
- this._instance.#shutdownToken = getShutdownToken();
30
- }
31
- return this._instance;
32
- }
18
+ import { isDefined, isFunction } from '../utils/type-guards.js';
19
+ export const APPLICATION_MODULE = injectionToken('ApplicationModule');
20
+ export const APPLICATION_INITIALIZER = injectionToken('ApplicationInitializer');
21
+ export const APPLICATION_DESTRUCTOR = injectionToken('ApplicationDestructor');
22
+ let Application = Application_1 = class Application {
33
23
  #name = injectArgument(this);
34
- #injector = inject(Injector).fork(`${this.#name}Injector`);
35
- #logger = this.#injector.resolve(Logger, this.#name);
36
- #moduleTypesAndInstances = new Set();
24
+ #injector = inject(Injector);
25
+ #logger = inject(Logger, this.#name);
26
+ #moduleTypesAndInstances = new Set(injectAll(APPLICATION_MODULE, undefined, { optional: true }));
37
27
  #shutdownPromise = new DeferredPromise();
38
- #shutdownToken = getShutdownSignal().createChild();
39
- get shutdownSignal() {
40
- return this.#shutdownToken.signal;
41
- }
42
- static get shutdownSignal() {
43
- return Application_1.instance.shutdownSignal;
44
- }
45
- static registerModule(moduleType) {
46
- Application_1.instance.registerModule(moduleType);
47
- }
48
- static registerModuleFunction(fn) {
49
- Application_1.instance.registerModuleFunction(fn);
50
- }
51
- static run(...functionsAndModules) {
52
- Application_1.instance.run(...functionsAndModules);
53
- }
54
- static async waitForShutdown() {
55
- return Application_1.instance.waitForShutdown();
28
+ #shutdownToken = inject(CancellationSignal, undefined, { optional: true })?.createChild() ?? new CancellationToken();
29
+ static create(name, providers = []) {
30
+ const injector = new Injector(`${name}Injector`);
31
+ for (const providersItem of providers.flat()) {
32
+ injector.register(providersItem.provide, providersItem, { multi: providersItem.multi });
33
+ }
34
+ return injector.resolve(Application_1, name);
56
35
  }
57
- static async shutdown() {
58
- await Application_1.instance.shutdown();
36
+ static run(name, providers = []) {
37
+ const app = Application_1.create(name, providers);
38
+ app.run();
39
+ return app;
59
40
  }
60
- static requestShutdown() {
61
- Application_1.instance.requestShutdown();
41
+ get shutdownSignal() {
42
+ return this.#shutdownToken.signal;
62
43
  }
63
44
  registerModule(moduleType) {
64
45
  this.#moduleTypesAndInstances.add(moduleType);
65
46
  }
66
- registerModuleFunction(fn) {
67
- const module = new FunctionModule(fn);
68
- this.registerModule(module);
69
- }
70
- run(...optionsFunctionsAndModules) {
47
+ run() {
71
48
  if (this.#shutdownToken.isSet) {
72
49
  throw new Error('Application was shut down.');
73
50
  }
74
- const options = ((optionsFunctionsAndModules.length > 0) && isObject(optionsFunctionsAndModules[0])) ? optionsFunctionsAndModules[0] : undefined;
75
- const functionsAndModules = (isUndefined(options) ? optionsFunctionsAndModules : optionsFunctionsAndModules.slice(1));
76
- void this._run(functionsAndModules, options);
51
+ void this._run();
52
+ }
53
+ async runAndWait() {
54
+ this.run();
55
+ await this.waitForShutdown();
77
56
  }
78
57
  async shutdown() {
79
58
  this.requestShutdown();
@@ -86,28 +65,19 @@ let Application = class Application {
86
65
  this.#shutdownToken.set();
87
66
  }
88
67
  async waitForShutdown() {
89
- return this.#shutdownPromise;
68
+ await this.#shutdownPromise;
90
69
  }
91
- async _run(functionsAndModules, options = {}) {
70
+ async _run() {
92
71
  let modules;
93
72
  try {
94
- for (const fnOrModule of functionsAndModules.flatMap((fns) => fns)) {
95
- if (fnOrModule.prototype instanceof ModuleBase) {
96
- this.registerModule(fnOrModule);
97
- }
98
- else {
99
- this.registerModuleFunction(fnOrModule);
100
- }
73
+ const initializers = await this.#injector.resolveAllAsync(APPLICATION_INITIALIZER, undefined, { optional: true });
74
+ for (const initializer of initializers) {
75
+ await runInInjectionContext(this.#injector, initializer);
101
76
  }
102
- if (isDefined(options.bootstrap)) {
103
- for (const fn of toArray(options.bootstrap)) {
104
- await runInInjectionContext(this.#injector, fn);
105
- }
106
- }
107
- modules = await toArrayAsync(mapAsync(this.#moduleTypesAndInstances, async (instanceOrType) => (isFunction(instanceOrType) ? this.#injector.resolveAsync(instanceOrType) : instanceOrType)));
77
+ modules = await toArrayAsync(mapAsync(this.#moduleTypesAndInstances, async (instanceOrType) => (isFunction(instanceOrType) ? await this.#injector.resolveAsync(instanceOrType) : instanceOrType)));
108
78
  await Promise.race([
109
79
  this.runModules(modules),
110
- this.shutdownSignal
80
+ this.shutdownSignal,
111
81
  ]);
112
82
  }
113
83
  catch (error) {
@@ -119,6 +89,15 @@ let Application = class Application {
119
89
  if (isDefined(modules)) {
120
90
  await this.stopModules(modules);
121
91
  }
92
+ const destructors = await this.#injector.resolveAllAsync(APPLICATION_DESTRUCTOR, undefined, { optional: true });
93
+ for (const destructor of destructors) {
94
+ try {
95
+ await runInInjectionContext(this.#injector, destructor);
96
+ }
97
+ catch (error) {
98
+ this.#logger.error(error, { message: 'An error occurred during application destruction.' });
99
+ }
100
+ }
122
101
  await this.#injector.dispose();
123
102
  this.#logger.info('Bye');
124
103
  }
@@ -128,7 +107,7 @@ let Application = class Application {
128
107
  const promises = modules.map(async (module) => {
129
108
  try {
130
109
  this.#logger.info(`Starting module ${module.name}`);
131
- await runInInjectionContext(this.#injector, async () => module.run());
110
+ await runInInjectionContext(this.#injector, async () => await module.run());
132
111
  this.#logger.info(`Module ${module.name} stopped.`);
133
112
  }
134
113
  catch (error) {
@@ -1,6 +1,2 @@
1
- /**
2
- * Start application modules and shutting down the app
3
- *
4
- * @module Application
5
- */
6
1
  export * from './application.js';
2
+ export * from './providers.js';
@@ -1,6 +1,2 @@
1
- /**
2
- * Start application modules and shutting down the app
3
- *
4
- * @module Application
5
- */
6
1
  export * from './application.js';
2
+ export * from './providers.js';
@@ -0,0 +1,10 @@
1
+ import { CancellationSignal } from '../cancellation/index.js';
2
+ import { type ProvidersItem } from '../injector/index.js';
3
+ import { Module, type FunctionModuleFunction } from '../module/index.js';
4
+ import type { OneOrMany, Type } from '../types/index.js';
5
+ import { type DestructorFn, type InitializerFn } from './application.js';
6
+ export declare function provideModules(...functionsAndModules: OneOrMany<FunctionModuleFunction | Type<Module>>[]): ProvidersItem[];
7
+ export declare function provideInitializer(fn: InitializerFn): ProvidersItem;
8
+ export declare function provideDestructor(fn: DestructorFn): ProvidersItem;
9
+ export declare function provideShutdownSignal(signal: CancellationSignal): ProvidersItem;
10
+ export declare function provideSignalHandler(): ProvidersItem;
@@ -0,0 +1,54 @@
1
+ import { CancellationSignal } from '../cancellation/index.js';
2
+ import { inject } from '../injector/index.js';
3
+ import { Logger } from '../logger/index.js';
4
+ import { FunctionModule, Module } from '../module/index.js';
5
+ import { isFunction } from '../utils/type-guards.js';
6
+ import { typeExtends } from '../utils/type/index.js';
7
+ import { Application, APPLICATION_DESTRUCTOR, APPLICATION_INITIALIZER, APPLICATION_MODULE } from './application.js';
8
+ const quitSignals = ['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGBREAK'];
9
+ const quitEvents = ['uncaughtException', 'unhandledRejection', 'rejectionHandled'];
10
+ export function provideModules(...functionsAndModules) {
11
+ return functionsAndModules.flat().map((fnOrModule) => {
12
+ if (typeExtends(fnOrModule, Module)) {
13
+ return { provide: APPLICATION_MODULE, useValue: fnOrModule, multi: true };
14
+ }
15
+ else if (isFunction(fnOrModule)) {
16
+ return { provide: APPLICATION_MODULE, useToken: FunctionModule, defaultArgument: fnOrModule, multi: true };
17
+ }
18
+ else {
19
+ throw new TypeError('Invalid module or function provided to provideModules');
20
+ }
21
+ });
22
+ }
23
+ export function provideInitializer(fn) {
24
+ return { provide: APPLICATION_INITIALIZER, useValue: fn, multi: true };
25
+ }
26
+ export function provideDestructor(fn) {
27
+ return { provide: APPLICATION_DESTRUCTOR, useValue: fn, multi: true };
28
+ }
29
+ export function provideShutdownSignal(signal) {
30
+ return { provide: CancellationSignal, useValue: signal };
31
+ }
32
+ export function provideSignalHandler() {
33
+ let signalCounter = 0;
34
+ return provideInitializer(() => {
35
+ const application = inject(Application);
36
+ const logger = inject(Logger);
37
+ for (const event of quitEvents) {
38
+ process.on(event, (...args) => {
39
+ logger.error(`QuitEvent occurred: ${event}`, { details: args });
40
+ application.requestShutdown();
41
+ });
42
+ }
43
+ for (const quitSignal of quitSignals) {
44
+ process.on(quitSignal, (signal) => {
45
+ logger.info(`${signal} received, quitting.`);
46
+ application.requestShutdown();
47
+ if (++signalCounter > 1) {
48
+ logger.warn('Forcefully quitting due to multiple signals...');
49
+ setTimeout(() => process.exit(1), 1);
50
+ }
51
+ });
52
+ }
53
+ });
54
+ }
@@ -1,5 +1,3 @@
1
- import type { AsyncDisposable } from '../../disposable/index.js';
2
- import { disposeAsync } from '../../disposable/index.js';
3
1
  import type { AfterResolve } from '../../injector/index.js';
4
2
  import { afterResolve } from '../../injector/index.js';
5
3
  import type { Record } from '../../types/index.js';
@@ -95,7 +93,7 @@ export declare class AuthenticationClientService<AdditionalTokenPayload extends
95
93
  */
96
94
  initialize(): void;
97
95
  /** @internal */
98
- [disposeAsync](): Promise<void>;
96
+ [Symbol.asyncDispose](): Promise<void>;
99
97
  /**
100
98
  * Disposes the service.
101
99
  * Stops refresh loop and completes subjects.
@@ -9,7 +9,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { Subject, filter, firstValueFrom, race, timer } from 'rxjs';
11
11
  import { CancellationToken } from '../../cancellation/token.js';
12
- import { disposeAsync } from '../../disposable/index.js';
13
12
  import { BadRequestError } from '../../errors/bad-request.error.js';
14
13
  import { ForbiddenError } from '../../errors/forbidden.error.js';
15
14
  import { InvalidTokenError } from '../../errors/invalid-token.error.js';
@@ -162,7 +161,7 @@ let AuthenticationClientService = class AuthenticationClientService {
162
161
  void this.refreshLoop();
163
162
  }
164
163
  /** @internal */
165
- async [disposeAsync]() {
164
+ async [Symbol.asyncDispose]() {
166
165
  await this.dispose();
167
166
  }
168
167
  /**
@@ -254,7 +253,7 @@ let AuthenticationClientService = class AuthenticationClientService {
254
253
  if (this.impersonated()) {
255
254
  throw new Error('Already impersonating. Please unimpersonate first.');
256
255
  }
257
- await this.lock.use(lockTimeout, true, async () => {
256
+ await this.lock.use(lockTimeout, async () => {
258
257
  this.impersonatorAuthenticationData = this.authenticationData;
259
258
  this.authenticationData = data;
260
259
  try {
@@ -275,7 +274,7 @@ let AuthenticationClientService = class AuthenticationClientService {
275
274
  * @param data Additional authentication data. If not provided, the data from before impersonation is used.
276
275
  */
277
276
  async unimpersonate(data) {
278
- await this.lock.use(lockTimeout, true, async () => {
277
+ await this.lock.use(lockTimeout, async () => {
279
278
  const newData = data ?? this.impersonatorAuthenticationData;
280
279
  try {
281
280
  const token = await this.client.unimpersonate({ data: newData });
@@ -334,7 +333,7 @@ let AuthenticationClientService = class AuthenticationClientService {
334
333
  while (this.disposeToken.isUnset) {
335
334
  try {
336
335
  // Use a non-blocking lock to ensure only one tab/instance runs the refresh logic at a time.
337
- await this.lock.use(0, false, async () => await this.refreshLoopIteration());
336
+ await this.lock.tryUse(undefined, async () => await this.refreshLoopIteration());
338
337
  // Calculate delay until the next refresh check.
339
338
  // The buffer ensures we refresh *before* the token actually expires.
340
339
  const delay = ((this.token()?.exp ?? 0) - this.estimatedServerTimestampSeconds() - refreshBufferSeconds) * millisecondsPerSecond;
@@ -1,6 +1,4 @@
1
1
  import type { BrowserContext, Page } from 'playwright';
2
- import type { AsyncDisposable } from '../disposable/disposable.js';
3
- import { disposeAsync } from '../disposable/disposable.js';
4
2
  import type { Resolvable } from '../injector/interfaces.js';
5
3
  import { afterResolve, resolveArgumentType } from '../injector/interfaces.js';
6
4
  import type { Logger } from '../logger/logger.js';
@@ -20,14 +18,14 @@ export type BrowserContextState = Tagged<Record<string | number, unknown>, 'Brow
20
18
  export type BrowserContextControllerArgument = NewBrowserContextOptions;
21
19
  export declare class BrowserContextController implements AsyncDisposable, Resolvable<BrowserContextControllerArgument> {
22
20
  #private;
23
- /** @deprecated should be avoided */
21
+ /** @deprecated direct usage of underlying page object should be avoided */
24
22
  readonly context: BrowserContext;
25
23
  readonly options: BrowserContextControllerOptions;
26
24
  readonly [resolveArgumentType]: BrowserContextControllerArgument;
27
25
  constructor(context: BrowserContext, options?: BrowserContextControllerOptions);
28
26
  [afterResolve](): void;
29
27
  initialize(): void;
30
- [disposeAsync](): Promise<void>;
28
+ [Symbol.asyncDispose](): Promise<void>;
31
29
  pages(): PageController[];
32
30
  /**
33
31
  * Get a controller for the page.
@@ -7,7 +7,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { disposeAsync } from '../disposable/disposable.js';
11
10
  import { Injectable } from '../injector/decorators.js';
12
11
  import { afterResolve, resolveArgumentType } from '../injector/interfaces.js';
13
12
  import { filterUndefinedFromRecord } from '../utils/object/object.js';
@@ -17,7 +16,7 @@ import { PageController } from './page-controller.js';
17
16
  import { attachLogger } from './utils.js';
18
17
  let BrowserContextController = class BrowserContextController {
19
18
  #pageControllers = new WeakMap();
20
- /** @deprecated should be avoided */
19
+ /** @deprecated direct usage of underlying page object should be avoided */
21
20
  context;
22
21
  options;
23
22
  constructor(context, options = {}) {
@@ -32,7 +31,7 @@ let BrowserContextController = class BrowserContextController {
32
31
  page.once('close', () => this.#pageControllers.delete(page));
33
32
  });
34
33
  }
35
- async [disposeAsync]() {
34
+ async [Symbol.asyncDispose]() {
36
35
  await this.close();
37
36
  }
38
37
  pages() {
@@ -91,7 +90,7 @@ let BrowserContextController = class BrowserContextController {
91
90
  }
92
91
  }
93
92
  async waitForClose() {
94
- return new Promise((resolve) => this.context.once('close', () => resolve()));
93
+ await new Promise((resolve) => this.context.once('close', () => resolve()));
95
94
  }
96
95
  attachLogger(logger) {
97
96
  attachLogger(this.context, logger);
@@ -108,8 +107,8 @@ BrowserContextController = __decorate([
108
107
  const { context: browserContext, controllerOptions } = await browserController.newRawContext(argument);
109
108
  value.context = browserContext;
110
109
  value.options = controllerOptions;
111
- }
112
- }
110
+ },
111
+ },
113
112
  }),
114
113
  __metadata("design:paramtypes", [Object, Object])
115
114
  ], BrowserContextController);
@@ -1,6 +1,4 @@
1
1
  import type { Browser, BrowserContext } from 'playwright';
2
- import type { AsyncDisposable } from '../disposable/disposable.js';
3
- import { disposeAsync } from '../disposable/disposable.js';
4
2
  import type { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
5
3
  import type { Record } from '../types/index.js';
6
4
  import type { BrowserContextControllerOptions, BrowserContextState, NewPageOptions } from './browser-context-controller.js';
@@ -29,12 +27,12 @@ export type NewBrowserContextOptions = {
29
27
  };
30
28
  export type BrowserControllerArgument = NewBrowserOptions;
31
29
  export declare class BrowserController implements AsyncDisposable, Resolvable<BrowserControllerArgument> {
32
- /** @deprecated should be avoided */
30
+ /** @deprecated direct usage of underlying browser object should be avoided */
33
31
  readonly browser: Browser;
34
32
  readonly options: BrowserControllerOptions | undefined;
35
33
  readonly [resolveArgumentType]: BrowserControllerArgument;
36
34
  constructor(browser: Browser, options?: BrowserControllerOptions);
37
- [disposeAsync](): Promise<void>;
35
+ [Symbol.asyncDispose](): Promise<void>;
38
36
  /**
39
37
  * @deprecated for internal use
40
38
  */
@@ -7,7 +7,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { disposeAsync } from '../disposable/disposable.js';
11
10
  import { Injectable } from '../injector/decorators.js';
12
11
  import { inject } from '../injector/inject.js';
13
12
  import { filterUndefinedFromRecord } from '../utils/object/object.js';
@@ -16,14 +15,14 @@ import { BrowserContextController } from './browser-context-controller.js';
16
15
  import { BrowserService } from './browser.service.js';
17
16
  import { mergeNewBrowserContextOptions } from './utils.js';
18
17
  let BrowserController = class BrowserController {
19
- /** @deprecated should be avoided */
18
+ /** @deprecated direct usage of underlying browser object should be avoided */
20
19
  browser;
21
20
  options;
22
21
  constructor(browser, options) {
23
22
  this.browser = browser;
24
23
  this.options = options;
25
24
  }
26
- async [disposeAsync]() {
25
+ async [Symbol.asyncDispose]() {
27
26
  await this.close();
28
27
  }
29
28
  /**
@@ -64,7 +63,7 @@ let BrowserController = class BrowserController {
64
63
  }
65
64
  }
66
65
  async waitForClose() {
67
- return await new Promise((resolve) => {
66
+ await new Promise((resolve) => {
68
67
  if (!this.browser.isConnected()) {
69
68
  resolve();
70
69
  }
@@ -1,6 +1,4 @@
1
1
  import type { Browser, LaunchOptions } from 'playwright';
2
- import type { AsyncDisposable } from '../disposable/disposable.js';
3
- import { disposeAsync } from '../disposable/disposable.js';
4
2
  import type { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
5
3
  import { BrowserContextController } from './browser-context-controller.js';
6
4
  import type { BrowserControllerOptions, NewBrowserContextOptions } from './browser-controller.js';
@@ -26,7 +24,7 @@ export declare class BrowserService implements AsyncDisposable, Resolvable<Brows
26
24
  private readonly persistentBrowserContexts;
27
25
  readonly options: BrowserServiceOptions | undefined;
28
26
  readonly [resolveArgumentType]: BrowserServiceArgument;
29
- [disposeAsync](): Promise<void>;
27
+ [Symbol.asyncDispose](): Promise<void>;
30
28
  /**
31
29
  * @deprecated internal use only
32
30
  */
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { disposeAsync } from '../disposable/disposable.js';
8
7
  import { Singleton } from '../injector/decorators.js';
9
8
  import { injectArgument } from '../injector/inject.js';
10
9
  import { filterUndefinedFromRecord } from '../utils/object/object.js';
@@ -20,7 +19,7 @@ let BrowserService = class BrowserService {
20
19
  browsers = new Set();
21
20
  persistentBrowserContexts = new Set();
22
21
  options = injectArgument(this, { optional: true });
23
- async [disposeAsync]() {
22
+ async [Symbol.asyncDispose]() {
24
23
  await this.dispose();
25
24
  }
26
25
  /**
@@ -1,6 +1,4 @@
1
1
  import type { Page } from 'playwright';
2
- import type { AsyncDisposable } from '../disposable/disposable.js';
3
- import { disposeAsync } from '../disposable/disposable.js';
4
2
  import type { Logger } from '../logger/logger.js';
5
3
  import type { BrowserContextController } from './browser-context-controller.js';
6
4
  import type { DocumentControllerOptions } from './document-controller.js';
@@ -15,11 +13,11 @@ export type ScrollToCoordinates = {
15
13
  y?: number;
16
14
  };
17
15
  export declare class PageController extends DocumentController<Page> implements AsyncDisposable {
18
- /** @deprecated should be avoided */
16
+ /** @deprecated direct usage of underlying page object should be avoided */
19
17
  readonly page: Page;
20
18
  readonly options: PageControllerOptions;
21
19
  constructor(page: Page, context: BrowserContextController, options?: PageControllerOptions);
22
- [disposeAsync](): Promise<void>;
20
+ [Symbol.asyncDispose](): Promise<void>;
23
21
  close(): Promise<void>;
24
22
  /** finds pages opened by this page (having opener set to this page) */
25
23
  opened(): Promise<PageController[]>;
@@ -1,4 +1,3 @@
1
- import { disposeAsync } from '../disposable/disposable.js';
2
1
  import { filterUndefinedFromRecord } from '../utils/object/object.js';
3
2
  import { readableStreamFromPromise } from '../utils/stream/from-promise.js';
4
3
  import { toReadableStream } from '../utils/stream/to-readable-stream.js';
@@ -9,7 +8,7 @@ import { DocumentController } from './document-controller.js';
9
8
  import { ElementController } from './element-controller.js';
10
9
  import { attachLogger, delay } from './utils.js';
11
10
  export class PageController extends DocumentController {
12
- /** @deprecated should be avoided */
11
+ /** @deprecated direct usage of underlying page object should be avoided */
13
12
  page;
14
13
  options;
15
14
  constructor(page, context, options = {}) {
@@ -17,7 +16,7 @@ export class PageController extends DocumentController {
17
16
  this.page = page;
18
17
  this.options = options;
19
18
  }
20
- async [disposeAsync]() {
19
+ async [Symbol.asyncDispose]() {
21
20
  await this.close();
22
21
  }
23
22
  async close() {
@@ -45,7 +44,7 @@ export class PageController extends DocumentController {
45
44
  await this.page.setExtraHTTPHeaders(filtered);
46
45
  }
47
46
  async waitForClose() {
48
- return new Promise((resolve) => {
47
+ await new Promise((resolve) => {
49
48
  if (this.page.isClosed()) {
50
49
  resolve();
51
50
  return;
@@ -69,7 +68,7 @@ export class PageController extends DocumentController {
69
68
  }
70
69
  async renderPdf(options = {}) {
71
70
  const createPdfOptions = convertPdfOptions(options);
72
- return withTimeout(options.timeout ?? 30 * millisecondsPerSecond, this.page.pdf(createPdfOptions), { errorMessage: 'Rendering pdf timed out.' });
71
+ return await withTimeout(options.timeout ?? 30 * millisecondsPerSecond, this.page.pdf(createPdfOptions), { errorMessage: 'Rendering pdf timed out.' });
73
72
  }
74
73
  async scroll(deltaX, deltaY) {
75
74
  await this.page.mouse.wheel(deltaX, deltaY);
@@ -87,7 +86,7 @@ export class PageController extends DocumentController {
87
86
  const offsetY = viewportSize.height / 10;
88
87
  const isElement = coordinatesOrController instanceof ElementController;
89
88
  while (true) {
90
- const { scrollWidth, scrollHeight, scrollLeft, scrollTop, clientWidth, clientHeight } = await this.page.evaluate(async () => {
89
+ const { scrollWidth, scrollHeight, scrollLeft, scrollTop, clientWidth, clientHeight } = await this.page.evaluate(() => {
91
90
  const { scrollWidth, scrollHeight, scrollLeft, scrollTop, clientWidth, clientHeight } = document.documentElement;
92
91
  return { scrollWidth, scrollHeight, scrollLeft, scrollTop, clientWidth, clientHeight };
93
92
  });
@@ -139,7 +138,7 @@ function convertPdfOptions(options) {
139
138
  top: options.margin,
140
139
  bottom: options.margin,
141
140
  right: options.margin,
142
- left: options.margin
141
+ left: options.margin,
143
142
  };
144
143
  return {
145
144
  format: options.format ?? 'a4',
@@ -151,6 +150,6 @@ function convertPdfOptions(options) {
151
150
  margin,
152
151
  displayHeaderFooter: options.displayHeaderFooter ?? (isDefined(options.headerTemplate) || isDefined(options.footerTemplate)),
153
152
  headerTemplate: options.headerTemplate,
154
- footerTemplate: options.footerTemplate
153
+ footerTemplate: options.footerTemplate,
155
154
  };
156
155
  }
package/browser/utils.js CHANGED
@@ -13,7 +13,7 @@ export function getLaunchOptions(options) {
13
13
  ignoreDefaultArgs: (options.headless == 'new') ? ['--headless'] : undefined,
14
14
  headless: headless != false,
15
15
  args,
16
- proxy: options.proxy
16
+ proxy: options.proxy,
17
17
  };
18
18
  }
19
19
  export function mergeNewBrowserContextOptions(a, b, c) {
@@ -22,13 +22,13 @@ export function mergeNewBrowserContextOptions(a, b, c) {
22
22
  ...a,
23
23
  ...b,
24
24
  ...c,
25
- extraHttpHeaders: (objectKeys(mergedExtraHttpHeaders).length > 0) ? mergedExtraHttpHeaders : undefined
25
+ extraHttpHeaders: (objectKeys(mergedExtraHttpHeaders).length > 0) ? mergedExtraHttpHeaders : undefined,
26
26
  };
27
27
  }
28
28
  function getPageLogger(page, baseLogger) {
29
29
  let pageLogger = pageLoggerMap.get(page);
30
30
  if (isUndefined(pageLogger)) {
31
- pageLogger = baseLogger.subModule(crypto.randomUUID().slice(-12));
31
+ pageLogger = baseLogger.with({ pageSession: crypto.randomUUID().slice(-12) });
32
32
  pageLoggerMap.set(page, pageLogger);
33
33
  }
34
34
  return pageLogger;