webforai 1.6.0 → 1.6.1
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/dist/bin.js +87 -50
- package/dist/types/cli/bin.js.map +1 -1
- package/dist/types/cli/commands/webforai/index.js.map +1 -1
- package/dist/types/cli/commands/webforai/loadHtml.js.map +1 -1
- package/dist/types/cli/utils.d.ts +0 -27
- package/dist/types/cli/utils.js.map +1 -1
- package/package.json +3 -2
- package/dist/cjs/cli/bin.js +0 -33
- package/dist/cjs/cli/commands/webforai/index.js +0 -86
- package/dist/cjs/cli/commands/webforai/loadHtml.js +0 -93
- package/dist/cjs/cli/constants.js +0 -34
- package/dist/cjs/cli/helpers/assertContinue.js +0 -34
- package/dist/cjs/cli/helpers/inputOutputPath.js +0 -89
- package/dist/cjs/cli/helpers/inputSourcePath.js +0 -64
- package/dist/cjs/cli/helpers/selectExtractMode.js +0 -39
- package/dist/cjs/cli/helpers/selectLoader.js +0 -44
- package/dist/cjs/cli/utils.js +0 -89
- package/dist/cli/bin.js +0 -11
- package/dist/cli/commands/webforai/index.js +0 -53
- package/dist/cli/commands/webforai/loadHtml.js +0 -60
- package/dist/cli/constants.js +0 -9
- package/dist/cli/helpers/assertContinue.js +0 -11
- package/dist/cli/helpers/inputOutputPath.js +0 -56
- package/dist/cli/helpers/inputSourcePath.js +0 -31
- package/dist/cli/helpers/selectExtractMode.js +0 -16
- package/dist/cli/helpers/selectLoader.js +0 -21
- package/dist/cli/utils.js +0 -52
package/dist/bin.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli/bin.ts
|
|
4
|
-
import { intro as intro2 } from "@clack/prompts";
|
|
5
4
|
import { program } from "commander";
|
|
6
|
-
import pc3 from "picocolors";
|
|
7
5
|
|
|
8
6
|
// package.json
|
|
9
7
|
var package_default = {
|
|
10
8
|
name: "webforai",
|
|
11
|
-
version: "1.6.
|
|
9
|
+
version: "1.6.1",
|
|
12
10
|
description: "A library that provides a web interface for AI",
|
|
13
11
|
author: "inaridiy",
|
|
14
12
|
license: "MIT",
|
|
@@ -112,6 +110,7 @@ var package_default = {
|
|
|
112
110
|
},
|
|
113
111
|
dependencies: {
|
|
114
112
|
"@clack/prompts": "^0.7.0",
|
|
113
|
+
boxen: "^8.0.1",
|
|
115
114
|
commander: "^12.1.0",
|
|
116
115
|
"hast-util-from-html": "^2.0.3",
|
|
117
116
|
"hast-util-select": "^6.0.2",
|
|
@@ -131,12 +130,12 @@ var package_default = {
|
|
|
131
130
|
devDependencies: {
|
|
132
131
|
"@cloudflare/puppeteer": "^0.0.6",
|
|
133
132
|
"@tsconfig/recommended": "^1.0.3",
|
|
134
|
-
"fastest-levenshtein": "^1.0.16",
|
|
135
133
|
"@types/hast": "^3.0.2",
|
|
136
134
|
"@types/mdast": "^4.0.2",
|
|
137
135
|
"@types/node": "^20.14.10",
|
|
138
136
|
arg: "^5.0.2",
|
|
139
137
|
esbuild: "^0.19.11",
|
|
138
|
+
"fastest-levenshtein": "^1.0.16",
|
|
140
139
|
glob: "^10.3.10",
|
|
141
140
|
ncp: "^2.0.0",
|
|
142
141
|
np: "^9.2.0",
|
|
@@ -151,7 +150,7 @@ var package_default = {
|
|
|
151
150
|
// src/cli/commands/webforai/index.ts
|
|
152
151
|
import fs5 from "node:fs/promises";
|
|
153
152
|
import path2 from "node:path";
|
|
154
|
-
import { intro, outro, spinner } from "@clack/prompts";
|
|
153
|
+
import { intro, log as log2, outro, spinner } from "@clack/prompts";
|
|
155
154
|
import pc2 from "picocolors";
|
|
156
155
|
|
|
157
156
|
// src/html-to-mdast.ts
|
|
@@ -683,38 +682,71 @@ var isUrl = (maybeUrl) => {
|
|
|
683
682
|
}
|
|
684
683
|
};
|
|
685
684
|
function changeFileExtension(filePath, newExtension) {
|
|
686
|
-
const
|
|
687
|
-
const
|
|
688
|
-
|
|
685
|
+
const parsedPath = filePath.split("/");
|
|
686
|
+
const fileName = parsedPath[parsedPath.length - 1];
|
|
687
|
+
const formattedNewExtension = newExtension.startsWith(".") ? newExtension : `.${newExtension}`;
|
|
688
|
+
if (fileName.startsWith(".")) {
|
|
689
|
+
const parts = fileName.split(".");
|
|
690
|
+
if (parts.length === 2) {
|
|
691
|
+
return parsedPath.slice(0, -1).concat(`${fileName}${formattedNewExtension}`).join("/");
|
|
692
|
+
}
|
|
693
|
+
parts[parts.length - 1] = newExtension.replace(/^\./, "");
|
|
694
|
+
return parsedPath.slice(0, -1).concat(parts.join(".")).join("/");
|
|
695
|
+
}
|
|
696
|
+
const lastDotIndex = fileName.lastIndexOf(".");
|
|
697
|
+
const baseName = lastDotIndex !== -1 ? fileName.slice(0, lastDotIndex) : fileName;
|
|
698
|
+
const newFileName = `${baseName}${formattedNewExtension}`;
|
|
699
|
+
parsedPath[parsedPath.length - 1] = newFileName;
|
|
700
|
+
return parsedPath.join("/");
|
|
689
701
|
}
|
|
690
702
|
function urlToFilename(url) {
|
|
691
703
|
try {
|
|
692
704
|
const urlObj = new URL(url);
|
|
693
|
-
const
|
|
694
|
-
|
|
705
|
+
const domainParts = urlObj.hostname.split(".").reverse().reduce((acc, part, index) => {
|
|
706
|
+
if (index === 0) {
|
|
707
|
+
return acc;
|
|
708
|
+
}
|
|
709
|
+
if (acc.length >= 2) {
|
|
710
|
+
return acc;
|
|
711
|
+
}
|
|
712
|
+
if (part === "www") {
|
|
713
|
+
return acc;
|
|
714
|
+
}
|
|
715
|
+
return [part, ...acc];
|
|
716
|
+
}, []);
|
|
717
|
+
const domainString = domainParts.reverse().join("-");
|
|
695
718
|
const pathParts = urlObj.pathname.split("/").filter(Boolean);
|
|
696
|
-
const relevantPathParts = pathParts.slice(-2)
|
|
697
|
-
|
|
719
|
+
const relevantPathParts = pathParts.slice(-2);
|
|
720
|
+
const pathString = relevantPathParts.map((part) => decodeURIComponent(part)).join("-");
|
|
721
|
+
let filename = [domainString, pathString].filter(Boolean).join("-");
|
|
698
722
|
filename = filename.toLowerCase().replace(/[<>:"/\\|?*\x00-\x1F]/g, "").replace(/[\s.]+/g, "-").replace(/^-+|-+$/g, "");
|
|
699
723
|
return filename || "output";
|
|
700
724
|
} catch {
|
|
701
725
|
return "output";
|
|
702
726
|
}
|
|
703
727
|
}
|
|
704
|
-
var sourcePathToOutputPath = (sourcePath) =>
|
|
728
|
+
var sourcePathToOutputPath = (sourcePath) => {
|
|
729
|
+
return isUrl(sourcePath) ? `${urlToFilename(sourcePath)}.md` : changeFileExtension(sourcePath, "md");
|
|
730
|
+
};
|
|
705
731
|
function getNextAvailableFilePath(filePath) {
|
|
706
|
-
const
|
|
707
|
-
const
|
|
708
|
-
const
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
let
|
|
713
|
-
|
|
732
|
+
const parsedPath = path.parse(filePath);
|
|
733
|
+
const directory = parsedPath.dir;
|
|
734
|
+
const fullName = parsedPath.base;
|
|
735
|
+
const [firstPart, ...restParts] = fullName.split(".");
|
|
736
|
+
const restName = restParts.length > 0 ? `.${restParts.join(".")}` : "";
|
|
737
|
+
const baseName = firstPart.replace(/_\d+$/, "");
|
|
738
|
+
let counter = 1;
|
|
739
|
+
let nextFilePath = filePath;
|
|
740
|
+
while (fs.existsSync(nextFilePath)) {
|
|
741
|
+
const match = firstPart.match(/_(\d+)$/);
|
|
742
|
+
if (match) {
|
|
743
|
+
counter = Number.parseInt(match[1], 10) + 1;
|
|
744
|
+
}
|
|
745
|
+
const newName = `${baseName}_${counter}${restName}`;
|
|
746
|
+
nextFilePath = path.join(directory, newName);
|
|
714
747
|
counter++;
|
|
715
|
-
newPath = path.join(dir, `${baseName}_${counter}${ext}`);
|
|
716
748
|
}
|
|
717
|
-
return
|
|
749
|
+
return nextFilePath;
|
|
718
750
|
}
|
|
719
751
|
|
|
720
752
|
// src/cli/helpers/assertContinue.ts
|
|
@@ -840,9 +872,10 @@ var selectLoader = async () => {
|
|
|
840
872
|
|
|
841
873
|
// src/cli/commands/webforai/loadHtml.ts
|
|
842
874
|
import fs4 from "node:fs/promises";
|
|
875
|
+
import { log } from "@clack/prompts";
|
|
876
|
+
import boxen from "boxen";
|
|
843
877
|
import pc from "picocolors";
|
|
844
878
|
import { chromium as chromium2 } from "playwright-core";
|
|
845
|
-
import playwrightPackageJson from "playwright-core/package.json";
|
|
846
879
|
|
|
847
880
|
// src/loaders/fetch.ts
|
|
848
881
|
var USER_AGENT = "mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/125.0.0.0 safari/537.36";
|
|
@@ -900,47 +933,52 @@ var checkPlaywrightAvailable = async () => {
|
|
|
900
933
|
const isAvailable = await fs4.access(path3).catch(() => false);
|
|
901
934
|
return !!isAvailable;
|
|
902
935
|
};
|
|
936
|
+
var getPlaywrightVersion = async () => {
|
|
937
|
+
const path3 = await import.meta.resolve("playwright-core/package.json");
|
|
938
|
+
const pwPackageJson = await fs4.readFile(path3.replace("file://", ""), "utf-8").then((res) => JSON.parse(res.toString())).catch(() => null);
|
|
939
|
+
return pwPackageJson?.version;
|
|
940
|
+
};
|
|
903
941
|
var loadHtml3 = async (sourcePath, loader, options) => {
|
|
904
942
|
if (loader === "local") {
|
|
905
|
-
options.debug &&
|
|
943
|
+
options.debug && log.info(`Loading HTML from local file: ${sourcePath}`);
|
|
906
944
|
const content = await fs4.readFile(sourcePath, "utf-8");
|
|
907
|
-
options.debug &&
|
|
945
|
+
options.debug && log.info(`HTML loaded: ${content.slice(0, 100)}`);
|
|
908
946
|
return content;
|
|
909
947
|
}
|
|
910
948
|
if (loader === "fetch") {
|
|
911
|
-
options.debug &&
|
|
949
|
+
options.debug && log.info(`Loading HTML from URL: ${sourcePath}`);
|
|
912
950
|
const content = await loadHtml(sourcePath);
|
|
913
|
-
options.debug &&
|
|
951
|
+
options.debug && log.info(`HTML loaded: ${content.slice(0, 100)}`);
|
|
914
952
|
return content;
|
|
915
953
|
}
|
|
916
954
|
if (loader === "playwright") {
|
|
917
|
-
options.debug &&
|
|
955
|
+
options.debug && log.info(`Loading HTML from playwright: ${sourcePath}`);
|
|
918
956
|
const isPlaywrightAvailable = await checkPlaywrightAvailable();
|
|
919
|
-
options.debug &&
|
|
957
|
+
options.debug && log.info(`Playwright available: ${isPlaywrightAvailable}`);
|
|
958
|
+
const pwVersion = await getPlaywrightVersion();
|
|
920
959
|
if (!isPlaywrightAvailable) {
|
|
921
960
|
const message = [
|
|
922
|
-
"
|
|
923
|
-
"You can install it by running:",
|
|
961
|
+
pc.bold("Error: Playwright is not available"),
|
|
924
962
|
"",
|
|
925
|
-
|
|
963
|
+
"To use the Playwright loader, please install Playwright by running:",
|
|
926
964
|
"",
|
|
927
|
-
|
|
928
|
-
"WARNING: It looks like you are running 'npx playwright install' without first installing your project's dependencies. ",
|
|
929
|
-
`${pc.bold("Ignore this warning.")}`,
|
|
965
|
+
` npx playwright@${pwVersion} install chromium`,
|
|
930
966
|
"",
|
|
931
|
-
"
|
|
932
|
-
"
|
|
933
|
-
"You
|
|
967
|
+
"Hint 1: If you receive a warning like this:",
|
|
968
|
+
` "WARNING: It looks like you are running 'npx playwright install' without first installing your project's dependencies."`,
|
|
969
|
+
"You can safely ignore this warning.",
|
|
934
970
|
"",
|
|
935
|
-
|
|
971
|
+
"Hint 2: If you encounter the following message:",
|
|
972
|
+
` "Host system is missing dependencies to run browsers."`,
|
|
973
|
+
"You should install the necessary dependencies by executing:",
|
|
936
974
|
"",
|
|
937
|
-
|
|
975
|
+
` sudo npx playwright@${pwVersion} install-deps`
|
|
938
976
|
];
|
|
939
|
-
|
|
977
|
+
log.error(boxen(message.join("\n"), { padding: 1, borderStyle: "round" }));
|
|
940
978
|
throw new Error("Playwright is not available");
|
|
941
979
|
}
|
|
942
980
|
const content = await loadHtml2(sourcePath);
|
|
943
|
-
options.debug &&
|
|
981
|
+
options.debug && log.info(`HTML loaded: ${content.slice(0, 100)}`);
|
|
944
982
|
return content;
|
|
945
983
|
}
|
|
946
984
|
throw new Error(`Unsupported loader: ${loader}`);
|
|
@@ -952,13 +990,13 @@ var readabilityModeOptions = { linkAsText: false, tableAsText: false, hideImage:
|
|
|
952
990
|
var webforaiCommand = async (initialPath, options) => {
|
|
953
991
|
intro(pc2.bold(pc2.green(`webforai CLI version ${package_default.version}`)));
|
|
954
992
|
const sourcePath = initialPath ?? await inputSourcePath();
|
|
955
|
-
options.debug &&
|
|
993
|
+
options.debug && log2.info(`sourcePath: ${sourcePath}`);
|
|
956
994
|
const loader = isUrl(sourcePath) ? options.loader ?? await selectLoader() : "local";
|
|
957
|
-
options.debug &&
|
|
995
|
+
options.debug && log2.info(`loader: ${loader}`);
|
|
958
996
|
const outputPath = options.output ?? await inputOutputPath(sourcePath);
|
|
959
|
-
options.debug &&
|
|
997
|
+
options.debug && log2.info(`outputPath: ${outputPath}`);
|
|
960
998
|
const mode = options.mode ?? await selectExtractMode();
|
|
961
|
-
options.debug &&
|
|
999
|
+
options.debug && log2.info(`mode: ${mode}`);
|
|
962
1000
|
let html;
|
|
963
1001
|
const s = spinner();
|
|
964
1002
|
try {
|
|
@@ -970,12 +1008,12 @@ var webforaiCommand = async (initialPath, options) => {
|
|
|
970
1008
|
console.error(error);
|
|
971
1009
|
process.exit(1);
|
|
972
1010
|
}
|
|
973
|
-
options.debug &&
|
|
1011
|
+
options.debug && log2.info(`html: ${html}`);
|
|
974
1012
|
const markdown = htmlToMarkdown(html, {
|
|
975
1013
|
baseUrl: isUrl(sourcePath) ? sourcePath : void 0,
|
|
976
1014
|
...mode === "ai" ? aiModeOptions : readabilityModeOptions
|
|
977
1015
|
});
|
|
978
|
-
options.debug &&
|
|
1016
|
+
options.debug && log2.info(`markdown: ${markdown}`);
|
|
979
1017
|
const directory = path2.dirname(outputPath);
|
|
980
1018
|
const isDirectoryExists = await fs5.stat(directory).then((stat) => stat.isDirectory());
|
|
981
1019
|
if (!isDirectoryExists) {
|
|
@@ -988,5 +1026,4 @@ var webforaiCommand = async (initialPath, options) => {
|
|
|
988
1026
|
// src/cli/bin.ts
|
|
989
1027
|
program.name("webforai").description("CLI tool for ultra-precise HTML to Markdown conversion").version(package_default.version, "-v, --version", "output the current version");
|
|
990
1028
|
program.argument("[source]", "URL or path to process").option("-o, --output <output>", "Path to output file or directory").option("-m, --mode <mode>", `Processing mode (${MODES.join(", ")})`).option("-l, --loader <loader>", `Loader to use (${LOADERS.join(", ")})`).option("-d, --debug", "output extra debugging information").action(webforaiCommand);
|
|
991
|
-
intro2(pc3.inverse(`webforai CLI version ${package_default.version}`));
|
|
992
1029
|
program.parse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../src/cli/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../src/cli/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO;KACL,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,wDAAwD,CAAC;KACrE,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,4BAA4B,CAAC,CAAC;AAE9E,OAAO;KACL,QAAQ,CAAC,UAAU,EAAE,wBAAwB,CAAC;KAC9C,MAAM,CAAC,uBAAuB,EAAE,kCAAkC,CAAC;KACnE,MAAM,CAAC,mBAAmB,EAAE,oBAAoB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACpE,MAAM,CAAC,uBAAuB,EAAE,kBAAkB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACxE,MAAM,CAAC,aAAa,EAAE,oCAAoC,CAAC;KAC3D,MAAM,CAAC,eAAe,CAAC,CAAC;AAE1B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cli/commands/webforai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cli/commands/webforai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,aAAa,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC/E,MAAM,sBAAsB,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAE3F,MAAM,CA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AAC,CAAC;AACxE,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadHtml.js","sourceRoot":"","sources":["../../../../../src/cli/commands/webforai/loadHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"loadHtml.js","sourceRoot":"","sources":["../../../../../src/cli/commands/webforai/loadHtml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAE/E,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE;IAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IAC7D,OAAO,CAAC,CAAC,WAAW,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,KAAK,IAAI,EAAE;IACvC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,MAAM,EAAE;SAC5B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC;SAC9C,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAA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AC,yBAAyB,qBAAqB,EAAE,CAAC,CAAC;QAE5E,MAAM,SAAS,GAAG,MAAM,oBAAoB,EAAE,CAAC;QAE/C,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG;gBACf,EAAE,CAAC,IAAI,CAAC,oCAAoC,CAAC;gBAC7C,EAAE;gBACF,qEAAqE;gBACrE,EAAE;gBACF,oBAAoB,SAAS,mBAAmB;gBAChD,EAAE;gBACF,6CAA6C;gBAC7C,2HAA2H;gBAC3H,qCAAqC;gBACrC,EAAE;gBACF,iDAAiD;gBACjD,0DAA0D;gBAC1D,6DAA6D;gBAC7D,EAAE;gBACF,yBAAyB,SAAS,eAAe;aACjD,CAAC;YAEF,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAC3E,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACvD,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC,gBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
|
@@ -1,32 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines whether a string is a valid URL.
|
|
3
|
-
* @param maybeUrl - The string to check.
|
|
4
|
-
* @returns `true` if the string is a valid URL, otherwise `false`.
|
|
5
|
-
*/
|
|
6
1
|
export declare const isUrl: (maybeUrl: string) => boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Changes the file extension of a given file path.
|
|
9
|
-
* @param filePath - The original file path.
|
|
10
|
-
* @param newExtension - The new extension (with or without the leading dot).
|
|
11
|
-
* @returns The file path with the updated extension.
|
|
12
|
-
*/
|
|
13
2
|
export declare function changeFileExtension(filePath: string, newExtension: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Converts a URL into a safe filename.
|
|
16
|
-
* @param url - The URL to convert.
|
|
17
|
-
* @returns The generated filename, or "output" if conversion fails.
|
|
18
|
-
*/
|
|
19
3
|
export declare function urlToFilename(url: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Converts a source path to an output path. If the source is a URL, it generates a filename and changes the extension to .md.
|
|
22
|
-
* If the source is a file path, it simply changes the extension to .md.
|
|
23
|
-
* @param sourcePath - The source path or URL.
|
|
24
|
-
* @returns The corresponding output path.
|
|
25
|
-
*/
|
|
26
4
|
export declare const sourcePathToOutputPath: (sourcePath: string) => string;
|
|
27
|
-
/**
|
|
28
|
-
* Retrieves the next available file path by appending a counter if the file already exists.
|
|
29
|
-
* @param filePath - The original file path.
|
|
30
|
-
* @returns A file path that does not currently exist.
|
|
31
|
-
*/
|
|
32
5
|
export declare function getNextAvailableFilePath(filePath: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,EAAE;IACzC,IAAI,CAAC;QACJ,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OA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OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,YAAY,GAAG,QAAQ,CAAC;IAE5B,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,QAAQ,IAAI,OAAO,GAAG,QAAQ,EAAE,CAAC;QACpD,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7C,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webforai",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "A library that provides a web interface for AI",
|
|
5
5
|
"author": "inaridiy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@clack/prompts": "^0.7.0",
|
|
99
|
+
"boxen": "^8.0.1",
|
|
99
100
|
"commander": "^12.1.0",
|
|
100
101
|
"hast-util-from-html": "^2.0.3",
|
|
101
102
|
"hast-util-select": "^6.0.2",
|
|
@@ -115,12 +116,12 @@
|
|
|
115
116
|
"devDependencies": {
|
|
116
117
|
"@cloudflare/puppeteer": "^0.0.6",
|
|
117
118
|
"@tsconfig/recommended": "^1.0.3",
|
|
118
|
-
"fastest-levenshtein": "^1.0.16",
|
|
119
119
|
"@types/hast": "^3.0.2",
|
|
120
120
|
"@types/mdast": "^4.0.2",
|
|
121
121
|
"@types/node": "^20.14.10",
|
|
122
122
|
"arg": "^5.0.2",
|
|
123
123
|
"esbuild": "^0.19.11",
|
|
124
|
+
"fastest-levenshtein": "^1.0.16",
|
|
124
125
|
"glob": "^10.3.10",
|
|
125
126
|
"ncp": "^2.0.0",
|
|
126
127
|
"np": "^9.2.0",
|
package/dist/cjs/cli/bin.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_prompts = require("@clack/prompts");
|
|
25
|
-
var import_commander = require("commander");
|
|
26
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
27
|
-
var import_package = __toESM(require("../../package.json"), 1);
|
|
28
|
-
var import_webforai = require("./commands/webforai");
|
|
29
|
-
var import_constants = require("./constants");
|
|
30
|
-
import_commander.program.name("webforai").description("CLI tool for ultra-precise HTML to Markdown conversion").version(import_package.default.version, "-v, --version", "output the current version");
|
|
31
|
-
import_commander.program.argument("[source]", "URL or path to process").option("-o, --output <output>", "Path to output file or directory").option("-m, --mode <mode>", `Processing mode (${import_constants.MODES.join(", ")})`).option("-l, --loader <loader>", `Loader to use (${import_constants.LOADERS.join(", ")})`).option("-d, --debug", "output extra debugging information").action(import_webforai.webforaiCommand);
|
|
32
|
-
(0, import_prompts.intro)(import_picocolors.default.inverse(`webforai CLI version ${import_package.default.version}`));
|
|
33
|
-
import_commander.program.parse();
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var webforai_exports = {};
|
|
30
|
-
__export(webforai_exports, {
|
|
31
|
-
webforaiCommand: () => webforaiCommand
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(webforai_exports);
|
|
34
|
-
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
var import_prompts = require("@clack/prompts");
|
|
37
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
38
|
-
var import_package = __toESM(require("../../../../package.json"), 1);
|
|
39
|
-
var import_html_to_markdown = require("../../../html-to-markdown");
|
|
40
|
-
var import_inputOutputPath = require("../../helpers/inputOutputPath");
|
|
41
|
-
var import_inputSourcePath = require("../../helpers/inputSourcePath");
|
|
42
|
-
var import_selectExtractMode = require("../../helpers/selectExtractMode");
|
|
43
|
-
var import_selectLoader = require("../../helpers/selectLoader");
|
|
44
|
-
var import_utils = require("../../utils");
|
|
45
|
-
var import_loadHtml = require("./loadHtml");
|
|
46
|
-
const aiModeOptions = { linkAsText: true, tableAsText: true, hideImage: true };
|
|
47
|
-
const readabilityModeOptions = { linkAsText: false, tableAsText: false, hideImage: false };
|
|
48
|
-
const webforaiCommand = async (initialPath, options) => {
|
|
49
|
-
(0, import_prompts.intro)(import_picocolors.default.bold(import_picocolors.default.green(`webforai CLI version ${import_package.default.version}`)));
|
|
50
|
-
const sourcePath = initialPath ?? await (0, import_inputSourcePath.inputSourcePath)();
|
|
51
|
-
options.debug && console.debug(`sourcePath: ${sourcePath}`);
|
|
52
|
-
const loader = (0, import_utils.isUrl)(sourcePath) ? options.loader ?? await (0, import_selectLoader.selectLoader)() : "local";
|
|
53
|
-
options.debug && console.debug(`loader: ${loader}`);
|
|
54
|
-
const outputPath = options.output ?? await (0, import_inputOutputPath.inputOutputPath)(sourcePath);
|
|
55
|
-
options.debug && console.debug(`outputPath: ${outputPath}`);
|
|
56
|
-
const mode = options.mode ?? await (0, import_selectExtractMode.selectExtractMode)();
|
|
57
|
-
options.debug && console.debug(`mode: ${mode}`);
|
|
58
|
-
let html;
|
|
59
|
-
const s = (0, import_prompts.spinner)();
|
|
60
|
-
try {
|
|
61
|
-
s.start("Loading content...");
|
|
62
|
-
html = await (0, import_loadHtml.loadHtml)(sourcePath, loader, { debug: options.debug });
|
|
63
|
-
s.stop(import_picocolors.default.green("Content loaded!"));
|
|
64
|
-
} catch (error) {
|
|
65
|
-
s.stop(import_picocolors.default.red("Content loading failed!"));
|
|
66
|
-
console.error(error);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
options.debug && console.debug(`html: ${html}`);
|
|
70
|
-
const markdown = (0, import_html_to_markdown.htmlToMarkdown)(html, {
|
|
71
|
-
baseUrl: (0, import_utils.isUrl)(sourcePath) ? sourcePath : void 0,
|
|
72
|
-
...mode === "ai" ? aiModeOptions : readabilityModeOptions
|
|
73
|
-
});
|
|
74
|
-
options.debug && console.debug(`markdown: ${markdown}`);
|
|
75
|
-
const directory = import_node_path.default.dirname(outputPath);
|
|
76
|
-
const isDirectoryExists = await import_promises.default.stat(directory).then((stat) => stat.isDirectory());
|
|
77
|
-
if (!isDirectoryExists) {
|
|
78
|
-
await import_promises.default.mkdir(directory, { recursive: true });
|
|
79
|
-
}
|
|
80
|
-
await import_promises.default.writeFile(outputPath, markdown);
|
|
81
|
-
(0, import_prompts.outro)(import_picocolors.default.green(`${import_picocolors.default.bold("Done!")} Markdown saved to ${outputPath}`));
|
|
82
|
-
};
|
|
83
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
-
0 && (module.exports = {
|
|
85
|
-
webforaiCommand
|
|
86
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var loadHtml_exports = {};
|
|
30
|
-
__export(loadHtml_exports, {
|
|
31
|
-
loadHtml: () => loadHtml
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(loadHtml_exports);
|
|
34
|
-
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
35
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
36
|
-
var import_playwright_core = require("playwright-core");
|
|
37
|
-
var import_package = __toESM(require("playwright-core/package.json"), 1);
|
|
38
|
-
var import_fetch = require("../../../loaders/fetch");
|
|
39
|
-
var import_playwright = require("../../../loaders/playwright");
|
|
40
|
-
const checkPlaywrightAvailable = async () => {
|
|
41
|
-
const path = import_playwright_core.chromium.executablePath();
|
|
42
|
-
const isAvailable = await import_promises.default.access(path).catch(() => false);
|
|
43
|
-
return !!isAvailable;
|
|
44
|
-
};
|
|
45
|
-
const loadHtml = async (sourcePath, loader, options) => {
|
|
46
|
-
if (loader === "local") {
|
|
47
|
-
options.debug && console.debug(`Loading HTML from local file: ${sourcePath}`);
|
|
48
|
-
const content = await import_promises.default.readFile(sourcePath, "utf-8");
|
|
49
|
-
options.debug && console.debug(`HTML loaded: ${content.slice(0, 100)}`);
|
|
50
|
-
return content;
|
|
51
|
-
}
|
|
52
|
-
if (loader === "fetch") {
|
|
53
|
-
options.debug && console.debug(`Loading HTML from URL: ${sourcePath}`);
|
|
54
|
-
const content = await (0, import_fetch.loadHtml)(sourcePath);
|
|
55
|
-
options.debug && console.debug(`HTML loaded: ${content.slice(0, 100)}`);
|
|
56
|
-
return content;
|
|
57
|
-
}
|
|
58
|
-
if (loader === "playwright") {
|
|
59
|
-
options.debug && console.debug(`Loading HTML from playwright: ${sourcePath}`);
|
|
60
|
-
const isPlaywrightAvailable = await checkPlaywrightAvailable();
|
|
61
|
-
options.debug && console.debug(`Playwright available: ${isPlaywrightAvailable}`);
|
|
62
|
-
if (!isPlaywrightAvailable) {
|
|
63
|
-
const message = [
|
|
64
|
-
"To use playwright loader, you need to install playwright.",
|
|
65
|
-
"You can install it by running:",
|
|
66
|
-
"",
|
|
67
|
-
` ${import_picocolors.default.bold(`npx playwright@${import_package.default.version} install chromium`)} `,
|
|
68
|
-
"",
|
|
69
|
-
"Hint1: If you get warning like this:",
|
|
70
|
-
"WARNING: It looks like you are running 'npx playwright install' without first installing your project's dependencies. ",
|
|
71
|
-
`${import_picocolors.default.bold("Ignore this warning.")}`,
|
|
72
|
-
"",
|
|
73
|
-
"Hint2: If you get message like this:",
|
|
74
|
-
"Host system is missing dependencies to run browsers.",
|
|
75
|
-
"You should install dependencies by running:",
|
|
76
|
-
"",
|
|
77
|
-
` ${import_picocolors.default.bold(`sudo npx playwright@${import_package.default.version} install-deps`)} `,
|
|
78
|
-
"",
|
|
79
|
-
import_picocolors.default.gray("Note: Good luck with that.")
|
|
80
|
-
];
|
|
81
|
-
console.info(message.join("\n"));
|
|
82
|
-
throw new Error("Playwright is not available");
|
|
83
|
-
}
|
|
84
|
-
const content = await (0, import_playwright.loadHtml)(sourcePath);
|
|
85
|
-
options.debug && console.debug(`HTML loaded: ${content.slice(0, 100)}`);
|
|
86
|
-
return content;
|
|
87
|
-
}
|
|
88
|
-
throw new Error(`Unsupported loader: ${loader}`);
|
|
89
|
-
};
|
|
90
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
-
0 && (module.exports = {
|
|
92
|
-
loadHtml
|
|
93
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
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 constants_exports = {};
|
|
20
|
-
__export(constants_exports, {
|
|
21
|
-
DEFAULT_PATH: () => DEFAULT_PATH,
|
|
22
|
-
LOADERS: () => LOADERS,
|
|
23
|
-
MODES: () => MODES
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(constants_exports);
|
|
26
|
-
const DEFAULT_PATH = "https://example.com";
|
|
27
|
-
const LOADERS = ["fetch", "playwright"];
|
|
28
|
-
const MODES = ["default", "ai"];
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
DEFAULT_PATH,
|
|
32
|
-
LOADERS,
|
|
33
|
-
MODES
|
|
34
|
-
});
|