@tstdl/base 0.92.167 → 0.93.0
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/application/application.d.ts +12 -18
- package/application/application.js +48 -69
- package/application/index.d.ts +1 -5
- package/application/index.js +1 -5
- package/application/providers.d.ts +10 -0
- package/application/providers.js +54 -0
- package/audit/audit.model.d.ts +15 -0
- package/audit/audit.model.js +73 -0
- package/audit/auditor.d.ts +42 -0
- package/audit/auditor.js +111 -0
- package/audit/index.d.ts +3 -0
- package/audit/index.js +3 -0
- package/audit/types.d.ts +22 -0
- package/audit/types.js +19 -0
- package/authentication/client/authentication.service.d.ts +1 -3
- package/authentication/client/authentication.service.js +4 -5
- package/browser/browser-context-controller.d.ts +2 -4
- package/browser/browser-context-controller.js +5 -6
- package/browser/browser-controller.d.ts +2 -4
- package/browser/browser-controller.js +3 -4
- package/browser/browser.service.d.ts +1 -3
- package/browser/browser.service.js +1 -2
- package/browser/page-controller.d.ts +2 -4
- package/browser/page-controller.js +7 -8
- package/browser/utils.js +3 -3
- package/cancellation/token.d.ts +104 -41
- package/cancellation/token.js +125 -54
- package/core.d.ts +1 -13
- package/core.js +1 -46
- package/disposable/disposable.d.ts +0 -8
- package/disposable/disposable.js +1 -3
- package/disposable/index.d.ts +0 -6
- package/disposable/index.js +0 -6
- package/disposable/using.d.ts +0 -1
- package/disposable/using.js +2 -3
- package/distributed-loop/distributed-loop.js +2 -2
- package/errors/utils.js +4 -1
- package/examples/api/authentication.js +11 -5
- package/examples/api/basic-overview.js +17 -12
- package/examples/api/custom-authentication.js +13 -7
- package/examples/api/streaming.js +15 -12
- package/examples/browser/basic.js +6 -3
- package/examples/document-management/main.js +6 -3
- package/examples/http/client.js +7 -3
- package/examples/mail/basic.js +9 -7
- package/examples/pdf/basic.js +8 -6
- package/examples/template/basic.js +7 -5
- package/http/client/http-client-request.d.ts +1 -2
- package/http/client/http-client-request.js +1 -2
- package/http/server/http-server.d.ts +1 -3
- package/http/server/http-server.js +0 -1
- package/http/server/node/node-http-server.d.ts +1 -2
- package/http/server/node/node-http-server.js +1 -2
- package/import.js +1 -1
- package/injector/injector.d.ts +1 -1
- package/injector/types.d.ts +3 -4
- package/lock/lock.d.ts +40 -21
- package/lock/lock.js +74 -1
- package/lock/postgres/drizzle/0000_busy_tattoo.sql +7 -0
- package/lock/postgres/drizzle/meta/0000_snapshot.json +65 -0
- package/lock/postgres/drizzle/meta/_journal.json +13 -0
- package/lock/postgres/drizzle.config.js +11 -0
- package/lock/postgres/index.d.ts +2 -0
- package/lock/postgres/index.js +2 -0
- package/lock/postgres/lock.d.ts +14 -0
- package/lock/postgres/lock.js +127 -0
- package/lock/postgres/models/index.d.ts +2 -0
- package/lock/postgres/models/index.js +2 -0
- package/lock/postgres/models/lock.model.d.ts +7 -0
- package/{examples/orm/user.model.js → lock/postgres/models/lock.model.js} +22 -30
- package/lock/postgres/models/schemas.d.ts +3 -0
- package/lock/postgres/models/schemas.js +4 -0
- package/lock/postgres/module.d.ts +6 -0
- package/lock/postgres/module.js +26 -0
- package/lock/postgres/provider.d.ts +6 -0
- package/lock/postgres/provider.js +29 -0
- package/lock/provider.d.ts +12 -2
- package/lock/provider.js +24 -1
- package/lock/web/web-lock.d.ts +4 -3
- package/lock/web/web-lock.js +49 -42
- package/lock/web/web-lock.provider.d.ts +0 -3
- package/lock/web/web-lock.provider.js +5 -22
- package/logger/formatter.d.ts +13 -0
- package/logger/formatter.js +3 -0
- package/logger/formatters/index.d.ts +2 -0
- package/logger/formatters/index.js +2 -0
- package/logger/formatters/json.d.ts +5 -0
- package/logger/formatters/json.js +33 -0
- package/logger/formatters/pretty-print.d.ts +5 -0
- package/logger/formatters/pretty-print.js +55 -0
- package/logger/index.d.ts +5 -2
- package/logger/index.js +5 -2
- package/logger/level.d.ts +10 -8
- package/logger/level.js +9 -9
- package/logger/logger.d.ts +21 -30
- package/logger/logger.js +98 -26
- package/logger/manager.d.ts +20 -0
- package/logger/manager.js +86 -0
- package/logger/tokens.d.ts +1 -1
- package/logger/tokens.js +1 -1
- package/logger/transport.d.ts +14 -0
- package/logger/transport.js +16 -0
- package/logger/transports/console.d.ts +14 -0
- package/logger/transports/console.js +36 -0
- package/logger/transports/index.d.ts +1 -0
- package/logger/transports/index.js +1 -0
- package/mail/clients/nodemailer.mail-client.d.ts +0 -1
- package/mail/clients/nodemailer.mail-client.js +9 -7
- package/message-bus/local/local-message-bus.js +2 -2
- package/message-bus/message-bus-base.d.ts +2 -3
- package/message-bus/message-bus-base.js +5 -6
- package/message-bus/message-bus.d.ts +1 -2
- package/message-bus/message-bus.js +1 -2
- package/module/index.d.ts +0 -2
- package/module/index.js +0 -2
- package/module/module.d.ts +17 -18
- package/module/module.js +47 -12
- package/module/modules/function.module.d.ts +6 -6
- package/module/modules/function.module.js +25 -9
- package/module/modules/web-server.module.d.ts +2 -10
- package/module/modules/web-server.module.js +3 -11
- package/openid-connect/index.d.ts +0 -2
- package/openid-connect/index.js +0 -2
- package/openid-connect/oidc-state.model.d.ts +4 -5
- package/openid-connect/oidc-state.model.js +51 -1
- package/openid-connect/oidc.service-model.d.ts +1 -1
- package/openid-connect/oidc.service.d.ts +2 -6
- package/openid-connect/oidc.service.js +24 -37
- package/orm/decorators.d.ts +10 -1
- package/orm/decorators.js +8 -0
- package/orm/server/repository.d.ts +3 -1
- package/orm/server/repository.js +32 -3
- package/package.json +19 -29
- package/pdf/pdf.service.js +9 -9
- package/pool/pool.d.ts +1 -3
- package/pool/pool.js +3 -4
- package/queue/postgres/job.model.d.ts +1 -2
- package/queue/postgres/job.model.js +1 -2
- package/queue/postgres/module.js +1 -1
- package/threading/thread-pool.d.ts +1 -3
- package/threading/thread-pool.js +7 -8
- package/utils/format-error.d.ts +7 -0
- package/utils/format-error.js +59 -17
- package/utils/function/memoize.d.ts +22 -7
- package/utils/function/memoize.js +82 -23
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/object/dereference.d.ts +51 -19
- package/utils/object/dereference.js +52 -43
- package/utils/timing.js +2 -2
- package/utils/try-chain.d.ts +22 -0
- package/utils/try-chain.js +46 -0
- package/database/entity-repository.d.ts +0 -50
- package/database/entity-repository.js +0 -3
- package/database/entity.d.ts +0 -7
- package/database/entity.js +0 -1
- package/database/id.d.ts +0 -1
- package/database/id.js +0 -9
- package/database/index.d.ts +0 -11
- package/database/index.js +0 -11
- package/database/module.d.ts +0 -8
- package/database/module.js +0 -11
- package/database/mongo/classes.d.ts +0 -21
- package/database/mongo/classes.js +0 -26
- package/database/mongo/index.d.ts +0 -15
- package/database/mongo/index.js +0 -15
- package/database/mongo/model/document.d.ts +0 -29
- package/database/mongo/model/document.js +0 -63
- package/database/mongo/model/index.d.ts +0 -1
- package/database/mongo/model/index.js +0 -1
- package/database/mongo/module.d.ts +0 -8
- package/database/mongo/module.js +0 -68
- package/database/mongo/mongo-base.repository.d.ts +0 -103
- package/database/mongo/mongo-base.repository.js +0 -263
- package/database/mongo/mongo-bulk.d.ts +0 -35
- package/database/mongo/mongo-bulk.js +0 -90
- package/database/mongo/mongo-entity-repository.d.ts +0 -98
- package/database/mongo/mongo-entity-repository.js +0 -278
- package/database/mongo/operations.d.ts +0 -10
- package/database/mongo/operations.js +0 -54
- package/database/mongo/query-converter.d.ts +0 -6
- package/database/mongo/query-converter.js +0 -83
- package/database/mongo/simple-entity-repository.d.ts +0 -7
- package/database/mongo/simple-entity-repository.js +0 -6
- package/database/mongo/types.d.ts +0 -50
- package/database/mongo/types.js +0 -3
- package/database/query.d.ts +0 -121
- package/database/query.js +0 -7
- package/database/utils.d.ts +0 -2
- package/database/utils.js +0 -3
- package/disposable/async-disposer.d.ts +0 -35
- package/disposable/async-disposer.js +0 -125
- package/examples/orm/drizzle.config.js +0 -6
- package/examples/orm/schemas.d.ts +0 -3
- package/examples/orm/schemas.js +0 -4
- package/examples/orm/test.d.ts +0 -1
- package/examples/orm/test.js +0 -11
- package/examples/orm/user.model.d.ts +0 -13
- package/key-value-store/mongo/index.d.ts +0 -6
- package/key-value-store/mongo/index.js +0 -6
- package/key-value-store/mongo/module.d.ts +0 -8
- package/key-value-store/mongo/module.js +0 -18
- package/key-value-store/mongo/mongo-key-value-store.provider.d.ts +0 -8
- package/key-value-store/mongo/mongo-key-value-store.provider.js +0 -26
- package/key-value-store/mongo/mongo-key-value.model.d.ts +0 -7
- package/key-value-store/mongo/mongo-key-value.model.js +0 -1
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +0 -10
- package/key-value-store/mongo/mongo-key-value.repository.js +0 -31
- package/key-value-store/mongo/mongo-key-value.store.d.ts +0 -15
- package/key-value-store/mongo/mongo-key-value.store.js +0 -82
- package/key-value-store/mongo/tokens.d.ts +0 -3
- package/key-value-store/mongo/tokens.js +0 -2
- package/lock/mongo/index.d.ts +0 -5
- package/lock/mongo/index.js +0 -5
- package/lock/mongo/lock.d.ts +0 -14
- package/lock/mongo/lock.js +0 -125
- package/lock/mongo/model.d.ts +0 -6
- package/lock/mongo/model.js +0 -1
- package/lock/mongo/module.d.ts +0 -12
- package/lock/mongo/module.js +0 -20
- package/lock/mongo/mongo-lock-repository.d.ts +0 -14
- package/lock/mongo/mongo-lock-repository.js +0 -67
- package/lock/mongo/provider.d.ts +0 -8
- package/lock/mongo/provider.js +0 -36
- package/logger/console/index.d.ts +0 -1
- package/logger/console/index.js +0 -1
- package/logger/console/logger.d.ts +0 -11
- package/logger/console/logger.js +0 -64
- package/logger/noop/index.d.ts +0 -1
- package/logger/noop/index.js +0 -1
- package/logger/noop/logger.d.ts +0 -9
- package/logger/noop/logger.js +0 -21
- package/migration/index.d.ts +0 -9
- package/migration/index.js +0 -9
- package/migration/migration-state-repository.d.ts +0 -4
- package/migration/migration-state-repository.js +0 -3
- package/migration/migration-state.d.ts +0 -6
- package/migration/migration-state.js +0 -1
- package/migration/migrator.d.ts +0 -23
- package/migration/migrator.js +0 -76
- package/migration/mongo/index.d.ts +0 -2
- package/migration/mongo/index.js +0 -2
- package/migration/mongo/migration-state-repository.d.ts +0 -11
- package/migration/mongo/migration-state-repository.js +0 -32
- package/migration/mongo/module.d.ts +0 -12
- package/migration/mongo/module.js +0 -17
- package/module/module-base.d.ts +0 -18
- package/module/module-base.js +0 -40
- package/module/module-metric-reporter.d.ts +0 -29
- package/module/module-metric-reporter.js +0 -62
- package/openid-connect/mongo-oidc-state.repository.d.ts +0 -21
- package/openid-connect/mongo-oidc-state.repository.js +0 -52
- package/openid-connect/oidc-state.repository.d.ts +0 -4
- package/openid-connect/oidc-state.repository.js +0 -3
- package/process-shutdown.d.ts +0 -9
- package/process-shutdown.js +0 -65
- package/queue/mongo/index.d.ts +0 -4
- package/queue/mongo/index.js +0 -4
- package/queue/mongo/job.d.ts +0 -12
- package/queue/mongo/job.js +0 -1
- package/queue/mongo/mongo-job.repository.d.ts +0 -13
- package/queue/mongo/mongo-job.repository.js +0 -54
- package/queue/mongo/queue.d.ts +0 -38
- package/queue/mongo/queue.js +0 -266
- package/queue/mongo/queue.provider.d.ts +0 -18
- package/queue/mongo/queue.provider.js +0 -38
- package/search-index/elastic/config.d.ts +0 -8
- package/search-index/elastic/config.js +0 -26
- package/search-index/elastic/index.d.ts +0 -8
- package/search-index/elastic/index.js +0 -8
- package/search-index/elastic/keyword-rewriter.d.ts +0 -8
- package/search-index/elastic/keyword-rewriter.js +0 -18
- package/search-index/elastic/model/elastic-query.d.ts +0 -16
- package/search-index/elastic/model/elastic-query.js +0 -1
- package/search-index/elastic/model/index-mapping.d.ts +0 -26
- package/search-index/elastic/model/index-mapping.js +0 -4
- package/search-index/elastic/model/index.d.ts +0 -3
- package/search-index/elastic/model/index.js +0 -3
- package/search-index/elastic/model/sort.d.ts +0 -8
- package/search-index/elastic/model/sort.js +0 -1
- package/search-index/elastic/module.d.ts +0 -10
- package/search-index/elastic/module.js +0 -49
- package/search-index/elastic/query-builder/boolean-query-builder.d.ts +0 -11
- package/search-index/elastic/query-builder/boolean-query-builder.js +0 -52
- package/search-index/elastic/query-builder/index.d.ts +0 -1
- package/search-index/elastic/query-builder/index.js +0 -1
- package/search-index/elastic/query-converter.d.ts +0 -9
- package/search-index/elastic/query-converter.js +0 -183
- package/search-index/elastic/search-index.d.ts +0 -30
- package/search-index/elastic/search-index.js +0 -144
- package/search-index/elastic/sort-converter.d.ts +0 -4
- package/search-index/elastic/sort-converter.js +0 -14
- package/search-index/elastic/types.d.ts +0 -5
- package/search-index/elastic/types.js +0 -1
- package/search-index/error.d.ts +0 -10
- package/search-index/error.js +0 -14
- package/search-index/index.d.ts +0 -3
- package/search-index/index.js +0 -3
- package/search-index/memory/index.d.ts +0 -1
- package/search-index/memory/index.js +0 -1
- package/search-index/memory/memory-search-index.d.ts +0 -19
- package/search-index/memory/memory-search-index.js +0 -144
- package/search-index/search-index.d.ts +0 -46
- package/search-index/search-index.js +0 -31
- package/search-index/search-result.d.ts +0 -12
- package/search-index/search-result.js +0 -1
- package/theme/adapters/css-adapter.d.ts +0 -5
- package/theme/adapters/css-adapter.js +0 -29
- package/theme/adapters/index.d.ts +0 -2
- package/theme/adapters/index.js +0 -2
- package/theme/adapters/tailwind-adapter.d.ts +0 -18
- package/theme/adapters/tailwind-adapter.js +0 -32
- package/theme/index.d.ts +0 -1
- package/theme/index.js +0 -1
- package/theme/theme-service.d.ts +0 -43
- package/theme/theme-service.js +0 -128
- /package/{examples/orm → lock/postgres}/drizzle.config.d.ts +0 -0
|
@@ -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
|
-
[
|
|
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 [
|
|
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
|
-
|
|
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
|
-
[
|
|
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 [
|
|
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
|
-
|
|
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
|
-
[
|
|
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 [
|
|
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
|
-
[
|
|
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 [
|
|
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
|
-
|
|
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(
|
|
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.
|
|
31
|
+
pageLogger = baseLogger.with({ pageSession: crypto.randomUUID().slice(-12) });
|
|
32
32
|
pageLoggerMap.set(page, pageLogger);
|
|
33
33
|
}
|
|
34
34
|
return pageLogger;
|
package/cancellation/token.d.ts
CHANGED
|
@@ -1,138 +1,201 @@
|
|
|
1
1
|
import { BehaviorSubject, type Observable, type Observer, type Subscribable, type Unsubscribable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for connecting a source to a CancellationToken.
|
|
4
|
+
*/
|
|
2
5
|
export type ConnectConfig = {
|
|
3
6
|
/**
|
|
4
|
-
* Propagate
|
|
7
|
+
* Propagate 'set' (true) states to the child token.
|
|
5
8
|
* @default true
|
|
6
9
|
*/
|
|
7
10
|
set?: boolean;
|
|
8
11
|
/**
|
|
9
|
-
* Propagate unset to child.
|
|
12
|
+
* Propagate 'unset' (false) states to the child token.
|
|
10
13
|
* @default true
|
|
11
14
|
*/
|
|
12
15
|
unset?: boolean;
|
|
13
16
|
/**
|
|
14
|
-
* Propagate complete to child.
|
|
17
|
+
* Propagate the 'complete' event to the child token.
|
|
15
18
|
* @default true
|
|
16
19
|
*/
|
|
17
20
|
complete?: boolean;
|
|
18
21
|
/**
|
|
19
|
-
* Propagate errors to child.
|
|
22
|
+
* Propagate errors to the child token.
|
|
20
23
|
* @default true
|
|
21
24
|
*/
|
|
22
25
|
error?: boolean;
|
|
23
26
|
/**
|
|
24
|
-
*
|
|
27
|
+
* Immediately apply the source's current state upon connection.
|
|
28
|
+
* If false, waits for the next state change.
|
|
25
29
|
* @default true
|
|
26
30
|
*/
|
|
27
31
|
immediate?: boolean;
|
|
28
32
|
/**
|
|
29
|
-
* Only
|
|
33
|
+
* Only propagate the first applicable state change, then disconnect.
|
|
30
34
|
* @default false
|
|
31
35
|
*/
|
|
32
36
|
once?: boolean;
|
|
33
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* A read-only view of a CancellationToken's state.
|
|
40
|
+
*
|
|
41
|
+
* It allows consumers to subscribe to state changes, await cancellation,
|
|
42
|
+
* or convert to other signal types (like AbortSignal) without being able
|
|
43
|
+
* to change the token's state.
|
|
44
|
+
*
|
|
45
|
+
* It is both `PromiseLike<void>` (resolves when set) and `Subscribable<void>`
|
|
46
|
+
* (emits when set).
|
|
47
|
+
*/
|
|
34
48
|
export declare class CancellationSignal implements PromiseLike<void>, Subscribable<void> {
|
|
35
|
-
|
|
49
|
+
protected readonly _stateSubject: BehaviorSubject<boolean>;
|
|
36
50
|
/**
|
|
37
|
-
* Observable which emits the current state
|
|
51
|
+
* Observable which emits the current state (true for set, false for unset)
|
|
52
|
+
* and any subsequent state changes.
|
|
38
53
|
*/
|
|
39
54
|
readonly state$: Observable<boolean>;
|
|
40
55
|
/**
|
|
41
|
-
* Observable which emits when
|
|
56
|
+
* Observable which emits `void` only when the token becomes set.
|
|
42
57
|
*/
|
|
43
58
|
readonly set$: Observable<void>;
|
|
44
59
|
/**
|
|
45
|
-
* Observable which emits when
|
|
60
|
+
* Observable which emits `void` only when the token becomes unset.
|
|
46
61
|
*/
|
|
47
62
|
readonly unset$: Observable<void>;
|
|
48
63
|
/**
|
|
49
|
-
*
|
|
64
|
+
* A promise that resolves with the next state of the token.
|
|
50
65
|
*/
|
|
51
66
|
get $state(): Promise<boolean>;
|
|
52
67
|
/**
|
|
53
|
-
*
|
|
68
|
+
* A promise that resolves when the token is next set.
|
|
69
|
+
* If the token is already set, it resolves immediately.
|
|
54
70
|
*/
|
|
55
71
|
get $set(): Promise<void>;
|
|
56
72
|
/**
|
|
57
|
-
*
|
|
73
|
+
* A promise that resolves when the token is next unset.
|
|
74
|
+
* If the token is already unset, it resolves immediately.
|
|
58
75
|
*/
|
|
59
76
|
get $unset(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* The current state of the token.
|
|
79
|
+
* @returns `true` if set, `false` if unset.
|
|
80
|
+
*/
|
|
60
81
|
get state(): boolean;
|
|
61
82
|
/**
|
|
62
|
-
* Whether
|
|
83
|
+
* Whether the token is currently in a 'set' state.
|
|
63
84
|
*/
|
|
64
85
|
get isSet(): boolean;
|
|
65
86
|
/**
|
|
66
|
-
* Whether
|
|
87
|
+
* Whether the token is currently in an 'unset' state.
|
|
67
88
|
*/
|
|
68
89
|
get isUnset(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
69
93
|
constructor(stateSubject: BehaviorSubject<boolean>);
|
|
70
94
|
/**
|
|
71
|
-
* Returns
|
|
95
|
+
* Returns a standard `AbortSignal` that is aborted when this token is set.
|
|
96
|
+
* Useful for interoperability with APIs like `fetch`.
|
|
72
97
|
*/
|
|
73
98
|
asAbortSignal(): AbortSignal;
|
|
74
99
|
/**
|
|
75
|
-
*
|
|
100
|
+
* Creates a new `CancellationToken` that is connected to this one.
|
|
101
|
+
* State changes from this token will propagate to the new child token.
|
|
76
102
|
* @see {@link connect}
|
|
77
103
|
*/
|
|
78
104
|
createChild(config?: ConnectConfig): CancellationToken;
|
|
79
105
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @param target
|
|
106
|
+
* Propagates state changes from this token to a target `CancellationToken`.
|
|
107
|
+
* @param target The token to receive state updates.
|
|
108
|
+
* @param config Configuration for the connection.
|
|
82
109
|
*/
|
|
83
110
|
connect(target: CancellationToken, config?: ConnectConfig): void;
|
|
111
|
+
/**
|
|
112
|
+
* Allows this object to be awaited. The promise resolves when the token is set.
|
|
113
|
+
* Implements the `PromiseLike<void>` interface.
|
|
114
|
+
*/
|
|
84
115
|
then<TResult>(onfulfilled?: ((value: void) => TResult | PromiseLike<TResult>) | null): Promise<TResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Subscribes to notifications for when the token becomes set.
|
|
118
|
+
* This is an alias for `this.set$.subscribe(observer)`.
|
|
119
|
+
* Implements the `Subscribable<void>` interface.
|
|
120
|
+
*/
|
|
85
121
|
subscribe(observer: Partial<Observer<void>>): Unsubscribable;
|
|
86
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* A CancellationToken represents a unit of work that can be cancelled.
|
|
125
|
+
* It can be explicitly set/unset, completed, or errored.
|
|
126
|
+
*
|
|
127
|
+
* You can create child tokens, connect them to other async primitives
|
|
128
|
+
* (Promises, AbortSignals), and pass around its read-only `signal`
|
|
129
|
+
* to consumers that should only react to cancellation, not trigger it.
|
|
130
|
+
*/
|
|
87
131
|
export declare class CancellationToken extends CancellationSignal {
|
|
88
132
|
#private;
|
|
89
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* A read-only view of this token.
|
|
135
|
+
* Useful for passing to functions that should only be able to check for
|
|
136
|
+
* cancellation but not trigger it.
|
|
137
|
+
*/
|
|
90
138
|
get signal(): CancellationSignal;
|
|
91
139
|
/**
|
|
92
|
-
* @param initialState
|
|
93
|
-
* - `false`: unset
|
|
94
|
-
* - `true`: set
|
|
95
|
-
* @default false
|
|
140
|
+
* @param initialState The initial state of the token. `false` (unset) by default.
|
|
96
141
|
*/
|
|
97
142
|
constructor(initialState?: boolean);
|
|
98
143
|
/**
|
|
99
|
-
* Creates a token
|
|
100
|
-
* @param source source to listen to
|
|
101
|
-
* @
|
|
144
|
+
* Creates a token that is set when the source signals.
|
|
145
|
+
* @param source The event source to listen to.
|
|
146
|
+
* @example
|
|
147
|
+
* // From a fetch promise
|
|
148
|
+
* const token = CancellationToken.from(fetch('/api/data'));
|
|
149
|
+
*
|
|
150
|
+
* // From a browser AbortSignal
|
|
151
|
+
* const controller = new AbortController();
|
|
152
|
+
* const token = CancellationToken.from(controller.signal);
|
|
102
153
|
*/
|
|
103
|
-
static from(source: AbortSignal | PromiseLike<any> | Observable<void>,
|
|
104
|
-
complete?: boolean;
|
|
105
|
-
}): CancellationToken;
|
|
154
|
+
static from(source: AbortSignal | PromiseLike<any> | Observable<void>, config?: ConnectConfig): CancellationToken;
|
|
106
155
|
/**
|
|
107
|
-
* Creates a token and connects
|
|
108
|
-
*
|
|
156
|
+
* Creates a token and connects it to an `Observable<boolean>` source.
|
|
157
|
+
* The token's state will mirror the boolean values emitted by the observable.
|
|
158
|
+
* @param source The observable source.
|
|
159
|
+
* @param config Configuration for the connection.
|
|
109
160
|
*/
|
|
110
161
|
static from(source: Observable<boolean>, config?: ConnectConfig): CancellationToken;
|
|
111
|
-
static connect(state$: Observable<boolean>, target: CancellationToken, config?: ConnectConfig): void;
|
|
112
162
|
/**
|
|
113
|
-
*
|
|
163
|
+
* Connects an observable state source to a target token.
|
|
164
|
+
* @param source$ The observable providing boolean state.
|
|
165
|
+
* @param target The CancellationToken to update.
|
|
166
|
+
* @param config The connection configuration.
|
|
167
|
+
*/
|
|
168
|
+
static connect(source$: Observable<boolean>, target: CancellationToken, config?: ConnectConfig): void;
|
|
169
|
+
/**
|
|
170
|
+
* Makes this token a child of a parent token.
|
|
171
|
+
* State changes from the parent will propagate to this token.
|
|
172
|
+
* @param parent The token to inherit state from.
|
|
173
|
+
* @param config Configuration for the connection.
|
|
114
174
|
*/
|
|
115
175
|
inherit(parent: CancellationToken | CancellationSignal, config?: ConnectConfig): this;
|
|
116
176
|
/**
|
|
117
|
-
*
|
|
177
|
+
* Sets the token's state to `true`.
|
|
178
|
+
* This signals cancellation or completion of the associated operation.
|
|
118
179
|
*/
|
|
119
180
|
set(): void;
|
|
120
181
|
/**
|
|
121
|
-
*
|
|
182
|
+
* Sets the token's state to `false`.
|
|
183
|
+
* This can be used to reset the token.
|
|
122
184
|
*/
|
|
123
185
|
unset(): void;
|
|
124
186
|
/**
|
|
125
|
-
*
|
|
187
|
+
* Explicitly sets the state of the token.
|
|
188
|
+
* @param state `true` for set, `false` for unset.
|
|
126
189
|
*/
|
|
127
190
|
setState(state: boolean): void;
|
|
128
191
|
/**
|
|
129
|
-
*
|
|
192
|
+
* Puts the token into an errored state.
|
|
193
|
+
* All current and future subscribers will receive this error.
|
|
130
194
|
*/
|
|
131
195
|
error(error: Error): void;
|
|
132
196
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* Keep in mind that *active* awaits (promise) on this token will throw.
|
|
197
|
+
* Completes the token's lifecycle.
|
|
198
|
+
* No further state changes can occur. Active awaits may throw an error.
|
|
136
199
|
*/
|
|
137
200
|
complete(): void;
|
|
138
201
|
}
|