@xbrowser/cli 0.14.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 (55) hide show
  1. package/README.md +858 -0
  2. package/dist/admin-6UTU2RZ2.js +281 -0
  3. package/dist/admin-MDGF4CET.js +285 -0
  4. package/dist/admin-RPJJ5CAF.js +282 -0
  5. package/dist/browser-GWBH6OJK.js +46 -0
  6. package/dist/browser-I2HJZ7IP.js +48 -0
  7. package/dist/browser-R7B255ML.js +46 -0
  8. package/dist/chunk-2ONMTDLK.js +2050 -0
  9. package/dist/chunk-3RG5ZIWI.js +10 -0
  10. package/dist/chunk-43VX3TYN.js +83 -0
  11. package/dist/chunk-ATFTAKMN.js +267 -0
  12. package/dist/chunk-DESA2KMG.js +77 -0
  13. package/dist/chunk-DTJRVA76.js +206 -0
  14. package/dist/chunk-F3ZWFCJJ.js +2051 -0
  15. package/dist/chunk-FF5WHQHN.js +135 -0
  16. package/dist/chunk-HINTG75P.js +77 -0
  17. package/dist/chunk-KDYXFLAC.js +1503 -0
  18. package/dist/chunk-KTSQU4QT.js +29 -0
  19. package/dist/chunk-L53IDAWK.js +68 -0
  20. package/dist/chunk-M7CMBPCA.js +100 -0
  21. package/dist/chunk-NFGO7J2I.js +29 -0
  22. package/dist/chunk-OLB6UJ25.js +438 -0
  23. package/dist/chunk-OPRXFZVE.js +52 -0
  24. package/dist/chunk-RS6YYWTK.js +685 -0
  25. package/dist/chunk-VEDJ5XSQ.js +196 -0
  26. package/dist/chunk-VEKPHQBR.js +47 -0
  27. package/dist/chunk-VUJDJCIN.js +437 -0
  28. package/dist/chunk-YEN2ODUI.js +14 -0
  29. package/dist/chunk-ZZ2TFWIV.js +1382 -0
  30. package/dist/cli.js +11012 -0
  31. package/dist/convert-4DUWZIKH.js +205 -0
  32. package/dist/convert-EKQVHKB4.js +11 -0
  33. package/dist/daemon-client-3IJD6X4B.js +59 -0
  34. package/dist/daemon-client-GX2UYIW4.js +241 -0
  35. package/dist/daemon-client-XWSSQBEA.js +58 -0
  36. package/dist/daemon-main.js +9910 -0
  37. package/dist/extract-EGRXZSSK.js +67 -0
  38. package/dist/extract-JUOQQX4V.js +11 -0
  39. package/dist/filter-OLAE26HN.js +51 -0
  40. package/dist/filter-VID2GGZ7.js +9 -0
  41. package/dist/human-interaction-QPHNDD76.js +8 -0
  42. package/dist/index.d.ts +2313 -0
  43. package/dist/index.js +13839 -0
  44. package/dist/marketplace-FCVN5OTZ.js +706 -0
  45. package/dist/marketplace-FPT5YLKB.js +351 -0
  46. package/dist/marketplace-W545W4FR.js +706 -0
  47. package/dist/network-store-2S5HATEV.js +194 -0
  48. package/dist/network-store-BN6QEZ7R.js +196 -0
  49. package/dist/network-store-YAF5OIBH.js +12 -0
  50. package/dist/parse-action-dsl-DRSPBALP.js +72 -0
  51. package/dist/parse-action-dsl-T3DYC33D.js +74 -0
  52. package/dist/proxy-WKGUCH2C.js +7 -0
  53. package/dist/session-recorder-ILSSV2UC.js +6 -0
  54. package/dist/session-recorder-XET3DNML.js +7 -0
  55. package/package.json +111 -0
