diff --git a/.github/workflows/ci-js.yml b/.github/workflows/ci-js.yml index 5f64bc0b..3a85cf5a 100644 --- a/.github/workflows/ci-js.yml +++ b/.github/workflows/ci-js.yml @@ -1,10 +1,10 @@ -on: [push, pull_request] +on: [push] name: CI (JS) jobs: test: - name: Check + name: Lint/Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index b520557d..901ab6e8 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -2,6 +2,7 @@ on: push: paths: - src-tauri/** + - .github/workflows/** name: CI (Rust) @@ -11,7 +12,7 @@ defaults: jobs: test: - name: Test + name: Check/Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -21,10 +22,42 @@ jobs: - run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev - - uses: actions-rs/toolchain@v1 + - name: Install Rust + uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + toolchain: ${{ inputs.rust-version }} override: true - - run: cargo check + components: rustfmt, clippy + - name: Set up cargo cache + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + - name: Lint + run: | + cargo fmt --all -- --check + cargo clippy -- -D warnings + - name: Install cargo check tools + run: | + cargo install --locked cargo-deny || true + cargo install --locked cargo-outdated || true + cargo install --locked cargo-udeps || true + cargo install --locked cargo-audit || true + cargo install --locked cargo-pants || true + - name: Check + run: | + cargo deny check + cargo outdated --exit-code 1 + cargo udeps + rm -rf ~/.cargo/advisory-db + cargo audit + cargo pants - run: cargo test --all diff --git a/.gitignore b/.gitignore index 394cf269..05eba812 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ dist-ssr *.sqlite *.sqlite-* -.cargo \ No newline at end of file +.cargo +plugins/**/build diff --git a/plugins/exporter-curl/vite.config.js b/plugins/exporter-curl/vite.config.js index 291b5b5e..787b3345 100644 --- a/plugins/exporter-curl/vite.config.js +++ b/plugins/exporter-curl/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/exporter-curl'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/plugins/filter-jsonpath/src/index.js b/plugins/filter-jsonpath/src/index.js index a773c12a..78973419 100644 --- a/plugins/filter-jsonpath/src/index.js +++ b/plugins/filter-jsonpath/src/index.js @@ -1,6 +1,6 @@ import jp from 'jsonpath'; -export function pluginHookResponseFilter(filter, text) { +export function pluginHookResponseFilter(ctx, filter, text) { let parsed; try { parsed = JSON.parse(text); diff --git a/plugins/filter-jsonpath/vite.config.js b/plugins/filter-jsonpath/vite.config.js index 17baae7e..175fa69e 100644 --- a/plugins/filter-jsonpath/vite.config.js +++ b/plugins/filter-jsonpath/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/filter-jsonpath'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/plugins/filter-xpath/src/index.js b/plugins/filter-xpath/src/index.js index 922bba72..8ad18313 100644 --- a/plugins/filter-xpath/src/index.js +++ b/plugins/filter-xpath/src/index.js @@ -1,7 +1,7 @@ import xpath from 'xpath'; import { DOMParser } from '@xmldom/xmldom'; -export function pluginHookResponseFilter(filter, text) { +export function pluginHookResponseFilter(ctx, filter, text) { const doc = new DOMParser().parseFromString(text, 'text/xml'); const filtered = `${xpath.select(filter, doc)}`; return { filtered }; diff --git a/plugins/filter-xpath/vite.config.js b/plugins/filter-xpath/vite.config.js index 18a43a2a..175fa69e 100644 --- a/plugins/filter-xpath/vite.config.js +++ b/plugins/filter-xpath/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/filter-xpath'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/plugins/importer-curl/src/index.ts b/plugins/importer-curl/src/index.ts index cb3a08f6..07a50162 100644 --- a/plugins/importer-curl/src/index.ts +++ b/plugins/importer-curl/src/index.ts @@ -43,7 +43,7 @@ type Pair = string | boolean; type PairsByName = Record; -export function pluginHookImport(rawData: string) { +export function pluginHookImport(ctx: any, rawData: string) { if (!rawData.match(/^\s*curl /)) { return null; } diff --git a/plugins/importer-curl/vite.config.js b/plugins/importer-curl/vite.config.js index 204e4457..787b3345 100644 --- a/plugins/importer-curl/vite.config.js +++ b/plugins/importer-curl/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/importer-curl'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/plugins/importer-insomnia/src/index.ts b/plugins/importer-insomnia/src/index.ts index a9146a6d..152c2328 100644 --- a/plugins/importer-insomnia/src/index.ts +++ b/plugins/importer-insomnia/src/index.ts @@ -5,7 +5,7 @@ import { HttpRequest, Workspace, } from '../../../src-web/lib/models'; -import { parse as parseYaml } from 'yaml'; +import '../../../src-web/plugin/runtime.d.ts'; type AtLeast = Partial & Pick; @@ -17,7 +17,7 @@ export interface ExportResources { folders: AtLeast[]; } -export function pluginHookImport(contents: string) { +export function pluginHookImport(ctx: YaakContext, contents: string) { let parsed: any; try { @@ -25,8 +25,10 @@ export function pluginHookImport(contents: string) { } catch (e) {} try { - parsed = parseYaml(contents); - } catch (e) {} + parsed = parsed ?? YAML.parse(contents); + } catch (e) { + console.log('FAILED', e); + } if (!isJSObject(parsed)) return; if (!Array.isArray(parsed.resources)) return; diff --git a/plugins/importer-insomnia/vite.config.js b/plugins/importer-insomnia/vite.config.js index 9d76fdb9..787b3345 100644 --- a/plugins/importer-insomnia/vite.config.js +++ b/plugins/importer-insomnia/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/importer-insomnia'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/plugins/importer-postman/src/index.ts b/plugins/importer-postman/src/index.ts index b0ddbffa..fc529cde 100644 --- a/plugins/importer-postman/src/index.ts +++ b/plugins/importer-postman/src/index.ts @@ -13,7 +13,11 @@ interface ExportResources { folders: AtLeast[]; } -export function pluginHookImport(contents: string): { resources: ExportResources } | undefined { +export function pluginHookImport( + ctx: any, + contents: string, +): { resources: ExportResources } | undefined { + console.log('CTX', ctx); const root = parseJSONToRecord(contents); if (root == null) return; diff --git a/plugins/importer-postman/tests/index.test.ts b/plugins/importer-postman/tests/index.test.ts index 2de5459e..ce294cb7 100644 --- a/plugins/importer-postman/tests/index.test.ts +++ b/plugins/importer-postman/tests/index.test.ts @@ -23,7 +23,7 @@ describe('importer-postman', () => { for (const fixture of fixtures) { test('Imports ' + fixture, () => { const contents = fs.readFileSync(path.join(p, fixture), 'utf-8'); - const imported = pluginHookImport(contents); + const imported = pluginHookImport({}, contents); const folder0 = newId('folder'); const folder1 = newId('folder'); expect(imported).toEqual({ diff --git a/plugins/importer-postman/vite.config.js b/plugins/importer-postman/vite.config.js index 1c261948..787b3345 100644 --- a/plugins/importer-postman/vite.config.js +++ b/plugins/importer-postman/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/importer-postman'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/plugins/importer-yaak/src/index.ts b/plugins/importer-yaak/src/index.ts index 7b349ef0..f50a13fd 100644 --- a/plugins/importer-yaak/src/index.ts +++ b/plugins/importer-yaak/src/index.ts @@ -1,4 +1,4 @@ -export function pluginHookImport(contents: string) { +export function pluginHookImport(ctx: any, contents: string) { let parsed; try { parsed = JSON.parse(contents); @@ -18,7 +18,7 @@ export function pluginHookImport(contents: string) { // Migrate v1 to v2 -- changes requests to httpRequests if ('requests' in parsed.resources) { parsed.resources.httpRequests = parsed.resources.requests; - delete parsed.resources.requests; + delete parsed.resources['requests']; } return { resources: parsed.resources }; // Should already be in the correct format diff --git a/plugins/importer-yaak/vite.config.js b/plugins/importer-yaak/vite.config.js index b4fd6920..787b3345 100644 --- a/plugins/importer-yaak/vite.config.js +++ b/plugins/importer-yaak/vite.config.js @@ -8,6 +8,8 @@ export default defineConfig({ fileName: 'index', formats: ['es'], }, - outDir: resolve(__dirname, '../../src-tauri/plugins/importer-yaak'), + emptyOutDir: true, + sourcemap: true, + outDir: resolve(__dirname, 'build'), }, }); diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index c487b78e..a5deb8ac 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.22.0" @@ -160,6 +170,18 @@ dependencies = [ "zbus", ] +[[package]] +name = "ast_node" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab31376d309dd3bfc9cfb3c11c93ce0e0741bbe0354b20e7f8c60b044730b79" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.66", +] + [[package]] name = "async-broadcast" version = "0.7.1" @@ -432,12 +454,54 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64-simd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5" +dependencies = [ + "simd-abstraction", +] + [[package]] name = "base64ct" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "better_scoped_tls" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794edcc9b3fb07bb4aecaa11f093fd45663b4feadb782d68303a2268bc2701de" +dependencies = [ + "scoped-tls", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bit_field" version = "0.10.2" @@ -508,141 +572,6 @@ dependencies = [ "piper", ] -[[package]] -name = "boa_ast" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6fb81ca0f301f33aff7401e2ffab37dc9e0e4a1cf0ccf6b34f4d9e60aa0682" -dependencies = [ - "bitflags 2.5.0", - "boa_interner", - "boa_macros", - "indexmap 2.2.6", - "num-bigint", - "rustc-hash", -] - -[[package]] -name = "boa_engine" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600e4e4a65b26efcef08a7b1cf2899d3845a32e82e067ee3b75eaf7e413ff31c" -dependencies = [ - "arrayvec", - "bitflags 2.5.0", - "boa_ast", - "boa_gc", - "boa_interner", - "boa_macros", - "boa_parser", - "boa_profiler", - "bytemuck", - "cfg-if", - "dashmap", - "fast-float", - "hashbrown 0.14.5", - "icu_normalizer", - "indexmap 2.2.6", - "intrusive-collections", - "itertools", - "num-bigint", - "num-integer", - "num-traits", - "num_enum 0.7.2", - "once_cell", - "paste", - "pollster", - "portable-atomic", - "rand 0.8.5", - "regress", - "rustc-hash", - "ryu-js", - "serde", - "serde_json", - "sptr", - "static_assertions", - "tap", - "thin-vec", - "thiserror", - "time", -] - -[[package]] -name = "boa_gc" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c055ef3cd87ea7db014779195bc90c6adfc35de4902e3b2fe587adecbd384578" -dependencies = [ - "boa_macros", - "boa_profiler", - "hashbrown 0.14.5", - "thin-vec", -] - -[[package]] -name = "boa_interner" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cacc9caf022d92195c827a3e5bf83f96089d4bfaff834b359ac7b6be46e9187" -dependencies = [ - "boa_gc", - "boa_macros", - "hashbrown 0.14.5", - "indexmap 2.2.6", - "once_cell", - "phf 0.11.2", - "rustc-hash", - "static_assertions", -] - -[[package]] -name = "boa_macros" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6be9c93793b60dac381af475b98634d4b451e28336e72218cad9a20176218dbc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - -[[package]] -name = "boa_parser" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8592556849f0619ed142ce2b3a19086769314a8d657f93a5765d06dbce4818" -dependencies = [ - "bitflags 2.5.0", - "boa_ast", - "boa_interner", - "boa_macros", - "boa_profiler", - "fast-float", - "icu_properties", - "num-bigint", - "num-traits", - "regress", - "rustc-hash", -] - -[[package]] -name = "boa_profiler" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d8372f2d5cbac600a260de87877141b42da1e18d2c7a08ccb493a49cbd55c0" - -[[package]] -name = "boa_runtime" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088ac38072a9517691478d33c4385cfd67657ec584b57f8397820a55b660990e" -dependencies = [ - "boa_engine", - "boa_gc", - "rustc-hash", -] - [[package]] name = "borsh" version = "1.3.0" @@ -753,20 +682,6 @@ name = "bytemuck" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] [[package]] name = "byteorder" @@ -834,7 +749,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -1023,6 +938,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cooked-waker" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147be55d677052dabc6b22252d5dd0fd4c29c8c27aa4f2fbef0f94aa003b406f" + [[package]] name = "cookie" version = "0.17.0" @@ -1268,6 +1189,18 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "data-url" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" + [[package]] name = "datetime" version = "0.5.2" @@ -1282,6 +1215,148 @@ dependencies = [ "winapi", ] +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "serde", + "uuid", +] + +[[package]] +name = "deno_ast" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32edef567e3090862e865c75628f4d35ace80ca90e0fc5263a7d10fa307ae899" +dependencies = [ + "anyhow", + "base64 0.21.7", + "deno_media_type", + "deno_terminal", + "dprint-swc-ext", + "once_cell", + "percent-encoding", + "serde", + "swc_atoms", + "swc_common", + "swc_config", + "swc_config_macro", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_codegen_macros", + "swc_ecma_loader", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", + "swc_ecma_transforms_proposal", + "swc_ecma_transforms_react", + "swc_ecma_transforms_typescript", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_eq_ignore_macros", + "swc_macros_common", + "swc_visit", + "swc_visit_macros", + "text_lines", + "thiserror", + "unicode-width", + "url", +] + +[[package]] +name = "deno_console" +version = "0.155.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1010ed683985a70fce7f449c39b1d1a62675ab178b86f70eff954a161aa6dcaf" +dependencies = [ + "deno_core", +] + +[[package]] +name = "deno_core" +version = "0.284.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a5c809e81be26fcfbbce4275573251f6a156137b67059889e9e38f73e75b63" +dependencies = [ + "anyhow", + "bincode", + "bit-set", + "bit-vec", + "bytes", + "cooked-waker", + "deno_core_icudata", + "deno_ops", + "deno_unsync", + "futures", + "libc", + "memoffset", + "parking_lot", + "pin-project", + "serde", + "serde_json", + "serde_v8", + "smallvec", + "sourcemap", + "static_assertions", + "tokio", + "url", + "v8", +] + +[[package]] +name = "deno_core_icudata" +version = "0.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13951ea98c0a4c372f162d669193b4c9d991512de9f2381dd161027f34b26b1" + +[[package]] +name = "deno_media_type" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8978229b82552bf8457a0125aa20863f023619cfc21ebb007b1e571d68fd85b" +dependencies = [ + "data-url", + "serde", + "url", +] + +[[package]] +name = "deno_ops" +version = "0.160.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "517e54d41a2da6a69b8f534294334d79d9115ddd43aea88a5ceefdb717e6d85e" +dependencies = [ + "proc-macro-rules", + "proc-macro2", + "quote", + "strum", + "strum_macros", + "syn 2.0.66", + "thiserror", +] + +[[package]] +name = "deno_terminal" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6337d4e7f375f8b986409a76fbeecfa4bd8a1343e63355729ae4befa058eaf" +dependencies = [ + "once_cell", + "termcolor", +] + +[[package]] +name = "deno_unsync" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7557a5e9278b9a5cc8056dc37062ea4344770bda4eeb5973c7cbb7ebf636b9a4" +dependencies = [ + "tokio", +] + [[package]] name = "der" version = "0.7.9" @@ -1334,7 +1409,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -1465,6 +1540,21 @@ dependencies = [ "serde", ] +[[package]] +name = "dprint-swc-ext" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "019d17f2c2457c5a70a7cf4505b1a562ca8ab168c0ac0c005744efbd29fcb8fe" +dependencies = [ + "num-bigint", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "text_lines", +] + [[package]] name = "dtoa" version = "1.0.9" @@ -1509,7 +1599,7 @@ checksum = "c6985554d0688b687c5cb73898a34fbe3ad6c24c58c238a4d91d5e840670ee9d" dependencies = [ "cc", "memchr", - "rustc_version", + "rustc_version 0.4.0", "toml 0.8.2", "vswhom", "winreg 0.52.0", @@ -1643,12 +1733,6 @@ dependencies = [ "zune-inflate", ] -[[package]] -name = "fast-float" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" - [[package]] name = "fastrand" version = "2.1.0" @@ -1681,7 +1765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ "memoffset", - "rustc_version", + "rustc_version 0.4.0", ] [[package]] @@ -1774,6 +1858,27 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "from_variant" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc9cc75639b041067353b9bce2450d6847e547276c6fbe4487d7407980e07db" +dependencies = [ + "proc-macro2", + "swc_macros_common", + "syn 2.0.66", +] + +[[package]] +name = "fslock" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "funty" version = "2.0.0" @@ -1790,6 +1895,21 @@ dependencies = [ "new_debug_unreachable", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.30" @@ -1876,6 +1996,7 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -2236,6 +2357,15 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "gzip-header" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95cc527b92e6029a62960ad99aa8a6660faa4555fe5f731aab13aa6a921795a2" +dependencies = [ + "crc32fast", +] + [[package]] name = "h2" version = "0.3.26" @@ -2356,6 +2486,20 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "hstr" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96274be293b8877e61974a607105d09c84caebe9620b47774aa8a6b942042dd4" +dependencies = [ + "hashbrown 0.14.5", + "new_debug_unreachable", + "once_cell", + "phf 0.11.2", + "rustc-hash", + "triomphe", +] + [[package]] name = "html5ever" version = "0.26.0" @@ -2598,124 +2742,6 @@ dependencies = [ "png", ] -[[package]] -name = "icu_collections" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "137d96353afc8544d437e8a99eceb10ab291352699573b0de5b08bda38c78c60" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0aa2536adc14c07e2a521e95512b75ed8ef832f0fdf9299d4a0a45d2be2a9d" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c17d8f6524fdca4471101dd71f0a132eb6382b5d6d7f2970441cb25f6f435a" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c6c3e8bf9580e2dafee8de6f9ec14826aaf359787789c7724f1f85f47d3dc" - -[[package]] -name = "icu_normalizer" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accb85c5b2e76f8dade22978b3795ae1e550198c6cfc7e915144e17cd6e2ab56" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3744fecc0df9ce19999cdaf1f9f3a48c253431ce1d67ef499128fe9d0b607ab" - -[[package]] -name = "icu_properties" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8173ba888885d250016e957b8ebfd5a65cdb690123d8833a19f6833f9c2b579" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70a8b51ee5dd4ff8f20ee9b1dd1bc07afc110886a3747b1fec04cc6e5a15815" - -[[package]] -name = "icu_provider" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba58e782287eb6950247abbf11719f83f5d4e4a5c1f2cd490d30a334bc47c2f4" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2abdd3a62551e8337af119c5899e600ca0c88ec8f23a46c60ba216c803dcf1a" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -2742,6 +2768,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + [[package]] name = "image" version = "0.24.9" @@ -2813,15 +2845,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "intrusive-collections" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b694dc9f70c3bda874626d2aed13b780f137aab435f4e9814121955cf706122e" -dependencies = [ - "memoffset", -] - [[package]] name = "ipnet" version = "2.9.0" @@ -2837,6 +2860,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "is-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a85abdc13717906baccb5a1e435556ce0df215f242892f721dff62bf25288f" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "is-terminal" version = "0.4.12" @@ -3090,12 +3125,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "locale" version = "0.2.2" @@ -3390,6 +3419,7 @@ checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ "num-integer", "num-traits", + "rand 0.8.5", "serde", ] @@ -3781,6 +3811,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "outref" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" + [[package]] name = "overload" version = "0.1.1" @@ -4123,18 +4159,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "pollster" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" - -[[package]] -name = "portable-atomic" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" - [[package]] name = "powerfmt" version = "0.2.0" @@ -4203,6 +4227,29 @@ version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" +[[package]] +name = "proc-macro-rules" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" +dependencies = [ + "proc-macro-rules-macros", + "proc-macro2", + "syn 2.0.66", +] + +[[package]] +name = "proc-macro-rules-macros" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "207fffb0fe655d1d47f6af98cc2793405e85929bdbc420d685554ff07be27ac7" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "proc-macro2" version = "1.0.85" @@ -4276,6 +4323,15 @@ version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "ptr_meta" version = "0.1.4" @@ -4531,16 +4587,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "regress" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eae2a1ebfecc58aff952ef8ccd364329abe627762f5bf09ff42eb9d98522479" -dependencies = [ - "hashbrown 0.14.5", - "memchr", -] - [[package]] name = "rend" version = "0.4.2" @@ -4777,13 +4823,22 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.23", ] [[package]] @@ -5016,6 +5071,15 @@ dependencies = [ "thin-slice", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.23" @@ -5025,6 +5089,12 @@ dependencies = [ "serde", ] +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.203" @@ -5072,6 +5142,7 @@ version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ + "indexmap 2.2.6", "itoa 1.0.11", "ryu", "serde", @@ -5109,6 +5180,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_v8" +version = "0.193.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ec612dfc7ab70330b5405e8015b25e637bbfe1d79c4bd173557933aea66e76" +dependencies = [ + "num-bigint", + "serde", + "smallvec", + "thiserror", + "v8", +] + [[package]] name = "serde_with" version = "3.8.1" @@ -5139,6 +5223,19 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.2.6", + "itoa 1.0.11", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "serialize-to-javascript" version = "0.1.1" @@ -5171,6 +5268,17 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "sha-1" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha1" version = "0.10.6" @@ -5231,6 +5339,15 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simd-abstraction" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987" +dependencies = [ + "outref", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -5264,6 +5381,17 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check 0.9.4", +] + [[package]] name = "socket2" version = "0.5.7" @@ -5324,6 +5452,25 @@ dependencies = [ "system-deps", ] +[[package]] +name = "sourcemap" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "208d40b9e8cad9f93613778ea295ed8f3c2b1824217c6cfc7219d3f6f45b96d4" +dependencies = [ + "base64-simd", + "bitvec", + "data-encoding", + "debugid", + "if_chain", + "rustc-hash", + "rustc_version 0.2.3", + "serde", + "serde_json", + "unicode-id-start", + "url", +] + [[package]] name = "spin" version = "0.5.2" @@ -5349,12 +5496,6 @@ dependencies = [ "der", ] -[[package]] -name = "sptr" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" - [[package]] name = "sqlformat" version = "0.2.3" @@ -5577,6 +5718,19 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + [[package]] name = "state" version = "0.6.0" @@ -5618,6 +5772,18 @@ dependencies = [ "quote", ] +[[package]] +name = "string_enum" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e383308aebc257e7d7920224fa055c632478d92744eca77f99be8fa1545b90" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.66", +] + [[package]] name = "stringprep" version = "0.1.5" @@ -5635,12 +5801,384 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.66", +] + [[package]] name = "subtle" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "swc_atoms" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6567e4e67485b3e7662b486f1565bdae54bd5b9d6b16b2ba1a9babb1e42125" +dependencies = [ + "hstr", + "once_cell", + "rustc-hash", + "serde", +] + +[[package]] +name = "swc_cached" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83406221c501860fce9c27444f44125eafe9e598b8b81be7563d7036784cd05c" +dependencies = [ + "ahash 0.8.11", + "anyhow", + "dashmap", + "once_cell", + "regex", + "serde", +] + +[[package]] +name = "swc_common" +version = "0.33.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2f9706038906e66f3919028f9f7a37f3ed552f1b85578e93f4468742e2da438" +dependencies = [ + "ast_node", + "better_scoped_tls", + "cfg-if", + "either", + "from_variant", + "new_debug_unreachable", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "siphasher", + "sourcemap", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_visit", + "tracing", + "unicode-width", + "url", +] + +[[package]] +name = "swc_config" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be1a689e146be1eae53139482cb061dcf0fa01dff296bbe7b96fff92d8e2936" +dependencies = [ + "anyhow", + "indexmap 2.2.6", + "serde", + "serde_json", + "swc_cached", + "swc_config_macro", +] + +[[package]] +name = "swc_config_macro" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c5f56139042c1a95b54f5ca48baa0e0172d369bcc9d3d473dad1de36bae8399" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.66", +] + +[[package]] +name = "swc_ecma_ast" +version = "0.113.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1690cc0c9ab60b44ac0225ba1e231ac532f7ba1d754df761c6ee607561afae" +dependencies = [ + "bitflags 2.5.0", + "is-macro", + "num-bigint", + "phf 0.11.2", + "scoped-tls", + "serde", + "string_enum", + "swc_atoms", + "swc_common", + "unicode-id-start", +] + +[[package]] +name = "swc_ecma_codegen" +version = "0.149.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fef147127a2926ca26171c7afcbf028ff86dc543ced87d316713f25620a15b9" +dependencies = [ + "memchr", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "sourcemap", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen_macros", + "tracing", +] + +[[package]] +name = "swc_ecma_codegen_macros" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090e409af49c8d1a3c13b3aab1ed09dd4eda982207eb3e63c2ad342f072b49c8" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.66", +] + +[[package]] +name = "swc_ecma_loader" +version = "0.45.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c68f934bd2c51f29c4ad0bcae09924e9dc30d7ce0680367d45b42d40338a67" +dependencies = [ + "anyhow", + "pathdiff", + "serde", + "swc_atoms", + "swc_common", + "tracing", +] + +[[package]] +name = "swc_ecma_parser" +version = "0.144.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0499e69683ae5d67a20ff0279b94bc90f29df7922a46331b54d5dd367bf89570" +dependencies = [ + "either", + "new_debug_unreachable", + "num-bigint", + "num-traits", + "phf 0.11.2", + "serde", + "smallvec", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", + "typed-arena", +] + +[[package]] +name = "swc_ecma_transforms_base" +version = "0.138.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddb95c2bdad1c9c29edf35712e1e0f9b9ddc1cdb5ba2d582fd93468cb075a03" +dependencies = [ + "better_scoped_tls", + "bitflags 2.5.0", + "indexmap 2.2.6", + "once_cell", + "phf 0.11.2", + "rustc-hash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_utils", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_classes" +version = "0.127.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53043d81678f3c693604eeb1d1f0fe6ba10f303104a31b954dbeebed9cadf530" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_macros" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500a1dadad1e0e41e417d633b3d6d5de677c9e0d3159b94ba3348436cdb15aab" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.66", +] + +[[package]] +name = "swc_ecma_transforms_proposal" +version = "0.172.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fbc414d6a9c5479cfb4c6e92fcdac504582bd7bc89a0ed7f8808b72dc8bd1f0" +dependencies = [ + "either", + "rustc-hash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_react" +version = "0.184.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "565a76c4ca47ce31d78301c0beab878e4c2cb4f624691254d834ec8c0e236755" +dependencies = [ + "base64 0.21.7", + "dashmap", + "indexmap 2.2.6", + "once_cell", + "serde", + "sha-1", + "string_enum", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_typescript" +version = "0.189.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e209026c1d3c577cafac257d87e7c0d23119282fbdc8ed03d7f56077e95beb90" +dependencies = [ + "ryu-js", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_react", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_utils" +version = "0.128.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5242670bc74e0a0b64b9d4912b37be36944517ce0881314162aeb4381272c3" +dependencies = [ + "indexmap 2.2.6", + "num_cpus", + "once_cell", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_visit", + "tracing", + "unicode-id", +] + +[[package]] +name = "swc_ecma_visit" +version = "0.99.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28a6ce28ad8e591f8d627f1f9cb26b25e5d83052a9bc1b674d95fc28040cfa98" +dependencies = [ + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_visit", + "tracing", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "695a1d8b461033d32429b5befbf0ad4d7a2c4d6ba9cd5ba4e0645c615839e8e4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "swc_macros_common" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91745f3561057493d2da768437c427c0e979dff7396507ae02f16c981c4a8466" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "swc_visit" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043d11fe683dcb934583ead49405c0896a5af5face522e4682c16971ef7871b9" +dependencies = [ + "either", + "swc_visit_macros", +] + +[[package]] +name = "swc_visit_macros" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ef18ff8daffa999f729db056d2821cd2f790f3a11e46422d19f46bb193e7" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.66", +] + [[package]] name = "swift-rs" version = "1.0.6" @@ -5692,17 +6230,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "sys-locale" version = "0.3.1" @@ -5882,7 +6409,7 @@ dependencies = [ "heck 0.5.0", "json-patch", "schemars", - "semver", + "semver 1.0.23", "serde", "serde_json", "tauri-utils", @@ -5905,7 +6432,7 @@ dependencies = [ "png", "proc-macro2", "quote", - "semver", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -6096,7 +6623,7 @@ dependencies = [ "infer", "minisign-verify", "reqwest 0.12.4", - "semver", + "semver 1.0.23", "serde", "serde_json", "tar", @@ -6191,7 +6718,7 @@ dependencies = [ "quote", "regex", "schemars", - "semver", + "semver 1.0.23", "serde", "serde_json", "serde_with", @@ -6240,18 +6767,30 @@ dependencies = [ "utf-8", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "text_lines" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd5828de7deaa782e1dd713006ae96b3bee32d3279b79eb67ecf8072c059bcf" +dependencies = [ + "serde", +] + [[package]] name = "thin-slice" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" -[[package]] -name = "thin-vec" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" - [[package]] name = "thiserror" version = "1.0.61" @@ -6301,7 +6840,6 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa 1.0.11", - "js-sys", "libc", "num-conv", "num_threads", @@ -6336,16 +6874,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -6372,6 +6900,7 @@ dependencies = [ "libc", "mio", "num_cpus", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -6675,12 +7204,28 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" +[[package]] +name = "triomphe" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b2cb4fbb9995eeb36ac86fadf24031ccd58f99d6b4b2d7b911db70bddb80d90" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" version = "1.17.0" @@ -6754,6 +7299,18 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +[[package]] +name = "unicode-id" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" + +[[package]] +name = "unicode-id-start" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02aebfa694eccbbbffdd92922c7de136b9fe764396d2f10e21bce1681477cfc1" + [[package]] name = "unicode-ident" version = "1.0.12" @@ -6793,6 +7350,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.9.0" @@ -6836,24 +7399,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - [[package]] name = "utf8-width" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "uuid" version = "1.8.0" @@ -6863,6 +7414,21 @@ dependencies = [ "getrandom 0.2.15", ] +[[package]] +name = "v8" +version = "0.92.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234589219e37a7496cbce73d971586db8369871be2420372c45a579b6a919b15" +dependencies = [ + "bitflags 2.5.0", + "fslock", + "gzip-header", + "home", + "miniz_oxide", + "once_cell", + "which", +] + [[package]] name = "valuable" version = "0.1.0" @@ -7157,6 +7723,19 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +[[package]] +name = "which" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "whoami" version = "1.5.1" @@ -7535,18 +8114,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "wry" version = "0.40.1" @@ -7661,12 +8228,14 @@ dependencies = [ name = "yaak-app" version = "0.0.0" dependencies = [ + "anyhow", "base64 0.22.1", - "boa_engine", - "boa_runtime", "chrono", "cocoa", "datetime", + "deno_ast", + "deno_console", + "deno_core", "grpc", "hex_color", "http 0.2.12", @@ -7679,6 +8248,7 @@ dependencies = [ "reqwest_cookie_store", "serde", "serde_json", + "serde_yaml", "sqlx", "tauri", "tauri-build", @@ -7697,30 +8267,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zbus" version = "4.0.1" @@ -7800,55 +8346,12 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -[[package]] -name = "zerovec" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "zip" version = "1.1.4" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 0a02e6e7..e9f2d8fb 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -26,11 +26,13 @@ openssl-sys = { version = "0.9", features = ["vendored"] } # For Ubuntu installa [dependencies] grpc = { path = "./grpc" } templates = { path = "./templates" } +anyhow = "1.0.86" base64 = "0.22.0" -boa_engine = { version = "0.18.0", features = ["annex-b"] } -boa_runtime = { version = "0.18.0" } chrono = { version = "0.4.31", features = ["serde"] } datetime = "0.5.2" +deno_ast = { version = "0.39.0", features = ["transpiling"] } +deno_console = "0.155.0" +deno_core = { version = "0.284.0" } hex_color = "3.0.0" http = "0.2.10" log = "0.4.21" @@ -40,8 +42,9 @@ reqwest = { version = "0.11.23", features = ["multipart", "cookies", "gzip", "br reqwest_cookie_store = "0.6.0" serde = { version = "1.0.198", features = ["derive"] } serde_json = { version = "1.0.116", features = ["raw_value"] } +serde_yaml = "0.9.34+deprecated" sqlx = { version = "0.7.4", features = ["sqlite", "runtime-tokio-rustls", "json", "chrono", "time"] } -tauri = { version = "2.0.0-beta", features = ["config-toml", "devtools", "protocol-asset"] } +tauri = { version = "2.0.0-beta", features = ["devtools", "protocol-asset"] } tauri-plugin-clipboard-manager = "2.1.0-beta" tauri-plugin-deep-link = "2.0.0-beta" tauri-plugin-dialog = "2.0.0-beta" diff --git a/src-tauri/plugins/importer-curl/index.mjs b/src-tauri/plugins/importer-curl/index.mjs deleted file mode 100644 index b8123807..00000000 --- a/src-tauri/plugins/importer-curl/index.mjs +++ /dev/null @@ -1,297 +0,0 @@ -var j = "(?:" + [ - "\\|\\|", - "\\&\\&", - ";;", - "\\|\\&", - "\\<\\(", - "\\<\\<\\<", - ">>", - ">\\&", - "<\\&", - "[&;()|<>]" -].join("|") + ")", D = new RegExp("^" + j + "$"), q = "|&;()<> \\t", M = '"((\\\\"|[^"])*?)"', Q = "'((\\\\'|[^'])*?)'", V = /^#$/, _ = "'", G = '"', U = "$", $ = "", z = 4294967296; -for (var L = 0; L < 4; L++) - $ += (z * Math.random()).toString(16); -var J = new RegExp("^" + $); -function X(n, s) { - for (var e = s.lastIndex, t = [], c; c = s.exec(n); ) - t.push(c), s.lastIndex === c.index && (s.lastIndex += 1); - return s.lastIndex = e, t; -} -function F(n, s, e) { - var t = typeof n == "function" ? n(e) : n[e]; - return typeof t > "u" && e != "" ? t = "" : typeof t > "u" && (t = "$"), typeof t == "object" ? s + $ + JSON.stringify(t) + $ : s + t; -} -function K(n, s, e) { - e || (e = {}); - var t = e.escape || "\\", c = "(\\" + t + `['"` + q + `]|[^\\s'"` + q + "])+", m = new RegExp([ - "(" + j + ")", - // control chars - "(" + c + "|" + M + "|" + Q + ")+" - ].join("|"), "g"), f = X(n, m); - if (f.length === 0) - return []; - s || (s = {}); - var w = !1; - return f.map(function(r) { - var a = r[0]; - if (!a || w) - return; - if (D.test(a)) - return { op: a }; - var x = !1, C = !1, d = "", O = !1, i; - function T() { - i += 1; - var v, p, R = a.charAt(i); - if (R === "{") { - if (i += 1, a.charAt(i) === "}") - throw new Error("Bad substitution: " + a.slice(i - 2, i + 1)); - if (v = a.indexOf("}", i), v < 0) - throw new Error("Bad substitution: " + a.slice(i)); - p = a.slice(i, v), i = v; - } else if (/[*@#?$!_-]/.test(R)) - p = R, i += 1; - else { - var g = a.slice(i); - v = g.match(/[^\w\d_]/), v ? (p = g.slice(0, v.index), i += v.index - 1) : (p = g, i = a.length); - } - return F(s, "", p); - } - for (i = 0; i < a.length; i++) { - var u = a.charAt(i); - if (O = O || !x && (u === "*" || u === "?"), C) - d += u, C = !1; - else if (x) - u === x ? x = !1 : x == _ ? d += u : u === t ? (i += 1, u = a.charAt(i), u === G || u === t || u === U ? d += u : d += t + u) : u === U ? d += T() : d += u; - else if (u === G || u === _) - x = u; - else { - if (D.test(u)) - return { op: a }; - if (V.test(u)) { - w = !0; - var b = { comment: n.slice(r.index + i + 1) }; - return d.length ? [d, b] : [b]; - } else - u === t ? C = !0 : u === U ? d += T() : d += u; - } - } - return O ? { op: "glob", pattern: d } : d; - }).reduce(function(r, a) { - return typeof a > "u" ? r : r.concat(a); - }, []); -} -var Y = function(s, e, t) { - var c = K(s, e, t); - return typeof e != "function" ? c : c.reduce(function(m, f) { - if (typeof f == "object") - return m.concat(f); - var w = f.split(RegExp("(" + $ + ".*?" + $ + ")", "g")); - return w.length === 1 ? m.concat(w[0]) : m.concat(w.filter(Boolean).map(function(r) { - return J.test(r) ? JSON.parse(r.split($)[1]) : r; - })); - }, []); -}, Z = Y; -const ae = "curl", se = "cURL", ie = "cURL command line tool", H = ["d", "data", "data-raw", "data-urlencode", "data-binary", "data-ascii"], ee = [ - ["url"], - // Specify the URL explicitly - ["user", "u"], - // Authentication - ["digest"], - // Apply auth as digest - ["header", "H"], - ["cookie", "b"], - ["get", "G"], - // Put the post data in the URL - ["d", "data"], - // Add url encoded data - ["data-raw"], - ["data-urlencode"], - ["data-binary"], - ["data-ascii"], - ["form", "F"], - // Add multipart data - ["request", "X"], - // Request method - H -].flatMap((n) => n); -function oe(n) { - if (!n.match(/^\s*curl /)) - return null; - const s = [], e = n.replace(/\ncurl/g, "; curl"); - let t = []; - const m = Z(e).flatMap((r) => typeof r == "string" && r.startsWith("-") && !r.startsWith("--") && r.length > 2 ? [r.slice(0, 2), r.slice(2)] : r); - for (const r of m) { - if (typeof r == "string") { - r.startsWith("$") ? t.push(r.slice(1)) : t.push(r); - continue; - } - if ("comment" in r) - continue; - const { op: a } = r; - if (a === ";") { - s.push(t), t = []; - continue; - } - if (a != null && a.startsWith("$")) { - const x = a.slice(2, a.length - 1).replace(/\\'/g, "'"); - t.push(x); - continue; - } - a === "glob" && t.push(r.pattern); - } - s.push(t); - const f = { - model: "workspace", - id: N("workspace"), - name: "Curl Import" - }; - return { - resources: { - httpRequests: s.filter((r) => r[0] === "curl").map((r) => te(r, f.id)), - workspaces: [f] - } - }; -} -function te(n, s) { - const e = {}, t = []; - for (let o = 1; o < n.length; o++) { - let l = n[o]; - if (typeof l == "string" && (l = l.trim()), typeof l == "string" && l.match(/^-{1,2}[\w-]+/)) { - const E = l[0] === "-" && l[1] !== "-"; - let h = l.replace(/^-{1,2}/, ""); - if (!ee.includes(h)) - continue; - let y; - const S = n[o + 1]; - E && h.length > 1 ? (y = h.slice(1), h = h.slice(0, 1)) : typeof S == "string" && !S.startsWith("-") ? (y = S, o++) : y = !0, e[h] = e[h] || [], e[h].push(y); - } else - l && t.push(l); - } - let c, m; - const f = A(e, t[0] || "", ["url"]), [w, r] = W(f, "?"); - c = (r == null ? void 0 : r.split("&").map((o) => { - const l = W(o, "="); - return { name: l[0] ?? "", value: l[1] ?? "", enabled: !0 }; - })) ?? [], m = w ?? f; - const [a, x] = A(e, "", ["u", "user"]).split(/:(.*)$/), C = A(e, !1, ["digest"]), d = a ? C ? "digest" : "basic" : null, O = a ? { - username: a.trim(), - password: (x ?? "").trim() - } : {}, i = [ - ...e.header || [], - ...e.H || [] - ].map((o) => { - const [l, E] = o.split(/:(.*)$/); - return E ? { - name: (l ?? "").trim(), - value: E.trim(), - enabled: !0 - } : { - name: (l ?? "").trim().replace(/;$/, ""), - value: "", - enabled: !0 - }; - }), T = [ - ...e.cookie || [], - ...e.b || [] - ].map((o) => { - const l = o.split("=", 1)[0], E = o.replace(`${l}=`, ""); - return `${l}=${E}`; - }).join("; "), u = i.find((o) => o.name.toLowerCase() === "cookie"); - T && u ? u.value += `; ${T}` : T && i.push({ - name: "Cookie", - value: T, - enabled: !0 - }); - const b = ne(e), v = i.find((o) => o.name.toLowerCase() === "content-type"), p = v ? v.value.split(";")[0] : null, R = [ - ...e.form || [], - ...e.F || [] - ].map((o) => { - const l = o.split("="), E = l[0] ?? "", h = l[1] ?? "", y = { - name: E, - enabled: !0 - }; - return h.indexOf("@") === 0 ? y.file = h.slice(1) : y.value = h, y; - }); - let g = {}, I = null; - const B = A(e, !1, ["G", "get"]); - b.length > 0 && B ? c.push(...b) : b.length > 0 && (p == null || p === "application/x-www-form-urlencoded") ? (I = p ?? "application/x-www-form-urlencoded", g = { - form: b.map((o) => ({ - ...o, - name: decodeURIComponent(o.name || ""), - value: decodeURIComponent(o.value || "") - })) - }, i.push({ - name: "Content-Type", - value: "application/x-www-form-urlencoded", - enabled: !0 - })) : b.length > 0 ? (I = p === "application/json" || p === "text/xml" || p === "text/plain" ? p : "other", g = { - text: b.map(({ name: o, value: l }) => o && l ? `${o}=${l}` : o || l).join("&") - }) : R.length && (I = p ?? "multipart/form-data", g = { - form: R - }, p == null && i.push({ - name: "Content-Type", - value: "multipart/form-data", - enabled: !0 - })); - let P = A(e, "", ["X", "request"]).toUpperCase(); - return P === "" && g && (P = "text" in g || "form" in g ? "POST" : "GET"), { - id: N("http_request"), - model: "http_request", - workspaceId: s, - name: "", - urlParameters: c, - url: m, - method: P, - headers: i, - authentication: O, - authenticationType: d, - body: g, - bodyType: I, - folderId: null, - sortPriority: 0 - }; -} -const ne = (n) => { - let s = []; - for (const e of H) { - const t = n[e]; - if (!(!t || t.length === 0)) - for (const c of t) { - if (typeof c != "string") - continue; - const [m, f] = c.split("="); - c.startsWith("@") ? s.push({ - name: m ?? "", - value: "", - filePath: c.slice(1), - enabled: !0 - }) : s.push({ - name: m ?? "", - value: e === "data-urlencode" ? encodeURIComponent(f ?? "") : f ?? "", - enabled: !0 - }); - } - } - return s; -}, A = (n, s, e) => { - for (const t of e) - if (n[t] && n[t].length) - return n[t][0]; - return s; -}; -function W(n, s) { - const e = n.indexOf(s); - return e > -1 ? [n.slice(0, e), n.slice(e + 1)] : [n]; -} -const k = {}; -function N(n) { - return k[n] = (k[n] ?? -1) + 1, `GENERATE_ID::${n.toUpperCase()}_${k[n]}`; -} -export { - ie as description, - ae as id, - te as importCommand, - se as name, - oe as pluginHookImport -}; diff --git a/src-tauri/plugins/importer-insomnia/index.mjs b/src-tauri/plugins/importer-insomnia/index.mjs deleted file mode 100644 index 669849d9..00000000 --- a/src-tauri/plugins/importer-insomnia/index.mjs +++ /dev/null @@ -1,4554 +0,0 @@ -const et = Symbol.for("yaml.alias"), Qe = Symbol.for("yaml.document"), V = Symbol.for("yaml.map"), $t = Symbol.for("yaml.pair"), U = Symbol.for("yaml.scalar"), le = Symbol.for("yaml.seq"), q = Symbol.for("yaml.node.type"), ae = (s) => !!s && typeof s == "object" && s[q] === et, Ce = (s) => !!s && typeof s == "object" && s[q] === Qe, we = (s) => !!s && typeof s == "object" && s[q] === V, L = (s) => !!s && typeof s == "object" && s[q] === $t, A = (s) => !!s && typeof s == "object" && s[q] === U, ke = (s) => !!s && typeof s == "object" && s[q] === le; -function E(s) { - if (s && typeof s == "object") - switch (s[q]) { - case V: - case le: - return !0; - } - return !1; -} -function $(s) { - if (s && typeof s == "object") - switch (s[q]) { - case et: - case V: - case U: - case le: - return !0; - } - return !1; -} -const cs = (s) => (A(s) || E(s)) && !!s.anchor, Y = Symbol("break visit"), fs = Symbol("skip children"), me = Symbol("remove node"); -function H(s, e) { - const t = us(e); - Ce(s) ? ee(null, s.contents, t, Object.freeze([s])) === me && (s.contents = null) : ee(null, s, t, Object.freeze([])); -} -H.BREAK = Y; -H.SKIP = fs; -H.REMOVE = me; -function ee(s, e, t, n) { - const i = hs(s, e, t, n); - if ($(i) || L(i)) - return ds(s, n, i), ee(s, i, t, n); - if (typeof i != "symbol") { - if (E(e)) { - n = Object.freeze(n.concat(e)); - for (let r = 0; r < e.items.length; ++r) { - const o = ee(r, e.items[r], t, n); - if (typeof o == "number") - r = o - 1; - else { - if (o === Y) - return Y; - o === me && (e.items.splice(r, 1), r -= 1); - } - } - } else if (L(e)) { - n = Object.freeze(n.concat(e)); - const r = ee("key", e.key, t, n); - if (r === Y) - return Y; - r === me && (e.key = null); - const o = ee("value", e.value, t, n); - if (o === Y) - return Y; - o === me && (e.value = null); - } - } - return i; -} -function us(s) { - return typeof s == "object" && (s.Collection || s.Node || s.Value) ? Object.assign({ - Alias: s.Node, - Map: s.Node, - Scalar: s.Node, - Seq: s.Node - }, s.Value && { - Map: s.Value, - Scalar: s.Value, - Seq: s.Value - }, s.Collection && { - Map: s.Collection, - Seq: s.Collection - }, s) : s; -} -function hs(s, e, t, n) { - var i, r, o, l, a; - if (typeof t == "function") - return t(s, e, n); - if (we(e)) - return (i = t.Map) == null ? void 0 : i.call(t, s, e, n); - if (ke(e)) - return (r = t.Seq) == null ? void 0 : r.call(t, s, e, n); - if (L(e)) - return (o = t.Pair) == null ? void 0 : o.call(t, s, e, n); - if (A(e)) - return (l = t.Scalar) == null ? void 0 : l.call(t, s, e, n); - if (ae(e)) - return (a = t.Alias) == null ? void 0 : a.call(t, s, e, n); -} -function ds(s, e, t) { - const n = e[e.length - 1]; - if (E(n)) - n.items[s] = t; - else if (L(n)) - s === "key" ? n.key = t : n.value = t; - else if (Ce(n)) - n.contents = t; - else { - const i = ae(n) ? "alias" : "scalar"; - throw new Error(`Cannot replace node with ${i} parent`); - } -} -const ps = { - "!": "%21", - ",": "%2C", - "[": "%5B", - "]": "%5D", - "{": "%7B", - "}": "%7D" -}, ms = (s) => s.replace(/[!,[\]{}]/g, (e) => ps[e]); -class v { - constructor(e, t) { - this.docStart = null, this.docEnd = !1, this.yaml = Object.assign({}, v.defaultYaml, e), this.tags = Object.assign({}, v.defaultTags, t); - } - clone() { - const e = new v(this.yaml, this.tags); - return e.docStart = this.docStart, e; - } - /** - * During parsing, get a Directives instance for the current document and - * update the stream state according to the current version's spec. - */ - atDocument() { - const e = new v(this.yaml, this.tags); - switch (this.yaml.version) { - case "1.1": - this.atNextDocument = !0; - break; - case "1.2": - this.atNextDocument = !1, this.yaml = { - explicit: v.defaultYaml.explicit, - version: "1.2" - }, this.tags = Object.assign({}, v.defaultTags); - break; - } - return e; - } - /** - * @param onError - May be called even if the action was successful - * @returns `true` on success - */ - add(e, t) { - this.atNextDocument && (this.yaml = { explicit: v.defaultYaml.explicit, version: "1.1" }, this.tags = Object.assign({}, v.defaultTags), this.atNextDocument = !1); - const n = e.trim().split(/[ \t]+/), i = n.shift(); - switch (i) { - case "%TAG": { - if (n.length !== 2 && (t(0, "%TAG directive should contain exactly two parts"), n.length < 2)) - return !1; - const [r, o] = n; - return this.tags[r] = o, !0; - } - case "%YAML": { - if (this.yaml.explicit = !0, n.length !== 1) - return t(0, "%YAML directive should contain exactly one part"), !1; - const [r] = n; - if (r === "1.1" || r === "1.2") - return this.yaml.version = r, !0; - { - const o = /^\d+\.\d+$/.test(r); - return t(6, `Unsupported YAML version ${r}`, o), !1; - } - } - default: - return t(0, `Unknown directive ${i}`, !0), !1; - } - } - /** - * Resolves a tag, matching handles to those defined in %TAG directives. - * - * @returns Resolved tag, which may also be the non-specific tag `'!'` or a - * `'!local'` tag, or `null` if unresolvable. - */ - tagName(e, t) { - if (e === "!") - return "!"; - if (e[0] !== "!") - return t(`Not a valid tag: ${e}`), null; - if (e[1] === "<") { - const o = e.slice(2, -1); - return o === "!" || o === "!!" ? (t(`Verbatim tags aren't resolved, so ${e} is invalid.`), null) : (e[e.length - 1] !== ">" && t("Verbatim tags must end with a >"), o); - } - const [, n, i] = e.match(/^(.*!)([^!]*)$/s); - i || t(`The ${e} tag has no suffix`); - const r = this.tags[n]; - if (r) - try { - return r + decodeURIComponent(i); - } catch (o) { - return t(String(o)), null; - } - return n === "!" ? e : (t(`Could not resolve tag: ${e}`), null); - } - /** - * Given a fully resolved tag, returns its printable string form, - * taking into account current tag prefixes and defaults. - */ - tagString(e) { - for (const [t, n] of Object.entries(this.tags)) - if (e.startsWith(n)) - return t + ms(e.substring(n.length)); - return e[0] === "!" ? e : `!<${e}>`; - } - toString(e) { - const t = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [], n = Object.entries(this.tags); - let i; - if (e && n.length > 0 && $(e.contents)) { - const r = {}; - H(e.contents, (o, l) => { - $(l) && l.tag && (r[l.tag] = !0); - }), i = Object.keys(r); - } else - i = []; - for (const [r, o] of n) - r === "!!" && o === "tag:yaml.org,2002:" || (!e || i.some((l) => l.startsWith(o))) && t.push(`%TAG ${r} ${o}`); - return t.join(` -`); - } -} -v.defaultYaml = { explicit: !1, version: "1.2" }; -v.defaultTags = { "!!": "tag:yaml.org,2002:" }; -function _t(s) { - if (/[\x00-\x19\s,[\]{}]/.test(s)) { - const t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`; - throw new Error(t); - } - return !0; -} -function Ct(s) { - const e = /* @__PURE__ */ new Set(); - return H(s, { - Value(t, n) { - n.anchor && e.add(n.anchor); - } - }), e; -} -function vt(s, e) { - for (let t = 1; ; ++t) { - const n = `${s}${t}`; - if (!e.has(n)) - return n; - } -} -function gs(s, e) { - const t = [], n = /* @__PURE__ */ new Map(); - let i = null; - return { - onAnchor: (r) => { - t.push(r), i || (i = Ct(s)); - const o = vt(e, i); - return i.add(o), o; - }, - /** - * With circular references, the source node is only resolved after all - * of its child nodes are. This is why anchors are set only after all of - * the nodes have been created. - */ - setAnchors: () => { - for (const r of t) { - const o = n.get(r); - if (typeof o == "object" && o.anchor && (A(o.node) || E(o.node))) - o.node.anchor = o.anchor; - else { - const l = new Error("Failed to resolve repeated object (this should not happen)"); - throw l.source = r, l; - } - } - }, - sourceObjects: n - }; -} -function te(s, e, t, n) { - if (n && typeof n == "object") - if (Array.isArray(n)) - for (let i = 0, r = n.length; i < r; ++i) { - const o = n[i], l = te(s, n, String(i), o); - l === void 0 ? delete n[i] : l !== o && (n[i] = l); - } - else if (n instanceof Map) - for (const i of Array.from(n.keys())) { - const r = n.get(i), o = te(s, n, i, r); - o === void 0 ? n.delete(i) : o !== r && n.set(i, o); - } - else if (n instanceof Set) - for (const i of Array.from(n)) { - const r = te(s, n, i, i); - r === void 0 ? n.delete(i) : r !== i && (n.delete(i), n.add(r)); - } - else - for (const [i, r] of Object.entries(n)) { - const o = te(s, n, i, r); - o === void 0 ? delete n[i] : o !== r && (n[i] = o); - } - return s.call(e, t, n); -} -function P(s, e, t) { - if (Array.isArray(s)) - return s.map((n, i) => P(n, String(i), t)); - if (s && typeof s.toJSON == "function") { - if (!t || !cs(s)) - return s.toJSON(e, t); - const n = { aliasCount: 0, count: 1, res: void 0 }; - t.anchors.set(s, n), t.onCreate = (r) => { - n.res = r, delete t.onCreate; - }; - const i = s.toJSON(e, t); - return t.onCreate && t.onCreate(i), i; - } - return typeof s == "bigint" && !(t != null && t.keep) ? Number(s) : s; -} -class tt { - constructor(e) { - Object.defineProperty(this, q, { value: e }); - } - /** Create a copy of this node. */ - clone() { - const e = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); - return this.range && (e.range = this.range.slice()), e; - } - /** A plain JavaScript representation of this node. */ - toJS(e, { mapAsMap: t, maxAliasCount: n, onAnchor: i, reviver: r } = {}) { - if (!Ce(e)) - throw new TypeError("A document argument is required"); - const o = { - anchors: /* @__PURE__ */ new Map(), - doc: e, - keep: !0, - mapAsMap: t === !0, - mapKeyWarned: !1, - maxAliasCount: typeof n == "number" ? n : 100 - }, l = P(this, "", o); - if (typeof i == "function") - for (const { count: a, res: c } of o.anchors.values()) - i(c, a); - return typeof r == "function" ? te(r, { "": l }, "", l) : l; - } -} -class st extends tt { - constructor(e) { - super(et), this.source = e, Object.defineProperty(this, "tag", { - set() { - throw new Error("Alias nodes cannot have tags"); - } - }); - } - /** - * Resolve the value of this alias within `doc`, finding the last - * instance of the `source` anchor before this node. - */ - resolve(e) { - let t; - return H(e, { - Node: (n, i) => { - if (i === this) - return H.BREAK; - i.anchor === this.source && (t = i); - } - }), t; - } - toJSON(e, t) { - if (!t) - return { source: this.source }; - const { anchors: n, doc: i, maxAliasCount: r } = t, o = this.resolve(i); - if (!o) { - const a = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; - throw new ReferenceError(a); - } - let l = n.get(o); - if (l || (P(o, null, t), l = n.get(o)), !l || l.res === void 0) { - const a = "This should not happen: Alias anchor was not resolved?"; - throw new ReferenceError(a); - } - if (r >= 0 && (l.count += 1, l.aliasCount === 0 && (l.aliasCount = Te(i, o, n)), l.count * l.aliasCount > r)) { - const a = "Excessive alias count indicates a resource exhaustion attack"; - throw new ReferenceError(a); - } - return l.res; - } - toString(e, t, n) { - const i = `*${this.source}`; - if (e) { - if (_t(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) { - const r = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; - throw new Error(r); - } - if (e.implicitKey) - return `${i} `; - } - return i; - } -} -function Te(s, e, t) { - if (ae(e)) { - const n = e.resolve(s), i = t && n && t.get(n); - return i ? i.count * i.aliasCount : 0; - } else if (E(e)) { - let n = 0; - for (const i of e.items) { - const r = Te(s, i, t); - r > n && (n = r); - } - return n; - } else if (L(e)) { - const n = Te(s, e.key, t), i = Te(s, e.value, t); - return Math.max(n, i); - } - return 1; -} -const Bt = (s) => !s || typeof s != "function" && typeof s != "object"; -class N extends tt { - constructor(e) { - super(U), this.value = e; - } - toJSON(e, t) { - return t != null && t.keep ? this.value : P(this.value, e, t); - } - toString() { - return String(this.value); - } -} -N.BLOCK_FOLDED = "BLOCK_FOLDED"; -N.BLOCK_LITERAL = "BLOCK_LITERAL"; -N.PLAIN = "PLAIN"; -N.QUOTE_DOUBLE = "QUOTE_DOUBLE"; -N.QUOTE_SINGLE = "QUOTE_SINGLE"; -const ys = "tag:yaml.org,2002:"; -function bs(s, e, t) { - if (e) { - const n = t.filter((r) => r.tag === e), i = n.find((r) => !r.format) ?? n[0]; - if (!i) - throw new Error(`Tag ${e} not found`); - return i; - } - return t.find((n) => { - var i; - return ((i = n.identify) == null ? void 0 : i.call(n, s)) && !n.format; - }); -} -function ye(s, e, t) { - var f, u, m; - if (Ce(s) && (s = s.contents), $(s)) - return s; - if (L(s)) { - const y = (u = (f = t.schema[V]).createNode) == null ? void 0 : u.call(f, t.schema, null, t); - return y.items.push(s), y; - } - (s instanceof String || s instanceof Number || s instanceof Boolean || typeof BigInt < "u" && s instanceof BigInt) && (s = s.valueOf()); - const { aliasDuplicateObjects: n, onAnchor: i, onTagObj: r, schema: o, sourceObjects: l } = t; - let a; - if (n && s && typeof s == "object") { - if (a = l.get(s), a) - return a.anchor || (a.anchor = i(s)), new st(a.anchor); - a = { anchor: null, node: null }, l.set(s, a); - } - e != null && e.startsWith("!!") && (e = ys + e.slice(2)); - let c = bs(s, e, o.tags); - if (!c) { - if (s && typeof s.toJSON == "function" && (s = s.toJSON()), !s || typeof s != "object") { - const y = new N(s); - return a && (a.node = y), y; - } - c = s instanceof Map ? o[V] : Symbol.iterator in Object(s) ? o[le] : o[V]; - } - r && (r(c), delete t.onTagObj); - const d = c != null && c.createNode ? c.createNode(t.schema, s, t) : typeof ((m = c == null ? void 0 : c.nodeClass) == null ? void 0 : m.from) == "function" ? c.nodeClass.from(t.schema, s, t) : new N(s); - return e ? d.tag = e : c.default || (d.tag = c.tag), a && (a.node = d), d; -} -function $e(s, e, t) { - let n = t; - for (let i = e.length - 1; i >= 0; --i) { - const r = e[i]; - if (typeof r == "number" && Number.isInteger(r) && r >= 0) { - const o = []; - o[r] = n, n = o; - } else - n = /* @__PURE__ */ new Map([[r, n]]); - } - return ye(n, void 0, { - aliasDuplicateObjects: !1, - keepUndefined: !1, - onAnchor: () => { - throw new Error("This should not happen, please report a bug."); - }, - schema: s, - sourceObjects: /* @__PURE__ */ new Map() - }); -} -const de = (s) => s == null || typeof s == "object" && !!s[Symbol.iterator]().next().done; -class nt extends tt { - constructor(e, t) { - super(e), Object.defineProperty(this, "schema", { - value: t, - configurable: !0, - enumerable: !1, - writable: !0 - }); - } - /** - * Create a copy of this collection. - * - * @param schema - If defined, overwrites the original's schema - */ - clone(e) { - const t = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); - return e && (t.schema = e), t.items = t.items.map((n) => $(n) || L(n) ? n.clone(e) : n), this.range && (t.range = this.range.slice()), t; - } - /** - * Adds a value to the collection. For `!!map` and `!!omap` the value must - * be a Pair instance or a `{ key, value }` object, which may not have a key - * that already exists in the map. - */ - addIn(e, t) { - if (de(e)) - this.add(t); - else { - const [n, ...i] = e, r = this.get(n, !0); - if (E(r)) - r.addIn(i, t); - else if (r === void 0 && this.schema) - this.set(n, $e(this.schema, i, t)); - else - throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`); - } - } - /** - * Removes a value from the collection. - * @returns `true` if the item was found and removed. - */ - deleteIn(e) { - const [t, ...n] = e; - if (n.length === 0) - return this.delete(t); - const i = this.get(t, !0); - if (E(i)) - return i.deleteIn(n); - throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`); - } - /** - * Returns item at `key`, or `undefined` if not found. By default unwraps - * scalar values from their surrounding node; to disable set `keepScalar` to - * `true` (collections are always returned intact). - */ - getIn(e, t) { - const [n, ...i] = e, r = this.get(n, !0); - return i.length === 0 ? !t && A(r) ? r.value : r : E(r) ? r.getIn(i, t) : void 0; - } - hasAllNullValues(e) { - return this.items.every((t) => { - if (!L(t)) - return !1; - const n = t.value; - return n == null || e && A(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag; - }); - } - /** - * Checks if the collection includes a value with the key `key`. - */ - hasIn(e) { - const [t, ...n] = e; - if (n.length === 0) - return this.has(t); - const i = this.get(t, !0); - return E(i) ? i.hasIn(n) : !1; - } - /** - * Sets a value in this collection. For `!!set`, `value` needs to be a - * boolean to add/remove the item from the set. - */ - setIn(e, t) { - const [n, ...i] = e; - if (i.length === 0) - this.set(n, t); - else { - const r = this.get(n, !0); - if (E(r)) - r.setIn(i, t); - else if (r === void 0 && this.schema) - this.set(n, $e(this.schema, i, t)); - else - throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`); - } - } -} -nt.maxFlowStringSingleLineLength = 60; -const ws = (s) => s.replace(/^(?!$)(?: $)?/gm, "#"); -function F(s, e) { - return /^\n+$/.test(s) ? s.substring(1) : e ? s.replace(/^(?! *$)/gm, e) : s; -} -const W = (s, e, t) => s.endsWith(` -`) ? F(t, e) : t.includes(` -`) ? ` -` + F(t, e) : (s.endsWith(" ") ? "" : " ") + t, Dt = "flow", He = "block", Ee = "quoted"; -function ve(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentWidth: r = 20, onFold: o, onOverflow: l } = {}) { - if (!i || i < 0) - return s; - const a = Math.max(1 + r, 1 + i - e.length); - if (s.length <= a) - return s; - const c = [], d = {}; - let f = i - e.length; - typeof n == "number" && (n > i - Math.max(2, r) ? c.push(0) : f = i - n); - let u, m, y = !1, h = -1, p = -1, b = -1; - t === He && (h = gt(s, h, e.length), h !== -1 && (f = h + a)); - for (let S; S = s[h += 1]; ) { - if (t === Ee && S === "\\") { - switch (p = h, s[h + 1]) { - case "x": - h += 3; - break; - case "u": - h += 5; - break; - case "U": - h += 9; - break; - default: - h += 1; - } - b = h; - } - if (S === ` -`) - t === He && (h = gt(s, h, e.length)), f = h + e.length + a, u = void 0; - else { - if (S === " " && m && m !== " " && m !== ` -` && m !== " ") { - const k = s[h + 1]; - k && k !== " " && k !== ` -` && k !== " " && (u = h); - } - if (h >= f) - if (u) - c.push(u), f = u + a, u = void 0; - else if (t === Ee) { - for (; m === " " || m === " "; ) - m = S, S = s[h += 1], y = !0; - const k = h > b + 1 ? h - 2 : p - 1; - if (d[k]) - return s; - c.push(k), d[k] = !0, f = k + a, u = void 0; - } else - y = !0; - } - m = S; - } - if (y && l && l(), c.length === 0) - return s; - o && o(); - let w = s.slice(0, c[0]); - for (let S = 0; S < c.length; ++S) { - const k = c[S], O = c[S + 1] || s.length; - k === 0 ? w = ` -${e}${s.slice(0, O)}` : (t === Ee && d[k] && (w += `${s[k]}\\`), w += ` -${e}${s.slice(k + 1, O)}`); - } - return w; -} -function gt(s, e, t) { - let n = e, i = e + 1, r = s[i]; - for (; r === " " || r === " "; ) - if (e < i + t) - r = s[++e]; - else { - do - r = s[++e]; - while (r && r !== ` -`); - n = e, i = e + 1, r = s[i]; - } - return n; -} -const Be = (s, e) => ({ - indentAtStart: e ? s.indent.length : s.indentAtStart, - lineWidth: s.options.lineWidth, - minContentWidth: s.options.minContentWidth -}), De = (s) => /^(%|---|\.\.\.)/m.test(s); -function ks(s, e, t) { - if (!e || e < 0) - return !1; - const n = e - t, i = s.length; - if (i <= n) - return !1; - for (let r = 0, o = 0; r < i; ++r) - if (s[r] === ` -`) { - if (r - o > n) - return !0; - if (o = r + 1, i - o <= n) - return !1; - } - return !0; -} -function ge(s, e) { - const t = JSON.stringify(s); - if (e.options.doubleQuotedAsJSON) - return t; - const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (De(s) ? " " : ""); - let o = "", l = 0; - for (let a = 0, c = t[a]; c; c = t[++a]) - if (c === " " && t[a + 1] === "\\" && t[a + 2] === "n" && (o += t.slice(l, a) + "\\ ", a += 1, l = a, c = "\\"), c === "\\") - switch (t[a + 1]) { - case "u": - { - o += t.slice(l, a); - const d = t.substr(a + 2, 4); - switch (d) { - case "0000": - o += "\\0"; - break; - case "0007": - o += "\\a"; - break; - case "000b": - o += "\\v"; - break; - case "001b": - o += "\\e"; - break; - case "0085": - o += "\\N"; - break; - case "00a0": - o += "\\_"; - break; - case "2028": - o += "\\L"; - break; - case "2029": - o += "\\P"; - break; - default: - d.substr(0, 2) === "00" ? o += "\\x" + d.substr(2) : o += t.substr(a, 6); - } - a += 5, l = a + 1; - } - break; - case "n": - if (n || t[a + 2] === '"' || t.length < i) - a += 1; - else { - for (o += t.slice(l, a) + ` - -`; t[a + 2] === "\\" && t[a + 3] === "n" && t[a + 4] !== '"'; ) - o += ` -`, a += 2; - o += r, t[a + 2] === " " && (o += "\\"), a += 1, l = a + 1; - } - break; - default: - a += 1; - } - return o = l ? o + t.slice(l) : t, n ? o : ve(o, r, Ee, Be(e, !1)); -} -function Xe(s, e) { - if (e.options.singleQuote === !1 || e.implicitKey && s.includes(` -`) || /[ \t]\n|\n[ \t]/.test(s)) - return ge(s, e); - const t = e.indent || (De(s) ? " " : ""), n = "'" + s.replace(/'/g, "''").replace(/\n+/g, `$& -${t}`) + "'"; - return e.implicitKey ? n : ve(n, t, Dt, Be(e, !1)); -} -function se(s, e) { - const { singleQuote: t } = e.options; - let n; - if (t === !1) - n = ge; - else { - const i = s.includes('"'), r = s.includes("'"); - i && !r ? n = Xe : r && !i ? n = ge : n = t ? Xe : ge; - } - return n(s, e); -} -let Ze; -try { - Ze = new RegExp(`(^|(? -`; - let f, u; - for (u = t.length; u > 0; --u) { - const g = t[u - 1]; - if (g !== ` -` && g !== " " && g !== " ") - break; - } - let m = t.substring(u); - const y = m.indexOf(` -`); - y === -1 ? f = "-" : t === m || y !== m.length - 1 ? (f = "+", r && r()) : f = "", m && (t = t.slice(0, -m.length), m[m.length - 1] === ` -` && (m = m.slice(0, -1)), m = m.replace(Ze, `$&${c}`)); - let h = !1, p, b = -1; - for (p = 0; p < t.length; ++p) { - const g = t[p]; - if (g === " ") - h = !0; - else if (g === ` -`) - b = p; - else - break; - } - let w = t.substring(0, b < p ? b + 1 : p); - w && (t = t.substring(w.length), w = w.replace(/\n+/g, `$&${c}`)); - let k = (d ? "|" : ">") + (h ? c ? "2" : "1" : "") + f; - if (s && (k += " " + l(s.replace(/ ?[\r\n]+/g, " ")), i && i()), d) - return t = t.replace(/\n+/g, `$&${c}`), `${k} -${c}${w}${t}${m}`; - t = t.replace(/\n+/g, ` -$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${c}`); - const O = ve(`${w}${t}${m}`, c, He, Be(n, !0)); - return `${k} -${c}${O}`; -} -function Ss(s, e, t, n) { - const { type: i, value: r } = s, { actualString: o, implicitKey: l, indent: a, indentStep: c, inFlow: d } = e; - if (l && r.includes(` -`) || d && /[[\]{},]/.test(r)) - return se(r, e); - if (!r || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r)) - return l || d || !r.includes(` -`) ? se(r, e) : Le(s, e, t, n); - if (!l && !d && i !== N.PLAIN && r.includes(` -`)) - return Le(s, e, t, n); - if (De(r)) { - if (a === "") - return e.forceBlockIndent = !0, Le(s, e, t, n); - if (l && a === c) - return se(r, e); - } - const f = r.replace(/\n+/g, `$& -${a}`); - if (o) { - const u = (h) => { - var p; - return h.default && h.tag !== "tag:yaml.org,2002:str" && ((p = h.test) == null ? void 0 : p.test(f)); - }, { compat: m, tags: y } = e.doc.schema; - if (y.some(u) || m != null && m.some(u)) - return se(r, e); - } - return l ? f : ve(f, a, Dt, Be(e, !1)); -} -function it(s, e, t, n) { - const { implicitKey: i, inFlow: r } = e, o = typeof s.value == "string" ? s : Object.assign({}, s, { value: String(s.value) }); - let { type: l } = s; - l !== N.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (l = N.QUOTE_DOUBLE); - const a = (d) => { - switch (d) { - case N.BLOCK_FOLDED: - case N.BLOCK_LITERAL: - return i || r ? se(o.value, e) : Le(o, e, t, n); - case N.QUOTE_DOUBLE: - return ge(o.value, e); - case N.QUOTE_SINGLE: - return Xe(o.value, e); - case N.PLAIN: - return Ss(o, e, t, n); - default: - return null; - } - }; - let c = a(l); - if (c === null) { - const { defaultKeyType: d, defaultStringType: f } = e.options, u = i && d || f; - if (c = a(u), c === null) - throw new Error(`Unsupported default string type ${u}`); - } - return c; -} -function Mt(s, e) { - const t = Object.assign({ - blockQuote: !0, - commentString: ws, - defaultKeyType: null, - defaultStringType: "PLAIN", - directives: null, - doubleQuotedAsJSON: !1, - doubleQuotedMinMultiLineLength: 40, - falseStr: "false", - flowCollectionPadding: !0, - indentSeq: !0, - lineWidth: 80, - minContentWidth: 20, - nullStr: "null", - simpleKeys: !1, - singleQuote: null, - trueStr: "true", - verifyAliasOrder: !0 - }, s.schema.toStringOptions, e); - let n; - switch (t.collectionStyle) { - case "block": - n = !1; - break; - case "flow": - n = !0; - break; - default: - n = null; - } - return { - anchors: /* @__PURE__ */ new Set(), - doc: s, - flowCollectionPadding: t.flowCollectionPadding ? " " : "", - indent: "", - indentStep: typeof t.indent == "number" ? " ".repeat(t.indent) : " ", - inFlow: n, - options: t - }; -} -function Ns(s, e) { - var i; - if (e.tag) { - const r = s.filter((o) => o.tag === e.tag); - if (r.length > 0) - return r.find((o) => o.format === e.format) ?? r[0]; - } - let t, n; - if (A(e)) { - n = e.value; - const r = s.filter((o) => { - var l; - return (l = o.identify) == null ? void 0 : l.call(o, n); - }); - t = r.find((o) => o.format === e.format) ?? r.find((o) => !o.format); - } else - n = e, t = s.find((r) => r.nodeClass && n instanceof r.nodeClass); - if (!t) { - const r = ((i = n == null ? void 0 : n.constructor) == null ? void 0 : i.name) ?? typeof n; - throw new Error(`Tag not resolved for ${r} value`); - } - return t; -} -function Os(s, e, { anchors: t, doc: n }) { - if (!n.directives) - return ""; - const i = [], r = (A(s) || E(s)) && s.anchor; - r && _t(r) && (t.add(r), i.push(`&${r}`)); - const o = s.tag ? s.tag : e.default ? null : e.tag; - return o && i.push(n.directives.tagString(o)), i.join(" "); -} -function re(s, e, t, n) { - var a; - if (L(s)) - return s.toString(e, t, n); - if (ae(s)) { - if (e.doc.directives) - return s.toString(e); - if ((a = e.resolvedAliases) != null && a.has(s)) - throw new TypeError("Cannot stringify circular structure without alias nodes"); - e.resolvedAliases ? e.resolvedAliases.add(s) : e.resolvedAliases = /* @__PURE__ */ new Set([s]), s = s.resolve(e.doc); - } - let i; - const r = $(s) ? s : e.doc.createNode(s, { onTagObj: (c) => i = c }); - i || (i = Ns(e.doc.schema.tags, r)); - const o = Os(r, i, e); - o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1); - const l = typeof i.stringify == "function" ? i.stringify(r, e, t, n) : A(r) ? it(r, e, t, n) : r.toString(e, t, n); - return o ? A(r) || l[0] === "{" || l[0] === "[" ? `${o} ${l}` : `${o} -${e.indent}${l}` : l; -} -function As({ key: s, value: e }, t, n, i) { - const { allNullValues: r, doc: o, indent: l, indentStep: a, options: { commentString: c, indentSeq: d, simpleKeys: f } } = t; - let u = $(s) && s.comment || null; - if (f) { - if (u) - throw new Error("With simple keys, key nodes cannot have comments"); - if (E(s)) { - const I = "With simple keys, collection cannot be used as a key value"; - throw new Error(I); - } - } - let m = !f && (!s || u && e == null && !t.inFlow || E(s) || (A(s) ? s.type === N.BLOCK_FOLDED || s.type === N.BLOCK_LITERAL : typeof s == "object")); - t = Object.assign({}, t, { - allNullValues: !1, - implicitKey: !m && (f || !r), - indent: l + a - }); - let y = !1, h = !1, p = re(s, t, () => y = !0, () => h = !0); - if (!m && !t.inFlow && p.length > 1024) { - if (f) - throw new Error("With simple keys, single line scalar must not span more than 1024 characters"); - m = !0; - } - if (t.inFlow) { - if (r || e == null) - return y && n && n(), p === "" ? "?" : m ? `? ${p}` : p; - } else if (r && !f || e == null && m) - return p = `? ${p}`, u && !y ? p += W(p, t.indent, c(u)) : h && i && i(), p; - y && (u = null), m ? (u && (p += W(p, t.indent, c(u))), p = `? ${p} -${l}:`) : (p = `${p}:`, u && (p += W(p, t.indent, c(u)))); - let b, w, S; - $(e) ? (b = !!e.spaceBefore, w = e.commentBefore, S = e.comment) : (b = !1, w = null, S = null, e && typeof e == "object" && (e = o.createNode(e))), t.implicitKey = !1, !m && !u && A(e) && (t.indentAtStart = p.length + 1), h = !1, !d && a.length >= 2 && !t.inFlow && !m && ke(e) && !e.flow && !e.tag && !e.anchor && (t.indent = t.indent.substring(2)); - let k = !1; - const O = re(e, t, () => k = !0, () => h = !0); - let g = " "; - if (u || b || w) { - if (g = b ? ` -` : "", w) { - const I = c(w); - g += ` -${F(I, t.indent)}`; - } - O === "" && !t.inFlow ? g === ` -` && (g = ` - -`) : g += ` -${t.indent}`; - } else if (!m && E(e)) { - const I = O[0], T = O.indexOf(` -`), C = T !== -1, J = t.inFlow ?? e.flow ?? e.items.length === 0; - if (C || !J) { - let Z = !1; - if (C && (I === "&" || I === "!")) { - let _ = O.indexOf(" "); - I === "&" && _ !== -1 && _ < T && O[_ + 1] === "!" && (_ = O.indexOf(" ", _ + 1)), (_ === -1 || T < _) && (Z = !0); - } - Z || (g = ` -${t.indent}`); - } - } else - (O === "" || O[0] === ` -`) && (g = ""); - return p += g + O, t.inFlow ? k && n && n() : S && !k ? p += W(p, t.indent, c(S)) : h && i && i(), p; -} -function Pt(s, e) { - (s === "debug" || s === "warn") && (typeof process < "u" && process.emitWarning ? process.emitWarning(e) : console.warn(e)); -} -const yt = "<<"; -function jt(s, e, { key: t, value: n }) { - if (s != null && s.doc.schema.merge && Is(t)) - if (n = ae(n) ? n.resolve(s.doc) : n, ke(n)) - for (const i of n.items) - Fe(s, e, i); - else if (Array.isArray(n)) - for (const i of n) - Fe(s, e, i); - else - Fe(s, e, n); - else { - const i = P(t, "", s); - if (e instanceof Map) - e.set(i, P(n, i, s)); - else if (e instanceof Set) - e.add(i); - else { - const r = Ts(t, i, s), o = P(n, r, s); - r in e ? Object.defineProperty(e, r, { - value: o, - writable: !0, - enumerable: !0, - configurable: !0 - }) : e[r] = o; - } - } - return e; -} -const Is = (s) => s === yt || A(s) && s.value === yt && (!s.type || s.type === N.PLAIN); -function Fe(s, e, t) { - const n = s && ae(t) ? t.resolve(s.doc) : t; - if (!we(n)) - throw new Error("Merge sources must be maps or map aliases"); - const i = n.toJSON(null, s, Map); - for (const [r, o] of i) - e instanceof Map ? e.has(r) || e.set(r, o) : e instanceof Set ? e.add(r) : Object.prototype.hasOwnProperty.call(e, r) || Object.defineProperty(e, r, { - value: o, - writable: !0, - enumerable: !0, - configurable: !0 - }); - return e; -} -function Ts(s, e, t) { - if (e === null) - return ""; - if (typeof e != "object") - return String(e); - if ($(s) && (t != null && t.doc)) { - const n = Mt(t.doc, {}); - n.anchors = /* @__PURE__ */ new Set(); - for (const r of t.anchors.keys()) - n.anchors.add(r.anchor); - n.inFlow = !0, n.inStringifyKey = !0; - const i = s.toString(n); - if (!t.mapKeyWarned) { - let r = JSON.stringify(i); - r.length > 40 && (r = r.substring(0, 36) + '..."'), Pt(t.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`), t.mapKeyWarned = !0; - } - return i; - } - return JSON.stringify(e); -} -function rt(s, e, t) { - const n = ye(s, void 0, t), i = ye(e, void 0, t); - return new B(n, i); -} -class B { - constructor(e, t = null) { - Object.defineProperty(this, q, { value: $t }), this.key = e, this.value = t; - } - clone(e) { - let { key: t, value: n } = this; - return $(t) && (t = t.clone(e)), $(n) && (n = n.clone(e)), new B(t, n); - } - toJSON(e, t) { - const n = t != null && t.mapAsMap ? /* @__PURE__ */ new Map() : {}; - return jt(t, n, this); - } - toString(e, t, n) { - return e != null && e.doc ? As(this, e, t, n) : JSON.stringify(this); - } -} -function qt(s, e, t) { - return (e.inFlow ?? s.flow ? Ls : Es)(s, e, t); -} -function Es({ comment: s, items: e }, t, { blockItemPrefix: n, flowChars: i, itemIndent: r, onChompKeep: o, onComment: l }) { - const { indent: a, options: { commentString: c } } = t, d = Object.assign({}, t, { indent: r, type: null }); - let f = !1; - const u = []; - for (let y = 0; y < e.length; ++y) { - const h = e[y]; - let p = null; - if ($(h)) - !f && h.spaceBefore && u.push(""), _e(t, u, h.commentBefore, f), h.comment && (p = h.comment); - else if (L(h)) { - const w = $(h.key) ? h.key : null; - w && (!f && w.spaceBefore && u.push(""), _e(t, u, w.commentBefore, f)); - } - f = !1; - let b = re(h, d, () => p = null, () => f = !0); - p && (b += W(b, r, c(p))), f && p && (f = !1), u.push(n + b); - } - let m; - if (u.length === 0) - m = i.start + i.end; - else { - m = u[0]; - for (let y = 1; y < u.length; ++y) { - const h = u[y]; - m += h ? ` -${a}${h}` : ` -`; - } - } - return s ? (m += ` -` + F(c(s), a), l && l()) : f && o && o(), m; -} -function Ls({ items: s }, e, { flowChars: t, itemIndent: n }) { - const { indent: i, indentStep: r, flowCollectionPadding: o, options: { commentString: l } } = e; - n += r; - const a = Object.assign({}, e, { - indent: n, - inFlow: !0, - type: null - }); - let c = !1, d = 0; - const f = []; - for (let y = 0; y < s.length; ++y) { - const h = s[y]; - let p = null; - if ($(h)) - h.spaceBefore && f.push(""), _e(e, f, h.commentBefore, !1), h.comment && (p = h.comment); - else if (L(h)) { - const w = $(h.key) ? h.key : null; - w && (w.spaceBefore && f.push(""), _e(e, f, w.commentBefore, !1), w.comment && (c = !0)); - const S = $(h.value) ? h.value : null; - S ? (S.comment && (p = S.comment), S.commentBefore && (c = !0)) : h.value == null && (w != null && w.comment) && (p = w.comment); - } - p && (c = !0); - let b = re(h, a, () => p = null); - y < s.length - 1 && (b += ","), p && (b += W(b, n, l(p))), !c && (f.length > d || b.includes(` -`)) && (c = !0), f.push(b), d = f.length; - } - const { start: u, end: m } = t; - if (f.length === 0) - return u + m; - if (!c) { - const y = f.reduce((h, p) => h + p.length + 2, 2); - c = e.options.lineWidth > 0 && y > e.options.lineWidth; - } - if (c) { - let y = u; - for (const h of f) - y += h ? ` -${r}${i}${h}` : ` -`; - return `${y} -${i}${m}`; - } else - return `${u}${o}${f.join(" ")}${o}${m}`; -} -function _e({ indent: s, options: { commentString: e } }, t, n, i) { - if (n && i && (n = n.replace(/^\n+/, "")), n) { - const r = F(e(n), s); - t.push(r.trimStart()); - } -} -function Q(s, e) { - const t = A(e) ? e.value : e; - for (const n of s) - if (L(n) && (n.key === e || n.key === t || A(n.key) && n.key.value === t)) - return n; -} -class M extends nt { - static get tagName() { - return "tag:yaml.org,2002:map"; - } - constructor(e) { - super(V, e), this.items = []; - } - /** - * A generic collection parsing method that can be extended - * to other node classes that inherit from YAMLMap - */ - static from(e, t, n) { - const { keepUndefined: i, replacer: r } = n, o = new this(e), l = (a, c) => { - if (typeof r == "function") - c = r.call(t, a, c); - else if (Array.isArray(r) && !r.includes(a)) - return; - (c !== void 0 || i) && o.items.push(rt(a, c, n)); - }; - if (t instanceof Map) - for (const [a, c] of t) - l(a, c); - else if (t && typeof t == "object") - for (const a of Object.keys(t)) - l(a, t[a]); - return typeof e.sortMapEntries == "function" && o.items.sort(e.sortMapEntries), o; - } - /** - * Adds a value to the collection. - * - * @param overwrite - If not set `true`, using a key that is already in the - * collection will throw. Otherwise, overwrites the previous value. - */ - add(e, t) { - var o; - let n; - L(e) ? n = e : !e || typeof e != "object" || !("key" in e) ? n = new B(e, e == null ? void 0 : e.value) : n = new B(e.key, e.value); - const i = Q(this.items, n.key), r = (o = this.schema) == null ? void 0 : o.sortMapEntries; - if (i) { - if (!t) - throw new Error(`Key ${n.key} already set`); - A(i.value) && Bt(n.value) ? i.value.value = n.value : i.value = n.value; - } else if (r) { - const l = this.items.findIndex((a) => r(n, a) < 0); - l === -1 ? this.items.push(n) : this.items.splice(l, 0, n); - } else - this.items.push(n); - } - delete(e) { - const t = Q(this.items, e); - return t ? this.items.splice(this.items.indexOf(t), 1).length > 0 : !1; - } - get(e, t) { - const n = Q(this.items, e), i = n == null ? void 0 : n.value; - return (!t && A(i) ? i.value : i) ?? void 0; - } - has(e) { - return !!Q(this.items, e); - } - set(e, t) { - this.add(new B(e, t), !0); - } - /** - * @param ctx - Conversion context, originally set in Document#toJS() - * @param {Class} Type - If set, forces the returned collection type - * @returns Instance of Type, Map, or Object - */ - toJSON(e, t, n) { - const i = n ? new n() : t != null && t.mapAsMap ? /* @__PURE__ */ new Map() : {}; - t != null && t.onCreate && t.onCreate(i); - for (const r of this.items) - jt(t, i, r); - return i; - } - toString(e, t, n) { - if (!e) - return JSON.stringify(this); - for (const i of this.items) - if (!L(i)) - throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`); - return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })), qt(this, e, { - blockItemPrefix: "", - flowChars: { start: "{", end: "}" }, - itemIndent: e.indent || "", - onChompKeep: n, - onComment: t - }); - } -} -const ce = { - collection: "map", - default: !0, - nodeClass: M, - tag: "tag:yaml.org,2002:map", - resolve(s, e) { - return we(s) || e("Expected a mapping for this tag"), s; - }, - createNode: (s, e, t) => M.from(s, e, t) -}; -class X extends nt { - static get tagName() { - return "tag:yaml.org,2002:seq"; - } - constructor(e) { - super(le, e), this.items = []; - } - add(e) { - this.items.push(e); - } - /** - * Removes a value from the collection. - * - * `key` must contain a representation of an integer for this to succeed. - * It may be wrapped in a `Scalar`. - * - * @returns `true` if the item was found and removed. - */ - delete(e) { - const t = Oe(e); - return typeof t != "number" ? !1 : this.items.splice(t, 1).length > 0; - } - get(e, t) { - const n = Oe(e); - if (typeof n != "number") - return; - const i = this.items[n]; - return !t && A(i) ? i.value : i; - } - /** - * Checks if the collection includes a value with the key `key`. - * - * `key` must contain a representation of an integer for this to succeed. - * It may be wrapped in a `Scalar`. - */ - has(e) { - const t = Oe(e); - return typeof t == "number" && t < this.items.length; - } - /** - * Sets a value in this collection. For `!!set`, `value` needs to be a - * boolean to add/remove the item from the set. - * - * If `key` does not contain a representation of an integer, this will throw. - * It may be wrapped in a `Scalar`. - */ - set(e, t) { - const n = Oe(e); - if (typeof n != "number") - throw new Error(`Expected a valid index, not ${e}.`); - const i = this.items[n]; - A(i) && Bt(t) ? i.value = t : this.items[n] = t; - } - toJSON(e, t) { - const n = []; - t != null && t.onCreate && t.onCreate(n); - let i = 0; - for (const r of this.items) - n.push(P(r, String(i++), t)); - return n; - } - toString(e, t, n) { - return e ? qt(this, e, { - blockItemPrefix: "- ", - flowChars: { start: "[", end: "]" }, - itemIndent: (e.indent || "") + " ", - onChompKeep: n, - onComment: t - }) : JSON.stringify(this); - } - static from(e, t, n) { - const { replacer: i } = n, r = new this(e); - if (t && Symbol.iterator in Object(t)) { - let o = 0; - for (let l of t) { - if (typeof i == "function") { - const a = t instanceof Set ? l : String(o++); - l = i.call(t, a, l); - } - r.items.push(ye(l, void 0, n)); - } - } - return r; - } -} -function Oe(s) { - let e = A(s) ? s.value : s; - return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null; -} -const fe = { - collection: "seq", - default: !0, - nodeClass: X, - tag: "tag:yaml.org,2002:seq", - resolve(s, e) { - return ke(s) || e("Expected a sequence for this tag"), s; - }, - createNode: (s, e, t) => X.from(s, e, t) -}, Me = { - identify: (s) => typeof s == "string", - default: !0, - tag: "tag:yaml.org,2002:str", - resolve: (s) => s, - stringify(s, e, t, n) { - return e = Object.assign({ actualString: !0 }, e), it(s, e, t, n); - } -}, Pe = { - identify: (s) => s == null, - createNode: () => new N(null), - default: !0, - tag: "tag:yaml.org,2002:null", - test: /^(?:~|[Nn]ull|NULL)?$/, - resolve: () => new N(null), - stringify: ({ source: s }, e) => typeof s == "string" && Pe.test.test(s) ? s : e.options.nullStr -}, ot = { - identify: (s) => typeof s == "boolean", - default: !0, - tag: "tag:yaml.org,2002:bool", - test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/, - resolve: (s) => new N(s[0] === "t" || s[0] === "T"), - stringify({ source: s, value: e }, t) { - if (s && ot.test.test(s)) { - const n = s[0] === "t" || s[0] === "T"; - if (e === n) - return s; - } - return e ? t.options.trueStr : t.options.falseStr; - } -}; -function R({ format: s, minFractionDigits: e, tag: t, value: n }) { - if (typeof n == "bigint") - return String(n); - const i = typeof n == "number" ? n : Number(n); - if (!isFinite(i)) - return isNaN(i) ? ".nan" : i < 0 ? "-.inf" : ".inf"; - let r = JSON.stringify(n); - if (!s && e && (!t || t === "tag:yaml.org,2002:float") && /^\d/.test(r)) { - let o = r.indexOf("."); - o < 0 && (o = r.length, r += "."); - let l = e - (r.length - o - 1); - for (; l-- > 0; ) - r += "0"; - } - return r; -} -const Kt = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - test: /^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/, - resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, - stringify: R -}, Rt = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - format: "EXP", - test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/, - resolve: (s) => parseFloat(s), - stringify(s) { - const e = Number(s.value); - return isFinite(e) ? e.toExponential() : R(s); - } -}, Ft = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/, - resolve(s) { - const e = new N(parseFloat(s)), t = s.indexOf("."); - return t !== -1 && s[s.length - 1] === "0" && (e.minFractionDigits = s.length - t - 1), e; - }, - stringify: R -}, je = (s) => typeof s == "bigint" || Number.isInteger(s), lt = (s, e, t, { intAsBigInt: n }) => n ? BigInt(s) : parseInt(s.substring(e), t); -function Ut(s, e, t) { - const { value: n } = s; - return je(n) && n >= 0 ? t + n.toString(e) : R(s); -} -const Vt = { - identify: (s) => je(s) && s >= 0, - default: !0, - tag: "tag:yaml.org,2002:int", - format: "OCT", - test: /^0o[0-7]+$/, - resolve: (s, e, t) => lt(s, 2, 8, t), - stringify: (s) => Ut(s, 8, "0o") -}, Jt = { - identify: je, - default: !0, - tag: "tag:yaml.org,2002:int", - test: /^[-+]?[0-9]+$/, - resolve: (s, e, t) => lt(s, 0, 10, t), - stringify: R -}, Yt = { - identify: (s) => je(s) && s >= 0, - default: !0, - tag: "tag:yaml.org,2002:int", - format: "HEX", - test: /^0x[0-9a-fA-F]+$/, - resolve: (s, e, t) => lt(s, 2, 16, t), - stringify: (s) => Ut(s, 16, "0x") -}, $s = [ - ce, - fe, - Me, - Pe, - ot, - Vt, - Jt, - Yt, - Kt, - Rt, - Ft -]; -function bt(s) { - return typeof s == "bigint" || Number.isInteger(s); -} -const Ae = ({ value: s }) => JSON.stringify(s), _s = [ - { - identify: (s) => typeof s == "string", - default: !0, - tag: "tag:yaml.org,2002:str", - resolve: (s) => s, - stringify: Ae - }, - { - identify: (s) => s == null, - createNode: () => new N(null), - default: !0, - tag: "tag:yaml.org,2002:null", - test: /^null$/, - resolve: () => null, - stringify: Ae - }, - { - identify: (s) => typeof s == "boolean", - default: !0, - tag: "tag:yaml.org,2002:bool", - test: /^true|false$/, - resolve: (s) => s === "true", - stringify: Ae - }, - { - identify: bt, - default: !0, - tag: "tag:yaml.org,2002:int", - test: /^-?(?:0|[1-9][0-9]*)$/, - resolve: (s, e, { intAsBigInt: t }) => t ? BigInt(s) : parseInt(s, 10), - stringify: ({ value: s }) => bt(s) ? s.toString() : JSON.stringify(s) - }, - { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/, - resolve: (s) => parseFloat(s), - stringify: Ae - } -], Cs = { - default: !0, - tag: "", - test: /^/, - resolve(s, e) { - return e(`Unresolved plain scalar ${JSON.stringify(s)}`), s; - } -}, vs = [ce, fe].concat(_s, Cs), at = { - identify: (s) => s instanceof Uint8Array, - // Buffer inherits from Uint8Array - default: !1, - tag: "tag:yaml.org,2002:binary", - /** - * Returns a Buffer in node and an Uint8Array in browsers - * - * To use the resulting buffer as an image, you'll want to do something like: - * - * const blob = new Blob([buffer], { type: 'image/jpeg' }) - * document.querySelector('#photo').src = URL.createObjectURL(blob) - */ - resolve(s, e) { - if (typeof Buffer == "function") - return Buffer.from(s, "base64"); - if (typeof atob == "function") { - const t = atob(s.replace(/[\n\r]/g, "")), n = new Uint8Array(t.length); - for (let i = 0; i < t.length; ++i) - n[i] = t.charCodeAt(i); - return n; - } else - return e("This environment does not support reading binary tags; either Buffer or atob is required"), s; - }, - stringify({ comment: s, type: e, value: t }, n, i, r) { - const o = t; - let l; - if (typeof Buffer == "function") - l = o instanceof Buffer ? o.toString("base64") : Buffer.from(o.buffer).toString("base64"); - else if (typeof btoa == "function") { - let a = ""; - for (let c = 0; c < o.length; ++c) - a += String.fromCharCode(o[c]); - l = btoa(a); - } else - throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required"); - if (e || (e = N.BLOCK_LITERAL), e !== N.QUOTE_DOUBLE) { - const a = Math.max(n.options.lineWidth - n.indent.length, n.options.minContentWidth), c = Math.ceil(l.length / a), d = new Array(c); - for (let f = 0, u = 0; f < c; ++f, u += a) - d[f] = l.substr(u, a); - l = d.join(e === N.BLOCK_LITERAL ? ` -` : " "); - } - return it({ comment: s, type: e, value: l }, n, i, r); - } -}; -function Gt(s, e) { - if (ke(s)) - for (let t = 0; t < s.items.length; ++t) { - let n = s.items[t]; - if (!L(n)) { - if (we(n)) { - n.items.length > 1 && e("Each pair must have its own sequence indicator"); - const i = n.items[0] || new B(new N(null)); - if (n.commentBefore && (i.key.commentBefore = i.key.commentBefore ? `${n.commentBefore} -${i.key.commentBefore}` : n.commentBefore), n.comment) { - const r = i.value ?? i.key; - r.comment = r.comment ? `${n.comment} -${r.comment}` : n.comment; - } - n = i; - } - s.items[t] = L(n) ? n : new B(n); - } - } - else - e("Expected a sequence for this tag"); - return s; -} -function Wt(s, e, t) { - const { replacer: n } = t, i = new X(s); - i.tag = "tag:yaml.org,2002:pairs"; - let r = 0; - if (e && Symbol.iterator in Object(e)) - for (let o of e) { - typeof n == "function" && (o = n.call(e, String(r++), o)); - let l, a; - if (Array.isArray(o)) - if (o.length === 2) - l = o[0], a = o[1]; - else - throw new TypeError(`Expected [key, value] tuple: ${o}`); - else if (o && o instanceof Object) { - const c = Object.keys(o); - if (c.length === 1) - l = c[0], a = o[l]; - else - throw new TypeError(`Expected tuple with one key, not ${c.length} keys`); - } else - l = o; - i.items.push(rt(l, a, t)); - } - return i; -} -const ct = { - collection: "seq", - default: !1, - tag: "tag:yaml.org,2002:pairs", - resolve: Gt, - createNode: Wt -}; -class ne extends X { - constructor() { - super(), this.add = M.prototype.add.bind(this), this.delete = M.prototype.delete.bind(this), this.get = M.prototype.get.bind(this), this.has = M.prototype.has.bind(this), this.set = M.prototype.set.bind(this), this.tag = ne.tag; - } - /** - * If `ctx` is given, the return type is actually `Map`, - * but TypeScript won't allow widening the signature of a child method. - */ - toJSON(e, t) { - if (!t) - return super.toJSON(e); - const n = /* @__PURE__ */ new Map(); - t != null && t.onCreate && t.onCreate(n); - for (const i of this.items) { - let r, o; - if (L(i) ? (r = P(i.key, "", t), o = P(i.value, r, t)) : r = P(i, "", t), n.has(r)) - throw new Error("Ordered maps must not include duplicate keys"); - n.set(r, o); - } - return n; - } - static from(e, t, n) { - const i = Wt(e, t, n), r = new this(); - return r.items = i.items, r; - } -} -ne.tag = "tag:yaml.org,2002:omap"; -const ft = { - collection: "seq", - identify: (s) => s instanceof Map, - nodeClass: ne, - default: !1, - tag: "tag:yaml.org,2002:omap", - resolve(s, e) { - const t = Gt(s, e), n = []; - for (const { key: i } of t.items) - A(i) && (n.includes(i.value) ? e(`Ordered maps must not include duplicate keys: ${i.value}`) : n.push(i.value)); - return Object.assign(new ne(), t); - }, - createNode: (s, e, t) => ne.from(s, e, t) -}; -function Qt({ value: s, source: e }, t) { - return e && (s ? Ht : Xt).test.test(e) ? e : s ? t.options.trueStr : t.options.falseStr; -} -const Ht = { - identify: (s) => s === !0, - default: !0, - tag: "tag:yaml.org,2002:bool", - test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/, - resolve: () => new N(!0), - stringify: Qt -}, Xt = { - identify: (s) => s === !1, - default: !0, - tag: "tag:yaml.org,2002:bool", - test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/, - resolve: () => new N(!1), - stringify: Qt -}, Bs = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - test: /^[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN)$/, - resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, - stringify: R -}, Ds = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - format: "EXP", - test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/, - resolve: (s) => parseFloat(s.replace(/_/g, "")), - stringify(s) { - const e = Number(s.value); - return isFinite(e) ? e.toExponential() : R(s); - } -}, Ms = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/, - resolve(s) { - const e = new N(parseFloat(s.replace(/_/g, ""))), t = s.indexOf("."); - if (t !== -1) { - const n = s.substring(t + 1).replace(/_/g, ""); - n[n.length - 1] === "0" && (e.minFractionDigits = n.length); - } - return e; - }, - stringify: R -}, Se = (s) => typeof s == "bigint" || Number.isInteger(s); -function qe(s, e, t, { intAsBigInt: n }) { - const i = s[0]; - if ((i === "-" || i === "+") && (e += 1), s = s.substring(e).replace(/_/g, ""), n) { - switch (t) { - case 2: - s = `0b${s}`; - break; - case 8: - s = `0o${s}`; - break; - case 16: - s = `0x${s}`; - break; - } - const o = BigInt(s); - return i === "-" ? BigInt(-1) * o : o; - } - const r = parseInt(s, t); - return i === "-" ? -1 * r : r; -} -function ut(s, e, t) { - const { value: n } = s; - if (Se(n)) { - const i = n.toString(e); - return n < 0 ? "-" + t + i.substr(1) : t + i; - } - return R(s); -} -const Ps = { - identify: Se, - default: !0, - tag: "tag:yaml.org,2002:int", - format: "BIN", - test: /^[-+]?0b[0-1_]+$/, - resolve: (s, e, t) => qe(s, 2, 2, t), - stringify: (s) => ut(s, 2, "0b") -}, js = { - identify: Se, - default: !0, - tag: "tag:yaml.org,2002:int", - format: "OCT", - test: /^[-+]?0[0-7_]+$/, - resolve: (s, e, t) => qe(s, 1, 8, t), - stringify: (s) => ut(s, 8, "0") -}, qs = { - identify: Se, - default: !0, - tag: "tag:yaml.org,2002:int", - test: /^[-+]?[0-9][0-9_]*$/, - resolve: (s, e, t) => qe(s, 0, 10, t), - stringify: R -}, Ks = { - identify: Se, - default: !0, - tag: "tag:yaml.org,2002:int", - format: "HEX", - test: /^[-+]?0x[0-9a-fA-F_]+$/, - resolve: (s, e, t) => qe(s, 2, 16, t), - stringify: (s) => ut(s, 16, "0x") -}; -class ie extends M { - constructor(e) { - super(e), this.tag = ie.tag; - } - add(e) { - let t; - L(e) ? t = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? t = new B(e.key, null) : t = new B(e, null), Q(this.items, t.key) || this.items.push(t); - } - /** - * If `keepPair` is `true`, returns the Pair matching `key`. - * Otherwise, returns the value of that Pair's key. - */ - get(e, t) { - const n = Q(this.items, e); - return !t && L(n) ? A(n.key) ? n.key.value : n.key : n; - } - set(e, t) { - if (typeof t != "boolean") - throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`); - const n = Q(this.items, e); - n && !t ? this.items.splice(this.items.indexOf(n), 1) : !n && t && this.items.push(new B(e)); - } - toJSON(e, t) { - return super.toJSON(e, t, Set); - } - toString(e, t, n) { - if (!e) - return JSON.stringify(this); - if (this.hasAllNullValues(!0)) - return super.toString(Object.assign({}, e, { allNullValues: !0 }), t, n); - throw new Error("Set items must all have null values"); - } - static from(e, t, n) { - const { replacer: i } = n, r = new this(e); - if (t && Symbol.iterator in Object(t)) - for (let o of t) - typeof i == "function" && (o = i.call(t, o, o)), r.items.push(rt(o, null, n)); - return r; - } -} -ie.tag = "tag:yaml.org,2002:set"; -const ht = { - collection: "map", - identify: (s) => s instanceof Set, - nodeClass: ie, - default: !1, - tag: "tag:yaml.org,2002:set", - createNode: (s, e, t) => ie.from(s, e, t), - resolve(s, e) { - if (we(s)) { - if (s.hasAllNullValues(!0)) - return Object.assign(new ie(), s); - e("Set items must all have null values"); - } else - e("Expected a mapping for this tag"); - return s; - } -}; -function dt(s, e) { - const t = s[0], n = t === "-" || t === "+" ? s.substring(1) : s, i = (o) => e ? BigInt(o) : Number(o), r = n.replace(/_/g, "").split(":").reduce((o, l) => o * i(60) + i(l), i(0)); - return t === "-" ? i(-1) * r : r; -} -function Zt(s) { - let { value: e } = s, t = (o) => o; - if (typeof e == "bigint") - t = (o) => BigInt(o); - else if (isNaN(e) || !isFinite(e)) - return R(s); - let n = ""; - e < 0 && (n = "-", e *= t(-1)); - const i = t(60), r = [e % i]; - return e < 60 ? r.unshift(0) : (e = (e - r[0]) / i, r.unshift(e % i), e >= 60 && (e = (e - r[0]) / i, r.unshift(e))), n + r.map((o) => String(o).padStart(2, "0")).join(":").replace(/000000\d*$/, ""); -} -const zt = { - identify: (s) => typeof s == "bigint" || Number.isInteger(s), - default: !0, - tag: "tag:yaml.org,2002:int", - format: "TIME", - test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/, - resolve: (s, e, { intAsBigInt: t }) => dt(s, t), - stringify: Zt -}, xt = { - identify: (s) => typeof s == "number", - default: !0, - tag: "tag:yaml.org,2002:float", - format: "TIME", - test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/, - resolve: (s) => dt(s, !1), - stringify: Zt -}, Ke = { - identify: (s) => s instanceof Date, - default: !0, - tag: "tag:yaml.org,2002:timestamp", - // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part - // may be omitted altogether, resulting in a date format. In such a case, the time part is - // assumed to be 00:00:00Z (start of day, UTC). - test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"), - resolve(s) { - const e = s.match(Ke.test); - if (!e) - throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd"); - const [, t, n, i, r, o, l] = e.map(Number), a = e[7] ? Number((e[7] + "00").substr(1, 3)) : 0; - let c = Date.UTC(t, n - 1, i, r || 0, o || 0, l || 0, a); - const d = e[8]; - if (d && d !== "Z") { - let f = dt(d, !1); - Math.abs(f) < 30 && (f *= 60), c -= 6e4 * f; - } - return new Date(c); - }, - stringify: ({ value: s }) => s.toISOString().replace(/((T00:00)?:00)?\.000Z$/, "") -}, wt = [ - ce, - fe, - Me, - Pe, - Ht, - Xt, - Ps, - js, - qs, - Ks, - Bs, - Ds, - Ms, - at, - ft, - ct, - ht, - zt, - xt, - Ke -], kt = /* @__PURE__ */ new Map([ - ["core", $s], - ["failsafe", [ce, fe, Me]], - ["json", vs], - ["yaml11", wt], - ["yaml-1.1", wt] -]), St = { - binary: at, - bool: ot, - float: Ft, - floatExp: Rt, - floatNaN: Kt, - floatTime: xt, - int: Jt, - intHex: Yt, - intOct: Vt, - intTime: zt, - map: ce, - null: Pe, - omap: ft, - pairs: ct, - seq: fe, - set: ht, - timestamp: Ke -}, Rs = { - "tag:yaml.org,2002:binary": at, - "tag:yaml.org,2002:omap": ft, - "tag:yaml.org,2002:pairs": ct, - "tag:yaml.org,2002:set": ht, - "tag:yaml.org,2002:timestamp": Ke -}; -function Ue(s, e) { - let t = kt.get(e); - if (!t) - if (Array.isArray(s)) - t = []; - else { - const n = Array.from(kt.keys()).filter((i) => i !== "yaml11").map((i) => JSON.stringify(i)).join(", "); - throw new Error(`Unknown schema "${e}"; use one of ${n} or define customTags array`); - } - if (Array.isArray(s)) - for (const n of s) - t = t.concat(n); - else - typeof s == "function" && (t = s(t.slice())); - return t.map((n) => { - if (typeof n != "string") - return n; - const i = St[n]; - if (i) - return i; - const r = Object.keys(St).map((o) => JSON.stringify(o)).join(", "); - throw new Error(`Unknown custom tag "${n}"; use one of ${r}`); - }); -} -const Fs = (s, e) => s.key < e.key ? -1 : s.key > e.key ? 1 : 0; -class pt { - constructor({ compat: e, customTags: t, merge: n, resolveKnownTags: i, schema: r, sortMapEntries: o, toStringDefaults: l }) { - this.compat = Array.isArray(e) ? Ue(e, "compat") : e ? Ue(null, e) : null, this.merge = !!n, this.name = typeof r == "string" && r || "core", this.knownTags = i ? Rs : {}, this.tags = Ue(t, this.name), this.toStringOptions = l ?? null, Object.defineProperty(this, V, { value: ce }), Object.defineProperty(this, U, { value: Me }), Object.defineProperty(this, le, { value: fe }), this.sortMapEntries = typeof o == "function" ? o : o === !0 ? Fs : null; - } - clone() { - const e = Object.create(pt.prototype, Object.getOwnPropertyDescriptors(this)); - return e.tags = this.tags.slice(), e; - } -} -function Us(s, e) { - var a; - const t = []; - let n = e.directives === !0; - if (e.directives !== !1 && s.directives) { - const c = s.directives.toString(s); - c ? (t.push(c), n = !0) : s.directives.docStart && (n = !0); - } - n && t.push("---"); - const i = Mt(s, e), { commentString: r } = i.options; - if (s.commentBefore) { - t.length !== 1 && t.unshift(""); - const c = r(s.commentBefore); - t.unshift(F(c, "")); - } - let o = !1, l = null; - if (s.contents) { - if ($(s.contents)) { - if (s.contents.spaceBefore && n && t.push(""), s.contents.commentBefore) { - const f = r(s.contents.commentBefore); - t.push(F(f, "")); - } - i.forceBlockIndent = !!s.comment, l = s.contents.comment; - } - const c = l ? void 0 : () => o = !0; - let d = re(s.contents, i, () => l = null, c); - l && (d += W(d, "", r(l))), (d[0] === "|" || d[0] === ">") && t[t.length - 1] === "---" ? t[t.length - 1] = `--- ${d}` : t.push(d); - } else - t.push(re(s.contents, i)); - if ((a = s.directives) != null && a.docEnd) - if (s.comment) { - const c = r(s.comment); - c.includes(` -`) ? (t.push("..."), t.push(F(c, ""))) : t.push(`... ${c}`); - } else - t.push("..."); - else { - let c = s.comment; - c && o && (c = c.replace(/^\n+/, "")), c && ((!o || l) && t[t.length - 1] !== "" && t.push(""), t.push(F(r(c), ""))); - } - return t.join(` -`) + ` -`; -} -class Re { - constructor(e, t, n) { - this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this, q, { value: Qe }); - let i = null; - typeof t == "function" || Array.isArray(t) ? i = t : n === void 0 && t && (n = t, t = void 0); - const r = Object.assign({ - intAsBigInt: !1, - keepSourceTokens: !1, - logLevel: "warn", - prettyErrors: !0, - strict: !0, - uniqueKeys: !0, - version: "1.2" - }, n); - this.options = r; - let { version: o } = r; - n != null && n._directives ? (this.directives = n._directives.atDocument(), this.directives.yaml.explicit && (o = this.directives.yaml.version)) : this.directives = new v({ version: o }), this.setSchema(o, n), this.contents = e === void 0 ? null : this.createNode(e, i, n); - } - /** - * Create a deep copy of this Document and its contents. - * - * Custom Node values that inherit from `Object` still refer to their original instances. - */ - clone() { - const e = Object.create(Re.prototype, { - [q]: { value: Qe } - }); - return e.commentBefore = this.commentBefore, e.comment = this.comment, e.errors = this.errors.slice(), e.warnings = this.warnings.slice(), e.options = Object.assign({}, this.options), this.directives && (e.directives = this.directives.clone()), e.schema = this.schema.clone(), e.contents = $(this.contents) ? this.contents.clone(e.schema) : this.contents, this.range && (e.range = this.range.slice()), e; - } - /** Adds a value to the document. */ - add(e) { - z(this.contents) && this.contents.add(e); - } - /** Adds a value to the document. */ - addIn(e, t) { - z(this.contents) && this.contents.addIn(e, t); - } - /** - * Create a new `Alias` node, ensuring that the target `node` has the required anchor. - * - * If `node` already has an anchor, `name` is ignored. - * Otherwise, the `node.anchor` value will be set to `name`, - * or if an anchor with that name is already present in the document, - * `name` will be used as a prefix for a new unique anchor. - * If `name` is undefined, the generated anchor will use 'a' as a prefix. - */ - createAlias(e, t) { - if (!e.anchor) { - const n = Ct(this); - e.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - !t || n.has(t) ? vt(t || "a", n) : t; - } - return new st(e.anchor); - } - createNode(e, t, n) { - let i; - if (typeof t == "function") - e = t.call({ "": e }, "", e), i = t; - else if (Array.isArray(t)) { - const p = (w) => typeof w == "number" || w instanceof String || w instanceof Number, b = t.filter(p).map(String); - b.length > 0 && (t = t.concat(b)), i = t; - } else - n === void 0 && t && (n = t, t = void 0); - const { aliasDuplicateObjects: r, anchorPrefix: o, flow: l, keepUndefined: a, onTagObj: c, tag: d } = n ?? {}, { onAnchor: f, setAnchors: u, sourceObjects: m } = gs( - this, - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - o || "a" - ), y = { - aliasDuplicateObjects: r ?? !0, - keepUndefined: a ?? !1, - onAnchor: f, - onTagObj: c, - replacer: i, - schema: this.schema, - sourceObjects: m - }, h = ye(e, d, y); - return l && E(h) && (h.flow = !0), u(), h; - } - /** - * Convert a key and a value into a `Pair` using the current schema, - * recursively wrapping all values as `Scalar` or `Collection` nodes. - */ - createPair(e, t, n = {}) { - const i = this.createNode(e, null, n), r = this.createNode(t, null, n); - return new B(i, r); - } - /** - * Removes a value from the document. - * @returns `true` if the item was found and removed. - */ - delete(e) { - return z(this.contents) ? this.contents.delete(e) : !1; - } - /** - * Removes a value from the document. - * @returns `true` if the item was found and removed. - */ - deleteIn(e) { - return de(e) ? this.contents == null ? !1 : (this.contents = null, !0) : z(this.contents) ? this.contents.deleteIn(e) : !1; - } - /** - * Returns item at `key`, or `undefined` if not found. By default unwraps - * scalar values from their surrounding node; to disable set `keepScalar` to - * `true` (collections are always returned intact). - */ - get(e, t) { - return E(this.contents) ? this.contents.get(e, t) : void 0; - } - /** - * Returns item at `path`, or `undefined` if not found. By default unwraps - * scalar values from their surrounding node; to disable set `keepScalar` to - * `true` (collections are always returned intact). - */ - getIn(e, t) { - return de(e) ? !t && A(this.contents) ? this.contents.value : this.contents : E(this.contents) ? this.contents.getIn(e, t) : void 0; - } - /** - * Checks if the document includes a value with the key `key`. - */ - has(e) { - return E(this.contents) ? this.contents.has(e) : !1; - } - /** - * Checks if the document includes a value at `path`. - */ - hasIn(e) { - return de(e) ? this.contents !== void 0 : E(this.contents) ? this.contents.hasIn(e) : !1; - } - /** - * Sets a value in this document. For `!!set`, `value` needs to be a - * boolean to add/remove the item from the set. - */ - set(e, t) { - this.contents == null ? this.contents = $e(this.schema, [e], t) : z(this.contents) && this.contents.set(e, t); - } - /** - * Sets a value in this document. For `!!set`, `value` needs to be a - * boolean to add/remove the item from the set. - */ - setIn(e, t) { - de(e) ? this.contents = t : this.contents == null ? this.contents = $e(this.schema, Array.from(e), t) : z(this.contents) && this.contents.setIn(e, t); - } - /** - * Change the YAML version and schema used by the document. - * A `null` version disables support for directives, explicit tags, anchors, and aliases. - * It also requires the `schema` option to be given as a `Schema` instance value. - * - * Overrides all previously set schema options. - */ - setSchema(e, t = {}) { - typeof e == "number" && (e = String(e)); - let n; - switch (e) { - case "1.1": - this.directives ? this.directives.yaml.version = "1.1" : this.directives = new v({ version: "1.1" }), n = { merge: !0, resolveKnownTags: !1, schema: "yaml-1.1" }; - break; - case "1.2": - case "next": - this.directives ? this.directives.yaml.version = e : this.directives = new v({ version: e }), n = { merge: !1, resolveKnownTags: !0, schema: "core" }; - break; - case null: - this.directives && delete this.directives, n = null; - break; - default: { - const i = JSON.stringify(e); - throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`); - } - } - if (t.schema instanceof Object) - this.schema = t.schema; - else if (n) - this.schema = new pt(Object.assign(n, t)); - else - throw new Error("With a null YAML version, the { schema: Schema } option is required"); - } - // json & jsonArg are only used from toJSON() - toJS({ json: e, jsonArg: t, mapAsMap: n, maxAliasCount: i, onAnchor: r, reviver: o } = {}) { - const l = { - anchors: /* @__PURE__ */ new Map(), - doc: this, - keep: !e, - mapAsMap: n === !0, - mapKeyWarned: !1, - maxAliasCount: typeof i == "number" ? i : 100 - }, a = P(this.contents, t ?? "", l); - if (typeof r == "function") - for (const { count: c, res: d } of l.anchors.values()) - r(d, c); - return typeof o == "function" ? te(o, { "": a }, "", a) : a; - } - /** - * A JSON representation of the document `contents`. - * - * @param jsonArg Used by `JSON.stringify` to indicate the array index or - * property name. - */ - toJSON(e, t) { - return this.toJS({ json: !0, jsonArg: e, mapAsMap: !1, onAnchor: t }); - } - /** A YAML representation of the document. */ - toString(e = {}) { - if (this.errors.length > 0) - throw new Error("Document with errors cannot be stringified"); - if ("indent" in e && (!Number.isInteger(e.indent) || Number(e.indent) <= 0)) { - const t = JSON.stringify(e.indent); - throw new Error(`"indent" option must be a positive integer, not ${t}`); - } - return Us(this, e); - } -} -function z(s) { - if (E(s)) - return !0; - throw new Error("Expected a YAML collection as document contents"); -} -class es extends Error { - constructor(e, t, n, i) { - super(), this.name = e, this.code = n, this.message = i, this.pos = t; - } -} -class pe extends es { - constructor(e, t, n) { - super("YAMLParseError", e, t, n); - } -} -class Vs extends es { - constructor(e, t, n) { - super("YAMLWarning", e, t, n); - } -} -const Nt = (s, e) => (t) => { - if (t.pos[0] === -1) - return; - t.linePos = t.pos.map((l) => e.linePos(l)); - const { line: n, col: i } = t.linePos[0]; - t.message += ` at line ${n}, column ${i}`; - let r = i - 1, o = s.substring(e.lineStarts[n - 1], e.lineStarts[n]).replace(/[\n\r]+$/, ""); - if (r >= 60 && o.length > 80) { - const l = Math.min(r - 39, o.length - 79); - o = "…" + o.substring(l), r -= l - 1; - } - if (o.length > 80 && (o = o.substring(0, 79) + "…"), n > 1 && /^ *$/.test(o.substring(0, r))) { - let l = s.substring(e.lineStarts[n - 2], e.lineStarts[n - 1]); - l.length > 80 && (l = l.substring(0, 79) + `… -`), o = l + o; - } - if (/[^ ]/.test(o)) { - let l = 1; - const a = t.linePos[1]; - a && a.line === n && a.col > i && (l = Math.max(1, Math.min(a.col - i, 80 - r))); - const c = " ".repeat(r) + "^".repeat(l); - t.message += `: - -${o} -${c} -`; - } -}; -function oe(s, { flow: e, indicator: t, next: n, offset: i, onError: r, startOnNewline: o }) { - let l = !1, a = o, c = o, d = "", f = "", u = !1, m = !1, y = !1, h = null, p = null, b = null, w = null, S = null; - for (const g of s) - switch (y && (g.type !== "space" && g.type !== "newline" && g.type !== "comma" && r(g.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), y = !1), g.type) { - case "space": - !e && a && t !== "doc-start" && g.source[0] === " " && r(g, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), c = !0; - break; - case "comment": { - c || r(g, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); - const I = g.source.substring(1) || " "; - d ? d += f + I : d = I, f = "", a = !1; - break; - } - case "newline": - a ? d ? d += g.source : l = !0 : f += g.source, a = !0, u = !0, (h || p) && (m = !0), c = !0; - break; - case "anchor": - h && r(g, "MULTIPLE_ANCHORS", "A node can have at most one anchor"), g.source.endsWith(":") && r(g.offset + g.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", !0), h = g, S === null && (S = g.offset), a = !1, c = !1, y = !0; - break; - case "tag": { - p && r(g, "MULTIPLE_TAGS", "A node can have at most one tag"), p = g, S === null && (S = g.offset), a = !1, c = !1, y = !0; - break; - } - case t: - (h || p) && r(g, "BAD_PROP_ORDER", `Anchors and tags must be after the ${g.source} indicator`), w && r(g, "UNEXPECTED_TOKEN", `Unexpected ${g.source} in ${e ?? "collection"}`), w = g, a = !1, c = !1; - break; - case "comma": - if (e) { - b && r(g, "UNEXPECTED_TOKEN", `Unexpected , in ${e}`), b = g, a = !1, c = !1; - break; - } - default: - r(g, "UNEXPECTED_TOKEN", `Unexpected ${g.type} token`), a = !1, c = !1; - } - const k = s[s.length - 1], O = k ? k.offset + k.source.length : i; - return y && n && n.type !== "space" && n.type !== "newline" && n.type !== "comma" && (n.type !== "scalar" || n.source !== "") && r(n.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), { - comma: b, - found: w, - spaceBefore: l, - comment: d, - hasNewline: u, - hasNewlineAfterProp: m, - anchor: h, - tag: p, - end: O, - start: S ?? O - }; -} -function be(s) { - if (!s) - return null; - switch (s.type) { - case "alias": - case "scalar": - case "double-quoted-scalar": - case "single-quoted-scalar": - if (s.source.includes(` -`)) - return !0; - if (s.end) { - for (const e of s.end) - if (e.type === "newline") - return !0; - } - return !1; - case "flow-collection": - for (const e of s.items) { - for (const t of e.start) - if (t.type === "newline") - return !0; - if (e.sep) { - for (const t of e.sep) - if (t.type === "newline") - return !0; - } - if (be(e.key) || be(e.value)) - return !0; - } - return !1; - default: - return !0; - } -} -function ze(s, e, t) { - if ((e == null ? void 0 : e.type) === "flow-collection") { - const n = e.end[0]; - n.indent === s && (n.source === "]" || n.source === "}") && be(e) && t(n, "BAD_INDENT", "Flow end indicator should be more indented than parent", !0); - } -} -function ts(s, e, t) { - const { uniqueKeys: n } = s.options; - if (n === !1) - return !1; - const i = typeof n == "function" ? n : (r, o) => r === o || A(r) && A(o) && r.value === o.value && !(r.value === "<<" && s.schema.merge); - return e.some((r) => i(r.key, t)); -} -const Ot = "All mapping items must start at the same column"; -function Js({ composeNode: s, composeEmptyNode: e }, t, n, i, r) { - var d; - const o = (r == null ? void 0 : r.nodeClass) ?? M, l = new o(t.schema); - t.atRoot && (t.atRoot = !1); - let a = n.offset, c = null; - for (const f of n.items) { - const { start: u, key: m, sep: y, value: h } = f, p = oe(u, { - indicator: "explicit-key-ind", - next: m ?? (y == null ? void 0 : y[0]), - offset: a, - onError: i, - startOnNewline: !0 - }), b = !p.found; - if (b) { - if (m && (m.type === "block-seq" ? i(a, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key") : "indent" in m && m.indent !== n.indent && i(a, "BAD_INDENT", Ot)), !p.anchor && !p.tag && !y) { - c = p.end, p.comment && (l.comment ? l.comment += ` -` + p.comment : l.comment = p.comment); - continue; - } - (p.hasNewlineAfterProp || be(m)) && i(m ?? u[u.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line"); - } else - ((d = p.found) == null ? void 0 : d.indent) !== n.indent && i(a, "BAD_INDENT", Ot); - const w = p.end, S = m ? s(t, m, p, i) : e(t, w, u, null, p, i); - t.schema.compat && ze(n.indent, m, i), ts(t, l.items, S) && i(w, "DUPLICATE_KEY", "Map keys must be unique"); - const k = oe(y ?? [], { - indicator: "map-value-ind", - next: h, - offset: S.range[2], - onError: i, - startOnNewline: !m || m.type === "block-scalar" - }); - if (a = k.end, k.found) { - b && ((h == null ? void 0 : h.type) === "block-map" && !k.hasNewline && i(a, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"), t.options.strict && p.start < k.found.offset - 1024 && i(S.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key")); - const O = h ? s(t, h, k, i) : e(t, a, y, null, k, i); - t.schema.compat && ze(n.indent, h, i), a = O.range[2]; - const g = new B(S, O); - t.options.keepSourceTokens && (g.srcToken = f), l.items.push(g); - } else { - b && i(S.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"), k.comment && (S.comment ? S.comment += ` -` + k.comment : S.comment = k.comment); - const O = new B(S); - t.options.keepSourceTokens && (O.srcToken = f), l.items.push(O); - } - } - return c && c < a && i(c, "IMPOSSIBLE", "Map comment with trailing content"), l.range = [n.offset, a, c ?? a], l; -} -function Ys({ composeNode: s, composeEmptyNode: e }, t, n, i, r) { - const o = (r == null ? void 0 : r.nodeClass) ?? X, l = new o(t.schema); - t.atRoot && (t.atRoot = !1); - let a = n.offset, c = null; - for (const { start: d, value: f } of n.items) { - const u = oe(d, { - indicator: "seq-item-ind", - next: f, - offset: a, - onError: i, - startOnNewline: !0 - }); - if (!u.found) - if (u.anchor || u.tag || f) - f && f.type === "block-seq" ? i(u.end, "BAD_INDENT", "All sequence items must start at the same column") : i(a, "MISSING_CHAR", "Sequence item without - indicator"); - else { - c = u.end, u.comment && (l.comment = u.comment); - continue; - } - const m = f ? s(t, f, u, i) : e(t, u.end, d, null, u, i); - t.schema.compat && ze(n.indent, f, i), a = m.range[2], l.items.push(m); - } - return l.range = [n.offset, a, c ?? a], l; -} -function Ne(s, e, t, n) { - let i = ""; - if (s) { - let r = !1, o = ""; - for (const l of s) { - const { source: a, type: c } = l; - switch (c) { - case "space": - r = !0; - break; - case "comment": { - t && !r && n(l, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); - const d = a.substring(1) || " "; - i ? i += o + d : i = d, o = ""; - break; - } - case "newline": - i && (o += a), r = !0; - break; - default: - n(l, "UNEXPECTED_TOKEN", `Unexpected ${c} at node end`); - } - e += a.length; - } - } - return { comment: i, offset: e }; -} -const Ve = "Block collections are not allowed within flow collections", Je = (s) => s && (s.type === "block-map" || s.type === "block-seq"); -function Gs({ composeNode: s, composeEmptyNode: e }, t, n, i, r) { - const o = n.start.source === "{", l = o ? "flow map" : "flow sequence", a = (r == null ? void 0 : r.nodeClass) ?? (o ? M : X), c = new a(t.schema); - c.flow = !0; - const d = t.atRoot; - d && (t.atRoot = !1); - let f = n.offset + n.start.source.length; - for (let p = 0; p < n.items.length; ++p) { - const b = n.items[p], { start: w, key: S, sep: k, value: O } = b, g = oe(w, { - flow: l, - indicator: "explicit-key-ind", - next: S ?? (k == null ? void 0 : k[0]), - offset: f, - onError: i, - startOnNewline: !1 - }); - if (!g.found) { - if (!g.anchor && !g.tag && !k && !O) { - p === 0 && g.comma ? i(g.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${l}`) : p < n.items.length - 1 && i(g.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${l}`), g.comment && (c.comment ? c.comment += ` -` + g.comment : c.comment = g.comment), f = g.end; - continue; - } - !o && t.options.strict && be(S) && i( - S, - // checked by containsNewline() - "MULTILINE_IMPLICIT_KEY", - "Implicit keys of flow sequence pairs need to be on a single line" - ); - } - if (p === 0) - g.comma && i(g.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${l}`); - else if (g.comma || i(g.start, "MISSING_CHAR", `Missing , between ${l} items`), g.comment) { - let I = ""; - e: - for (const T of w) - switch (T.type) { - case "comma": - case "space": - break; - case "comment": - I = T.source.substring(1); - break e; - default: - break e; - } - if (I) { - let T = c.items[c.items.length - 1]; - L(T) && (T = T.value ?? T.key), T.comment ? T.comment += ` -` + I : T.comment = I, g.comment = g.comment.substring(I.length + 1); - } - } - if (!o && !k && !g.found) { - const I = O ? s(t, O, g, i) : e(t, g.end, k, null, g, i); - c.items.push(I), f = I.range[2], Je(O) && i(I.range, "BLOCK_IN_FLOW", Ve); - } else { - const I = g.end, T = S ? s(t, S, g, i) : e(t, I, w, null, g, i); - Je(S) && i(T.range, "BLOCK_IN_FLOW", Ve); - const C = oe(k ?? [], { - flow: l, - indicator: "map-value-ind", - next: O, - offset: T.range[2], - onError: i, - startOnNewline: !1 - }); - if (C.found) { - if (!o && !g.found && t.options.strict) { - if (k) - for (const _ of k) { - if (_ === C.found) - break; - if (_.type === "newline") { - i(_, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line"); - break; - } - } - g.start < C.found.offset - 1024 && i(C.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key"); - } - } else - O && ("source" in O && O.source && O.source[0] === ":" ? i(O, "MISSING_CHAR", `Missing space after : in ${l}`) : i(C.start, "MISSING_CHAR", `Missing , or : between ${l} items`)); - const J = O ? s(t, O, C, i) : C.found ? e(t, C.end, k, null, C, i) : null; - J ? Je(O) && i(J.range, "BLOCK_IN_FLOW", Ve) : C.comment && (T.comment ? T.comment += ` -` + C.comment : T.comment = C.comment); - const Z = new B(T, J); - if (t.options.keepSourceTokens && (Z.srcToken = b), o) { - const _ = c; - ts(t, _.items, T) && i(I, "DUPLICATE_KEY", "Map keys must be unique"), _.items.push(Z); - } else { - const _ = new M(t.schema); - _.flow = !0, _.items.push(Z), c.items.push(_); - } - f = J ? J.range[2] : C.end; - } - } - const u = o ? "}" : "]", [m, ...y] = n.end; - let h = f; - if (m && m.source === u) - h = m.offset + m.source.length; - else { - const p = l[0].toUpperCase() + l.substring(1), b = d ? `${p} must end with a ${u}` : `${p} in block collection must be sufficiently indented and end with a ${u}`; - i(f, d ? "MISSING_CHAR" : "BAD_INDENT", b), m && m.source.length !== 1 && y.unshift(m); - } - if (y.length > 0) { - const p = Ne(y, h, t.options.strict, i); - p.comment && (c.comment ? c.comment += ` -` + p.comment : c.comment = p.comment), c.range = [n.offset, h, p.offset]; - } else - c.range = [n.offset, h, h]; - return c; -} -function Ye(s, e, t, n, i, r) { - const o = t.type === "block-map" ? Js(s, e, t, n, r) : t.type === "block-seq" ? Ys(s, e, t, n, r) : Gs(s, e, t, n, r), l = o.constructor; - return i === "!" || i === l.tagName ? (o.tag = l.tagName, o) : (i && (o.tag = i), o); -} -function Ws(s, e, t, n, i) { - var f; - const r = n ? e.directives.tagName(n.source, (u) => i(n, "TAG_RESOLVE_FAILED", u)) : null, o = t.type === "block-map" ? "map" : t.type === "block-seq" ? "seq" : t.start.source === "{" ? "map" : "seq"; - if (!n || !r || r === "!" || r === M.tagName && o === "map" || r === X.tagName && o === "seq" || !o) - return Ye(s, e, t, i, r); - let l = e.schema.tags.find((u) => u.tag === r && u.collection === o); - if (!l) { - const u = e.schema.knownTags[r]; - if (u && u.collection === o) - e.schema.tags.push(Object.assign({}, u, { default: !1 })), l = u; - else - return u != null && u.collection ? i(n, "BAD_COLLECTION_TYPE", `${u.tag} used for ${o} collection, but expects ${u.collection}`, !0) : i(n, "TAG_RESOLVE_FAILED", `Unresolved tag: ${r}`, !0), Ye(s, e, t, i, r); - } - const a = Ye(s, e, t, i, r, l), c = ((f = l.resolve) == null ? void 0 : f.call(l, a, (u) => i(n, "TAG_RESOLVE_FAILED", u), e.options)) ?? a, d = $(c) ? c : new N(c); - return d.range = a.range, d.tag = r, l != null && l.format && (d.format = l.format), d; -} -function Qs(s, e, t) { - const n = s.offset, i = Hs(s, e, t); - if (!i) - return { value: "", type: null, comment: "", range: [n, n, n] }; - const r = i.mode === ">" ? N.BLOCK_FOLDED : N.BLOCK_LITERAL, o = s.source ? Xs(s.source) : []; - let l = o.length; - for (let h = o.length - 1; h >= 0; --h) { - const p = o[h][1]; - if (p === "" || p === "\r") - l = h; - else - break; - } - if (l === 0) { - const h = i.chomp === "+" && o.length > 0 ? ` -`.repeat(Math.max(1, o.length - 1)) : ""; - let p = n + i.length; - return s.source && (p += s.source.length), { value: h, type: r, comment: i.comment, range: [n, p, p] }; - } - let a = s.indent + i.indent, c = s.offset + i.length, d = 0; - for (let h = 0; h < l; ++h) { - const [p, b] = o[h]; - if (b === "" || b === "\r") - i.indent === 0 && p.length > a && (a = p.length); - else { - p.length < a && t(c + p.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"), i.indent === 0 && (a = p.length), d = h; - break; - } - c += p.length + b.length + 1; - } - for (let h = o.length - 1; h >= l; --h) - o[h][0].length > a && (l = h + 1); - let f = "", u = "", m = !1; - for (let h = 0; h < d; ++h) - f += o[h][0].slice(a) + ` -`; - for (let h = d; h < l; ++h) { - let [p, b] = o[h]; - c += p.length + b.length + 1; - const w = b[b.length - 1] === "\r"; - if (w && (b = b.slice(0, -1)), b && p.length < a) { - const k = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`; - t(c - b.length - (w ? 2 : 1), "BAD_INDENT", k), p = ""; - } - r === N.BLOCK_LITERAL ? (f += u + p.slice(a) + b, u = ` -`) : p.length > a || b[0] === " " ? (u === " " ? u = ` -` : !m && u === ` -` && (u = ` - -`), f += u + p.slice(a) + b, u = ` -`, m = !0) : b === "" ? u === ` -` ? f += ` -` : u = ` -` : (f += u + b, u = " ", m = !1); - } - switch (i.chomp) { - case "-": - break; - case "+": - for (let h = l; h < o.length; ++h) - f += ` -` + o[h][0].slice(a); - f[f.length - 1] !== ` -` && (f += ` -`); - break; - default: - f += ` -`; - } - const y = n + i.length + s.source.length; - return { value: f, type: r, comment: i.comment, range: [n, y, y] }; -} -function Hs({ offset: s, props: e }, t, n) { - if (e[0].type !== "block-scalar-header") - return n(e[0], "IMPOSSIBLE", "Block scalar header not found"), null; - const { source: i } = e[0], r = i[0]; - let o = 0, l = "", a = -1; - for (let u = 1; u < i.length; ++u) { - const m = i[u]; - if (!l && (m === "-" || m === "+")) - l = m; - else { - const y = Number(m); - !o && y ? o = y : a === -1 && (a = s + u); - } - } - a !== -1 && n(a, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${i}`); - let c = !1, d = "", f = i.length; - for (let u = 1; u < e.length; ++u) { - const m = e[u]; - switch (m.type) { - case "space": - c = !0; - case "newline": - f += m.source.length; - break; - case "comment": - t && !c && n(m, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"), f += m.source.length, d = m.source.substring(1); - break; - case "error": - n(m, "UNEXPECTED_TOKEN", m.message), f += m.source.length; - break; - default: { - const y = `Unexpected token in block scalar header: ${m.type}`; - n(m, "UNEXPECTED_TOKEN", y); - const h = m.source; - h && typeof h == "string" && (f += h.length); - } - } - } - return { mode: r, indent: o, chomp: l, comment: d, length: f }; -} -function Xs(s) { - const e = s.split(/\n( *)/), t = e[0], n = t.match(/^( *)/), r = [n != null && n[1] ? [n[1], t.slice(n[1].length)] : ["", t]]; - for (let o = 1; o < e.length; o += 2) - r.push([e[o], e[o + 1]]); - return r; -} -function Zs(s, e, t) { - const { offset: n, type: i, source: r, end: o } = s; - let l, a; - const c = (u, m, y) => t(n + u, m, y); - switch (i) { - case "scalar": - l = N.PLAIN, a = zs(r, c); - break; - case "single-quoted-scalar": - l = N.QUOTE_SINGLE, a = xs(r, c); - break; - case "double-quoted-scalar": - l = N.QUOTE_DOUBLE, a = en(r, c); - break; - default: - return t(s, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${i}`), { - value: "", - type: null, - comment: "", - range: [n, n + r.length, n + r.length] - }; - } - const d = n + r.length, f = Ne(o, d, e, t); - return { - value: a, - type: l, - comment: f.comment, - range: [n, d, f.offset] - }; -} -function zs(s, e) { - let t = ""; - switch (s[0]) { - case " ": - t = "a tab character"; - break; - case ",": - t = "flow indicator character ,"; - break; - case "%": - t = "directive indicator character %"; - break; - case "|": - case ">": { - t = `block scalar indicator ${s[0]}`; - break; - } - case "@": - case "`": { - t = `reserved character ${s[0]}`; - break; - } - } - return t && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${t}`), ss(s); -} -function xs(s, e) { - return (s[s.length - 1] !== "'" || s.length === 1) && e(s.length, "MISSING_CHAR", "Missing closing 'quote"), ss(s.slice(1, -1)).replace(/''/g, "'"); -} -function ss(s) { - let e, t; - try { - e = new RegExp(`(.*?)(? r ? s.slice(r, n + 1) : i); - } else - t += i; - } - return (s[s.length - 1] !== '"' || s.length === 1) && e(s.length, "MISSING_CHAR", 'Missing closing "quote'), t; -} -function tn(s, e) { - let t = "", n = s[e + 1]; - for (; (n === " " || n === " " || n === ` -` || n === "\r") && !(n === "\r" && s[e + 2] !== ` -`); ) - n === ` -` && (t += ` -`), e += 1, n = s[e + 1]; - return t || (t = " "), { fold: t, offset: e }; -} -const sn = { - 0: "\0", - // null character - a: "\x07", - // bell character - b: "\b", - // backspace - e: "\x1B", - // escape character - f: "\f", - // form feed - n: ` -`, - // line feed - r: "\r", - // carriage return - t: " ", - // horizontal tab - v: "\v", - // vertical tab - N: "…", - // Unicode next line - _: " ", - // Unicode non-breaking space - L: "\u2028", - // Unicode line separator - P: "\u2029", - // Unicode paragraph separator - " ": " ", - '"': '"', - "/": "/", - "\\": "\\", - " ": " " -}; -function nn(s, e, t, n) { - const i = s.substr(e, t), o = i.length === t && /^[0-9a-fA-F]+$/.test(i) ? parseInt(i, 16) : NaN; - if (isNaN(o)) { - const l = s.substr(e - 2, t + 2); - return n(e - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${l}`), l; - } - return String.fromCodePoint(o); -} -function ns(s, e, t, n) { - const { value: i, type: r, comment: o, range: l } = e.type === "block-scalar" ? Qs(e, s.options.strict, n) : Zs(e, s.options.strict, n), a = t ? s.directives.tagName(t.source, (f) => n(t, "TAG_RESOLVE_FAILED", f)) : null, c = t && a ? rn(s.schema, i, a, t, n) : e.type === "scalar" ? on(s, i, e, n) : s.schema[U]; - let d; - try { - const f = c.resolve(i, (u) => n(t ?? e, "TAG_RESOLVE_FAILED", u), s.options); - d = A(f) ? f : new N(f); - } catch (f) { - const u = f instanceof Error ? f.message : String(f); - n(t ?? e, "TAG_RESOLVE_FAILED", u), d = new N(i); - } - return d.range = l, d.source = i, r && (d.type = r), a && (d.tag = a), c.format && (d.format = c.format), o && (d.comment = o), d; -} -function rn(s, e, t, n, i) { - var l; - if (t === "!") - return s[U]; - const r = []; - for (const a of s.tags) - if (!a.collection && a.tag === t) - if (a.default && a.test) - r.push(a); - else - return a; - for (const a of r) - if ((l = a.test) != null && l.test(e)) - return a; - const o = s.knownTags[t]; - return o && !o.collection ? (s.tags.push(Object.assign({}, o, { default: !1, test: void 0 })), o) : (i(n, "TAG_RESOLVE_FAILED", `Unresolved tag: ${t}`, t !== "tag:yaml.org,2002:str"), s[U]); -} -function on({ directives: s, schema: e }, t, n, i) { - const r = e.tags.find((o) => { - var l; - return o.default && ((l = o.test) == null ? void 0 : l.test(t)); - }) || e[U]; - if (e.compat) { - const o = e.compat.find((l) => { - var a; - return l.default && ((a = l.test) == null ? void 0 : a.test(t)); - }) ?? e[U]; - if (r.tag !== o.tag) { - const l = s.tagString(r.tag), a = s.tagString(o.tag), c = `Value may be parsed as either ${l} or ${a}`; - i(n, "TAG_RESOLVE_FAILED", c, !0); - } - } - return r; -} -function ln(s, e, t) { - if (e) { - t === null && (t = e.length); - for (let n = t - 1; n >= 0; --n) { - let i = e[n]; - switch (i.type) { - case "space": - case "comment": - case "newline": - s -= i.source.length; - continue; - } - for (i = e[++n]; (i == null ? void 0 : i.type) === "space"; ) - s += i.source.length, i = e[++n]; - break; - } - } - return s; -} -const an = { composeNode: is, composeEmptyNode: mt }; -function is(s, e, t, n) { - const { spaceBefore: i, comment: r, anchor: o, tag: l } = t; - let a, c = !0; - switch (e.type) { - case "alias": - a = cn(s, e, n), (o || l) && n(e, "ALIAS_PROPS", "An alias node must not specify any properties"); - break; - case "scalar": - case "single-quoted-scalar": - case "double-quoted-scalar": - case "block-scalar": - a = ns(s, e, l, n), o && (a.anchor = o.source.substring(1)); - break; - case "block-map": - case "block-seq": - case "flow-collection": - a = Ws(an, s, e, l, n), o && (a.anchor = o.source.substring(1)); - break; - default: { - const d = e.type === "error" ? e.message : `Unsupported token (type: ${e.type})`; - n(e, "UNEXPECTED_TOKEN", d), a = mt(s, e.offset, void 0, null, t, n), c = !1; - } - } - return o && a.anchor === "" && n(o, "BAD_ALIAS", "Anchor cannot be an empty string"), i && (a.spaceBefore = !0), r && (e.type === "scalar" && e.source === "" ? a.comment = r : a.commentBefore = r), s.options.keepSourceTokens && c && (a.srcToken = e), a; -} -function mt(s, e, t, n, { spaceBefore: i, comment: r, anchor: o, tag: l, end: a }, c) { - const d = { - type: "scalar", - offset: ln(e, t, n), - indent: -1, - source: "" - }, f = ns(s, d, l, c); - return o && (f.anchor = o.source.substring(1), f.anchor === "" && c(o, "BAD_ALIAS", "Anchor cannot be an empty string")), i && (f.spaceBefore = !0), r && (f.comment = r, f.range[2] = a), f; -} -function cn({ options: s }, { offset: e, source: t, end: n }, i) { - const r = new st(t.substring(1)); - r.source === "" && i(e, "BAD_ALIAS", "Alias cannot be an empty string"), r.source.endsWith(":") && i(e + t.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", !0); - const o = e + t.length, l = Ne(n, o, s.strict, i); - return r.range = [e, o, l.offset], l.comment && (r.comment = l.comment), r; -} -function fn(s, e, { offset: t, start: n, value: i, end: r }, o) { - const l = Object.assign({ _directives: e }, s), a = new Re(void 0, l), c = { - atRoot: !0, - directives: a.directives, - options: a.options, - schema: a.schema - }, d = oe(n, { - indicator: "doc-start", - next: i ?? (r == null ? void 0 : r[0]), - offset: t, - onError: o, - startOnNewline: !0 - }); - d.found && (a.directives.docStart = !0, i && (i.type === "block-map" || i.type === "block-seq") && !d.hasNewline && o(d.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker")), a.contents = i ? is(c, i, d, o) : mt(c, d.end, n, null, d, o); - const f = a.contents.range[2], u = Ne(r, f, !1, o); - return u.comment && (a.comment = u.comment), a.range = [t, f, u.offset], a; -} -function he(s) { - if (typeof s == "number") - return [s, s + 1]; - if (Array.isArray(s)) - return s.length === 2 ? s : [s[0], s[1]]; - const { offset: e, source: t } = s; - return [e, e + (typeof t == "string" ? t.length : 1)]; -} -function At(s) { - var i; - let e = "", t = !1, n = !1; - for (let r = 0; r < s.length; ++r) { - const o = s[r]; - switch (o[0]) { - case "#": - e += (e === "" ? "" : n ? ` - -` : ` -`) + (o.substring(1) || " "), t = !0, n = !1; - break; - case "%": - ((i = s[r + 1]) == null ? void 0 : i[0]) !== "#" && (r += 1), t = !1; - break; - default: - t || (n = !0), t = !1; - } - } - return { comment: e, afterEmptyLine: n }; -} -class un { - constructor(e = {}) { - this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (t, n, i, r) => { - const o = he(t); - r ? this.warnings.push(new Vs(o, n, i)) : this.errors.push(new pe(o, n, i)); - }, this.directives = new v({ version: e.version || "1.2" }), this.options = e; - } - decorate(e, t) { - const { comment: n, afterEmptyLine: i } = At(this.prelude); - if (n) { - const r = e.contents; - if (t) - e.comment = e.comment ? `${e.comment} -${n}` : n; - else if (i || e.directives.docStart || !r) - e.commentBefore = n; - else if (E(r) && !r.flow && r.items.length > 0) { - let o = r.items[0]; - L(o) && (o = o.key); - const l = o.commentBefore; - o.commentBefore = l ? `${n} -${l}` : n; - } else { - const o = r.commentBefore; - r.commentBefore = o ? `${n} -${o}` : n; - } - } - t ? (Array.prototype.push.apply(e.errors, this.errors), Array.prototype.push.apply(e.warnings, this.warnings)) : (e.errors = this.errors, e.warnings = this.warnings), this.prelude = [], this.errors = [], this.warnings = []; - } - /** - * Current stream status information. - * - * Mostly useful at the end of input for an empty stream. - */ - streamInfo() { - return { - comment: At(this.prelude).comment, - directives: this.directives, - errors: this.errors, - warnings: this.warnings - }; - } - /** - * Compose tokens into documents. - * - * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. - * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. - */ - *compose(e, t = !1, n = -1) { - for (const i of e) - yield* this.next(i); - yield* this.end(t, n); - } - /** Advance the composer by one CST token. */ - *next(e) { - switch (e.type) { - case "directive": - this.directives.add(e.source, (t, n, i) => { - const r = he(e); - r[0] += t, this.onError(r, "BAD_DIRECTIVE", n, i); - }), this.prelude.push(e.source), this.atDirectives = !0; - break; - case "document": { - const t = fn(this.options, this.directives, e, this.onError); - this.atDirectives && !t.directives.docStart && this.onError(e, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"), this.decorate(t, !1), this.doc && (yield this.doc), this.doc = t, this.atDirectives = !1; - break; - } - case "byte-order-mark": - case "space": - break; - case "comment": - case "newline": - this.prelude.push(e.source); - break; - case "error": { - const t = e.source ? `${e.message}: ${JSON.stringify(e.source)}` : e.message, n = new pe(he(e), "UNEXPECTED_TOKEN", t); - this.atDirectives || !this.doc ? this.errors.push(n) : this.doc.errors.push(n); - break; - } - case "doc-end": { - if (!this.doc) { - const n = "Unexpected doc-end without preceding document"; - this.errors.push(new pe(he(e), "UNEXPECTED_TOKEN", n)); - break; - } - this.doc.directives.docEnd = !0; - const t = Ne(e.end, e.offset + e.source.length, this.doc.options.strict, this.onError); - if (this.decorate(this.doc, !0), t.comment) { - const n = this.doc.comment; - this.doc.comment = n ? `${n} -${t.comment}` : t.comment; - } - this.doc.range[2] = t.offset; - break; - } - default: - this.errors.push(new pe(he(e), "UNEXPECTED_TOKEN", `Unsupported token ${e.type}`)); - } - } - /** - * Call at end of input to yield any remaining document. - * - * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. - * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. - */ - *end(e = !1, t = -1) { - if (this.doc) - this.decorate(this.doc, !0), yield this.doc, this.doc = null; - else if (e) { - const n = Object.assign({ _directives: this.directives }, this.options), i = new Re(void 0, n); - this.atDirectives && this.onError(t, "MISSING_CHAR", "Missing directives-end indicator line"), i.range = [0, t, t], this.decorate(i, !1), yield i; - } - } -} -const rs = "\uFEFF", os = "", ls = "", xe = ""; -function hn(s) { - switch (s) { - case rs: - return "byte-order-mark"; - case os: - return "doc-mode"; - case ls: - return "flow-error-end"; - case xe: - return "scalar"; - case "---": - return "doc-start"; - case "...": - return "doc-end"; - case "": - case ` -`: - case `\r -`: - return "newline"; - case "-": - return "seq-item-ind"; - case "?": - return "explicit-key-ind"; - case ":": - return "map-value-ind"; - case "{": - return "flow-map-start"; - case "}": - return "flow-map-end"; - case "[": - return "flow-seq-start"; - case "]": - return "flow-seq-end"; - case ",": - return "comma"; - } - switch (s[0]) { - case " ": - case " ": - return "space"; - case "#": - return "comment"; - case "%": - return "directive-line"; - case "*": - return "alias"; - case "&": - return "anchor"; - case "!": - return "tag"; - case "'": - return "single-quoted-scalar"; - case '"': - return "double-quoted-scalar"; - case "|": - case ">": - return "block-scalar-header"; - } - return null; -} -function D(s) { - switch (s) { - case void 0: - case " ": - case ` -`: - case "\r": - case " ": - return !0; - default: - return !1; - } -} -const It = "0123456789ABCDEFabcdef".split(""), dn = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()".split(""), Ge = ",[]{}".split(""), pn = ` ,[]{} -\r `.split(""), We = (s) => !s || pn.includes(s); -class mn { - constructor() { - this.atEnd = !1, this.blockScalarIndent = -1, this.blockScalarKeep = !1, this.buffer = "", this.flowKey = !1, this.flowLevel = 0, this.indentNext = 0, this.indentValue = 0, this.lineEndPos = null, this.next = null, this.pos = 0; - } - /** - * Generate YAML tokens from the `source` string. If `incomplete`, - * a part of the last line may be left as a buffer for the next call. - * - * @returns A generator of lexical tokens - */ - *lex(e, t = !1) { - e && (this.buffer = this.buffer ? this.buffer + e : e, this.lineEndPos = null), this.atEnd = !t; - let n = this.next ?? "stream"; - for (; n && (t || this.hasChars(1)); ) - n = yield* this.parseNext(n); - } - atLineEnd() { - let e = this.pos, t = this.buffer[e]; - for (; t === " " || t === " "; ) - t = this.buffer[++e]; - return !t || t === "#" || t === ` -` ? !0 : t === "\r" ? this.buffer[e + 1] === ` -` : !1; - } - charAt(e) { - return this.buffer[this.pos + e]; - } - continueScalar(e) { - let t = this.buffer[e]; - if (this.indentNext > 0) { - let n = 0; - for (; t === " "; ) - t = this.buffer[++n + e]; - if (t === "\r") { - const i = this.buffer[n + e + 1]; - if (i === ` -` || !i && !this.atEnd) - return e + n + 1; - } - return t === ` -` || n >= this.indentNext || !t && !this.atEnd ? e + n : -1; - } - if (t === "-" || t === ".") { - const n = this.buffer.substr(e, 3); - if ((n === "---" || n === "...") && D(this.buffer[e + 3])) - return -1; - } - return e; - } - getLine() { - let e = this.lineEndPos; - return (typeof e != "number" || e !== -1 && e < this.pos) && (e = this.buffer.indexOf(` -`, this.pos), this.lineEndPos = e), e === -1 ? this.atEnd ? this.buffer.substring(this.pos) : null : (this.buffer[e - 1] === "\r" && (e -= 1), this.buffer.substring(this.pos, e)); - } - hasChars(e) { - return this.pos + e <= this.buffer.length; - } - setNext(e) { - return this.buffer = this.buffer.substring(this.pos), this.pos = 0, this.lineEndPos = null, this.next = e, null; - } - peek(e) { - return this.buffer.substr(this.pos, e); - } - *parseNext(e) { - switch (e) { - case "stream": - return yield* this.parseStream(); - case "line-start": - return yield* this.parseLineStart(); - case "block-start": - return yield* this.parseBlockStart(); - case "doc": - return yield* this.parseDocument(); - case "flow": - return yield* this.parseFlowCollection(); - case "quoted-scalar": - return yield* this.parseQuotedScalar(); - case "block-scalar": - return yield* this.parseBlockScalar(); - case "plain-scalar": - return yield* this.parsePlainScalar(); - } - } - *parseStream() { - let e = this.getLine(); - if (e === null) - return this.setNext("stream"); - if (e[0] === rs && (yield* this.pushCount(1), e = e.substring(1)), e[0] === "%") { - let t = e.length; - const n = e.indexOf("#"); - if (n !== -1) { - const r = e[n - 1]; - (r === " " || r === " ") && (t = n - 1); - } - for (; ; ) { - const r = e[t - 1]; - if (r === " " || r === " ") - t -= 1; - else - break; - } - const i = (yield* this.pushCount(t)) + (yield* this.pushSpaces(!0)); - return yield* this.pushCount(e.length - i), this.pushNewline(), "stream"; - } - if (this.atLineEnd()) { - const t = yield* this.pushSpaces(!0); - return yield* this.pushCount(e.length - t), yield* this.pushNewline(), "stream"; - } - return yield os, yield* this.parseLineStart(); - } - *parseLineStart() { - const e = this.charAt(0); - if (!e && !this.atEnd) - return this.setNext("line-start"); - if (e === "-" || e === ".") { - if (!this.atEnd && !this.hasChars(4)) - return this.setNext("line-start"); - const t = this.peek(3); - if (t === "---" && D(this.charAt(3))) - return yield* this.pushCount(3), this.indentValue = 0, this.indentNext = 0, "doc"; - if (t === "..." && D(this.charAt(3))) - return yield* this.pushCount(3), "stream"; - } - return this.indentValue = yield* this.pushSpaces(!1), this.indentNext > this.indentValue && !D(this.charAt(1)) && (this.indentNext = this.indentValue), yield* this.parseBlockStart(); - } - *parseBlockStart() { - const [e, t] = this.peek(2); - if (!t && !this.atEnd) - return this.setNext("block-start"); - if ((e === "-" || e === "?" || e === ":") && D(t)) { - const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(!0)); - return this.indentNext = this.indentValue + 1, this.indentValue += n, yield* this.parseBlockStart(); - } - return "doc"; - } - *parseDocument() { - yield* this.pushSpaces(!0); - const e = this.getLine(); - if (e === null) - return this.setNext("doc"); - let t = yield* this.pushIndicators(); - switch (e[t]) { - case "#": - yield* this.pushCount(e.length - t); - case void 0: - return yield* this.pushNewline(), yield* this.parseLineStart(); - case "{": - case "[": - return yield* this.pushCount(1), this.flowKey = !1, this.flowLevel = 1, "flow"; - case "}": - case "]": - return yield* this.pushCount(1), "doc"; - case "*": - return yield* this.pushUntil(We), "doc"; - case '"': - case "'": - return yield* this.parseQuotedScalar(); - case "|": - case ">": - return t += yield* this.parseBlockScalarHeader(), t += yield* this.pushSpaces(!0), yield* this.pushCount(e.length - t), yield* this.pushNewline(), yield* this.parseBlockScalar(); - default: - return yield* this.parsePlainScalar(); - } - } - *parseFlowCollection() { - let e, t, n = -1; - do - e = yield* this.pushNewline(), e > 0 ? (t = yield* this.pushSpaces(!1), this.indentValue = n = t) : t = 0, t += yield* this.pushSpaces(!0); - while (e + t > 0); - const i = this.getLine(); - if (i === null) - return this.setNext("flow"); - if ((n !== -1 && n < this.indentNext && i[0] !== "#" || n === 0 && (i.startsWith("---") || i.startsWith("...")) && D(i[3])) && !(n === this.indentNext - 1 && this.flowLevel === 1 && (i[0] === "]" || i[0] === "}"))) - return this.flowLevel = 0, yield ls, yield* this.parseLineStart(); - let r = 0; - for (; i[r] === ","; ) - r += yield* this.pushCount(1), r += yield* this.pushSpaces(!0), this.flowKey = !1; - switch (r += yield* this.pushIndicators(), i[r]) { - case void 0: - return "flow"; - case "#": - return yield* this.pushCount(i.length - r), "flow"; - case "{": - case "[": - return yield* this.pushCount(1), this.flowKey = !1, this.flowLevel += 1, "flow"; - case "}": - case "]": - return yield* this.pushCount(1), this.flowKey = !0, this.flowLevel -= 1, this.flowLevel ? "flow" : "doc"; - case "*": - return yield* this.pushUntil(We), "flow"; - case '"': - case "'": - return this.flowKey = !0, yield* this.parseQuotedScalar(); - case ":": { - const o = this.charAt(1); - if (this.flowKey || D(o) || o === ",") - return this.flowKey = !1, yield* this.pushCount(1), yield* this.pushSpaces(!0), "flow"; - } - default: - return this.flowKey = !1, yield* this.parsePlainScalar(); - } - } - *parseQuotedScalar() { - const e = this.charAt(0); - let t = this.buffer.indexOf(e, this.pos + 1); - if (e === "'") - for (; t !== -1 && this.buffer[t + 1] === "'"; ) - t = this.buffer.indexOf("'", t + 2); - else - for (; t !== -1; ) { - let r = 0; - for (; this.buffer[t - 1 - r] === "\\"; ) - r += 1; - if (r % 2 === 0) - break; - t = this.buffer.indexOf('"', t + 1); - } - const n = this.buffer.substring(0, t); - let i = n.indexOf(` -`, this.pos); - if (i !== -1) { - for (; i !== -1; ) { - const r = this.continueScalar(i + 1); - if (r === -1) - break; - i = n.indexOf(` -`, r); - } - i !== -1 && (t = i - (n[i - 1] === "\r" ? 2 : 1)); - } - if (t === -1) { - if (!this.atEnd) - return this.setNext("quoted-scalar"); - t = this.buffer.length; - } - return yield* this.pushToIndex(t + 1, !1), this.flowLevel ? "flow" : "doc"; - } - *parseBlockScalarHeader() { - this.blockScalarIndent = -1, this.blockScalarKeep = !1; - let e = this.pos; - for (; ; ) { - const t = this.buffer[++e]; - if (t === "+") - this.blockScalarKeep = !0; - else if (t > "0" && t <= "9") - this.blockScalarIndent = Number(t) - 1; - else if (t !== "-") - break; - } - return yield* this.pushUntil((t) => D(t) || t === "#"); - } - *parseBlockScalar() { - let e = this.pos - 1, t = 0, n; - e: - for (let i = this.pos; n = this.buffer[i]; ++i) - switch (n) { - case " ": - t += 1; - break; - case ` -`: - e = i, t = 0; - break; - case "\r": { - const r = this.buffer[i + 1]; - if (!r && !this.atEnd) - return this.setNext("block-scalar"); - if (r === ` -`) - break; - } - default: - break e; - } - if (!n && !this.atEnd) - return this.setNext("block-scalar"); - if (t >= this.indentNext) { - this.blockScalarIndent === -1 ? this.indentNext = t : this.indentNext += this.blockScalarIndent; - do { - const i = this.continueScalar(e + 1); - if (i === -1) - break; - e = this.buffer.indexOf(` -`, i); - } while (e !== -1); - if (e === -1) { - if (!this.atEnd) - return this.setNext("block-scalar"); - e = this.buffer.length; - } - } - if (!this.blockScalarKeep) - do { - let i = e - 1, r = this.buffer[i]; - r === "\r" && (r = this.buffer[--i]); - const o = i; - for (; r === " " || r === " "; ) - r = this.buffer[--i]; - if (r === ` -` && i >= this.pos && i + 1 + t > o) - e = i; - else - break; - } while (!0); - return yield xe, yield* this.pushToIndex(e + 1, !0), yield* this.parseLineStart(); - } - *parsePlainScalar() { - const e = this.flowLevel > 0; - let t = this.pos - 1, n = this.pos - 1, i; - for (; i = this.buffer[++n]; ) - if (i === ":") { - const r = this.buffer[n + 1]; - if (D(r) || e && r === ",") - break; - t = n; - } else if (D(i)) { - let r = this.buffer[n + 1]; - if (i === "\r" && (r === ` -` ? (n += 1, i = ` -`, r = this.buffer[n + 1]) : t = n), r === "#" || e && Ge.includes(r)) - break; - if (i === ` -`) { - const o = this.continueScalar(n + 1); - if (o === -1) - break; - n = Math.max(n, o - 2); - } - } else { - if (e && Ge.includes(i)) - break; - t = n; - } - return !i && !this.atEnd ? this.setNext("plain-scalar") : (yield xe, yield* this.pushToIndex(t + 1, !0), e ? "flow" : "doc"); - } - *pushCount(e) { - return e > 0 ? (yield this.buffer.substr(this.pos, e), this.pos += e, e) : 0; - } - *pushToIndex(e, t) { - const n = this.buffer.slice(this.pos, e); - return n ? (yield n, this.pos += n.length, n.length) : (t && (yield ""), 0); - } - *pushIndicators() { - switch (this.charAt(0)) { - case "!": - return (yield* this.pushTag()) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators()); - case "&": - return (yield* this.pushUntil(We)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators()); - case "-": - case "?": - case ":": { - const e = this.flowLevel > 0, t = this.charAt(1); - if (D(t) || e && Ge.includes(t)) - return e ? this.flowKey && (this.flowKey = !1) : this.indentNext = this.indentValue + 1, (yield* this.pushCount(1)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators()); - } - } - return 0; - } - *pushTag() { - if (this.charAt(1) === "<") { - let e = this.pos + 2, t = this.buffer[e]; - for (; !D(t) && t !== ">"; ) - t = this.buffer[++e]; - return yield* this.pushToIndex(t === ">" ? e + 1 : e, !1); - } else { - let e = this.pos + 1, t = this.buffer[e]; - for (; t; ) - if (dn.includes(t)) - t = this.buffer[++e]; - else if (t === "%" && It.includes(this.buffer[e + 1]) && It.includes(this.buffer[e + 2])) - t = this.buffer[e += 3]; - else - break; - return yield* this.pushToIndex(e, !1); - } - } - *pushNewline() { - const e = this.buffer[this.pos]; - return e === ` -` ? yield* this.pushCount(1) : e === "\r" && this.charAt(1) === ` -` ? yield* this.pushCount(2) : 0; - } - *pushSpaces(e) { - let t = this.pos - 1, n; - do - n = this.buffer[++t]; - while (n === " " || e && n === " "); - const i = t - this.pos; - return i > 0 && (yield this.buffer.substr(this.pos, i), this.pos = t), i; - } - *pushUntil(e) { - let t = this.pos, n = this.buffer[t]; - for (; !e(n); ) - n = this.buffer[++t]; - return yield* this.pushToIndex(t, !1); - } -} -class gn { - constructor() { - this.lineStarts = [], this.addNewLine = (e) => this.lineStarts.push(e), this.linePos = (e) => { - let t = 0, n = this.lineStarts.length; - for (; t < n; ) { - const r = t + n >> 1; - this.lineStarts[r] < e ? t = r + 1 : n = r; - } - if (this.lineStarts[t] === e) - return { line: t + 1, col: 1 }; - if (t === 0) - return { line: 0, col: e }; - const i = this.lineStarts[t - 1]; - return { line: t, col: e - i + 1 }; - }; - } -} -function K(s, e) { - for (let t = 0; t < s.length; ++t) - if (s[t].type === e) - return !0; - return !1; -} -function Tt(s) { - for (let e = 0; e < s.length; ++e) - switch (s[e].type) { - case "space": - case "comment": - case "newline": - break; - default: - return e; - } - return -1; -} -function as(s) { - switch (s == null ? void 0 : s.type) { - case "alias": - case "scalar": - case "single-quoted-scalar": - case "double-quoted-scalar": - case "flow-collection": - return !0; - default: - return !1; - } -} -function Ie(s) { - switch (s.type) { - case "document": - return s.start; - case "block-map": { - const e = s.items[s.items.length - 1]; - return e.sep ?? e.start; - } - case "block-seq": - return s.items[s.items.length - 1].start; - default: - return []; - } -} -function x(s) { - var t; - if (s.length === 0) - return []; - let e = s.length; - e: - for (; --e >= 0; ) - switch (s[e].type) { - case "doc-start": - case "explicit-key-ind": - case "map-value-ind": - case "seq-item-ind": - case "newline": - break e; - } - for (; ((t = s[++e]) == null ? void 0 : t.type) === "space"; ) - ; - return s.splice(e, s.length); -} -function Et(s) { - if (s.start.type === "flow-seq-start") - for (const e of s.items) - e.sep && !e.value && !K(e.start, "explicit-key-ind") && !K(e.sep, "map-value-ind") && (e.key && (e.value = e.key), delete e.key, as(e.value) ? e.value.end ? Array.prototype.push.apply(e.value.end, e.sep) : e.value.end = e.sep : Array.prototype.push.apply(e.start, e.sep), delete e.sep); -} -class yn { - /** - * @param onNewLine - If defined, called separately with the start position of - * each new line (in `parse()`, including the start of input). - */ - constructor(e) { - this.atNewLine = !0, this.atScalar = !1, this.indent = 0, this.offset = 0, this.onKeyLine = !1, this.stack = [], this.source = "", this.type = "", this.lexer = new mn(), this.onNewLine = e; - } - /** - * Parse `source` as a YAML stream. - * If `incomplete`, a part of the last line may be left as a buffer for the next call. - * - * Errors are not thrown, but yielded as `{ type: 'error', message }` tokens. - * - * @returns A generator of tokens representing each directive, document, and other structure. - */ - *parse(e, t = !1) { - this.onNewLine && this.offset === 0 && this.onNewLine(0); - for (const n of this.lexer.lex(e, t)) - yield* this.next(n); - t || (yield* this.end()); - } - /** - * Advance the parser by the `source` of one lexical token. - */ - *next(e) { - if (this.source = e, this.atScalar) { - this.atScalar = !1, yield* this.step(), this.offset += e.length; - return; - } - const t = hn(e); - if (t) - if (t === "scalar") - this.atNewLine = !1, this.atScalar = !0, this.type = "scalar"; - else { - switch (this.type = t, yield* this.step(), t) { - case "newline": - this.atNewLine = !0, this.indent = 0, this.onNewLine && this.onNewLine(this.offset + e.length); - break; - case "space": - this.atNewLine && e[0] === " " && (this.indent += e.length); - break; - case "explicit-key-ind": - case "map-value-ind": - case "seq-item-ind": - this.atNewLine && (this.indent += e.length); - break; - case "doc-mode": - case "flow-error-end": - return; - default: - this.atNewLine = !1; - } - this.offset += e.length; - } - else { - const n = `Not a YAML token: ${e}`; - yield* this.pop({ type: "error", offset: this.offset, message: n, source: e }), this.offset += e.length; - } - } - /** Call at end of input to push out any remaining constructions */ - *end() { - for (; this.stack.length > 0; ) - yield* this.pop(); - } - get sourceToken() { - return { - type: this.type, - offset: this.offset, - indent: this.indent, - source: this.source - }; - } - *step() { - const e = this.peek(1); - if (this.type === "doc-end" && (!e || e.type !== "doc-end")) { - for (; this.stack.length > 0; ) - yield* this.pop(); - this.stack.push({ - type: "doc-end", - offset: this.offset, - source: this.source - }); - return; - } - if (!e) - return yield* this.stream(); - switch (e.type) { - case "document": - return yield* this.document(e); - case "alias": - case "scalar": - case "single-quoted-scalar": - case "double-quoted-scalar": - return yield* this.scalar(e); - case "block-scalar": - return yield* this.blockScalar(e); - case "block-map": - return yield* this.blockMap(e); - case "block-seq": - return yield* this.blockSequence(e); - case "flow-collection": - return yield* this.flowCollection(e); - case "doc-end": - return yield* this.documentEnd(e); - } - yield* this.pop(); - } - peek(e) { - return this.stack[this.stack.length - e]; - } - *pop(e) { - const t = e ?? this.stack.pop(); - if (!t) - yield { type: "error", offset: this.offset, source: "", message: "Tried to pop an empty stack" }; - else if (this.stack.length === 0) - yield t; - else { - const n = this.peek(1); - switch (t.type === "block-scalar" ? t.indent = "indent" in n ? n.indent : 0 : t.type === "flow-collection" && n.type === "document" && (t.indent = 0), t.type === "flow-collection" && Et(t), n.type) { - case "document": - n.value = t; - break; - case "block-scalar": - n.props.push(t); - break; - case "block-map": { - const i = n.items[n.items.length - 1]; - if (i.value) { - n.items.push({ start: [], key: t, sep: [] }), this.onKeyLine = !0; - return; - } else if (i.sep) - i.value = t; - else { - Object.assign(i, { key: t, sep: [] }), this.onKeyLine = !K(i.start, "explicit-key-ind"); - return; - } - break; - } - case "block-seq": { - const i = n.items[n.items.length - 1]; - i.value ? n.items.push({ start: [], value: t }) : i.value = t; - break; - } - case "flow-collection": { - const i = n.items[n.items.length - 1]; - !i || i.value ? n.items.push({ start: [], key: t, sep: [] }) : i.sep ? i.value = t : Object.assign(i, { key: t, sep: [] }); - return; - } - default: - yield* this.pop(), yield* this.pop(t); - } - if ((n.type === "document" || n.type === "block-map" || n.type === "block-seq") && (t.type === "block-map" || t.type === "block-seq")) { - const i = t.items[t.items.length - 1]; - i && !i.sep && !i.value && i.start.length > 0 && Tt(i.start) === -1 && (t.indent === 0 || i.start.every((r) => r.type !== "comment" || r.indent < t.indent)) && (n.type === "document" ? n.end = i.start : n.items.push({ start: i.start }), t.items.splice(-1, 1)); - } - } - } - *stream() { - switch (this.type) { - case "directive-line": - yield { type: "directive", offset: this.offset, source: this.source }; - return; - case "byte-order-mark": - case "space": - case "comment": - case "newline": - yield this.sourceToken; - return; - case "doc-mode": - case "doc-start": { - const e = { - type: "document", - offset: this.offset, - start: [] - }; - this.type === "doc-start" && e.start.push(this.sourceToken), this.stack.push(e); - return; - } - } - yield { - type: "error", - offset: this.offset, - message: `Unexpected ${this.type} token in YAML stream`, - source: this.source - }; - } - *document(e) { - if (e.value) - return yield* this.lineEnd(e); - switch (this.type) { - case "doc-start": { - Tt(e.start) !== -1 ? (yield* this.pop(), yield* this.step()) : e.start.push(this.sourceToken); - return; - } - case "anchor": - case "tag": - case "space": - case "comment": - case "newline": - e.start.push(this.sourceToken); - return; - } - const t = this.startBlockValue(e); - t ? this.stack.push(t) : yield { - type: "error", - offset: this.offset, - message: `Unexpected ${this.type} token in YAML document`, - source: this.source - }; - } - *scalar(e) { - if (this.type === "map-value-ind") { - const t = Ie(this.peek(2)), n = x(t); - let i; - e.end ? (i = e.end, i.push(this.sourceToken), delete e.end) : i = [this.sourceToken]; - const r = { - type: "block-map", - offset: e.offset, - indent: e.indent, - items: [{ start: n, key: e, sep: i }] - }; - this.onKeyLine = !0, this.stack[this.stack.length - 1] = r; - } else - yield* this.lineEnd(e); - } - *blockScalar(e) { - switch (this.type) { - case "space": - case "comment": - case "newline": - e.props.push(this.sourceToken); - return; - case "scalar": - if (e.source = this.source, this.atNewLine = !0, this.indent = 0, this.onNewLine) { - let t = this.source.indexOf(` -`) + 1; - for (; t !== 0; ) - this.onNewLine(this.offset + t), t = this.source.indexOf(` -`, t) + 1; - } - yield* this.pop(); - break; - default: - yield* this.pop(), yield* this.step(); - } - } - *blockMap(e) { - var n; - const t = e.items[e.items.length - 1]; - switch (this.type) { - case "newline": - if (this.onKeyLine = !1, t.value) { - const i = "end" in t.value ? t.value.end : void 0, r = Array.isArray(i) ? i[i.length - 1] : void 0; - (r == null ? void 0 : r.type) === "comment" ? i == null || i.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] }); - } else - t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken); - return; - case "space": - case "comment": - if (t.value) - e.items.push({ start: [this.sourceToken] }); - else if (t.sep) - t.sep.push(this.sourceToken); - else { - if (this.atIndentedComment(t.start, e.indent)) { - const i = e.items[e.items.length - 2], r = (n = i == null ? void 0 : i.value) == null ? void 0 : n.end; - if (Array.isArray(r)) { - Array.prototype.push.apply(r, t.start), r.push(this.sourceToken), e.items.pop(); - return; - } - } - t.start.push(this.sourceToken); - } - return; - } - if (this.indent >= e.indent) { - const i = !this.onKeyLine && this.indent === e.indent && t.sep && this.type !== "seq-item-ind"; - let r = []; - if (i && t.sep && !t.value) { - const o = []; - for (let l = 0; l < t.sep.length; ++l) { - const a = t.sep[l]; - switch (a.type) { - case "newline": - o.push(l); - break; - case "space": - break; - case "comment": - a.indent > e.indent && (o.length = 0); - break; - default: - o.length = 0; - } - } - o.length >= 2 && (r = t.sep.splice(o[1])); - } - switch (this.type) { - case "anchor": - case "tag": - i || t.value ? (r.push(this.sourceToken), e.items.push({ start: r }), this.onKeyLine = !0) : t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken); - return; - case "explicit-key-ind": - !t.sep && !K(t.start, "explicit-key-ind") ? t.start.push(this.sourceToken) : i || t.value ? (r.push(this.sourceToken), e.items.push({ start: r })) : this.stack.push({ - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: [this.sourceToken] }] - }), this.onKeyLine = !0; - return; - case "map-value-ind": - if (K(t.start, "explicit-key-ind")) - if (t.sep) - if (t.value) - e.items.push({ start: [], key: null, sep: [this.sourceToken] }); - else if (K(t.sep, "map-value-ind")) - this.stack.push({ - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: r, key: null, sep: [this.sourceToken] }] - }); - else if (as(t.key) && !K(t.sep, "newline")) { - const o = x(t.start), l = t.key, a = t.sep; - a.push(this.sourceToken), delete t.key, delete t.sep, this.stack.push({ - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: o, key: l, sep: a }] - }); - } else - r.length > 0 ? t.sep = t.sep.concat(r, this.sourceToken) : t.sep.push(this.sourceToken); - else if (K(t.start, "newline")) - Object.assign(t, { key: null, sep: [this.sourceToken] }); - else { - const o = x(t.start); - this.stack.push({ - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: o, key: null, sep: [this.sourceToken] }] - }); - } - else - t.sep ? t.value || i ? e.items.push({ start: r, key: null, sep: [this.sourceToken] }) : K(t.sep, "map-value-ind") ? this.stack.push({ - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: [], key: null, sep: [this.sourceToken] }] - }) : t.sep.push(this.sourceToken) : Object.assign(t, { key: null, sep: [this.sourceToken] }); - this.onKeyLine = !0; - return; - case "alias": - case "scalar": - case "single-quoted-scalar": - case "double-quoted-scalar": { - const o = this.flowScalar(this.type); - i || t.value ? (e.items.push({ start: r, key: o, sep: [] }), this.onKeyLine = !0) : t.sep ? this.stack.push(o) : (Object.assign(t, { key: o, sep: [] }), this.onKeyLine = !0); - return; - } - default: { - const o = this.startBlockValue(e); - if (o) { - i && o.type !== "block-seq" && K(t.start, "explicit-key-ind") && e.items.push({ start: r }), this.stack.push(o); - return; - } - } - } - } - yield* this.pop(), yield* this.step(); - } - *blockSequence(e) { - var n; - const t = e.items[e.items.length - 1]; - switch (this.type) { - case "newline": - if (t.value) { - const i = "end" in t.value ? t.value.end : void 0, r = Array.isArray(i) ? i[i.length - 1] : void 0; - (r == null ? void 0 : r.type) === "comment" ? i == null || i.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] }); - } else - t.start.push(this.sourceToken); - return; - case "space": - case "comment": - if (t.value) - e.items.push({ start: [this.sourceToken] }); - else { - if (this.atIndentedComment(t.start, e.indent)) { - const i = e.items[e.items.length - 2], r = (n = i == null ? void 0 : i.value) == null ? void 0 : n.end; - if (Array.isArray(r)) { - Array.prototype.push.apply(r, t.start), r.push(this.sourceToken), e.items.pop(); - return; - } - } - t.start.push(this.sourceToken); - } - return; - case "anchor": - case "tag": - if (t.value || this.indent <= e.indent) - break; - t.start.push(this.sourceToken); - return; - case "seq-item-ind": - if (this.indent !== e.indent) - break; - t.value || K(t.start, "seq-item-ind") ? e.items.push({ start: [this.sourceToken] }) : t.start.push(this.sourceToken); - return; - } - if (this.indent > e.indent) { - const i = this.startBlockValue(e); - if (i) { - this.stack.push(i); - return; - } - } - yield* this.pop(), yield* this.step(); - } - *flowCollection(e) { - const t = e.items[e.items.length - 1]; - if (this.type === "flow-error-end") { - let n; - do - yield* this.pop(), n = this.peek(1); - while (n && n.type === "flow-collection"); - } else if (e.end.length === 0) { - switch (this.type) { - case "comma": - case "explicit-key-ind": - !t || t.sep ? e.items.push({ start: [this.sourceToken] }) : t.start.push(this.sourceToken); - return; - case "map-value-ind": - !t || t.value ? e.items.push({ start: [], key: null, sep: [this.sourceToken] }) : t.sep ? t.sep.push(this.sourceToken) : Object.assign(t, { key: null, sep: [this.sourceToken] }); - return; - case "space": - case "comment": - case "newline": - case "anchor": - case "tag": - !t || t.value ? e.items.push({ start: [this.sourceToken] }) : t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken); - return; - case "alias": - case "scalar": - case "single-quoted-scalar": - case "double-quoted-scalar": { - const i = this.flowScalar(this.type); - !t || t.value ? e.items.push({ start: [], key: i, sep: [] }) : t.sep ? this.stack.push(i) : Object.assign(t, { key: i, sep: [] }); - return; - } - case "flow-map-end": - case "flow-seq-end": - e.end.push(this.sourceToken); - return; - } - const n = this.startBlockValue(e); - n ? this.stack.push(n) : (yield* this.pop(), yield* this.step()); - } else { - const n = this.peek(2); - if (n.type === "block-map" && (this.type === "map-value-ind" && n.indent === e.indent || this.type === "newline" && !n.items[n.items.length - 1].sep)) - yield* this.pop(), yield* this.step(); - else if (this.type === "map-value-ind" && n.type !== "flow-collection") { - const i = Ie(n), r = x(i); - Et(e); - const o = e.end.splice(1, e.end.length); - o.push(this.sourceToken); - const l = { - type: "block-map", - offset: e.offset, - indent: e.indent, - items: [{ start: r, key: e, sep: o }] - }; - this.onKeyLine = !0, this.stack[this.stack.length - 1] = l; - } else - yield* this.lineEnd(e); - } - } - flowScalar(e) { - if (this.onNewLine) { - let t = this.source.indexOf(` -`) + 1; - for (; t !== 0; ) - this.onNewLine(this.offset + t), t = this.source.indexOf(` -`, t) + 1; - } - return { - type: e, - offset: this.offset, - indent: this.indent, - source: this.source - }; - } - startBlockValue(e) { - switch (this.type) { - case "alias": - case "scalar": - case "single-quoted-scalar": - case "double-quoted-scalar": - return this.flowScalar(this.type); - case "block-scalar-header": - return { - type: "block-scalar", - offset: this.offset, - indent: this.indent, - props: [this.sourceToken], - source: "" - }; - case "flow-map-start": - case "flow-seq-start": - return { - type: "flow-collection", - offset: this.offset, - indent: this.indent, - start: this.sourceToken, - items: [], - end: [] - }; - case "seq-item-ind": - return { - type: "block-seq", - offset: this.offset, - indent: this.indent, - items: [{ start: [this.sourceToken] }] - }; - case "explicit-key-ind": { - this.onKeyLine = !0; - const t = Ie(e), n = x(t); - return n.push(this.sourceToken), { - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: n }] - }; - } - case "map-value-ind": { - this.onKeyLine = !0; - const t = Ie(e), n = x(t); - return { - type: "block-map", - offset: this.offset, - indent: this.indent, - items: [{ start: n, key: null, sep: [this.sourceToken] }] - }; - } - } - return null; - } - atIndentedComment(e, t) { - return this.type !== "comment" || this.indent <= t ? !1 : e.every((n) => n.type === "newline" || n.type === "space"); - } - *documentEnd(e) { - this.type !== "doc-mode" && (e.end ? e.end.push(this.sourceToken) : e.end = [this.sourceToken], this.type === "newline" && (yield* this.pop())); - } - *lineEnd(e) { - switch (this.type) { - case "comma": - case "doc-start": - case "doc-end": - case "flow-seq-end": - case "flow-map-end": - case "map-value-ind": - yield* this.pop(), yield* this.step(); - break; - case "newline": - this.onKeyLine = !1; - case "space": - case "comment": - default: - e.end ? e.end.push(this.sourceToken) : e.end = [this.sourceToken], this.type === "newline" && (yield* this.pop()); - } - } -} -function bn(s) { - const e = s.prettyErrors !== !1; - return { lineCounter: s.lineCounter || e && new gn() || null, prettyErrors: e }; -} -function wn(s, e = {}) { - const { lineCounter: t, prettyErrors: n } = bn(e), i = new yn(t == null ? void 0 : t.addNewLine), r = new un(e); - let o = null; - for (const l of r.compose(i.parse(s), !0, s.length)) - if (!o) - o = l; - else if (o.options.logLevel !== "silent") { - o.errors.push(new pe(l.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()")); - break; - } - return n && t && (o.errors.forEach(Nt(s, t)), o.warnings.forEach(Nt(s, t))), o; -} -function kn(s, e, t) { - let n; - const i = wn(s, t); - if (!i) - return null; - if (i.warnings.forEach((r) => Pt(i.options.logLevel, r)), i.errors.length > 0) { - if (i.options.logLevel !== "silent") - throw i.errors[0]; - i.errors = []; - } - return i.toJS(Object.assign({ reviver: n }, t)); -} -function Cn(s) { - let e; - try { - e = JSON.parse(s); - } catch { - } - try { - e = kn(s); - } catch { - } - if (!ue(e) || !Array.isArray(e.resources)) - return; - const t = { - workspaces: [], - httpRequests: [], - grpcRequests: [], - environments: [], - folders: [] - }, n = e.resources.filter(Tn); - for (const i of n) { - const r = e.resources.find( - (a) => Lt(a) && a.parentId === i._id - ); - t.workspaces.push({ - id: j(i._id), - createdAt: new Date(n.created ?? Date.now()).toISOString().replace("Z", ""), - updatedAt: new Date(n.updated ?? Date.now()).toISOString().replace("Z", ""), - model: "workspace", - name: i.name, - variables: r ? In(r.data) : [] - }); - const o = e.resources.filter( - (a) => Lt(a) && a.parentId === (r == null ? void 0 : r._id) - ); - t.environments.push( - ...o.map((a) => Sn(a, i._id)) - ); - const l = (a) => { - const c = e.resources.filter((f) => f.parentId === a); - let d = 0; - for (const f of c) - En(f) ? (t.folders.push(Nn(f, i._id)), l(f._id)) : Ln(f) ? t.httpRequests.push( - An(f, i._id, d++) - ) : $n(f) && t.grpcRequests.push( - On(f, i._id, d++) - ); - }; - l(i._id); - } - return t.httpRequests = t.httpRequests.filter(Boolean), t.grpcRequests = t.grpcRequests.filter(Boolean), t.environments = t.environments.filter(Boolean), t.workspaces = t.workspaces.filter(Boolean), { resources: t }; -} -function Sn(s, e) { - return { - id: j(s._id), - createdAt: new Date(s.created ?? Date.now()).toISOString().replace("Z", ""), - updatedAt: new Date(s.updated ?? Date.now()).toISOString().replace("Z", ""), - workspaceId: j(e), - model: "environment", - name: s.name, - variables: Object.entries(s.data).map(([t, n]) => ({ - enabled: !0, - name: t, - value: `${n}` - })) - }; -} -function Nn(s, e) { - return { - id: j(s._id), - createdAt: new Date(s.created ?? Date.now()).toISOString().replace("Z", ""), - updatedAt: new Date(s.updated ?? Date.now()).toISOString().replace("Z", ""), - folderId: s.parentId === e ? null : j(s.parentId), - workspaceId: j(e), - model: "folder", - name: s.name - }; -} -function On(s, e, t = 0) { - var o; - const n = s.protoMethodName.split("/").filter((l) => l !== ""), i = n[0] ?? null, r = n[1] ?? null; - return { - id: j(s._id), - createdAt: new Date(s.created ?? Date.now()).toISOString().replace("Z", ""), - updatedAt: new Date(s.updated ?? Date.now()).toISOString().replace("Z", ""), - workspaceId: j(e), - folderId: s.parentId === e ? null : j(s.parentId), - model: "grpc_request", - sortPriority: t, - name: s.name, - url: G(s.url), - service: i, - method: r, - message: ((o = s.body) == null ? void 0 : o.text) ?? "", - metadata: (s.metadata ?? []).map((l) => ({ - enabled: !l.disabled, - name: l.name ?? "", - value: l.value ?? "" - })).filter(({ name: l, value: a }) => l !== "" || a !== "") - }; -} -function An(s, e, t = 0) { - var l, a, c, d; - let n = null, i = {}; - s.body.mimeType === "application/octet-stream" ? (n = "binary", i = { filePath: s.body.fileName ?? "" }) : ((l = s.body) == null ? void 0 : l.mimeType) === "application/x-www-form-urlencoded" ? (n = "application/x-www-form-urlencoded", i = { - form: (s.body.params ?? []).map((f) => ({ - enabled: !f.disabled, - name: f.name ?? "", - value: f.value ?? "" - })) - }) : ((a = s.body) == null ? void 0 : a.mimeType) === "multipart/form-data" ? (n = "multipart/form-data", i = { - form: (s.body.params ?? []).map((f) => ({ - enabled: !f.disabled, - name: f.name ?? "", - value: f.value ?? "", - file: f.fileName ?? null - })) - }) : ((c = s.body) == null ? void 0 : c.mimeType) === "application/graphql" ? (n = "graphql", i = { text: G(s.body.text ?? "") }) : ((d = s.body) == null ? void 0 : d.mimeType) === "application/json" && (n = "application/json", i = { text: G(s.body.text ?? "") }); - let r = null, o = {}; - return s.authentication.type === "bearer" ? (r = "bearer", o = { - token: G(s.authentication.token) - }) : s.authentication.type === "basic" && (r = "basic", o = { - username: G(s.authentication.username), - password: G(s.authentication.password) - }), { - id: j(s._id), - createdAt: new Date(s.created ?? Date.now()).toISOString().replace("Z", ""), - updatedAt: new Date(s.updated ?? Date.now()).toISOString().replace("Z", ""), - workspaceId: j(e), - folderId: s.parentId === e ? null : j(s.parentId), - model: "http_request", - sortPriority: t, - name: s.name, - url: G(s.url), - body: i, - bodyType: n, - authentication: o, - authenticationType: r, - method: s.method, - headers: (s.headers ?? []).map((f) => ({ - enabled: !f.disabled, - name: f.name ?? "", - value: f.value ?? "" - })).filter(({ name: f, value: u }) => f !== "" || u !== "") - }; -} -function In(s) { - return Object.entries(s).map(([e, t]) => ({ - enabled: !0, - name: e, - value: `${t}` - })); -} -function G(s) { - return _n(s) ? s.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}") : s; -} -function Tn(s) { - return ue(s) && s._type === "workspace"; -} -function En(s) { - return ue(s) && s._type === "request_group"; -} -function Ln(s) { - return ue(s) && s._type === "request"; -} -function $n(s) { - return ue(s) && s._type === "grpc_request"; -} -function Lt(s) { - return ue(s) && s._type === "environment"; -} -function ue(s) { - return Object.prototype.toString.call(s) === "[object Object]"; -} -function _n(s) { - return Object.prototype.toString.call(s) === "[object String]"; -} -function j(s) { - return s.startsWith("GENERATE_ID::") ? s : `GENERATE_ID::${s}`; -} -export { - Cn as pluginHookImport -}; diff --git a/src-tauri/plugins/importer-postman/index.mjs b/src-tauri/plugins/importer-postman/index.mjs deleted file mode 100644 index 0e813e99..00000000 --- a/src-tauri/plugins/importer-postman/index.mjs +++ /dev/null @@ -1,182 +0,0 @@ -const S = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", _ = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", O = [_, S]; -function v(e) { - var g; - const t = k(e); - if (t == null) - return; - const o = i(t.info); - if (!O.includes(o.schema) || !Array.isArray(t.item)) - return; - const u = A(t.auth), s = { - workspaces: [], - environments: [], - httpRequests: [], - folders: [] - }, n = { - model: "workspace", - id: h("workspace"), - name: o.name || "Postman Import", - description: o.description || "", - variables: ((g = t.variable) == null ? void 0 : g.map((r) => ({ - name: r.key, - value: r.value - }))) ?? [] - }; - s.workspaces.push(n); - const T = (r, p = null) => { - if (typeof r.name == "string" && Array.isArray(r.item)) { - const a = { - model: "folder", - workspaceId: n.id, - id: h("folder"), - name: r.name, - folderId: p - }; - s.folders.push(a); - for (const l of r.item) - T(l, a.id); - } else if (typeof r.name == "string" && "request" in r) { - const a = i(r.request), l = j(a.body), w = A(a.auth), d = w.authenticationType == null ? u : w, q = { - model: "http_request", - id: h("http_request"), - workspaceId: n.id, - folderId: p, - name: r.name, - method: a.method || "GET", - url: typeof a.url == "string" ? a.url : i(a.url).raw, - body: l.body, - bodyType: l.bodyType, - authentication: d.authentication, - authenticationType: d.authenticationType, - headers: [ - ...l.headers, - ...d.headers, - ...b(a.header).map((m) => ({ - name: m.key, - value: m.value, - enabled: !m.disabled - })) - ] - }; - s.httpRequests.push(q); - } else - console.log("Unknown item", r, p); - }; - for (const r of t.item) - T(r); - return { resources: f(s) }; -} -function A(e) { - const t = i(e); - return "basic" in t ? { - headers: [], - authenticationType: "basic", - authentication: { - username: t.basic.username || "", - password: t.basic.password || "" - } - } : "bearer" in t ? { - headers: [], - authenticationType: "bearer", - authentication: { - token: t.bearer.token || "" - } - } : { headers: [], authenticationType: null, authentication: {} }; -} -function j(e) { - var o, c, u, s; - const t = i(e); - return "graphql" in t ? { - headers: [ - { - name: "Content-Type", - value: "application/json", - enabled: !0 - } - ], - bodyType: "graphql", - body: { - text: JSON.stringify( - { query: t.graphql.query, variables: k(t.graphql.variables) }, - null, - 2 - ) - } - } : "urlencoded" in t ? { - headers: [ - { - name: "Content-Type", - value: "application/x-www-form-urlencoded", - enabled: !0 - } - ], - bodyType: "application/x-www-form-urlencoded", - body: { - form: b(t.urlencoded).map((n) => ({ - enabled: !n.disabled, - name: n.key ?? "", - value: n.value ?? "" - })) - } - } : "formdata" in t ? { - headers: [ - { - name: "Content-Type", - value: "multipart/form-data", - enabled: !0 - } - ], - bodyType: "multipart/form-data", - body: { - form: b(t.formdata).map( - (n) => n.src != null ? { - enabled: !n.disabled, - contentType: n.contentType ?? null, - name: n.key ?? "", - file: n.src ?? "" - } : { - enabled: !n.disabled, - name: n.key ?? "", - value: n.value ?? "" - } - ) - } - } : "raw" in t ? { - headers: [ - { - name: "Content-Type", - value: ((c = (o = t.options) == null ? void 0 : o.raw) == null ? void 0 : c.language) === "json" ? "application/json" : "", - enabled: !0 - } - ], - bodyType: ((s = (u = t.options) == null ? void 0 : u.raw) == null ? void 0 : s.language) === "json" ? "application/json" : "other", - body: { - text: t.raw ?? "" - } - } : { headers: [], bodyType: null, body: {} }; -} -function k(e) { - try { - return i(JSON.parse(e)); - } catch { - } - return null; -} -function i(e) { - return Object.prototype.toString.call(e) === "[object Object]" ? e : {}; -} -function b(e) { - return Object.prototype.toString.call(e) === "[object Array]" ? e : []; -} -function f(e) { - return typeof e == "string" ? e.replace(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}") : Array.isArray(e) && e != null ? e.map(f) : typeof e == "object" && e != null ? Object.fromEntries( - Object.entries(e).map(([t, o]) => [t, f(o)]) - ) : e; -} -const y = {}; -function h(e) { - return y[e] = (y[e] ?? -1) + 1, `GENERATE_ID::${e.toUpperCase()}_${y[e]}`; -} -export { - v as pluginHookImport -}; diff --git a/src-tauri/plugins/importer-yaak/index.mjs b/src-tauri/plugins/importer-yaak/index.mjs deleted file mode 100644 index 00238af6..00000000 --- a/src-tauri/plugins/importer-yaak/index.mjs +++ /dev/null @@ -1,17 +0,0 @@ -function u(r) { - let e; - try { - e = JSON.parse(r); - } catch { - return; - } - if (!(!t(e) || !("yaakSchema" in e))) - return "requests" in e.resources && (e.resources.httpRequests = e.resources.requests, delete e.resources.requests), { resources: e.resources }; -} -function t(r) { - return Object.prototype.toString.call(r) === "[object Object]"; -} -export { - t as isJSObject, - u as pluginHookImport -}; diff --git a/src-tauri/src/deno.rs b/src-tauri/src/deno.rs new file mode 100644 index 00000000..f2c4253e --- /dev/null +++ b/src-tauri/src/deno.rs @@ -0,0 +1,237 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +//! This example shows how to use swc to transpile TypeScript and JSX/TSX +//! modules. +//! +//! It will only transpile, not typecheck (like Deno's `--no-check` flag). + +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; +use std::sync::Arc; + +use crate::deno_ops::op_yaml_parse; +use anyhow::anyhow; +use anyhow::bail; +use anyhow::Context; +use anyhow::Error; +use deno_ast::ParseParams; +use deno_ast::{EmitOptions, MediaType, SourceMapOption, TranspileOptions}; +use deno_core::error::{AnyError, JsError}; +use deno_core::resolve_path; +use deno_core::JsRuntime; +use deno_core::ModuleLoadResponse; +use deno_core::ModuleLoader; +use deno_core::ModuleSource; +use deno_core::ModuleSourceCode; +use deno_core::ModuleSpecifier; +use deno_core::ModuleType; +use deno_core::RequestedModuleType; +use deno_core::ResolutionKind; +use deno_core::RuntimeOptions; +use deno_core::SourceMapGetter; +use deno_core::{resolve_import, v8}; +use tokio::task::block_in_place; + +#[derive(Clone)] +struct SourceMapStore(Rc>>>); + +impl SourceMapGetter for SourceMapStore { + fn get_source_map(&self, specifier: &str) -> Option> { + self.0.borrow().get(specifier).cloned() + } + + fn get_source_line(&self, _file_name: &str, _line_number: usize) -> Option { + None + } +} + +struct TypescriptModuleLoader { + source_maps: SourceMapStore, +} + +impl ModuleLoader for TypescriptModuleLoader { + fn resolve( + &self, + specifier: &str, + referrer: &str, + _kind: ResolutionKind, + ) -> Result { + Ok(resolve_import(specifier, referrer)?) + } + + fn load( + &self, + module_specifier: &ModuleSpecifier, + _maybe_referrer: Option<&ModuleSpecifier>, + _is_dyn_import: bool, + _requested_module_type: RequestedModuleType, + ) -> ModuleLoadResponse { + let source_maps = self.source_maps.clone(); + fn load( + source_maps: SourceMapStore, + module_specifier: &ModuleSpecifier, + ) -> Result { + let path = module_specifier + .to_file_path() + .map_err(|_| anyhow!("Only file:// URLs are supported."))?; + + let media_type = MediaType::from_path(&path); + let (module_type, should_transpile) = match MediaType::from_path(&path) { + MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => { + (ModuleType::JavaScript, false) + } + MediaType::Jsx => (ModuleType::JavaScript, true), + MediaType::TypeScript + | MediaType::Mts + | MediaType::Cts + | MediaType::Dts + | MediaType::Dmts + | MediaType::Dcts + | MediaType::Tsx => (ModuleType::JavaScript, true), + MediaType::Json => (ModuleType::Json, false), + _ => bail!("Unknown extension {:?}", path.extension()), + }; + + let code = std::fs::read_to_string(&path)?; + let code = if should_transpile { + let parsed = deno_ast::parse_module(ParseParams { + specifier: module_specifier.clone(), + text: Arc::from(code), + media_type, + capture_tokens: false, + scope_analysis: false, + maybe_syntax: None, + })?; + let res = parsed.transpile( + &TranspileOptions::default(), + &EmitOptions { + source_map: SourceMapOption::Separate, + inline_sources: true, + ..Default::default() + }, + )?; + let src = res.into_source(); + let source_map = src.source_map.unwrap(); + let source = src.source; + source_maps + .0 + .borrow_mut() + .insert(module_specifier.to_string(), source_map); + String::from_utf8(source).unwrap() + } else { + code + }; + + Ok(ModuleSource::new( + module_type, + ModuleSourceCode::String(code.into()), + module_specifier, + None, + )) + } + + ModuleLoadResponse::Sync(load(source_maps, module_specifier)) + } +} + +pub fn run_plugin_deno_block( + plugin_index_file: &str, + fn_name: &str, + fn_args: Vec, +) -> Result { + block_in_place(|| { + tauri::async_runtime::block_on(run_plugin_deno_2(plugin_index_file, fn_name, fn_args)) + }) +} + +deno_core::extension!( + yaak_runtime, + ops = [ op_yaml_parse ], + esm_entry_point = "ext:yaak_runtime/yaml.js", + esm = [dir "src/plugin-runtime", "yaml.js"] +); + +async fn run_plugin_deno_2( + plugin_index_file: &str, + fn_name: &str, + fn_args: Vec, +) -> Result { + let source_map_store = SourceMapStore(Rc::new(RefCell::new(HashMap::new()))); + + let mut ext_console = deno_console::deno_console::init_ops_and_esm(); + ext_console.esm_entry_point = Some("ext:deno_console/01_console.js"); + + let ext_yaak = yaak_runtime::init_ops_and_esm(); + + let mut js_runtime = JsRuntime::new(RuntimeOptions { + module_loader: Some(Rc::new(TypescriptModuleLoader { + source_maps: source_map_store.clone(), + })), + source_map_getter: Some(Rc::new(source_map_store)), + extensions: vec![ext_console, ext_yaak], + ..Default::default() + }); + + let main_module = resolve_path( + plugin_index_file, + &std::env::current_dir().context("Unable to get CWD")?, + )?; + + // Load the main module so we can do stuff with it + let mod_id = js_runtime.load_main_es_module(&main_module).await?; + let result = js_runtime.mod_evaluate(mod_id); + js_runtime.run_event_loop(Default::default()).await?; + result.await?; + + let module_namespace = js_runtime.get_module_namespace(mod_id).unwrap(); + let scope = &mut js_runtime.handle_scope(); + let module_namespace = v8::Local::::new(scope, module_namespace); + + // Get the exported function we're calling + let func_key = v8::String::new(scope, fn_name).unwrap(); + let func = module_namespace.get(scope, func_key.into()).unwrap(); + let func = v8::Local::::try_from(func).unwrap(); + let tc_scope = &mut v8::TryCatch::new(scope); + + // Create Yaak context object + let null = v8::null(tc_scope).into(); + let name = v8::String::new(tc_scope, "foo").unwrap().into(); + let value = v8::String::new(tc_scope, "bar").unwrap().into(); + let yaak_ctx: v8::Local = + v8::Object::with_prototype_and_properties(tc_scope, null, &[name], &[value]).into(); + + // Create the function arguments + let passed_args = &mut fn_args + .iter() + .map(|a| { + let v: v8::Local = deno_core::serde_v8::to_v8(tc_scope, a).unwrap(); + v + }) + .collect::>>(); + + let all_args = &mut vec![yaak_ctx]; + all_args.append(passed_args); + + // Call the function + let func_res = func.call(tc_scope, module_namespace.into(), all_args); + + // Catch and return any thrown errors + if tc_scope.has_caught() { + let e = tc_scope.exception().unwrap(); + let js_error = JsError::from_v8_exception(tc_scope, e); + return Err(Error::msg(js_error.stack.unwrap_or_default())); + } + + // Handle the result + match func_res { + None => Ok(serde_json::Value::Null), + Some(res) => { + if res.is_null() || res.is_undefined() { + Ok(serde_json::Value::Null) + } else { + let value: serde_json::Value = deno_core::serde_v8::from_v8(tc_scope, res).unwrap(); + Ok(value) + } + } + } +} diff --git a/src-tauri/src/deno_ops.rs b/src-tauri/src/deno_ops.rs new file mode 100644 index 00000000..6430f208 --- /dev/null +++ b/src-tauri/src/deno_ops.rs @@ -0,0 +1,14 @@ +use deno_core::error::AnyError; +use deno_core::op2; + +#[op2] +#[serde] pub fn op_yaml_parse(#[string] text: String) -> Result { + let value = serde_yaml::from_str(&text)?; + Ok(value) +} + +#[op2] +#[string] pub fn op_yaml_stringify(#[serde] value: serde_json::Value) -> Result { + let value = serde_yaml::to_string(&value)?; + Ok(value) +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index df69d193..499662e4 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -71,6 +71,8 @@ mod render; mod tauri_plugin_mac_window; mod updates; mod window_menu; +mod deno; +mod deno_ops; const DEFAULT_WINDOW_WIDTH: f64 = 1100.0; const DEFAULT_WINDOW_HEIGHT: f64 = 600.0; @@ -118,7 +120,6 @@ async fn cmd_dismiss_notification( notification_id: &str, yaak_notifier: State<'_, Mutex>, ) -> Result<(), String> { - info!("SEEN? {notification_id}"); yaak_notifier.lock().await.seen(&app, notification_id).await } @@ -736,7 +737,7 @@ async fn cmd_filter_response( }; let body = read_to_string(response.body_path.unwrap()).unwrap(); - let filter_result = plugin::run_plugin_filter(&w.app_handle(), plugin_name, filter, &body) + let filter_result = plugin::run_plugin_filter(plugin_name, filter, &body) .await .expect("Failed to run filter"); Ok(filter_result.filtered) @@ -759,7 +760,7 @@ async fn cmd_import_data( read_to_string(file_path).unwrap_or_else(|_| panic!("Unable to read file {}", file_path)); let file_contents = file.as_str(); for plugin_name in plugins { - let v = run_plugin_import(&w.app_handle(), plugin_name, file_contents) + let v = run_plugin_import(plugin_name, file_contents) .await .map_err(|e| e.to_string())?; if let Some(r) = v { @@ -808,13 +809,12 @@ async fn cmd_import_data( } }; - info!("Importing resources"); for mut v in r.resources.workspaces { v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeWorkspace, &mut id_map); let x = upsert_workspace(&w, v).await.map_err(|e| e.to_string())?; imported_resources.workspaces.push(x.clone()); - info!("Imported workspace: {}", x.name); } + info!("Imported {} workspaces", imported_resources.workspaces.len()); for mut v in r.resources.environments { v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeEnvironment, &mut id_map); @@ -825,8 +825,8 @@ async fn cmd_import_data( ); let x = upsert_environment(&w, v).await.map_err(|e| e.to_string())?; imported_resources.environments.push(x.clone()); - info!("Imported environment: {}", x.name); } + info!("Imported {} environments", imported_resources.environments.len()); for mut v in r.resources.folders { v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeFolder, &mut id_map); @@ -838,8 +838,8 @@ async fn cmd_import_data( v.folder_id = maybe_gen_id_opt(v.folder_id, ModelType::TypeFolder, &mut id_map); let x = upsert_folder(&w, v).await.map_err(|e| e.to_string())?; imported_resources.folders.push(x.clone()); - info!("Imported folder: {}", x.name); } + info!("Imported {} folders", imported_resources.folders.len()); for mut v in r.resources.http_requests { v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeHttpRequest, &mut id_map); @@ -853,8 +853,8 @@ async fn cmd_import_data( .await .map_err(|e| e.to_string())?; imported_resources.http_requests.push(x.clone()); - info!("Imported request: {}", x.name); } + info!("Imported {} http_requests", imported_resources.http_requests.len()); for mut v in r.resources.grpc_requests { v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeGrpcRequest, &mut id_map); @@ -868,8 +868,8 @@ async fn cmd_import_data( .await .map_err(|e| e.to_string())?; imported_resources.grpc_requests.push(x.clone()); - info!("Imported request: {}", x.name); } + info!("Imported {} grpc_requests", imported_resources.grpc_requests.len()); Ok(imported_resources) } @@ -893,16 +893,15 @@ async fn cmd_request_to_curl( .await .map_err(|e| e.to_string())?; let rendered = render_request(&request, &workspace, environment.as_ref()); - Ok(run_plugin_export_curl(&app, &rendered)?) + Ok(run_plugin_export_curl(&rendered)?) } #[tauri::command] async fn cmd_curl_to_request( - app: AppHandle, command: &str, workspace_id: &str, ) -> Result { - let v = run_plugin_import(&app, "importer-curl", command) + let v = run_plugin_import("importer-curl", command) .await .map_err(|e| e.to_string()); match v { @@ -1581,7 +1580,9 @@ pub fn run() { .level_for("tokio_util", log::LevelFilter::Info) .level_for("tonic", log::LevelFilter::Info) .level_for("tower", log::LevelFilter::Info) - .level_for("tracing", log::LevelFilter::Info) + .level_for("tracing", log::LevelFilter::Warn) + .level_for("swc_ecma_codegen", log::LevelFilter::Off) + .level_for("swc_ecma_transforms_base", log::LevelFilter::Off) .with_colors(ColoredLevelConfig::default()) .level(if is_dev() { log::LevelFilter::Trace diff --git a/src-tauri/src/plugin-runtime/yaml.js b/src-tauri/src/plugin-runtime/yaml.js new file mode 100644 index 00000000..f7d84120 --- /dev/null +++ b/src-tauri/src/plugin-runtime/yaml.js @@ -0,0 +1,7 @@ +((globalThis) => { + const core = Deno.core; + globalThis.YAML = { + parse: core.ops.op_yaml_parse, + stringify: core.ops.op_yaml_stringify, + }; +})(globalThis); diff --git a/src-tauri/src/plugin.rs b/src-tauri/src/plugin.rs index 1fd56d14..76580fa9 100644 --- a/src-tauri/src/plugin.rs +++ b/src-tauri/src/plugin.rs @@ -1,17 +1,9 @@ -use std::rc::Rc; +use std::path; -use boa_engine::builtins::promise::PromiseState; -use boa_engine::{ - js_string, module::SimpleModuleLoader, property::Attribute, Context, JsNativeError, JsValue, - Module, Source, -}; -use boa_runtime::Console; -use log::{debug, error}; +use log::error; use serde::{Deserialize, Serialize}; -use serde_json::json; -use tauri::path::BaseDirectory; -use tauri::{AppHandle, Manager}; +use crate::deno::run_plugin_deno_block; use crate::models::{HttpRequest, WorkspaceExportResources}; #[derive(Default, Debug, Deserialize, Serialize)] @@ -25,140 +17,68 @@ pub struct ImportResult { } pub async fn run_plugin_filter( - app_handle: &AppHandle, plugin_name: &str, response_body: &str, filter: &str, ) -> Option { - let result_json = run_plugin( - app_handle, - plugin_name, - "pluginHookResponseFilter", - &[js_string!(response_body).into(), js_string!(filter).into()], - ); + let plugin_dir = path::Path::new("/Users/gschier/Workspace/yaak/plugins"); + let plugin_index_file = plugin_dir.join(plugin_name).join("build/index.mjs"); - if result_json.is_null() { + let result = run_plugin_deno_block( + plugin_index_file.to_str().unwrap(), + "pluginHookResponseFilter", + vec![ + serde_json::to_value(response_body).unwrap(), + serde_json::to_value(filter).unwrap(), + ], + ) + .map_err(|e| e.to_string()) + .expect("Failed to run plugin"); + + if result.is_null() { error!("Plugin {} failed to run", plugin_name); return None; } let resources: FilterResult = - serde_json::from_value(result_json).expect("failed to parse filter plugin result json"); + serde_json::from_value(result).expect("failed to parse filter plugin result json"); Some(resources) } -pub fn run_plugin_export_curl( - app_handle: &AppHandle, - request: &HttpRequest, -) -> Result { - let mut context = Context::default(); - let request_json = serde_json::to_value(request).map_err(|e| e.to_string())?; - let result_json = run_plugin( - app_handle, - "exporter-curl", - "pluginHookExport", - &[JsValue::from_json(&request_json, &mut context).map_err(|e| e.to_string())?], - ); +pub fn run_plugin_export_curl(request: &HttpRequest) -> Result { + let plugin_dir = path::Path::new("/Users/gschier/Workspace/yaak/plugins"); + let plugin_index_file = plugin_dir.join("exporter-curl").join("build/index.mjs"); - let resources: String = serde_json::from_value(result_json).map_err(|e| e.to_string())?; - Ok(resources) + let request_json = serde_json::to_value(request).map_err(|e| e.to_string())?; + let result = run_plugin_deno_block( + plugin_index_file.to_str().unwrap(), + "pluginHookExport", + vec![request_json], + ) + .map_err(|e| e.to_string())?; + + let export_str: String = serde_json::from_value(result).map_err(|e| e.to_string())?; + Ok(export_str) } pub async fn run_plugin_import( - app_handle: &AppHandle, plugin_name: &str, file_contents: &str, ) -> Result, String> { - let result_json = run_plugin( - app_handle, - plugin_name, - "pluginHookImport", - &[js_string!(file_contents).into()], - ); + let plugin_dir = path::Path::new("/Users/gschier/Workspace/yaak/plugins"); + let plugin_index_file = plugin_dir.join(plugin_name).join("build/index.mjs"); - if result_json.is_null() { + let result = run_plugin_deno_block( + plugin_index_file.to_str().unwrap(), + "pluginHookImport", + vec![serde_json::to_value(file_contents).map_err(|e| e.to_string())?], + ) + .map_err(|e| e.to_string())?; + + if result.is_null() { return Ok(None); } - let resources: ImportResult = serde_json::from_value(result_json).map_err(|e| e.to_string())?; + let resources: ImportResult = serde_json::from_value(result).map_err(|e| e.to_string())?; Ok(Some(resources)) } - -fn run_plugin( - app_handle: &AppHandle, - plugin_name: &str, - entrypoint: &str, - js_args: &[JsValue], -) -> serde_json::Value { - let plugin_dir = app_handle - .path() - .resolve("plugins", BaseDirectory::Resource) - .expect("failed to resolve plugin directory resource") - .join(plugin_name); - let plugin_index_file = plugin_dir.join("index.mjs"); - - debug!( - "Running plugin dir={:?} file={:?}", - plugin_dir, plugin_index_file - ); - - let loader = Rc::new(SimpleModuleLoader::new(plugin_dir).unwrap()); - let context = &mut Context::builder() - .module_loader(loader.clone()) - .build() - .expect("failed to create context"); - - add_runtime(context); - - let source = Source::from_filepath(&plugin_index_file).expect("Error opening file"); - - // Can also pass a `Some(realm)` if you need to execute the module in another realm. - let module = Module::parse(source, None, context).expect("failed to parse module"); - - // Insert parsed entrypoint into the module loader - loader.insert(plugin_index_file, module.clone()); - - let promise_result = module.load_link_evaluate(context); - - // Very important to push forward the job queue after queueing promises. - context.run_jobs(); - - // Checking if the final promise didn't return an error. - match promise_result.state() { - PromiseState::Pending => { - panic!("Promise was pending"); - } - PromiseState::Fulfilled(v) => { - assert_eq!(v, JsValue::undefined()) - } - PromiseState::Rejected(err) => { - panic!("Failed to link: {}", err.display()); - } - } - - let namespace = module.namespace(context); - - let result = namespace - .get(js_string!(entrypoint), context) - .expect("failed to get entrypoint") - .as_callable() - .cloned() - .ok_or_else(|| JsNativeError::typ().with_message("export wasn't a function!")) - .expect("Failed to get entrypoint") - .call(&JsValue::undefined(), js_args, context) - .expect("Failed to call entrypoint"); - - match result.is_undefined() { - true => json!(null), // to_json doesn't work with undefined (yet) - false => result - .to_json(context) - .expect("failed to convert result to json"), - } -} - -fn add_runtime(context: &mut Context) { - let console = Console::init(context); - context - .register_global_property(js_string!(Console::NAME), console, Attribute::all()) - .expect("the console builtin shouldn't exist"); -} diff --git a/src-web/components/core/FormattedError.tsx b/src-web/components/core/FormattedError.tsx index 8539b4a3..48a6c4b8 100644 --- a/src-web/components/core/FormattedError.tsx +++ b/src-web/components/core/FormattedError.tsx @@ -9,7 +9,7 @@ export function FormattedError({ children }: Props) { return (
diff --git a/src-web/hooks/useAlert.ts b/src-web/hooks/useAlert.ts
index 2c3b84e0..d856f8c1 100644
--- a/src-web/hooks/useAlert.ts
+++ b/src-web/hooks/useAlert.ts
@@ -7,12 +7,22 @@ import { Alert } from './Alert';
 export function useAlert() {
   const dialog = useDialog();
   return useCallback(
-    ({ id, title, body }: { id: string; title: DialogProps['title']; body: AlertProps['body'] }) =>
+    ({
+      id,
+      title,
+      body,
+      size = 'sm',
+    }: {
+      id: string;
+      title: DialogProps['title'];
+      body: AlertProps['body'];
+      size?: DialogProps['size'];
+    }) =>
       dialog.show({
         id,
         title,
         hideX: true,
-        size: 'sm',
+        size,
         render: ({ hide }) => Alert({ onHide: hide, body }),
       }),
     // eslint-disable-next-line react-hooks/exhaustive-deps
diff --git a/src-web/hooks/useImportData.tsx b/src-web/hooks/useImportData.tsx
index 495ed879..1788ac0e 100644
--- a/src-web/hooks/useImportData.tsx
+++ b/src-web/hooks/useImportData.tsx
@@ -2,6 +2,7 @@ import { useMutation } from '@tanstack/react-query';
 import { invoke } from '@tauri-apps/api/core';
 import { open } from '@tauri-apps/plugin-dialog';
 import { Button } from '../components/core/Button';
+import { FormattedError } from '../components/core/FormattedError';
 import { VStack } from '../components/core/Stacks';
 import { useDialog } from '../components/DialogContext';
 import type { Environment, Folder, GrpcRequest, HttpRequest, Workspace } from '../lib/models';
@@ -77,7 +78,12 @@ export function useImportData() {
 
   return useMutation({
     onError: (err: string) => {
-      alert({ id: 'import-failed', title: 'Import Failed', body: err });
+      alert({
+        id: 'import-failed',
+        title: 'Import Failed',
+        size: 'md',
+        body: {err},
+      });
     },
     mutationFn: async () => {
       return new Promise((resolve, reject) => {
diff --git a/src-web/plugin/runtime.d.ts b/src-web/plugin/runtime.d.ts
new file mode 100644
index 00000000..13f022b6
--- /dev/null
+++ b/src-web/plugin/runtime.d.ts
@@ -0,0 +1,10 @@
+declare global {
+  const YAML: {
+    parse: (yml: string) => unknown;
+  };
+  interface YaakContext {
+    foo: string;
+  }
+}
+
+export {};