@jackwener/opencli 1.0.1 → 1.0.3
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/.github/workflows/build-extension.yml +62 -0
- package/.github/workflows/ci.yml +6 -6
- package/.github/workflows/e2e-headed.yml +2 -2
- package/.github/workflows/pkg-pr-new.yml +2 -2
- package/.github/workflows/release.yml +2 -5
- package/.github/workflows/security.yml +2 -2
- package/CDP.md +1 -1
- package/CDP.zh-CN.md +1 -1
- package/README.md +15 -7
- package/README.zh-CN.md +15 -7
- package/SKILL.md +3 -5
- package/dist/browser/cdp.d.ts +27 -0
- package/dist/browser/cdp.js +295 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +4 -0
- package/dist/browser/page.js +2 -23
- package/dist/browser/utils.d.ts +10 -0
- package/dist/browser/utils.js +27 -0
- package/dist/browser.test.js +42 -1
- package/dist/chaoxing.d.ts +58 -0
- package/dist/chaoxing.js +225 -0
- package/dist/chaoxing.test.d.ts +1 -0
- package/dist/chaoxing.test.js +38 -0
- package/dist/cli-manifest.json +203 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +197 -0
- package/dist/clis/boss/chatlist.d.ts +1 -0
- package/dist/clis/boss/chatlist.js +50 -0
- package/dist/clis/boss/chatmsg.d.ts +1 -0
- package/dist/clis/boss/chatmsg.js +73 -0
- package/dist/clis/boss/send.d.ts +1 -0
- package/dist/clis/boss/send.js +176 -0
- package/dist/clis/chaoxing/assignments.d.ts +1 -0
- package/dist/clis/chaoxing/assignments.js +74 -0
- package/dist/clis/chaoxing/exams.d.ts +1 -0
- package/dist/clis/chaoxing/exams.js +74 -0
- package/dist/clis/chatgpt/ask.js +15 -14
- package/dist/clis/chatgpt/ax.d.ts +1 -0
- package/dist/clis/chatgpt/ax.js +78 -0
- package/dist/clis/chatgpt/read.js +5 -6
- package/dist/clis/twitter/post.js +9 -2
- package/dist/clis/twitter/search.js +14 -33
- package/dist/clis/xiaohongshu/download.d.ts +1 -1
- package/dist/clis/xiaohongshu/download.js +1 -1
- package/dist/engine.js +24 -13
- package/dist/explore.js +46 -101
- package/dist/main.js +4 -193
- package/dist/output.d.ts +1 -1
- package/dist/registry.d.ts +3 -3
- package/dist/scripts/framework.d.ts +4 -0
- package/dist/scripts/framework.js +21 -0
- package/dist/scripts/interact.d.ts +4 -0
- package/dist/scripts/interact.js +20 -0
- package/dist/scripts/store.d.ts +9 -0
- package/dist/scripts/store.js +44 -0
- package/dist/synthesize.js +1 -1
- package/extension/dist/background.js +338 -430
- package/extension/manifest.json +2 -2
- package/extension/src/background.ts +2 -2
- package/package.json +1 -1
- package/src/browser/cdp.ts +295 -0
- package/src/browser/index.ts +4 -0
- package/src/browser/page.ts +2 -24
- package/src/browser/utils.ts +27 -0
- package/src/browser.test.ts +46 -0
- package/src/chaoxing.test.ts +45 -0
- package/src/chaoxing.ts +268 -0
- package/src/cli.ts +185 -0
- package/src/clis/antigravity/SKILL.md +5 -0
- package/src/clis/boss/chatlist.ts +50 -0
- package/src/clis/boss/chatmsg.ts +70 -0
- package/src/clis/boss/send.ts +193 -0
- package/src/clis/chaoxing/README.md +36 -0
- package/src/clis/chaoxing/README.zh-CN.md +35 -0
- package/src/clis/chaoxing/assignments.ts +88 -0
- package/src/clis/chaoxing/exams.ts +88 -0
- package/src/clis/chatgpt/ask.ts +14 -15
- package/src/clis/chatgpt/ax.ts +81 -0
- package/src/clis/chatgpt/read.ts +5 -7
- package/src/clis/twitter/post.ts +9 -2
- package/src/clis/twitter/search.ts +15 -33
- package/src/clis/xiaohongshu/download.ts +1 -1
- package/src/engine.ts +20 -13
- package/src/explore.ts +51 -100
- package/src/main.ts +4 -180
- package/src/output.ts +12 -12
- package/src/registry.ts +3 -3
- package/src/scripts/framework.ts +20 -0
- package/src/scripts/interact.ts +22 -0
- package/src/scripts/store.ts +40 -0
- package/src/synthesize.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -5,16 +5,9 @@
|
|
|
5
5
|
import * as os from 'node:os';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { fullName, getRegistry, strategyLabel } from './registry.js';
|
|
12
|
-
import { render as renderOutput } from './output.js';
|
|
13
|
-
import { BrowserBridge } from './browser/index.js';
|
|
14
|
-
import { browserSession, DEFAULT_BROWSER_COMMAND_TIMEOUT, runWithTimeout } from './runtime.js';
|
|
15
|
-
import { PKG_VERSION } from './version.js';
|
|
16
|
-
import { getCompletions, printCompletionScript } from './completion.js';
|
|
17
|
-
import { CliError } from './errors.js';
|
|
8
|
+
import { discoverClis } from './engine.js';
|
|
9
|
+
import { getCompletions } from './completion.js';
|
|
10
|
+
import { runCli } from './cli.js';
|
|
18
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
12
|
const __dirname = path.dirname(__filename);
|
|
20
13
|
const BUILTIN_CLIS = path.resolve(__dirname, 'clis');
|
|
@@ -42,186 +35,4 @@ if (getCompIdx !== -1) {
|
|
|
42
35
|
process.stdout.write(candidates.join('\n') + '\n');
|
|
43
36
|
process.exit(0);
|
|
44
37
|
}
|
|
45
|
-
|
|
46
|
-
program.name('opencli').description('Make any website your CLI. Zero setup. AI-powered.').version(PKG_VERSION);
|
|
47
|
-
// ── Built-in commands ──────────────────────────────────────────────────────
|
|
48
|
-
program.command('list').description('List all available CLI commands').option('-f, --format <fmt>', 'Output format: table, json, yaml, md, csv', 'table').option('--json', 'JSON output (deprecated)')
|
|
49
|
-
.action((opts) => {
|
|
50
|
-
const registry = getRegistry();
|
|
51
|
-
const commands = [...registry.values()].sort((a, b) => fullName(a).localeCompare(fullName(b)));
|
|
52
|
-
const rows = commands.map(c => ({
|
|
53
|
-
command: fullName(c),
|
|
54
|
-
site: c.site,
|
|
55
|
-
name: c.name,
|
|
56
|
-
description: c.description,
|
|
57
|
-
strategy: strategyLabel(c),
|
|
58
|
-
browser: c.browser,
|
|
59
|
-
args: c.args.map(a => a.name).join(', '),
|
|
60
|
-
}));
|
|
61
|
-
const fmt = opts.json && opts.format === 'table' ? 'json' : opts.format;
|
|
62
|
-
if (fmt !== 'table') {
|
|
63
|
-
renderOutput(rows, {
|
|
64
|
-
fmt,
|
|
65
|
-
columns: ['command', 'site', 'name', 'description', 'strategy', 'browser', 'args'],
|
|
66
|
-
title: 'opencli/list',
|
|
67
|
-
source: 'opencli list',
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const sites = new Map();
|
|
72
|
-
for (const cmd of commands) {
|
|
73
|
-
const g = sites.get(cmd.site) ?? [];
|
|
74
|
-
g.push(cmd);
|
|
75
|
-
sites.set(cmd.site, g);
|
|
76
|
-
}
|
|
77
|
-
console.log();
|
|
78
|
-
console.log(chalk.bold(' opencli') + chalk.dim(' — available commands'));
|
|
79
|
-
console.log();
|
|
80
|
-
for (const [site, cmds] of sites) {
|
|
81
|
-
console.log(chalk.bold.cyan(` ${site}`));
|
|
82
|
-
for (const cmd of cmds) {
|
|
83
|
-
const tag = strategyLabel(cmd) === 'public' ? chalk.green('[public]') : chalk.yellow(`[${strategyLabel(cmd)}]`);
|
|
84
|
-
console.log(` ${cmd.name} ${tag}${cmd.description ? chalk.dim(` — ${cmd.description}`) : ''}`);
|
|
85
|
-
}
|
|
86
|
-
console.log();
|
|
87
|
-
}
|
|
88
|
-
console.log(chalk.dim(` ${commands.length} commands across ${sites.size} sites`));
|
|
89
|
-
console.log();
|
|
90
|
-
});
|
|
91
|
-
program.command('validate').description('Validate CLI definitions').argument('[target]', 'site or site/name')
|
|
92
|
-
.action(async (target) => {
|
|
93
|
-
const { validateClisWithTarget, renderValidationReport } = await import('./validate.js');
|
|
94
|
-
console.log(renderValidationReport(validateClisWithTarget([BUILTIN_CLIS, USER_CLIS], target)));
|
|
95
|
-
});
|
|
96
|
-
program.command('verify').description('Validate + smoke test').argument('[target]').option('--smoke', 'Run smoke tests', false)
|
|
97
|
-
.action(async (target, opts) => {
|
|
98
|
-
const { verifyClis, renderVerifyReport } = await import('./verify.js');
|
|
99
|
-
const r = await verifyClis({ builtinClis: BUILTIN_CLIS, userClis: USER_CLIS, target, smoke: opts.smoke });
|
|
100
|
-
console.log(renderVerifyReport(r));
|
|
101
|
-
process.exitCode = r.ok ? 0 : 1;
|
|
102
|
-
});
|
|
103
|
-
program.command('explore').alias('probe').description('Explore a website: discover APIs, stores, and recommend strategies').argument('<url>').option('--site <name>').option('--goal <text>').option('--wait <s>', '', '3').option('--auto', 'Enable interactive fuzzing (simulate clicks to trigger lazy APIs)').option('--click <labels>', 'Comma-separated labels to click before fuzzing (e.g. "字幕,CC,评论")')
|
|
104
|
-
.action(async (url, opts) => { const { exploreUrl, renderExploreSummary } = await import('./explore.js'); const clickLabels = opts.click ? opts.click.split(',').map((s) => s.trim()) : undefined; console.log(renderExploreSummary(await exploreUrl(url, { BrowserFactory: BrowserBridge, site: opts.site, goal: opts.goal, waitSeconds: parseFloat(opts.wait), auto: opts.auto, clickLabels }))); });
|
|
105
|
-
program.command('synthesize').description('Synthesize CLIs from explore').argument('<target>').option('--top <n>', '', '3')
|
|
106
|
-
.action(async (target, opts) => { const { synthesizeFromExplore, renderSynthesizeSummary } = await import('./synthesize.js'); console.log(renderSynthesizeSummary(synthesizeFromExplore(target, { top: parseInt(opts.top) }))); });
|
|
107
|
-
program.command('generate').description('One-shot: explore → synthesize → register').argument('<url>').option('--goal <text>').option('--site <name>')
|
|
108
|
-
.action(async (url, opts) => { const { generateCliFromUrl, renderGenerateSummary } = await import('./generate.js'); const r = await generateCliFromUrl({ url, BrowserFactory: BrowserBridge, builtinClis: BUILTIN_CLIS, userClis: USER_CLIS, goal: opts.goal, site: opts.site }); console.log(renderGenerateSummary(r)); process.exitCode = r.ok ? 0 : 1; });
|
|
109
|
-
program.command('cascade').description('Strategy cascade: find simplest working strategy').argument('<url>').option('--site <name>')
|
|
110
|
-
.action(async (url, opts) => {
|
|
111
|
-
const { cascadeProbe, renderCascadeResult } = await import('./cascade.js');
|
|
112
|
-
const result = await browserSession(BrowserBridge, async (page) => {
|
|
113
|
-
// Navigate to the site first for cookie context
|
|
114
|
-
try {
|
|
115
|
-
const siteUrl = new URL(url);
|
|
116
|
-
await page.goto(`${siteUrl.protocol}//${siteUrl.host}`);
|
|
117
|
-
await page.wait(2);
|
|
118
|
-
}
|
|
119
|
-
catch { }
|
|
120
|
-
return cascadeProbe(page, url);
|
|
121
|
-
});
|
|
122
|
-
console.log(renderCascadeResult(result));
|
|
123
|
-
});
|
|
124
|
-
program.command('doctor')
|
|
125
|
-
.description('Diagnose opencli browser bridge connectivity')
|
|
126
|
-
.option('--live', 'Test browser connectivity (requires Chrome running)', false)
|
|
127
|
-
.action(async (opts) => {
|
|
128
|
-
const { runBrowserDoctor, renderBrowserDoctorReport } = await import('./doctor.js');
|
|
129
|
-
const report = await runBrowserDoctor({ live: opts.live, cliVersion: PKG_VERSION });
|
|
130
|
-
console.log(renderBrowserDoctorReport(report));
|
|
131
|
-
});
|
|
132
|
-
program.command('setup')
|
|
133
|
-
.description('Interactive setup: verify browser bridge connectivity')
|
|
134
|
-
.action(async () => {
|
|
135
|
-
const { runSetup } = await import('./setup.js');
|
|
136
|
-
await runSetup({ cliVersion: PKG_VERSION });
|
|
137
|
-
});
|
|
138
|
-
program.command('completion')
|
|
139
|
-
.description('Output shell completion script')
|
|
140
|
-
.argument('<shell>', 'Shell type: bash, zsh, or fish')
|
|
141
|
-
.action((shell) => {
|
|
142
|
-
printCompletionScript(shell);
|
|
143
|
-
});
|
|
144
|
-
// ── Dynamic site commands ──────────────────────────────────────────────────
|
|
145
|
-
const registry = getRegistry();
|
|
146
|
-
const siteGroups = new Map();
|
|
147
|
-
for (const [, cmd] of registry) {
|
|
148
|
-
let siteCmd = siteGroups.get(cmd.site);
|
|
149
|
-
if (!siteCmd) {
|
|
150
|
-
siteCmd = program.command(cmd.site).description(`${cmd.site} commands`);
|
|
151
|
-
siteGroups.set(cmd.site, siteCmd);
|
|
152
|
-
}
|
|
153
|
-
const subCmd = siteCmd.command(cmd.name).description(cmd.description);
|
|
154
|
-
// Register positional args first, then named options
|
|
155
|
-
const positionalArgs = [];
|
|
156
|
-
for (const arg of cmd.args) {
|
|
157
|
-
if (arg.positional) {
|
|
158
|
-
const bracket = arg.required ? `<${arg.name}>` : `[${arg.name}]`;
|
|
159
|
-
subCmd.argument(bracket, arg.help ?? '');
|
|
160
|
-
positionalArgs.push(arg);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
const flag = arg.required ? `--${arg.name} <value>` : `--${arg.name} [value]`;
|
|
164
|
-
if (arg.required)
|
|
165
|
-
subCmd.requiredOption(flag, arg.help ?? '');
|
|
166
|
-
else if (arg.default != null)
|
|
167
|
-
subCmd.option(flag, arg.help ?? '', String(arg.default));
|
|
168
|
-
else
|
|
169
|
-
subCmd.option(flag, arg.help ?? '');
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
subCmd.option('-f, --format <fmt>', 'Output format: table, json, yaml, md, csv', 'table').option('-v, --verbose', 'Debug output', false);
|
|
173
|
-
subCmd.action(async (...actionArgs) => {
|
|
174
|
-
// Commander passes positional args first, then options object, then the Command
|
|
175
|
-
const actionOpts = actionArgs[positionalArgs.length] ?? {};
|
|
176
|
-
const startTime = Date.now();
|
|
177
|
-
const kwargs = {};
|
|
178
|
-
// Collect positional args
|
|
179
|
-
for (let i = 0; i < positionalArgs.length; i++) {
|
|
180
|
-
const arg = positionalArgs[i];
|
|
181
|
-
const v = actionArgs[i];
|
|
182
|
-
if (v !== undefined)
|
|
183
|
-
kwargs[arg.name] = v;
|
|
184
|
-
}
|
|
185
|
-
// Collect named options
|
|
186
|
-
for (const arg of cmd.args) {
|
|
187
|
-
if (arg.positional)
|
|
188
|
-
continue;
|
|
189
|
-
const camelName = arg.name.replace(/-([a-z])/g, (_m, ch) => ch.toUpperCase());
|
|
190
|
-
const v = actionOpts[arg.name] ?? actionOpts[camelName];
|
|
191
|
-
if (v !== undefined)
|
|
192
|
-
kwargs[arg.name] = v;
|
|
193
|
-
}
|
|
194
|
-
try {
|
|
195
|
-
if (actionOpts.verbose)
|
|
196
|
-
process.env.OPENCLI_VERBOSE = '1';
|
|
197
|
-
let result;
|
|
198
|
-
if (cmd.browser) {
|
|
199
|
-
result = await browserSession(BrowserBridge, async (page) => {
|
|
200
|
-
return runWithTimeout(executeCommand(cmd, page, kwargs, actionOpts.verbose), { timeout: cmd.timeoutSeconds ?? DEFAULT_BROWSER_COMMAND_TIMEOUT, label: fullName(cmd) });
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
result = await executeCommand(cmd, null, kwargs, actionOpts.verbose);
|
|
205
|
-
}
|
|
206
|
-
if (actionOpts.verbose && (!result || (Array.isArray(result) && result.length === 0))) {
|
|
207
|
-
console.error(chalk.yellow(`[Verbose] Warning: Command returned an empty result. If the website structural API changed or requires authentication, check the network or update the adapter.`));
|
|
208
|
-
}
|
|
209
|
-
renderOutput(result, { fmt: actionOpts.format, columns: cmd.columns, title: `${cmd.site}/${cmd.name}`, elapsed: (Date.now() - startTime) / 1000, source: fullName(cmd) });
|
|
210
|
-
}
|
|
211
|
-
catch (err) {
|
|
212
|
-
if (err instanceof CliError) {
|
|
213
|
-
console.error(chalk.red(`Error [${err.code}]: ${err.message}`));
|
|
214
|
-
if (err.hint)
|
|
215
|
-
console.error(chalk.yellow(`Hint: ${err.hint}`));
|
|
216
|
-
}
|
|
217
|
-
else if (actionOpts.verbose && err.stack) {
|
|
218
|
-
console.error(chalk.red(err.stack));
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
console.error(chalk.red(`Error: ${err.message ?? err}`));
|
|
222
|
-
}
|
|
223
|
-
process.exitCode = 1;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
program.parse();
|
|
38
|
+
runCli(BUILTIN_CLIS, USER_CLIS);
|
package/dist/output.d.ts
CHANGED
package/dist/registry.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare enum Strategy {
|
|
|
12
12
|
export interface Arg {
|
|
13
13
|
name: string;
|
|
14
14
|
type?: string;
|
|
15
|
-
default?:
|
|
15
|
+
default?: unknown;
|
|
16
16
|
required?: boolean;
|
|
17
17
|
positional?: boolean;
|
|
18
18
|
help?: string;
|
|
@@ -27,8 +27,8 @@ export interface CliCommand {
|
|
|
27
27
|
browser?: boolean;
|
|
28
28
|
args: Arg[];
|
|
29
29
|
columns?: string[];
|
|
30
|
-
func?: (page: IPage, kwargs: Record<string, any>, debug?: boolean) => Promise<
|
|
31
|
-
pipeline?:
|
|
30
|
+
func?: (page: IPage, kwargs: Record<string, any>, debug?: boolean) => Promise<unknown>;
|
|
31
|
+
pipeline?: Record<string, unknown>[];
|
|
32
32
|
timeoutSeconds?: number;
|
|
33
33
|
source?: string;
|
|
34
34
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injected script for detecting frontend frameworks (Vue, React, Next, Nuxt, etc.)
|
|
3
|
+
*/
|
|
4
|
+
export function detectFramework() {
|
|
5
|
+
const r = {};
|
|
6
|
+
try {
|
|
7
|
+
const app = document.querySelector('#app');
|
|
8
|
+
r.vue3 = !!(app && app.__vue_app__);
|
|
9
|
+
r.vue2 = !!(app && app.__vue__);
|
|
10
|
+
r.react = !!window.__REACT_DEVTOOLS_GLOBAL_HOOK__ || !!document.querySelector('[data-reactroot]');
|
|
11
|
+
r.nextjs = !!window.__NEXT_DATA__;
|
|
12
|
+
r.nuxt = !!window.__NUXT__;
|
|
13
|
+
if (r.vue3 && app.__vue_app__) {
|
|
14
|
+
const gp = app.__vue_app__.config?.globalProperties;
|
|
15
|
+
r.pinia = !!(gp && gp.$pinia);
|
|
16
|
+
r.vuex = !!(gp && gp.$store);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injected script for interactive fuzzing (clicking elements to trigger lazy loading)
|
|
3
|
+
*/
|
|
4
|
+
export async function interactFuzz() {
|
|
5
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
6
|
+
const clickables = Array.from(document.querySelectorAll('button, [role="button"], [role="tab"], .tab, .btn, a[href="javascript:void(0)"], a[href="#"]')).slice(0, 15); // limit to a small number to avoid endless loops
|
|
7
|
+
let clicked = 0;
|
|
8
|
+
for (const el of clickables) {
|
|
9
|
+
try {
|
|
10
|
+
const rect = el.getBoundingClientRect();
|
|
11
|
+
if (rect.width > 0 && rect.height > 0) {
|
|
12
|
+
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
|
|
13
|
+
clicked++;
|
|
14
|
+
await sleep(300); // give it time to trigger network
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
}
|
|
19
|
+
return clicked;
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injected script for discovering Pinia or Vuex stores and their actions/state representations
|
|
3
|
+
*/
|
|
4
|
+
export function discoverStores() {
|
|
5
|
+
const stores = [];
|
|
6
|
+
try {
|
|
7
|
+
const app = document.querySelector('#app');
|
|
8
|
+
if (!app?.__vue_app__)
|
|
9
|
+
return stores;
|
|
10
|
+
const gp = app.__vue_app__.config?.globalProperties;
|
|
11
|
+
// Pinia stores
|
|
12
|
+
const pinia = gp?.$pinia;
|
|
13
|
+
if (pinia?._s) {
|
|
14
|
+
pinia._s.forEach((store, id) => {
|
|
15
|
+
const actions = [];
|
|
16
|
+
const stateKeys = [];
|
|
17
|
+
for (const k in store) {
|
|
18
|
+
try {
|
|
19
|
+
if (k.startsWith('$') || k.startsWith('_'))
|
|
20
|
+
continue;
|
|
21
|
+
if (typeof store[k] === 'function')
|
|
22
|
+
actions.push(k);
|
|
23
|
+
else
|
|
24
|
+
stateKeys.push(k);
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
27
|
+
}
|
|
28
|
+
stores.push({ type: 'pinia', id, actions: actions.slice(0, 20), stateKeys: stateKeys.slice(0, 15) });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// Vuex store modules
|
|
32
|
+
const vuex = gp?.$store;
|
|
33
|
+
if (vuex?._modules?.root?._children) {
|
|
34
|
+
const children = vuex._modules.root._children;
|
|
35
|
+
for (const [modName, mod] of Object.entries(children)) {
|
|
36
|
+
const actions = Object.keys(mod._rawModule?.actions ?? {}).slice(0, 20);
|
|
37
|
+
const stateKeys = Object.keys(mod.state ?? {}).slice(0, 15);
|
|
38
|
+
stores.push({ type: 'vuex', id: modName, actions, stateKeys });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch { }
|
|
43
|
+
return stores;
|
|
44
|
+
}
|
package/dist/synthesize.js
CHANGED
|
@@ -108,7 +108,7 @@ function buildEvaluateScript(url, itemPath, endpoint) {
|
|
|
108
108
|
}
|
|
109
109
|
return [
|
|
110
110
|
'(async () => {',
|
|
111
|
-
` const res = await fetch(
|
|
111
|
+
` const res = await fetch(${JSON.stringify(url)}, {`,
|
|
112
112
|
` credentials: 'include'`,
|
|
113
113
|
' });',
|
|
114
114
|
' const data = await res.json();',
|