@@ -0,0 +1,135 @@
1
+ // src/config.ts
2
+ import { existsSync, mkdirSync, writeFileSync as writeFileSync2 } from "fs";
3
+ import { join } from "path";
4
+ import { homedir, tmpdir } from "os";
5
+
6
+ // src/utils/json-file.ts
7
+ import { readFileSync, writeFileSync } from "fs";
8
+ function readJsonFile(filePath, defaultValue) {
9
+ try {
10
+ const content = readFileSync(filePath, "utf-8");
11
+ return JSON.parse(content);
12
+ } catch {
13
+ return defaultValue;
14
+ }
15
+ }
16
+
17
+ // src/config.ts
18
+ function getConfigFile() {
19
+ return join(homedir() || tmpdir(), ".xbrowser", "config.json");
20
+ }
21
+ function loadConfig() {
22
+ const configFile = getConfigFile();
23
+ if (!existsSync(configFile)) return {};
24
+ return readJsonFile(configFile, {});
25
+ }
26
+ function saveConfig(config) {
27
+ const dir = join(homedir() || tmpdir(), ".xbrowser");
28
+ const configFile = getConfigFile();
29
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
30
+ writeFileSync2(configFile, JSON.stringify(config, null, 2), "utf-8");
31
+ }
32
+ function getConfigValue(key) {
33
+ return loadConfig()[key];
34
+ }
35
+ function setConfigValue(key, value) {
36
+ const config = loadConfig();
37
+ config[key] = value;
38
+ saveConfig(config);
39
+ }
40
+ var DEFAULT_MARKETPLACE_URL = "https://marketplace.xbrowser.dev";
41
+ var DEFAULT_REGISTRY_URL = "https://xbrowser.dev";
42
+ var NPM_REGISTRY_URL = "https://registry.npmjs.org";
43
+ var NPM_SCOPE = "@xbrowser/";
44
+ function getMarketplaceUrl() {
45
+ return process.env.XBROWSER_MARKETPLACE_URL || getConfigValue("marketplaceUrl") || DEFAULT_MARKETPLACE_URL;
46
+ }
47
+ function getRegistryUrl(options = {}, fallbackRegistry) {
48
+ return options["registry"] || process.env.XBROWSER_REGISTRY || fallbackRegistry || DEFAULT_REGISTRY_URL;
49
+ }
50
+ function resolveNpmPackageName(name) {
51
+ if (name.startsWith("@")) return name;
52
+ return `${NPM_SCOPE}${name}`;
53
+ }
54
+ var NPM_NAME_ALIASES = {
55
+ "1688": "alibaba-1688"
56
+ };
57
+ function generateNpmCandidates(name) {
58
+ if (name.startsWith("@")) return [name];
59
+ const resolved = NPM_NAME_ALIASES[name] ?? name;
60
+ return [
61
+ `${NPM_SCOPE}xbrowser-plugin-${resolved}`,
62
+ `${NPM_SCOPE}${resolved}`,
63
+ `xbrowser-plugin-${resolved}`
64
+ ];
65
+ }
66
+ async function resolveNpmPackageWithFallback(name) {
67
+ const candidates = generateNpmCandidates(name);
68
+ for (const candidate of candidates) {
69
+ try {
70
+ const encoded = encodeURIComponent(candidate);
71
+ const res = await fetch(`${NPM_REGISTRY_URL}/${encoded}`);
72
+ if (res.ok) return candidate;
73
+ } catch {
74
+ continue;
75
+ }
76
+ }
77
+ return resolveNpmPackageName(name);
78
+ }
79
+
80
+ // src/utils/proxy-fetch.ts
81
+ var patched = false;
82
+ async function ensureProxyFetch() {
83
+ if (patched) return;
84
+ patched = true;
85
+ if (process.env.https_proxy && !process.env.HTTPS_PROXY) {
86
+ process.env.HTTPS_PROXY = process.env.https_proxy;
87
+ }
88
+ if (process.env.http_proxy && !process.env.HTTP_PROXY) {
89
+ process.env.HTTP_PROXY = process.env.http_proxy;
90
+ }
91
+ if (process.env.all_proxy && !process.env.ALL_PROXY) {
92
+ process.env.ALL_PROXY = process.env.all_proxy;
93
+ }
94
+ const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.HTTP_PROXY || process.env.all_proxy || process.env.ALL_PROXY;
95
+ if (!proxyUrl) return;
96
+ try {
97
+ const undici = await import("undici");
98
+ const EnvHttpProxyAgent = undici.EnvHttpProxyAgent;
99
+ const uFetch = undici.fetch;
100
+ const UFormData = undici.FormData;
101
+ if (EnvHttpProxyAgent && uFetch && UFormData) {
102
+ const agent = new EnvHttpProxyAgent();
103
+ globalThis.fetch = ((input, init) => {
104
+ const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
105
+ const body = init?.body;
106
+ if (body instanceof globalThis.FormData && !(body instanceof UFormData)) {
107
+ const ufd = new UFormData();
108
+ body.forEach((value, key) => {
109
+ if (value instanceof Blob) {
110
+ ufd.append(key, value, value.name || "file");
111
+ } else {
112
+ ufd.append(key, value);
113
+ }
114
+ });
115
+ return uFetch(url, { ...init, body: ufd, dispatcher: agent });
116
+ }
117
+ return uFetch(url, { ...init, dispatcher: agent });
118
+ });
119
+ }
120
+ } catch {
121
+ }
122
+ }
123
+
124
+ export {
125
+ readJsonFile,
126
+ loadConfig,
127
+ getConfigValue,
128
+ setConfigValue,
129
+ NPM_REGISTRY_URL,
130
+ NPM_SCOPE,
131
+ getMarketplaceUrl,
132
+ getRegistryUrl,
133
+ resolveNpmPackageWithFallback,
134
+ ensureProxyFetch
135
+ };
@@ -0,0 +1,77 @@
1
+ import {
2
+ readJsonFile
3
+ } from "./chunk-FF5WHQHN.js";
4
+
5
+ // src/plugin/metadata-parser.ts
6
+ import { existsSync } from "fs";
7
+ import { resolve } from "path";
8
+ var PluginMetadataParser = class {
9
+ static XBROWSER_KEYWORDS = ["xbrowser", "xbrowser-plugin"];
10
+ static parseFromPackageJson(pluginPath) {
11
+ const packageJsonPath = resolve(pluginPath, "package.json");
12
+ if (!existsSync(packageJsonPath)) {
13
+ return null;
14
+ }
15
+ const packageJson = readJsonFile(packageJsonPath, null);
16
+ if (!packageJson) return null;
17
+ if (!packageJson.xbrowser) {
18
+ return null;
19
+ }
20
+ const xbrowser = packageJson.xbrowser;
21
+ const metadata = {
22
+ id: xbrowser.id || packageJson.name,
23
+ name: xbrowser.name || packageJson.name,
24
+ description: xbrowser.description || packageJson.description || "",
25
+ version: xbrowser.version || packageJson.version || "1.0.0",
26
+ author: xbrowser.author || this.extractAuthor(packageJson.author),
27
+ homepage: xbrowser.homepage || packageJson.homepage,
28
+ commands: xbrowser.commands,
29
+ sites: xbrowser.sites,
30
+ tags: xbrowser.tags,
31
+ screenshot: xbrowser.screenshot,
32
+ license: xbrowser.license || packageJson.license
33
+ };
34
+ return metadata;
35
+ }
36
+ static isXBrowserPlugin(packageJson) {
37
+ if (packageJson.xbrowser) {
38
+ return true;
39
+ }
40
+ const keywords = packageJson.keywords;
41
+ if (!keywords) return false;
42
+ return this.XBROWSER_KEYWORDS.some((kw) => keywords.includes(kw));
43
+ }
44
+ static fromNPMResult(result) {
45
+ const author = typeof result.author === "string" ? result.author : result.author?.name || "Unknown";
46
+ return {
47
+ id: result.name,
48
+ name: result.name.replace(/^xbrowser-plugin-/, "").replace(/^@[^/]+\//, ""),
49
+ description: result.description || "",
50
+ version: result.version,
51
+ author,
52
+ homepage: result.homepage || result.links?.homepage,
53
+ tags: result.keywords,
54
+ license: ""
55
+ };
56
+ }
57
+ static extractAuthor(author) {
58
+ if (typeof author === "string") return author;
59
+ if (typeof author === "object" && author !== null) {
60
+ const authorObj = author;
61
+ return authorObj.name || "Unknown";
62
+ }
63
+ return "Unknown";
64
+ }
65
+ static validateMetadata(metadata) {
66
+ const errors = [];
67
+ if (!metadata.id) errors.push("id is required");
68
+ if (!metadata.name) errors.push("name is required");
69
+ if (!metadata.description) errors.push("description is required");
70
+ if (!metadata.version) errors.push("version is required");
71
+ return errors;
72
+ }
73
+ };
74
+
75
+ export {
76
+ PluginMetadataParser
77
+ };