@adhd/decompile-cli 0.1.7

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 (83) hide show
  1. package/README.md +175 -0
  2. package/bin/decompile.d.ts +2 -0
  3. package/bin/decompile.js +89 -0
  4. package/bin/decompile.js.map +1 -0
  5. package/package.json +35 -0
  6. package/src/index.d.ts +1 -0
  7. package/src/index.js +2 -0
  8. package/src/index.js.map +1 -0
  9. package/src/lib/extractors/index.d.ts +10 -0
  10. package/src/lib/extractors/index.js +228 -0
  11. package/src/lib/extractors/index.js.map +1 -0
  12. package/src/lib/extractors/local-file.d.ts +5 -0
  13. package/src/lib/extractors/local-file.js +22 -0
  14. package/src/lib/extractors/local-file.js.map +1 -0
  15. package/src/lib/extractors/map.d.ts +6 -0
  16. package/src/lib/extractors/map.js +74 -0
  17. package/src/lib/extractors/map.js.map +1 -0
  18. package/src/lib/extractors/raw-html.d.ts +7 -0
  19. package/src/lib/extractors/raw-html.js +93 -0
  20. package/src/lib/extractors/raw-html.js.map +1 -0
  21. package/src/lib/extractors/site.d.ts +34 -0
  22. package/src/lib/extractors/site.js +96 -0
  23. package/src/lib/extractors/site.js.map +1 -0
  24. package/src/lib/index.d.ts +8 -0
  25. package/src/lib/index.js +6 -0
  26. package/src/lib/index.js.map +1 -0
  27. package/src/lib/pipeline/index.d.ts +1 -0
  28. package/src/lib/pipeline/index.js +2 -0
  29. package/src/lib/pipeline/index.js.map +1 -0
  30. package/src/lib/pipeline/pipes/resolver/actions.d.ts +14 -0
  31. package/src/lib/pipeline/pipes/resolver/actions.js +50 -0
  32. package/src/lib/pipeline/pipes/resolver/actions.js.map +1 -0
  33. package/src/lib/pipeline/pipes/resolver/index.d.ts +1 -0
  34. package/src/lib/pipeline/pipes/resolver/index.js +2 -0
  35. package/src/lib/pipeline/pipes/resolver/index.js.map +1 -0
  36. package/src/lib/pipeline/stack.d.ts +23 -0
  37. package/src/lib/pipeline/stack.js +45 -0
  38. package/src/lib/pipeline/stack.js.map +1 -0
  39. package/src/lib/store/build.d.ts +2 -0
  40. package/src/lib/store/build.js +50 -0
  41. package/src/lib/store/build.js.map +1 -0
  42. package/src/lib/store/index.d.ts +92 -0
  43. package/src/lib/store/index.js +127 -0
  44. package/src/lib/store/index.js.map +1 -0
  45. package/src/lib/store/package.d.ts +60 -0
  46. package/src/lib/store/package.js +114 -0
  47. package/src/lib/store/package.js.map +1 -0
  48. package/src/lib/store/templates.d.ts +84 -0
  49. package/src/lib/store/templates.js +78 -0
  50. package/src/lib/store/templates.js.map +1 -0
  51. package/src/lib/store/utils.d.ts +3 -0
  52. package/src/lib/store/utils.js +8 -0
  53. package/src/lib/store/utils.js.map +1 -0
  54. package/src/lib/validators/index.d.ts +2 -0
  55. package/src/lib/validators/index.js +7 -0
  56. package/src/lib/validators/index.js.map +1 -0
  57. package/src/lib/validators/local/index.d.ts +31 -0
  58. package/src/lib/validators/local/index.js +93 -0
  59. package/src/lib/validators/local/index.js.map +1 -0
  60. package/src/lib/validators/local/isBase64.d.ts +2 -0
  61. package/src/lib/validators/local/isBase64.js +11 -0
  62. package/src/lib/validators/local/isBase64.js.map +1 -0
  63. package/src/lib/validators/local/isCSS.d.ts +2 -0
  64. package/src/lib/validators/local/isCSS.js +15 -0
  65. package/src/lib/validators/local/isCSS.js.map +1 -0
  66. package/src/lib/validators/local/isHTML.d.ts +2 -0
  67. package/src/lib/validators/local/isHTML.js +13 -0
  68. package/src/lib/validators/local/isHTML.js.map +1 -0
  69. package/src/lib/validators/local/isJS.d.ts +2 -0
  70. package/src/lib/validators/local/isJS.js +28 -0
  71. package/src/lib/validators/local/isJS.js.map +1 -0
  72. package/src/lib/validators/local/isJson.d.ts +2 -0
  73. package/src/lib/validators/local/isJson.js +40 -0
  74. package/src/lib/validators/local/isJson.js.map +1 -0
  75. package/src/lib/validators/local/isSourceMap.d.ts +11 -0
  76. package/src/lib/validators/local/isSourceMap.js +57 -0
  77. package/src/lib/validators/local/isSourceMap.js.map +1 -0
  78. package/src/lib/validators/url/errors.d.ts +9 -0
  79. package/src/lib/validators/url/errors.js +36 -0
  80. package/src/lib/validators/url/errors.js.map +1 -0
  81. package/src/lib/validators/url/index.d.ts +32 -0
  82. package/src/lib/validators/url/index.js +231 -0
  83. package/src/lib/validators/url/index.js.map +1 -0
