diff --git a/README.md b/README.md new file mode 100644 index 0000000..36d8496 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Lightningbeam 2 + +This README needs content. This is Lightningbeam rewritten with Tauri. + +To test: + +`pnpm tauri dev` \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2348626 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "lightningbeam", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "tauri": "tauri" + }, + "devDependencies": { + "@tauri-apps/cli": "^2" + }, + "dependencies": { + "@tauri-apps/plugin-dialog": "~2", + "@tauri-apps/plugin-fs": "~2" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..9af2e76 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,151 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@tauri-apps/plugin-dialog': + specifier: ~2 + version: 2.0.1 + '@tauri-apps/plugin-fs': + specifier: ~2 + version: 2.0.2 + devDependencies: + '@tauri-apps/cli': + specifier: ^2 + version: 2.0.4 + +packages: + + '@tauri-apps/api@2.1.1': + resolution: {integrity: sha512-fzUfFFKo4lknXGJq8qrCidkUcKcH2UHhfaaCNt4GzgzGaW2iS26uFOg4tS3H4P8D6ZEeUxtiD5z0nwFF0UN30A==} + + '@tauri-apps/cli-darwin-arm64@2.0.4': + resolution: {integrity: sha512-siH7rOHobb16rPbc11k64p1mxIpiRCkWmzs2qmL5IX21Gx9K5onI3Tk67Oqpf2uNupbYzItrOttaDT4NHFC7tw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@tauri-apps/cli-darwin-x64@2.0.4': + resolution: {integrity: sha512-zIccfbCoZMfmUpnk6PFCV0keFyfVj1A9XV3Oiiitj/dkTZ9CQvzjhX3XC0XcK4rsTWegfr2PjSrK06aiPAROAw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@tauri-apps/cli-linux-arm-gnueabihf@2.0.4': + resolution: {integrity: sha512-fgQqJzefOGWCBNg4yrVA82Rg4s1XQr5K0dc2rCxBhJfa696e8dQ1LDrnWq/AiO5r+uHfVaoQTIUvxxpFicYRSA==} + engines: {node: '>= 10'} + cpu: [arm] + os: [linux] + + '@tauri-apps/cli-linux-arm64-gnu@2.0.4': + resolution: {integrity: sha512-u8wbt5tPA9pI6j+d7jGrfOz9UVCiTp+IYzKNiIqlrDsAjqAUFaNXYHKqOUboeFWEmI4zoCWj6LgpS2OJTQ5FKg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@tauri-apps/cli-linux-arm64-musl@2.0.4': + resolution: {integrity: sha512-hntF1V8e3V1hlrESm93PsghDhf3lA5pbvFrRfYxU1c+fVD/jRXGVw8BH3O1lW8MWwhEg1YdhKk01oAgsuHLuig==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@tauri-apps/cli-linux-x64-gnu@2.0.4': + resolution: {integrity: sha512-Iq1GGJb+oT1T0ZV8izrgf0cBtlzPCJaWcNueRbf1ZXquMf+FSTyQv+/Lo8rq5T6buOIJOH7cAOTuEWWqiCZteg==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@tauri-apps/cli-linux-x64-musl@2.0.4': + resolution: {integrity: sha512-9NTk6Pf0bSwXqCBdAA+PDYts9HeHebZzIo8mbRzRyUbER6QngG5HZb9Ka36Z1QWtJjdRy6uxSb4zb/9NuTeHfA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@tauri-apps/cli-win32-arm64-msvc@2.0.4': + resolution: {integrity: sha512-OF2e9oxiBFR8A8wVMOhUx9QGN/I1ZkquWC7gVQBnA56nx9PabJlDT08QBy5UD8USqZFVznnfNr2ehlheQahb3g==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@tauri-apps/cli-win32-ia32-msvc@2.0.4': + resolution: {integrity: sha512-T+hCKB3rFP6q0saHHtR02hm6wr1ZPJ0Mkii3oRTxjPG6BBXoVzHNCYzvdgEGJPTA2sFuAQtJH764NRtNlDMifw==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + + '@tauri-apps/cli-win32-x64-msvc@2.0.4': + resolution: {integrity: sha512-GVaiI3KWRFLomjJmApHqihhYlkJ+7FqhumhVfBO6Z2tWzZjQyVQgTdNp0kYEuW2WoAYEj0dKY6qd4YM33xYcUA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@tauri-apps/cli@2.0.4': + resolution: {integrity: sha512-Hl9eFXz+O366+6su9PfaSzu2EJdFe1p8K8ghkWmi40dz8VmSE7vsMTaOStD0I71ckSOkh2ICDX7FQTBgjlpjWw==} + engines: {node: '>= 10'} + hasBin: true + + '@tauri-apps/plugin-dialog@2.0.1': + resolution: {integrity: sha512-fnUrNr6EfvTqdls/ufusU7h6UbNFzLKvHk/zTuOiBq01R3dTODqwctZlzakdbfSp/7pNwTKvgKTAgl/NAP/Z0Q==} + + '@tauri-apps/plugin-fs@2.0.2': + resolution: {integrity: sha512-4YZaX2j7ta81M5/DL8aN10kTnpUkEpkPo1FTYPT8Dd0ImHe3azM8i8MrtjrDGoyBYLPO3zFv7df/mSCYF8oA0Q==} + +snapshots: + + '@tauri-apps/api@2.1.1': {} + + '@tauri-apps/cli-darwin-arm64@2.0.4': + optional: true + + '@tauri-apps/cli-darwin-x64@2.0.4': + optional: true + + '@tauri-apps/cli-linux-arm-gnueabihf@2.0.4': + optional: true + + '@tauri-apps/cli-linux-arm64-gnu@2.0.4': + optional: true + + '@tauri-apps/cli-linux-arm64-musl@2.0.4': + optional: true + + '@tauri-apps/cli-linux-x64-gnu@2.0.4': + optional: true + + '@tauri-apps/cli-linux-x64-musl@2.0.4': + optional: true + + '@tauri-apps/cli-win32-arm64-msvc@2.0.4': + optional: true + + '@tauri-apps/cli-win32-ia32-msvc@2.0.4': + optional: true + + '@tauri-apps/cli-win32-x64-msvc@2.0.4': + optional: true + + '@tauri-apps/cli@2.0.4': + optionalDependencies: + '@tauri-apps/cli-darwin-arm64': 2.0.4 + '@tauri-apps/cli-darwin-x64': 2.0.4 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.4 + '@tauri-apps/cli-linux-arm64-gnu': 2.0.4 + '@tauri-apps/cli-linux-arm64-musl': 2.0.4 + '@tauri-apps/cli-linux-x64-gnu': 2.0.4 + '@tauri-apps/cli-linux-x64-musl': 2.0.4 + '@tauri-apps/cli-win32-arm64-msvc': 2.0.4 + '@tauri-apps/cli-win32-ia32-msvc': 2.0.4 + '@tauri-apps/cli-win32-x64-msvc': 2.0.4 + + '@tauri-apps/plugin-dialog@2.0.1': + dependencies: + '@tauri-apps/api': 2.1.1 + + '@tauri-apps/plugin-fs@2.0.2': + dependencies: + '@tauri-apps/api': 2.1.1 diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock new file mode 100644 index 0000000..a828459 --- /dev/null +++ b/src-tauri/Cargo.lock @@ -0,0 +1,5091 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" + +[[package]] +name = "ashpd" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c39d707614dbcc6bed00015539f488d8e3fe3e66ed60961efc0c90f4b380b3" +dependencies = [ + "enumflags2", + "futures-channel", + "futures-util", + "rand 0.8.5", + "raw-window-handle", + "serde", + "serde_repr", + "tokio", + "url", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "zbus", +] + +[[package]] +name = "async-broadcast" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "async-trait" +version = "0.1.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "atk" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4af014b17dd80e8af9fa689b2d4a211ddba6eb583c1622f35d0cb543f6b17e4" +dependencies = [ + "atk-sys", + "glib", + "libc", +] + +[[package]] +name = "atk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "251e0b7d90e33e0ba930891a505a9a35ece37b2dd37a14f3ffc306c13b980009" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +dependencies = [ + "serde", +] + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2", +] + +[[package]] +name = "brotli" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytemuck" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +dependencies = [ + "serde", +] + +[[package]] +name = "cairo-rs" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" +dependencies = [ + "bitflags 2.6.0", + "cairo-sys-rs", + "glib", + "libc", + "once_cell", + "thiserror", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cargo_toml" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a969e13a7589e9e3e4207e153bae624ade2b5622fb4684a4923b23ec3d57719" +dependencies = [ + "serde", + "toml 0.8.2", +] + +[[package]] +name = "cc" +version = "1.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +dependencies = [ + "shlex", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cfb" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" +dependencies = [ + "byteorder", + "fnv", + "uuid", +] + +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.6", +] + +[[package]] +name = "cocoa" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79398230a6e2c08f5c9760610eb6924b52aa9e7950a619602baba59dcbbdbb2" +dependencies = [ + "bitflags 2.6.0", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14045fb83be07b5acf1c0884b2180461635b433455fa35d1cd6f17f1450679d" +dependencies = [ + "bitflags 2.6.0", + "block", + "core-foundation", + "core-graphics-types", + "libc", + "objc", +] + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core-graphics" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cssparser" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa 0.4.8", + "matches", + "phf 0.8.0", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.109", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +dependencies = [ + "quote", + "syn 2.0.87", +] + +[[package]] +name = "ctor" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" +dependencies = [ + "quote", + "syn 2.0.87", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.87", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading", +] + +[[package]] +name = "dlopen2" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1297103d2bbaea85724fcee6294c2d50b1081f9ad47d0f6f6f61eda65315a6" +dependencies = [ + "dlopen2_derive", + "libc", + "once_cell", + "winapi", +] + +[[package]] +name = "dlopen2_derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" +dependencies = [ + "serde", +] + +[[package]] +name = "dtoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + +[[package]] +name = "embed-resource" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4e24052d7be71f0efb50c201557f6fe7d237cfd5a64fd5bcd7fd8fe32dbbffa" +dependencies = [ + "cc", + "memchr", + "rustc_version", + "toml 0.8.2", + "vswhom", + "winreg", +] + +[[package]] +name = "embed_plist" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "endi" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" + +[[package]] +name = "enumflags2" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "erased-serde" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" +dependencies = [ + "serde", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" + +[[package]] +name = "fdeflate" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "field-offset" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "flate2" +version = "1.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fluent-uri" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" +dependencies = [ + "mac", + "new_debug_unreachable", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "gdk" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5ba081bdef3b75ebcdbfc953699ed2d7417d6bd853347a42a37d76406a33646" +dependencies = [ + "cairo-rs", + "gdk-pixbuf", + "gdk-sys", + "gio", + "glib", + "libc", + "pango", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" +dependencies = [ + "gdk-pixbuf-sys", + "gio", + "glib", + "libc", + "once_cell", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ff856cb3386dae1703a920f803abafcc580e9b5f711ca62ed1620c25b51ff2" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + +[[package]] +name = "gdkwayland-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a90fbf5c033c65d93792192a49a8efb5bb1e640c419682a58bb96f5ae77f3d4a" +dependencies = [ + "gdk-sys", + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", + "system-deps", +] + +[[package]] +name = "gdkx11" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2ea8a4909d530f79921290389cbd7c34cb9d623bfe970eaae65ca5f9cd9cce" +dependencies = [ + "gdk", + "gdkx11-sys", + "gio", + "glib", + "libc", + "x11", +] + +[[package]] +name = "gdkx11-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee8f00f4ee46cad2939b8990f5c70c94ff882c3028f3cc5abf950fa4ab53043" +dependencies = [ + "gdk-sys", + "glib-sys", + "libc", + "system-deps", + "x11", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "gio" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "gio-sys", + "glib", + "libc", + "once_cell", + "pin-project-lite", + "smallvec", + "thiserror", +] + +[[package]] +name = "gio-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + +[[package]] +name = "glib" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +dependencies = [ + "bitflags 2.6.0", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "memchr", + "once_cell", + "smallvec", + "thiserror", +] + +[[package]] +name = "glib-macros" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" +dependencies = [ + "heck 0.4.1", + "proc-macro-crate 2.0.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "glib-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +dependencies = [ + "libc", + "system-deps", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gobject-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gtk" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93c4f5e0e20b60e10631a5f06da7fe3dda744b05ad0ea71fee2f47adf865890c" +dependencies = [ + "atk", + "cairo-rs", + "field-offset", + "futures-channel", + "gdk", + "gdk-pixbuf", + "gio", + "glib", + "gtk-sys", + "gtk3-macros", + "libc", + "pango", + "pkg-config", +] + +[[package]] +name = "gtk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771437bf1de2c1c0b496c11505bdf748e26066bbe942dfc8f614c9460f6d7722" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "gtk3-macros" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6063efb63db582968fb7df72e1ae68aa6360dcfb0a75143f34fc7d616bad75e" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "html5ever" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +dependencies = [ + "log", + "mac", + "markup5ever", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa 1.0.11", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "hyper" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa 1.0.11", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core 0.52.0", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ico" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3804960be0bb5e4edb1e1ad67afd321a9ecfd875c3e65c099468fd2717d7cae" +dependencies = [ + "byteorder", + "png", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +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.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.1", + "serde", +] + +[[package]] +name = "infer" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc150e5ce2330295b8616ce0e3f53250e53af31759a9dbedad1621ba29151847" +dependencies = [ + "cfb", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "javascriptcore-rs" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc" +dependencies = [ + "bitflags 1.3.2", + "glib", + "javascriptcore-rs-sys", +] + +[[package]] +name = "javascriptcore-rs-sys" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "json-patch" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b1fb8864823fad91877e6caea0baca82e49e8db50f8e5c9f9a453e27d3330fc" +dependencies = [ + "jsonptr 0.4.7", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "json-patch" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863726d7afb6bc2590eeff7135d923545e5e964f004c2ccf8716c25e70a86f08" +dependencies = [ + "jsonptr 0.6.3", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "jsonptr" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c6e529149475ca0b2820835d3dce8fcc41c6b943ca608d32f35b449255e4627" +dependencies = [ + "fluent-uri", + "serde", + "serde_json", +] + +[[package]] +name = "jsonptr" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dea2b27dd239b2556ed7a25ba842fe47fd602e7fc7433c2a8d6106d4d9edd70" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.6.0", + "serde", + "unicode-segmentation", +] + +[[package]] +name = "kuchikiki" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8" +dependencies = [ + "cssparser", + "html5ever", + "indexmap 1.9.3", + "matches", + "selectors", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libappindicator" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a" +dependencies = [ + "glib", + "gtk", + "gtk-sys", + "libappindicator-sys", + "log", +] + +[[package]] +name = "libappindicator-sys" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf" +dependencies = [ + "gtk-sys", + "libloading", + "once_cell", +] + +[[package]] +name = "libc" +version = "0.2.162" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + +[[package]] +name = "lightningbeam" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "tauri", + "tauri-build", + "tauri-plugin-dialog", + "tauri-plugin-fs", + "tauri-plugin-shell", +] + +[[package]] +name = "linux-raw-sys" +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 = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "mac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "markup5ever" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" +dependencies = [ + "log", + "phf 0.10.1", + "phf_codegen 0.10.0", + "string_cache", + "string_cache_codegen", + "tendril", +] + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.52.0", +] + +[[package]] +name = "muda" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdae9c00e61cc0579bcac625e8ad22104c60548a025bfc972dc83868a28e1484" +dependencies = [ + "crossbeam-channel", + "dpi", + "gtk", + "keyboard-types", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "once_cell", + "png", + "serde", + "thiserror", + "windows-sys 0.59.0", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.6.0", + "jni-sys", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" +dependencies = [ + "cc", +] + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.6.0", + "block2", + "libc", + "objc2", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-core-location", + "objc2-foundation", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2", + "objc2", + "objc2-contacts", + "objc2-foundation", +] + +[[package]] +name = "objc2-encode" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.6.0", + "block2", + "dispatch", + "libc", + "objc2", +] + +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2", + "objc2", + "objc2-app-kit", + "objc2-foundation", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation", + "objc2-link-presentation", + "objc2-quartz-core", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-core-location", + "objc2-foundation", +] + +[[package]] +name = "objc2-web-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bc69301064cebefc6c4c90ce9cba69225239e4b8ff99d445a2b5563797da65" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-app-kit", + "objc2-foundation", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "open" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "os_pipe" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "pango" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +dependencies = [ + "gio", + "glib", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "pathdiff" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "phf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_macros 0.8.0", + "phf_shared 0.8.0", + "proc-macro-hack", +] + +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_shared 0.10.0", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros 0.11.2", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_codegen" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +dependencies = [ + "phf_generator 0.8.0", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf_codegen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", +] + +[[package]] +name = "phf_generator" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +dependencies = [ + "phf_shared 0.8.0", + "rand 0.7.3", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand 0.8.5", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" +dependencies = [ + "phf_generator 0.8.0", + "phf_shared 0.8.0", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator 0.11.2", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "plist" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" +dependencies = [ + "base64 0.22.1", + "indexmap 2.6.0", + "quick-xml 0.32.0", + "serde", + "time", +] + +[[package]] +name = "png" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.2", +] + +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit 0.22.22", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-xml" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" +dependencies = [ + "memchr", +] + +[[package]] +name = "quick-xml" +version = "0.36.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.15", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "windows-registry", +] + +[[package]] +name = "rfd" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f6f80a9b882647d9014673ca9925d30ffc9750f2eed2b4490e189eaebd01e8" +dependencies = [ + "ashpd", + "block2", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "log", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "indexmap 1.9.3", + "schemars_derive", + "serde", + "serde_json", + "url", + "uuid", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.87", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "selectors" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" +dependencies = [ + "bitflags 1.3.2", + "cssparser", + "derive_more", + "fxhash", + "log", + "matches", + "phf 0.8.0", + "phf_codegen 0.8.0", + "precomputed-hash", + "servo_arc", + "smallvec", + "thin-slice", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-untagged" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2676ba99bd82f75cae5cbd2c8eda6fa0b8760f18978ea840e980dd5567b5c5b6" +dependencies = [ + "erased-serde", + "serde", + "typeid", +] + +[[package]] +name = "serde_derive" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_json" +version = "1.0.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +dependencies = [ + "itoa 1.0.11", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa 1.0.11", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.6.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serialize-to-javascript" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9823f2d3b6a81d98228151fdeaf848206a7855a7a042bbf9bf870449a66cafb" +dependencies = [ + "serde", + "serde_json", + "serialize-to-javascript-impl", +] + +[[package]] +name = "serialize-to-javascript-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74064874e9f6a15f04c1f3cb627902d0e6b410abbf36668afa873c61889f1763" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "servo_arc" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" +dependencies = [ + "nodrop", + "stable_deref_trait", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shared_child" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fa9338aed9a1df411814a5b2252f7cd206c55ae9bf2fa763f8de84603aa60c" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "softbuffer" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08" +dependencies = [ + "bytemuck", + "cfg_aliases", + "core-graphics", + "foreign-types", + "js-sys", + "log", + "objc2", + "objc2-foundation", + "objc2-quartz-core", + "raw-window-handle", + "redox_syscall", + "wasm-bindgen", + "web-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "soup3" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f" +dependencies = [ + "futures-channel", + "gio", + "glib", + "libc", + "soup3-sys", +] + +[[package]] +name = "soup3-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared 0.10.0", + "precomputed-hash", + "serde", +] + +[[package]] +name = "string_cache_codegen" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro2", + "quote", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "swift-rs" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4057c98e2e852d51fdcfca832aac7b571f6b351ad159f9eda5db1655f8d0c4d7" +dependencies = [ + "base64 0.21.7", + "serde", + "serde_json", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + +[[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.87", +] + +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck 0.5.0", + "pkg-config", + "toml 0.8.2", + "version-compare", +] + +[[package]] +name = "tao" +version = "0.30.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63f1f6b2017cc33d7f6fc9c6186a2c0f5dfc985899a7b4fe9e64985c17533db3" +dependencies = [ + "bitflags 2.6.0", + "cocoa", + "core-foundation", + "core-graphics", + "crossbeam-channel", + "dispatch", + "dlopen2", + "dpi", + "gdkwayland-sys", + "gdkx11-sys", + "gtk", + "instant", + "jni", + "lazy_static", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "objc", + "once_cell", + "parking_lot", + "raw-window-handle", + "scopeguard", + "tao-macros", + "unicode-segmentation", + "url", + "windows", + "windows-core 0.58.0", + "windows-version", + "x11-dl", +] + +[[package]] +name = "tao-macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "tauri" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3889b392db6d32a105d3757230ea0220090b8f94c90d3e60b6c5eb91178ab1b" +dependencies = [ + "anyhow", + "bytes", + "dirs", + "dunce", + "embed_plist", + "futures-util", + "getrandom 0.2.15", + "glob", + "gtk", + "heck 0.5.0", + "http", + "jni", + "libc", + "log", + "mime", + "muda", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "percent-encoding", + "plist", + "raw-window-handle", + "reqwest", + "serde", + "serde_json", + "serde_repr", + "serialize-to-javascript", + "swift-rs", + "tauri-build", + "tauri-macros", + "tauri-runtime", + "tauri-runtime-wry", + "tauri-utils", + "thiserror", + "tokio", + "tray-icon", + "url", + "urlpattern", + "webkit2gtk", + "webview2-com", + "window-vibrancy", + "windows", +] + +[[package]] +name = "tauri-build" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f96827ccfb1aa40d55d0ded79562d18ba18566657a553f992a982d755148376" +dependencies = [ + "anyhow", + "cargo_toml", + "dirs", + "glob", + "heck 0.5.0", + "json-patch 3.0.1", + "schemars", + "semver", + "serde", + "serde_json", + "tauri-utils", + "tauri-winres", + "toml 0.8.2", + "walkdir", +] + +[[package]] +name = "tauri-codegen" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947f16f47becd9e9cd39b74ee337fd1981574d78819be18e4384d85e5a0b82f" +dependencies = [ + "base64 0.22.1", + "brotli", + "ico", + "json-patch 2.0.0", + "plist", + "png", + "proc-macro2", + "quote", + "semver", + "serde", + "serde_json", + "sha2", + "syn 2.0.87", + "tauri-utils", + "thiserror", + "time", + "url", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-macros" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bd1c8d4a66799d3438747c3a79705cd665a95d6f24cb5f315413ff7a981fe2a" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.87", + "tauri-codegen", + "tauri-utils", +] + +[[package]] +name = "tauri-plugin" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa4e6c94cb1d635f65a770c69e23de1bc054b0e4c554fa037a7cc7676333d39" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars", + "serde", + "serde_json", + "tauri-utils", + "toml 0.8.2", + "walkdir", +] + +[[package]] +name = "tauri-plugin-dialog" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4307310e1d2c09ab110235834722e7c2b85099b683e1eb7342ab351b0be5ada3" +dependencies = [ + "log", + "raw-window-handle", + "rfd", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror", + "url", +] + +[[package]] +name = "tauri-plugin-fs" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ba7d46e86db8c830d143ef90ab5a453328365b0cc834c24edea4267b16aba0" +dependencies = [ + "anyhow", + "dunce", + "glob", + "percent-encoding", + "schemars", + "serde", + "serde_json", + "serde_repr", + "tauri", + "tauri-plugin", + "thiserror", + "url", + "uuid", +] + +[[package]] +name = "tauri-plugin-shell" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad7880c5586b6b2104be451e3d7fc0f3800c84bda69e9ba81c828f87cb34267" +dependencies = [ + "encoding_rs", + "log", + "open", + "os_pipe", + "regex", + "schemars", + "serde", + "serde_json", + "shared_child", + "tauri", + "tauri-plugin", + "thiserror", + "tokio", +] + +[[package]] +name = "tauri-runtime" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ef7363e7229ac8d04e8a5d405670dbd43dde8fc4bc3bc56105c35452d03784" +dependencies = [ + "dpi", + "gtk", + "http", + "jni", + "raw-window-handle", + "serde", + "serde_json", + "tauri-utils", + "thiserror", + "url", + "windows", +] + +[[package]] +name = "tauri-runtime-wry" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62fa2068e8498ad007b54d5773d03d57c3ff6dd96f8c8ce58beff44d0d5e0d30" +dependencies = [ + "gtk", + "http", + "jni", + "log", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "percent-encoding", + "raw-window-handle", + "softbuffer", + "tao", + "tauri-runtime", + "tauri-utils", + "url", + "webkit2gtk", + "webview2-com", + "windows", + "wry", +] + +[[package]] +name = "tauri-utils" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc65d6f5c54e56b66258948a6d9e47a82ea41f4b5a7612bfbdd1634c2913ed0" +dependencies = [ + "brotli", + "cargo_metadata", + "ctor", + "dunce", + "glob", + "html5ever", + "infer", + "json-patch 2.0.0", + "kuchikiki", + "log", + "memchr", + "phf 0.11.2", + "proc-macro2", + "quote", + "regex", + "schemars", + "semver", + "serde", + "serde-untagged", + "serde_json", + "serde_with", + "swift-rs", + "thiserror", + "toml 0.8.2", + "url", + "urlpattern", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-winres" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb" +dependencies = [ + "embed-resource", + "toml 0.7.8", +] + +[[package]] +name = "tempfile" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "tendril" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" +dependencies = [ + "futf", + "mac", + "utf-8", +] + +[[package]] +name = "thin-slice" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" + +[[package]] +name = "thiserror" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa 1.0.11", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.41.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.2", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.6.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.6.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap 2.6.0", + "toml_datetime", + "winnow 0.6.20", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tray-icon" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c92af36a182b46206723bdf8a7942e20838cde1cf062e5b97854d57eb01763b" +dependencies = [ + "core-graphics", + "crossbeam-channel", + "dirs", + "libappindicator", + "muda", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "once_cell", + "png", + "serde", + "thiserror", + "windows-sys 0.59.0", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typeid" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uds_windows" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" +dependencies = [ + "memoffset", + "tempfile", + "winapi", +] + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-ucd-ident" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "url" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "urlpattern" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70acd30e3aa1450bc2eece896ce2ad0d178e9c079493819301573dae3c37ba6d" +dependencies = [ + "regex", + "serde", + "unic-ucd-ident", + "url", +] + +[[package]] +name = "utf-8" +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_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +dependencies = [ + "getrandom 0.2.15", + "serde", +] + +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vswhom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] + +[[package]] +name = "vswhom-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wayland-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6" +dependencies = [ + "cc", + "downcast-rs", + "rustix", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66249d3fc69f76fd74c82cc319300faa554e9d865dab1f7cd66cc20db10b280" +dependencies = [ + "bitflags 2.6.0", + "rustix", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd0ade57c4e6e9a8952741325c30bf82f4246885dca8bf561898b86d0c1f58e" +dependencies = [ + "bitflags 2.6.0", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597f2001b2e5fc1121e3d5b9791d3e78f05ba6bfa4641053846248e3a13661c3" +dependencies = [ + "proc-macro2", + "quick-xml 0.36.2", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efa8ac0d8e8ed3e3b5c9fc92c7881406a268e11555abe36493efabe649a29e09" +dependencies = [ + "dlib", + "log", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webkit2gtk" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b1bc1e54c581da1e9f179d0b38512ba358fb1af2d634a1affe42e37172361a" +dependencies = [ + "bitflags 1.3.2", + "cairo-rs", + "gdk", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk", + "gtk-sys", + "javascriptcore-rs", + "libc", + "once_cell", + "soup3", + "webkit2gtk-sys", +] + +[[package]] +name = "webkit2gtk-sys" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62daa38afc514d1f8f12b8693d30d5993ff77ced33ce30cd04deebc267a6d57c" +dependencies = [ + "bitflags 1.3.2", + "cairo-sys-rs", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "gtk-sys", + "javascriptcore-rs-sys", + "libc", + "pkg-config", + "soup3-sys", + "system-deps", +] + +[[package]] +name = "webview2-com" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61ff3d9d0ee4efcb461b14eb3acfda2702d10dc329f339303fc3e57215ae2c" +dependencies = [ + "webview2-com-macros", + "webview2-com-sys", + "windows", + "windows-core 0.58.0", + "windows-implement", + "windows-interface", +] + +[[package]] +name = "webview2-com-macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "webview2-com-sys" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3a3e2eeb58f82361c93f9777014668eb3d07e7d174ee4c819575a9208011886" +dependencies = [ + "thiserror", + "windows", + "windows-core 0.58.0", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "window-vibrancy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ea403deff7b51fff19e261330f71608ff2cdef5721d72b64180bb95be7c4150" +dependencies = [ + "objc2", + "objc2-app-kit", + "objc2-foundation", + "raw-window-handle", + "windows-sys 0.59.0", + "windows-version", +] + +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-version" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6998aa457c9ba8ff2fb9f13e9d2a930dabcea28f1d0ab94d687d8b3654844515" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "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.46.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd5cdf57c66813d97601181349c63b96994b3074fc3d7a31a8cce96e968e3bbd" +dependencies = [ + "base64 0.22.1", + "block2", + "crossbeam-channel", + "dpi", + "dunce", + "gdkx11", + "gtk", + "html5ever", + "http", + "javascriptcore-rs", + "jni", + "kuchikiki", + "libc", + "ndk", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "objc2-ui-kit", + "objc2-web-kit", + "once_cell", + "percent-encoding", + "raw-window-handle", + "sha2", + "soup3", + "tao-macros", + "thiserror", + "webkit2gtk", + "webkit2gtk-sys", + "webview2-com", + "windows", + "windows-core 0.58.0", + "windows-version", + "x11-dl", +] + +[[package]] +name = "x11" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "xdg-home" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[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.87", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1162094dc63b1629fcc44150bcceeaa80798cd28bcbe7fa987b65a034c258608" +dependencies = [ + "async-broadcast", + "async-recursion", + "async-trait", + "enumflags2", + "event-listener", + "futures-core", + "futures-util", + "hex", + "nix", + "ordered-stream", + "serde", + "serde_repr", + "static_assertions", + "tokio", + "tracing", + "uds_windows", + "windows-sys 0.59.0", + "winnow 0.6.20", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cd2dcdce3e2727f7d74b7e33b5a89539b3cc31049562137faf7ae4eb86cd16d" +dependencies = [ + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.87", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "856b7a38811f71846fd47856ceee8bccaec8399ff53fb370247e66081ace647b" +dependencies = [ + "serde", + "static_assertions", + "winnow 0.6.20", + "zvariant", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[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.87", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zvariant" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1200ee6ac32f1e5a312e455a949a4794855515d34f9909f4a3e082d14e1a56f" +dependencies = [ + "endi", + "enumflags2", + "serde", + "static_assertions", + "url", + "winnow 0.6.20", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "687e3b97fae6c9104fbbd36c73d27d149abf04fb874e2efbd84838763daa8916" +dependencies = [ + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.87", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20d1d011a38f12360e5fcccceeff5e2c42a8eb7f27f0dcba97a0862ede05c9c6" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "static_assertions", + "syn 2.0.87", + "winnow 0.6.20", +] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml new file mode 100644 index 0000000..e7d269e --- /dev/null +++ b/src-tauri/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "lightningbeam" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "lightningbeam_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-shell = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tauri-plugin-fs = "2" +tauri-plugin-dialog = "2" + diff --git a/src-tauri/build.rs b/src-tauri/build.rs new file mode 100644 index 0000000..d860e1e --- /dev/null +++ b/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json new file mode 100644 index 0000000..0b6d6a4 --- /dev/null +++ b/src-tauri/capabilities/default.json @@ -0,0 +1,39 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": [ + "main" + ], + "permissions": [ + "core:default", + "core:window:allow-close", + "shell:allow-open", + "fs:default", + { + "identifier": "fs:allow-exists", + "allow": [ + { + "path": "$DOCUMENT/*" + } + ] + }, + { + "identifier": "fs:allow-app-write-recursive", + "allow": [ + { + "path": "$DOCUMENT/*" + } + ] + }, + { + "identifier": "fs:allow-app-read-recursive", + "allow": [ + { + "path": "$DOCUMENT/*" + } + ] + }, + "dialog:default" + ] +} \ No newline at end of file diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png new file mode 100644 index 0000000..6be5e50 Binary files /dev/null and b/src-tauri/icons/128x128.png differ diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png new file mode 100644 index 0000000..e81bece Binary files /dev/null and b/src-tauri/icons/128x128@2x.png differ diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png new file mode 100644 index 0000000..a437dd5 Binary files /dev/null and b/src-tauri/icons/32x32.png differ diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 0000000..0ca4f27 Binary files /dev/null and b/src-tauri/icons/Square107x107Logo.png differ diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 0000000..b81f820 Binary files /dev/null and b/src-tauri/icons/Square142x142Logo.png differ diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 0000000..624c7bf Binary files /dev/null and b/src-tauri/icons/Square150x150Logo.png differ diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 0000000..c021d2b Binary files /dev/null and b/src-tauri/icons/Square284x284Logo.png differ diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 0000000..6219700 Binary files /dev/null and b/src-tauri/icons/Square30x30Logo.png differ diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 0000000..f9bc048 Binary files /dev/null and b/src-tauri/icons/Square310x310Logo.png differ diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 0000000..d5fbfb2 Binary files /dev/null and b/src-tauri/icons/Square44x44Logo.png differ diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 0000000..63440d7 Binary files /dev/null and b/src-tauri/icons/Square71x71Logo.png differ diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 0000000..f3f705a Binary files /dev/null and b/src-tauri/icons/Square89x89Logo.png differ diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png new file mode 100644 index 0000000..4556388 Binary files /dev/null and b/src-tauri/icons/StoreLogo.png differ diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns new file mode 100644 index 0000000..12a5bce Binary files /dev/null and b/src-tauri/icons/icon.icns differ diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico new file mode 100644 index 0000000..b3636e4 Binary files /dev/null and b/src-tauri/icons/icon.ico differ diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png new file mode 100644 index 0000000..e1cd261 Binary files /dev/null and b/src-tauri/icons/icon.png differ diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs new file mode 100644 index 0000000..60d6479 --- /dev/null +++ b/src-tauri/src/lib.rs @@ -0,0 +1,16 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_dialog::init()) + .plugin(tauri_plugin_fs::init()) + .plugin(tauri_plugin_shell::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs new file mode 100644 index 0000000..dc77732 --- /dev/null +++ b/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + lightningbeam_lib::run() +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json new file mode 100644 index 0000000..0cd2754 --- /dev/null +++ b/src-tauri/tauri.conf.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "lightningbeam", + "version": "0.1.0", + "identifier": "org.lightningbeam.app", + "build": { + "frontendDist": "../src" + }, + + "app": { + "withGlobalTauri": true, + "windows": [ + { + "title": "lightningbeam", + "width": 1500, + "height": 1024 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/src/assets/draw.svg b/src/assets/draw.svg new file mode 100644 index 0000000..e1a096a --- /dev/null +++ b/src/assets/draw.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + + diff --git a/src/assets/ellipse.svg b/src/assets/ellipse.svg new file mode 100644 index 0000000..abb2701 --- /dev/null +++ b/src/assets/ellipse.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + diff --git a/src/assets/infopanel.svg b/src/assets/infopanel.svg new file mode 100644 index 0000000..6df5109 --- /dev/null +++ b/src/assets/infopanel.svg @@ -0,0 +1,108 @@ + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + i + + + diff --git a/src/assets/javascript.svg b/src/assets/javascript.svg new file mode 100644 index 0000000..f9abb2b --- /dev/null +++ b/src/assets/javascript.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/paint_bucket.svg b/src/assets/paint_bucket.svg new file mode 100644 index 0000000..0208168 --- /dev/null +++ b/src/assets/paint_bucket.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + + + diff --git a/src/assets/preferences.svg b/src/assets/preferences.svg new file mode 100644 index 0000000..ef6313c --- /dev/null +++ b/src/assets/preferences.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + + + + diff --git a/src/assets/rectangle.svg b/src/assets/rectangle.svg new file mode 100644 index 0000000..d52258b --- /dev/null +++ b/src/assets/rectangle.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + diff --git a/src/assets/select.svg b/src/assets/select.svg new file mode 100644 index 0000000..de109e2 --- /dev/null +++ b/src/assets/select.svg @@ -0,0 +1,139 @@ + + + + + + + + + image/svg+xml + + + + + Barbara Muraus, Jakub Steiner, Klaus Staedtler + + + Images originally created as the "Art Libre" icon set. Extended and adopted for GIMP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/stage.svg b/src/assets/stage.svg new file mode 100644 index 0000000..04412ea --- /dev/null +++ b/src/assets/stage.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + diff --git a/src/assets/tauri.svg b/src/assets/tauri.svg new file mode 100644 index 0000000..31b62c9 --- /dev/null +++ b/src/assets/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/assets/timeline.svg b/src/assets/timeline.svg new file mode 100644 index 0000000..776dfce --- /dev/null +++ b/src/assets/timeline.svg @@ -0,0 +1,143 @@ + + + + + + + image/svg+xml + + + + + Barbara Muraus, Jakub Steiner, Klaus Staedtler + + + Images originally created as the "Art Libre" icon set. Extended and adopted for GIMP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/toolbar.svg b/src/assets/toolbar.svg new file mode 100644 index 0000000..02db28c --- /dev/null +++ b/src/assets/toolbar.svg @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/transform.svg b/src/assets/transform.svg new file mode 100644 index 0000000..afc157b --- /dev/null +++ b/src/assets/transform.svg @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + + + + + diff --git a/src/bezier.js b/src/bezier.js new file mode 100644 index 0000000..6b12ce6 --- /dev/null +++ b/src/bezier.js @@ -0,0 +1,2003 @@ +import { Vector } from "./vector.js"; + +// math-inlining. +const { abs, cos, sin, acos, atan2, sqrt, pow } = Math; + +// cube root function yielding real roots +function crt(v) { + return v < 0 ? -pow(-v, 1 / 3) : pow(v, 1 / 3); +} + +// trig constants +const pi = Math.PI, + tau = 2 * pi, + quart = pi / 2, + // float precision significant decimal + epsilon = 0.000001, + // extremas used in bbox calculation and similar algorithms + nMax = Number.MAX_SAFE_INTEGER || 9007199254740991, + nMin = Number.MIN_SAFE_INTEGER || -9007199254740991, + // a zero coordinate, which is surprisingly useful + ZERO = { x: 0, y: 0, z: 0 }; + +// Bezier utility functions +const utils = { + // Legendre-Gauss abscissae with n=24 (x_i values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x)) + Tvalues: [ + -0.0640568928626056260850430826247450385909, + 0.0640568928626056260850430826247450385909, + -0.1911188674736163091586398207570696318404, + 0.1911188674736163091586398207570696318404, + -0.3150426796961633743867932913198102407864, + 0.3150426796961633743867932913198102407864, + -0.4337935076260451384870842319133497124524, + 0.4337935076260451384870842319133497124524, + -0.5454214713888395356583756172183723700107, + 0.5454214713888395356583756172183723700107, + -0.6480936519369755692524957869107476266696, + 0.6480936519369755692524957869107476266696, + -0.7401241915785543642438281030999784255232, + 0.7401241915785543642438281030999784255232, + -0.8200019859739029219539498726697452080761, + 0.8200019859739029219539498726697452080761, + -0.8864155270044010342131543419821967550873, + 0.8864155270044010342131543419821967550873, + -0.9382745520027327585236490017087214496548, + 0.9382745520027327585236490017087214496548, + -0.9747285559713094981983919930081690617411, + 0.9747285559713094981983919930081690617411, + -0.9951872199970213601799974097007368118745, + 0.9951872199970213601799974097007368118745, + ], + + // Legendre-Gauss weights with n=24 (w_i values, defined by a function linked to in the Bezier primer article) + Cvalues: [ + 0.1279381953467521569740561652246953718517, + 0.1279381953467521569740561652246953718517, + 0.1258374563468282961213753825111836887264, + 0.1258374563468282961213753825111836887264, + 0.121670472927803391204463153476262425607, + 0.121670472927803391204463153476262425607, + 0.1155056680537256013533444839067835598622, + 0.1155056680537256013533444839067835598622, + 0.1074442701159656347825773424466062227946, + 0.1074442701159656347825773424466062227946, + 0.0976186521041138882698806644642471544279, + 0.0976186521041138882698806644642471544279, + 0.086190161531953275917185202983742667185, + 0.086190161531953275917185202983742667185, + 0.0733464814110803057340336152531165181193, + 0.0733464814110803057340336152531165181193, + 0.0592985849154367807463677585001085845412, + 0.0592985849154367807463677585001085845412, + 0.0442774388174198061686027482113382288593, + 0.0442774388174198061686027482113382288593, + 0.0285313886289336631813078159518782864491, + 0.0285313886289336631813078159518782864491, + 0.0123412297999871995468056670700372915759, + 0.0123412297999871995468056670700372915759, + ], + + arcfn: function (t, derivativeFn) { + const d = derivativeFn(t); + let l = d.x * d.x + d.y * d.y; + if (typeof d.z !== "undefined") { + l += d.z * d.z; + } + return sqrt(l); + }, + + compute: function (t, points, _3d) { + // shortcuts + if (t === 0) { + points[0].t = 0; + return points[0]; + } + + const order = points.length - 1; + + if (t === 1) { + points[order].t = 1; + return points[order]; + } + + const mt = 1 - t; + let p = points; + + // constant? + if (order === 0) { + points[0].t = t; + return points[0]; + } + + // linear? + if (order === 1) { + const ret = { + x: mt * p[0].x + t * p[1].x, + y: mt * p[0].y + t * p[1].y, + t: t, + }; + if (_3d) { + ret.z = mt * p[0].z + t * p[1].z; + } + return ret; + } + + // quadratic/cubic curve? + if (order < 4) { + let mt2 = mt * mt, + t2 = t * t, + a, + b, + c, + d = 0; + if (order === 2) { + p = [p[0], p[1], p[2], ZERO]; + a = mt2; + b = mt * t * 2; + c = t2; + } else if (order === 3) { + a = mt2 * mt; + b = mt2 * t * 3; + c = mt * t2 * 3; + d = t * t2; + } + const ret = { + x: a * p[0].x + b * p[1].x + c * p[2].x + d * p[3].x, + y: a * p[0].y + b * p[1].y + c * p[2].y + d * p[3].y, + t: t, + }; + if (_3d) { + ret.z = a * p[0].z + b * p[1].z + c * p[2].z + d * p[3].z; + } + return ret; + } + + // higher order curves: use de Casteljau's computation + const dCpts = JSON.parse(JSON.stringify(points)); + while (dCpts.length > 1) { + for (let i = 0; i < dCpts.length - 1; i++) { + dCpts[i] = { + x: dCpts[i].x + (dCpts[i + 1].x - dCpts[i].x) * t, + y: dCpts[i].y + (dCpts[i + 1].y - dCpts[i].y) * t, + }; + if (typeof dCpts[i].z !== "undefined") { + dCpts[i] = dCpts[i].z + (dCpts[i + 1].z - dCpts[i].z) * t; + } + } + dCpts.splice(dCpts.length - 1, 1); + } + dCpts[0].t = t; + return dCpts[0]; + }, + + computeWithRatios: function (t, points, ratios, _3d) { + const mt = 1 - t, + r = ratios, + p = points; + + let f1 = r[0], + f2 = r[1], + f3 = r[2], + f4 = r[3], + d; + + // spec for linear + f1 *= mt; + f2 *= t; + + if (p.length === 2) { + d = f1 + f2; + return { + x: (f1 * p[0].x + f2 * p[1].x) / d, + y: (f1 * p[0].y + f2 * p[1].y) / d, + z: !_3d ? false : (f1 * p[0].z + f2 * p[1].z) / d, + t: t, + }; + } + + // upgrade to quadratic + f1 *= mt; + f2 *= 2 * mt; + f3 *= t * t; + + if (p.length === 3) { + d = f1 + f2 + f3; + return { + x: (f1 * p[0].x + f2 * p[1].x + f3 * p[2].x) / d, + y: (f1 * p[0].y + f2 * p[1].y + f3 * p[2].y) / d, + z: !_3d ? false : (f1 * p[0].z + f2 * p[1].z + f3 * p[2].z) / d, + t: t, + }; + } + + // upgrade to cubic + f1 *= mt; + f2 *= 1.5 * mt; + f3 *= 3 * mt; + f4 *= t * t * t; + + if (p.length === 4) { + d = f1 + f2 + f3 + f4; + return { + x: (f1 * p[0].x + f2 * p[1].x + f3 * p[2].x + f4 * p[3].x) / d, + y: (f1 * p[0].y + f2 * p[1].y + f3 * p[2].y + f4 * p[3].y) / d, + z: !_3d + ? false + : (f1 * p[0].z + f2 * p[1].z + f3 * p[2].z + f4 * p[3].z) / d, + t: t, + }; + } + }, + + derive: function (points, _3d) { + const dpoints = []; + for (let p = points, d = p.length, c = d - 1; d > 1; d--, c--) { + const list = []; + for (let j = 0, dpt; j < c; j++) { + dpt = { + x: c * (p[j + 1].x - p[j].x), + y: c * (p[j + 1].y - p[j].y), + }; + if (_3d) { + dpt.z = c * (p[j + 1].z - p[j].z); + } + list.push(dpt); + } + dpoints.push(list); + p = list; + } + return dpoints; + }, + + between: function (v, m, M) { + return ( + (m <= v && v <= M) || + utils.approximately(v, m) || + utils.approximately(v, M) + ); + }, + + approximately: function (a, b, precision) { + return abs(a - b) <= (precision || epsilon); + }, + + length: function (derivativeFn) { + const z = 0.5, + len = utils.Tvalues.length; + + let sum = 0; + + for (let i = 0, t; i < len; i++) { + t = z * utils.Tvalues[i] + z; + sum += utils.Cvalues[i] * utils.arcfn(t, derivativeFn); + } + return z * sum; + }, + + map: function (v, ds, de, ts, te) { + const d1 = de - ds, + d2 = te - ts, + v2 = v - ds, + r = v2 / d1; + return ts + d2 * r; + }, + + lerp: function (r, v1, v2) { + const ret = { + x: v1.x + r * (v2.x - v1.x), + y: v1.y + r * (v2.y - v1.y), + }; + if (v1.z !== undefined && v2.z !== undefined) { + ret.z = v1.z + r * (v2.z - v1.z); + } + return ret; + }, + + pointToString: function (p) { + let s = p.x + "/" + p.y; + if (typeof p.z !== "undefined") { + s += "/" + p.z; + } + return s; + }, + + pointsToString: function (points) { + return "[" + points.map(utils.pointToString).join(", ") + "]"; + }, + + copy: function (obj) { + return JSON.parse(JSON.stringify(obj)); + }, + + angle: function (o, v1, v2) { + const dx1 = v1.x - o.x, + dy1 = v1.y - o.y, + dx2 = v2.x - o.x, + dy2 = v2.y - o.y, + cross = dx1 * dy2 - dy1 * dx2, + dot = dx1 * dx2 + dy1 * dy2; + return atan2(cross, dot); + }, + + // round as string, to avoid rounding errors + round: function (v, d) { + const s = "" + v; + const pos = s.indexOf("."); + return parseFloat(s.substring(0, pos + 1 + d)); + }, + + dist: function (p1, p2) { + const dx = p1.x - p2.x, + dy = p1.y - p2.y; + return sqrt(dx * dx + dy * dy); + }, + + closest: function (LUT, point) { + let mdist = pow(2, 63), + mpos, + d; + LUT.forEach(function (p, idx) { + d = utils.dist(point, p); + if (d < mdist) { + mdist = d; + mpos = idx; + } + }); + return { mdist: mdist, mpos: mpos }; + }, + + abcratio: function (t, n) { + // see ratio(t) note on http://pomax.github.io/bezierinfo/#abc + if (n !== 2 && n !== 3) { + return false; + } + if (typeof t === "undefined") { + t = 0.5; + } else if (t === 0 || t === 1) { + return t; + } + const bottom = pow(t, n) + pow(1 - t, n), + top = bottom - 1; + return abs(top / bottom); + }, + + projectionratio: function (t, n) { + // see u(t) note on http://pomax.github.io/bezierinfo/#abc + if (n !== 2 && n !== 3) { + return false; + } + if (typeof t === "undefined") { + t = 0.5; + } else if (t === 0 || t === 1) { + return t; + } + const top = pow(1 - t, n), + bottom = pow(t, n) + top; + return top / bottom; + }, + + lli8: function (x1, y1, x2, y2, x3, y3, x4, y4) { + const nx = + (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4), + ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4), + d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); + if (d == 0) { + return false; + } + return { x: nx / d, y: ny / d }; + }, + + lli4: function (p1, p2, p3, p4) { + const x1 = p1.x, + y1 = p1.y, + x2 = p2.x, + y2 = p2.y, + x3 = p3.x, + y3 = p3.y, + x4 = p4.x, + y4 = p4.y; + return utils.lli8(x1, y1, x2, y2, x3, y3, x4, y4); + }, + + lli: function (v1, v2) { + return utils.lli4(v1, v1.c, v2, v2.c); + }, + + makeline: function (p1, p2) { + return new Bezier( + p1.x, + p1.y, + (p1.x + p2.x) / 2, + (p1.y + p2.y) / 2, + p2.x, + p2.y + ); + }, + + findbbox: function (sections) { + let mx = nMax, + my = nMax, + MX = nMin, + MY = nMin; + sections.forEach(function (s) { + const bbox = s.bbox(); + if (mx > bbox.x.min) mx = bbox.x.min; + if (my > bbox.y.min) my = bbox.y.min; + if (MX < bbox.x.max) MX = bbox.x.max; + if (MY < bbox.y.max) MY = bbox.y.max; + }); + return { + x: { min: mx, mid: (mx + MX) / 2, max: MX, size: MX - mx }, + y: { min: my, mid: (my + MY) / 2, max: MY, size: MY - my }, + }; + }, + + shapeintersections: function ( + s1, + bbox1, + s2, + bbox2, + curveIntersectionThreshold + ) { + if (!utils.bboxoverlap(bbox1, bbox2)) return []; + const intersections = []; + const a1 = [s1.startcap, s1.forward, s1.back, s1.endcap]; + const a2 = [s2.startcap, s2.forward, s2.back, s2.endcap]; + a1.forEach(function (l1) { + if (l1.virtual) return; + a2.forEach(function (l2) { + if (l2.virtual) return; + const iss = l1.intersects(l2, curveIntersectionThreshold); + if (iss.length > 0) { + iss.c1 = l1; + iss.c2 = l2; + iss.s1 = s1; + iss.s2 = s2; + intersections.push(iss); + } + }); + }); + return intersections; + }, + + makeshape: function (forward, back, curveIntersectionThreshold) { + const bpl = back.points.length; + const fpl = forward.points.length; + const start = utils.makeline(back.points[bpl - 1], forward.points[0]); + const end = utils.makeline(forward.points[fpl - 1], back.points[0]); + const shape = { + startcap: start, + forward: forward, + back: back, + endcap: end, + bbox: utils.findbbox([start, forward, back, end]), + }; + shape.intersections = function (s2) { + return utils.shapeintersections( + shape, + shape.bbox, + s2, + s2.bbox, + curveIntersectionThreshold + ); + }; + return shape; + }, + + getminmax: function (curve, d, list) { + if (!list) return { min: 0, max: 0 }; + let min = nMax, + max = nMin, + t, + c; + if (list.indexOf(0) === -1) { + list = [0].concat(list); + } + if (list.indexOf(1) === -1) { + list.push(1); + } + for (let i = 0, len = list.length; i < len; i++) { + t = list[i]; + c = curve.get(t); + if (c[d] < min) { + min = c[d]; + } + if (c[d] > max) { + max = c[d]; + } + } + return { min: min, mid: (min + max) / 2, max: max, size: max - min }; + }, + + align: function (points, line) { + const tx = line.p1.x, + ty = line.p1.y, + a = -atan2(line.p2.y - ty, line.p2.x - tx), + d = function (v) { + return { + x: (v.x - tx) * cos(a) - (v.y - ty) * sin(a), + y: (v.x - tx) * sin(a) + (v.y - ty) * cos(a), + }; + }; + return points.map(d); + }, + + roots: function (points, line) { + line = line || { p1: { x: 0, y: 0 }, p2: { x: 1, y: 0 } }; + + const order = points.length - 1; + const aligned = utils.align(points, line); + const reduce = function (t) { + return 0 <= t && t <= 1; + }; + + if (order === 2) { + const a = aligned[0].y, + b = aligned[1].y, + c = aligned[2].y, + d = a - 2 * b + c; + if (d !== 0) { + const m1 = -sqrt(b * b - a * c), + m2 = -a + b, + v1 = -(m1 + m2) / d, + v2 = -(-m1 + m2) / d; + return [v1, v2].filter(reduce); + } else if (b !== c && d === 0) { + return [(2 * b - c) / (2 * b - 2 * c)].filter(reduce); + } + return []; + } + + // see http://www.trans4mind.com/personal_development/mathematics/polynomials/cubicAlgebra.htm + const pa = aligned[0].y, + pb = aligned[1].y, + pc = aligned[2].y, + pd = aligned[3].y; + + let d = -pa + 3 * pb - 3 * pc + pd, + a = 3 * pa - 6 * pb + 3 * pc, + b = -3 * pa + 3 * pb, + c = pa; + + if (utils.approximately(d, 0)) { + // this is not a cubic curve. + if (utils.approximately(a, 0)) { + // in fact, this is not a quadratic curve either. + if (utils.approximately(b, 0)) { + // in fact in fact, there are no solutions. + return []; + } + // linear solution: + return [-c / b].filter(reduce); + } + // quadratic solution: + const q = sqrt(b * b - 4 * a * c), + a2 = 2 * a; + return [(q - b) / a2, (-b - q) / a2].filter(reduce); + } + + // at this point, we know we need a cubic solution: + + a /= d; + b /= d; + c /= d; + + const p = (3 * b - a * a) / 3, + p3 = p / 3, + q = (2 * a * a * a - 9 * a * b + 27 * c) / 27, + q2 = q / 2, + discriminant = q2 * q2 + p3 * p3 * p3; + + let u1, v1, x1, x2, x3; + if (discriminant < 0) { + const mp3 = -p / 3, + mp33 = mp3 * mp3 * mp3, + r = sqrt(mp33), + t = -q / (2 * r), + cosphi = t < -1 ? -1 : t > 1 ? 1 : t, + phi = acos(cosphi), + crtr = crt(r), + t1 = 2 * crtr; + x1 = t1 * cos(phi / 3) - a / 3; + x2 = t1 * cos((phi + tau) / 3) - a / 3; + x3 = t1 * cos((phi + 2 * tau) / 3) - a / 3; + return [x1, x2, x3].filter(reduce); + } else if (discriminant === 0) { + u1 = q2 < 0 ? crt(-q2) : -crt(q2); + x1 = 2 * u1 - a / 3; + x2 = -u1 - a / 3; + return [x1, x2].filter(reduce); + } else { + const sd = sqrt(discriminant); + u1 = crt(-q2 + sd); + v1 = crt(q2 + sd); + return [u1 - v1 - a / 3].filter(reduce); + } + }, + + droots: function (p) { + // quadratic roots are easy + if (p.length === 3) { + const a = p[0], + b = p[1], + c = p[2], + d = a - 2 * b + c; + if (d !== 0) { + const m1 = -sqrt(b * b - a * c), + m2 = -a + b, + v1 = -(m1 + m2) / d, + v2 = -(-m1 + m2) / d; + return [v1, v2]; + } else if (b !== c && d === 0) { + return [(2 * b - c) / (2 * (b - c))]; + } + return []; + } + + // linear roots are even easier + if (p.length === 2) { + const a = p[0], + b = p[1]; + if (a !== b) { + return [a / (a - b)]; + } + return []; + } + + return []; + }, + + curvature: function (t, d1, d2, _3d, kOnly) { + let num, + dnm, + adk, + dk, + k = 0, + r = 0; + + // + // We're using the following formula for curvature: + // + // x'y" - y'x" + // k(t) = ------------------ + // (x'² + y'²)^(3/2) + // + // from https://en.wikipedia.org/wiki/Radius_of_curvature#Definition + // + // With it corresponding 3D counterpart: + // + // sqrt( (y'z" - y"z')² + (z'x" - z"x')² + (x'y" - x"y')²) + // k(t) = ------------------------------------------------------- + // (x'² + y'² + z'²)^(3/2) + // + + const d = utils.compute(t, d1); + const dd = utils.compute(t, d2); + const qdsum = d.x * d.x + d.y * d.y; + + if (_3d) { + num = sqrt( + pow(d.y * dd.z - dd.y * d.z, 2) + + pow(d.z * dd.x - dd.z * d.x, 2) + + pow(d.x * dd.y - dd.x * d.y, 2) + ); + dnm = pow(qdsum + d.z * d.z, 3 / 2); + } else { + num = d.x * dd.y - d.y * dd.x; + dnm = pow(qdsum, 3 / 2); + } + + if (num === 0 || dnm === 0) { + return { k: 0, r: 0 }; + } + + k = num / dnm; + r = dnm / num; + + // We're also computing the derivative of kappa, because + // there is value in knowing the rate of change for the + // curvature along the curve. And we're just going to + // ballpark it based on an epsilon. + if (!kOnly) { + // compute k'(t) based on the interval before, and after it, + // to at least try to not introduce forward/backward pass bias. + const pk = utils.curvature(t - 0.001, d1, d2, _3d, true).k; + const nk = utils.curvature(t + 0.001, d1, d2, _3d, true).k; + dk = (nk - k + (k - pk)) / 2; + adk = (abs(nk - k) + abs(k - pk)) / 2; + } + + return { k: k, r: r, dk: dk, adk: adk }; + }, + + inflections: function (points) { + if (points.length < 4) return []; + + // FIXME: TODO: add in inflection abstraction for quartic+ curves? + + const p = utils.align(points, { p1: points[0], p2: points.slice(-1)[0] }), + a = p[2].x * p[1].y, + b = p[3].x * p[1].y, + c = p[1].x * p[2].y, + d = p[3].x * p[2].y, + v1 = 18 * (-3 * a + 2 * b + 3 * c - d), + v2 = 18 * (3 * a - b - 3 * c), + v3 = 18 * (c - a); + + if (utils.approximately(v1, 0)) { + if (!utils.approximately(v2, 0)) { + let t = -v3 / v2; + if (0 <= t && t <= 1) return [t]; + } + return []; + } + + const trm = v2 * v2 - 4 * v1 * v3, + sq = Math.sqrt(trm), + d2 = 2 * v1; + + if (utils.approximately(d2, 0)) return []; + + return [(sq - v2) / d2, -(v2 + sq) / d2].filter(function (r) { + return 0 <= r && r <= 1; + }); + }, + + bboxoverlap: function (b1, b2) { + const dims = ["x", "y"], + len = dims.length; + + for (let i = 0, dim, l, t, d; i < len; i++) { + dim = dims[i]; + l = b1[dim].mid; + t = b2[dim].mid; + d = (b1[dim].size + b2[dim].size) / 2; + if (abs(l - t) >= d) return false; + } + return true; + }, + + expandbox: function (bbox, _bbox) { + if (_bbox.x.min < bbox.x.min) { + bbox.x.min = _bbox.x.min; + } + if (_bbox.y.min < bbox.y.min) { + bbox.y.min = _bbox.y.min; + } + if (_bbox.z && _bbox.z.min < bbox.z.min) { + bbox.z.min = _bbox.z.min; + } + if (_bbox.x.max > bbox.x.max) { + bbox.x.max = _bbox.x.max; + } + if (_bbox.y.max > bbox.y.max) { + bbox.y.max = _bbox.y.max; + } + if (_bbox.z && _bbox.z.max > bbox.z.max) { + bbox.z.max = _bbox.z.max; + } + bbox.x.mid = (bbox.x.min + bbox.x.max) / 2; + bbox.y.mid = (bbox.y.min + bbox.y.max) / 2; + if (bbox.z) { + bbox.z.mid = (bbox.z.min + bbox.z.max) / 2; + } + bbox.x.size = bbox.x.max - bbox.x.min; + bbox.y.size = bbox.y.max - bbox.y.min; + if (bbox.z) { + bbox.z.size = bbox.z.max - bbox.z.min; + } + }, + + pairiteration: function (c1, c2, curveIntersectionThreshold) { + const c1b = c1.bbox(), + c2b = c2.bbox(), + r = 100000, + threshold = curveIntersectionThreshold || 0.5; + + if ( + c1b.x.size + c1b.y.size < threshold && + c2b.x.size + c2b.y.size < threshold + ) { + return [ + (((r * (c1._t1 + c1._t2)) / 2) | 0) / r + + "/" + + (((r * (c2._t1 + c2._t2)) / 2) | 0) / r, + ]; + } + + let cc1 = c1.split(0.5), + cc2 = c2.split(0.5), + pairs = [ + { left: cc1.left, right: cc2.left }, + { left: cc1.left, right: cc2.right }, + { left: cc1.right, right: cc2.right }, + { left: cc1.right, right: cc2.left }, + ]; + + pairs = pairs.filter(function (pair) { + return utils.bboxoverlap(pair.left.bbox(), pair.right.bbox()); + }); + + let results = []; + + if (pairs.length === 0) return results; + + pairs.forEach(function (pair) { + results = results.concat( + utils.pairiteration(pair.left, pair.right, threshold) + ); + }); + + results = results.filter(function (v, i) { + return results.indexOf(v) === i; + }); + + return results; + }, + + getccenter: function (p1, p2, p3) { + const dx1 = p2.x - p1.x, + dy1 = p2.y - p1.y, + dx2 = p3.x - p2.x, + dy2 = p3.y - p2.y, + dx1p = dx1 * cos(quart) - dy1 * sin(quart), + dy1p = dx1 * sin(quart) + dy1 * cos(quart), + dx2p = dx2 * cos(quart) - dy2 * sin(quart), + dy2p = dx2 * sin(quart) + dy2 * cos(quart), + // chord midpoints + mx1 = (p1.x + p2.x) / 2, + my1 = (p1.y + p2.y) / 2, + mx2 = (p2.x + p3.x) / 2, + my2 = (p2.y + p3.y) / 2, + // midpoint offsets + mx1n = mx1 + dx1p, + my1n = my1 + dy1p, + mx2n = mx2 + dx2p, + my2n = my2 + dy2p, + // intersection of these lines: + arc = utils.lli8(mx1, my1, mx1n, my1n, mx2, my2, mx2n, my2n), + r = utils.dist(arc, p1); + + // arc start/end values, over mid point: + let s = atan2(p1.y - arc.y, p1.x - arc.x), + m = atan2(p2.y - arc.y, p2.x - arc.x), + e = atan2(p3.y - arc.y, p3.x - arc.x), + _; + + // determine arc direction (cw/ccw correction) + if (s < e) { + // if s m || m > e) { + s += tau; + } + if (s > e) { + _ = e; + e = s; + s = _; + } + } else { + // if e 4) { + if (arguments.length !== 1) { + throw new Error( + "Only new Bezier(point[]) is accepted for 4th and higher order curves" + ); + } + higher = true; + } + } else { + if (len !== 6 && len !== 8 && len !== 9 && len !== 12) { + if (arguments.length !== 1) { + throw new Error( + "Only new Bezier(point[]) is accepted for 4th and higher order curves" + ); + } + } + } + + const _3d = (this._3d = + (!higher && (len === 9 || len === 12)) || + (coords && coords[0] && typeof coords[0].z !== "undefined")); + + const points = (this.points = []); + for (let idx = 0, step = _3d ? 3 : 2; idx < len; idx += step) { + var point = { + x: args[idx], + y: args[idx + 1], + }; + if (_3d) { + point.z = args[idx + 2]; + } + points.push(point); + } + const order = (this.order = points.length - 1); + + const dims = (this.dims = ["x", "y"]); + if (_3d) dims.push("z"); + this.dimlen = dims.length; + + // is this curve, practically speaking, a straight line? + const aligned = utils.align(points, { p1: points[0], p2: points[order] }); + const baselength = utils.dist(points[0], points[order]); + this._linear = aligned.reduce((t, p) => t + abs$1(p.y), 0) < baselength / 50; + + this._lut = []; + + this._t1 = 0; + this._t2 = 1; + this.update(); + } + + static quadraticFromPoints(p1, p2, p3, t) { + if (typeof t === "undefined") { + t = 0.5; + } + // shortcuts, although they're really dumb + if (t === 0) { + return new Bezier(p2, p2, p3); + } + if (t === 1) { + return new Bezier(p1, p2, p2); + } + // real fitting. + const abc = Bezier.getABC(2, p1, p2, p3, t); + return new Bezier(p1, abc.A, p3); + } + + static cubicFromPoints(S, B, E, t, d1) { + if (typeof t === "undefined") { + t = 0.5; + } + const abc = Bezier.getABC(3, S, B, E, t); + if (typeof d1 === "undefined") { + d1 = utils.dist(B, abc.C); + } + const d2 = (d1 * (1 - t)) / t; + + const selen = utils.dist(S, E), + lx = (E.x - S.x) / selen, + ly = (E.y - S.y) / selen, + bx1 = d1 * lx, + by1 = d1 * ly, + bx2 = d2 * lx, + by2 = d2 * ly; + // derivation of new hull coordinates + const e1 = { x: B.x - bx1, y: B.y - by1 }, + e2 = { x: B.x + bx2, y: B.y + by2 }, + A = abc.A, + v1 = { x: A.x + (e1.x - A.x) / (1 - t), y: A.y + (e1.y - A.y) / (1 - t) }, + v2 = { x: A.x + (e2.x - A.x) / t, y: A.y + (e2.y - A.y) / t }, + nc1 = { x: S.x + (v1.x - S.x) / t, y: S.y + (v1.y - S.y) / t }, + nc2 = { + x: E.x + (v2.x - E.x) / (1 - t), + y: E.y + (v2.y - E.y) / (1 - t), + }; + // ...done + return new Bezier(S, nc1, nc2, E); + } + + static getUtils() { + return utils; + } + + getUtils() { + return Bezier.getUtils(); + } + + static get PolyBezier() { + return PolyBezier; + } + + valueOf() { + return this.toString(); + } + + toString() { + return utils.pointsToString(this.points); + } + + toSVG() { + if (this._3d) return false; + const p = this.points, + x = p[0].x, + y = p[0].y, + s = ["M", x, y, this.order === 2 ? "Q" : "C"]; + for (let i = 1, last = p.length; i < last; i++) { + s.push(p[i].x); + s.push(p[i].y); + } + return s.join(" "); + } + + setRatios(ratios) { + if (ratios.length !== this.points.length) { + throw new Error("incorrect number of ratio values"); + } + this.ratios = ratios; + this._lut = []; // invalidate any precomputed LUT + } + + setColor(color) { + this.color = color + return this + } + + verify() { + const print = this.coordDigest(); + if (print !== this._print) { + this._print = print; + this.update(); + } + } + + coordDigest() { + return this.points + .map(function (c, pos) { + return "" + pos + c.x + c.y + (c.z ? c.z : 0); + }) + .join(""); + } + + update() { + // invalidate any precomputed LUT + this._lut = []; + this.dpoints = utils.derive(this.points, this._3d); + this.computedirection(); + } + + computedirection() { + const points = this.points; + const angle = utils.angle(points[0], points[this.order], points[1]); + this.clockwise = angle > 0; + } + + length() { + return utils.length(this.derivative.bind(this)); + } + + static getABC(order = 2, S, B, E, t = 0.5) { + const u = utils.projectionratio(t, order), + um = 1 - u, + C = { + x: u * S.x + um * E.x, + y: u * S.y + um * E.y, + }, + s = utils.abcratio(t, order), + A = { + x: B.x + (B.x - C.x) / s, + y: B.y + (B.y - C.y) / s, + }; + return { A, B, C, S, E }; + } + + getABC(t, B) { + B = B || this.get(t); + let S = this.points[0]; + let E = this.points[this.order]; + return Bezier.getABC(this.order, S, B, E, t); + } + + getLUT(steps) { + this.verify(); + steps = steps || 100; + if (this._lut.length === steps) { + return this._lut; + } + this._lut = []; + // n steps means n+1 points + steps++; + this._lut = []; + for (let i = 0, p, t; i < steps; i++) { + t = i / (steps - 1); + p = this.compute(t); + p.t = t; + this._lut.push(p); + } + return this._lut; + } + + on(point, error) { + error = error || 5; + const lut = this.getLUT(), + hits = []; + for (let i = 0, c, t = 0; i < lut.length; i++) { + c = lut[i]; + if (utils.dist(c, point) < error) { + hits.push(c); + t += i / lut.length; + } + } + if (!hits.length) return false; + return (t /= hits.length); + } + + project(point) { + // step 1: coarse check + const LUT = this.getLUT(), + l = LUT.length - 1, + closest = utils.closest(LUT, point), + mpos = closest.mpos, + t1 = (mpos - 1) / l, + t2 = (mpos + 1) / l, + step = 0.1 / l; + + // step 2: fine check + let mdist = closest.mdist, + t = t1, + ft = t, + p; + mdist += 1; + for (let d; t < t2 + step; t += step) { + p = this.compute(t); + d = utils.dist(point, p); + if (d < mdist) { + mdist = d; + ft = t; + } + } + ft = ft < 0 ? 0 : ft > 1 ? 1 : ft; + p = this.compute(ft); + p.t = ft; + p.d = mdist; + return p; + } + + get(t) { + return this.compute(t); + } + + point(idx) { + return this.points[idx]; + } + + compute(t) { + if (this.ratios) { + return utils.computeWithRatios(t, this.points, this.ratios, this._3d); + } + return utils.compute(t, this.points, this._3d, this.ratios); + } + + raise() { + const p = this.points, + np = [p[0]], + k = p.length; + for (let i = 1, pi, pim; i < k; i++) { + pi = p[i]; + pim = p[i - 1]; + np[i] = { + x: ((k - i) / k) * pi.x + (i / k) * pim.x, + y: ((k - i) / k) * pi.y + (i / k) * pim.y, + }; + } + np[k] = p[k - 1]; + return new Bezier(np); + } + + derivative(t) { + return utils.compute(t, this.dpoints[0], this._3d); + } + + dderivative(t) { + return utils.compute(t, this.dpoints[1], this._3d); + } + + align() { + let p = this.points; + return new Bezier(utils.align(p, { p1: p[0], p2: p[p.length - 1] })); + } + + curvature(t) { + return utils.curvature(t, this.dpoints[0], this.dpoints[1], this._3d); + } + + inflections() { + return utils.inflections(this.points); + } + + normal(t) { + return this._3d ? this.__normal3(t) : this.__normal2(t); + } + + __normal2(t) { + const d = this.derivative(t); + const q = sqrt$1(d.x * d.x + d.y * d.y); + return { x: -d.y / q, y: d.x / q }; + } + + __normal3(t) { + // see http://stackoverflow.com/questions/25453159 + const r1 = this.derivative(t), + r2 = this.derivative(t + 0.01), + q1 = sqrt$1(r1.x * r1.x + r1.y * r1.y + r1.z * r1.z), + q2 = sqrt$1(r2.x * r2.x + r2.y * r2.y + r2.z * r2.z); + r1.x /= q1; + r1.y /= q1; + r1.z /= q1; + r2.x /= q2; + r2.y /= q2; + r2.z /= q2; + // cross product + const c = { + x: r2.y * r1.z - r2.z * r1.y, + y: r2.z * r1.x - r2.x * r1.z, + z: r2.x * r1.y - r2.y * r1.x, + }; + const m = sqrt$1(c.x * c.x + c.y * c.y + c.z * c.z); + c.x /= m; + c.y /= m; + c.z /= m; + // rotation matrix + const R = [ + c.x * c.x, + c.x * c.y - c.z, + c.x * c.z + c.y, + c.x * c.y + c.z, + c.y * c.y, + c.y * c.z - c.x, + c.x * c.z - c.y, + c.y * c.z + c.x, + c.z * c.z, + ]; + // normal vector: + const n = { + x: R[0] * r1.x + R[1] * r1.y + R[2] * r1.z, + y: R[3] * r1.x + R[4] * r1.y + R[5] * r1.z, + z: R[6] * r1.x + R[7] * r1.y + R[8] * r1.z, + }; + return n; + } + + hull(t) { + let p = this.points, + _p = [], + q = [], + idx = 0; + q[idx++] = p[0]; + q[idx++] = p[1]; + q[idx++] = p[2]; + if (this.order === 3) { + q[idx++] = p[3]; + } + // we lerp between all points at each iteration, until we have 1 point left. + while (p.length > 1) { + _p = []; + for (let i = 0, pt, l = p.length - 1; i < l; i++) { + pt = utils.lerp(t, p[i], p[i + 1]); + q[idx++] = pt; + _p.push(pt); + } + p = _p; + } + return q; + } + + split(t1, t2) { + // shortcuts + if (t1 === 0 && !!t2) { + return this.split(t2).left; + } + if (t2 === 1) { + return this.split(t1).right; + } + + // no shortcut: use "de Casteljau" iteration. + const q = this.hull(t1); + const result = { + left: + this.order === 2 + ? new Bezier([q[0], q[3], q[5]]) + : new Bezier([q[0], q[4], q[7], q[9]]), + right: + this.order === 2 + ? new Bezier([q[5], q[4], q[2]]) + : new Bezier([q[9], q[8], q[6], q[3]]), + span: q, + }; + + // make sure we bind _t1/_t2 information! + result.left._t1 = utils.map(0, 0, 1, this._t1, this._t2); + result.left._t2 = utils.map(t1, 0, 1, this._t1, this._t2); + result.right._t1 = utils.map(t1, 0, 1, this._t1, this._t2); + result.right._t2 = utils.map(1, 0, 1, this._t1, this._t2); + + // if we have no t2, we're done + if (!t2) { + return result; + } + + // if we have a t2, split again: + t2 = utils.map(t2, t1, 1, 0, 1); + return result.right.split(t2).left; + } + + extrema() { + const result = {}; + let roots = []; + + this.dims.forEach( + function (dim) { + let mfn = function (v) { + return v[dim]; + }; + let p = this.dpoints[0].map(mfn); + result[dim] = utils.droots(p); + if (this.order === 3) { + p = this.dpoints[1].map(mfn); + result[dim] = result[dim].concat(utils.droots(p)); + } + result[dim] = result[dim].filter(function (t) { + return t >= 0 && t <= 1; + }); + roots = roots.concat(result[dim].sort(utils.numberSort)); + }.bind(this) + ); + + result.values = roots.sort(utils.numberSort).filter(function (v, idx) { + return roots.indexOf(v) === idx; + }); + + return result; + } + + bbox() { + const extrema = this.extrema(), + result = {}; + this.dims.forEach( + function (d) { + result[d] = utils.getminmax(this, d, extrema[d]); + }.bind(this) + ); + return result; + } + + overlaps(curve) { + const lbbox = this.bbox(), + tbbox = curve.bbox(); + return utils.bboxoverlap(lbbox, tbbox); + } + + offset(t, d) { + if (typeof d !== "undefined") { + const c = this.get(t), + n = this.normal(t); + const ret = { + c: c, + n: n, + x: c.x + n.x * d, + y: c.y + n.y * d, + }; + if (this._3d) { + ret.z = c.z + n.z * d; + } + return ret; + } + if (this._linear) { + const nv = this.normal(0), + coords = this.points.map(function (p) { + const ret = { + x: p.x + t * nv.x, + y: p.y + t * nv.y, + }; + if (p.z && nv.z) { + ret.z = p.z + t * nv.z; + } + return ret; + }); + return [new Bezier(coords)]; + } + return this.reduce().map(function (s) { + if (s._linear) { + return s.offset(t)[0]; + } + return s.scale(t); + }); + } + + simple() { + if (this.order === 3) { + const a1 = utils.angle(this.points[0], this.points[3], this.points[1]); + const a2 = utils.angle(this.points[0], this.points[3], this.points[2]); + if ((a1 > 0 && a2 < 0) || (a1 < 0 && a2 > 0)) return false; + } + const n1 = this.normal(0); + const n2 = this.normal(1); + let s = n1.x * n2.x + n1.y * n2.y; + if (this._3d) { + s += n1.z * n2.z; + } + return abs$1(acos$1(s)) < pi$1 / 3; + } + + reduce() { + // TODO: examine these var types in more detail... + let i, + t1 = 0, + t2 = 0, + step = 0.01, + segment, + pass1 = [], + pass2 = []; + // first pass: split on extrema + let extrema = this.extrema().values; + if (extrema.indexOf(0) === -1) { + extrema = [0].concat(extrema); + } + if (extrema.indexOf(1) === -1) { + extrema.push(1); + } + + for (t1 = extrema[0], i = 1; i < extrema.length; i++) { + t2 = extrema[i]; + segment = this.split(t1, t2); + segment._t1 = t1; + segment._t2 = t2; + pass1.push(segment); + t1 = t2; + } + + // second pass: further reduce these segments to simple segments + pass1.forEach(function (p1) { + t1 = 0; + t2 = 0; + while (t2 <= 1) { + for (t2 = t1 + step; t2 <= 1 + step; t2 += step) { + segment = p1.split(t1, t2); + if (!segment.simple()) { + t2 -= step; + if (abs$1(t1 - t2) < step) { + // we can never form a reduction + return []; + } + segment = p1.split(t1, t2); + segment._t1 = utils.map(t1, 0, 1, p1._t1, p1._t2); + segment._t2 = utils.map(t2, 0, 1, p1._t1, p1._t2); + pass2.push(segment); + t1 = t2; + break; + } + } + } + if (t1 < 1) { + segment = p1.split(t1, 1); + segment._t1 = utils.map(t1, 0, 1, p1._t1, p1._t2); + segment._t2 = p1._t2; + pass2.push(segment); + } + }); + return pass2; + } + + translate(v, d1, d2) { + d2 = typeof d2 === "number" ? d2 : d1; + + // TODO: make this take curves with control points outside + // of the start-end interval into account + + const o = this.order; + let d = this.points.map((_, i) => (1 - i / o) * d1 + (i / o) * d2); + return new Bezier( + this.points.map((p, i) => ({ + x: p.x + v.x * d[i], + y: p.y + v.y * d[i], + })) + ); + } + + scale(d) { + const order = this.order; + let distanceFn = false; + if (typeof d === "function") { + distanceFn = d; + } + if (distanceFn && order === 2) { + return this.raise().scale(distanceFn); + } + + // TODO: add special handling for non-linear degenerate curves. + + const clockwise = this.clockwise; + const points = this.points; + + if (this._linear) { + return this.translate( + this.normal(0), + distanceFn ? distanceFn(0) : d, + distanceFn ? distanceFn(1) : d + ); + } + + const r1 = distanceFn ? distanceFn(0) : d; + const r2 = distanceFn ? distanceFn(1) : d; + const v = [this.offset(0, 10), this.offset(1, 10)]; + const np = []; + const o = utils.lli4(v[0], v[0].c, v[1], v[1].c); + + if (!o) { + throw new Error("cannot scale this curve. Try reducing it first."); + } + + // move all points by distance 'd' wrt the origin 'o', + // and move end points by fixed distance along normal. + [0, 1].forEach(function (t) { + const p = (np[t * order] = utils.copy(points[t * order])); + p.x += (t ? r2 : r1) * v[t].n.x; + p.y += (t ? r2 : r1) * v[t].n.y; + }); + + if (!distanceFn) { + // move control points to lie on the intersection of the offset + // derivative vector, and the origin-through-control vector + [0, 1].forEach((t) => { + if (order === 2 && !!t) return; + const p = np[t * order]; + const d = this.derivative(t); + const p2 = { x: p.x + d.x, y: p.y + d.y }; + np[t + 1] = utils.lli4(p, p2, o, points[t + 1]); + }); + return new Bezier(np); + } + + // move control points by "however much necessary to + // ensure the correct tangent to endpoint". + [0, 1].forEach(function (t) { + if (order === 2 && !!t) return; + var p = points[t + 1]; + var ov = { + x: p.x - o.x, + y: p.y - o.y, + }; + var rc = distanceFn ? distanceFn((t + 1) / order) : d; + if (distanceFn && !clockwise) rc = -rc; + var m = sqrt$1(ov.x * ov.x + ov.y * ov.y); + ov.x /= m; + ov.y /= m; + np[t + 1] = { + x: p.x + rc * ov.x, + y: p.y + rc * ov.y, + }; + }); + return new Bezier(np); + } + + outline(d1, d2, d3, d4) { + d2 = d2 === undefined ? d1 : d2; + + if (this._linear) { + // TODO: find the actual extrema, because they might + // be before the start, or past the end. + + const n = this.normal(0); + const start = this.points[0]; + const end = this.points[this.points.length - 1]; + let s, mid, e; + + if (d3 === undefined) { + d3 = d1; + d4 = d2; + } + + s = { x: start.x + n.x * d1, y: start.y + n.y * d1 }; + e = { x: end.x + n.x * d3, y: end.y + n.y * d3 }; + mid = { x: (s.x + e.x) / 2, y: (s.y + e.y) / 2 }; + const fline = [s, mid, e]; + + s = { x: start.x - n.x * d2, y: start.y - n.y * d2 }; + e = { x: end.x - n.x * d4, y: end.y - n.y * d4 }; + mid = { x: (s.x + e.x) / 2, y: (s.y + e.y) / 2 }; + const bline = [e, mid, s]; + + const ls = utils.makeline(bline[2], fline[0]); + const le = utils.makeline(fline[2], bline[0]); + const segments = [ls, new Bezier(fline), le, new Bezier(bline)]; + return new PolyBezier(segments); + } + + const reduced = this.reduce(), + len = reduced.length, + fcurves = []; + + let bcurves = [], + p, + alen = 0, + tlen = this.length(); + + const graduated = typeof d3 !== "undefined" && typeof d4 !== "undefined"; + + function linearDistanceFunction(s, e, tlen, alen, slen) { + return function (v) { + const f1 = alen / tlen, + f2 = (alen + slen) / tlen, + d = e - s; + return utils.map(v, 0, 1, s + f1 * d, s + f2 * d); + }; + } + + // form curve oulines + reduced.forEach(function (segment) { + const slen = segment.length(); + if (graduated) { + fcurves.push( + segment.scale(linearDistanceFunction(d1, d3, tlen, alen, slen)) + ); + bcurves.push( + segment.scale(linearDistanceFunction(-d2, -d4, tlen, alen, slen)) + ); + } else { + fcurves.push(segment.scale(d1)); + bcurves.push(segment.scale(-d2)); + } + alen += slen; + }); + + // reverse the "return" outline + bcurves = bcurves + .map(function (s) { + p = s.points; + if (p[3]) { + s.points = [p[3], p[2], p[1], p[0]]; + } else { + s.points = [p[2], p[1], p[0]]; + } + return s; + }) + .reverse(); + + // form the endcaps as lines + const fs = fcurves[0].points[0], + fe = fcurves[len - 1].points[fcurves[len - 1].points.length - 1], + bs = bcurves[len - 1].points[bcurves[len - 1].points.length - 1], + be = bcurves[0].points[0], + ls = utils.makeline(bs, fs), + le = utils.makeline(fe, be), + segments = [ls].concat(fcurves).concat([le]).concat(bcurves); + + return new PolyBezier(segments); + } + + outlineshapes(d1, d2, curveIntersectionThreshold) { + d2 = d2 || d1; + const outline = this.outline(d1, d2).curves; + const shapes = []; + for (let i = 1, len = outline.length; i < len / 2; i++) { + const shape = utils.makeshape( + outline[i], + outline[len - i], + curveIntersectionThreshold + ); + shape.startcap.virtual = i > 1; + shape.endcap.virtual = i < len / 2 - 1; + shapes.push(shape); + } + return shapes; + } + + intersects(curve, curveIntersectionThreshold) { + if (!curve) return this.selfintersects(curveIntersectionThreshold); + if (curve.p1 && curve.p2) { + return this.lineIntersects(curve); + } + if (curve instanceof Bezier) { + curve = curve.reduce(); + } + return this.curveintersects( + this.reduce(), + curve, + curveIntersectionThreshold + ); + } + + lineIntersects(line) { + const mx = min(line.p1.x, line.p2.x), + my = min(line.p1.y, line.p2.y), + MX = max(line.p1.x, line.p2.x), + MY = max(line.p1.y, line.p2.y); + return utils.roots(this.points, line).filter((t) => { + var p = this.get(t); + return utils.between(p.x, mx, MX) && utils.between(p.y, my, MY); + }); + } + + selfintersects(curveIntersectionThreshold) { + // "simple" curves cannot intersect with their direct + // neighbour, so for each segment X we check whether + // it intersects [0:x-2][x+2:last]. + + const reduced = this.reduce(), + len = reduced.length - 2, + results = []; + + for (let i = 0, result, left, right; i < len; i++) { + left = reduced.slice(i, i + 1); + right = reduced.slice(i + 2); + result = this.curveintersects(left, right, curveIntersectionThreshold); + results.push(...result); + } + return results; + } + + curveintersects(c1, c2, curveIntersectionThreshold) { + const pairs = []; + // step 1: pair off any overlapping segments + c1.forEach(function (l) { + c2.forEach(function (r) { + if (l.overlaps(r)) { + pairs.push({ left: l, right: r }); + } + }); + }); + // step 2: for each pairing, run through the convergence algorithm. + let intersections = []; + pairs.forEach(function (pair) { + const result = utils.pairiteration( + pair.left, + pair.right, + curveIntersectionThreshold + ); + if (result.length > 0) { + intersections = intersections.concat(result); + } + }); + return intersections; + } + + arcs(errorThreshold) { + errorThreshold = errorThreshold || 0.5; + return this._iterate(errorThreshold, []); + } + + _error(pc, np1, s, e) { + const q = (e - s) / 4, + c1 = this.get(s + q), + c2 = this.get(e - q), + ref = utils.dist(pc, np1), + d1 = utils.dist(pc, c1), + d2 = utils.dist(pc, c2); + return abs$1(d1 - ref) + abs$1(d2 - ref); + } + + _iterate(errorThreshold, circles) { + let t_s = 0, + t_e = 1, + safety; + // we do a binary search to find the "good `t` closest to no-longer-good" + do { + safety = 0; + + // step 1: start with the maximum possible arc + t_e = 1; + + // points: + let np1 = this.get(t_s), + np2, + np3, + arc, + prev_arc; + + // booleans: + let curr_good = false, + prev_good = false, + done; + + // numbers: + let t_m = t_e, + prev_e = 1; + + // step 2: find the best possible arc + do { + prev_good = curr_good; + prev_arc = arc; + t_m = (t_s + t_e) / 2; + + np2 = this.get(t_m); + np3 = this.get(t_e); + + arc = utils.getccenter(np1, np2, np3); + + //also save the t values + arc.interval = { + start: t_s, + end: t_e, + }; + + let error = this._error(arc, np1, t_s, t_e); + curr_good = error <= errorThreshold; + + done = prev_good && !curr_good; + if (!done) prev_e = t_e; + + // this arc is fine: we can move 'e' up to see if we can find a wider arc + if (curr_good) { + // if e is already at max, then we're done for this arc. + if (t_e >= 1) { + // make sure we cap at t=1 + arc.interval.end = prev_e = 1; + prev_arc = arc; + // if we capped the arc segment to t=1 we also need to make sure that + // the arc's end angle is correct with respect to the bezier end point. + if (t_e > 1) { + let d = { + x: arc.x + arc.r * cos$1(arc.e), + y: arc.y + arc.r * sin$1(arc.e), + }; + arc.e += utils.angle({ x: arc.x, y: arc.y }, d, this.get(1)); + } + break; + } + // if not, move it up by half the iteration distance + t_e = t_e + (t_e - t_s) / 2; + } else { + // this is a bad arc: we need to move 'e' down to find a good arc + t_e = t_m; + } + } while (!done && safety++ < 100); + + if (safety >= 100) { + break; + } + + // console.log("L835: [F] arc found", t_s, prev_e, prev_arc.x, prev_arc.y, prev_arc.s, prev_arc.e); + + prev_arc = prev_arc ? prev_arc : arc; + circles.push(prev_arc); + t_s = prev_e; + } while (t_e < 1); + return circles; + } + + getStrutPoints(t) { + const p = this.points.map((p) => new Vector(p)); + const mt = 1 - t; + + let s = 0; + let n = p.length + 1; + while (--n > 1) { + let list = p.slice(s, s + n); + for (let i = 0, e = list.length - 1; i < e; i++) { + let pt = list[i + 1].subtract(list[i + 1].subtract(list[i]).scale(mt)); + p.push(pt); + } + s += n; + } + + return p; + } + + toString() { + return `<[${this.points[0].x},${this.points[0].y}], [${this.points[1].x},${this.points[1].y}], [${this.points[2].x},${this.points[2].y}], [${this.points[3].x},${this.points[3].y}]` + } + +} + +export { Bezier }; diff --git a/src/coloris.css b/src/coloris.css new file mode 100644 index 0000000..41ddad2 --- /dev/null +++ b/src/coloris.css @@ -0,0 +1,577 @@ +.clr-picker { + display: none; + flex-wrap: wrap; + position: absolute; + width: 200px; + z-index: 1000; + border-radius: 10px; + background-color: #fff; + justify-content: flex-end; + direction: ltr; + box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1); + -moz-user-select: none; + -webkit-user-select: none; + user-select: none; +} + +.clr-picker.clr-open, +.clr-picker[data-inline="true"] { + display: flex; +} + +.clr-picker[data-inline="true"] { + position: relative; +} + +.clr-gradient { + position: relative; + width: 100%; + height: 100px; + margin-bottom: 15px; + border-radius: 3px 3px 0 0; + background-image: linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor); + cursor: pointer; +} + +.clr-marker { + position: absolute; + width: 12px; + height: 12px; + margin: -6px 0 0 -6px; + border: 1px solid #fff; + border-radius: 50%; + background-color: currentColor; + cursor: pointer; +} + +.clr-picker input[type="range"]::-webkit-slider-runnable-track { + width: 100%; + height: 16px; +} + +.clr-picker input[type="range"]::-webkit-slider-thumb { + width: 16px; + height: 16px; + -webkit-appearance: none; +} + +.clr-picker input[type="range"]::-moz-range-track { + width: 100%; + height: 16px; + border: 0; +} + +.clr-picker input[type="range"]::-moz-range-thumb { + width: 16px; + height: 16px; + border: 0; +} + +.clr-hue { + background-image: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%); +} + +.clr-hue, +.clr-alpha { + position: relative; + width: calc(100% - 40px); + height: 8px; + margin: 5px 20px; + border-radius: 4px; +} + +.clr-alpha span { + display: block; + height: 100%; + width: 100%; + border-radius: inherit; + background-image: linear-gradient(90deg, rgba(0,0,0,0), currentColor); +} + +.clr-hue input[type="range"], +.clr-alpha input[type="range"] { + position: absolute; + width: calc(100% + 32px); + height: 16px; + left: -16px; + top: -4px; + margin: 0; + background-color: transparent; + opacity: 0; + cursor: pointer; + appearance: none; + -webkit-appearance: none; +} + +.clr-hue div, +.clr-alpha div { + position: absolute; + width: 16px; + height: 16px; + left: 0; + top: 50%; + margin-left: -8px; + transform: translateY(-50%); + border: 2px solid #fff; + border-radius: 50%; + background-color: currentColor; + box-shadow: 0 0 1px #888; + pointer-events: none; +} + +.clr-alpha div:before { + content: ''; + position: absolute; + height: 100%; + width: 100%; + left: 0; + top: 0; + border-radius: 50%; + background-color: currentColor; +} + +.clr-format { + display: none; + order: 1; + width: calc(100% - 40px); + margin: 0 20px 20px; +} + +.clr-segmented { + display: flex; + position: relative; + width: 100%; + margin: 0; + padding: 0; + border: 1px solid #ddd; + border-radius: 15px; + box-sizing: border-box; + color: #999; + font-size: 12px; +} + +.clr-segmented input, +.clr-segmented legend { + position: absolute; + width: 100%; + height: 100%; + margin: 0; + padding: 0; + border: 0; + left: 0; + top: 0; + opacity: 0; + pointer-events: none; +} + +.clr-segmented label { + flex-grow: 1; + margin: 0; + padding: 4px 0; + font-size: inherit; + font-weight: normal; + line-height: initial; + text-align: center; + cursor: pointer; +} + +.clr-segmented label:first-of-type { + border-radius: 10px 0 0 10px; +} + +.clr-segmented label:last-of-type { + border-radius: 0 10px 10px 0; +} + +.clr-segmented input:checked + label { + color: #fff; + background-color: #666; +} + +.clr-swatches { + order: 2; + width: calc(100% - 32px); + margin: 0 16px; +} + +.clr-swatches div { + display: flex; + flex-wrap: wrap; + padding-bottom: 12px; + justify-content: center; +} + +.clr-swatches button { + position: relative; + width: 20px; + height: 20px; + margin: 0 4px 6px 4px; + padding: 0; + border: 0; + border-radius: 50%; + color: inherit; + text-indent: -1000px; + white-space: nowrap; + overflow: hidden; + cursor: pointer; +} + +.clr-swatches button:after { + content: ''; + display: block; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + border-radius: inherit; + background-color: currentColor; + box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); +} + +input.clr-color { + order: 1; + width: calc(100% - 80px); + height: 32px; + margin: 15px 20px 20px auto; + padding: 0 10px; + border: 1px solid #ddd; + border-radius: 16px; + color: #444; + background-color: #fff; + font-family: sans-serif; + font-size: 14px; + text-align: center; + box-shadow: none; +} + +input.clr-color:focus { + outline: none; + border: 1px solid #1e90ff; +} + +.clr-close, +.clr-clear { + display: none; + order: 2; + height: 24px; + margin: 0 20px 20px; + padding: 0 20px; + border: 0; + border-radius: 12px; + color: #fff; + background-color: #666; + font-family: inherit; + font-size: 12px; + font-weight: 400; + cursor: pointer; +} + +.clr-close { + display: block; + margin: 0 20px 20px auto; +} + +.clr-preview { + position: relative; + width: 32px; + height: 32px; + margin: 15px 0 20px 20px; + border-radius: 50%; + overflow: hidden; +} + +.clr-preview:before, +.clr-preview:after { + content: ''; + position: absolute; + height: 100%; + width: 100%; + left: 0; + top: 0; + border: 1px solid #fff; + border-radius: 50%; +} + +.clr-preview:after { + border: 0; + background-color: currentColor; + box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); +} + +.clr-preview button { + position: absolute; + width: 100%; + height: 100%; + z-index: 1; + margin: 0; + padding: 0; + border: 0; + border-radius: 50%; + outline-offset: -2px; + background-color: transparent; + text-indent: -9999px; + cursor: pointer; + overflow: hidden; +} + +.clr-marker, +.clr-hue div, +.clr-alpha div, +.clr-color { + box-sizing: border-box; +} + +.clr-field { + display: inline-block; + position: relative; + color: transparent; +} + +.clr-field input { + margin: 0; + direction: ltr; +} + +.clr-field.clr-rtl input { + text-align: right; +} + +.clr-field button { + position: absolute; + width: 30px; + height: 100%; + right: 0; + top: 50%; + transform: translateY(-50%); + margin: 0; + padding: 0; + border: 0; + color: inherit; + text-indent: -1000px; + white-space: nowrap; + overflow: hidden; + pointer-events: none; +} + +.clr-field.clr-rtl button { + right: auto; + left: 0; +} + +.clr-field button:after { + content: ''; + display: block; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + border-radius: inherit; + background-color: currentColor; + box-shadow: inset 0 0 1px rgba(0,0,0,.5); +} + +.clr-alpha, +.clr-alpha div, +.clr-swatches button, +.clr-preview:before, +.clr-field button { + background-image: repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa), repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa); + background-position: 0 0, 4px 4px; + background-size: 8px 8px; +} + +.clr-marker:focus { + outline: none; +} + +.clr-keyboard-nav .clr-marker:focus, +.clr-keyboard-nav .clr-hue input:focus + div, +.clr-keyboard-nav .clr-alpha input:focus + div, +.clr-keyboard-nav .clr-segmented input:focus + label { + outline: none; + box-shadow: 0 0 0 2px #1e90ff, 0 0 2px 2px #fff; +} + +.clr-picker[data-alpha="false"] .clr-alpha { + display: none; +} + +.clr-picker[data-minimal="true"] { + padding-top: 16px; +} + +.clr-picker[data-minimal="true"] .clr-gradient, +.clr-picker[data-minimal="true"] .clr-hue, +.clr-picker[data-minimal="true"] .clr-alpha, +.clr-picker[data-minimal="true"] .clr-color, +.clr-picker[data-minimal="true"] .clr-preview { + display: none; +} + +/** Dark theme **/ + +.clr-dark { + background-color: #444; +} + +.clr-dark .clr-segmented { + border-color: #777; +} + +.clr-dark .clr-swatches button:after { + box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); +} + +.clr-dark input.clr-color { + color: #fff; + border-color: #777; + background-color: #555; +} + +.clr-dark input.clr-color:focus { + border-color: #1e90ff; +} + +.clr-dark .clr-preview:after { + box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); +} + +.clr-dark .clr-alpha, +.clr-dark .clr-alpha div, +.clr-dark .clr-swatches button, +.clr-dark .clr-preview:before { + background-image: repeating-linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #888 75%, #888), repeating-linear-gradient(45deg, #888 25%, #444 25%, #444 75%, #888 75%, #888); +} + +/** Polaroid theme **/ + +.clr-picker.clr-polaroid { + border-radius: 6px; + box-shadow: 0 0 5px rgba(0,0,0,.1), 0 5px 30px rgba(0,0,0,.2); +} + +.clr-picker.clr-polaroid:before { + content: ''; + display: block; + position: absolute; + width: 16px; + height: 10px; + left: 20px; + top: -10px; + border: solid transparent; + border-width: 0 8px 10px 8px; + border-bottom-color: currentColor; + box-sizing: border-box; + color: #fff; + filter: drop-shadow(0 -4px 3px rgba(0,0,0,.1)); + pointer-events: none; +} + +.clr-picker.clr-polaroid.clr-dark:before { + color: #444; +} + +.clr-picker.clr-polaroid.clr-left:before { + left: auto; + right: 20px; +} + +.clr-picker.clr-polaroid.clr-top:before { + top: auto; + bottom: -10px; + transform: rotateZ(180deg); +} + +.clr-polaroid .clr-gradient { + width: calc(100% - 20px); + height: 120px; + margin: 10px; + border-radius: 3px; +} + +.clr-polaroid .clr-hue, +.clr-polaroid .clr-alpha { + width: calc(100% - 30px); + height: 10px; + margin: 6px 15px; + border-radius: 5px; +} + +.clr-polaroid .clr-hue div, +.clr-polaroid .clr-alpha div { + box-shadow: 0 0 5px rgba(0,0,0,.2); +} + +.clr-polaroid .clr-format { + width: calc(100% - 20px); + margin: 0 10px 15px; +} + +.clr-polaroid .clr-swatches { + width: calc(100% - 12px); + margin: 0 6px; +} +.clr-polaroid .clr-swatches div { + padding-bottom: 10px; +} + +.clr-polaroid .clr-swatches button { + width: 22px; + height: 22px; +} + +.clr-polaroid input.clr-color { + width: calc(100% - 60px); + margin: 10px 10px 15px auto; +} + +.clr-polaroid .clr-clear { + margin: 0 10px 15px 10px; +} + +.clr-polaroid .clr-close { + margin: 0 10px 15px auto; +} + +.clr-polaroid .clr-preview { + margin: 10px 0 15px 10px; +} + +/** Large theme **/ + +.clr-picker.clr-large { + width: 275px; +} + +.clr-large .clr-gradient { + height: 150px; +} + +.clr-large .clr-swatches button { + width: 22px; + height: 22px; +} + +/** Pill (horizontal) theme **/ + +.clr-picker.clr-pill { + width: 380px; + padding-left: 180px; + box-sizing: border-box; +} + +.clr-pill .clr-gradient { + position: absolute; + width: 180px; + height: 100%; + left: 0; + top: 0; + margin-bottom: 0; + border-radius: 3px 0 0 3px; +} + +.clr-pill .clr-hue { + margin-top: 20px; +} \ No newline at end of file diff --git a/src/coloris.js b/src/coloris.js new file mode 100644 index 0000000..1aa88b0 --- /dev/null +++ b/src/coloris.js @@ -0,0 +1,1263 @@ + /*! + * Copyright (c) 2021 Momo Bassit. + * Licensed under the MIT License (MIT) + * https://github.com/mdbassit/Coloris + */ + +(function (window, document, Math, undefined) { + var ctx = document.createElement('canvas').getContext('2d'); + var currentColor = { r: 0, g: 0, b: 0, h: 0, s: 0, v: 0, a: 1 }; + var container,picker,colorArea,colorMarker,colorPreview,colorValue,clearButton,closeButton, + hueSlider,hueMarker,alphaSlider,alphaMarker,currentEl,currentFormat,oldColor,keyboardNav, + colorAreaDims = {}; + + // Default settings + var settings = { + el: '[data-coloris]', + parent: 'body', + theme: 'default', + themeMode: 'light', + rtl: false, + wrap: true, + margin: 2, + format: 'hex', + formatToggle: false, + swatches: [], + swatchesOnly: false, + alpha: true, + forceAlpha: false, + focusInput: true, + selectInput: false, + inline: false, + defaultColor: '#000000', + clearButton: false, + clearLabel: 'Clear', + closeButton: false, + closeLabel: 'Close', + onChange: function onChange() {return undefined;}, + a11y: { + open: 'Open color picker', + close: 'Close color picker', + clear: 'Clear the selected color', + marker: 'Saturation: {s}. Brightness: {v}.', + hueSlider: 'Hue slider', + alphaSlider: 'Opacity slider', + input: 'Color value field', + format: 'Color format', + swatch: 'Color swatch', + instruction: 'Saturation and brightness selector. Use up, down, left and right arrow keys to select.' } }; + + + + // Virtual instances cache + var instances = {}; + var currentInstanceId = ''; + var defaultInstance = {}; + var hasInstance = false; + + /** + * Configure the color picker. + * @param {object} options Configuration options. + */ + function configure(options) { + if (typeof options !== 'object') { + return; + } + + for (var key in options) { + switch (key) { + case 'el': + bindFields(options.el); + if (options.wrap !== false) { + wrapFields(options.el); + } + break; + case 'parent': + container = options.parent instanceof HTMLElement ? options.parent : document.querySelector(options.parent); + if (container) { + container.appendChild(picker); + settings.parent = options.parent; + + // document.body is special + if (container === document.body) { + container = undefined; + } + } + break; + case 'themeMode': + settings.themeMode = options.themeMode; + if (options.themeMode === 'auto' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + settings.themeMode = 'dark'; + } + // The lack of a break statement is intentional + case 'theme': + if (options.theme) { + settings.theme = options.theme; + } + + // Set the theme and color scheme + picker.className = "clr-picker clr-" + settings.theme + " clr-" + settings.themeMode; + + // Update the color picker's position if inline mode is in use + if (settings.inline) { + updatePickerPosition(); + } + break; + case 'rtl': + settings.rtl = !!options.rtl; + Array.from(document.getElementsByClassName('clr-field')).forEach(function (field) {return field.classList.toggle('clr-rtl', settings.rtl);}); + break; + case 'margin': + options.margin *= 1; + settings.margin = !isNaN(options.margin) ? options.margin : settings.margin; + break; + case 'wrap': + if (options.el && options.wrap) { + wrapFields(options.el); + } + break; + case 'formatToggle': + settings.formatToggle = !!options.formatToggle; + getEl('clr-format').style.display = settings.formatToggle ? 'block' : 'none'; + if (settings.formatToggle) { + settings.format = 'auto'; + } + break; + case 'swatches': + if (Array.isArray(options.swatches)) {(function () { + var swatchesContainer = getEl('clr-swatches'); + var swatches = document.createElement('div'); + + // Clear current swatches + swatchesContainer.textContent = ''; + + // Build new swatches + options.swatches.forEach(function (swatch, i) { + var button = document.createElement('button'); + + button.setAttribute('type', "button"); + button.setAttribute('id', "clr-swatch-" + i); + button.setAttribute('aria-labelledby', "clr-swatch-label clr-swatch-" + i); + button.style.color = swatch; + button.textContent = swatch; + + swatches.appendChild(button); + }); + + // Append new swatches if any + if (options.swatches.length) { + swatchesContainer.appendChild(swatches); + } + + settings.swatches = options.swatches.slice();})(); + } + break; + case 'swatchesOnly': + settings.swatchesOnly = !!options.swatchesOnly; + picker.setAttribute('data-minimal', settings.swatchesOnly); + break; + case 'alpha': + settings.alpha = !!options.alpha; + picker.setAttribute('data-alpha', settings.alpha); + break; + case 'inline': + settings.inline = !!options.inline; + picker.setAttribute('data-inline', settings.inline); + + if (settings.inline) { + var defaultColor = options.defaultColor || settings.defaultColor; + + currentFormat = getColorFormatFromStr(defaultColor); + updatePickerPosition(); + setColorFromStr(defaultColor); + } + break; + case 'clearButton': + // Backward compatibility + if (typeof options.clearButton === 'object') { + if (options.clearButton.label) { + settings.clearLabel = options.clearButton.label; + clearButton.innerHTML = settings.clearLabel; + } + + options.clearButton = options.clearButton.show; + } + + settings.clearButton = !!options.clearButton; + clearButton.style.display = settings.clearButton ? 'block' : 'none'; + break; + case 'clearLabel': + settings.clearLabel = options.clearLabel; + clearButton.innerHTML = settings.clearLabel; + break; + case 'closeButton': + settings.closeButton = !!options.closeButton; + + if (settings.closeButton) { + picker.insertBefore(closeButton, colorPreview); + } else { + colorPreview.appendChild(closeButton); + } + + break; + case 'closeLabel': + settings.closeLabel = options.closeLabel; + closeButton.innerHTML = settings.closeLabel; + break; + case 'a11y': + var labels = options.a11y; + var update = false; + + if (typeof labels === 'object') { + for (var label in labels) { + if (labels[label] && settings.a11y[label]) { + settings.a11y[label] = labels[label]; + update = true; + } + } + } + + if (update) { + var openLabel = getEl('clr-open-label'); + var swatchLabel = getEl('clr-swatch-label'); + + openLabel.innerHTML = settings.a11y.open; + swatchLabel.innerHTML = settings.a11y.swatch; + closeButton.setAttribute('aria-label', settings.a11y.close); + clearButton.setAttribute('aria-label', settings.a11y.clear); + hueSlider.setAttribute('aria-label', settings.a11y.hueSlider); + alphaSlider.setAttribute('aria-label', settings.a11y.alphaSlider); + colorValue.setAttribute('aria-label', settings.a11y.input); + colorArea.setAttribute('aria-label', settings.a11y.instruction); + } + break; + default: + settings[key] = options[key];} + + } + } + + /** + * Add or update a virtual instance. + * @param {String} selector The CSS selector of the elements to which the instance is attached. + * @param {Object} options Per-instance options to apply. + */ + function setVirtualInstance(selector, options) { + if (typeof selector === 'string' && typeof options === 'object') { + instances[selector] = options; + hasInstance = true; + } + } + + /** + * Remove a virtual instance. + * @param {String} selector The CSS selector of the elements to which the instance is attached. + */ + function removeVirtualInstance(selector) { + delete instances[selector]; + + if (Object.keys(instances).length === 0) { + hasInstance = false; + + if (selector === currentInstanceId) { + resetVirtualInstance(); + } + } + } + + /** + * Attach a virtual instance to an element if it matches a selector. + * @param {Object} element Target element that will receive a virtual instance if applicable. + */ + function attachVirtualInstance(element) { + if (hasInstance) { + // These options can only be set globally, not per instance + var unsupportedOptions = ['el', 'wrap', 'rtl', 'inline', 'defaultColor', 'a11y'];var _loop = function _loop( + + selector) { + var options = instances[selector]; + + // If the element matches an instance's CSS selector + if (element.matches(selector)) { + currentInstanceId = selector; + defaultInstance = {}; + + // Delete unsupported options + unsupportedOptions.forEach(function (option) {return delete options[option];}); + + // Back up the default options so we can restore them later + for (var option in options) { + defaultInstance[option] = Array.isArray(settings[option]) ? settings[option].slice() : settings[option]; + } + + // Set the instance's options + configure(options); + return "break"; + }};for (var selector in instances) {var _ret = _loop(selector);if (_ret === "break") break; + } + } + } + + /** + * Revert any per-instance options that were previously applied. + */ + function resetVirtualInstance() { + if (Object.keys(defaultInstance).length > 0) { + configure(defaultInstance); + currentInstanceId = ''; + defaultInstance = {}; + } + } + + /** + * Bind the color picker to input fields that match the selector. + * @param {(string|HTMLElement|HTMLElement[])} selector A CSS selector string, a DOM element or a list of DOM elements. + */ + function bindFields(selector) { + if (selector instanceof HTMLElement) { + selector = [selector]; + } + + if (Array.isArray(selector)) { + selector.forEach(function (field) { + addListener(field, 'click', openPicker); + addListener(field, 'input', updateColorPreview); + }); + } else { + addListener(document, 'click', selector, openPicker); + addListener(document, 'input', selector, updateColorPreview); + } + } + + /** + * Open the color picker. + * @param {object} event The event that opens the color picker. + */ + function openPicker(event) { + // Skip if inline mode is in use + if (settings.inline) { + return; + } + + // Apply any per-instance options first + attachVirtualInstance(event.target); + + currentEl = event.target; + oldColor = currentEl.value; + currentFormat = getColorFormatFromStr(oldColor); + picker.classList.add('clr-open'); + + updatePickerPosition(); + setColorFromStr(oldColor); + + if (settings.focusInput || settings.selectInput) { + colorValue.focus({ preventScroll: true }); + colorValue.setSelectionRange(currentEl.selectionStart, currentEl.selectionEnd); + } + + if (settings.selectInput) { + colorValue.select(); + } + + // Always focus the first element when using keyboard navigation + if (keyboardNav || settings.swatchesOnly) { + getFocusableElements().shift().focus(); + } + + // Trigger an "open" event + currentEl.dispatchEvent(new Event('open', { bubbles: true })); + } + + /** + * Update the color picker's position and the color gradient's offset + */ + function updatePickerPosition() { + var parent = container; + var scrollY = window.scrollY; + var pickerWidth = picker.offsetWidth; + var pickerHeight = picker.offsetHeight; + var reposition = { left: false, top: false }; + var parentStyle, parentMarginTop, parentBorderTop; + var offset = { x: 0, y: 0 }; + + if (parent) { + parentStyle = window.getComputedStyle(parent); + parentMarginTop = parseFloat(parentStyle.marginTop); + parentBorderTop = parseFloat(parentStyle.borderTopWidth); + + offset = parent.getBoundingClientRect(); + offset.y += parentBorderTop + scrollY; + } + + if (!settings.inline) { + var coords = currentEl.getBoundingClientRect(); + var left = coords.x; + var top = scrollY + coords.y + coords.height + settings.margin; + + // If the color picker is inside a custom container + // set the position relative to it + if (parent) { + left -= offset.x; + top -= offset.y; + + if (left + pickerWidth > parent.clientWidth) { + left += coords.width - pickerWidth; + reposition.left = true; + } + + if (top + pickerHeight > parent.clientHeight - parentMarginTop) { + if (pickerHeight + settings.margin <= coords.top - (offset.y - scrollY)) { + top -= coords.height + pickerHeight + settings.margin * 2; + reposition.top = true; + } + } + + top += parent.scrollTop; + + // Otherwise set the position relative to the whole document + } else { + if (left + pickerWidth > document.documentElement.clientWidth) { + left += coords.width - pickerWidth; + reposition.left = true; + } + + if (top + pickerHeight - scrollY > document.documentElement.clientHeight) { + if (pickerHeight + settings.margin <= coords.top) { + top = scrollY + coords.y - pickerHeight - settings.margin; + reposition.top = true; + } + } + } + + picker.classList.toggle('clr-left', reposition.left); + picker.classList.toggle('clr-top', reposition.top); + picker.style.left = left + "px"; + picker.style.top = top + "px"; + offset.x += picker.offsetLeft; + offset.y += picker.offsetTop; + } + + colorAreaDims = { + width: colorArea.offsetWidth, + height: colorArea.offsetHeight, + x: colorArea.offsetLeft + offset.x, + y: colorArea.offsetTop + offset.y }; + + } + + /** + * Wrap the linked input fields in a div that adds a color preview. + * @param {(string|HTMLElement|HTMLElement[])} selector A CSS selector string, a DOM element or a list of DOM elements. + */ + function wrapFields(selector) { + if (selector instanceof HTMLElement) { + wrapColorField(selector); + } else if (Array.isArray(selector)) { + selector.forEach(wrapColorField); + } else { + document.querySelectorAll(selector).forEach(wrapColorField); + } + } + + /** + * Wrap an input field in a div that adds a color preview. + * @param {object} field The input field. + */ + function wrapColorField(field) { + var parentNode = field.parentNode; + + if (!parentNode.classList.contains('clr-field')) { + var wrapper = document.createElement('div'); + var classes = 'clr-field'; + + if (settings.rtl || field.classList.contains('clr-rtl')) { + classes += ' clr-rtl'; + } + + wrapper.innerHTML = ''; + parentNode.insertBefore(wrapper, field); + wrapper.className = classes; + wrapper.style.color = field.value; + wrapper.appendChild(field); + } + } + + /** + * Update the color preview of an input field + * @param {object} event The "input" event that triggers the color change. + */ + function updateColorPreview(event) { + var parent = event.target.parentNode; + + // Only update the preview if the field has been previously wrapped + if (parent.classList.contains('clr-field')) { + parent.style.color = event.target.value; + } + } + + /** + * Close the color picker. + * @param {boolean} [revert] If true, revert the color to the original value. + */ + function closePicker(revert) { + if (currentEl && !settings.inline) { + var prevEl = currentEl; + + // Revert the color to the original value if needed + if (revert) { + // This will prevent the "change" event on the colorValue input to execute its handler + currentEl = undefined; + + if (oldColor !== prevEl.value) { + prevEl.value = oldColor; + + // Trigger an "input" event to force update the thumbnail next to the input field + prevEl.dispatchEvent(new Event('input', { bubbles: true })); + } + } + + // Trigger a "change" event if needed + setTimeout(function () {// Add this to the end of the event loop + if (oldColor !== prevEl.value) { + prevEl.dispatchEvent(new Event('change', { bubbles: true })); + } + }); + + // Hide the picker dialog + picker.classList.remove('clr-open'); + + // Reset any previously set per-instance options + if (hasInstance) { + resetVirtualInstance(); + } + + // Trigger a "close" event + prevEl.dispatchEvent(new Event('close', { bubbles: true })); + + if (settings.focusInput) { + prevEl.focus({ preventScroll: true }); + } + + // This essentially marks the picker as closed + currentEl = undefined; + } + } + + /** + * Set the active color from a string. + * @param {string} str String representing a color. + */ + function setColorFromStr(str) { + var rgba = strToRGBA(str); + var hsva = RGBAtoHSVA(rgba); + + updateMarkerA11yLabel(hsva.s, hsva.v); + updateColor(rgba, hsva); + + // Update the UI + hueSlider.value = hsva.h; + picker.style.color = "hsl(" + hsva.h + ", 100%, 50%)"; + hueMarker.style.left = hsva.h / 360 * 100 + "%"; + + colorMarker.style.left = colorAreaDims.width * hsva.s / 100 + "px"; + colorMarker.style.top = colorAreaDims.height - colorAreaDims.height * hsva.v / 100 + "px"; + + alphaSlider.value = hsva.a * 100; + alphaMarker.style.left = hsva.a * 100 + "%"; + } + + /** + * Guess the color format from a string. + * @param {string} str String representing a color. + * @return {string} The color format. + */ + function getColorFormatFromStr(str) { + var format = str.substring(0, 3).toLowerCase(); + + if (format === 'rgb' || format === 'hsl') { + return format; + } + + return 'hex'; + } + + /** + * Copy the active color to the linked input field. + * @param {number} [color] Color value to override the active color. + */ + function pickColor(color) { + color = color !== undefined ? color : colorValue.value; + + if (currentEl) { + currentEl.value = color; + currentEl.dispatchEvent(new Event('input', { bubbles: true })); + } + + if (settings.onChange) { + settings.onChange.call(window, color, currentEl); + } + + document.dispatchEvent(new CustomEvent('coloris:pick', { detail: { color: color, currentEl: currentEl } })); + } + + /** + * Set the active color based on a specific point in the color gradient. + * @param {number} x Left position. + * @param {number} y Top position. + */ + function setColorAtPosition(x, y) { + var hsva = { + h: hueSlider.value * 1, + s: x / colorAreaDims.width * 100, + v: 100 - y / colorAreaDims.height * 100, + a: alphaSlider.value / 100 }; + + var rgba = HSVAtoRGBA(hsva); + + updateMarkerA11yLabel(hsva.s, hsva.v); + updateColor(rgba, hsva); + pickColor(); + } + + /** + * Update the color marker's accessibility label. + * @param {number} saturation + * @param {number} value + */ + function updateMarkerA11yLabel(saturation, value) { + var label = settings.a11y.marker; + + saturation = saturation.toFixed(1) * 1; + value = value.toFixed(1) * 1; + label = label.replace('{s}', saturation); + label = label.replace('{v}', value); + colorMarker.setAttribute('aria-label', label); + } + + // + /** + * Get the pageX and pageY positions of the pointer. + * @param {object} event The MouseEvent or TouchEvent object. + * @return {object} The pageX and pageY positions. + */ + function getPointerPosition(event) { + return { + pageX: event.changedTouches ? event.changedTouches[0].pageX : event.pageX, + pageY: event.changedTouches ? event.changedTouches[0].pageY : event.pageY }; + + } + + /** + * Move the color marker when dragged. + * @param {object} event The MouseEvent object. + */ + function moveMarker(event) { + var pointer = getPointerPosition(event); + var x = pointer.pageX - colorAreaDims.x; + var y = pointer.pageY - colorAreaDims.y; + + if (container) { + y += container.scrollTop; + } + + setMarkerPosition(x, y); + + // Prevent scrolling while dragging the marker + event.preventDefault(); + event.stopPropagation(); + } + + /** + * Move the color marker when the arrow keys are pressed. + * @param {number} offsetX The horizontal amount to move. + * @param {number} offsetY The vertical amount to move. + */ + function moveMarkerOnKeydown(offsetX, offsetY) { + var x = colorMarker.style.left.replace('px', '') * 1 + offsetX; + var y = colorMarker.style.top.replace('px', '') * 1 + offsetY; + + setMarkerPosition(x, y); + } + + /** + * Set the color marker's position. + * @param {number} x Left position. + * @param {number} y Top position. + */ + function setMarkerPosition(x, y) { + // Make sure the marker doesn't go out of bounds + x = x < 0 ? 0 : x > colorAreaDims.width ? colorAreaDims.width : x; + y = y < 0 ? 0 : y > colorAreaDims.height ? colorAreaDims.height : y; + + // Set the position + colorMarker.style.left = x + "px"; + colorMarker.style.top = y + "px"; + + // Update the color + setColorAtPosition(x, y); + + // Make sure the marker is focused + colorMarker.focus(); + } + + /** + * Update the color picker's input field and preview thumb. + * @param {Object} rgba Red, green, blue and alpha values. + * @param {Object} [hsva] Hue, saturation, value and alpha values. + */ + function updateColor(rgba, hsva) {if (rgba === void 0) {rgba = {};}if (hsva === void 0) {hsva = {};} + var format = settings.format; + + for (var key in rgba) { + currentColor[key] = rgba[key]; + } + + for (var _key in hsva) { + currentColor[_key] = hsva[_key]; + } + + var hex = RGBAToHex(currentColor); + var opaqueHex = hex.substring(0, 7); + + colorMarker.style.color = opaqueHex; + alphaMarker.parentNode.style.color = opaqueHex; + alphaMarker.style.color = hex; + colorPreview.style.color = hex; + + // Force repaint the color and alpha gradients as a workaround for a Google Chrome bug + colorArea.style.display = 'none'; + colorArea.offsetHeight; + colorArea.style.display = ''; + alphaMarker.nextElementSibling.style.display = 'none'; + alphaMarker.nextElementSibling.offsetHeight; + alphaMarker.nextElementSibling.style.display = ''; + + if (format === 'mixed') { + format = currentColor.a === 1 ? 'hex' : 'rgb'; + } else if (format === 'auto') { + format = currentFormat; + } + + switch (format) { + case 'hex': + colorValue.value = hex; + break; + case 'rgb': + colorValue.value = RGBAToStr(currentColor); + break; + case 'hsl': + colorValue.value = HSLAToStr(HSVAtoHSLA(currentColor)); + break;} + + + // Select the current format in the format switcher + document.querySelector(".clr-format [value=\"" + format + "\"]").checked = true; + } + + /** + * Set the hue when its slider is moved. + */ + function setHue() { + var hue = hueSlider.value * 1; + var x = colorMarker.style.left.replace('px', '') * 1; + var y = colorMarker.style.top.replace('px', '') * 1; + + picker.style.color = "hsl(" + hue + ", 100%, 50%)"; + hueMarker.style.left = hue / 360 * 100 + "%"; + + setColorAtPosition(x, y); + } + + /** + * Set the alpha when its slider is moved. + */ + function setAlpha() { + var alpha = alphaSlider.value / 100; + + alphaMarker.style.left = alpha * 100 + "%"; + updateColor({ a: alpha }); + pickColor(); + } + + /** + * Convert HSVA to RGBA. + * @param {object} hsva Hue, saturation, value and alpha values. + * @return {object} Red, green, blue and alpha values. + */ + function HSVAtoRGBA(hsva) { + var saturation = hsva.s / 100; + var value = hsva.v / 100; + var chroma = saturation * value; + var hueBy60 = hsva.h / 60; + var x = chroma * (1 - Math.abs(hueBy60 % 2 - 1)); + var m = value - chroma; + + chroma = chroma + m; + x = x + m; + + var index = Math.floor(hueBy60) % 6; + var red = [chroma, x, m, m, x, chroma][index]; + var green = [x, chroma, chroma, x, m, m][index]; + var blue = [m, m, x, chroma, chroma, x][index]; + + return { + r: Math.round(red * 255), + g: Math.round(green * 255), + b: Math.round(blue * 255), + a: hsva.a }; + + } + + /** + * Convert HSVA to HSLA. + * @param {object} hsva Hue, saturation, value and alpha values. + * @return {object} Hue, saturation, lightness and alpha values. + */ + function HSVAtoHSLA(hsva) { + var value = hsva.v / 100; + var lightness = value * (1 - hsva.s / 100 / 2); + var saturation; + + if (lightness > 0 && lightness < 1) { + saturation = Math.round((value - lightness) / Math.min(lightness, 1 - lightness) * 100); + } + + return { + h: hsva.h, + s: saturation || 0, + l: Math.round(lightness * 100), + a: hsva.a }; + + } + + /** + * Convert RGBA to HSVA. + * @param {object} rgba Red, green, blue and alpha values. + * @return {object} Hue, saturation, value and alpha values. + */ + function RGBAtoHSVA(rgba) { + var red = rgba.r / 255; + var green = rgba.g / 255; + var blue = rgba.b / 255; + var xmax = Math.max(red, green, blue); + var xmin = Math.min(red, green, blue); + var chroma = xmax - xmin; + var value = xmax; + var hue = 0; + var saturation = 0; + + if (chroma) { + if (xmax === red) {hue = (green - blue) / chroma;} + if (xmax === green) {hue = 2 + (blue - red) / chroma;} + if (xmax === blue) {hue = 4 + (red - green) / chroma;} + if (xmax) {saturation = chroma / xmax;} + } + + hue = Math.floor(hue * 60); + + return { + h: hue < 0 ? hue + 360 : hue, + s: Math.round(saturation * 100), + v: Math.round(value * 100), + a: rgba.a }; + + } + + /** + * Parse a string to RGBA. + * @param {string} str String representing a color. + * @return {object} Red, green, blue and alpha values. + */ + function strToRGBA(str) { + var regex = /^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i; + var match, rgba; + + // Default to black for invalid color strings + ctx.fillStyle = '#000'; + + // Use canvas to convert the string to a valid color string + ctx.fillStyle = str; + match = regex.exec(ctx.fillStyle); + + if (match) { + rgba = { + r: match[3] * 1, + g: match[4] * 1, + b: match[5] * 1, + a: match[6] * 1 }; + + + } else { + match = ctx.fillStyle.replace('#', '').match(/.{2}/g).map(function (h) {return parseInt(h, 16);}); + rgba = { + r: match[0], + g: match[1], + b: match[2], + a: 1 }; + + } + + return rgba; + } + + /** + * Convert RGBA to Hex. + * @param {object} rgba Red, green, blue and alpha values. + * @return {string} Hex color string. + */ + function RGBAToHex(rgba) { + var R = rgba.r.toString(16); + var G = rgba.g.toString(16); + var B = rgba.b.toString(16); + var A = ''; + + if (rgba.r < 16) { + R = '0' + R; + } + + if (rgba.g < 16) { + G = '0' + G; + } + + if (rgba.b < 16) { + B = '0' + B; + } + + if (settings.alpha && (rgba.a < 1 || settings.forceAlpha)) { + var alpha = rgba.a * 255 | 0; + A = alpha.toString(16); + + if (alpha < 16) { + A = '0' + A; + } + } + + return '#' + R + G + B + A; + } + + /** + * Convert RGBA values to a CSS rgb/rgba string. + * @param {object} rgba Red, green, blue and alpha values. + * @return {string} CSS color string. + */ + function RGBAToStr(rgba) { + if (!settings.alpha || rgba.a === 1 && !settings.forceAlpha) { + return "rgb(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ")"; + } else { + return "rgba(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ", " + rgba.a + ")"; + } + } + + /** + * Convert HSLA values to a CSS hsl/hsla string. + * @param {object} hsla Hue, saturation, lightness and alpha values. + * @return {string} CSS color string. + */ + function HSLAToStr(hsla) { + if (!settings.alpha || hsla.a === 1 && !settings.forceAlpha) { + return "hsl(" + hsla.h + ", " + hsla.s + "%, " + hsla.l + "%)"; + } else { + return "hsla(" + hsla.h + ", " + hsla.s + "%, " + hsla.l + "%, " + hsla.a + ")"; + } + } + + /** + * Init the color picker. + */ + function init() { + // Render the UI + container = undefined; + picker = document.createElement('div'); + picker.setAttribute('id', 'clr-picker'); + picker.className = 'clr-picker'; + picker.innerHTML = + "" + ("
") + + '
' + + '
' + + '
' + ("") + + '
' + + '
' + + '
' + ("") + + '
' + + '' + + '
' + + '
' + + '
' + ("" + + settings.a11y.format + "") + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '
' + + '
' + ("") + + '
' + ("") + + '
' + ("") + (""); + + // Append the color picker to the DOM + document.body.appendChild(picker); + + // Reference the UI elements + colorArea = getEl('clr-color-area'); + colorMarker = getEl('clr-color-marker'); + clearButton = getEl('clr-clear'); + closeButton = getEl('clr-close'); + colorPreview = getEl('clr-color-preview'); + colorValue = getEl('clr-color-value'); + hueSlider = getEl('clr-hue-slider'); + hueMarker = getEl('clr-hue-marker'); + alphaSlider = getEl('clr-alpha-slider'); + alphaMarker = getEl('clr-alpha-marker'); + + // Bind the picker to the default selector + bindFields(settings.el); + wrapFields(settings.el); + + addListener(picker, 'mousedown', function (event) { + picker.classList.remove('clr-keyboard-nav'); + event.stopPropagation(); + }); + + addListener(colorArea, 'mousedown', function (event) { + addListener(document, 'mousemove', moveMarker); + }); + + addListener(colorArea, 'contextmenu', function (event) { + event.preventDefault(); + }); + + addListener(colorArea, 'touchstart', function (event) { + document.addEventListener('touchmove', moveMarker, { passive: false }); + }); + + addListener(colorMarker, 'mousedown', function (event) { + addListener(document, 'mousemove', moveMarker); + }); + + addListener(colorMarker, 'touchstart', function (event) { + document.addEventListener('touchmove', moveMarker, { passive: false }); + }); + + addListener(colorValue, 'change', function (event) { + var value = colorValue.value; + + if (currentEl || settings.inline) { + var color = value === '' ? value : setColorFromStr(value); + pickColor(color); + } + }); + + addListener(clearButton, 'click', function (event) { + pickColor(''); + closePicker(); + }); + + addListener(closeButton, 'click', function (event) { + pickColor(); + closePicker(); + }); + + addListener(getEl('clr-format'), 'click', '.clr-format input', function (event) { + currentFormat = event.target.value; + updateColor(); + pickColor(); + }); + + addListener(picker, 'click', '.clr-swatches button', function (event) { + setColorFromStr(event.target.textContent); + pickColor(); + + if (settings.swatchesOnly) { + closePicker(); + } + }); + + addListener(document, 'mouseup', function (event) { + document.removeEventListener('mousemove', moveMarker); + }); + + addListener(document, 'touchend', function (event) { + document.removeEventListener('touchmove', moveMarker); + }); + + addListener(document, 'mousedown', function (event) { + keyboardNav = false; + picker.classList.remove('clr-keyboard-nav'); + closePicker(); + }); + + addListener(document, 'keydown', function (event) { + var key = event.key; + var target = event.target; + var shiftKey = event.shiftKey; + var navKeys = ['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']; + + if (key === 'Escape') { + closePicker(true); + + // Display focus rings when using the keyboard + } else if (navKeys.includes(key)) { + keyboardNav = true; + picker.classList.add('clr-keyboard-nav'); + } + + // Trap the focus within the color picker while it's open + if (key === 'Tab' && target.matches('.clr-picker *')) { + var focusables = getFocusableElements(); + var firstFocusable = focusables.shift(); + var lastFocusable = focusables.pop(); + + if (shiftKey && target === firstFocusable) { + lastFocusable.focus(); + event.preventDefault(); + } else if (!shiftKey && target === lastFocusable) { + firstFocusable.focus(); + event.preventDefault(); + } + } + }); + + addListener(document, 'click', '.clr-field button', function (event) { + // Reset any previously set per-instance options + if (hasInstance) { + resetVirtualInstance(); + } + + // Open the color picker + event.target.nextElementSibling.dispatchEvent(new Event('click', { bubbles: true })); + }); + + addListener(colorMarker, 'keydown', function (event) { + var movements = { + ArrowUp: [0, -1], + ArrowDown: [0, 1], + ArrowLeft: [-1, 0], + ArrowRight: [1, 0] }; + + + if (Object.keys(movements).includes(event.key)) { + moveMarkerOnKeydown.apply(void 0, movements[event.key]); + event.preventDefault(); + } + }); + + addListener(colorArea, 'click', moveMarker); + addListener(hueSlider, 'input', setHue); + addListener(alphaSlider, 'input', setAlpha); + } + + /** + * Return a list of focusable elements within the color picker. + * @return {array} The list of focusable DOM elemnts. + */ + function getFocusableElements() { + var controls = Array.from(picker.querySelectorAll('input, button')); + var focusables = controls.filter(function (node) {return !!node.offsetWidth;}); + + return focusables; + } + + /** + * Shortcut for getElementById to optimize the minified JS. + * @param {string} id The element id. + * @return {object} The DOM element with the provided id. + */ + function getEl(id) { + return document.getElementById(id); + } + + /** + * Shortcut for addEventListener to optimize the minified JS. + * @param {object} context The context to which the listener is attached. + * @param {string} type Event type. + * @param {(string|function)} selector Event target if delegation is used, event handler if not. + * @param {function} [fn] Event handler if delegation is used. + */ + function addListener(context, type, selector, fn) { + var matches = Element.prototype.matches || Element.prototype.msMatchesSelector; + + // Delegate event to the target of the selector + if (typeof selector === 'string') { + context.addEventListener(type, function (event) { + if (matches.call(event.target, selector)) { + fn.call(event.target, event); + } + }); + + // If the selector is not a string then it's a function + // in which case we need a regular event listener + } else { + fn = selector; + context.addEventListener(type, fn); + } + } + + /** + * Call a function only when the DOM is ready. + * @param {function} fn The function to call. + * @param {array} [args] Arguments to pass to the function. + */ + function DOMReady(fn, args) { + args = args !== undefined ? args : []; + + if (document.readyState !== 'loading') { + fn.apply(void 0, args); + } else { + document.addEventListener('DOMContentLoaded', function () { + fn.apply(void 0, args); + }); + } + } + + // Polyfill for Nodelist.forEach + if (NodeList !== undefined && NodeList.prototype && !NodeList.prototype.forEach) { + NodeList.prototype.forEach = Array.prototype.forEach; + } + + // Expose the color picker to the global scope + window.Coloris = function () { + var methods = { + set: configure, + wrap: wrapFields, + close: closePicker, + setInstance: setVirtualInstance, + removeInstance: removeVirtualInstance, + updatePosition: updatePickerPosition, + ready: DOMReady }; + + + function Coloris(options) { + DOMReady(function () { + if (options) { + if (typeof options === 'string') { + bindFields(options); + } else { + configure(options); + } + } + }); + }var _loop2 = function _loop2( + + key) { + Coloris[key] = function () {for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {args[_key2] = arguments[_key2];} + DOMReady(methods[key], args); + };};for (var key in methods) {_loop2(key); + } + + return Coloris; + }(); + + // Init the color picker when the DOM is ready + DOMReady(init); + +})(window, document, Math); \ No newline at end of file diff --git a/src/d3-interpolate-path.js b/src/d3-interpolate-path.js new file mode 100644 index 0000000..7d31297 --- /dev/null +++ b/src/d3-interpolate-path.js @@ -0,0 +1,782 @@ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : +typeof define === 'function' && define.amd ? define(['exports'], factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {})); +}(this, (function (exports) { 'use strict'; + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + + if (enumerableOnly) { + symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + } + + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; + + if (!it) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = it.call(o); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +/** + * de Casteljau's algorithm for drawing and splitting bezier curves. + * Inspired by https://pomax.github.io/bezierinfo/ + * + * @param {Number[][]} points Array of [x,y] points: [start, control1, control2, ..., end] + * The original segment to split. + * @param {Number} t Where to split the curve (value between [0, 1]) + * @return {Object} An object { left, right } where left is the segment from 0..t and + * right is the segment from t..1. + */ +function decasteljau(points, t) { + var left = []; + var right = []; + + function decasteljauRecurse(points, t) { + if (points.length === 1) { + left.push(points[0]); + right.push(points[0]); + } else { + var newPoints = Array(points.length - 1); + + for (var i = 0; i < newPoints.length; i++) { + if (i === 0) { + left.push(points[0]); + } + + if (i === newPoints.length - 1) { + right.push(points[i + 1]); + } + + newPoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]]; + } + + decasteljauRecurse(newPoints, t); + } + } + + if (points.length) { + decasteljauRecurse(points, t); + } + + return { + left: left, + right: right.reverse() + }; +} +/** + * Convert segments represented as points back into a command object + * + * @param {Number[][]} points Array of [x,y] points: [start, control1, control2, ..., end] + * Represents a segment + * @return {Object} A command object representing the segment. + */ + + +function pointsToCommand(points) { + var command = {}; + + if (points.length === 4) { + command.x2 = points[2][0]; + command.y2 = points[2][1]; + } + + if (points.length >= 3) { + command.x1 = points[1][0]; + command.y1 = points[1][1]; + } + + command.x = points[points.length - 1][0]; + command.y = points[points.length - 1][1]; + + if (points.length === 4) { + // start, control1, control2, end + command.type = 'C'; + } else if (points.length === 3) { + // start, control, end + command.type = 'Q'; + } else { + // start, end + command.type = 'L'; + } + + return command; +} +/** + * Runs de Casteljau's algorithm enough times to produce the desired number of segments. + * + * @param {Number[][]} points Array of [x,y] points for de Casteljau (the initial segment to split) + * @param {Number} segmentCount Number of segments to split the original into + * @return {Number[][][]} Array of segments + */ + + +function splitCurveAsPoints(points, segmentCount) { + segmentCount = segmentCount || 2; + var segments = []; + var remainingCurve = points; + var tIncrement = 1 / segmentCount; // x-----x-----x-----x + // t= 0.33 0.66 1 + // x-----o-----------x + // r= 0.33 + // x-----o-----x + // r= 0.5 (0.33 / (1 - 0.33)) === tIncrement / (1 - (tIncrement * (i - 1)) + // x-----x-----x-----x----x + // t= 0.25 0.5 0.75 1 + // x-----o----------------x + // r= 0.25 + // x-----o----------x + // r= 0.33 (0.25 / (1 - 0.25)) + // x-----o----x + // r= 0.5 (0.25 / (1 - 0.5)) + + for (var i = 0; i < segmentCount - 1; i++) { + var tRelative = tIncrement / (1 - tIncrement * i); + var split = decasteljau(remainingCurve, tRelative); + segments.push(split.left); + remainingCurve = split.right; + } // last segment is just to the end from the last point + + + segments.push(remainingCurve); + return segments; +} +/** + * Convert command objects to arrays of points, run de Casteljau's algorithm on it + * to split into to the desired number of segments. + * + * @param {Object} commandStart The start command object + * @param {Object} commandEnd The end command object + * @param {Number} segmentCount The number of segments to create + * @return {Object[]} An array of commands representing the segments in sequence + */ + + +function splitCurve(commandStart, commandEnd, segmentCount) { + var points = [[commandStart.x, commandStart.y]]; + + if (commandEnd.x1 != null) { + points.push([commandEnd.x1, commandEnd.y1]); + } + + if (commandEnd.x2 != null) { + points.push([commandEnd.x2, commandEnd.y2]); + } + + points.push([commandEnd.x, commandEnd.y]); + return splitCurveAsPoints(points, segmentCount).map(pointsToCommand); +} + +var commandTokenRegex = /[MLCSTQAHVZmlcstqahv]|-?[\d.e+-]+/g; +/** + * List of params for each command type in a path `d` attribute + */ + +var typeMap = { + M: ['x', 'y'], + L: ['x', 'y'], + H: ['x'], + V: ['y'], + C: ['x1', 'y1', 'x2', 'y2', 'x', 'y'], + S: ['x2', 'y2', 'x', 'y'], + Q: ['x1', 'y1', 'x', 'y'], + T: ['x', 'y'], + A: ['rx', 'ry', 'xAxisRotation', 'largeArcFlag', 'sweepFlag', 'x', 'y'], + Z: [] +}; // Add lower case entries too matching uppercase (e.g. 'm' == 'M') + +Object.keys(typeMap).forEach(function (key) { + typeMap[key.toLowerCase()] = typeMap[key]; +}); + +function arrayOfLength(length, value) { + var array = Array(length); + + for (var i = 0; i < length; i++) { + array[i] = value; + } + + return array; +} +/** + * Converts a command object to a string to be used in a `d` attribute + * @param {Object} command A command object + * @return {String} The string for the `d` attribute + */ + + +function commandToString(command) { + return "".concat(command.type).concat(typeMap[command.type].map(function (p) { + return command[p]; + }).join(',')); +} +/** + * Converts command A to have the same type as command B. + * + * e.g., L0,5 -> C0,5,0,5,0,5 + * + * Uses these rules: + * x1 <- x + * x2 <- x + * y1 <- y + * y2 <- y + * rx <- 0 + * ry <- 0 + * xAxisRotation <- read from B + * largeArcFlag <- read from B + * sweepflag <- read from B + * + * @param {Object} aCommand Command object from path `d` attribute + * @param {Object} bCommand Command object from path `d` attribute to match against + * @return {Object} aCommand converted to type of bCommand + */ + + +function convertToSameType(aCommand, bCommand) { + var conversionMap = { + x1: 'x', + y1: 'y', + x2: 'x', + y2: 'y' + }; + var readFromBKeys = ['xAxisRotation', 'largeArcFlag', 'sweepFlag']; // convert (but ignore M types) + + if (aCommand.type !== bCommand.type && bCommand.type.toUpperCase() !== 'M') { + var aConverted = {}; + Object.keys(bCommand).forEach(function (bKey) { + var bValue = bCommand[bKey]; // first read from the A command + + var aValue = aCommand[bKey]; // if it is one of these values, read from B no matter what + + if (aValue === undefined) { + if (readFromBKeys.includes(bKey)) { + aValue = bValue; + } else { + // if it wasn't in the A command, see if an equivalent was + if (aValue === undefined && conversionMap[bKey]) { + aValue = aCommand[conversionMap[bKey]]; + } // if it doesn't have a converted value, use 0 + + + if (aValue === undefined) { + aValue = 0; + } + } + } + + aConverted[bKey] = aValue; + }); // update the type to match B + + aConverted.type = bCommand.type; + aCommand = aConverted; + } + + return aCommand; +} +/** + * Interpolate between command objects commandStart and commandEnd segmentCount times. + * If the types are L, Q, or C then the curves are split as per de Casteljau's algorithm. + * Otherwise we just copy commandStart segmentCount - 1 times, finally ending with commandEnd. + * + * @param {Object} commandStart Command object at the beginning of the segment + * @param {Object} commandEnd Command object at the end of the segment + * @param {Number} segmentCount The number of segments to split this into. If only 1 + * Then [commandEnd] is returned. + * @return {Object[]} Array of ~segmentCount command objects between commandStart and + * commandEnd. (Can be segmentCount+1 objects if commandStart is type M). + */ + + +function splitSegment(commandStart, commandEnd, segmentCount) { + var segments = []; // line, quadratic bezier, or cubic bezier + + if (commandEnd.type === 'L' || commandEnd.type === 'Q' || commandEnd.type === 'C') { + segments = segments.concat(splitCurve(commandStart, commandEnd, segmentCount)); // general case - just copy the same point + } else { + var copyCommand = _extends({}, commandStart); // convert M to L + + + if (copyCommand.type === 'M') { + copyCommand.type = 'L'; + } + + segments = segments.concat(arrayOfLength(segmentCount - 1).map(function () { + return copyCommand; + })); + segments.push(commandEnd); + } + + return segments; +} +/** + * Extends an array of commandsToExtend to the length of the referenceCommands by + * splitting segments until the number of commands match. Ensures all the actual + * points of commandsToExtend are in the extended array. + * + * @param {Object[]} commandsToExtend The command object array to extend + * @param {Object[]} referenceCommands The command object array to match in length + * @param {Function} excludeSegment a function that takes a start command object and + * end command object and returns true if the segment should be excluded from splitting. + * @return {Object[]} The extended commandsToExtend array + */ + + +function extend(commandsToExtend, referenceCommands, excludeSegment) { + // compute insertion points: + // number of segments in the path to extend + var numSegmentsToExtend = commandsToExtend.length - 1; // number of segments in the reference path. + + var numReferenceSegments = referenceCommands.length - 1; // this value is always between [0, 1]. + + var segmentRatio = numSegmentsToExtend / numReferenceSegments; // create a map, mapping segments in referenceCommands to how many points + // should be added in that segment (should always be >= 1 since we need each + // point itself). + // 0 = segment 0-1, 1 = segment 1-2, n-1 = last vertex + + var countPointsPerSegment = arrayOfLength(numReferenceSegments).reduce(function (accum, d, i) { + var insertIndex = Math.floor(segmentRatio * i); // handle excluding segments + + if (excludeSegment && insertIndex < commandsToExtend.length - 1 && excludeSegment(commandsToExtend[insertIndex], commandsToExtend[insertIndex + 1])) { + // set the insertIndex to the segment that this point should be added to: + // round the insertIndex essentially so we split half and half on + // neighbouring segments. hence the segmentRatio * i < 0.5 + var addToPriorSegment = segmentRatio * i % 1 < 0.5; // only skip segment if we already have 1 point in it (can't entirely remove a segment) + + if (accum[insertIndex]) { + // TODO - Note this is a naive algorithm that should work for most d3-area use cases + // but if two adjacent segments are supposed to be skipped, this will not perform as + // expected. Could be updated to search for nearest segment to place the point in, but + // will only do that if necessary. + // add to the prior segment + if (addToPriorSegment) { + if (insertIndex > 0) { + insertIndex -= 1; // not possible to add to previous so adding to next + } else if (insertIndex < commandsToExtend.length - 1) { + insertIndex += 1; + } // add to next segment + + } else if (insertIndex < commandsToExtend.length - 1) { + insertIndex += 1; // not possible to add to next so adding to previous + } else if (insertIndex > 0) { + insertIndex -= 1; + } + } + } + + accum[insertIndex] = (accum[insertIndex] || 0) + 1; + return accum; + }, []); // extend each segment to have the correct number of points for a smooth interpolation + + var extended = countPointsPerSegment.reduce(function (extended, segmentCount, i) { + // if last command, just add `segmentCount` number of times + if (i === commandsToExtend.length - 1) { + var lastCommandCopies = arrayOfLength(segmentCount, _extends({}, commandsToExtend[commandsToExtend.length - 1])); // convert M to L + + if (lastCommandCopies[0].type === 'M') { + lastCommandCopies.forEach(function (d) { + d.type = 'L'; + }); + } + + return extended.concat(lastCommandCopies); + } // otherwise, split the segment segmentCount times. + + + return extended.concat(splitSegment(commandsToExtend[i], commandsToExtend[i + 1], segmentCount)); + }, []); // add in the very first point since splitSegment only adds in the ones after it + + extended.unshift(commandsToExtend[0]); + return extended; +} +/** + * Takes a path `d` string and converts it into an array of command + * objects. Drops the `Z` character. + * + * @param {String|null} d A path `d` string + */ + + +function pathCommandsFromString(d) { + // split into valid tokens + var tokens = (d || '').match(commandTokenRegex) || []; + var commands = []; + var commandArgs; + var command; // iterate over each token, checking if we are at a new command + // by presence in the typeMap + + for (var i = 0; i < tokens.length; ++i) { + commandArgs = typeMap[tokens[i]]; // new command found: + + if (commandArgs) { + command = { + type: tokens[i] + }; // add each of the expected args for this command: + + for (var a = 0; a < commandArgs.length; ++a) { + command[commandArgs[a]] = +tokens[i + a + 1]; + } // need to increment our token index appropriately since + // we consumed token args + + + i += commandArgs.length; + commands.push(command); + } + } + + return commands; +} +/** + * Interpolate from A to B by extending A and B during interpolation to have + * the same number of points. This allows for a smooth transition when they + * have a different number of points. + * + * Ignores the `Z` command in paths unless both A and B end with it. + * + * This function works directly with arrays of command objects instead of with + * path `d` strings (see interpolatePath for working with `d` strings). + * + * @param {Object[]} aCommandsInput Array of path commands + * @param {Object[]} bCommandsInput Array of path commands + * @param {(Function|Object)} interpolateOptions + * @param {Function} interpolateOptions.excludeSegment a function that takes a start command object and + * end command object and returns true if the segment should be excluded from splitting. + * @param {Boolean} interpolateOptions.snapEndsToInput a boolean indicating whether end of input should + * be sourced from input argument or computed. + * @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands. + */ + +function interpolatePathCommands(aCommandsInput, bCommandsInput, interpolateOptions) { + // make a copy so we don't mess with the input arrays + var aCommands = aCommandsInput == null ? [] : aCommandsInput.slice(); + var bCommands = bCommandsInput == null ? [] : bCommandsInput.slice(); + + var _ref = _typeof(interpolateOptions) === 'object' ? interpolateOptions : { + excludeSegment: interpolateOptions, + snapEndsToInput: true + }, + excludeSegment = _ref.excludeSegment, + snapEndsToInput = _ref.snapEndsToInput; // both input sets are empty, so we don't interpolate + + + if (!aCommands.length && !bCommands.length) { + return function nullInterpolator() { + return []; + }; + } // do we add Z during interpolation? yes if both have it. (we'd expect both to have it or not) + + + var addZ = (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') && (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z'); // we temporarily remove Z + + if (aCommands.length > 0 && aCommands[aCommands.length - 1].type === 'Z') { + aCommands.pop(); + } + + if (bCommands.length > 0 && bCommands[bCommands.length - 1].type === 'Z') { + bCommands.pop(); + } // if A is empty, treat it as if it used to contain just the first point + // of B. This makes it so the line extends out of from that first point. + + + if (!aCommands.length) { + aCommands.push(bCommands[0]); // otherwise if B is empty, treat it as if it contains the first point + // of A. This makes it so the line retracts into the first point. + } else if (!bCommands.length) { + bCommands.push(aCommands[0]); + } // extend to match equal size + + + var numPointsToExtend = Math.abs(bCommands.length - aCommands.length); + + if (numPointsToExtend !== 0) { + // B has more points than A, so add points to A before interpolating + if (bCommands.length > aCommands.length) { + aCommands = extend(aCommands, bCommands, excludeSegment); // else if A has more points than B, add more points to B + } else if (bCommands.length < aCommands.length) { + bCommands = extend(bCommands, aCommands, excludeSegment); + } + } // commands have same length now. + // convert commands in A to the same type as those in B + + + aCommands = aCommands.map(function (aCommand, i) { + return convertToSameType(aCommand, bCommands[i]); + }); // create mutable interpolated command objects + + var interpolatedCommands = aCommands.map(function (aCommand) { + return _objectSpread2({}, aCommand); + }); + + if (addZ) { + interpolatedCommands.push({ + type: 'Z' + }); + aCommands.push({ + type: 'Z' + }); // required for when returning at t == 0 + } + + return function pathCommandInterpolator(t) { + // at 1 return the final value without the extensions used during interpolation + if (t === 1 && snapEndsToInput) { + return bCommandsInput == null ? [] : bCommandsInput; + } // work with aCommands directly since interpolatedCommands are mutated + + + if (t === 0) { + return aCommands; + } // interpolate the commands using the mutable interpolated command objs + + + for (var i = 0; i < interpolatedCommands.length; ++i) { + // if (interpolatedCommands[i].type === 'Z') continue; + var aCommand = aCommands[i]; + var bCommand = bCommands[i]; + var interpolatedCommand = interpolatedCommands[i]; + + var _iterator = _createForOfIteratorHelper(typeMap[interpolatedCommand.type]), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var arg = _step.value; + interpolatedCommand[arg] = (1 - t) * aCommand[arg] + t * bCommand[arg]; // do not use floats for flags (#27), round to integer + + if (arg === 'largeArcFlag' || arg === 'sweepFlag') { + interpolatedCommand[arg] = Math.round(interpolatedCommand[arg]); + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } + + return interpolatedCommands; + }; +} +/** @typedef InterpolateOptions */ + +/** + * Interpolate from A to B by extending A and B during interpolation to have + * the same number of points. This allows for a smooth transition when they + * have a different number of points. + * + * Ignores the `Z` character in paths unless both A and B end with it. + * + * @param {String} a The `d` attribute for a path + * @param {String} b The `d` attribute for a path + * @param {((command1, command2) => boolean|{ + * excludeSegment?: (command1, command2) => boolean; + * snapEndsToInput?: boolean + * })} interpolateOptions The excludeSegment function or an options object + * - interpolateOptions.excludeSegment a function that takes a start command object and + * end command object and returns true if the segment should be excluded from splitting. + * - interpolateOptions.snapEndsToInput a boolean indicating whether end of input should + * be sourced from input argument or computed. + * @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string. + */ + +function interpolatePath(a, b, interpolateOptions) { + var aCommands = pathCommandsFromString(a); + var bCommands = pathCommandsFromString(b); + + var _ref2 = _typeof(interpolateOptions) === 'object' ? interpolateOptions : { + excludeSegment: interpolateOptions, + snapEndsToInput: true + }, + excludeSegment = _ref2.excludeSegment, + snapEndsToInput = _ref2.snapEndsToInput; + + if (!aCommands.length && !bCommands.length) { + return function nullInterpolator() { + return ''; + }; + } + + var commandInterpolator = interpolatePathCommands(aCommands, bCommands, { + excludeSegment: excludeSegment, + snapEndsToInput: snapEndsToInput + }); + return function pathStringInterpolator(t) { + // at 1 return the final value without the extensions used during interpolation + if (t === 1 && snapEndsToInput) { + return b == null ? '' : b; + } + + var interpolatedCommands = commandInterpolator(t); // convert to a string (fastest concat: https://jsperf.com/join-concat/150) + + var interpolatedString = ''; + + var _iterator2 = _createForOfIteratorHelper(interpolatedCommands), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var interpolatedCommand = _step2.value; + interpolatedString += commandToString(interpolatedCommand); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + return interpolatedString; + }; +} + +exports.interpolatePath = interpolatePath; +exports.interpolatePathCommands = interpolatePathCommands; +exports.pathCommandsFromString = pathCommandsFromString; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/src/fit-curve.js b/src/fit-curve.js new file mode 100644 index 0000000..d0aa229 --- /dev/null +++ b/src/fit-curve.js @@ -0,0 +1,606 @@ + + +/** + * @preserve JavaScript implementation of + * Algorithm for Automatically Fitting Digitized Curves + * by Philip J. Schneider + * "Graphics Gems", Academic Press, 1990 + * + * The MIT License (MIT) + * + * https://github.com/soswow/fit-curves + */ + +/** + * Fit one or more Bezier curves to a set of points. + * + * @param {Array>} points - Array of digitized points, e.g. [[5,5],[5,50],[110,140],[210,160],[320,110]] + * @param {Number} maxError - Tolerance, squared error between points and fitted curve + * @returns {Array>>} Array of Bezier curves, where each element is [first-point, control-point-1, control-point-2, second-point] and points are [x, y] + */ +export function fitCurve(points, maxError, progressCallback) { + if (!Array.isArray(points)) { + throw new TypeError("First argument should be an array"); + } + points.forEach(function (point) { + if (!Array.isArray(point) || point.some(function (item) { + return typeof item !== 'number'; + }) || point.length !== points[0].length) { + throw Error("Each point should be an array of numbers. Each point should have the same amount of numbers."); + } + }); + + // Remove duplicate points + points = points.filter(function (point, i) { + return i === 0 || !point.every(function (val, j) { + return val === points[i - 1][j]; + }); + }); + + if (points.length < 2) { + return []; + } + + var len = points.length; + var leftTangent = createTangent(points[1], points[0]); + var rightTangent = createTangent(points[len - 2], points[len - 1]); + + return fitCubic(points, leftTangent, rightTangent, maxError, progressCallback); +} + +/** + * Fit a Bezier curve to a (sub)set of digitized points. + * Your code should not call this function directly. Use {@link fitCurve} instead. + * + * @param {Array>} points - Array of digitized points, e.g. [[5,5],[5,50],[110,140],[210,160],[320,110]] + * @param {Array} leftTangent - Unit tangent vector at start point + * @param {Array} rightTangent - Unit tangent vector at end point + * @param {Number} error - Tolerance, squared error between points and fitted curve + * @returns {Array>>} Array of Bezier curves, where each element is [first-point, control-point-1, control-point-2, second-point] and points are [x, y] + */ +function fitCubic(points, leftTangent, rightTangent, error, progressCallback) { + var MaxIterations = 20; //Max times to try iterating (to find an acceptable curve) + + var bezCurve, //Control points of fitted Bezier curve + u, //Parameter values for point + uPrime, //Improved parameter values + maxError, prevErr, //Maximum fitting error + splitPoint, prevSplit, //Point to split point set at if we need more than one curve + centerVector, toCenterTangent, fromCenterTangent, //Unit tangent vector(s) at splitPoint + beziers, //Array of fitted Bezier curves if we need more than one curve + dist, i; + + //console.log('fitCubic, ', points.length); + + //Use heuristic if region only has two points in it + if (points.length === 2) { + dist = maths.vectorLen(maths.subtract(points[0], points[1])) / 3.0; + bezCurve = [points[0], maths.addArrays(points[0], maths.mulItems(leftTangent, dist)), maths.addArrays(points[1], maths.mulItems(rightTangent, dist)), points[1]]; + return [bezCurve]; + } + + //Parameterize points, and attempt to fit curve + u = chordLengthParameterize(points); + + var _generateAndReport = generateAndReport(points, u, u, leftTangent, rightTangent, progressCallback); + + bezCurve = _generateAndReport[0]; + maxError = _generateAndReport[1]; + splitPoint = _generateAndReport[2]; + + + if (maxError === 0 || maxError < error) { + return [bezCurve]; + } + //If error not too large, try some reparameterization and iteration + if (maxError < error * error) { + + uPrime = u; + prevErr = maxError; + prevSplit = splitPoint; + + for (i = 0; i < MaxIterations; i++) { + + uPrime = reparameterize(bezCurve, points, uPrime); + + var _generateAndReport2 = generateAndReport(points, u, uPrime, leftTangent, rightTangent, progressCallback); + + bezCurve = _generateAndReport2[0]; + maxError = _generateAndReport2[1]; + splitPoint = _generateAndReport2[2]; + + + if (maxError < error) { + return [bezCurve]; + } + //If the development of the fitted curve grinds to a halt, + //we abort this attempt (and try a shorter curve): + else if (splitPoint === prevSplit) { + var errChange = maxError / prevErr; + if (errChange > .9999 && errChange < 1.0001) { + break; + } + } + + prevErr = maxError; + prevSplit = splitPoint; + } + } + + //Fitting failed -- split at max error point and fit recursively + beziers = []; + + //To create a smooth transition from one curve segment to the next, we + //calculate the line between the points directly before and after the + //center, and use that as the tangent both to and from the center point. + centerVector = maths.subtract(points[splitPoint - 1], points[splitPoint + 1]); + //However, this won't work if they're the same point, because the line we + //want to use as a tangent would be 0. Instead, we calculate the line from + //that "double-point" to the center point, and use its tangent. + if (centerVector.every(function (val) { + return val === 0; + })) { + //[x,y] -> [-y,x]: http://stackoverflow.com/a/4780141/1869660 + centerVector = maths.subtract(points[splitPoint - 1], points[splitPoint]); + var _ref = [-centerVector[1], centerVector[0]]; + centerVector[0] = _ref[0]; + centerVector[1] = _ref[1]; + } + toCenterTangent = maths.normalize(centerVector); + //To and from need to point in opposite directions: + fromCenterTangent = maths.mulItems(toCenterTangent, -1); + + /* + Note: An alternative to this "divide and conquer" recursion could be to always + let new curve segments start by trying to go all the way to the end, + instead of only to the end of the current subdivided polyline. + That might let many segments fit a few points more, reducing the number of total segments. + However, a few tests have shown that the segment reduction is insignificant + (240 pts, 100 err: 25 curves vs 27 curves. 140 pts, 100 err: 17 curves on both), + and the results take twice as many steps and milliseconds to finish, + without looking any better than what we already have. + */ + beziers = beziers.concat(fitCubic(points.slice(0, splitPoint + 1), leftTangent, toCenterTangent, error, progressCallback)); + beziers = beziers.concat(fitCubic(points.slice(splitPoint), fromCenterTangent, rightTangent, error, progressCallback)); + return beziers; +}; + +function generateAndReport(points, paramsOrig, paramsPrime, leftTangent, rightTangent, progressCallback) { + var bezCurve, maxError, splitPoint; + + bezCurve = generateBezier(points, paramsPrime, leftTangent, rightTangent, progressCallback); + //Find max deviation of points to fitted curve. + //Here we always use the original parameters (from chordLengthParameterize()), + //because we need to compare the current curve to the actual source polyline, + //and not the currently iterated parameters which reparameterize() & generateBezier() use, + //as those have probably drifted far away and may no longer be in ascending order. + + var _computeMaxError = computeMaxError(points, bezCurve, paramsOrig); + + maxError = _computeMaxError[0]; + splitPoint = _computeMaxError[1]; + + + if (progressCallback) { + progressCallback({ + bez: bezCurve, + points: points, + params: paramsOrig, + maxErr: maxError, + maxPoint: splitPoint + }); + } + + return [bezCurve, maxError, splitPoint]; +} + +/** + * Use least-squares method to find Bezier control points for region. + * + * @param {Array>} points - Array of digitized points + * @param {Array} parameters - Parameter values for region + * @param {Array} leftTangent - Unit tangent vector at start point + * @param {Array} rightTangent - Unit tangent vector at end point + * @returns {Array>} Approximated Bezier curve: [first-point, control-point-1, control-point-2, second-point] where points are [x, y] + */ +function generateBezier(points, parameters, leftTangent, rightTangent) { + var bezCurve, + //Bezier curve ctl pts + A, + a, + //Precomputed rhs for eqn + C, + X, + //Matrices C & X + det_C0_C1, + det_C0_X, + det_X_C1, + //Determinants of matrices + alpha_l, + alpha_r, + //Alpha values, left and right + + epsilon, + segLength, + i, + len, + tmp, + u, + ux, + firstPoint = points[0], + lastPoint = points[points.length - 1]; + + bezCurve = [firstPoint, null, null, lastPoint]; + //console.log('gb', parameters.length); + + //Compute the A's + A = maths.zeros_Xx2x2(parameters.length); + for (i = 0, len = parameters.length; i < len; i++) { + u = parameters[i]; + ux = 1 - u; + a = A[i]; + + a[0] = maths.mulItems(leftTangent, 3 * u * (ux * ux)); + a[1] = maths.mulItems(rightTangent, 3 * ux * (u * u)); + } + + //Create the C and X matrices + C = [[0, 0], [0, 0]]; + X = [0, 0]; + for (i = 0, len = points.length; i < len; i++) { + u = parameters[i]; + a = A[i]; + + C[0][0] += maths.dot(a[0], a[0]); + C[0][1] += maths.dot(a[0], a[1]); + C[1][0] += maths.dot(a[0], a[1]); + C[1][1] += maths.dot(a[1], a[1]); + + tmp = maths.subtract(points[i], bezier.q([firstPoint, firstPoint, lastPoint, lastPoint], u)); + + X[0] += maths.dot(a[0], tmp); + X[1] += maths.dot(a[1], tmp); + } + + //Compute the determinants of C and X + det_C0_C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1]; + det_C0_X = C[0][0] * X[1] - C[1][0] * X[0]; + det_X_C1 = X[0] * C[1][1] - X[1] * C[0][1]; + + //Finally, derive alpha values + alpha_l = det_C0_C1 === 0 ? 0 : det_X_C1 / det_C0_C1; + alpha_r = det_C0_C1 === 0 ? 0 : det_C0_X / det_C0_C1; + + //If alpha negative, use the Wu/Barsky heuristic (see text). + //If alpha is 0, you get coincident control points that lead to + //divide by zero in any subsequent NewtonRaphsonRootFind() call. + segLength = maths.vectorLen(maths.subtract(firstPoint, lastPoint)); + epsilon = 1.0e-6 * segLength; + if (alpha_l < epsilon || alpha_r < epsilon) { + //Fall back on standard (probably inaccurate) formula, and subdivide further if needed. + bezCurve[1] = maths.addArrays(firstPoint, maths.mulItems(leftTangent, segLength / 3.0)); + bezCurve[2] = maths.addArrays(lastPoint, maths.mulItems(rightTangent, segLength / 3.0)); + } else { + //First and last control points of the Bezier curve are + //positioned exactly at the first and last data points + //Control points 1 and 2 are positioned an alpha distance out + //on the tangent vectors, left and right, respectively + bezCurve[1] = maths.addArrays(firstPoint, maths.mulItems(leftTangent, alpha_l)); + bezCurve[2] = maths.addArrays(lastPoint, maths.mulItems(rightTangent, alpha_r)); + } + + return bezCurve; +}; + +/** + * Given set of points and their parameterization, try to find a better parameterization. + * + * @param {Array>} bezier - Current fitted curve + * @param {Array>} points - Array of digitized points + * @param {Array} parameters - Current parameter values + * @returns {Array} New parameter values + */ +function reparameterize(bezier, points, parameters) { + /* + var j, len, point, results, u; + results = []; + for (j = 0, len = points.length; j < len; j++) { + point = points[j], u = parameters[j]; + results.push(newtonRaphsonRootFind(bezier, point, u)); + } + return results; + //*/ + return parameters.map(function (p, i) { + return newtonRaphsonRootFind(bezier, points[i], p); + }); +}; + +/** + * Use Newton-Raphson iteration to find better root. + * + * @param {Array>} bez - Current fitted curve + * @param {Array} point - Digitized point + * @param {Number} u - Parameter value for "P" + * @returns {Number} New u + */ +function newtonRaphsonRootFind(bez, point, u) { + /* + Newton's root finding algorithm calculates f(x)=0 by reiterating + x_n+1 = x_n - f(x_n)/f'(x_n) + We are trying to find curve parameter u for some point p that minimizes + the distance from that point to the curve. Distance point to curve is d=q(u)-p. + At minimum distance the point is perpendicular to the curve. + We are solving + f = q(u)-p * q'(u) = 0 + with + f' = q'(u) * q'(u) + q(u)-p * q''(u) + gives + u_n+1 = u_n - |q(u_n)-p * q'(u_n)| / |q'(u_n)**2 + q(u_n)-p * q''(u_n)| + */ + + var d = maths.subtract(bezier.q(bez, u), point), + qprime = bezier.qprime(bez, u), + numerator = maths.mulMatrix(d, qprime), + denominator = maths.sum(maths.squareItems(qprime)) + 2 * maths.mulMatrix(d, bezier.qprimeprime(bez, u)); + + if (denominator === 0) { + return u; + } else { + return u - numerator / denominator; + } +}; + +/** + * Assign parameter values to digitized points using relative distances between points. + * + * @param {Array>} points - Array of digitized points + * @returns {Array} Parameter values + */ +function chordLengthParameterize(points) { + var u = [], + currU, + prevU, + prevP; + + points.forEach(function (p, i) { + currU = i ? prevU + maths.vectorLen(maths.subtract(p, prevP)) : 0; + u.push(currU); + + prevU = currU; + prevP = p; + }); + u = u.map(function (x) { + return x / prevU; + }); + + return u; +}; + +/** + * Find the maximum squared distance of digitized points to fitted curve. + * + * @param {Array>} points - Array of digitized points + * @param {Array>} bez - Fitted curve + * @param {Array} parameters - Parameterization of points + * @returns {Array} Maximum error (squared) and point of max error + */ +function computeMaxError(points, bez, parameters) { + var dist, //Current error + maxDist, //Maximum error + splitPoint, //Point of maximum error + v, //Vector from point to curve + i, count, point, t; + + maxDist = 0; + splitPoint = Math.floor(points.length / 2); + + var t_distMap = mapTtoRelativeDistances(bez, 10); + + for (i = 0, count = points.length; i < count; i++) { + point = points[i]; + //Find 't' for a point on the bez curve that's as close to 'point' as possible: + t = find_t(bez, parameters[i], t_distMap, 10); + + v = maths.subtract(bezier.q(bez, t), point); + dist = v[0] * v[0] + v[1] * v[1]; + + if (dist > maxDist) { + maxDist = dist; + splitPoint = i; + } + } + + return [maxDist, splitPoint]; +}; + +//Sample 't's and map them to relative distances along the curve: +var mapTtoRelativeDistances = function mapTtoRelativeDistances(bez, B_parts) { + var B_t_curr; + var B_t_dist = [0]; + var B_t_prev = bez[0]; + var sumLen = 0; + + for (var i = 1; i <= B_parts; i++) { + B_t_curr = bezier.q(bez, i / B_parts); + + sumLen += maths.vectorLen(maths.subtract(B_t_curr, B_t_prev)); + + B_t_dist.push(sumLen); + B_t_prev = B_t_curr; + } + + //Normalize B_length to the same interval as the parameter distances; 0 to 1: + B_t_dist = B_t_dist.map(function (x) { + return x / sumLen; + }); + return B_t_dist; +}; + +function find_t(bez, param, t_distMap, B_parts) { + if (param < 0) { + return 0; + } + if (param > 1) { + return 1; + } + + /* + 'param' is a value between 0 and 1 telling us the relative position + of a point on the source polyline (linearly from the start (0) to the end (1)). + To see if a given curve - 'bez' - is a close approximation of the polyline, + we compare such a poly-point to the point on the curve that's the same + relative distance along the curve's length. + But finding that curve-point takes a little work: + There is a function "B(t)" to find points along a curve from the parametric parameter 't' + (also relative from 0 to 1: http://stackoverflow.com/a/32841764/1869660 + http://pomax.github.io/bezierinfo/#explanation), + but 't' isn't linear by length (http://gamedev.stackexchange.com/questions/105230). + So, we sample some points along the curve using a handful of values for 't'. + Then, we calculate the length between those samples via plain euclidean distance; + B(t) concentrates the points around sharp turns, so this should give us a good-enough outline of the curve. + Thus, for a given relative distance ('param'), we can now find an upper and lower value + for the corresponding 't' by searching through those sampled distances. + Finally, we just use linear interpolation to find a better value for the exact 't'. + More info: + http://gamedev.stackexchange.com/questions/105230/points-evenly-spaced-along-a-bezier-curve + http://stackoverflow.com/questions/29438398/cheap-way-of-calculating-cubic-bezier-length + http://steve.hollasch.net/cgindex/curves/cbezarclen.html + https://github.com/retuxx/tinyspline + */ + var lenMax, lenMin, tMax, tMin, t; + + //Find the two t-s that the current param distance lies between, + //and then interpolate a somewhat accurate value for the exact t: + for (var i = 1; i <= B_parts; i++) { + + if (param <= t_distMap[i]) { + tMin = (i - 1) / B_parts; + tMax = i / B_parts; + lenMin = t_distMap[i - 1]; + lenMax = t_distMap[i]; + + t = (param - lenMin) / (lenMax - lenMin) * (tMax - tMin) + tMin; + break; + } + } + return t; +} + +/** + * Creates a vector of length 1 which shows the direction from B to A + */ +function createTangent(pointA, pointB) { + return maths.normalize(maths.subtract(pointA, pointB)); +} + +/* + Simplified versions of what we need from math.js + Optimized for our input, which is only numbers and 1x2 arrays (i.e. [x, y] coordinates). +*/ + +var maths = function () { + function maths() { + _classCallCheck(this, maths); + } + + maths.zeros_Xx2x2 = function zeros_Xx2x2(x) { + var zs = []; + while (x--) { + zs.push([0, 0]); + } + return zs; + }; + + maths.mulItems = function mulItems(items, multiplier) { + return items.map(function (x) { + return x * multiplier; + }); + }; + + maths.mulMatrix = function mulMatrix(m1, m2) { + //https://en.wikipedia.org/wiki/Matrix_multiplication#Matrix_product_.28two_matrices.29 + //Simplified to only handle 1-dimensional matrices (i.e. arrays) of equal length: + return m1.reduce(function (sum, x1, i) { + return sum + x1 * m2[i]; + }, 0); + }; + + maths.subtract = function subtract(arr1, arr2) { + return arr1.map(function (x1, i) { + return x1 - arr2[i]; + }); + }; + + maths.addArrays = function addArrays(arr1, arr2) { + return arr1.map(function (x1, i) { + return x1 + arr2[i]; + }); + }; + + maths.addItems = function addItems(items, addition) { + return items.map(function (x) { + return x + addition; + }); + }; + + maths.sum = function sum(items) { + return items.reduce(function (sum, x) { + return sum + x; + }); + }; + + maths.dot = function dot(m1, m2) { + return maths.mulMatrix(m1, m2); + }; + + maths.vectorLen = function vectorLen(v) { + return Math.hypot.apply(Math, v); + }; + + maths.divItems = function divItems(items, divisor) { + return items.map(function (x) { + return x / divisor; + }); + }; + + maths.squareItems = function squareItems(items) { + return items.map(function (x) { + return x * x; + }); + }; + + maths.normalize = function normalize(v) { + return this.divItems(v, this.vectorLen(v)); + }; + + return maths; +}(); + +var bezier = function () { + function bezier() { + _classCallCheck(this, bezier); + } + + bezier.q = function q(ctrlPoly, t) { + var tx = 1.0 - t; + var pA = maths.mulItems(ctrlPoly[0], tx * tx * tx), + pB = maths.mulItems(ctrlPoly[1], 3 * tx * tx * t), + pC = maths.mulItems(ctrlPoly[2], 3 * tx * t * t), + pD = maths.mulItems(ctrlPoly[3], t * t * t); + return maths.addArrays(maths.addArrays(pA, pB), maths.addArrays(pC, pD)); + }; + + bezier.qprime = function qprime(ctrlPoly, t) { + var tx = 1.0 - t; + var pA = maths.mulItems(maths.subtract(ctrlPoly[1], ctrlPoly[0]), 3 * tx * tx), + pB = maths.mulItems(maths.subtract(ctrlPoly[2], ctrlPoly[1]), 6 * tx * t), + pC = maths.mulItems(maths.subtract(ctrlPoly[3], ctrlPoly[2]), 3 * t * t); + return maths.addArrays(maths.addArrays(pA, pB), pC); + }; + + bezier.qprimeprime = function qprimeprime(ctrlPoly, t) { + return maths.addArrays(maths.mulItems(maths.addArrays(maths.subtract(ctrlPoly[2], maths.mulItems(ctrlPoly[1], 2)), ctrlPoly[0]), 6 * (1.0 - t)), maths.mulItems(maths.addArrays(maths.subtract(ctrlPoly[3], maths.mulItems(ctrlPoly[2], 2)), ctrlPoly[1]), 6 * t)); + }; + + return bezier; +}(); diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..c2f3171 --- /dev/null +++ b/src/index.html @@ -0,0 +1,48 @@ + + + + + + + + + Tauri App + + + + + + + + + + + +
+ + +
+ + + diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..705847b --- /dev/null +++ b/src/main.js @@ -0,0 +1,2426 @@ +const { invoke } = window.__TAURI__.core; +import * as fitCurve from '/fit-curve.js'; +import { Bezier } from "/bezier.js"; +import { Quadtree } from './quadtree.js'; +import { createNewFileDialog, showNewFileDialog, closeDialog } from './newfile.js'; +import { titleCase, getMousePositionFraction, getKeyframesSurrounding, invertPixels } from './utils.js'; +const { writeTextFile: writeTextFile, readTextFile: readTextFile }= window.__TAURI__.fs; +const { + open: openFileDialog, + save: saveFileDialog, + message: messageDialog, + confirm: confirmDialog, +} = window.__TAURI__.dialog; +const { documentDir, join } = window.__TAURI__.path; +const { Menu, MenuItem, Submenu } = window.__TAURI__.menu ; +const { getCurrentWindow } = window.__TAURI__.window; + + +const macOS = navigator.userAgent.includes('Macintosh') + +let simplifyPolyline = simplify + +let greetInputEl; +let greetMsgEl; +let rootPane; + +let canvases = []; + +let mode = "draw" + +let minSegmentSize = 5; +let maxSmoothAngle = 0.6; + +let undoStack = []; +let redoStack = []; + +let layoutElements = [] + +let appVersion = "0.6.1-alpha" +let minFileVersion = "1.0" +let maxFileVersion = "2.0" + +let filePath = undefined +let fileWidth = 1500 +let fileHeight = 1000 +let fileFps = 12 + +let playing = false + +let tools = { + select: { + icon: "/assets/select.svg", + properties: {} + + }, + transform: { + icon: "/assets/transform.svg", + properties: {} + + }, + draw: { + icon: "/assets/draw.svg", + properties: { + "lineWidth": { + type: "number", + label: "Line Width" + }, + "simplifyMode": { + type: "enum", + options: ["corners", "smooth"], // "auto"], + label: "Line Mode" + }, + "fillShape": { + type: "boolean", + label: "Fill Shape" + } + } + }, + rectangle: { + icon: "/assets/rectangle.svg", + properties: {} + }, + ellipse: { + icon: "assets/ellipse.svg", + properties: {} + }, + paint_bucket: { + icon: "/assets/paint_bucket.svg", + properties: {} + } +} + +let mouseEvent; + +let context = { + mouseDown: false, + swatches: [ + "#000000", + "#FFFFFF", + "#FF0000", + "#FFFF00", + "#00FF00", + "#00FFFF", + "#0000FF", + "#FF00FF", + ], + lineWidth: 5, + simplifyMode: "smooth", + fillShape: true, + strokeShape: true, + dragging: false, + selectionRect: undefined, + selection: [], + shapeselection: [], +} + +let config = { + shortcuts: { + playAnimation: " ", + // undo: "+z" + undo: "z", + redo: "Z", + new: "n", + save: "s", + saveAs: "S", + open: "o", + quit: "q", + group: "g", + } +} + +// Pointers to all objects +let pointerList = {} +// Keeping track of initial values of variables when we edit them continuously +let startProps = {} + +let actions = { + addShape: { + create: (parent, shape) => { + redoStack.length = 0; // Clear redo stack + let serializableCurves = [] + for (let curve of shape.curves) { + serializableCurves.push({ points: curve.points, color: curve.color }) + } + let action = { + parent: parent.idx, + curves: serializableCurves, + startx: shape.startx, + starty: shape.starty, + uuid: uuidv4() + } + undoStack.push({name: "addShape", action: action}) + actions.addShape.execute(action) + }, + execute: (action) => { + let object = pointerList[action.parent] + let curvesList = action.curves + let shape = new Shape(action.startx, action.starty, context, action.uuid) + for (let curve of curvesList) { + shape.addCurve(new Bezier( + curve.points[0].x, curve.points[0].y, + curve.points[1].x, curve.points[1].y, + curve.points[2].x, curve.points[2].y, + curve.points[3].x, curve.points[3].y + ).setColor(curve.color)) + } + shape.update() + object.addShape(shape) + }, + rollback: (action) => { + let object = pointerList[action.parent] + let shape = pointerList[action.uuid] + object.removeShape(shape) + delete pointerList[action.uuid] + } + }, + editShape: { + create: (shape, newCurves) => { + redoStack.length = 0; // Clear redo stack + let serializableNewCurves = [] + for (let curve of newCurves) { + serializableNewCurves.push({ points: curve.points, color: curve.color }) + } + let serializableOldCurves = [] + for (let curve of shape.curves) { + serializableOldCurves.push({ points: curve.points }) + } + let action = { + shape: shape.idx, + oldCurves: serializableOldCurves, + newCurves: serializableNewCurves + } + undoStack.push({name: "editShape", action: action}) + actions.editShape.execute(action) + + }, + execute: (action) => { + let shape = pointerList[action.shape] + let curvesList = action.newCurves + shape.curves = [] + for (let curve of curvesList) { + shape.addCurve(new Bezier( + curve.points[0].x, curve.points[0].y, + curve.points[1].x, curve.points[1].y, + curve.points[2].x, curve.points[2].y, + curve.points[3].x, curve.points[3].y + ).setColor(curve.color)) + } + shape.update() + }, + rollback: (action) => { + let shape = pointerList[action.shape] + let curvesList = action.oldCurves + shape.curves = [] + for (let curve of curvesList) { + shape.addCurve(new Bezier( + curve.points[0].x, curve.points[0].y, + curve.points[1].x, curve.points[1].y, + curve.points[2].x, curve.points[2].y, + curve.points[3].x, curve.points[3].y + ).setColor(curve.color)) + } + shape.update() + } + }, + colorRegion: { + create: (region, color) => { + redoStack.length = 0; // Clear redo stack + let action = { + region: region.idx, + oldColor: region.fillStyle, + newColor: color + } + undoStack.push({name: "colorRegion", action: action}) + actions.colorRegion.execute(action) + }, + execute: (action) => { + let region = pointerList[action.region] + region.fillStyle = action.newColor + }, + rollback: (action) => { + let region = pointerList[action.region] + region.fillStyle = action.oldColor + } + }, + addImageObject: { + create: (x, y, imgsrc, ix, parent) => { + redoStack.length = 0; // Clear redo stack + let action = { + shapeUuid: uuidv4(), + objectUuid: uuidv4(), + x: x, + y: y, + src: imgsrc, + ix: ix, + parent: parent.idx + + } + undoStack.push({name: "addImageObject", action: action}) + actions.addImageObject.execute(action) + }, + execute: (action) => { + let imageObject = new GraphicsObject(action.objectUuid) + // let img = pointerList[action.img] + let img = new Image(); + img.onload = function() { + let ct = { + ...context, + fillImage: img, + strokeShape: false, + } + let imageShape = new Shape(0, 0, ct, action.shapeUuid) + imageShape.addLine(img.width, 0) + imageShape.addLine(img.width, img.height) + imageShape.addLine(0, img.height) + imageShape.addLine(0, 0) + imageShape.update() + imageShape.regions[0].fillImage = img + imageShape.regions[0].filled = true + imageObject.addShape(imageShape) + let parent = pointerList[action.parent] + parent.addObject( + imageObject, + action.x-img.width/2 + (20*action.ix), + action.y-img.height/2 + (20*action.ix) + ) + updateUI(); + } + img.src = action.src + }, + rollback: (action) => { + let shape = pointerList[action.shapeUuid] + let object = pointerList[action.objectUuid] + let parent = pointerList[action.parent] + object.removeShape(shape) + delete pointerList[action.shapeUuid] + parent.removeChild(object) + delete pointerList[action.objectUuid] + let selectIndex = context.selection.indexOf(object) + if (selectIndex >= 0) { + context.selection.splice(selectIndex, 1) + } + } + }, + editFrame: { + create: (frame) => { + redoStack.length = 0; // Clear redo stack + let action = { + newState: structuredClone(frame.keys), + oldState: startProps[frame.idx], + frame: frame.idx + } + undoStack.push({name: "editFrame", action: action}) + actions.editFrame.execute(action) + }, + execute: (action) => { + let frame = pointerList[action.frame] + console.log(pointerList) + console.log(action.frame) + frame.keys = structuredClone(action.newState) + }, + rollback: (action) => { + let frame = pointerList[action.frame] + frame.keys = structuredClone(action.oldState) + } + }, + addFrame: { + create: () => { + redoStack.length = 0 + let frames = [] + for (let i=context.activeObject.activeLayer.frames.length; i<=context.activeObject.currentFrameNum; i++) { + frames.push(uuidv4()) + } + let action = { + frames: frames, + layer: context.activeObject.activeLayer.idx + } + undoStack.push({name: 'addFrame', action: action}) + actions.addFrame.execute(action) + }, + execute: (action) => { + let layer = pointerList[action.layer] + for (let frame of action.frames) { + layer.frames.push(new Frame("normal", frame)) + } + updateLayers() + }, + rollback: (action) => { + let layer = pointerList[action.layer] + for (let _frame of action.frames) { + layer.frames.pop() + } + updateLayers() + } + }, + addKeyframe: { + create: () => { + let frameNum = context.activeObject.currentFrameNum + let layer = context.activeObject.activeLayer + let formerType; + let addedFrames = {}; + if (frameNum >= layer.frames.length) { + formerType = "none" + for (let i=layer.frames.length; i<=frameNum; i++) { + addedFrames[i] = uuidv4() + } + } else if (layer.frames[frameNum].frameType != "keyframe") { + formerType = layer.frames[frameNum].frameType + } else { + console.log("foolish") + return // Already a keyframe, nothing to do + } + redoStack.length = 0 + let action = { + frameNum: frameNum, + object: context.activeObject.idx, + layer: layer.idx, + formerType: formerType, + addedFrames: addedFrames, + uuid: uuidv4() + } + undoStack.push({name: 'addKeyframe', action: action}) + actions.addKeyframe.execute(action) + }, + execute: (action) => { + let object = pointerList[action.object] + let layer = pointerList[action.layer] + let latestFrame = object.getFrame(Math.max(action.frameNum-1, 0)) + let newKeyframe = new Frame("keyframe", action.uuid) + for (let key in latestFrame.keys) { + newKeyframe.keys[key] = structuredClone(latestFrame.keys[key]) + } + for (let shape of latestFrame.shapes) { + newKeyframe.shapes.push(shape.copy()) + } + if (action.frameNum >= layer.frames.length) { + for (const [index, idx] of Object.entries(action.addedFrames)) { + layer.frames[index] = new Frame("normal", idx) + } + } + // layer.frames.push(newKeyframe) + // } else if (layer.frames[action.frameNum].frameType != "keyframe") { + layer.frames[action.frameNum] = newKeyframe + // } + updateLayers() + }, + rollback: (action) => { + let layer = pointerList[action.layer] + if (action.formerType == "none") { + for (let i in action.addedFrames) { + layer.frames.pop() + } + } else { + let layer = pointerList[action.layer] + layer.frames[action.frameNum].frameType = action.formerType + } + updateLayers() + } + }, + addMotionTween: { + create: () => { + redoStack.length = 0 + let frameNum = context.activeObject.currentFrameNum + let layer = context.activeObject.activeLayer + let frames = layer.frames + let {lastKeyframeBefore, firstKeyframeAfter} = getKeyframesSurrounding(frames, frameNum) + + let action = { + frameNum: frameNum, + layer: layer.idx, + lastBefore: lastKeyframeBefore, + firstAfter: firstKeyframeAfter, + } + undoStack.push({name: 'addMotionTween', action: action}) + actions.addMotionTween.execute(action) + }, + execute: (action) => { + let layer = pointerList[action.layer] + let frames = layer.frames + if ((action.lastBefore != undefined) && (action.firstAfter != undefined)) { + for (let i=action.lastBefore + 1; i { + let layer = pointerList[action.layer] + let frames = layer.frames + for (let i=action.lastBefore + 1; i { + redoStack.length = 0 + let serializableShapes = [] + let serializableObjects = [] + for (let shape of context.shapeselection) { + serializableShapes.push(shape.idx) + } + for (let object of context.selection) { + serializableObjects.push(object.idx) + } + context.shapeselection = [] + context.selection = [] + let action = { + shapes: serializableShapes, + objects: serializableObjects, + groupUuid: uuidv4(), + parent: context.activeObject.idx + } + undoStack.push({name: 'group', action: action}) + actions.group.execute(action) + }, + execute: (action) => { + // your code here + let group = new GraphicsObject(action.groupUuid) + let parent = pointerList[action.parent] + for (let shapeIdx of action.shapes) { + let shape = pointerList[shapeIdx] + group.addShape(shape) + parent.removeShape(shape) + } + for (let objectIdx of action.objects) { + let object = pointerList[objectIdx] + group.addObject(object, object.x, object.y) + parent.removeChild(object) + } + parent.addObject(group) + if (context.activeObject==parent && context.selection.length==0 && context.shapeselection.length==0) { + context.selection.push(group) + } + updateUI() + }, + rollback: (action) => { + let group = pointerList[action.groupUuid] + let parent = pointerList[action.parent] + for (let shapeIdx of action.shapes) { + let shape = pointerList[shapeIdx] + parent.addShape(shape) + group.removeShape(shape) + } + for (let objectIdx of action.objects) { + let object = pointerList[objectIdx] + parent.addObject(object, object.x, object.y) + group.removeChild(object) + } + parent.removeChild(group) + updateUI() + } + }, +} + +function uuidv4() { + return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c => + (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16) + ); +} +function vectorDist(a, b) { + return Math.sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)) +} + +function getMousePos(canvas, evt) { + var rect = canvas.getBoundingClientRect(); + return { + x: evt.clientX - rect.left, + y: evt.clientY - rect.top + }; +} + +function getProperty(context, path) { + let pointer = context; + let pathComponents = path.split('.') + for (let component of pathComponents) { + pointer = pointer[component] + } + return pointer +} + +function setProperty(context, path, value) { + let pointer = context; + let pathComponents = path.split('.') + let finalComponent = pathComponents.pop() + for (let component of pathComponents) { + pointer = pointer[component] + } + pointer[finalComponent] = value +} + +function selectCurve(context, mouse) { + let mouseTolerance = 15; + let closestDist = mouseTolerance; + let closestCurve = undefined + let closestShape = undefined + for (let shape of context.activeObject.currentFrame.shapes) { + if (mouse.x > shape.boundingBox.x.min - mouseTolerance && + mouse.x < shape.boundingBox.x.max + mouseTolerance && + mouse.y > shape.boundingBox.y.min - mouseTolerance && + mouse.y < shape.boundingBox.y.max + mouseTolerance) { + for (let curve of shape.curves) { + let dist = vectorDist(mouse, curve.project(mouse)) + if (dist <= closestDist ) { + closestDist = dist + closestCurve = curve + closestShape = shape + } + } + } + } + if (closestCurve) { + return {curve:closestCurve, shape:closestShape} + } else { + return undefined + } +} +function selectVertex(context, mouse) { + let mouseTolerance = 15; + let closestDist = mouseTolerance; + let closestVertex = undefined + let closestShape = undefined + for (let shape of context.activeObject.currentFrame.shapes) { + if (mouse.x > shape.boundingBox.x.min - mouseTolerance && + mouse.x < shape.boundingBox.x.max + mouseTolerance && + mouse.y > shape.boundingBox.y.min - mouseTolerance && + mouse.y < shape.boundingBox.y.max + mouseTolerance) { + for (let vertex of shape.vertices) { + let dist = vectorDist(mouse, vertex.point) + if (dist <= closestDist ) { + closestDist = dist + closestVertex = vertex + closestShape = shape + } + } + } + } + if (closestVertex) { + return {vertex:closestVertex, shape:closestShape} + } else { + return undefined + } +} + +function moldCurve(curve, mouse, oldmouse) { + let diff = {x: mouse.x - oldmouse.x, y: mouse.y - oldmouse.y} + let p = curve.project(mouse) + let min_influence = 0.1 + const CP1 = { + x: curve.points[1].x + diff.x*(1-p.t)*2, + y: curve.points[1].y + diff.y*(1-p.t)*2 + } + const CP2 = { + x: curve.points[2].x + diff.x*(p.t)*2, + y: curve.points[2].y + diff.y*(p.t)*2 + } + return new Bezier(curve.points[0], CP1, CP2, curve.points[3]) + // return curve +} + + +function deriveControlPoints(S, A, E, e1, e2, t) { + // Deriving the control points is effectively "doing what + // we talk about in the section", in code: + + const v1 = { + x: A.x - (A.x - e1.x)/(1-t), + y: A.y - (A.y - e1.y)/(1-t) + }; + const v2 = { + x: A.x - (A.x - e2.x)/t, + y: A.y - (A.y - e2.y)/t + }; + + const C1 = { + x: S.x + (v1.x - S.x) / t, + y: S.y + (v1.y - S.y) / t + }; + const C2 = { + x: E.x + (v2.x - E.x) / (1-t), + y: E.y + (v2.y - E.y) / (1-t) + }; + + return {v1, v2, C1, C2}; +} + + +function growBoundingBox(bboxa, bboxb) { + bboxa.x.min = Math.min(bboxa.x.min, bboxb.x.min) + bboxa.y.min = Math.min(bboxa.y.min, bboxb.y.min) + bboxa.x.max = Math.max(bboxa.x.max, bboxb.x.max) + bboxa.y.max = Math.max(bboxa.y.max, bboxb.y.max) +} + +function regionToBbox(region) { + return { + x: {min: Math.min(region.x1, region.x2), max: Math.max(region.x1, region.x2)}, + y: {min: Math.min(region.y1, region.y2), max: Math.max(region.y1, region.y2)} + } +} + +function hitTest(candidate, object) { + let bbox = object.bbox() + if (candidate.x.min) { + // We're checking a bounding box + if (candidate.x.min < bbox.x.max && candidate.x.max > bbox.x.min && + candidate.y.min < bbox.y.max && candidate.y.max > bbox.y.min) { + return true; + } else { + return false; + } + } else { + // We're checking a point + if (candidate.x > bbox.x.min && + candidate.x < bbox.x.max && + candidate.y > bbox.y.min && + candidate.y < bbox.y.max) { + return true; + } else { + return false + } + } + +} + +function undo() { + let action = undoStack.pop() + if (action) { + actions[action.name].rollback(action.action) + redoStack.push(action) + updateUI() + } else { + console.log("No actions to undo") + } +} + +function redo() { + let action = redoStack.pop() + if (action) { + actions[action.name].execute(action.action) + undoStack.push(action) + updateUI() + } else { + console.log("No actions to redo") + } +} + + +class Frame { + constructor(frameType="normal", uuid=undefined) { + this.keys = {} + this.shapes = [] + this.frameType = frameType + if (!uuid) { + this.idx = uuidv4() + } else { + this.idx = uuid + } + pointerList[this.idx] = this + } + saveState() { + startProps[this.idx] = structuredClone(this.keys) + } +} + +class Layer { + constructor(uuid) { + this.frames = [new Frame("keyframe")] + this.children = [] + if (!uuid) { + this.idx = uuidv4() + } else { + this.idx = uuid + } + pointerList[this.idx] = this + } +} + +class Shape { + constructor(startx, starty, context, uuid=undefined) { + this.startx = startx; + this.starty = starty; + this.curves = []; + this.vertices = []; + this.triangles = []; + this.regions = []; + this.fillStyle = context.fillStyle; + this.fillImage = context.fillImage; + this.strokeStyle = context.strokeStyle; + this.lineWidth = context.lineWidth + this.filled = context.fillShape; + this.stroked = context.strokeShape; + this.boundingBox = { + x: {min: startx, max: starty}, + y: {min: starty, max: starty} + } + this.quadtree = new Quadtree({x: {min: 0, max: 500}, y: {min: 0, max: 500}}, 4) + if (!uuid) { + this.idx = uuidv4() + } else { + this.idx = uuid + } + pointerList[this.idx] = this + this.regionIdx = 0; + } + addCurve(curve) { + this.curves.push(curve) + this.quadtree.insert(curve, this.curves.length - 1) + growBoundingBox(this.boundingBox, curve.bbox()) + } + addLine(x, y) { + let lastpoint; + if (this.curves.length) { + lastpoint = this.curves[this.curves.length - 1].points[3] + } else { + lastpoint = {x: this.startx, y: this.starty} + } + let midpoint = {x: (x + lastpoint.x) / 2, y: (y + lastpoint.y) / 2} + let curve = new Bezier(lastpoint.x, lastpoint.y, + midpoint.x, midpoint.y, + midpoint.x, midpoint.y, + x, y) + curve.color = context.strokeStyle + this.curves.push(curve) + } + bbox() { + return this.boundingBox + } + clear() { + this.curves = [] + } + copy() { + let newShape = new Shape(this.startx, this.starty, {}) + newShape.startx = this.startx; + newShape.starty = this.starty; + for (let curve of this.curves) { + let newCurve = new Bezier( + curve.points[0].x, curve.points[0].y, + curve.points[1].x, curve.points[1].y, + curve.points[2].x, curve.points[2].y, + curve.points[3].x, curve.points[3].y, + ) + newCurve.color = curve.color + newShape.addCurve(newCurve) + } + // TODO + // for (let vertex of this.vertices) { + + // } + newShape.updateVertices() + newShape.fillStyle = this.fillStyle; + newShape.fillImage = this.fillImage; + newShape.strokeStyle = this.strokeStyle; + newShape.lineWidth = this.lineWidth + newShape.filled = this.filled; + newShape.stroked = this.stroked; + + return newShape + } + recalculateBoundingBox() { + for (let curve of this.curves) { + growBoundingBox(this.boundingBox, curve.bbox()) + } + } + simplify(mode="corners") { + this.quadtree.clear() + // Mode can be corners, smooth or auto + if (mode=="corners") { + let points = [{x: this.startx, y: this.starty}] + for (let curve of this.curves) { + points.push(curve.points[3]) + } + // points = points.concat(this.curves) + let newpoints = simplifyPolyline(points, 10, false) + this.curves = [] + let lastpoint = newpoints.shift() + let midpoint + for (let point of newpoints) { + midpoint = {x: (lastpoint.x+point.x)/2, y: (lastpoint.y+point.y)/2} + let bezier = new Bezier(lastpoint.x, lastpoint.y, + midpoint.x, midpoint.y, + midpoint.x,midpoint.y, + point.x,point.y) + this.curves.push(bezier) + this.quadtree.insert(bezier, this.curves.length - 1) + lastpoint = point + } + } else if (mode=="smooth") { + let error = 30; + let points = [[this.startx, this.starty]] + for (let curve of this.curves) { + points.push([curve.points[3].x, curve.points[3].y]) + } + this.curves = [] + let curves = fitCurve.fitCurve(points, error) + for (let curve of curves) { + let bezier = new Bezier(curve[0][0], curve[0][1], + curve[1][0],curve[1][1], + curve[2][0], curve[2][1], + curve[3][0], curve[3][1]) + this.curves.push(bezier) + this.quadtree.insert(bezier, this.curves.length - 1) + + } + } + let epsilon = 0.01 + let newCurves = [] + let intersectMap = {} + for (let i=0; i= j) continue; + let intersects = this.curves[i].intersects(this.curves[j]) + if (intersects.length) { + intersectMap[i] ||= [] + intersectMap[j] ||= [] + for(let intersect of intersects) { + let [t1, t2] = intersect.split("/") + intersectMap[i].push(parseFloat(t1)) + intersectMap[j].push(parseFloat(t2)) + } + } + } + } + for (let lst in intersectMap) { + for (let i=1; i=0; i--) { + if (i in intersectMap) { + intersectMap[i].sort().reverse() + let remainingFraction = 1 + let remainingCurve = this.curves[i] + for (let t of intersectMap[i]) { + let split = remainingCurve.split(t / remainingFraction) + remainingFraction = t + newCurves.push(split.right) + remainingCurve = split.left + } + newCurves.push(remainingCurve) + + } else { + newCurves.push(this.curves[i]) + } + } + for (let curve of newCurves) { + curve.color = context.strokeStyle + } + newCurves.reverse() + this.curves = newCurves + } + update() { + this.recalculateBoundingBox() + this.updateVertices() + if (this.curves.length) { + this.startx = this.curves[0].points[0].x + this.starty = this.curves[0].points[0].y + } + } + getClockwiseCurves(point, otherPoints) { + // Returns array of {x, y, idx, angle} + + let points = [] + for (let point of otherPoints) { + points.push({...this.vertices[point].point, idx: point}) + } + // Add an angle property to each point using tan(angle) = y/x + const angles = points.map(({ x, y, idx }) => { + return { x, y, idx, angle: Math.atan2(y - point.y, x - point.x) * 180 / Math.PI }; + }); + // Sort your points by angle + const pointsSorted = angles.sort((a, b) => a.angle - b.angle); + return pointsSorted + } + updateVertices() { + this.vertices = [] + let utils = Bezier.getUtils() + let epsilon = 1.5 // big epsilon whoa + let tooClose; + let i = 0; + + + let region = {idx: `${this.idx}-r${this.regionIdx++}`, curves: [], fillStyle: undefined, filled: false} + pointerList[region.idx] = region + this.regions = [region] + for (let curve of this.curves) { + this.regions[0].curves.push(curve) + } + if (this.regions[0].curves.length) { + if (utils.dist( + this.regions[0].curves[0].points[0], + this.regions[0].curves[this.regions[0].curves.length - 1].points[3] + ) < epsilon) { + this.regions[0].filled = true + } + } + + // Generate vertices + for (let curve of this.curves) { + for (let index of [0, 3]) { + tooClose = false + for (let vertex of this.vertices) { + if (utils.dist(curve.points[index], vertex.point) < epsilon){ + tooClose = true; + vertex[["startCurves",,,"endCurves"][index]][i] = curve + break + } + } + if (!tooClose) { + if (index==0) { + this.vertices.push({ + point:curve.points[index], + startCurves: {[i]:curve}, + endCurves: {} + }) + } else { + this.vertices.push({ + point:curve.points[index], + startCurves: {}, + endCurves: {[i]:curve} + }) + } + } + } + i++; + } + + this.vertices.forEach((vertex, i) => { + for (let i=0; i start) { + let newRegion = { + idx: `${this.idx}-r${this.regionIdx++}`, // TODO: generate this deterministically so that undo/redo works + curves: region.curves.splice(start, end - start), + fillStyle: region.fillStyle, + filled: true + } + pointerList[newRegion.idx] = newRegion + this.regions.push(newRegion) + } + } else { + // not sure how to handle vertices with more than 4 curves + console.log(`Unexpected vertex with ${Object.keys(vertexCurves).length} curves!`) + } + } + }) + } + draw(context) { + let ctx = context.ctx; + ctx.lineWidth = this.lineWidth + ctx.lineCap = "round" + for (let region of this.regions) { + // if (region.filled) continue; + if ((region.fillStyle || region.fillImage) && region.filled) { + // ctx.fillStyle = region.fill + if (region.fillImage) { + let pat = ctx.createPattern(region.fillImage, "no-repeat") + ctx.fillStyle = pat + } else { + ctx.fillStyle = region.fillStyle + } + ctx.beginPath() + for (let curve of region.curves) { + ctx.lineTo(curve.points[0].x, curve.points[0].y) + ctx.bezierCurveTo(curve.points[1].x, curve.points[1].y, + curve.points[2].x, curve.points[2].y, + curve.points[3].x, curve.points[3].y) + } + ctx.fill() + } + } + if (this.stroked) { + for (let curve of this.curves) { + ctx.strokeStyle = curve.color + ctx.beginPath() + ctx.moveTo(curve.points[0].x, curve.points[0].y) + ctx.bezierCurveTo(curve.points[1].x, curve.points[1].y, + curve.points[2].x, curve.points[2].y, + curve.points[3].x, curve.points[3].y) + ctx.stroke() + + // Debug, show curve endpoints + // ctx.beginPath() + // ctx.arc(curve.points[3].x,curve.points[3].y, 3, 0, 2*Math.PI) + // ctx.fill() + } + } + // Debug, show quadtree + // this.quadtree.draw(ctx) + + } +} + +class GraphicsObject { + constructor(uuid) { + this.x = 0; + this.y = 0; + this.rotation = 0; // in radians + this.scale = 1; + if (!uuid) { + this.idx = uuidv4() + } else { + this.idx = uuid + } + pointerList[this.idx] = this + + this.currentFrameNum = 0; + this.currentLayer = 0; + this.layers = [new Layer(uuid+"-L1")] + // this.children = [] + + this.shapes = [] + } + get activeLayer() { + return this.layers[this.currentLayer] + } + get children() { + return this.activeLayer.children + } + get currentFrame() { + return this.getFrame(this.currentFrameNum) + } + getFrame(num) { + if (this.activeLayer.frames[num]) { + if (this.activeLayer.frames[num].frameType == "keyframe") { + return this.activeLayer.frames[num] + } else if (this.activeLayer.frames[num].frameType == "motion") { + let frameKeys = {} + const t = (num - this.activeLayer.frames[num].prevIndex) / (this.activeLayer.frames[num].nextIndex - this.activeLayer.frames[num].prevIndex); + console.log(this.activeLayer.frames[num].prev) + for (let key in this.activeLayer.frames[num].prev.keys) { + frameKeys[key] = {} + let prevKeyDict = this.activeLayer.frames[num].prev.keys[key] + let nextKeyDict = this.activeLayer.frames[num].next.keys[key] + for (let prop in prevKeyDict) { + frameKeys[key][prop] = (1 - t) * prevKeyDict[prop] + t * nextKeyDict[prop]; + } + + } + let frame = new Frame("motion", "temp") + frame.keys = frameKeys + return frame + } else if (this.activeLayer.frames[num].frameType == "shape") { + + } else { + for (let i=Math.min(num, this.activeLayer.frames.length-1); i>=0; i--) { + if (this.activeLayer.frames[i].frameType == "keyframe") { + return this.activeLayer.frames[i] + } + } + } + } else { + for (let i=Math.min(num, this.activeLayer.frames.length-1); i>=0; i--) { + if (this.activeLayer.frames[i].frameType == "keyframe") { + return this.activeLayer.frames[i] + } + } + } + } + get maxFrame() { + let maxFrames = [] + for (let layer of this.layers) { + maxFrames.push(layer.frames.length) + } + return Math.max(maxFrames) + } + bbox() { + let bbox; + if (this.currentFrame.shapes.length > 0) { + bbox = structuredClone(this.currentFrame.shapes[0].boundingBox) + for (let shape of this.currentFrame.shapes) { + growBoundingBox(bbox, shape.boundingBox) + } + } + if (this.children.length > 0) { + if (!bbox) { + bbox = structuredClone(this.children[0].bbox()) + } + for (let child of this.children) { + growBoundingBox(bbox, child.bbox()) + } + } + bbox.x.min += this.x + bbox.x.max += this.x + bbox.y.min += this.y + bbox.y.max += this.y + console.log(bbox) + return bbox + } + draw(context) { + let ctx = context.ctx; + ctx.translate(this.x, this.y) + ctx.rotate(this.rotation) + // if (this.currentFrameNum>=this.maxFrame) { + // this.currentFrameNum = 0; + // } + for (let shape of this.currentFrame.shapes) { + if (context.shapeselection.indexOf(shape) >= 0) { + invertPixels(ctx, fileWidth, fileHeight) + } + shape.draw(context) + if (context.shapeselection.indexOf(shape) >= 0) { + invertPixels(ctx, fileWidth, fileHeight) + } + } + for (let child of this.children) { + let idx = child.idx + if (idx in this.currentFrame.keys) { + child.x = this.currentFrame.keys[idx].x; + child.y = this.currentFrame.keys[idx].y; + child.rotation = this.currentFrame.keys[idx].rotation; + child.scale = this.currentFrame.keys[idx].scale; + ctx.save() + child.draw(context) + if (true) { + + } + ctx.restore() + } + } + if (this == context.activeObject) { + if (context.activeCurve) { + ctx.strokeStyle = "magenta" + ctx.beginPath() + ctx.moveTo(context.activeCurve.current.points[0].x, context.activeCurve.current.points[0].y) + ctx.bezierCurveTo(context.activeCurve.current.points[1].x, context.activeCurve.current.points[1].y, + context.activeCurve.current.points[2].x, context.activeCurve.current.points[2].y, + context.activeCurve.current.points[3].x, context.activeCurve.current.points[3].y + ) + ctx.stroke() + } + if (context.activeVertex) { + ctx.save() + ctx.strokeStyle = "#00ffff" + let curves = {...context.activeVertex.current.startCurves, + ...context.activeVertex.current.endCurves + } + // I don't understand why I can't use a for...of loop here + for (let idx in curves) { + let curve = curves[idx] + ctx.beginPath() + ctx.moveTo(curve.points[0].x, curve.points[0].y) + ctx.bezierCurveTo( + curve.points[1].x,curve.points[1].y, + curve.points[2].x,curve.points[2].y, + curve.points[3].x,curve.points[3].y + ) + ctx.stroke() + } + ctx.fillStyle = "black" + ctx.beginPath() + let vertexSize = 15 + ctx.rect(context.activeVertex.current.point.x - vertexSize/2, + context.activeVertex.current.point.y - vertexSize/2, vertexSize, vertexSize + ) + ctx.fill() + ctx.restore() + } + for (let item of context.selection) { + ctx.save() + ctx.strokeStyle = "#00ffff" + ctx.lineWidth = 1; + ctx.beginPath() + let bbox = item.bbox() + ctx.rect(bbox.x.min, bbox.y.min, bbox.x.max - bbox.x.min, bbox.y.max - bbox.y.min) + ctx.stroke() + ctx.restore() + } + if (context.selectionRect) { + ctx.save() + ctx.strokeStyle = "#00ffff" + ctx.lineWidth = 1; + ctx.beginPath() + ctx.rect( + context.selectionRect.x1, context.selectionRect.y1, + context.selectionRect.x2 - context.selectionRect.x1, + context.selectionRect.y2 - context.selectionRect.y1 + ) + ctx.stroke() + ctx.restore() + } + } + } + addShape(shape) { + this.currentFrame.shapes.push(shape) + } + addObject(object, x=0, y=0) { + this.children.push(object) + let idx = object.idx + this.currentFrame.keys[idx] = { + x: x, + y: y, + rotation: 0, + scale: 1, + } + } + removeShape(shape) { + for (let layer of this.layers) { + for (let frame of layer.frames) { + let shapeIndex = frame.shapes.indexOf(shape) + if (shapeIndex >= 0) { + frame.shapes.splice(shapeIndex, 1) + } + } + } + } + removeChild(childObject) { + let idx = childObject.idx + for (let layer of this.layers) { + for (let frame of layer.frames) { + delete frame[idx] + } + } + this.children.splice(this.children.indexOf(childObject), 1) + } + saveState() { + startProps[this.idx] = { + x: this.x, + y: this.y, + rotation: this.rotation, + scale: this.scale + } + } +} + +let root = new GraphicsObject("root"); +context.activeObject = root + +async function greet() { + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value }); + +} + +window.addEventListener("DOMContentLoaded", () => { + rootPane = document.querySelector("#root") + rootPane.appendChild(createPane(panes.toolbar)) + rootPane.addEventListener("mousemove", (e) => { + mouseEvent = e; + }) + let [_toolbar, panel] = splitPane(rootPane, 10, true, createPane(panes.timeline)) + let [stageAndTimeline, _infopanel] = splitPane(panel, 70, false, createPane(panes.infopanel)) + let [_timeline, _stage] = splitPane(stageAndTimeline, 30, false, createPane(panes.stage)) +}); + +window.addEventListener("resize", () => { + updateAll() +}) + +window.addEventListener("click", function(event) { + const popupMenu = document.getElementById("popupMenu"); + + // If the menu exists and the click is outside the menu and any button with the class 'paneButton', remove the menu + if (popupMenu && !popupMenu.contains(event.target) && !event.target.classList.contains("paneButton")) { + popupMenu.remove(); // Remove the menu from the DOM + } +}) + +window.addEventListener("keydown", (e) => { + // let shortcuts = {} + // for (let shortcut of config.shortcuts) { + // shortcut = shortcut.split("+") + // TODO + // } + // console.log(e) + if (e.key == config.shortcuts.playAnimation) { + console.log("Spacebar pressed") + playPause() + } else if (e.key == config.shortcuts.new && e.ctrlKey == true) { + newFile() + } else if (e.key == config.shortcuts.save && e.ctrlKey == true) { + save() + } else if (e.key == config.shortcuts.saveAs && e.ctrlKey == true) { + saveAs() + } else if (e.key == config.shortcuts.open && e.ctrlKey == true) { + open() + } else if (e.key == config.shortcuts.quit && e.ctrlKey == true) { + quit() + } else if (e.key == config.shortcuts.undo && e.ctrlKey == true) { + undo() + } else if (e.key == config.shortcuts.redo && e.ctrlKey == true) { + redo() + } else if (e.key == config.shortcuts.group && e.ctrlKey == true) { + actions.group.create() + } + else if (e.key == "ArrowRight") { + advanceFrame() + } + else if (e.key == "ArrowLeft") { + decrementFrame() + } +}) + +function playPause() { + playing = !playing + updateUI() +} + +function advanceFrame() { + context.activeObject.currentFrameNum += 1 + updateLayers() + updateMenu() + updateUI() +} + +function decrementFrame() { + if (context.activeObject.currentFrameNum > 0) { + context.activeObject.currentFrameNum -= 1 + updateLayers() + updateMenu() + updateUI() + } +} + +function _newFile(width, height, fps) { + root = new GraphicsObject("root"); + context.activeObject = root + fileWidth = width + fileHeight = height + fileFps = fps + for (let stage of document.querySelectorAll(".stage")) { + stage.width = width + stage.height = height + stage.style.width = `${width}px` + stage.style.height = `${height}px` + } + updateUI() +} + +async function newFile() { + if (await confirmDialog("Create a new file? Unsaved work will be lost.", {title: "New file", kind: "warning"})) { + showNewFileDialog() + // updateUI() + } +} + +async function _save(path) { + try { + const fileData = { + version: "1.1", + width: fileWidth, + height: fileHeight, + fps: fileFps, + actions: undoStack + } + const contents = JSON.stringify(fileData ); + await writeTextFile(path, contents) + filePath = path + console.log(`${path} saved successfully!`); + } catch (error) { + console.error("Error saving text file:", error); + } +} + +async function save() { + if (filePath) { + _save(filePath) + } else { + saveAs() + } +} + +async function saveAs() { + const path = await saveFileDialog({ + filters: [ + { + name: 'Lightningbeam files (.beam)', + extensions: ['beam'], + }, + ], + defaultPath: await join(await documentDir(), "untitled.beam") + }); + if (path != undefined) _save(path); +} + +async function open() { + const path = await openFileDialog({ + multiple: false, + directory: false, + filters: [ + { + name: 'Lightningbeam files (.beam)', + extensions: ['beam'], + }, + ], + defaultPath: await documentDir(), + }); + if (path) { + try { + const contents = await readTextFile(path) + let file = JSON.parse(contents) + if (file.version == undefined) { + await messageDialog("Could not read file version!", { title: "Load error", kind: 'error' }) + return + } + if (file.version >= minFileVersion) { + if (file.version < maxFileVersion) { + _newFile(file.width, file.height, file.fps) + if (file.actions == undefined) { + await messageDialog("File has no content!", {title: "Parse error", kind: 'error'}) + return + } + for (let action of file.actions) { + if (!(action.name in actions)) { + await messageDialog(`Invalid action ${action.name}. File may be corrupt.`, { title: "Error", kind: 'error'}) + return + } + actions[action.name].execute(action.action) + undoStack.push(action) + } + updateUI() + } else { + await messageDialog(`File ${path} was created in a newer version of Lightningbeam and cannot be opened in this version.`, { title: 'File version mismatch', kind: 'error' }); + } + } else { + await messageDialog(`File ${path} is too old to be opened in this version of Lightningbeam.`, { title: 'File version mismatch', kind: 'error' }); + } + } catch (e) { + console.log(e ) + if (e instanceof SyntaxError) { + await messageDialog(`Could not parse ${path}, ${e.message}`, { title: 'Error', kind: 'error' }) + } else if (e.startsWith("failed to read file as text")) { + await messageDialog(`Could not parse ${path}, is it actually a Lightningbeam file?`, { title: 'Error', kind: 'error' }) + } + } + } +} + +async function quit() { + if (undoStack.length) { + if (await confirmDialog("Are you sure you want to quit?", {title: 'Really quit?', kind: "warning"})) { + getCurrentWindow().close() + } + } else { + getCurrentWindow().close() + } +} + +function addFrame() { + if (context.activeObject.currentFrameNum >= context.activeObject.activeLayer.frames.length) { + actions.addFrame.create() + } +} + +function addKeyframe() { + console.log(context.activeObject.currentFrameNum) + actions.addKeyframe.create() +} + +function addMotionTween() { + actions.addMotionTween.create() +} + +function stage() { + let stage = document.createElement("canvas") + let scroller = document.createElement("div") + stage.className = "stage" + stage.width = 1500 + stage.height = 1000 + scroller.className = "scroll" + stage.addEventListener("drop", (e) => { + e.preventDefault() + let mouse = getMousePos(stage, e) + const imageTypes = ['image/png', 'image/gif', 'image/avif', 'image/jpeg', + 'image/svg+xml', 'image/webp' + ]; + if (e.dataTransfer.items) { + let i = 0 + for (let item of e.dataTransfer.items) { + if (item.kind == "file") { + let file = item.getAsFile() + if (imageTypes.includes(file.type)) { + let img = new Image(); + let reader = new FileReader(); + + // Read the file as a data URL + reader.readAsDataURL(file); + reader.ix = i + + reader.onload = function(event) { + let imgsrc = event.target.result; // This is the data URL + // console.log(imgsrc) + + // img.onload = function() { + actions.addImageObject.create( + mouse.x, mouse.y, imgsrc, reader.ix, context.activeObject); + // }; + }; + + reader.onerror = function(error) { + console.error("Error reading file as data URL", error); + }; + } + i++; + } + } + } else { + } + }) + stage.addEventListener("dragover", (e) => { + e.preventDefault() + }) + canvases.push(stage) + scroller.appendChild(stage) + stage.addEventListener("mousedown", (e) => { + let mouse = getMousePos(stage, e) + switch (mode) { + case "rectangle": + case "draw": + context.mouseDown = true + context.activeShape = new Shape(mouse.x, mouse.y, context, true, true) + context.lastMouse = mouse + break; + case "select": + let selection = selectVertex(context, mouse) + if (selection) { + context.dragging = true + context.activeCurve = undefined + context.activeVertex = { + current: { + point: {x: selection.vertex.point.x, y: selection.vertex.point.y}, + startCurves: structuredClone(selection.vertex.startCurves), + endCurves: structuredClone(selection.vertex.endCurves), + }, + initial: selection.vertex, + shape: selection.shape, + startmouse: {x: mouse.x, y: mouse.y} + } + console.log("gonna move this") + } else { + selection = selectCurve(context, mouse) + if (selection) { + context.dragging = true + context.activeVertex = undefined + context.activeCurve = { + initial: selection.curve, + current: new Bezier(selection.curve.points).setColor(selection.curve.color), + shape: selection.shape, + startmouse: {x: mouse.x, y: mouse.y} + } + console.log("gonna move this") + } else { + let selected = false + let child; + if (context.selection.length) { + for (child of context.selection) { + if (hitTest(mouse, child)) { + context.dragging = true + context.lastMouse = mouse + context.activeObject.currentFrame.saveState() + break + } + } + } + if (!context.dragging) { + // Have to iterate in reverse order to grab the frontmost object when two overlap + for (let i=context.activeObject.children.length-1; i>=0; i--) { + child = context.activeObject.children[i] + // let bbox = child.bbox() + if (hitTest(mouse, child)) { + if (context.selection.indexOf(child) != -1) { + // dragging = true + } + child.saveState() + context.selection = [child] + context.dragging = true + selected = true + context.activeObject.currentFrame.saveState() + break + } + } + if (!selected) { + context.selection = [] + context.selectionRect = {x1: mouse.x, x2: mouse.x, y1: mouse.y, y2:mouse.y} + } + } + } + } + break; + case "paint_bucket": + let line = {p1: mouse, p2: {x: mouse.x + 3000, y: mouse.y}} + for (let shape of context.activeObject.currentFrame.shapes) { + for (let region of shape.regions) { + let intersect_count = 0; + for (let curve of region.curves) { + intersect_count += curve.intersects(line).length + } + if (intersect_count%2==1) { + // region.fillStyle = context.fillStyle + actions.colorRegion.create(region, context.fillStyle) + } + } + } + break; + default: + break; + } + context.lastMouse = mouse + updateUI() + }) + stage.addEventListener("mouseup", (e) => { + context.mouseDown = false + context.dragging = false + context.selectionRect = undefined + let mouse = getMousePos(stage, e) + switch (mode) { + case "draw": + if (context.activeShape) { + context.activeShape.addLine(mouse.x, mouse.y) + context.activeShape.simplify(context.simplifyMode) + actions.addShape.create(context.activeObject, context.activeShape) + context.activeShape = undefined + } + break; + case "rectangle": + actions.addShape.create(context.activeObject, context.activeShape) + context.activeShape = undefined + break; + case "select": + if (context.activeVertex) { + let newCurves = [] + for (let i in context.activeVertex.shape.curves) { + if (i in context.activeVertex.current.startCurves) { + newCurves.push(context.activeVertex.current.startCurves[i]) + } else if (i in context.activeVertex.current.endCurves) { + newCurves.push(context.activeVertex.current.endCurves[i]) + } else { + newCurves.push(context.activeVertex.shape.curves[i]) + } + } + actions.editShape.create(context.activeVertex.shape, newCurves) + } else if (context.activeCurve) { + let newCurves = [] + for (let curve of context.activeCurve.shape.curves) { + if (curve == context.activeCurve.initial) { + newCurves.push(context.activeCurve.current) + } else { + newCurves.push(curve) + } + } + actions.editShape.create(context.activeCurve.shape, newCurves) + } else if (context.selection.length) { + actions.editFrame.create(context.activeObject.currentFrame) + } + break; + default: + break; + } + context.lastMouse = mouse + context.activeCurve = undefined + updateUI() + }) + stage.addEventListener("mousemove", (e) => { + let mouse = getMousePos(stage, e) + switch (mode) { + case "draw": + context.activeCurve = undefined + if (context.activeShape) { + if (vectorDist(mouse, context.lastMouse) > minSegmentSize) { + context.activeShape.addLine(mouse.x, mouse.y) + context.lastMouse = mouse + } + } + break; + case "rectangle": + context.activeCurve = undefined + if (context.activeShape) { + context.activeShape.clear() + context.activeShape.addLine(mouse.x, context.activeShape.starty) + context.activeShape.addLine(mouse.x, mouse.y) + context.activeShape.addLine(context.activeShape.startx, mouse.y) + context.activeShape.addLine(context.activeShape.startx, context.activeShape.starty) + context.activeShape.update() + } + break; + case "select": + if (context.dragging) { + if (context.activeVertex) { + let vert = context.activeVertex + let mouseDelta = {x: mouse.x - vert.startmouse.x, y: mouse.y - vert.startmouse.y} + vert.current.point.x = vert.initial.point.x + mouseDelta.x + vert.current.point.y = vert.initial.point.y + mouseDelta.y + for (let i in vert.current.startCurves) { + let curve = vert.current.startCurves[i] + let oldCurve = vert.initial.startCurves[i] + curve.points[0] = vert.current.point + curve.points[1] = { + x: oldCurve.points[1].x + mouseDelta.x, + y: oldCurve.points[1].y + mouseDelta.y + } + } + for (let i in vert.current.endCurves) { + let curve = vert.current.endCurves[i] + let oldCurve = vert.initial.endCurves[i] + curve.points[3] = {x:vert.current.point.x, y:vert.current.point.y} + curve.points[2] = { + x: oldCurve.points[2].x + mouseDelta.x, + y: oldCurve.points[2].y + mouseDelta.y + } + } + } else if (context.activeCurve) { + context.activeCurve.current.points = moldCurve( + context.activeCurve.initial, mouse, context.activeCurve.startmouse + ).points + } else { + for (let child of context.selection) { + context.activeObject.currentFrame.keys[child.idx].x += (mouse.x - context.lastMouse.x) + context.activeObject.currentFrame.keys[child.idx] .y += (mouse.y - context.lastMouse.y) + } + } + } else if (context.selectionRect) { + context.selectionRect.x2 = mouse.x + context.selectionRect.y2 = mouse.y + context.selection = [] + context.shapeselection = [] + for (let child of context.activeObject.children) { + if (hitTest(regionToBbox(context.selectionRect), child)) { + context.selection.push(child) + } + } + for (let shape of context.activeObject.currentFrame.shapes) { + if (hitTest(regionToBbox(context.selectionRect), shape)) { + context.shapeselection.push(shape) + } + } + } else { + let selection = selectVertex(context, mouse) + if (selection) { + context.activeCurve = undefined + context.activeVertex = { + current: selection.vertex, + initial: { + point: {x: selection.vertex.point.x, y: selection.vertex.point.y}, + startCurves: structuredClone(selection.vertex.startCurves), + endCurves: structuredClone(selection.vertex.endCurves), + }, + shape: selection.shape, + startmouse: {x: mouse.x, y: mouse.y} + } + } else { + context.activeVertex = undefined + selection = selectCurve(context, mouse) + if (selection) { + context.activeCurve = { + current: selection.curve, + initial: new Bezier(selection.curve.points).setColor(selection.curve.color), + shape: selection.shape, + startmouse: mouse + } + } else { + context.activeCurve = undefined + } + } + } + context.lastMouse = mouse + break; + default: + break; + } + updateUI() + }) + return scroller +} + +function toolbar() { + let tools_scroller = document.createElement("div") + tools_scroller.className = "toolbar" + for (let tool in tools) { + let toolbtn = document.createElement("button") + toolbtn.className = "toolbtn" + let icon = document.createElement("img") + icon.className = "icon" + icon.src = tools[tool].icon + toolbtn.appendChild(icon) + tools_scroller.appendChild(toolbtn) + toolbtn.addEventListener("click", () => { + mode = tool + console.log(tool) + }) + } + let tools_break = document.createElement("div") + tools_break.className = "horiz_break" + tools_scroller.appendChild(tools_break) + let fillColor = document.createElement("input") + let strokeColor = document.createElement("input") + fillColor.className = "color-field" + strokeColor.className = "color-field" + fillColor.value = "#ff0000" + strokeColor.value = "#000000" + context.fillStyle = fillColor.value + context.strokeStyle = strokeColor.value + fillColor.addEventListener('click', e => { + Coloris({ + el: ".color-field", + selectInput: true, + focusInput: true, + theme: 'default', + swatches: context.swatches, + defaultColor: '#ff0000', + onChange: (color) => { + context.fillStyle = color; + } + }) + }) + strokeColor.addEventListener('click', e => { + Coloris({ + el: ".color-field", + selectInput: true, + focusInput: true, + theme: 'default', + swatches: context.swatches, + defaultColor: '#000000', + onChange: (color) => { + context.strokeStyle = color; + } + }) + }) + // Fill and stroke colors use the same set of swatches + fillColor.addEventListener("change", e => { + context.swatches.unshift(fillColor.value) + if (context.swatches.length>12) context.swatches.pop(); + }) + strokeColor.addEventListener("change", e => { + context.swatches.unshift(strokeColor.value) + if (context.swatches.length>12) context.swatches.pop(); + }) + tools_scroller.appendChild(fillColor) + tools_scroller.appendChild(strokeColor) + return tools_scroller +} + +function timeline() { + let container = document.createElement("div") + let layerspanel = document.createElement("div") + let framescontainer = document.createElement("div") + container.classList.add("horizontal-grid") + container.classList.add("layers-container") + layerspanel.className = "layers" + framescontainer.className = "frames-container" + container.appendChild(layerspanel) + container.appendChild(framescontainer) + layoutElements.push(container) + container.setAttribute("lb-percent", 20) + + return container +} + +function infopanel() { + let panel = document.createElement("div") + panel.className = "infopanel" + let input; + let label; + let span; + // for (let i=0; i<10; i++) { + for (let property in tools[mode].properties) { + let prop = tools[mode].properties[property] + label = document.createElement("label") + label.className = "infopanel-field" + span = document.createElement("span") + span.className = "infopanel-label" + span.innerText = prop.label + switch (prop.type) { + case "number": + input = document.createElement("input") + input.className = "infopanel-input" + input.type = "number" + input.value = getProperty(context, property) + break; + case "enum": + input = document.createElement("select") + input.className = "infopanel-input" + let optionEl; + for (let option of prop.options) { + optionEl = document.createElement("option") + optionEl.value = option + optionEl.innerText = option + input.appendChild(optionEl) + } + input.value = getProperty(context, property) + break; + case "boolean": + input = document.createElement("input") + input.className = "infopanel-input" + input.type = "checkbox" + input.checked = getProperty(context, property) + break; + } + input.addEventListener("input", (e) => { + switch (prop.type) { + case "number": + if (!isNaN(e.target.value) && e.target.value > 0) { + setProperty(context, property, e.target.value) + } + break; + case "enum": + if (prop.options.indexOf(e.target.value) >= 0) { + setProperty(context, property, e.target.value) + } + break; + case "boolean": + setProperty(context, property, e.target.checked) + } + + }) + label.appendChild(span) + label.appendChild(input) + panel.appendChild(label) + } + return panel +} + + +createNewFileDialog(_newFile); +showNewFileDialog() + +function createPaneMenu(div) { + const menuItems = ["Item 1", "Item 2", "Item 3"]; // The items for the menu + + // Get the menu container (create a new div for the menu) + const popupMenu = document.createElement("div"); + popupMenu.id = "popupMenu"; // Set the ID to ensure we can target it later + + // Create a
    element to hold the list items + const ul = document.createElement("ul"); + + // Loop through the menuItems array and create a
  • for each item + for (let pane in panes) { + const li = document.createElement("li"); + // Create the element for the icon + const img = document.createElement("img"); + img.src = `assets/${panes[pane].name}.svg`; // Use the appropriate SVG as the source + // img.style.width = "20px"; // Set the icon size + // img.style.height = "20px"; // Set the icon size + // img.style.marginRight = "10px"; // Add space between the icon and text + + // Append the image to the
  • element + li.appendChild(img); + + // Set the text of the item + li.appendChild(document.createTextNode(titleCase(panes[pane].name))); + li.addEventListener("click", () => { + createPane(panes[pane], div) + updateUI() + updateLayers() + updateAll() + popupMenu.remove() + }) + ul.appendChild(li); // Append the
  • to the
      + } + + popupMenu.appendChild(ul); // Append the
        to the popupMenu div + document.body.appendChild(popupMenu); // Append the menu to the body + return popupMenu; // Return the created menu element +} + +function createPane(paneType=undefined, div=undefined) { + if (!div) { + div = document.createElement("div") + } else { + div.textContent = '' + } + let header = document.createElement("div") + if (!paneType) { + paneType = panes.stage // TODO: change based on type + } + let content = paneType.func() + header.className = "header" + + let button = document.createElement("button") + header.appendChild(button) + let icon = document.createElement("img") + icon.className="icon" + icon.src = `/assets/${paneType.name}.svg` + button.appendChild(icon) + button.addEventListener("click", () => { + let popupMenu = document.getElementById("popupMenu"); + + // If the menu is already in the DOM, remove it + if (popupMenu) { + popupMenu.remove(); // Remove the menu from the DOM + } else { + // Create and append the new menu to the DOM + popupMenu = createPaneMenu(div); + + // Position the menu below the button + const buttonRect = event.target.getBoundingClientRect(); + popupMenu.style.left = `${buttonRect.left}px`; + popupMenu.style.top = `${buttonRect.bottom + window.scrollY}px`; + } + + // Prevent the click event from propagating to the window click listener + event.stopPropagation(); + }) + + div.className = "vertical-grid" + header.style.height = "calc( 2 * var(--lineheight))" + content.style.height = "calc( 100% - 2 * var(--lineheight) )" + div.appendChild(header) + div.appendChild(content) + return div +} + +function splitPane(div, percent, horiz, newPane=undefined) { + let content = div.firstElementChild + let div1 = document.createElement("div") + let div2 = document.createElement("div") + + div1.className = "panecontainer" + div2.className = "panecontainer" + + div1.appendChild(content) + if (newPane) { + div2.appendChild(newPane) + } else { + div2.appendChild(createPane()) + } + div.appendChild(div1) + div.appendChild(div2) + + if (horiz) { + div.className = "horizontal-grid" + } else { + div.className = "vertical-grid" + } + div.setAttribute("lb-percent", percent) // TODO: better attribute name + div.addEventListener('mousedown', function(event) { + // Check if the clicked element is the parent itself and not a child element + if (event.target === event.currentTarget) { + event.currentTarget.setAttribute("dragging", true) + event.currentTarget.style.userSelect = 'none'; + rootPane.style.userSelect = "none"; + } else { + event.currentTarget.setAttribute("dragging", false) + } + }); + div.addEventListener('mousemove', function(event) { + // Check if the clicked element is the parent itself and not a child element + if (event.currentTarget.getAttribute("dragging")=="true") { + const frac = getMousePositionFraction(event, event.currentTarget) + div.setAttribute("lb-percent", frac*100) + updateAll() + console.log(frac); // Ensure the fraction is between 0 and 1 + } + }); + div.addEventListener('mouseup', (event) => { + console.log("mouseup") + event.currentTarget.setAttribute("dragging", false) + event.currentTarget.style.userSelect = 'auto'; + }) + Coloris({el: ".color-field"}) + updateAll() + updateUI() + updateLayers() + return [div1, div2] +} + +function updateAll() { + updateLayout(rootPane) + for (let element of layoutElements) { + updateLayout(element) + } +} + +function updateLayout(element) { + let rect = element.getBoundingClientRect() + let percent = element.getAttribute("lb-percent") + percent ||= 50 + let children = element.children + if (children.length != 2) return; + if (element.classList.contains("horizontal-grid")) { + children[0].style.width = `${rect.width * percent / 100}px` + children[1].style.width = `${rect.width * (100 - percent) / 100}px` + children[0].style.height = `${rect.height}px` + children[1].style.height = `${rect.height}px` + } else if (element.classList.contains("vertical-grid")) { + children[0].style.height = `${rect.height * percent / 100}px` + children[1].style.height = `${rect.height * (100 - percent) / 100}px` + children[0].style.width = `${rect.width}px` + children[1].style.width = `${rect.width}px` + } + if (children[0].getAttribute("lb-percent")) { + updateLayout(children[0]) + } + if (children[1].getAttribute("lb-percent")) { + updateLayout(children[1]) + } +} + +function updateUI() { + for (let canvas of canvases) { + let ctx = canvas.getContext("2d") + ctx.reset(); + ctx.fillStyle = "white" + ctx.fillRect(0,0,canvas.width,canvas.height) + + context.ctx = ctx; + root.draw(context) + if (context.activeShape) { + context.activeShape.draw(context) + } + + } + if (playing) { + setTimeout(advanceFrame, 1000/fileFps) + } +} + +function updateLayers() { + console.log(document.querySelectorAll(".layers-container")) + for (let container of document.querySelectorAll(".layers-container")) { + let layerspanel = container.querySelectorAll(".layers")[0] + let framescontainer = container.querySelectorAll(".frames-container")[0] + layerspanel.textContent = "" + framescontainer.textContent = "" + console.log(context.activeObject) + for (let layer of context.activeObject.layers) { + let layerHeader = document.createElement("div") + layerHeader.className = "layer-header" + layerspanel.appendChild(layerHeader) + let layerTrack = document.createElement("div") + layerTrack.className = "layer-track" + framescontainer.appendChild(layerTrack) + layerTrack.addEventListener("click", (e) => { + console.log(layerTrack.getBoundingClientRect()) + let mouse = getMousePos(layerTrack, e) + let frameNum = parseInt(mouse.x/25) + context.activeObject.currentFrameNum = frameNum + console.log(context.activeObject ) + updateLayers() + updateMenu() + updateUI() + }) + let highlightedFrame = false + layer.frames.forEach((frame, i) => { + let frameEl = document.createElement("div") + frameEl.className = "frame" + frameEl.setAttribute("frameNum", i) + if (i == context.activeObject.currentFrameNum) { + frameEl.classList.add("active") + highlightedFrame = true + } + + frameEl.classList.add(frame.frameType) + layerTrack.appendChild(frameEl) + }) + if (!highlightedFrame) { + let highlightObj = document.createElement("div") + let frameCount = layer.frames.length + highlightObj.className = "frame-highlight" + highlightObj.style.left = `${(context.activeObject.currentFrameNum - frameCount) * 25}px`; + layerTrack.appendChild(highlightObj) + } + } + } +} + +async function updateMenu() { + let activeFrame; + let activeKeyframe; + let newFrameMenuItem; + let newKeyframeMenuItem; + let deleteFrameMenuItem; + + activeKeyframe = false + if (context.activeObject.activeLayer.frames[context.activeObject.currentFrameNum]) { + activeFrame = true + if (context.activeObject.activeLayer.frames[context.activeObject.currentFrameNum].frameType=="keyframe") { + activeKeyframe = true + } + } else { + activeFrame = false + } + const fileSubmenu = await Submenu.new({ + text: 'File', + items: [ + { + text: 'New file...', + enabled: true, + action: newFile, + }, + { + text: 'Save', + enabled: true, + action: save, + }, + { + text: 'Save As...', + enabled: true, + action: saveAs, + }, + { + text: 'Open File...', + enabled: true, + action: open, + }, + { + text: 'Quit', + enabled: true, + action: quit, + }, + ] + }) + + const editSubmenu = await Submenu.new({ + text: "Edit", + items: [ + { + text: "Undo", + enabled: true, + action: undo + }, + { + text: "Redo", + enabled: true, + action: redo + }, + { + text: "Cut", + enabled: true, + action: () => {} + }, + { + text: "Copy", + enabled: true, + action: () => {} + }, + { + text: "Paste", + enabled: true, + action: () => {} + }, + { + text: "Group", + enabled: true, + action: actions.group.create + }, + ] + }); + + newFrameMenuItem = { + text: "New Frame", + enabled: !activeFrame, + action: addFrame + } + newKeyframeMenuItem = { + text: "New Keyframe", + enabled: !activeKeyframe, + action: addKeyframe + } + deleteFrameMenuItem = { + text: "Delete Frame", + enabled: activeFrame, + action: () => {} + } + + const timelineSubmenu = await Submenu.new({ + text: "Timeline", + items: [ + newFrameMenuItem, + newKeyframeMenuItem, + deleteFrameMenuItem, + { + text: "Add Motion Tween", + enabled: activeFrame && (!activeKeyframe), + action: addMotionTween + }, + { + text: "Return to start", + enabled: false, + action: () => {} + }, + { + text: "Play", + enabled: false, + action: () => {} + }, + ] + }); + const viewSubmenu = await Submenu.new({ + text: "View", + items: [ + { + text: "Zoom In", + enabled: false, + action: () => {} + }, + { + text: "Zoom Out", + enabled: false, + action: () => {} + }, + ] + }); + const helpSubmenu = await Submenu.new({ + text: "Help", + items: [ + { + text: "About...", + enabled: true, + action: () => { + messageDialog(`Lightningbeam version ${appVersion}\nDeveloped by Skyler Lehmkuhl`, + {title: 'About', kind: "info"} + ) + } + } + ] +}); + + const menu = await Menu.new({ + items: [fileSubmenu, editSubmenu, timelineSubmenu, viewSubmenu, helpSubmenu], + }) + await (macOS ? menu.setAsAppMenu() : menu.setAsWindowMenu()) +} +updateMenu() + +const panes = { + stage: { + name: "stage", + func: stage + }, + toolbar: { + name: "toolbar", + func: toolbar + }, + timeline: { + name: "timeline", + func: timeline + }, + infopanel: { + name: "infopanel", + func: infopanel + }, +} \ No newline at end of file diff --git a/src/newfile.js b/src/newfile.js new file mode 100644 index 0000000..0ced18f --- /dev/null +++ b/src/newfile.js @@ -0,0 +1,97 @@ +let overlay; +let newFileDialog; + +function createNewFileDialog(callback) { + overlay = document.createElement('div'); + overlay.id = 'overlay'; + document.body.appendChild(overlay); + + newFileDialog = document.createElement('div'); + newFileDialog.id = 'newFileDialog'; + newFileDialog.classList.add('hidden'); + document.body.appendChild(newFileDialog); + + // Create dialog content dynamically + const title = document.createElement('h3'); + title.textContent = 'Create New File'; + newFileDialog.appendChild(title); + + // Create Width input + const widthLabel = document.createElement('label'); + widthLabel.setAttribute('for', 'width'); + widthLabel.classList.add('dialog-label'); + widthLabel.textContent = 'Width:'; + newFileDialog.appendChild(widthLabel); + + const widthInput = document.createElement('input'); + widthInput.type = 'number'; + widthInput.id = 'width'; + widthInput.classList.add('dialog-input'); + widthInput.value = '1500'; // Default value + newFileDialog.appendChild(widthInput); + + // Create Height input + const heightLabel = document.createElement('label'); + heightLabel.setAttribute('for', 'height'); + heightLabel.classList.add('dialog-label'); + heightLabel.textContent = 'Height:'; + newFileDialog.appendChild(heightLabel); + + const heightInput = document.createElement('input'); + heightInput.type = 'number'; + heightInput.id = 'height'; + heightInput.classList.add('dialog-input'); + heightInput.value = '1000'; // Default value + newFileDialog.appendChild(heightInput); + + // Create FPS input + const fpsLabel = document.createElement('label'); + fpsLabel.setAttribute('for', 'fps'); + fpsLabel.classList.add('dialog-label'); + fpsLabel.textContent = 'Frames per Second:'; + newFileDialog.appendChild(fpsLabel); + + const fpsInput = document.createElement('input'); + fpsInput.type = 'number'; + fpsInput.id = 'fps'; + fpsInput.classList.add('dialog-input'); + fpsInput.value = '12'; // Default value + newFileDialog.appendChild(fpsInput); + + // Create Create button + const createButton = document.createElement('button'); + createButton.textContent = 'Create'; + createButton.classList.add('dialog-button'); + createButton.onclick = createNewFile; + newFileDialog.appendChild(createButton); + + + // Create the new file (simulation) + function createNewFile() { + const width = document.getElementById('width').value; + const height = document.getElementById('height').value; + const fps = document.getElementById('fps').value; + console.log(`New file created with width: ${width} and height: ${height}`); + callback(width, height, fps) + + // Add any further logic to handle the new file creation here + + closeDialog(); // Close the dialog after file creation + } + + // Close the dialog if the overlay is clicked + overlay.onclick = closeDialog; +} + +// Show the dialog +function showNewFileDialog() { + overlay.style.display = 'block'; + newFileDialog.style.display = 'block'; +} + +// Close the dialog +function closeDialog() { + overlay.style.display = 'none'; + newFileDialog.style.display = 'none'; +} +export { createNewFileDialog, showNewFileDialog, closeDialog }; \ No newline at end of file diff --git a/src/quadtree.js b/src/quadtree.js new file mode 100644 index 0000000..68df8e0 --- /dev/null +++ b/src/quadtree.js @@ -0,0 +1,176 @@ +class Quadtree { + constructor(boundary, capacity) { + // Boundary is the bounding box of the area this quadtree node covers + // Capacity is the maximum number of curves a node can hold before subdividing + this.boundary = boundary; // {x: {min: , max: }, y: {min: , max: }} + this.capacity = capacity; + this.curveIndexes = []; + this.curves = []; + this.divided = false; + + this.nw = null; // Northwest quadrant + this.ne = null; // Northeast quadrant + this.sw = null; // Southwest quadrant + this.se = null; // Southeast quadrant + } + + + // Check if a bounding box intersects with the boundary of this quadtree node + intersects(bbox) { + return !(bbox.x.max < this.boundary.x.min || bbox.x.min > this.boundary.x.max || + bbox.y.max < this.boundary.y.min || bbox.y.min > this.boundary.y.max); + } + + // Subdivide this quadtree node into 4 quadrants + subdivide() { + const xMid = (this.boundary.x.min + this.boundary.x.max) / 2; + const yMid = (this.boundary.y.min + this.boundary.y.max) / 2; + + const nwBoundary = { x: { min: this.boundary.x.min, max: xMid }, y: { min: this.boundary.y.min, max: yMid }}; + const neBoundary = { x: { min: xMid, max: this.boundary.x.max }, y: { min: this.boundary.y.min, max: yMid }}; + const swBoundary = { x: { min: this.boundary.x.min, max: xMid }, y: { min: yMid, max: this.boundary.y.max }}; + const seBoundary = { x: { min: xMid, max: this.boundary.x.max }, y: { min: yMid, max: this.boundary.y.max }}; + + this.nw = new Quadtree(nwBoundary, this.capacity); + this.ne = new Quadtree(neBoundary, this.capacity); + this.sw = new Quadtree(swBoundary, this.capacity); + this.se = new Quadtree(seBoundary, this.capacity); + + this.divided = true; + } + + insert (curve, curveIdx) { + const bbox = curve.bbox() + if (!this.intersects(curve.bbox())) { + let newNode = new Quadtree(this.boundary, this.capacity) + newNode.curveIndexes = this.curveIndexes; + newNode.curves = this.curves; + newNode.divided = this.divided; + + newNode.nw = this.nw; + newNode.ne = this.ne; + newNode.sw = this.sw; + newNode.se = this.se; + + this.curveIndexes = []; + this.curves = []; + this.subdivide() + if (bbox.x.max < this.boundary.x.max) { + if (bbox.y.max < this.boundary.y.max) { + this.boundary.x.min -= this.boundary.x.max - this.boundary.x.min + this.boundary.y.min -= this.boundary.y.max - this.boundary.y.min + this.nw = newNode + } else { + this.boundary.x.min -= this.boundary.x.max - this.boundary.x.min + this.boundary.y.max += this.boundary.y.max - this.boundary.y.min + this.sw = newNode + } + } else { + if (bbox.y.max < this.boundary.y.max) { + this.boundary.x.max += this.boundary.x.max - this.boundary.x.min + this.boundary.y.min -= this.boundary.y.max - this.boundary.y.min + this.ne = newNode + } else { + this.boundary.x.max += this.boundary.x.max - this.boundary.x.min + this.boundary.y.max += this.boundary.y.max - this.boundary.y.min + this.se = newNode + } + } + return this.insert(curve, curveIdx) + } else { + return this._insert(curve, curveIdx) + } + } + + // Insert a curve into the quadtree, subdividing if necessary + _insert(curve, curveIdx) { + // If the curve's bounding box doesn't intersect this node's boundary, do nothing + if (!this.intersects(curve.bbox())) { + return false; + } + + // If the node has space, insert the curve here + if (this.curves.length < this.capacity) { + this.curves.push(curve); + this.curveIndexes.push(curveIdx) + return true; + } + + // Otherwise, subdivide and insert the curve into the appropriate quadrant + if (!this.divided) { + this.subdivide(); + } + + return ( + this.nw._insert(curve, curveIdx) || + this.ne._insert(curve, curveIdx) || + this.sw._insert(curve, curveIdx) || + this.se._insert(curve, curveIdx) + ); + } + + // Query all curves that intersect with a given bounding box + query(range, found = []) { + // If the range doesn't intersect with this node's boundary, return + if (!this.intersects(range)) { + return found; + } + + // Check the curves in this node + for (let i = 0; i < this.curves.length; i++) { + if (this.bboxIntersect(this.curves[i].bbox(), range)) { + found.push(this.curveIndexes[i]); // Return the curve index instead of the curve + } + } + + // If the node is subdivided, check the child quadrants + if (this.divided) { + this.nw.query(range, found); + this.ne.query(range, found); + this.sw.query(range, found); + this.se.query(range, found); + } + + return found; + } + + // Helper method to check if two bounding boxes intersect + bboxIntersect(bbox1, bbox2) { + return !(bbox1.x.max < bbox2.x.min || bbox1.x.min > bbox2.x.max || + bbox1.y.max < bbox2.y.min || bbox1.y.min > bbox2.y.max); + } + + clear() { + this.curveIndexes = []; + this.curves = []; + this.divided = false; + + this.nw = null; // Northwest quadrant + this.ne = null; // Northeast quadrant + this.sw = null; // Southwest quadrant + this.se = null; // Southeast quadrant + } + draw(ctx) { + // Debug visualization + ctx.save() + ctx.strokeStyle = "red" + ctx.lineWidth = 1 + ctx.beginPath() + ctx.rect( + this.boundary.x.min, + this.boundary.y.min, + this.boundary.x.max-this.boundary.x.min, + this.boundary.y.max-this.boundary.y.min + ) + ctx.stroke() + if (this.divided) { + this.nw.draw(ctx) + this.ne.draw(ctx) + this.sw.draw(ctx) + this.se.draw(ctx) + } + ctx.restore() + } + } + + export { Quadtree }; \ No newline at end of file diff --git a/src/simplify.js b/src/simplify.js new file mode 100644 index 0000000..339c84f --- /dev/null +++ b/src/simplify.js @@ -0,0 +1,123 @@ +/* + (c) 2017, Vladimir Agafonkin + Simplify.js, a high-performance JS polyline simplification library + mourner.github.io/simplify-js +*/ + +(function () { 'use strict'; + +// to suit your point format, run search/replace for '.x' and '.y'; +// for 3D version, see 3d branch (configurability would draw significant performance overhead) + +// square distance between 2 points +function getSqDist(p1, p2) { + + var dx = p1.x - p2.x, + dy = p1.y - p2.y; + + return dx * dx + dy * dy; +} + +// square distance from a point to a segment +function getSqSegDist(p, p1, p2) { + + var x = p1.x, + y = p1.y, + dx = p2.x - x, + dy = p2.y - y; + + if (dx !== 0 || dy !== 0) { + + var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); + + if (t > 1) { + x = p2.x; + y = p2.y; + + } else if (t > 0) { + x += dx * t; + y += dy * t; + } + } + + dx = p.x - x; + dy = p.y - y; + + return dx * dx + dy * dy; +} +// rest of the code doesn't care about point format + +// basic distance-based simplification +function simplifyRadialDist(points, sqTolerance) { + + var prevPoint = points[0], + newPoints = [prevPoint], + point; + + for (var i = 1, len = points.length; i < len; i++) { + point = points[i]; + + if (getSqDist(point, prevPoint) > sqTolerance) { + newPoints.push(point); + prevPoint = point; + } + } + + if (prevPoint !== point) newPoints.push(point); + + return newPoints; +} + +function simplifyDPStep(points, first, last, sqTolerance, simplified) { + var maxSqDist = sqTolerance, + index; + + for (var i = first + 1; i < last; i++) { + var sqDist = getSqSegDist(points[i], points[first], points[last]); + + if (sqDist > maxSqDist) { + index = i; + maxSqDist = sqDist; + } + } + + if (maxSqDist > sqTolerance) { + if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified); + simplified.push(points[index]); + if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified); + } +} + +// simplification using Ramer-Douglas-Peucker algorithm +function simplifyDouglasPeucker(points, sqTolerance) { + var last = points.length - 1; + + var simplified = [points[0]]; + simplifyDPStep(points, 0, last, sqTolerance, simplified); + simplified.push(points[last]); + + return simplified; +} + +// both algorithms combined for awesome performance +function simplify(points, tolerance, highestQuality) { + + if (points.length <= 2) return points; + + var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; + + points = highestQuality ? points : simplifyRadialDist(points, sqTolerance); + points = simplifyDouglasPeucker(points, sqTolerance); + + return points; +} + +// export as AMD module / Node module / browser or worker variable +if (typeof define === 'function' && define.amd) define(function() { return simplify; }); +else if (typeof module !== 'undefined') { + module.exports = simplify; + module.exports.default = simplify; +} else if (typeof self !== 'undefined') self.simplify = simplify; +else window.simplify = simplify; + +})(); diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..51781e1 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,415 @@ +body { + width: 100%; + height: 100%; + overflow: hidden; +} + +.logo.vanilla:hover { + filter: drop-shadow(0 0 2em #ffe21c); +} +:root { + --lineheight: 24px; + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: var(--lineheight); + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; + height: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +div { + /* this should be on everything by default, really */ + box-sizing: border-box; +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} + +.header { + height: 60px; + min-width: 100%; + background-color: #3f3f3f; + text-align: left; + z-index: 1; +} + +.icon { + width: var(--lineheight); + height: var(--lineheight); +} + +.panecontainer { + width: 100%; + height: 100%; +} + +.horizontal-grid, .vertical-grid { + display: flex; + gap: 5px; + background-color: #0f0f0f; + width: 100%; + height: 100%; + contain: strict; +} +.horizontal-grid { + flex-direction: row; +} +.vertical-grid { + flex-direction: column; +} +/* I don't fully understand this selector but it works for now */ +.horizontal-grid:hover:not(:has(*:hover)) { + background: #666; + cursor: ew-resize; +} +.vertical-grid:hover:not(:has(*:hover)) { + background: #666; + cursor: ns-resize +} +.scroll { + overflow: scroll; + width: 100%; + height: 100%; + background-color: #555; +} +.stage { + width: 1500px; + height: 1000px; + overflow: scroll; +} +.toolbar { + display: flex; + flex-direction: row; + gap: 10px; + padding: 5px; + flex-wrap: wrap; + align-content: flex-start; + justify-content: space-around; +} +.toolbtn { + width: calc( 3 * var(--lineheight) ); + height: calc( 3 * var(--lineheight) ); + background-color: #2f2f2f; +} + +.horiz_break { + width: 100%; + height: 5px; + + background-color: #2f2f2f; +} +.clr-field { + width: 100%; +} +.clr-field button { + width: 50% !important; + /* height: 100% !important; */ + /* margin: 100px; */ + border-radius: 5px; +} +.clr-field input { + width: 50%; +} +.infopanel { + width: 100%; + height: 100%; + background-color: #3f3f3f; + display: flex; + box-sizing: border-box; + gap: calc( var(--lineheight) / 2 ); + padding: calc( var(--lineheight) / 2 ); + flex-direction: column; + flex-wrap: wrap; + align-content: flex-start; +} +.infopanel-field { + width: 300px; + height: var(--lineheight); + display: flex; + flex-direction: row; +} +.infopanel-label { + flex: 1 1 50%; +} +.infopanel-input { + flex: 1 1 50%; + width: 50%; +} +.layers-container { + overflow-y: scroll; +} +.layers { + background-color: #222222; + display: flex; + flex-direction: column; + flex-wrap: nowrap; + min-height: 100%; +} +.frames-container { + background-color: #222222; + display: flex; + flex-direction: column; + flex-wrap: nowrap; + /* overflow-x: scroll; */ + /* overflow-y:inherit; */ + min-height: 100%; +} +.layer-header { + width: 100%; + height: calc( 2 * var(--lineheight)); + background-color: #3f3f3f; + border-top: 1px solid #4f4f4f; + border-bottom: 1px solid #222222; + flex-shrink: 0; +} +.layer-track { + min-width: 100%; + height: calc( 2 * var(--lineheight)); + background: repeating-linear-gradient(to right, transparent, transparent 24px, #3f3f3f 24px, #3f3f3f 25px), + repeating-linear-gradient(to right, #222222, #222222 100px, #151515 100px, #151515 125px); + + display: flex; + flex-direction: row; + border-top: 1px solid #222222; + border-bottom: 1px solid #3f3f3f; + flex-shrink: 0; +} +.frame { + width: 25px; + height: 100%; + + background-color: #4f4f4f; + flex-grow: 0; + flex-shrink: 0; + border-right: 1px solid #3f3f3f; + border-left: 1px solid #555555; +} +.frame:hover { + background-color: #555555; +} +.frame.active { + background-color: #666666; +} +.frame.keyframe { + position: relative; +} +.frame.keyframe::before { + content: ''; /* Creates a pseudo-element */ + position: absolute; + bottom: 0; /* Position the circle at the bottom of the div */ + left: 50%; /* Center the circle horizontally */ + transform: translateX(-50%); /* Adjust for perfect centering */ + width: 50%; /* Set the width of the circle to half of the div's width */ + height: 0; /* Initially set to 0 */ + padding-bottom: 50%; /* Set padding-bottom to 50% of the div's width to create a circle */ + border-radius: 50%; /* Make the shape a circle */ + background-color: #222; /* Set the color of the circle (black in this case) */ + margin-bottom: 5px; +} +.frame.motion { + background-color: #7a00b3; + border: none; +} +.frame.motion:hover, .frame.motion.active { + background-color: #530379; + border: none; +} +/* :nth-child(1 of .frame.motion) { + background-color: blue; +} +:nth-last-child(1 of .frame.motion) { + background-color: red; +} */ + +.frame-highlight { + background-color: red; + width: 25px; + height: calc( 2 * var(--lineheight) - 2px); + position: relative; +} + +.hidden { + display: none; +} + +#overlay { + display: none; /* Hidden by default */ + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.5); + z-index: 999; /* Under the dialog */ +} + +/* Scoped styles for the dialog */ +#newFileDialog { + display: none; /* Hidden by default */ + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: #444; + border: 1px solid #333; + border-radius: 5px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); + padding: 20px; + width: 300px; + z-index: 1000; /* Make sure it's in front of other elements */ +} + +#newFileDialog .dialog-label { + display: block; + margin: 10px 0 5px; +} + +#newFileDialog .dialog-input { + width: 100%; + padding: 8px; + margin: 5px 0; + border: 1px solid #333; +} + +#newFileDialog .dialog-button { + width: 100%; + padding: 10px; + background-color: #007bff; + color: white; + border: none; + cursor: pointer; +} + +#newFileDialog .dialog-button:hover { + background-color: #0056b3; +} + +#popupMenu { + background-color: #222; + box-shadow: 0 4px 8px rgba(0,0,0,0.5); + padding: 20px; + border-radius: 5px; + position: absolute; +} +#popupMenu ul { + padding: 0px; + margin: 0px; +} +#popupMenu li { + color: #ccc; + list-style-type: none; + display: flex; + align-items: center; /* Vertically center the image and text */ + padding: 5px 0; /* Add padding for better spacing */ +} +#popupMenu li:hover { + background-color: #444; + cursor:pointer; +} +#popupMenu li:not(:last-child) { + border-bottom: 1px solid #444; /* Horizontal line for all li elements except the last */ +} +#popupMenu li img { + margin-right: 10px; /* Space between the icon and text */ + width: 20px; /* Adjust the width of the icon */ + height: 20px; /* Adjust the height of the icon */ +} \ No newline at end of file diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..974df6d --- /dev/null +++ b/src/utils.js @@ -0,0 +1,94 @@ +function titleCase(str) { + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} + +function getMousePositionFraction(event, element) { + const rect = element.getBoundingClientRect(); // Get the element's position and size + + if (element.classList.contains('horizontal-grid')) { + // If the element has the "horizontal-grid" class, calculate the horizontal position (X) + const xPos = event.clientX - rect.left; // Mouse X position relative to the element + const fraction = xPos / rect.width; // Fraction of the width + return Math.min(Math.max(fraction, 0), 1); // Ensure the fraction is between 0 and 1 + } else if (element.classList.contains('vertical-grid')) { + // If the element has the "vertical-grid" class, calculate the vertical position (Y) + const yPos = event.clientY - rect.top; // Mouse Y position relative to the element + const fraction = yPos / rect.height; // Fraction of the height + return Math.min(Math.max(fraction, 0), 1); // Ensure the fraction is between 0 and 1 + } + return 0; // If neither class is present, return 0 (or handle as needed) + } + +function getKeyframesSurrounding(frames, index) { + let lastKeyframeBefore = undefined; + let firstKeyframeAfter = undefined; + + // Find the last keyframe before the given index + for (let i = index - 1; i >= 0; i--) { + if (frames[i].frameType === "keyframe") { + lastKeyframeBefore = i; + break; + } + } + + // Find the first keyframe after the given index + for (let i = index + 1; i < frames.length; i++) { + if (frames[i].frameType === "keyframe") { + firstKeyframeAfter = i; + break; + } + } + return { lastKeyframeBefore, firstKeyframeAfter }; +} + +function invertPixels(ctx, width, height) { + // Create an off-screen canvas for the pattern + const patternCanvas = document.createElement('canvas'); + const patternContext = patternCanvas.getContext('2d'); + + // Define the size of the repeating pattern (2x2 pixels) + const patternSize = 2; + patternCanvas.width = patternSize; + patternCanvas.height = patternSize; + + // Create the alternating pattern (regular and inverted pixels) + function createInvertedPattern() { + const patternData = patternContext.createImageData(patternSize, patternSize); + const data = patternData.data; + + // Fill the pattern with alternating colors (inverted every other pixel) + for (let i = 0; i < patternSize; i++) { + for (let j = 0; j < patternSize; j++) { + const index = (i * patternSize + j) * 4; + // Determine if we should invert the color + if ((i + j) % 2 === 0) { + data[index] = 255; // Red + data[index + 1] = 0; // Green + data[index + 2] = 0; // Blue + data[index + 3] = 255; // Alpha + } else { + data[index] = 0; // Red (inverted) + data[index + 1] = 255; // Green (inverted) + data[index + 2] = 255; // Blue (inverted) + data[index + 3] = 255; // Alpha + } + } + } + + // Set the pattern on the off-screen canvas + patternContext.putImageData(patternData, 0, 0); + return patternCanvas; + } + + // Create the pattern using the function + const pattern = ctx.createPattern(createInvertedPattern(), 'repeat'); + + // Draw a rectangle with the pattern + ctx.globalCompositeOperation = "difference" + ctx.fillStyle = pattern; + ctx.fillRect(0, 0, width, height); + + ctx.globalCompositeOperation = "source-over" +} + +export { titleCase, getMousePositionFraction, getKeyframesSurrounding, invertPixels }; \ No newline at end of file diff --git a/src/vector.js b/src/vector.js new file mode 100644 index 0000000..704a41f --- /dev/null +++ b/src/vector.js @@ -0,0 +1,74 @@ +class Vector { + constructor(x, y, z) { + if (arguments.length === 1) { + z = x.z; + y = x.y; + x = x.x; + } + this.x = x; + this.y = y; + if (z !== undefined) { + this.z = z; + } + } + dist(other, y, z = 0) { + if (y !== undefined) other = { x: other, y, z }; + let sum = 0; + sum += (this.x - other.x) ** 2; + sum += (this.y - other.y) ** 2; + let z1 = this.z ? this.z : 0; + let z2 = other.z ? other.z : 0; + sum += (z1 - z2) ** 2; + return sum ** 0.5; + } + normalize(f) { + let mag = this.dist(0, 0, 0); + return new Vector((f * this.x) / mag, (f * this.y) / mag, (f * this.z) / mag); + } + getAngle() { + return -Math.atan2(this.y, this.x); + } + reflect(other) { + let p = new Vector(other.x - this.x, other.y - this.y); + if (other.z !== undefined) { + p.z = other.z; + if (this.z !== undefined) { + p.z -= this.z; + } + } + return this.subtract(p); + } + add(other) { + let p = new Vector(this.x + other.x, this.y + other.y); + if (this.z !== undefined) { + p.z = this.z; + if (other.z !== undefined) { + p.z += other.z; + } + } + return p; + } + subtract(other) { + let p = new Vector(this.x - other.x, this.y - other.y); + if (this.z !== undefined) { + p.z = this.z; + if (other.z !== undefined) { + p.z -= other.z; + } + } + return p; + } + scale(f = 1) { + if (f === 0) { + return new Vector(0, 0, this.z === undefined ? undefined : 0); + } + let p = new Vector(this.x * f, this.y * f); + if (this.z !== undefined) { + p.z = this.z * f; + } + return p; + } + } + + export { Vector }; + \ No newline at end of file