portadom 1.0.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.
Files changed (38) hide show
  1. package/README.md +202 -0
  2. package/dist/cjs/dom/dom.d.ts +19 -0
  3. package/dist/cjs/dom/dom.js +813 -0
  4. package/dist/cjs/dom/dom.js.map +1 -0
  5. package/dist/cjs/dom/domUtils.d.ts +42 -0
  6. package/dist/cjs/dom/domUtils.js +126 -0
  7. package/dist/cjs/dom/domUtils.js.map +1 -0
  8. package/dist/cjs/dom/types.d.ts +371 -0
  9. package/dist/cjs/dom/types.js +216 -0
  10. package/dist/cjs/dom/types.js.map +1 -0
  11. package/dist/cjs/index.d.ts +6 -0
  12. package/dist/cjs/index.js +22 -0
  13. package/dist/cjs/index.js.map +1 -0
  14. package/dist/cjs/page/page.d.ts +12 -0
  15. package/dist/cjs/page/page.js +105 -0
  16. package/dist/cjs/page/page.js.map +1 -0
  17. package/dist/cjs/page/pageUtils.d.ts +16 -0
  18. package/dist/cjs/page/pageUtils.js +116 -0
  19. package/dist/cjs/page/pageUtils.js.map +1 -0
  20. package/dist/cjs/page/types.d.ts +61 -0
  21. package/dist/cjs/page/types.js +3 -0
  22. package/dist/cjs/page/types.js.map +1 -0
  23. package/dist/cjs/utils/async.d.ts +19 -0
  24. package/dist/cjs/utils/async.js +74 -0
  25. package/dist/cjs/utils/async.js.map +1 -0
  26. package/dist/cjs/utils/error.d.ts +1 -0
  27. package/dist/cjs/utils/error.js +10 -0
  28. package/dist/cjs/utils/error.js.map +1 -0
  29. package/dist/cjs/utils/format.d.ts +9 -0
  30. package/dist/cjs/utils/format.js +19 -0
  31. package/dist/cjs/utils/format.js.map +1 -0
  32. package/dist/cjs/utils/types.d.ts +6 -0
  33. package/dist/cjs/utils/types.js +9 -0
  34. package/dist/cjs/utils/types.js.map +1 -0
  35. package/dist/cjs/utils/url.d.ts +9 -0
  36. package/dist/cjs/utils/url.js +32 -0
  37. package/dist/cjs/utils/url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;IACD,OAAO;QACL,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC,CAAA,CAAC;AA7BW,QAAA,UAAU,cA6BrB","sourcesContent":["import type { MaybePromise } from '../utils/types';\n\nexport const serialAsyncMap = async <T, R>(\n inputArr: T[],\n fn: (item: T, index: number) => MaybePromise<R>\n) => {\n const results = await inputArr.reduce(async (aggResultPromise, input, index) => {\n const agg = await aggResultPromise;\n const result = await fn(input, index);\n agg.push(result);\n return agg;\n }, Promise.resolve([] as R[]));\n\n return results;\n};\n\nexport const serialAsyncFilter = async <T>(\n inputArr: T[],\n fn: (item: T, index: number) => MaybePromise<any>\n) => {\n const results = await inputArr.reduce(async (aggResultPromise, input, index) => {\n const agg = await aggResultPromise;\n const result = await fn(input, index);\n if (result) agg.push(input);\n return agg;\n }, Promise.resolve([] as T[]));\n\n return results;\n};\n\nexport const serialAsyncFind = async <T>(\n inputArr: T[],\n fn: (item: T, index: number) => MaybePromise<any>\n) => {\n let index = 0;\n for (const input of inputArr) {\n const result = await fn(input, index);\n if (result) return input;\n index++;\n }\n};\n\nexport interface RetryAsyncOptions {\n /** Number of retries after the function call fails */\n maxRetries?: number;\n /** Delay between retries in milliseconds */\n delay?: number;\n /** Callback called with error if the function call errors */\n onError?: (error: unknown, retryIndex: number) => MaybePromise<void>;\n}\n\n/** @param {number} ms Number of ms to wait */\nexport const wait = (ms?: number) => new Promise((res) => setTimeout(res, ms));\n\n/** Call async function, and retry to call it `maxRetries` times if it fails. */\nexport const retryAsync = async <T>(\n fn: (retries: number) => Promise<T>,\n { maxRetries = 1, delay = 0, onError = () => {} }: RetryAsyncOptions = {}\n) => {\n if (typeof maxRetries !== 'number' || maxRetries < 0) {\n throw Error(\n `Invalid input for maxRetries in retryAsync(fn, maxRetries). maxRetries must be a non-negative number. Got ${maxRetries}`\n );\n }\n\n let result: T | null = null;\n const errors: unknown[] = [];\n let retries = 0;\n while (retries <= maxRetries) {\n try {\n result = await fn(retries);\n } catch (err) {\n errors.push(err);\n await onError(err, retries);\n await wait(delay);\n retries++;\n continue; // Retry if failed\n }\n break; // Exit loop and continue flow if success\n }\n return {\n result,\n errors,\n };\n};\n"]}
@@ -0,0 +1 @@
1
+ export declare const logAndRethrow: (e: any, log?: ((e: any) => any) | undefined) => never;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logAndRethrow = void 0;
4
+ const logAndRethrow = (e, log) => {
5
+ const logger = log !== null && log !== void 0 ? log : console.error;
6
+ logger(e);
7
+ throw e;
8
+ };
9
+ exports.logAndRethrow = logAndRethrow;
10
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/utils/error.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,CAAM,EAAE,GAAqB,EAAE,EAAE;IAC7D,MAAM,MAAM,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,OAAO,CAAC,KAAK,CAAC;IACpC,MAAM,CAAC,CAAC,CAAC,CAAC;IACV,MAAM,CAAC,CAAC;AACV,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB","sourcesContent":["export const logAndRethrow = (e: any, log?: (e: any) => any) => {\n const logger = log ?? console.error;\n logger(e);\n throw e;\n};\n"]}
@@ -0,0 +1,9 @@
1
+ export declare const strOrNull: (s: string | null, allowEmpty?: boolean) => string | null;
2
+ export interface StrAsNumOptions {
3
+ allowEmpty?: boolean;
4
+ removeWhitespace?: boolean;
5
+ mode: 'int' | 'float';
6
+ separator?: string;
7
+ decimal?: string;
8
+ }
9
+ export declare const strAsNumber: (s: string | null, options?: StrAsNumOptions) => number | null;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.strAsNumber = exports.strOrNull = void 0;
4
+ const strOrNull = (s, allowEmpty) => s ? s : typeof s === 'string' && allowEmpty ? s : null; // prettier-ignore
5
+ exports.strOrNull = strOrNull;
6
+ const strAsNumber = (s, options) => {
7
+ var _a, _b, _c;
8
+ const { removeWhitespace, allowEmpty, separator, decimal, mode = 'float' } = options || {};
9
+ let content = removeWhitespace ? (_a = s === null || s === void 0 ? void 0 : s.replace(/\s+/g, '')) !== null && _a !== void 0 ? _a : null : s;
10
+ content = (0, exports.strOrNull)(content, allowEmpty);
11
+ if (content === null)
12
+ return null;
13
+ content = separator ? (_b = content === null || content === void 0 ? void 0 : content.replace(new RegExp(separator, 'g'), '')) !== null && _b !== void 0 ? _b : null : content;
14
+ content = decimal ? (_c = content === null || content === void 0 ? void 0 : content.replace(new RegExp(decimal, 'g'), '.')) !== null && _c !== void 0 ? _c : null : content;
15
+ const num = mode === 'int' ? Number.parseInt(content) : Number.parseFloat(content);
16
+ return Number.isNaN(num) ? null : num;
17
+ };
18
+ exports.strAsNumber = strAsNumber;
19
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,CAAgB,EAAE,UAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,kBAAkB;AAAlI,QAAA,SAAS,aAAsG;AAUrH,MAAM,WAAW,GAAG,CAAC,CAAgB,EAAE,OAAyB,EAAiB,EAAE;;IACxF,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,OAAO,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC3F,IAAI,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,mCAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,OAAO,GAAG,IAAA,iBAAS,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,mCAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IACzF,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,mCAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IACtF,MAAM,GAAG,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AACxC,CAAC,CAAC;AAVW,QAAA,WAAW,eAUtB","sourcesContent":["export const strOrNull = (s: string | null, allowEmpty?: boolean) => s ? s : typeof s === 'string' && allowEmpty ? s : null; // prettier-ignore\n\nexport interface StrAsNumOptions {\n allowEmpty?: boolean;\n removeWhitespace?: boolean;\n mode: 'int' | 'float';\n separator?: string;\n decimal?: string;\n}\n\nexport const strAsNumber = (s: string | null, options?: StrAsNumOptions): number | null => {\n const { removeWhitespace, allowEmpty, separator, decimal, mode = 'float' } = options || {};\n let content = removeWhitespace ? s?.replace(/\\s+/g, '') ?? null : s;\n content = strOrNull(content, allowEmpty);\n if (content === null) return null;\n\n content = separator ? content?.replace(new RegExp(separator, 'g'), '') ?? null : content;\n content = decimal ? content?.replace(new RegExp(decimal, 'g'), '.') ?? null : content;\n const num = mode === 'int' ? Number.parseInt(content) : Number.parseFloat(content);\n return Number.isNaN(num) ? null : num;\n};\n"]}
@@ -0,0 +1,6 @@
1
+ export type MaybePromise<T> = T | Promise<T>;
2
+ export type MaybeArray<T> = T | T[];
3
+ export type ArrVal<T extends any[] | readonly any[]> = T[number];
4
+ export declare const enumFromArray: <T extends readonly any[]>(arr: T) => { [Key in ArrVal<T>]: Key; };
5
+ export type PickPartial<T extends object, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys>>;
6
+ export type PickRequired<T extends object, Keys extends keyof T> = Omit<T, Keys> & Required<Pick<T, Keys>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enumFromArray = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const enumFromArray = (arr) => {
6
+ return (0, lodash_1.fromPairs)(arr.map((k) => [k, k]));
7
+ };
8
+ exports.enumFromArray = enumFromArray;
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAO5B,MAAM,aAAa,GAAG,CAA2B,GAAM,EAAE,EAAE;IAChE,OAAO,IAAA,kBAAS,EAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAgC,CAAC;AAC1E,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB","sourcesContent":["import { fromPairs } from 'lodash';\n\nexport type MaybePromise<T> = T | Promise<T>;\nexport type MaybeArray<T> = T | T[];\n\nexport type ArrVal<T extends any[] | readonly any[]> = T[number];\n\nexport const enumFromArray = <T extends readonly any[]>(arr: T) => {\n return fromPairs(arr.map((k) => [k, k])) as { [Key in ArrVal<T>]: Key };\n};\n\nexport type PickPartial<T extends object, Keys extends keyof T> = Omit<T, Keys> &\n Partial<Pick<T, Keys>>;\n\nexport type PickRequired<T extends object, Keys extends keyof T> = Omit<T, Keys> &\n Required<Pick<T, Keys>>;\n"]}
@@ -0,0 +1,9 @@
1
+ /** Validate correctness of a URL */
2
+ export declare const validateUrl: (url: string) => void;
3
+ /** Transform relative URL paths to absolute URLs */
4
+ export declare const resolveUrlPath: (urlBase: string, urlPath: string) => string;
5
+ export interface FormatUrlOptions {
6
+ allowRelative?: boolean;
7
+ baseUrl?: string | null;
8
+ }
9
+ export declare const formatUrl: <T>(maybeUrl: string | T, { allowRelative, baseUrl }?: FormatUrlOptions) => string | T;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatUrl = exports.resolveUrlPath = exports.validateUrl = void 0;
4
+ /** Validate correctness of a URL */
5
+ const validateUrl = (url) => {
6
+ try {
7
+ new URL(url);
8
+ }
9
+ catch (err) {
10
+ err.message += `\nURL: "${url}"`;
11
+ throw err;
12
+ }
13
+ };
14
+ exports.validateUrl = validateUrl;
15
+ /** Transform relative URL paths to absolute URLs */
16
+ const resolveUrlPath = (urlBase, urlPath) => {
17
+ const url = new URL(urlBase);
18
+ url.pathname = urlPath;
19
+ return url.href;
20
+ };
21
+ exports.resolveUrlPath = resolveUrlPath;
22
+ const formatUrl = (maybeUrl, { allowRelative, baseUrl } = {}) => {
23
+ if (typeof maybeUrl !== 'string')
24
+ return maybeUrl;
25
+ if (!maybeUrl.startsWith('/') || allowRelative)
26
+ return maybeUrl;
27
+ if (!baseUrl)
28
+ throw Error('Cannot convert URL from relative to absolute path - baseUrl is missing'); // prettier-ignore
29
+ return (0, exports.resolveUrlPath)(baseUrl, maybeUrl);
30
+ };
31
+ exports.formatUrl = formatUrl;
32
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/utils/url.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AAC7B,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;IACzC,IAAI;QACF,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;KACd;IAAC,OAAO,GAAG,EAAE;QACX,GAAa,CAAC,OAAO,IAAI,WAAW,GAAG,GAAG,CAAC;QAC5C,MAAM,GAAG,CAAC;KACX;AACH,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB;AAEF,oDAAoD;AAC7C,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;IACjE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC;IACvB,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB;AAOK,MAAM,SAAS,GAAG,CACvB,QAAoB,EACpB,EAAE,aAAa,EAAE,OAAO,KAAuB,EAAE,EACjD,EAAE;IACF,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAClD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,aAAa;QAAE,OAAO,QAAQ,CAAC;IAEhE,IAAI,CAAC,OAAO;QAAE,MAAM,KAAK,CAAC,wEAAwE,CAAC,CAAC,CAAC,kBAAkB;IACvH,OAAO,IAAA,sBAAc,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC,CAAC;AATW,QAAA,SAAS,aASpB","sourcesContent":["/** Validate correctness of a URL */\nexport const validateUrl = (url: string) => {\n try {\n new URL(url);\n } catch (err) {\n (err as Error).message += `\\nURL: \"${url}\"`;\n throw err;\n }\n};\n\n/** Transform relative URL paths to absolute URLs */\nexport const resolveUrlPath = (urlBase: string, urlPath: string) => {\n const url = new URL(urlBase);\n url.pathname = urlPath;\n return url.href;\n};\n\nexport interface FormatUrlOptions {\n allowRelative?: boolean;\n baseUrl?: string | null;\n}\n\nexport const formatUrl = <T>(\n maybeUrl: string | T,\n { allowRelative, baseUrl }: FormatUrlOptions = {}\n) => {\n if (typeof maybeUrl !== 'string') return maybeUrl;\n if (!maybeUrl.startsWith('/') || allowRelative) return maybeUrl;\n\n if (!baseUrl) throw Error('Cannot convert URL from relative to absolute path - baseUrl is missing'); // prettier-ignore\n return resolveUrlPath(baseUrl, maybeUrl);\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "portadom",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "Single DOM manipulation interface across Browser API, JSDOM, Cheerio, Playwright",
6
+ "author": "Juro Oravec <juraj.oravec.josefson@gmail.com>",
7
+ "homepage": "https://github.com/jurooravec/portadom#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jurooravec/portadom.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/jurooravec/portadom/issues"
14
+ },
15
+ "license": "MIT",
16
+ "keywords": [
17
+ "dom",
18
+ "manipulation",
19
+ "browser",
20
+ "jsdom",
21
+ "cheerio",
22
+ "playwright",
23
+ "crawler",
24
+ "scraper"
25
+ ],
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "exports": {
30
+ ".": "./dist/cjs/index.js"
31
+ },
32
+ "module": "dist/esm/index.js",
33
+ "types": "dist/cjs/index.d.js",
34
+ "bin": "dist/cjs/cli/index.js",
35
+ "engines": {
36
+ "node": ">=16.0.0"
37
+ },
38
+ "scripts": {
39
+ "start": "npm run start:dev",
40
+ "start:prod": "node dist/cjs/index.js",
41
+ "start:dev": "ts-node ./src/index.ts",
42
+ "build": "npm run build:cjs",
43
+ "build:all": "npm run build:cjs && npm run build:esm",
44
+ "build:cjs": "tsc -p tsconfig.cjs.json",
45
+ "build:esm": "tsc -p tsconfig.esm.json",
46
+ "lint": "eslint ./src --ext .ts",
47
+ "lint:fix": "eslint ./src --ext .ts --fix",
48
+ "gen:docs": "typedoc src/index.ts --plugin typedoc-plugin-markdown --tsconfig tsconfig.base.json --out ./docs/typedoc"
49
+ },
50
+ "devDependencies": {
51
+ "@types/lodash": "^4.14.194",
52
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
53
+ "@typescript-eslint/parser": "^4.33.0",
54
+ "cheerio": "^1.0.0-rc.12",
55
+ "eslint": "^7.32.0",
56
+ "eslint-config-prettier": "^6.15.0",
57
+ "eslint-plugin-prettier": "^3.4.1",
58
+ "playwright": "^1.37.1",
59
+ "prettier": "^2.5.1",
60
+ "ts-node": "^10.9.1",
61
+ "typedoc": "^0.25.0",
62
+ "typedoc-plugin-markdown": "^3.16.0",
63
+ "typescript": "^5.0.4"
64
+ },
65
+ "dependencies": {
66
+ "lodash": "^4.17.21"
67
+ }
68
+ }