@@ -0,0 +1,31 @@
1
+ export declare const assertIsFile: (f: string) => void;
2
+ export declare const assertIsDir: (f: string) => void;
3
+ export declare const ensurePathSync: (f: string) => boolean;
4
+ export declare const ensurePaths: (files: string[]) => Promise<void[]>;
5
+ export declare const getFileInfo: (f: string) => Promise<{
6
+ name: string;
7
+ ext: string;
8
+ state: number;
9
+ exists: boolean;
10
+ empty: boolean;
11
+ type: any;
12
+ root: string;
13
+ dir: string;
14
+ base: string;
15
+ }>;
16
+ declare const _default: {
17
+ ensure: (f: string) => boolean;
18
+ ensurePaths: (files: string[]) => Promise<void[]>;
19
+ getFileInfo: (f: string) => Promise<{
20
+ name: string;
21
+ ext: string;
22
+ state: number;
23
+ exists: boolean;
24
+ empty: boolean;
25
+ type: any;
26
+ root: string;
27
+ dir: string;
28
+ base: string;
29
+ }>;
30
+ };
31
+ export default _default;
@@ -0,0 +1,93 @@
1
+ import fs from 'fs-extra';
2
+ import detect from 'language-detect';
3
+ import path from 'path';
4
+ import isCSS from './isCSS.js';
5
+ import isHTML from './isHTML.js';
6
+ import isJS from './isJS.js';
7
+ import isJSON from './isJson.js';
8
+ import isSourceMap from './isSourceMap.js';
9
+ // see https://github.com/tj/node-language-classifier
10
+ const removeQuery = (s) => {
11
+ return s.split(/[?#]/)[0];
12
+ };
13
+ const checkIsDirSync = (f) => {
14
+ return fs.statSync(f).isDirectory();
15
+ };
16
+ const checkIsFileSync = (f) => {
17
+ const stat = fs.statSync(f);
18
+ if (!stat.isFile()) {
19
+ return stat.size > 0 ? 1 : 0;
20
+ }
21
+ else {
22
+ return -1;
23
+ }
24
+ // return stat.isFile() ? stat.size > 0 & 1 : -1;
25
+ };
26
+ export const assertIsFile = (f) => {
27
+ if (checkIsFileSync(f) === -1)
28
+ throw new Error('Should be a file: ' + f);
29
+ };
30
+ export const assertIsDir = (f) => {
31
+ if (!checkIsDirSync(f))
32
+ throw new Error('Should be a directory: ' + f);
33
+ };
34
+ export const ensurePathSync = (f) => {
35
+ return fs.pathExistsSync(f);
36
+ };
37
+ export const ensurePaths = async (files) => {
38
+ return await Promise.all(files.map(fs.pathExists));
39
+ };
40
+ export const getFileInfo = async (f) => {
41
+ const cleanName = removeQuery(f);
42
+ try {
43
+ const baseParsed = path.parse(cleanName);
44
+ const parsed = {
45
+ ...baseParsed,
46
+ name: cleanName,
47
+ ext: removeQuery(baseParsed.ext),
48
+ state: checkIsFileSync(f),
49
+ exists: checkIsFileSync(f) !== 0,
50
+ empty: checkIsFileSync(f) === 0,
51
+ type: detect.filename(cleanName) || 'unknown',
52
+ };
53
+ /* short circuit attempts to parse empty fole */
54
+ if (parsed.empty)
55
+ return parsed;
56
+ if (parsed.type === 'JSON') {
57
+ const data = (await fs.readFile(f)).toString();
58
+ parsed.type = isSourceMap(data) ? 'SourceMap' : 'JSON';
59
+ return parsed;
60
+ }
61
+ else if (parsed.ext === '.map') {
62
+ parsed.type = 'SourceMap';
63
+ }
64
+ if (parsed.exists && /unknown|JSON/i.test(parsed.type)) {
65
+ const content = (await fs.readFile(f)).toString();
66
+ if (isSourceMap(content)) {
67
+ parsed.type = 'SourceMap';
68
+ }
69
+ else if (isJSON(content)) {
70
+ parsed.type = 'JSON';
71
+ }
72
+ else if (isCSS(content)) {
73
+ parsed.type = 'CSS';
74
+ }
75
+ else if (isJS(content)) {
76
+ parsed.type = 'JavaScript';
77
+ }
78
+ else if (isHTML(content)) {
79
+ parsed.type = 'HTML';
80
+ }
81
+ else {
82
+ parsed.type = 'unknown:fallback';
83
+ }
84
+ }
85
+ return parsed;
86
+ }
87
+ catch (e) {
88
+ console.error('couldnt resolve type for', f);
89
+ throw e;
90
+ }
91
+ };
92
+ export default { ensure: ensurePathSync, ensurePaths, getFileInfo };
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,qDAAqD;AAErD,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,EAAE;IAChC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,EAAE;IACnC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,CAAS,EAAE,EAAE;IACpC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,iDAAiD;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE;IACxC,IAAI,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAAE,MAAM,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O,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import fs from 'fs-extra';\nimport detect from 'language-detect';\nimport path from 'path';\nimport isCSS from './isCSS.js';\nimport isHTML from './isHTML.js';\nimport isJS from './isJS.js';\nimport isJSON from './isJson.js';\nimport isSourceMap from './isSourceMap.js';\n// see https://github.com/tj/node-language-classifier\n\nconst removeQuery = (s: string) => {\n return s.split(/[?#]/)[0];\n};\n\nconst checkIsDirSync = (f: string) => {\n return fs.statSync(f).isDirectory();\n};\n\nconst checkIsFileSync = (f: string) => {\n const stat = fs.statSync(f);\n if (!stat.isFile()) {\n return stat.size > 0 ? 1 : 0;\n } else {\n return -1;\n }\n // return stat.isFile() ? stat.size > 0 & 1 : -1;\n};\n\nexport const assertIsFile = (f: string) => {\n if (checkIsFileSync(f) === -1) throw new Error('Should be a file: ' + f);\n};\n\nexport const assertIsDir = (f: string) => {\n if (!checkIsDirSync(f)) throw new Error('Should be a directory: ' + f);\n};\n\nexport const ensurePathSync = (f: string) => {\n return fs.pathExistsSync(f);\n};\n\nexport const ensurePaths = async (files: string[]) => {\n return await Promise.all(files.map(fs.pathExists));\n};\n\nexport const getFileInfo = async (f: string) => {\n const cleanName = removeQuery(f);\n try {\n const baseParsed = path.parse(cleanName);\n const parsed = {\n ...baseParsed,\n name: cleanName,\n ext: removeQuery(baseParsed.ext),\n state: checkIsFileSync(f),\n exists: checkIsFileSync(f) !== 0,\n empty: checkIsFileSync(f) === 0,\n type: detect.filename(cleanName) || 'unknown',\n };\n\n /* short circuit attempts to parse empty fole */\n if (parsed.empty) return parsed;\n if (parsed.type === 'JSON') {\n const data = (await fs.readFile(f)).toString();\n parsed.type = isSourceMap(data) ? 'SourceMap' : 'JSON';\n return parsed;\n } else if (parsed.ext === '.map') {\n parsed.type = 'SourceMap';\n }\n\n if (parsed.exists && /unknown|JSON/i.test(parsed.type)) {\n const content = (await fs.readFile(f)).toString();\n if (isSourceMap(content)) {\n parsed.type = 'SourceMap';\n } else if (isJSON(content)) {\n parsed.type = 'JSON';\n } else if (isCSS(content)) {\n parsed.type = 'CSS';\n } else if (isJS(content)) {\n parsed.type = 'JavaScript';\n } else if (isHTML(content)) {\n parsed.type = 'HTML';\n } else {\n parsed.type = 'unknown:fallback';\n }\n }\n return parsed;\n } catch (e) {\n console.error('couldnt resolve type for', f);\n throw e;\n }\n};\n\nexport default { ensure: ensurePathSync, ensurePaths, getFileInfo };\n"]}
@@ -0,0 +1,2 @@
1
+ declare const isBase64: (v: string) => boolean;
2
+ export default isBase64;
@@ -0,0 +1,11 @@
1
+ const isBase64 = (v) => {
2
+ console.log('Parser(Base64)');
3
+ try {
4
+ return !!Buffer.from(v, 'base64');
5
+ }
6
+ catch (e) {
7
+ return false;
8
+ }
9
+ };
10
+ export default isBase64;
11
+ //# sourceMappingURL=isBase64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isBase64.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/isBase64.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9B,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["const isBase64 = (v: string) => {\n console.log('Parser(Base64)');\n try {\n return !!Buffer.from(v, 'base64');\n } catch (e) {\n return false;\n }\n};\n\nexport default isBase64;\n"]}
@@ -0,0 +1,2 @@
1
+ declare const astCSS: (s: string) => boolean;
2
+ export default astCSS;
@@ -0,0 +1,15 @@
1
+ import postcss from 'postcss';
2
+ // const RE = /([#.@*]?[\w-.:> ,*]+)[\s]?{[\r\n\s]*([A-Za-z\- \s\r\n\t]+[:][\s]*[0-9\w .,\/()\-!%]+;?[\r\n]*(?:[A-Za-z\- \r\n\t]+[:][\s]*['":0-9\w .,\/()\-!%]+;?[\r\n]*)*)?}/g;
3
+ // const removeCSS = (s) => s.replace(/((?:^\s*)([\w#.@*,:\-.:>,*\s]+)\s*{(?:[\s]*)((?:[A-Za-z\- \s]+[:]\s*['"0-9\w .,\/()\-!%]+;?)*)*\s*}(?:\s*))/mg, '');
4
+ // const isCSS = (s) => removeCSS(s).replace(/[[\s;]+/gmi, '')==='';
5
+ const astCSS = (s) => {
6
+ console.log('Parser(CSS)');
7
+ try {
8
+ return !!postcss.parse(s);
9
+ }
10
+ catch (e) {
11
+ return false;
12
+ }
13
+ };
14
+ export default astCSS;
15
+ //# sourceMappingURL=isCSS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCSS.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/isCSS.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,gLAAgL;AAEhL,2JAA2J;AAE3J,oEAAoE;AAEpE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE;IAC3B,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import postcss from 'postcss';\n\n// const RE = /([#.@*]?[\\w-.:> ,*]+)[\\s]?{[\\r\\n\\s]*([A-Za-z\\- \\s\\r\\n\\t]+[:][\\s]*[0-9\\w .,\\/()\\-!%]+;?[\\r\\n]*(?:[A-Za-z\\- \\r\\n\\t]+[:][\\s]*['\":0-9\\w .,\\/()\\-!%]+;?[\\r\\n]*)*)?}/g;\n\n// const removeCSS = (s) => s.replace(/((?:^\\s*)([\\w#.@*,:\\-.:>,*\\s]+)\\s*{(?:[\\s]*)((?:[A-Za-z\\- \\s]+[:]\\s*['\"0-9\\w .,\\/()\\-!%]+;?)*)*\\s*}(?:\\s*))/mg, '');\n\n// const isCSS = (s) => removeCSS(s).replace(/[[\\s;]+/gmi, '')==='';\n\nconst astCSS = (s: string) => {\n console.log('Parser(CSS)');\n try {\n return !!postcss.parse(s);\n } catch (e) {\n return false;\n }\n};\n\nexport default astCSS;\n"]}
@@ -0,0 +1,2 @@
1
+ declare const astParser: (s: string) => boolean;
2
+ export default astParser;
@@ -0,0 +1,13 @@
1
+ import { parser } from 'posthtml-parser';
2
+ // const RE = /<(br|basefont|hr|input|source|frame|param|area|meta|!--|col|link|option|base|img|wbr|!DOCTYPE).*?>|<(a|abbr|acronym|address|applet|article|aside|audio|b|bdi|bdo|big|blockquote|body|button|canvas|caption|center|cite|code|colgroup|command|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frameset|head|header|hgroup|h1|h2|h3|h4|h5|h6|html|i|iframe|ins|kbd|keygen|label|legend|li|map|mark|menu|meter|nav|noframes|noscript|object|ol|optgroup|output|p|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video).*?<\/\2>/;
3
+ // const isHTML = (s) => s.replace(RE, '') == '';
4
+ // const hasHTML = (s) => {
5
+ // return RE.test(s);
6
+ // };
7
+ const astParser = (s) => {
8
+ console.log('Parser(HTML AST)');
9
+ const parsed = parser(s);
10
+ return parsed.filter((node) => typeof node != 'string').length > 0;
11
+ };
12
+ export default astParser;
13
+ //# sourceMappingURL=isHTML.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isHTML.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/isHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,isBAAisB;AAEjsB,iDAAiD;AAEjD,2BAA2B;AAC3B,uBAAuB;AACvB,KAAK;AAEL,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE;IAC9B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,IAAI,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACrE,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { parser } from 'posthtml-parser';\n\n// const RE = /<(br|basefont|hr|input|source|frame|param|area|meta|!--|col|link|option|base|img|wbr|!DOCTYPE).*?>|<(a|abbr|acronym|address|applet|article|aside|audio|b|bdi|bdo|big|blockquote|body|button|canvas|caption|center|cite|code|colgroup|command|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frameset|head|header|hgroup|h1|h2|h3|h4|h5|h6|html|i|iframe|ins|kbd|keygen|label|legend|li|map|mark|menu|meter|nav|noframes|noscript|object|ol|optgroup|output|p|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video).*?<\\/\\2>/;\n\n// const isHTML = (s) => s.replace(RE, '') == '';\n\n// const hasHTML = (s) => {\n// return RE.test(s);\n// };\n\nconst astParser = (s: string) => {\n console.log('Parser(HTML AST)');\n const parsed = parser(s);\n return parsed.filter((node) => typeof node != 'string').length > 0;\n};\n\nexport default astParser;\n"]}
@@ -0,0 +1,2 @@
1
+ declare const astJS: (s: string) => boolean;
2
+ export default astJS;
@@ -0,0 +1,28 @@
1
+ import * as acorn from 'acorn';
2
+ import jsx from 'acorn-jsx';
3
+ const Parser = acorn.Parser.extend(jsx());
4
+ const acornOptions = {
5
+ sourceType: 'module',
6
+ ecmaVersion: 'latest',
7
+ allowReserved: true,
8
+ allowReturnOutsideFunction: true,
9
+ allowImportExportEverywhere: true,
10
+ allowHashBang: true,
11
+ locations: true,
12
+ ranges: true,
13
+ preserveParens: true,
14
+ // 'plugins.jsx': true,'
15
+ };
16
+ // const funcRE = /(public|private|protected)\s+(static\s+)?(abstract(?!override)\s+|final\s+)?(\D\w+)\s+(\D\w+)\s*\((\s*\D\w+\s*\D\w+\s*,?)*\)\s*/gm;
17
+ const astJS = (s) => {
18
+ console.log('Parser(JS AST)');
19
+ try {
20
+ Parser.parse(s, acornOptions);
21
+ return true;
22
+ }
23
+ catch (e) {
24
+ return false;
25
+ }
26
+ };
27
+ export default astJS;
28
+ //# sourceMappingURL=isJS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isJS.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/isJS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,GAAG,MAAM,WAAW,CAAC;AAE5B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC1C,MAAM,YAAY,GAAkB;IAClC,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,QAAQ;IACrB,aAAa,EAAE,IAAI;IACnB,0BAA0B,EAAE,IAAI;IAChC,2BAA2B,EAAE,IAAI;IACjC,aAAa,EAAE,IAAI;IACnB,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;IACZ,cAAc,EAAE,IAAI;IACpB,wBAAwB;CACzB,CAAC;AAEF,sJAAsJ;AAEtJ,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE;IAC1B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import * as acorn from 'acorn';\nimport jsx from 'acorn-jsx';\n\nconst Parser = acorn.Parser.extend(jsx());\nconst acornOptions: acorn.Options = {\n sourceType: 'module',\n ecmaVersion: 'latest',\n allowReserved: true,\n allowReturnOutsideFunction: true,\n allowImportExportEverywhere: true,\n allowHashBang: true,\n locations: true,\n ranges: true,\n preserveParens: true,\n // 'plugins.jsx': true,'\n};\n\n// const funcRE = /(public|private|protected)\\s+(static\\s+)?(abstract(?!override)\\s+|final\\s+)?(\\D\\w+)\\s+(\\D\\w+)\\s*\\((\\s*\\D\\w+\\s*\\D\\w+\\s*,?)*\\)\\s*/gm;\n\nconst astJS = (s: string) => {\n console.log('Parser(JS AST)');\n try {\n Parser.parse(s, acornOptions);\n return true;\n } catch (e) {\n return false;\n }\n};\n\nexport default astJS;\n"]}
@@ -0,0 +1,2 @@
1
+ declare const _default: (s: string) => unknown;
2
+ export default _default;
@@ -0,0 +1,40 @@
1
+ // import parse from 'json-to-ast';
2
+ const rxOne = /^[\],:{}\s]*$/;
3
+ const rxTwo = /\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})/g;
4
+ const rxThree = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g;
5
+ const rxFour = /(?:^|:|,)(?:\s*\[)+/g;
6
+ const isJson = (s) => {
7
+ console.log('Parser(JSON:regex)');
8
+ return rxOne.test(s.replace(rxTwo, '@').replace(rxThree, ']').replace(rxFour, ''));
9
+ };
10
+ /* https://github.com/vtrushin/json-to-ast */
11
+ // eslint-disable-next-line no-unused-vars
12
+ // const astJSON = (s) => {
13
+ // console.log('Parser(JSON:ast)');
14
+ // try {
15
+ // parse(s);
16
+ // return true;
17
+ // } catch (e) {
18
+ // return false;
19
+ // }
20
+ // };
21
+ const Bench = {
22
+ count: 0,
23
+ total: 0,
24
+ };
25
+ // TODO: create a utility or package where this belings.
26
+ const benchWrapper = (func) => {
27
+ return (s) => {
28
+ const start = new Date();
29
+ const res = func(s);
30
+ const end = new Date().getTime() - start.getTime();
31
+ Bench.total += end;
32
+ Bench.count += 1;
33
+ console.log(res);
34
+ console.info('Execution time: %dms', end);
35
+ console.info('Avg time: %dms', Bench.total / Bench.count);
36
+ return res;
37
+ };
38
+ };
39
+ export default benchWrapper(isJson);
40
+ //# sourceMappingURL=isJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isJson.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/isJson.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC,MAAM,KAAK,GAAG,eAAe,CAAC;AAC9B,MAAM,KAAK,GAAG,oCAAoC,CAAC;AACnD,MAAM,OAAO,GACX,iEAAiE,CAAC;AACpE,MAAM,MAAM,GAAG,sBAAsB,CAAC;AAEtC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE;IAC3B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CACf,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAChE,CAAC;AACJ,CAAC,CAAC;AAEF,6CAA6C;AAC7C,0CAA0C;AAC1C,2BAA2B;AAC3B,qCAAqC;AACrC,UAAU;AACV,gBAAgB;AAChB,mBAAmB;AACnB,kBAAkB;AAClB,oBAAoB;AACpB,MAAM;AACN,KAAK;AAEL,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;CACT,CAAC;AACF,wDAAwD;AACxD,MAAM,YAAY,GAAG,CAAC,IAA4B,EAAE,EAAE;IACpD,OAAO,CAAC,CAAS,EAAE,EAAE;QACnB,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;QACnD,KAAK,CAAC,KAAK,IAAI,GAAG,CAAC;QACnB,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1D,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC,MAAM,CAAC,CAAC","sourcesContent":["// import parse from 'json-to-ast';\n\nconst rxOne = /^[\\],:{}\\s]*$/;\nconst rxTwo = /\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})/g;\nconst rxThree =\n /\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g;\nconst rxFour = /(?:^|:|,)(?:\\s*\\[)+/g;\n\nconst isJson = (s: string) => {\n console.log('Parser(JSON:regex)');\n return rxOne.test(\n s.replace(rxTwo, '@').replace(rxThree, ']').replace(rxFour, '')\n );\n};\n\n/* https://github.com/vtrushin/json-to-ast */\n// eslint-disable-next-line no-unused-vars\n// const astJSON = (s) => {\n// console.log('Parser(JSON:ast)');\n// try {\n// parse(s);\n// return true;\n// } catch (e) {\n// return false;\n// }\n// };\n\nconst Bench = {\n count: 0,\n total: 0,\n};\n// TODO: create a utility or package where this belings.\nconst benchWrapper = (func: (s: string) => unknown) => {\n return (s: string) => {\n const start = new Date();\n const res = func(s);\n const end = new Date().getTime() - start.getTime();\n Bench.total += end;\n Bench.count += 1;\n console.log(res);\n console.info('Execution time: %dms', end);\n console.info('Avg time: %dms', Bench.total / Bench.count);\n return res;\n };\n};\n\nexport default benchWrapper(isJson);\n"]}
@@ -0,0 +1,11 @@
1
+ type MapType = {
2
+ version: number;
3
+ sources: unknown[];
4
+ names: unknown[];
5
+ mappings: string;
6
+ file?: string;
7
+ sourceRoot?: unknown[];
8
+ sourcesContent?: unknown[];
9
+ };
10
+ declare const isSourceMap: (_data: string | MapType) => boolean;
11
+ export default isSourceMap;
@@ -0,0 +1,57 @@
1
+ /* REFERENCE: https://www.npmjs.com/package/source-map#consuming-a-source-map
2
+ * - The properties below make up a standard source map
3
+ *
4
+ * version: Which version of the source map spec this map is following.
5
+ *
6
+ * sources: An array of URLs to the original source files.
7
+ *
8
+ * names: An array of identifiers which can be referenced by individual mappings.
9
+ *
10
+ * sourceRoot: Optional. The URL root from which all sources are relative.
11
+ *
12
+ * sourcesContent: Optional. An array of contents of the original source files.
13
+ *
14
+ * mappings: A string of base64 VLQs which contain the actual mappings.
15
+ *
16
+ * file: Optional. The generated filename this source map is associated with.
17
+ */
18
+ import { Transform } from '@adhd/data-base-transforms';
19
+ import isBase64 from './isBase64.js';
20
+ const MapShape = {
21
+ version: ({ version }) => Transform.isInt(version),
22
+ sources: ({ sources }) => Transform.isArray(sources),
23
+ names: ({ names }) => Transform.isArray(names),
24
+ mappings: ({ mappings }) => isBase64(mappings),
25
+ file: ({ file }) => !file || Transform.isString(file),
26
+ sourceRoot: ({ sourceRoot }) => !sourceRoot || Transform.isArray(sourceRoot),
27
+ sourcesContent: ({ sourcesContent }) => !sourcesContent || Transform.isArray(sourcesContent),
28
+ };
29
+ const tryReadJson = (s) => {
30
+ if (!Transform.isString(s)) {
31
+ return false;
32
+ }
33
+ try {
34
+ return JSON.parse(s);
35
+ }
36
+ catch (e) {
37
+ return false;
38
+ }
39
+ };
40
+ const isSourceMap = (_data) => {
41
+ console.log('Parser(SourceMap:validate)');
42
+ let data = _data;
43
+ if (typeof data === 'string') {
44
+ if (data.length < 30)
45
+ return false;
46
+ data = tryReadJson(data);
47
+ if (!data)
48
+ return false;
49
+ }
50
+ return Object.keys(MapShape).reduce((r, k) => {
51
+ const check = MapShape[k](data);
52
+ r = r === true && check;
53
+ return r;
54
+ }, true);
55
+ };
56
+ export default isSourceMap;
57
+ //# sourceMappingURL=isSourceMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSourceMap.js","sourceRoot":"","sources":["../../../../../src/lib/validators/local/isSourceMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,QAAQ,MAAM,eAAe,CAAC;AAYrC,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,CAAC,EAAE,OAAO,EAAW,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC;IAC3D,OAAO,EAAE,CAAC,EAAE,OAAO,EAAW,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7D,KAAK,EAAE,CAAC,EAAE,KAAK,EAAW,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;IACvD,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACvD,IAAI,EAAE,CAAC,EAAE,IAAI,EAAW,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9D,UAAU,EAAE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AAC","sourcesContent":["/* REFERENCE: https://www.npmjs.com/package/source-map#consuming-a-source-map\n * - The properties below make up a standard source map\n *\n * version: Which version of the source map spec this map is following.\n *\n * sources: An array of URLs to the original source files.\n *\n * names: An array of identifiers which can be referenced by individual mappings.\n *\n * sourceRoot: Optional. The URL root from which all sources are relative.\n *\n * sourcesContent: Optional. An array of contents of the original source files.\n *\n * mappings: A string of base64 VLQs which contain the actual mappings.\n *\n * file: Optional. The generated filename this source map is associated with.\n */\n\nimport { Transform } from '@adhd/data-base-transforms';\nimport isBase64 from './isBase64.js';\n\ntype MapType = {\n version: number;\n sources: unknown[];\n names: unknown[];\n mappings: string;\n file?: string;\n sourceRoot?: unknown[];\n sourcesContent?: unknown[];\n};\n\nconst MapShape = {\n version: ({ version }: MapType) => Transform.isInt(version),\n sources: ({ sources }: MapType) => Transform.isArray(sources),\n names: ({ names }: MapType) => Transform.isArray(names),\n mappings: ({ mappings }: MapType) => isBase64(mappings),\n file: ({ file }: MapType) => !file || Transform.isString(file),\n sourceRoot: ({ sourceRoot }: MapType) =>\n !sourceRoot || Transform.isArray(sourceRoot),\n sourcesContent: ({ sourcesContent }: MapType) =>\n !sourcesContent || Transform.isArray(sourcesContent),\n};\n\nconst tryReadJson = (s: unknown) => {\n if (!Transform.isString(s)) {\n return false;\n }\n try {\n return JSON.parse(s as string);\n } catch (e) {\n return false;\n }\n};\n\nconst isSourceMap = (_data: string | MapType) => {\n console.log('Parser(SourceMap:validate)');\n let data = _data;\n if (typeof data === 'string') {\n if (data.length < 30) return false;\n data = tryReadJson(data) as MapType;\n if (!data) return false;\n }\n return Object.keys(MapShape).reduce((r, k) => {\n const check = MapShape[k as keyof typeof MapShape](data as MapType);\n r = r === true && check;\n return r;\n }, true);\n};\n\nexport default isSourceMap;\n"]}
@@ -0,0 +1,9 @@
1
+ declare const renamedMap: {
2
+ stripFragment: string;
3
+ normalizeHttp: string;
4
+ normalizeHttps: string;
5
+ };
6
+ export declare const InvalidUrlError: (url: string | URL) => Error;
7
+ export declare const FunctionRenamedError: (kind: keyof typeof renamedMap) => Error;
8
+ export declare const BadOptionsError: () => Error;
9
+ export {};
@@ -0,0 +1,36 @@
1
+ const renamedMap = {
2
+ stripFragment: 'stripHash',
3
+ normalizeHttp: 'forceHttps',
4
+ normalizeHttps: 'forceHttp',
5
+ };
6
+ export const InvalidUrlError = (url) => new Error(`Invalid URL: ${url}`);
7
+ export const FunctionRenamedError = (kind) => new Error(`options.${kind} is renamed to options.${renamedMap[kind]}`);
8
+ export const BadOptionsError = () => new Error('The `forceHttp` and `forceHttps` options cannot be used together');
9
+ // export class InvalidUrlError extends Error() {
10
+ // constructor ( url, extra ) {
11
+ // super(`Invalid URL: ${url}`)
12
+ // this.message = `Invalid URL: ${url}`
13
+ // Error.captureStackTrace( this, this.constructor )
14
+ // this.name = 'InvalidUrlError'
15
+ // if ( extra ) this.extra = extra
16
+ // }
17
+ // }
18
+ // export class FunctionRenamedError extends Error() {
19
+ // constructor ( kind, extra ) {
20
+ // super(`options.${kind} is renamed to options.${renamedMap[kind]}`)
21
+ // this.message = `options.${kind} is renamed to options.${renamedMap[kind]}`
22
+ // Error.captureStackTrace( this, this.constructor )
23
+ // this.name = 'FunctionRenamedError'
24
+ // if ( extra ) this.extra = extra
25
+ // }
26
+ // }
27
+ // export class BadOptionsError extends Error() {
28
+ // constructor(extra){
29
+ // super('The `forceHttp` and `forceHttps` options cannot be used together')
30
+ // this.message = 'The `forceHttp` and `forceHttps` options cannot be used together'
31
+ // Error.captureStackTrace( this, this.constructor )
32
+ // this.name = 'BadOptionsError'
33
+ // if ( extra ) this.extra = extra
34
+ // }
35
+ // }
36
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/lib/validators/url/errors.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG;IACjB,aAAa,EAAE,WAAW;IAC1B,aAAa,EAAE,YAAY;IAC3B,cAAc,EAAE,WAAW;CAC5B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAiB,EAAE,EAAE,CACnD,IAAI,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAA6B,EAAE,EAAE,CACpE,IAAI,KAAK,CAAC,WAAW,IAAI,0BAA0B,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAClC,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;AAEhF,iDAAiD;AACjD,iCAAiC;AACjC,mCAAmC;AACnC,2CAA2C;AAC3C,wDAAwD;AACxD,oCAAoC;AACpC,sCAAsC;AACtC,MAAM;AACN,IAAI;AACJ,sDAAsD;AACtD,kCAAkC;AAClC,yEAAyE;AACzE,iFAAiF;AACjF,wDAAwD;AACxD,yCAAyC;AACzC,sCAAsC;AACtC,MAAM;AACN,IAAI;AAEJ,iDAAiD;AACjD,wBAAwB;AACxB,gFAAgF;AAChF,wFAAwF;AACxF,wDAAwD;AACxD,oCAAoC;AACpC,sCAAsC;AACtC,MAAM;AACN,IAAI","sourcesContent":["const renamedMap = {\n stripFragment: 'stripHash',\n normalizeHttp: 'forceHttps',\n normalizeHttps: 'forceHttp',\n};\n\nexport const InvalidUrlError = (url: string | URL) =>\n new Error(`Invalid URL: ${url}`);\nexport const FunctionRenamedError = (kind: keyof typeof renamedMap) =>\n new Error(`options.${kind} is renamed to options.${renamedMap[kind]}`);\nexport const BadOptionsError = () =>\n new Error('The `forceHttp` and `forceHttps` options cannot be used together');\n\n// export class InvalidUrlError extends Error() {\n// constructor ( url, extra ) {\n// super(`Invalid URL: ${url}`)\n// this.message = `Invalid URL: ${url}`\n// Error.captureStackTrace( this, this.constructor )\n// this.name = 'InvalidUrlError'\n// if ( extra ) this.extra = extra\n// }\n// }\n// export class FunctionRenamedError extends Error() {\n// constructor ( kind, extra ) {\n// super(`options.${kind} is renamed to options.${renamedMap[kind]}`)\n// this.message = `options.${kind} is renamed to options.${renamedMap[kind]}`\n// Error.captureStackTrace( this, this.constructor )\n// this.name = 'FunctionRenamedError'\n// if ( extra ) this.extra = extra\n// }\n// }\n\n// export class BadOptionsError extends Error() {\n// constructor(extra){\n// super('The `forceHttp` and `forceHttps` options cannot be used together')\n// this.message = 'The `forceHttp` and `forceHttps` options cannot be used together'\n// Error.captureStackTrace( this, this.constructor )\n// this.name = 'BadOptionsError'\n// if ( extra ) this.extra = extra\n// }\n// }\n"]}
@@ -0,0 +1,32 @@
1
+ import { URL as NodeURL } from 'url';
2
+ type NormalizeOptions = {
3
+ defaultProtocol?: string;
4
+ normalizeProtocol?: boolean;
5
+ forceHttp?: boolean;
6
+ forceHttps?: boolean;
7
+ stripAuthentication?: boolean;
8
+ stripHash?: boolean;
9
+ stripProtocol?: boolean;
10
+ stripWWW?: boolean;
11
+ returns?: string;
12
+ removeQuery?: boolean;
13
+ removeQueryParameters?: (string | RegExp)[];
14
+ removeTrailingSlash?: boolean;
15
+ removeDirectoryIndex?: boolean | (string | RegExp)[];
16
+ sortQueryParameters?: boolean;
17
+ };
18
+ export declare const isValidUrl: (s: string) => boolean;
19
+ export declare const getPatch: (s: string) => string | NodeURL | null;
20
+ export declare const defaultOptions: NormalizeOptions;
21
+ export declare const normalizeUrl: (urlString: string, options?: NormalizeOptions) => string | NodeURL;
22
+ export declare const ErrorTypes: {
23
+ FunctionRenamedError: (kind: "stripFragment" | "normalizeHttp" | "normalizeHttps") => Error;
24
+ BadOptionsError: () => Error;
25
+ InvalidUrlError: (url: string | URL) => Error;
26
+ };
27
+ declare const _default: {
28
+ ensure: (urlString: string, options?: NormalizeOptions) => string | NodeURL;
29
+ isValidUrl: (s: string) => boolean;
30
+ getPatch: (s: string) => string | NodeURL | null;
31
+ };
32
+ export default _default;