@vue-html-bridge/cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/adapters.d.ts +29 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +55 -0
- package/dist/adapters.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +54 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +27 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +93 -0
- package/dist/cli.js.map +1 -0
- package/dist/diagnostics.d.ts +22 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +71 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/enumerate.d.ts +18 -0
- package/dist/enumerate.d.ts.map +1 -0
- package/dist/enumerate.js +182 -0
- package/dist/enumerate.js.map +1 -0
- package/dist/exit-codes.d.ts +23 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +38 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/line-index.d.ts +34 -0
- package/dist/line-index.d.ts.map +1 -0
- package/dist/line-index.js +82 -0
- package/dist/line-index.js.map +1 -0
- package/dist/options.d.ts +79 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +465 -0
- package/dist/options.js.map +1 -0
- package/dist/output/ndjson.d.ts +80 -0
- package/dist/output/ndjson.d.ts.map +1 -0
- package/dist/output/ndjson.js +61 -0
- package/dist/output/ndjson.js.map +1 -0
- package/dist/output/text.d.ts +12 -0
- package/dist/output/text.d.ts.map +1 -0
- package/dist/output/text.js +76 -0
- package/dist/output/text.js.map +1 -0
- package/dist/runner.d.ts +38 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +221 -0
- package/dist/runner.js.map +1 -0
- package/dist/settings-resolution.d.ts +27 -0
- package/dist/settings-resolution.d.ts.map +1 -0
- package/dist/settings-resolution.js +48 -0
- package/dist/settings-resolution.js.map +1 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Masato Nagashima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# `@vue-html-bridge/cli`
|
|
2
|
+
|
|
3
|
+
A one-shot command-line client for [vue-html-bridge](https://github.com/vue-html-bridge/vue-html-bridge):
|
|
4
|
+
runs the same analysis as the language server, for CI pipelines,
|
|
5
|
+
pre-commit hooks, and ad-hoc terminal use. It accepts the same settings
|
|
6
|
+
schema as the editor (`@vue-html-bridge/settings`) as command-line flags,
|
|
7
|
+
and loads adapters through the same `@vue-html-bridge/adapter-loader` — the
|
|
8
|
+
CLI and the language server are guaranteed to report the same diagnostics
|
|
9
|
+
for the same file under the same resolved settings and trust policy.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --global @vue-html-bridge/cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
or as a project `devDependency` invoked via `npx vue-html-bridge` / a
|
|
18
|
+
package-manager script.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
vue-html-bridge src/components
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
src/components/Menu.vue:6:27 error no-refer-to-non-existent-id
|
|
28
|
+
Missing "missing" ID [markuplint]
|
|
29
|
+
3 files analyzed: 1 error, 0 warnings, 0 infos, 0 hints
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
With no positional arguments, the `include` setting (default `**/*.vue`,
|
|
33
|
+
relative to `--workspace-root`, default the current directory) is used
|
|
34
|
+
instead. Exit code `0` means no diagnostic reached the `--fail-on` threshold
|
|
35
|
+
(default `error`); `1` means one did; `2` means a run-level problem occurred
|
|
36
|
+
(a bad argument, a fatal settings issue, a file that couldn't be read, an
|
|
37
|
+
adapter that failed to load) — see below. `130`/`143` on `SIGINT`/`SIGTERM`.
|
|
38
|
+
|
|
39
|
+
Machine-readable output:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
vue-html-bridge --format ndjson src/components
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
emits one self-contained JSON object per line (`meta`, then one `file` line
|
|
46
|
+
per analyzed file as it completes, then a `summary` line) — safe to pipe
|
|
47
|
+
into another process and to parse incrementally; see
|
|
48
|
+
[`docs/design/packages/cli.md`](../../docs/design/packages/cli.md) §7.2 for
|
|
49
|
+
the full record shapes and their versioning contract (`CliNdjsonRecord`,
|
|
50
|
+
also exported from this package's own public API for TypeScript consumers).
|
|
51
|
+
|
|
52
|
+
Run `vue-html-bridge --help` for the full flag reference — every field of
|
|
53
|
+
the shared settings schema that's meaningful outside an editor session has a
|
|
54
|
+
corresponding flag, listed in cli.md §4.2.
|
|
55
|
+
|
|
56
|
+
## Trust
|
|
57
|
+
|
|
58
|
+
Running the CLI in a repository is treated the same as running any other
|
|
59
|
+
linter's CLI there: **trusted by default** — it reads the workspace's
|
|
60
|
+
validator config, including JS config and plugins, exactly as a trusted
|
|
61
|
+
editor session would. Pass `--untrusted` for CI jobs analyzing untrusted
|
|
62
|
+
contributions: it forces `externalAdapters` off and the built-in Markuplint
|
|
63
|
+
adapter to its bundled, safe default config, while leaving every
|
|
64
|
+
host-neutral setting (`include`/`exclude`, `maxConcurrency`, output format,
|
|
65
|
+
`--fail-on`) unaffected.
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
The same `.vue-html-bridge.json` / `package.json#vueHtmlBridge` file the
|
|
70
|
+
language server discovers is used here too — flags and `--config <path>`
|
|
71
|
+
simply layer on top with the same precedence and validation rules as
|
|
72
|
+
`workspace/configuration` does for the editor
|
|
73
|
+
(`@vue-html-bridge/settings`'s `resolveSettings`, applied identically by
|
|
74
|
+
both hosts). Unlike the editor, an **`error`-severity settings issue is
|
|
75
|
+
fatal** here (exit `2`, before any analysis runs) rather than falling back —
|
|
76
|
+
CI must fail loudly on misconfiguration, not analyze with silently-wrong
|
|
77
|
+
settings.
|
|
78
|
+
|
|
79
|
+
See [`docs/design/packages/cli.md`](../../docs/design/packages/cli.md) for
|
|
80
|
+
the complete flag surface, the NDJSON contract, and the run-outcome/exit-code
|
|
81
|
+
model.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type AdapterLoadFailure, type AdapterModuleResolver } from "@vue-html-bridge/adapter-loader";
|
|
2
|
+
import type { ConfiguredAdapter } from "@vue-html-bridge/analyzer";
|
|
3
|
+
import type { ResolvedValidatorSetting } from "@vue-html-bridge/settings";
|
|
4
|
+
import type { AdapterLogger, HtmlValidatorAdapter } from "@vue-html-bridge/validator-api";
|
|
5
|
+
export declare const BUILTIN_MARKUPLINT_ID = "markuplint";
|
|
6
|
+
/**
|
|
7
|
+
* cli.md §4.2/§5: in an untrusted run (`--untrusted`), the built-in
|
|
8
|
+
* Markuplint adapter runs with its bundled, safe default config — no
|
|
9
|
+
* `configFile`, forced `searchConfig: false`, so it never loads workspace JS
|
|
10
|
+
* config or plugins. A trusted run uses the entry's own configured settings
|
|
11
|
+
* unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function builtinMarkuplintSettings(entry: ResolvedValidatorSetting | undefined, workspaceTrusted: boolean): unknown;
|
|
14
|
+
export interface LoadAdaptersForRunOptions {
|
|
15
|
+
validators: readonly ResolvedValidatorSetting[];
|
|
16
|
+
workspaceRoot: string;
|
|
17
|
+
workspaceTrusted: boolean;
|
|
18
|
+
externalAdapters: "disabled" | "trusted-workspace-only";
|
|
19
|
+
moduleResolver?: AdapterModuleResolver;
|
|
20
|
+
logger?: AdapterLogger;
|
|
21
|
+
/** Overridable for tests (adapter-loader.md §6 item 8's shared contract fixture); defaults to the real built-in Markuplint adapter. */
|
|
22
|
+
builtins?: ReadonlyMap<string, HtmlValidatorAdapter<unknown>>;
|
|
23
|
+
}
|
|
24
|
+
export interface LoadAdaptersForRunResult {
|
|
25
|
+
adapters: readonly ConfiguredAdapter[];
|
|
26
|
+
failures: readonly AdapterLoadFailure[];
|
|
27
|
+
}
|
|
28
|
+
export declare function loadAdaptersForRun(options: LoadAdaptersForRunOptions): Promise<LoadAdaptersForRunResult>;
|
|
29
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAOlD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,wBAAwB,GAAG,SAAS,EAC3C,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAGT;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,UAAU,GAAG,wBAAwB,CAAC;IACxD,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,uIAAuI;IACvI,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACzC;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAiCnC"}
|
package/dist/adapters.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Adapter loading (cli.md §5, §6 step 1): a thin wrapper over
|
|
2
|
+
// @vue-html-bridge/adapter-loader, mirroring
|
|
3
|
+
// packages/language-server/src/adapters/loading.ts's shape — the loader
|
|
4
|
+
// invocation and failure handling are identical between the two hosts; only
|
|
5
|
+
// the trust *default* differs (cli.md §5: trusted by default, restricted by
|
|
6
|
+
// `--untrusted`, vs. the LSP's untrusted-by-default). The built-in
|
|
7
|
+
// Markuplint adapter's own trust-based settings restriction
|
|
8
|
+
// (packages/language-server/src/adapters/trust.ts's `builtinMarkuplintSettings`)
|
|
9
|
+
// is reused verbatim here since it is not exported by that internal module.
|
|
10
|
+
import { markuplintAdapter } from "@vue-html-bridge/adapter-markuplint";
|
|
11
|
+
import { loadConfiguredAdapters, } from "@vue-html-bridge/adapter-loader";
|
|
12
|
+
export const BUILTIN_MARKUPLINT_ID = "markuplint";
|
|
13
|
+
const DEFAULT_BUILTINS = new Map([[BUILTIN_MARKUPLINT_ID, markuplintAdapter]]);
|
|
14
|
+
/**
|
|
15
|
+
* cli.md §4.2/§5: in an untrusted run (`--untrusted`), the built-in
|
|
16
|
+
* Markuplint adapter runs with its bundled, safe default config — no
|
|
17
|
+
* `configFile`, forced `searchConfig: false`, so it never loads workspace JS
|
|
18
|
+
* config or plugins. A trusted run uses the entry's own configured settings
|
|
19
|
+
* unchanged.
|
|
20
|
+
*/
|
|
21
|
+
export function builtinMarkuplintSettings(entry, workspaceTrusted) {
|
|
22
|
+
if (!workspaceTrusted)
|
|
23
|
+
return { searchConfig: false };
|
|
24
|
+
return entry?.settings ?? {};
|
|
25
|
+
}
|
|
26
|
+
export async function loadAdaptersForRun(options) {
|
|
27
|
+
const markuplintEntry = options.validators.find((entry) => entry.adapter === BUILTIN_MARKUPLINT_ID);
|
|
28
|
+
const result = await loadConfiguredAdapters({
|
|
29
|
+
validators: options.validators,
|
|
30
|
+
workspaceRoot: options.workspaceRoot,
|
|
31
|
+
trust: {
|
|
32
|
+
workspaceTrusted: options.workspaceTrusted,
|
|
33
|
+
externalAdapters: options.externalAdapters,
|
|
34
|
+
},
|
|
35
|
+
builtins: options.builtins ?? DEFAULT_BUILTINS,
|
|
36
|
+
moduleResolver: options.moduleResolver,
|
|
37
|
+
logger: options.logger,
|
|
38
|
+
});
|
|
39
|
+
const adapters = result.adapters.map((loaded) => {
|
|
40
|
+
if (loaded.entryKey === BUILTIN_MARKUPLINT_ID) {
|
|
41
|
+
return {
|
|
42
|
+
adapter: loaded.adapter,
|
|
43
|
+
settings: builtinMarkuplintSettings(markuplintEntry, options.workspaceTrusted),
|
|
44
|
+
enabled: loaded.enabled,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
adapter: loaded.adapter,
|
|
49
|
+
settings: loaded.settings,
|
|
50
|
+
enabled: loaded.enabled,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return { adapters, failures: result.failures };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,6CAA6C;AAC7C,wEAAwE;AACxE,4EAA4E;AAC5E,4EAA4E;AAC5E,mEAAmE;AACnE,4DAA4D;AAC5D,iFAAiF;AACjF,4EAA4E;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EACL,sBAAsB,GAGvB,MAAM,iCAAiC,CAAC;AAQzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,MAAM,gBAAgB,GAGlB,IAAI,GAAG,CAAC,CAAC,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAA2C,EAC3C,gBAAyB;IAEzB,IAAI,CAAC,gBAAgB;QAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACtD,OAAO,KAAK,EAAE,Q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file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Process entry point (cli.md §2, §6 "Signals"): wires real stdio, reads the
|
|
3
|
+
// package's own version for `--version`, and handles SIGINT/SIGTERM —
|
|
4
|
+
// abort the in-flight run through an AbortSignal, bounded cleanup (runner.ts
|
|
5
|
+
// owns the actual dispose bound), exit 130/143, and a second signal during
|
|
6
|
+
// cleanup exits immediately. stdout carries analysis results only; logs,
|
|
7
|
+
// progress, and notices go to stderr (mirrors the language server's rule).
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import { runVueHtmlBridgeCli } from "./cli.js";
|
|
10
|
+
import { EXIT_SIGINT, EXIT_SIGTERM } from "./exit-codes.js";
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const packageJson = require("../package.json");
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
let signalCount = 0;
|
|
15
|
+
/** Set once, by whichever of SIGINT/SIGTERM fires first — that is the exit code used once the aborted run actually stops (cli.md §6). */
|
|
16
|
+
let firstSignalExitCode;
|
|
17
|
+
function onSignal(exitCode) {
|
|
18
|
+
signalCount += 1;
|
|
19
|
+
if (signalCount === 1) {
|
|
20
|
+
firstSignalExitCode = exitCode;
|
|
21
|
+
controller.abort();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// A second signal during cleanup exits immediately (cli.md §6), using
|
|
25
|
+
// whichever code corresponds to *this* second signal.
|
|
26
|
+
process.exit(exitCode);
|
|
27
|
+
}
|
|
28
|
+
process.on("SIGINT", () => onSignal(EXIT_SIGINT));
|
|
29
|
+
process.on("SIGTERM", () => onSignal(EXIT_SIGTERM));
|
|
30
|
+
async function main() {
|
|
31
|
+
const result = await runVueHtmlBridgeCli({
|
|
32
|
+
argv: process.argv.slice(2),
|
|
33
|
+
cwd: process.cwd(),
|
|
34
|
+
writeStdout(chunk) {
|
|
35
|
+
process.stdout.write(chunk);
|
|
36
|
+
},
|
|
37
|
+
writeStderr(chunk) {
|
|
38
|
+
process.stderr.write(chunk);
|
|
39
|
+
},
|
|
40
|
+
signal: controller.signal,
|
|
41
|
+
version: packageJson.version,
|
|
42
|
+
stdoutIsTty: process.stdout.isTTY === true,
|
|
43
|
+
noColorEnv: process.env["NO_COLOR"] !== undefined,
|
|
44
|
+
});
|
|
45
|
+
if (result.interrupted) {
|
|
46
|
+
process.exit(firstSignalExitCode ?? EXIT_SIGINT);
|
|
47
|
+
}
|
|
48
|
+
process.exit(result.exitCode);
|
|
49
|
+
}
|
|
50
|
+
main().catch((error) => {
|
|
51
|
+
process.stderr.write(`vue-html-bridge: internal error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
52
|
+
process.exit(2);
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,6EAA6E;AAC7E,sEAAsE;AACtE,6EAA6E;AAC7E,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAEtE,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;AACzC,IAAI,WAAW,GAAG,CAAC,CAAC;AACpB,yIAAyI;AACzI,IAAI,mBAAuC,CAAC;AAE5C,SAAS,QAAQ,CAAC,QA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AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC/F,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AdapterModuleResolver } from "@vue-html-bridge/adapter-loader";
|
|
2
|
+
import type { AdapterLogger, HtmlValidatorAdapter } from "@vue-html-bridge/validator-api";
|
|
3
|
+
export interface CliIo {
|
|
4
|
+
argv: readonly string[];
|
|
5
|
+
/** Absolute. */
|
|
6
|
+
cwd: string;
|
|
7
|
+
writeStdout: (chunk: string) => void;
|
|
8
|
+
writeStderr: (chunk: string) => void;
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
/** The package's own version, for `--version` (bin.ts reads it from package.json). */
|
|
11
|
+
version: string;
|
|
12
|
+
/** cli.md §4.2: color is used only when stdout is a TTY and `NO_COLOR` is unset (and `--no-color` isn't given). */
|
|
13
|
+
stdoutIsTty?: boolean;
|
|
14
|
+
noColorEnv?: boolean;
|
|
15
|
+
/** Injectable for tests (adapter-loader.md §6 item 8's shared contract fixture, adapter-testkit's fake adapter). */
|
|
16
|
+
moduleResolver?: AdapterModuleResolver;
|
|
17
|
+
builtins?: ReadonlyMap<string, HtmlValidatorAdapter<unknown>>;
|
|
18
|
+
logger?: AdapterLogger;
|
|
19
|
+
}
|
|
20
|
+
export type CliInvocationResult = {
|
|
21
|
+
interrupted: true;
|
|
22
|
+
} | {
|
|
23
|
+
interrupted: false;
|
|
24
|
+
exitCode: number;
|
|
25
|
+
};
|
|
26
|
+
export declare function runVueHtmlBridgeCli(io: CliIo): Promise<CliInvocationResult>;
|
|
27
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAQxC,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,MAAM,EAAE,WAAW,CAAC;IACpB,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,mHAAmH;IACnH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oHAAoH;IACpH,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,MAAM,mBAAmB,GAC7B;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAOnE,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,KAAK,GACR,OAAO,CAAC,mBAAmB,CAAC,CAwF9B"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Top-level orchestration (cli.md §11): argument parsing dispatch,
|
|
2
|
+
// --help/--version, usage errors, settings sourcing, and handing off to
|
|
3
|
+
// runner.ts. bin.ts owns only the real process/stdio/signal wiring; this
|
|
4
|
+
// module is what a test drives directly, with injectable I/O.
|
|
5
|
+
import { realpath } from "node:fs/promises";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
import { EXIT_RUN_ERROR, EXIT_SUCCESS } from "./exit-codes.js";
|
|
8
|
+
import { HELP_TEXT, parseArgv } from "./options.js";
|
|
9
|
+
import { createNdjsonRenderer } from "./output/ndjson.js";
|
|
10
|
+
import { createTextRenderer } from "./output/text.js";
|
|
11
|
+
import { runCli } from "./runner.js";
|
|
12
|
+
import { resolveCliSettings } from "./settings-resolution.js";
|
|
13
|
+
function formatSettingsIssue(issue) {
|
|
14
|
+
const location = issue.sourcePath ? `${issue.sourcePath}: ` : "";
|
|
15
|
+
return `${issue.severity}: ${location}${issue.message}`;
|
|
16
|
+
}
|
|
17
|
+
export async function runVueHtmlBridgeCli(io) {
|
|
18
|
+
const parsed = parseArgv(io.argv);
|
|
19
|
+
if (parsed.kind === "error") {
|
|
20
|
+
io.writeStderr(`vue-html-bridge: ${parsed.message}\n\n${HELP_TEXT}`);
|
|
21
|
+
return { interrupted: false, exitCode: EXIT_RUN_ERROR };
|
|
22
|
+
}
|
|
23
|
+
const options = parsed.options;
|
|
24
|
+
if (options.help) {
|
|
25
|
+
io.writeStdout(HELP_TEXT);
|
|
26
|
+
return { interrupted: false, exitCode: EXIT_SUCCESS };
|
|
27
|
+
}
|
|
28
|
+
if (options.version) {
|
|
29
|
+
io.writeStdout(`${io.version}\n`);
|
|
30
|
+
return { interrupted: false, exitCode: EXIT_SUCCESS };
|
|
31
|
+
}
|
|
32
|
+
const rawWorkspaceRoot = options.workspaceRoot !== undefined
|
|
33
|
+
? resolve(io.cwd, options.workspaceRoot)
|
|
34
|
+
: io.cwd;
|
|
35
|
+
// Canonicalize once, up front: every downstream absolute-path comparison
|
|
36
|
+
// (enumeration's workspace-boundary check, workspace-relative output
|
|
37
|
+
// paths, the dedup-by-real-path rule in cli.md §6) assumes `workspaceRoot`
|
|
38
|
+
// and `cwd` are already real paths — e.g. on macOS, the OS temp directory
|
|
39
|
+
// is itself a symlink (/var -> /private/var), and comparing an
|
|
40
|
+
// un-resolved root against realpath()-resolved file paths would otherwise
|
|
41
|
+
// produce a spurious "outside the workspace" escape in relative-path math.
|
|
42
|
+
let workspaceRoot;
|
|
43
|
+
let cwd;
|
|
44
|
+
try {
|
|
45
|
+
[workspaceRoot, cwd] = await Promise.all([
|
|
46
|
+
realpath(rawWorkspaceRoot),
|
|
47
|
+
realpath(io.cwd),
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
io.writeStderr(`vue-html-bridge: error: could not resolve the workspace root "${rawWorkspaceRoot}": ${error instanceof Error ? error.message : String(error)}\n`);
|
|
52
|
+
return { interrupted: false, exitCode: EXIT_RUN_ERROR };
|
|
53
|
+
}
|
|
54
|
+
const settingsResult = await resolveCliSettings({
|
|
55
|
+
workspaceRoot,
|
|
56
|
+
cwd,
|
|
57
|
+
configPath: options.configPath,
|
|
58
|
+
flagsInput: options.settingsInput,
|
|
59
|
+
validatorOps: options.validatorOps,
|
|
60
|
+
untrusted: options.untrusted,
|
|
61
|
+
});
|
|
62
|
+
if (settingsResult.kind === "fatal") {
|
|
63
|
+
for (const issue of settingsResult.issues) {
|
|
64
|
+
io.writeStderr(`${formatSettingsIssue(issue)}\n`);
|
|
65
|
+
}
|
|
66
|
+
return { interrupted: false, exitCode: EXIT_RUN_ERROR };
|
|
67
|
+
}
|
|
68
|
+
for (const warning of settingsResult.warnings) {
|
|
69
|
+
io.writeStderr(`${formatSettingsIssue(warning)}\n`);
|
|
70
|
+
}
|
|
71
|
+
const color = !options.noColor && io.stdoutIsTty === true && io.noColorEnv !== true;
|
|
72
|
+
const renderer = options.format === "ndjson"
|
|
73
|
+
? createNdjsonRenderer(io.writeStdout)
|
|
74
|
+
: createTextRenderer(io.writeStdout, io.writeStderr, { color });
|
|
75
|
+
const result = await runCli({
|
|
76
|
+
workspaceRoot,
|
|
77
|
+
cwd,
|
|
78
|
+
positionalArgs: options.positionalArgs,
|
|
79
|
+
settings: settingsResult.settings,
|
|
80
|
+
workspaceTrusted: settingsResult.workspaceTrusted,
|
|
81
|
+
failOn: options.failOn,
|
|
82
|
+
signal: io.signal,
|
|
83
|
+
renderer,
|
|
84
|
+
notice: io.writeStderr,
|
|
85
|
+
moduleResolver: io.moduleResolver,
|
|
86
|
+
builtins: io.builtins,
|
|
87
|
+
logger: io.logger,
|
|
88
|
+
});
|
|
89
|
+
if (result.interrupted)
|
|
90
|
+
return { interrupted: true };
|
|
91
|
+
return { interrupted: false, exitCode: result.exitCode };
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,wEAAwE;AACxE,yEAAyE;AACzE,8DAA8D;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAuB9D,SAAS,mBAAmB,CAAC,KAAoB;IAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,OAAO,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AC;IACxE,MAAM,QAAQ,GACZ,OAAO,CAAC,MAAM,KAAK,QAAQ;QACzB,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC,WAAW,CAAC;QACtC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;QAC1B,aAAa;QACb,GAAG;QACH,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,QAAQ,EAAE,cAAc,CAAC,QAAQ;QACjC,gBAAgB,EAAE,cAAc,CAAC,gBAAgB;QACjD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,QAAQ;QACR,MAAM,EAAE,EAAE,CAAC,WAAW;QACtB,cAAc,EAAE,EAAE,CAAC,cAAc;QACjC,QAAQ,EAAE,EAAE,CAAC,QAAQ;QACrB,MAAM,EAAE,EAAE,CAAC,MAAM;KAClB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,WAAW;QAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACrD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SourceDiagnostic } from "@vue-html-bridge/analyzer";
|
|
2
|
+
import { type LineIndex } from "./line-index.js";
|
|
3
|
+
import type { CliDiagnostic } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* `relatedInformation` is restricted to the same file/URI in the initial
|
|
6
|
+
* version (analyzer.md §6.1, mirrored by language-server's diagnostics.ts) —
|
|
7
|
+
* there is no cross-file mapping yet — so every related entry uses the same
|
|
8
|
+
* `filePath`/`index` as the primary diagnostic.
|
|
9
|
+
*/
|
|
10
|
+
export declare function projectDiagnostic(diagnostic: SourceDiagnostic, index: LineIndex, filePath: string): CliDiagnostic;
|
|
11
|
+
/** cli.md §7: "Diagnostic ordering within a file is deterministic: range, severity, origin, adapterId, code, message." */
|
|
12
|
+
export declare function sortCliDiagnostics(diagnostics: readonly CliDiagnostic[]): readonly CliDiagnostic[];
|
|
13
|
+
/**
|
|
14
|
+
* language-server.md §7.3's session-failure detection (server.ts's
|
|
15
|
+
* `SESSION_FAILURE_CODE`), reused verbatim (cli.md §8): a `SourceDiagnostic`
|
|
16
|
+
* with `origin: "adapter"` whose code matches this shape is a session-level
|
|
17
|
+
* adapter failure that the analyzer places on *every* analyzed file. The CLI
|
|
18
|
+
* reports it once at run level instead of repeating it per file.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SESSION_FAILURE_CODE: RegExp;
|
|
21
|
+
export declare function isSessionFailureDiagnostic(diagnostic: SourceDiagnostic): boolean;
|
|
22
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,YAAY,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,MAAM,GACf,aAAa,CAyBf;AAyBD,0HAA0H;AAC1H,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,SAAS,aAAa,EAAE,GACpC,SAAS,aAAa,EAAE,CAW1B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QACgC,CAAC;AAElE,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAKT"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {} from "./line-index.js";
|
|
2
|
+
/**
|
|
3
|
+
* `relatedInformation` is restricted to the same file/URI in the initial
|
|
4
|
+
* version (analyzer.md §6.1, mirrored by language-server's diagnostics.ts) —
|
|
5
|
+
* there is no cross-file mapping yet — so every related entry uses the same
|
|
6
|
+
* `filePath`/`index` as the primary diagnostic.
|
|
7
|
+
*/
|
|
8
|
+
export function projectDiagnostic(diagnostic, index, filePath) {
|
|
9
|
+
return {
|
|
10
|
+
severity: diagnostic.severity,
|
|
11
|
+
code: diagnostic.code,
|
|
12
|
+
message: diagnostic.message,
|
|
13
|
+
origin: diagnostic.origin,
|
|
14
|
+
...(diagnostic.adapterId !== undefined
|
|
15
|
+
? { adapterId: diagnostic.adapterId }
|
|
16
|
+
: {}),
|
|
17
|
+
...(diagnostic.codeDescriptionHref !== undefined
|
|
18
|
+
? { codeDescriptionHref: diagnostic.codeDescriptionHref }
|
|
19
|
+
: {}),
|
|
20
|
+
range: {
|
|
21
|
+
start: diagnostic.sourceRange.start,
|
|
22
|
+
end: diagnostic.sourceRange.end,
|
|
23
|
+
},
|
|
24
|
+
position: index.toRangePosition(diagnostic.sourceRange),
|
|
25
|
+
relatedInformation: diagnostic.relatedInformation.map((related) => projectRelated(related, index, filePath)),
|
|
26
|
+
evidence: {
|
|
27
|
+
variantCount: diagnostic.evidence.variantCount,
|
|
28
|
+
truncated: diagnostic.evidence.truncated,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function projectRelated(related, index, filePath) {
|
|
33
|
+
return {
|
|
34
|
+
path: filePath,
|
|
35
|
+
range: {
|
|
36
|
+
start: related.sourceRange.start,
|
|
37
|
+
end: related.sourceRange.end,
|
|
38
|
+
},
|
|
39
|
+
position: index.toRangePosition(related.sourceRange),
|
|
40
|
+
message: related.message,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const SEVERITY_ORDER = {
|
|
44
|
+
error: 0,
|
|
45
|
+
warning: 1,
|
|
46
|
+
info: 2,
|
|
47
|
+
hint: 3,
|
|
48
|
+
};
|
|
49
|
+
/** cli.md §7: "Diagnostic ordering within a file is deterministic: range, severity, origin, adapterId, code, message." */
|
|
50
|
+
export function sortCliDiagnostics(diagnostics) {
|
|
51
|
+
return [...diagnostics].sort((a, b) => a.range.start - b.range.start ||
|
|
52
|
+
a.range.end - b.range.end ||
|
|
53
|
+
SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] ||
|
|
54
|
+
a.origin.localeCompare(b.origin) ||
|
|
55
|
+
(a.adapterId ?? "").localeCompare(b.adapterId ?? "") ||
|
|
56
|
+
a.code.localeCompare(b.code) ||
|
|
57
|
+
a.message.localeCompare(b.message));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* language-server.md §7.3's session-failure detection (server.ts's
|
|
61
|
+
* `SESSION_FAILURE_CODE`), reused verbatim (cli.md §8): a `SourceDiagnostic`
|
|
62
|
+
* with `origin: "adapter"` whose code matches this shape is a session-level
|
|
63
|
+
* adapter failure that the analyzer places on *every* analyzed file. The CLI
|
|
64
|
+
* reports it once at run level instead of repeating it per file.
|
|
65
|
+
*/
|
|
66
|
+
export const SESSION_FAILURE_CODE = /^adapter\/[^/]+\/(configuration-error|validator-unavailable)$/;
|
|
67
|
+
export function isSessionFailureDiagnostic(diagnostic) {
|
|
68
|
+
return (diagnostic.origin === "adapter" &&
|
|
69
|
+
SESSION_FAILURE_CODE.test(diagnostic.code));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAYA,OAAO,EAAkB,MAAM,iBAAiB,CAAC;AAGjD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA4B,EAC5B,KAAgB,EAChB,QAAgB;IAEhB,OAAO;QACL,QAAQ,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olute; positional arguments are resolved relative to this (cli.md §2). */
|
|
6
|
+
cwd: string;
|
|
7
|
+
positionalArgs: readonly string[];
|
|
8
|
+
include: readonly string[];
|
|
9
|
+
exclude: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export interface EnumerateFilesResult {
|
|
12
|
+
/** Absolute real paths, sorted by workspace-relative "/"-separated path. */
|
|
13
|
+
files: readonly string[];
|
|
14
|
+
/** Boundary violations (cli.md §6): one per out-of-root positional argument. */
|
|
15
|
+
errors: readonly RunLevelError[];
|
|
16
|
+
}
|
|
17
|
+
export declare function enumerateFiles(options: EnumerateFilesOptions): Promise<EnumerateFilesResult>;
|
|
18
|
+
//# sourceMappingURL=enumerate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerate.d.ts","sourceRoot":"","sources":["../src/enumerate.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,qBAAqB;IACpC,gBAAgB;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,gFAAgF;IAChF,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;CAClC;AAwHD,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAoE/B"}
|