@tstdl/base 0.84.27 → 0.84.29
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/browser/element-controller.d.ts +14 -3
- package/browser/element-controller.js +52 -4
- package/container/token.d.ts +1 -0
- package/container/token.js +3 -0
- package/json-path/json-path.d.ts +5 -2
- package/json-path/json-path.js +11 -8
- package/package.json +2 -2
- package/theme/adapters/tailwind-adapter.d.ts +1 -0
- package/theme/adapters/tailwind-adapter.js +2 -1
- package/utils/crc32.d.ts +1 -0
- package/utils/crc32.js +47 -0
- package/utils/cryptography.js +1 -1
|
@@ -16,7 +16,8 @@ export type ElementControllerOptions = {
|
|
|
16
16
|
typeDelay?: Delay;
|
|
17
17
|
};
|
|
18
18
|
type LocatorOptions<K extends keyof Locator, I extends keyof Parameters<Locator[K]>> = NonUndefinable<Parameters<Locator[K]>[I]>;
|
|
19
|
-
|
|
19
|
+
type Methods = 'isVisible' | 'isHidden' | 'isEnabled' | 'isDisabled' | 'isChecked' | 'isEditable' | 'fill' | 'type' | 'press' | 'check' | 'uncheck' | 'setChecked' | 'selectOption' | 'setInputFiles' | 'click' | 'hover' | 'focus' | 'tap' | 'selectText' | 'inputValue';
|
|
20
|
+
export declare class ElementController<T extends Locator | ElementHandle = Locator | ElementHandle> implements Pick<Locator, Methods> {
|
|
20
21
|
readonly locatorOrHandle: T;
|
|
21
22
|
readonly options: ElementControllerOptions;
|
|
22
23
|
constructor(locatorOrHandle: T, options?: ElementControllerOptions);
|
|
@@ -43,9 +44,19 @@ export declare class ElementController<T extends Locator | ElementHandle = Locat
|
|
|
43
44
|
isEditable(): Promise<boolean>;
|
|
44
45
|
fill(text: string, options?: Merge<LocatorOptions<'fill', 1>, ActionDelayOptions>): Promise<void>;
|
|
45
46
|
type(text: string, options?: Merge<TypedOmit<LocatorOptions<'type', 1>, 'delay'>, ActionDelayOptions & TypeDelayOptions>): Promise<void>;
|
|
46
|
-
|
|
47
|
+
press(key: string, options?: Merge<LocatorOptions<'press', 1>, ActionDelayOptions>): Promise<void>;
|
|
48
|
+
check(options?: Merge<LocatorOptions<'check', 1>, ActionDelayOptions>): Promise<void>;
|
|
49
|
+
uncheck(options?: Merge<LocatorOptions<'uncheck', 1>, ActionDelayOptions>): Promise<void>;
|
|
50
|
+
setChecked(checked: boolean, options?: Merge<LocatorOptions<'setChecked', 1>, ActionDelayOptions>): Promise<void>;
|
|
51
|
+
selectOption(option: string | string[], options?: Merge<LocatorOptions<'selectOption', 1>, ActionDelayOptions>): Promise<string[]>;
|
|
52
|
+
setInputFiles(files: LocatorOptions<'setInputFiles', 0>, options?: Merge<LocatorOptions<'setInputFiles', 1>, ActionDelayOptions>): Promise<void>;
|
|
47
53
|
click(options?: Merge<TypedOmit<LocatorOptions<'click', 0>, 'delay'>, ActionDelayOptions & ClickDelayOptions>): Promise<void>;
|
|
48
|
-
|
|
54
|
+
dblclick(options?: Merge<TypedOmit<LocatorOptions<'click', 0>, 'delay'>, ActionDelayOptions & ClickDelayOptions>): Promise<void>;
|
|
55
|
+
hover(options?: Merge<LocatorOptions<'hover', 1>, ActionDelayOptions>): Promise<void>;
|
|
56
|
+
focus(options?: Merge<LocatorOptions<'focus', 1>, ActionDelayOptions>): Promise<void>;
|
|
57
|
+
tap(options?: Merge<LocatorOptions<'tap', 1>, ActionDelayOptions>): Promise<void>;
|
|
58
|
+
selectText(options?: Merge<LocatorOptions<'selectText', 1>, ActionDelayOptions>): Promise<void>;
|
|
59
|
+
inputValue(options?: LocatorOptions<'inputValue', 0>): Promise<string>;
|
|
49
60
|
private prepareAction;
|
|
50
61
|
}
|
|
51
62
|
export {};
|
|
@@ -89,9 +89,30 @@ class ElementController {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
async
|
|
92
|
+
async press(key, options) {
|
|
93
93
|
await this.prepareAction(options);
|
|
94
|
-
await this.locatorOrHandle.
|
|
94
|
+
await this.locatorOrHandle.press(key, options);
|
|
95
|
+
}
|
|
96
|
+
async check(options) {
|
|
97
|
+
await this.prepareAction(options);
|
|
98
|
+
await this.locatorOrHandle.check(options);
|
|
99
|
+
}
|
|
100
|
+
async uncheck(options) {
|
|
101
|
+
await this.prepareAction(options);
|
|
102
|
+
await this.locatorOrHandle.uncheck(options);
|
|
103
|
+
}
|
|
104
|
+
async setChecked(checked, options) {
|
|
105
|
+
await this.prepareAction(options);
|
|
106
|
+
await this.locatorOrHandle.setChecked(checked, options);
|
|
107
|
+
}
|
|
108
|
+
async selectOption(option, options) {
|
|
109
|
+
await this.prepareAction(options);
|
|
110
|
+
const selectedOptions = await this.locatorOrHandle.selectOption(option, options);
|
|
111
|
+
return selectedOptions;
|
|
112
|
+
}
|
|
113
|
+
async setInputFiles(files, options) {
|
|
114
|
+
await this.prepareAction(options);
|
|
115
|
+
await this.locatorOrHandle.setInputFiles(files, options);
|
|
95
116
|
}
|
|
96
117
|
async click(options) {
|
|
97
118
|
await this.prepareAction(options);
|
|
@@ -100,11 +121,38 @@ class ElementController {
|
|
|
100
121
|
delay: (0, import_value_or_provider.resolveValueOrProvider)(options?.clickDelay)
|
|
101
122
|
});
|
|
102
123
|
}
|
|
103
|
-
async
|
|
124
|
+
async dblclick(options) {
|
|
125
|
+
await this.prepareAction(options);
|
|
126
|
+
await this.locatorOrHandle.dblclick({
|
|
127
|
+
...options,
|
|
128
|
+
delay: (0, import_value_or_provider.resolveValueOrProvider)(options?.clickDelay)
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async hover(options) {
|
|
132
|
+
await this.prepareAction(options);
|
|
133
|
+
await this.locatorOrHandle.hover(options);
|
|
134
|
+
}
|
|
135
|
+
async focus(options) {
|
|
136
|
+
await this.prepareAction(options);
|
|
137
|
+
await this.locatorOrHandle.focus(options);
|
|
138
|
+
}
|
|
139
|
+
async tap(options) {
|
|
140
|
+
await this.prepareAction(options);
|
|
141
|
+
await this.locatorOrHandle.tap(options);
|
|
142
|
+
}
|
|
143
|
+
async selectText(options) {
|
|
144
|
+
await this.prepareAction(options);
|
|
145
|
+
await this.locatorOrHandle.selectText(options);
|
|
146
|
+
}
|
|
147
|
+
async inputValue(options) {
|
|
104
148
|
return this.locatorOrHandle.inputValue(options);
|
|
105
149
|
}
|
|
106
150
|
async prepareAction(options) {
|
|
107
|
-
|
|
151
|
+
const actionDelay = options?.actionDelay ?? this.options.actionDelay;
|
|
152
|
+
if ((0, import_type_guards.isDefined)(actionDelay)) {
|
|
153
|
+
await this.waitFor("visible", { timeout: (0, import_value_or_provider.resolveValueOrProvider)(options?.timeout) });
|
|
154
|
+
await delay(actionDelay);
|
|
155
|
+
}
|
|
108
156
|
}
|
|
109
157
|
}
|
|
110
158
|
async function delay(milliseconds) {
|
package/container/token.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class ReifyingInjectionToken<T = any, A = any> {
|
|
|
11
11
|
private readonly [argument];
|
|
12
12
|
readonly description: string;
|
|
13
13
|
constructor(description: string);
|
|
14
|
+
toString(): string;
|
|
14
15
|
}
|
|
15
16
|
export declare function injectionToken<T, A = any>(description: string): InjectionToken<T, A>;
|
|
16
17
|
export declare function getTokenName(token: InjectionToken | undefined): string;
|
package/container/token.js
CHANGED
|
@@ -29,6 +29,9 @@ class ReifyingInjectionToken {
|
|
|
29
29
|
constructor(description) {
|
|
30
30
|
this.description = description;
|
|
31
31
|
}
|
|
32
|
+
toString() {
|
|
33
|
+
return `InjectionToken["${this.description}"]`;
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
function injectionToken(description) {
|
|
34
37
|
return new ReifyingInjectionToken(description);
|
package/json-path/json-path.d.ts
CHANGED
|
@@ -31,8 +31,11 @@ export type JsonPathOptions = {
|
|
|
31
31
|
treatArrayAsObject?: boolean;
|
|
32
32
|
/** encode as ['foo'] instead of .foo */
|
|
33
33
|
forceBrackets?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Prepend $
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
dollar?: boolean;
|
|
36
39
|
};
|
|
37
40
|
export type JsonPathContext = {
|
|
38
41
|
/** if path contains symbols, they are required in order to be mapped, otherwise they are created from global symbol registry */
|
package/json-path/json-path.js
CHANGED
|
@@ -35,7 +35,7 @@ class JsonPath {
|
|
|
35
35
|
/** json path as encoded string */
|
|
36
36
|
get path() {
|
|
37
37
|
if ((0, import_type_guards.isUndefined)(this._path)) {
|
|
38
|
-
this._path = encodeJsonPath(this._nodes);
|
|
38
|
+
this._path = encodeJsonPath(this._nodes, this._options);
|
|
39
39
|
}
|
|
40
40
|
return this._path;
|
|
41
41
|
}
|
|
@@ -55,6 +55,9 @@ class JsonPath {
|
|
|
55
55
|
this._path = pathOrNodesOrOptions;
|
|
56
56
|
} else if ((0, import_type_guards.isArray)(pathOrNodesOrOptions)) {
|
|
57
57
|
this._nodes = pathOrNodesOrOptions;
|
|
58
|
+
} else if (pathOrNodesOrOptions instanceof JsonPath) {
|
|
59
|
+
this._nodes = pathOrNodesOrOptions._nodes;
|
|
60
|
+
this._path = pathOrNodesOrOptions._path;
|
|
58
61
|
} else if ((0, import_is_iterable.isIterable)(pathOrNodesOrOptions)) {
|
|
59
62
|
this._nodes = [...pathOrNodesOrOptions];
|
|
60
63
|
} else {
|
|
@@ -88,7 +91,7 @@ function isJsonPath(path) {
|
|
|
88
91
|
return parsePattern.test(path);
|
|
89
92
|
}
|
|
90
93
|
function encodeJsonPath(nodes, options = {}) {
|
|
91
|
-
const { treatArrayAsObject = false, forceBrackets = false,
|
|
94
|
+
const { treatArrayAsObject = false, forceBrackets = false, dollar = true } = options;
|
|
92
95
|
let path = "";
|
|
93
96
|
for (const node of nodes) {
|
|
94
97
|
const nodeIsSymbol = (0, import_type_guards.isSymbol)(node);
|
|
@@ -105,13 +108,13 @@ function encodeJsonPath(nodes, options = {}) {
|
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return path
|
|
111
|
+
if (dollar) {
|
|
112
|
+
return `$${path}`;
|
|
113
|
+
}
|
|
114
|
+
if (path.startsWith("[")) {
|
|
115
|
+
return path;
|
|
113
116
|
}
|
|
114
|
-
return
|
|
117
|
+
return path.slice(1);
|
|
115
118
|
}
|
|
116
119
|
function decodeJsonPath(path, context = {}) {
|
|
117
120
|
const matches = path.trim().matchAll(parsePattern);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.29",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"luxon": "^3.3",
|
|
24
24
|
"reflect-metadata": "^0.1",
|
|
25
25
|
"rxjs": "^7.8",
|
|
26
|
-
"type-fest": "^3.
|
|
26
|
+
"type-fest": "^3.12"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/chroma-js": "2.4",
|
|
@@ -11,6 +11,7 @@ export type TailwindPalette = {
|
|
|
11
11
|
700: string;
|
|
12
12
|
800: string;
|
|
13
13
|
900: string;
|
|
14
|
+
950: string;
|
|
14
15
|
};
|
|
15
16
|
export declare function generateTailwindColorsFromTheme(theme: Theme, tailwindNamePrefix?: string): Record<string, TailwindPalette>;
|
|
16
17
|
export declare function generateTailwindColorsFromThemeColors(colors: readonly string[], tailwindNamePrefix?: string): Record<string, TailwindPalette>;
|
|
@@ -48,7 +48,8 @@ function generateTailwindPalette(color) {
|
|
|
48
48
|
600: `rgb(var(--theme-${color}-600-rgb) / <alpha-value>)`,
|
|
49
49
|
700: `rgb(var(--theme-${color}-700-rgb) / <alpha-value>)`,
|
|
50
50
|
800: `rgb(var(--theme-${color}-800-rgb) / <alpha-value>)`,
|
|
51
|
-
900: `rgb(var(--theme-${color}-900-rgb) / <alpha-value>)
|
|
51
|
+
900: `rgb(var(--theme-${color}-900-rgb) / <alpha-value>)`,
|
|
52
|
+
950: `rgb(var(--theme-${color}-950-rgb) / <alpha-value>)`
|
|
52
53
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
53
54
|
};
|
|
54
55
|
}
|
package/utils/crc32.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function crc32b(bytes: Uint8Array): Uint8Array;
|
package/utils/crc32.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var crc32_exports = {};
|
|
20
|
+
__export(crc32_exports, {
|
|
21
|
+
crc32b: () => crc32b
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(crc32_exports);
|
|
24
|
+
let crcTable;
|
|
25
|
+
function crc32b(bytes) {
|
|
26
|
+
crcTable ??= generateCrc32Table();
|
|
27
|
+
let crc = 0 ^ -1;
|
|
28
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
29
|
+
crc = crc >>> 8 ^ crcTable[crc & 255 ^ bytes[i]];
|
|
30
|
+
}
|
|
31
|
+
crc = (crc ^ -1) >>> 0;
|
|
32
|
+
const buffer = new ArrayBuffer(4);
|
|
33
|
+
const dataView = new DataView(buffer);
|
|
34
|
+
dataView.setUint32(0, crc, false);
|
|
35
|
+
return new Uint8Array(buffer);
|
|
36
|
+
}
|
|
37
|
+
function generateCrc32Table() {
|
|
38
|
+
const table = new Uint32Array(256);
|
|
39
|
+
for (let i = 0; i < 256; i++) {
|
|
40
|
+
let c = i;
|
|
41
|
+
for (let k = 0; k < 8; k++) {
|
|
42
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
43
|
+
}
|
|
44
|
+
table[i] = c;
|
|
45
|
+
}
|
|
46
|
+
return table;
|
|
47
|
+
}
|
package/utils/cryptography.js
CHANGED
|
@@ -114,7 +114,7 @@ async function importEcdsaKey(curve, key, extractable = false) {
|
|
|
114
114
|
}
|
|
115
115
|
async function importPbkdf2Key(key, extractable = false) {
|
|
116
116
|
const binaryKey = (0, import_type_guards.isString)(key) ? (0, import_encoding.encodeUtf8)(key) : key;
|
|
117
|
-
return subtle.importKey("raw", binaryKey, { name: "PBKDF2" }, extractable, ["deriveKey", "deriveBits"]);
|
|
117
|
+
return globalThis.crypto.subtle.importKey("raw", binaryKey, { name: "PBKDF2" }, extractable, ["deriveKey", "deriveBits"]);
|
|
118
118
|
}
|
|
119
119
|
async function generateEcdsaKey(curve, extractable = false, usages = ["sign", "verify"]) {
|
|
120
120
|
return subtle.generateKey({ name: "ECDSA", namedCurve: curve }, extractable, usages);
|